import { PasswordField } from "@govoplan/core-webui"; import { inputValueToFieldValue, normalizeFieldType, valueToInputText } from "../utils/fieldDefinitions"; export type FieldValueInputProps = { fieldType?: string; value: unknown; disabled?: boolean; placeholder?: string; className?: string; onChange: (value: unknown) => void; }; export default function FieldValueInput({ fieldType = "string", value, disabled = false, placeholder, className, onChange }: FieldValueInputProps) { const normalizedType = normalizeFieldType(fieldType); if (normalizedType === "password") { return ( onChange(inputValueToFieldValue(normalizedType, nextValue))} /> ); } const inputType = inputTypeForField(normalizedType); const step = normalizedType === "integer" ? "1" : normalizedType === "double" ? "any" : undefined; return ( onChange(inputValueToFieldValue(normalizedType, event.target.value))} /> ); } function inputTypeForField(fieldType: string): string { if (fieldType === "integer" || fieldType === "double") return "number"; if (fieldType === "date") return "date"; return "text"; }