export function View(props: { title: string; body: string }) { return ` ${props.title} - Shelves ${props.body} `; } export type FormFieldType = 'text' | 'textarea' | 'file' | 'number'; export type FormFieldProps = { name: string; type: FormFieldType; label: string; error?: string; required?: boolean; }; export function FormField(props: FormFieldProps) { const input = () => { const attrs = `name='${props.name}' id="${props.name}" ${ (props.required ?? true) && "required aria-required='true'" }`; if (props.type === 'textarea') { return ``; } else { return ``; } }; return `
${input()}
${ props.error ?? '' }
`; } export function Form( props: { action: string; fields: FormFieldProps[]; hasFileData?: boolean }, ) { return `
${props.fields.map(FormField).join('')}
`; }