import { type ButtonHTMLAttributes, type InputHTMLAttributes, type ReactNode, type SelectHTMLAttributes, type TextareaHTMLAttributes, useEffect } from 'react';
export function Button({
variant = 'default',
...props
}: ButtonHTMLAttributes & { variant?: 'default' | 'primary' | 'danger' | 'ghost' }) {
return ;
}
export function Field(
props: InputHTMLAttributes & { label: string; error?: string | undefined },
) {
const { label, error, ...input } = props;
return (
);
}
export function Textarea(props: TextareaHTMLAttributes & { label: string }) {
const { label, ...textarea } = props;
return (
);
}
export function Select(
props: Omit, 'value' | 'onChange'> & {
label: string;
value: T;
onChange: (v: T) => void;
options: ReadonlyArray<{ value: T; label: string }>;
},
) {
const { label, value, onChange, options, ...sel } = props;
return (
);
}
export function Modal({
open,
title,
onClose,
children,
footer,
}: {
open: boolean;
title: string;
onClose: () => void;
children: ReactNode;
footer?: ReactNode;
}) {
useEffect(() => {
if (!open) return;
const onKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
};
window.addEventListener('keydown', onKey);
return () => window.removeEventListener('keydown', onKey);
}, [open, onClose]);
if (!open) return null;
return (
e.stopPropagation()}>
{children}
{footer ?
: null}
);
}
export function EmptyState({ children }: { children: ReactNode }) {
return {children}
;
}
export function formatRub(cents: number): string {
return (cents / 100).toLocaleString('ru-RU', {
style: 'currency',
currency: 'RUB',
minimumFractionDigits: 2,
});
}