import type { SelectorID } from '../Selector.js' import type { FormItemElement } from './FormItemElement.js' export interface FormSectionElement { id: string header?: string footer?: string items: FormItemElement[] } export type SectionInfo = { id: string header?: string footer?: string } export function Section( params: string | SectionInfo, items: (FormItemElement | undefined)[] ): FormSectionElement { let info: SectionInfo if (typeof params === 'string') { info = { id: params } } else { info = params } return { ...info, items: items.filter((x) => x) as FormItemElement[], } } type ListSectionProps = { items: (FormItemElement | undefined)[] allowDeletion: boolean onRemove: SelectorID<() => Promise> allowAddition: boolean onAdd: SelectorID<() => Promise> allowReorder: boolean onReorder: SelectorID<() => Promise> rowBuilder: (item: unknown) => FormItemElement } // function ListSection(id: string, props: ListSectionProps) { // ListSection('mySection', { // items: [{ value: 'hello', id: 'world' }], // allowDeletion: true, // onRemove: Application.selector(this, 'myItemDidRemove'), // allowAddition: true, // onAdd: Application.selector(this, 'myItemDidAdd'), // rowBuilder: (element) => InputRow('myRow', { // id: element.id, // value: element.value, // placeholder: 'Foo' // }) // }) // }