import { U } from 'ts-toolbelt' import { CollectionInstance } from 'magnetar' import { BlitzFilterOptions, SchemaField } from 'blitzar' export type TableInfo = Record> = { // title: string /** * Pass a Blitzar schema to use for the table columns. * @example schemaFormAdd: [{ id: 'name', label: 'Name', component: 'input' }] */ schemaColumns: SchemaField[] // /** // * Pass a Blitzar schema to use for the grid cards. // * // * Otherwise use `componentForm` // * @example schemaFormAdd: [{ id: 'name', label: 'Name', component: 'input' }] // */ // schemaGrid: Field[] // /** // * Pass a Blitzar schema to use for adding. // * @example schemaFormAdd: [{ id: 'name', label: 'Name', component: 'input' }] // */ // schemaFormAdd?: SchemaField[] // /** // * Pass a Blitzar schema to use for editing. // * @example schemaFormEdit: [{ id: 'name', label: 'Name', component: 'input' }] // */ // schemaFormEdit?: SchemaField[] /** * Pass an actual Vue component to use for editing / adding. * * Otherwise use `schemaFormEdit` / `schemaFormAdd` * @example componentForm: markRaw(MyForm) */ componentForm?: any componentProps?: (formData: T) => Record // componentUi?: Field db: CollectionInstance | CollectionInstance[] filterOptions?: BlitzFilterOptions // labelDic?: Record | ComputedRef> /** * `mapRow` can map stuff on your rows * * @example * ```js * mapRow: (row) => { * const profile = dbProfiles.doc(row.id).data * return { ...row, profile } * }, * ``` */ mapRow?: (row: T) => T & Record onSave?: (newData: Partial, formData: T) => Promise /** * An optional function that is executed after the initial records are fetched. * * Should be used to fetch additional records based on the info shown in the table. * * Must return the number of additional records that were fetched. */ afterFetch?: (newData: Map) => Promise } export type SortState = { id: string direction: 'asc' | 'desc' parseValue?: (val: any, context: { formData: Record }) => any }[]