import React from 'react'; import classNames from 'classnames'; type CommonProps = { label: React.ReactNode; error?: React.ReactNode; }; type TextInputProps = { value: string; onChange: (value: string) => void; } type HTMLInputProps = Omit, 'onChange' | 'label'>; function BaseInput({label, value, onChange, error, ...props}: CommonProps & HTMLInputProps & TextInputProps) { const id = React.useId(); const handleChange = React.useCallback( (e: React.ChangeEvent) => onChange(e.target.value), [onChange], ); return
{error &&
{error}
}
; } export function TextInput(props: CommonProps & TextInputProps) { return ; } export function NumberInput({value, onChange, ...props}: CommonProps & { value: number; onChange: (value: number) => void; min?: number; max?: number; }) { const handleChange = React.useCallback((value: string) => onChange(+value), [onChange]); return ; }