UNPKG

alinea

Version:
40 lines (39 loc) 1.32 kB
import type { ComponentType } from 'react'; import { Field } from './Field.js'; import type { View } from './View.js'; export interface SectionDefinition { [key: string]: Field<any, any> | Section; } export interface SectionData { definition: SectionDefinition; fields: Record<string, Field>; sections: Array<Section>; view?: View<{ section: Section; }>; } export interface SectionI extends Record<string, Field> { } export declare class SectionI { get [Section.Data](): SectionData; } export type Section<Fields = object> = Fields & SectionI; export type SectionView<Fields> = ComponentType<{ section: Section<Fields>; }>; export declare namespace Section { const Data: unique symbol; function view(section: Section): View<{ section: Section; }> | undefined; function referencedViews(section: Section): Array<string>; function definition(section: Section): SectionDefinition; function fields(section: Section): Record<string, Field<any, any, any, any>>; function isSection(value: any): value is Section; } interface SectionOptions extends Omit<SectionData, 'fields' | 'sections'> { fields?: Record<string, Field>; sections?: Array<Section>; } export declare function section<Fields>(data: SectionOptions): Section<Fields>; export {};