'use client' import type { ComponentProps, ReactNode } from 'react' import { Description, FieldError, Label, NumberField } from '@heroui/react' import { cn } from '@/lib/cn' type NumberInputProps = Omit, 'children' | 'className' | 'onChange' | 'variant'> & { className?: string classNames?: { inputWrapper?: string; label?: string; input?: string } description?: ReactNode descriptionClassName?: string endContent?: ReactNode errorMessage?: ReactNode formatOptions?: Intl.NumberFormatOptions isClearable?: boolean label?: ReactNode radius?: 'none' | 'sm' | 'md' | 'lg' | 'full' size?: 'sm' | 'md' | 'lg' startContent?: ReactNode variant?: 'flat' | 'bordered' | 'faded' | 'underlined' onClear?: () => void onValueChange?: (value: number) => void } function radiusClass(radius: NumberInputProps['radius'], variant: NumberInputProps['variant']): string { if (variant === 'underlined') return 'rounded-none' if (!radius) return '' if (radius === 'none') return 'rounded-none' if (radius === 'full') return 'rounded-full' if (radius === 'lg') return 'rounded-2xl' if (radius === 'sm') return 'rounded-md' return 'rounded-lg' } export function NumberInput({ className, classNames, description, descriptionClassName, endContent, errorMessage, isClearable, isInvalid, label, radius, size, startContent, variant, value, onClear, onValueChange, ...props }: NumberInputProps) { return ( {label ? : null} {startContent} {isClearable && value !== undefined && value !== null ? ( ) : ( endContent )} {description ? {description} : null} {isInvalid && errorMessage ? {errorMessage} : null} ) }