"use client"; import * as React from "react"; import { cn } from "@/lib/utils"; import { formatMoneyGrouped, parseMoneyInput, toRialInteger } from "@/lib/utils"; export function Select({ className, children, ...props }: React.SelectHTMLAttributes) { return ( ); } export function FormField({ label, error, children, className, }: { label?: string; error?: string; children: React.ReactNode; className?: string; }) { return (
{label ? : null} {children} {error ?

{error}

: null}
); } export function Checkbox({ label, className, ...props }: React.InputHTMLAttributes & { label?: string }) { return ( ); } /** * Money field with live thousand separators. * RHF value stays as plain integer Rial digits (e.g. "1500000"); display shows "1,500,000". * No decimal places — Iranian Rial. */ export const MoneyInput = React.forwardRef< HTMLInputElement, Omit, "type"> >(function MoneyInput({ className, value, defaultValue, onChange, onBlur, ...props }, ref) { const isControlled = value !== undefined; const [inner, setInner] = React.useState(() => toRialInteger(defaultValue != null ? String(defaultValue) : "") ); const raw = isControlled ? toRialInteger(value == null ? "" : String(value)) : inner; const display = formatMoneyGrouped(raw); return ( { // Keep typing fluid; strip non-digits / separators, then integerize. const parsed = toRialInteger(parseMoneyInput(e.target.value)); if (!isControlled) setInner(parsed); e.target.value = parsed; onChange?.(e); }} onBlur={(e) => { const parsed = toRialInteger(e.target.value); if (!isControlled) setInner(parsed); e.target.value = parsed; onBlur?.(e); }} /> ); });