(
({ value, onChange, currency = 'USD', className, ...props }, ref) => {
const symbol = currencySymbol(currency);
// react-number-format wants undefined (not null) to render empty.
const formatValue =
value === null || value === undefined || value === '' ? undefined : Number(value);
return (
{symbol}
{
// floatValue is undefined when input is empty.
onChange(values.floatValue ?? null);
}}
className={cn('pl-9 tabular-nums', className)}
{...props}
/>
);
},
);
CurrencyInput.displayName = 'CurrencyInput';