import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectOption } from "@/components/ui/select"; import { Switch } from "@/components/ui/switch"; function FieldHint({ schema, schemaKey }: { schema: Record; schemaKey: string }) { const keyPath = schemaKey.includes(".") ? schemaKey : ""; const description = schema.description ? String(schema.description) : ""; if (!keyPath && !description) return null; return (
{keyPath && {keyPath}} {description && {description}}
); } export function AutoField({ schemaKey, schema, value, onChange, }: AutoFieldProps) { const rawLabel = schemaKey.split(".").pop() ?? schemaKey; const label = rawLabel.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()); if (schema.type === "boolean") { return (
); } if (schema.type === "select") { const options = (schema.options as string[]) ?? []; return (
); } if (schema.type === "number") { return (
{ const raw = e.target.value; if (raw === "") { onChange(0); return; } const n = Number(raw); if (!Number.isNaN(n)) { onChange(n); } }} />
); } if (schema.type === "text") { return (