UNPKG

alinea

Version:
40 lines (39 loc) 1.27 kB
import type { ComponentType } from 'react'; import type { Label } from './Label.js'; import type { Reference } from './Reference.js'; import type { Type } from './Type.js'; import type { PostProcess } from './pages/PostProcess.js'; import type { RecordShape } from './shape/RecordShape.js'; export interface PickerProps<T = any> { type: string; options: T; selection: Array<Reference> | undefined; onConfirm(value: Array<Reference> | undefined): void; onCancel(): void; } export interface PickerRow { id: string; type: string; entry?: string; url?: string; description?: string; target?: string; } export interface Picker<StoredValue extends Reference, Options extends {} = {}> { shape: RecordShape; fields: Type<any> | undefined; label: Label; handlesMultiple: boolean; options: Options; view?: ComponentType<PickerProps<Options>>; viewRow?: ComponentType<{ reference: StoredValue; }>; postProcess?: PostProcess<StoredValue>; } export declare function pickerWithView<R extends Reference, T extends {}, C extends (...args: Array<any>) => Picker<R, T>>(create: C, views: { view: ComponentType<PickerProps<T>>; viewRow: ComponentType<{ reference: R; }>; }): C;