UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

38 lines (37 loc) 1.37 kB
import { ComponentType } from 'react'; import { Field } from './Field.js'; export interface SectionDefinition { [key: string]: Field<any, any> | Section; } export interface SectionData { definition: SectionDefinition; fields: Record<string, Field>; view?: ComponentType<{ 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; const PREFIX = "@@@"; function provideView<Fields, Factory extends (...args: Array<any>) => Section<Fields>>(view: SectionView<Fields>, factory: Factory): Factory; function view(section: Section): ComponentType<{ section: Section<object>; }> | undefined; function definition(section: Section): SectionDefinition; function fields(section: Section): Record<string, Field<any, any, import("./Field.js").FieldOptions<any>>>; function isSection(value: any): value is Section; } interface SectionOptions extends Omit<SectionData, 'fields'> { fields?: Record<string, Field>; } export declare function section<Fields>(data: SectionOptions): Section<Fields>; export {};