Mohammad Khyata e1ef6fa2ea fix many bugs
Co-authored-by: Copilot <copilot@github.com>
2026-04-30 19:03:31 +03:00

37 lines
835 B
TypeScript

import type { BaseFieldControlProps } from "../types"
import { Input } from "@/shared/components/ui/input"
export type TextInputFieldProps = BaseFieldControlProps<string> & {
placeholder?: string
type?: React.HTMLInputTypeAttribute
step?: React.InputHTMLAttributes<HTMLInputElement>["step"]
formatter?: (value: string) => string
}
export function TextInputField({
value,
onChange,
onBlur,
name,
disabled,
invalid,
placeholder,
type = "text",
step,
formatter,
}: TextInputFieldProps) {
return (
<Input
value={value}
onChange={(e) => onChange(formatter ? formatter(e.target.value) : e.target.value)}
onBlur={onBlur}
name={name}
disabled={disabled}
aria-invalid={invalid || undefined}
placeholder={placeholder}
type={type}
step={step}
/>
)
}