'use client' import { Input } from '@/components/ui/input' import { Textarea } from '@/components/ui/textarea' import { Checkbox } from '@/components/ui/checkbox' import { Label } from '@/components/ui/label' import type { FormField } from '@/lib/forms-schema' // Renders a form's field schema as a controlled, fillable form. Shared by the // builder's live preview and the public /f/[slug] page so the two can never // drift. export function FormRenderer({ fields, values, onChange, disabled, idPrefix = 'f', }: { fields: FormField[] values: Record onChange: (key: string, value: unknown) => void disabled?: boolean idPrefix?: string }) { if (fields.length === 0) { return (

No fields yet. Add one to see it here.

) } return (
{fields.map(field => { const id = `${idPrefix}-${field.key}` const v = values[field.key] return (
{field.type !== 'checkbox' && ( )} {field.type === 'short_text' && ( onChange(field.key, e.target.value)} /> )} {field.type === 'long_text' && (