"use client"; import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText, } from "@/components/ui/input-group"; import { formatMoneyInput, parseMoney } from "@/shared/money"; /** * Türkçe tutar girişi ("1.250,50"). Değer string olarak tutulur (zod sunucuda/istemcide ayrıştırır); * alandan çıkınca geçerliyse Türkçe biçime getirilir. */ export function MoneyInput({ value, onChange, onBlur, allowNegative = false, ...props }: Omit, "value" | "onChange" | "type"> & { value: string; onChange: (value: string) => void; allowNegative?: boolean; }) { return ( onChange(e.target.value.replace(allowNegative ? /[^\d.,\s-−]/g : /[^\d.,\s]/g, "")) } onBlur={(e) => { const minor = parseMoney(value); if (minor !== null && value.trim() !== "") onChange(formatMoneyInput(minor)); onBlur?.(e); }} /> ₺ ); }