import type { ComponentProps } from 'react';
import { cn } from '@/lib/utils';

/** Text input for naira amounts with a ₦ prefix and a numeric keypad on phones. */
export default function NairaInput({
    className,
    ...props
}: Omit<ComponentProps<'input'>, 'type' | 'inputMode'>) {
    return (
        <div className="relative">
            <span
                aria-hidden="true"
                className="pointer-events-none absolute inset-y-0 left-3 flex items-center text-sm text-ink-400"
            >
                ₦
            </span>
            <input
                type="text"
                inputMode="decimal"
                autoComplete="off"
                pattern="[0-9]+([.][0-9]{1,2})?"
                className={cn(
                    'h-10 w-full rounded-md border border-input bg-white pr-3 pl-7 text-sm text-ink tabular-nums shadow-xs outline-none placeholder:text-ink-300 focus-visible:border-brand focus-visible:ring-3 focus-visible:ring-brand/15 aria-invalid:border-red-500',
                    className,
                )}
                {...props}
            />
        </div>
    );
}
