Open History to see the last commit
1import type { FunctionComponent } from 'react'
2β
3/**
4 * A recursively nested collection of components registered with
5 * `createFormHook`.
6 *
7 * Component trees are inferred from `fieldComponents` and `formComponents` in
8 * normal usage. This type is primarily useful when building wrappers around
9 * `createFormHook` or declaring reusable component registries.
10 *
11 * @example
12 * ```tsx
13 * const fields = {
14 * inputs: {
15 * TextField,
16 * },
17 * } satisfies ReactComponentTree
18 * ```
19 */
20export type ReactComponentTree = {
21 readonly [name: string]: FunctionComponent<any> | ReactComponentTree
22}
23β
24export interface ReactFormComponentMap<
25 in out TFormComponents extends ReactComponentTree,
26 in out TFieldComponents extends ReactComponentTree,
27> {
28 /** Components and component namespaces exposed on each App Form API. */
29 formComponents: TFormComponents
30 /** Components and component namespaces exposed on each App Field API. */
31 fieldComponents: TFieldComponents
32}
33β
34export type AnyReactFormComponentMap = ReactFormComponentMap<
35 ReactComponentTree,
36 ReactComponentTree
37>
38β
39export type DefaultReactFormComponentMap = ReactFormComponentMap<
40 Record<never, never>,
41 Record<never, never>
42>