@schema-engine/forms-react 0.0.0-stage → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +87 -2
- package/dist/chunk-5XCNXEJB.js +19 -0
- package/dist/chunk-5XCNXEJB.js.map +7 -0
- package/dist/chunk-6RI4LMM6.js +19 -0
- package/dist/chunk-6RI4LMM6.js.map +7 -0
- package/dist/chunk-7QNWPTT7.js +20 -0
- package/dist/chunk-7QNWPTT7.js.map +7 -0
- package/dist/chunk-7RUFT6EJ.js +39 -0
- package/dist/chunk-7RUFT6EJ.js.map +7 -0
- package/dist/chunk-AALIXTCD.js +56 -0
- package/dist/chunk-AALIXTCD.js.map +7 -0
- package/dist/chunk-CPJMN2IH.js +128 -0
- package/dist/chunk-CPJMN2IH.js.map +7 -0
- package/dist/chunk-DTJ64NZQ.js +142 -0
- package/dist/chunk-DTJ64NZQ.js.map +7 -0
- package/dist/chunk-EYDB6NR6.js +9 -0
- package/dist/chunk-EYDB6NR6.js.map +7 -0
- package/dist/chunk-GH2QO3WC.js +11 -0
- package/dist/chunk-GH2QO3WC.js.map +7 -0
- package/dist/chunk-H25SUEJE.js +8 -0
- package/dist/chunk-H25SUEJE.js.map +7 -0
- package/dist/chunk-HT43MPKW.js +0 -0
- package/dist/chunk-HT43MPKW.js.map +7 -0
- package/dist/chunk-IHX6VMAQ.js +0 -0
- package/dist/chunk-IHX6VMAQ.js.map +7 -0
- package/dist/chunk-ISDPSORR.js +265 -0
- package/dist/chunk-ISDPSORR.js.map +7 -0
- package/dist/chunk-IXRV3YCF.js +36 -0
- package/dist/chunk-IXRV3YCF.js.map +7 -0
- package/dist/chunk-K3LLWGXU.js +30 -0
- package/dist/chunk-K3LLWGXU.js.map +7 -0
- package/dist/chunk-K66J2V73.js +108 -0
- package/dist/chunk-K66J2V73.js.map +7 -0
- package/dist/chunk-KG6Q7MNI.js +51 -0
- package/dist/chunk-KG6Q7MNI.js.map +7 -0
- package/dist/chunk-MBN4WIAC.js +41 -0
- package/dist/chunk-MBN4WIAC.js.map +7 -0
- package/dist/chunk-NDFV5AQW.js +39 -0
- package/dist/chunk-NDFV5AQW.js.map +7 -0
- package/dist/chunk-QUZN42PL.js +128 -0
- package/dist/chunk-QUZN42PL.js.map +7 -0
- package/dist/chunk-SED35QJC.js +78 -0
- package/dist/chunk-SED35QJC.js.map +7 -0
- package/dist/chunk-ULKJHK3P.js +6 -0
- package/dist/chunk-ULKJHK3P.js.map +7 -0
- package/dist/chunk-USRF3EEE.js +122 -0
- package/dist/chunk-USRF3EEE.js.map +7 -0
- package/dist/chunk-WFRWVH4X.js +44 -0
- package/dist/chunk-WFRWVH4X.js.map +7 -0
- package/dist/chunk-WOTW7A2I.js +7 -0
- package/dist/chunk-WOTW7A2I.js.map +7 -0
- package/dist/chunk-WRJWSEL7.js +98 -0
- package/dist/chunk-WRJWSEL7.js.map +7 -0
- package/dist/chunk-XWHP2AGG.js +7 -0
- package/dist/chunk-XWHP2AGG.js.map +7 -0
- package/dist/chunk-ZWEYALBG.js +25 -0
- package/dist/chunk-ZWEYALBG.js.map +7 -0
- package/dist/components/form-debugger/form-debugger.css +374 -0
- package/dist/components/form-debugger/form-debugger.css.map +7 -0
- package/dist/components/form-debugger/form-debugger.d.ts +23 -0
- package/dist/components/form-debugger/form-debugger.js +17 -0
- package/dist/components/form-debugger/form-debugger.js.map +7 -0
- package/dist/components/form-debugger/index.css +374 -0
- package/dist/components/form-debugger/index.css.map +7 -0
- package/dist/components/form-debugger/index.d.ts +2 -0
- package/dist/components/form-debugger/index.js +17 -0
- package/dist/components/form-debugger/index.js.map +7 -0
- package/dist/components/form-engine-provider.d.ts +7 -0
- package/dist/components/form-engine-provider.js +7 -0
- package/dist/components/form-engine-provider.js.map +7 -0
- package/dist/components/form-provider.d.ts +23 -0
- package/dist/components/form-provider.js +13 -0
- package/dist/components/form-provider.js.map +7 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +43 -0
- package/dist/components/index.js.map +7 -0
- package/dist/components/internals/element-error.d.ts +9 -0
- package/dist/components/internals/element-error.js +6 -0
- package/dist/components/internals/element-error.js.map +7 -0
- package/dist/components/internals/field-renderer.d.ts +26 -0
- package/dist/components/internals/field-renderer.js +24 -0
- package/dist/components/internals/field-renderer.js.map +7 -0
- package/dist/components/internals/form-elements.d.ts +20 -0
- package/dist/components/internals/form-elements.js +25 -0
- package/dist/components/internals/form-elements.js.map +7 -0
- package/dist/components/internals/form-renderer.d.ts +28 -0
- package/dist/components/internals/form-renderer.js +31 -0
- package/dist/components/internals/form-renderer.js.map +7 -0
- package/dist/components/internals/recipe-renderer.d.ts +10 -0
- package/dist/components/internals/recipe-renderer.js +17 -0
- package/dist/components/internals/recipe-renderer.js.map +7 -0
- package/dist/components/provider.d.ts +18 -0
- package/dist/components/provider.js +8 -0
- package/dist/components/provider.js.map +7 -0
- package/dist/contexts/field-constraint-context.d.ts +15 -0
- package/dist/contexts/field-constraint-context.js +6 -0
- package/dist/contexts/field-constraint-context.js.map +7 -0
- package/dist/contexts/index.d.ts +2 -0
- package/dist/contexts/index.js +6 -0
- package/dist/contexts/index.js.map +7 -0
- package/dist/contexts/view-context.d.ts +14 -0
- package/dist/contexts/view-context.js +16 -0
- package/dist/contexts/view-context.js.map +7 -0
- package/dist/global.css +8 -0
- package/dist/hooks/field-text.d.ts +6 -0
- package/dist/hooks/field-text.js +6 -0
- package/dist/hooks/field-text.js.map +7 -0
- package/dist/hooks/form-state/context.d.ts +27 -0
- package/dist/hooks/form-state/context.js +10 -0
- package/dist/hooks/form-state/context.js.map +7 -0
- package/dist/hooks/form-state/field-registry.d.ts +60 -0
- package/dist/hooks/form-state/field-registry.js +9 -0
- package/dist/hooks/form-state/field-registry.js.map +7 -0
- package/dist/hooks/form-state/index.d.ts +8 -0
- package/dist/hooks/form-state/index.js +27 -0
- package/dist/hooks/form-state/index.js.map +7 -0
- package/dist/hooks/form-state/native-control.d.ts +39 -0
- package/dist/hooks/form-state/native-control.js +17 -0
- package/dist/hooks/form-state/native-control.js.map +7 -0
- package/dist/hooks/form-state/types.d.ts +191 -0
- package/dist/hooks/form-state/types.js +0 -0
- package/dist/hooks/form-state/types.js.map +7 -0
- package/dist/hooks/form-state/use-field-array.d.ts +12 -0
- package/dist/hooks/form-state/use-field-array.js +7 -0
- package/dist/hooks/form-state/use-field-array.js.map +7 -0
- package/dist/hooks/form-state/use-form-context.d.ts +10 -0
- package/dist/hooks/form-state/use-form-context.js +7 -0
- package/dist/hooks/form-state/use-form-context.js.map +7 -0
- package/dist/hooks/form-state/use-form-field.d.ts +24 -0
- package/dist/hooks/form-state/use-form-field.js +11 -0
- package/dist/hooks/form-state/use-form-field.js.map +7 -0
- package/dist/hooks/form-state/use-watch.d.ts +12 -0
- package/dist/hooks/form-state/use-watch.js +7 -0
- package/dist/hooks/form-state/use-watch.js.map +7 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.js +78 -0
- package/dist/hooks/index.js.map +7 -0
- package/dist/hooks/is-element-required.d.ts +5 -0
- package/dist/hooks/is-element-required.js +6 -0
- package/dist/hooks/is-element-required.js.map +7 -0
- package/dist/hooks/use-debounce.d.ts +14 -0
- package/dist/hooks/use-debounce.js +8 -0
- package/dist/hooks/use-debounce.js.map +7 -0
- package/dist/hooks/use-field.d.ts +44 -0
- package/dist/hooks/use-field.js +16 -0
- package/dist/hooks/use-field.js.map +7 -0
- package/dist/hooks/use-form-context.d.ts +63 -0
- package/dist/hooks/use-form-context.js +18 -0
- package/dist/hooks/use-form-context.js.map +7 -0
- package/dist/hooks/use-mobile.d.ts +9 -0
- package/dist/hooks/use-mobile.js +6 -0
- package/dist/hooks/use-mobile.js.map +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +7 -0
- package/dist/lib/logger.d.ts +2 -0
- package/dist/lib/object-identity.d.ts +6 -0
- package/dist/primitives.d.ts +28 -0
- package/dist/primitives.js +37 -0
- package/dist/primitives.js.map +7 -0
- package/package.json +139 -3
- package/skill/SKILL.md +79 -0
- package/skill/reference/forms-react-widgets.md +222 -0
- package/skill/reference/forms-react.md +92 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import "../chunk-IHX6VMAQ.js";
|
|
2
|
+
import {
|
|
3
|
+
FormRenderer
|
|
4
|
+
} from "../chunk-QUZN42PL.js";
|
|
5
|
+
import "../chunk-SED35QJC.js";
|
|
6
|
+
import "../chunk-K3LLWGXU.js";
|
|
7
|
+
import "../chunk-KG6Q7MNI.js";
|
|
8
|
+
import "../chunk-HT43MPKW.js";
|
|
9
|
+
import "../chunk-7RUFT6EJ.js";
|
|
10
|
+
import "../chunk-WFRWVH4X.js";
|
|
11
|
+
import "../chunk-7QNWPTT7.js";
|
|
12
|
+
import "../chunk-WOTW7A2I.js";
|
|
13
|
+
import "../chunk-ULKJHK3P.js";
|
|
14
|
+
import "../chunk-NDFV5AQW.js";
|
|
15
|
+
import "../chunk-MBN4WIAC.js";
|
|
16
|
+
import "../chunk-K66J2V73.js";
|
|
17
|
+
import "../chunk-DTJ64NZQ.js";
|
|
18
|
+
import "../chunk-EYDB6NR6.js";
|
|
19
|
+
import "../chunk-IXRV3YCF.js";
|
|
20
|
+
import {
|
|
21
|
+
FormEngineProvider
|
|
22
|
+
} from "../chunk-6RI4LMM6.js";
|
|
23
|
+
import {
|
|
24
|
+
FormProvider
|
|
25
|
+
} from "../chunk-WRJWSEL7.js";
|
|
26
|
+
import "../chunk-USRF3EEE.js";
|
|
27
|
+
import "../chunk-CPJMN2IH.js";
|
|
28
|
+
import "../chunk-H25SUEJE.js";
|
|
29
|
+
import "../chunk-XWHP2AGG.js";
|
|
30
|
+
import "../chunk-AALIXTCD.js";
|
|
31
|
+
import "../chunk-ZWEYALBG.js";
|
|
32
|
+
import {
|
|
33
|
+
FormEngineContext,
|
|
34
|
+
createFormEngineContextValue
|
|
35
|
+
} from "../chunk-GH2QO3WC.js";
|
|
36
|
+
import "../chunk-5XCNXEJB.js";
|
|
37
|
+
export {
|
|
38
|
+
FormEngineContext,
|
|
39
|
+
FormEngineProvider,
|
|
40
|
+
FormProvider,
|
|
41
|
+
FormRenderer,
|
|
42
|
+
createFormEngineContextValue
|
|
43
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface ElementErrorProps {
|
|
3
|
+
title: string;
|
|
4
|
+
message: string;
|
|
5
|
+
componentType?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
export declare function ElementError({ title, message, componentType, className, style }: ElementErrorProps): React.JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { type NormalizedElementConfig } from '@schema-engine/forms';
|
|
3
|
+
export interface FormElementProps {
|
|
4
|
+
/**
|
|
5
|
+
* Element from a `NormalizedFormConfig` or `engine.validateElement`.
|
|
6
|
+
* Authoring JSON is not accepted.
|
|
7
|
+
*/
|
|
8
|
+
config: NormalizedElementConfig;
|
|
9
|
+
/** Render-time field path. The frozen config is not cloned. */
|
|
10
|
+
name?: string;
|
|
11
|
+
/** Render-time HTML id. Prefer a stable instance id, not an array index. */
|
|
12
|
+
id?: string;
|
|
13
|
+
/** Stable array-item identity forwarded to nested containers. */
|
|
14
|
+
instanceId?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Renders a registered element. Config must already be normalized.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Whether the element is shown or disabled is the container's: `selectFieldState` says it, from the one ordered
|
|
23
|
+
* evaluation of the form's constraints, with the constraints of the containers around the element folded in.
|
|
24
|
+
* A field that takes no part is not rendered.
|
|
25
|
+
*/
|
|
26
|
+
export declare function FormElement({ config, name, id, instanceId, className, style }: FormElementProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FormElement
|
|
3
|
+
} from "../../chunk-KG6Q7MNI.js";
|
|
4
|
+
import "../../chunk-HT43MPKW.js";
|
|
5
|
+
import "../../chunk-7RUFT6EJ.js";
|
|
6
|
+
import "../../chunk-WFRWVH4X.js";
|
|
7
|
+
import "../../chunk-7QNWPTT7.js";
|
|
8
|
+
import "../../chunk-WOTW7A2I.js";
|
|
9
|
+
import "../../chunk-ULKJHK3P.js";
|
|
10
|
+
import "../../chunk-NDFV5AQW.js";
|
|
11
|
+
import "../../chunk-MBN4WIAC.js";
|
|
12
|
+
import "../../chunk-K66J2V73.js";
|
|
13
|
+
import "../../chunk-DTJ64NZQ.js";
|
|
14
|
+
import "../../chunk-EYDB6NR6.js";
|
|
15
|
+
import "../../chunk-IXRV3YCF.js";
|
|
16
|
+
import "../../chunk-H25SUEJE.js";
|
|
17
|
+
import "../../chunk-XWHP2AGG.js";
|
|
18
|
+
import "../../chunk-AALIXTCD.js";
|
|
19
|
+
import "../../chunk-ZWEYALBG.js";
|
|
20
|
+
import "../../chunk-GH2QO3WC.js";
|
|
21
|
+
import "../../chunk-5XCNXEJB.js";
|
|
22
|
+
export {
|
|
23
|
+
FormElement
|
|
24
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { type FieldScope, type NormalizedElementConfig } from '@schema-engine/forms';
|
|
3
|
+
export interface FormElementsProps {
|
|
4
|
+
elements: ReadonlyArray<NormalizedElementConfig>;
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
/**
|
|
8
|
+
* Object scope (`address`) or array-item scope (`contacts.0`).
|
|
9
|
+
* Fieldsets pass `config.name`; array items pass `${config.name}.${index}`.
|
|
10
|
+
*/
|
|
11
|
+
namePrefix?: string;
|
|
12
|
+
/**
|
|
13
|
+
* `join` (default): `${namePrefix}.${child.name}`.
|
|
14
|
+
* `replace`: scalar array items bind to `namePrefix` itself.
|
|
15
|
+
*/
|
|
16
|
+
nameStrategy?: FieldScope['nameStrategy'];
|
|
17
|
+
/** Stable array-item identity. Do not pass the item index. */
|
|
18
|
+
instanceId?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function FormElements({ elements, className, style, namePrefix, nameStrategy, instanceId }: FormElementsProps): React.JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FormElements
|
|
3
|
+
} from "../../chunk-K3LLWGXU.js";
|
|
4
|
+
import "../../chunk-KG6Q7MNI.js";
|
|
5
|
+
import "../../chunk-HT43MPKW.js";
|
|
6
|
+
import "../../chunk-7RUFT6EJ.js";
|
|
7
|
+
import "../../chunk-WFRWVH4X.js";
|
|
8
|
+
import "../../chunk-7QNWPTT7.js";
|
|
9
|
+
import "../../chunk-WOTW7A2I.js";
|
|
10
|
+
import "../../chunk-ULKJHK3P.js";
|
|
11
|
+
import "../../chunk-NDFV5AQW.js";
|
|
12
|
+
import "../../chunk-MBN4WIAC.js";
|
|
13
|
+
import "../../chunk-K66J2V73.js";
|
|
14
|
+
import "../../chunk-DTJ64NZQ.js";
|
|
15
|
+
import "../../chunk-EYDB6NR6.js";
|
|
16
|
+
import "../../chunk-IXRV3YCF.js";
|
|
17
|
+
import "../../chunk-H25SUEJE.js";
|
|
18
|
+
import "../../chunk-XWHP2AGG.js";
|
|
19
|
+
import "../../chunk-AALIXTCD.js";
|
|
20
|
+
import "../../chunk-ZWEYALBG.js";
|
|
21
|
+
import "../../chunk-GH2QO3WC.js";
|
|
22
|
+
import "../../chunk-5XCNXEJB.js";
|
|
23
|
+
export {
|
|
24
|
+
FormElements
|
|
25
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { FormProviderProps } from '../../hooks/form-state/types';
|
|
3
|
+
import { type EngineOutputMaps, type FormEngineRuntime as FormEngine, type FormValues, type NormalizedFormConfig, type FormConfig } from '@schema-engine/forms';
|
|
4
|
+
/**
|
|
5
|
+
* @template TValues - The values the form submits, which the normalized `config` carries: `onSubmit`, `onAction` and
|
|
6
|
+
* `defaultValues` are typed by it. A config passed as authoring input has none, so they are {@link FormValues}.
|
|
7
|
+
*/
|
|
8
|
+
export interface FormRendererProps<TElements extends Record<string, unknown> = Record<string, unknown>, TRecipes extends Record<string, unknown> = Record<string, unknown>, TActions extends Record<string, unknown> = Record<string, unknown>, TOutputs extends EngineOutputMaps = EngineOutputMaps, TValues extends FormValues = FormValues> extends Omit<FormProviderProps<TOutputs, TValues>, 'children' | 'config'> {
|
|
9
|
+
/**
|
|
10
|
+
* The form: the normalized config of `engine.defineForm` or `engine.validateForm`, or an authoring config.
|
|
11
|
+
*
|
|
12
|
+
* @remarks An authoring config carries no values type, so it is accepted only where `TValues` is {@link FormValues}: a callback typed by other values needs a normalized config that says so.
|
|
13
|
+
*/
|
|
14
|
+
config: NormalizedFormConfig<TOutputs['elements'], TOutputs['recipes'], TOutputs['actions'], TValues> | (FormValues extends TValues ? FormConfig<TElements, TRecipes, TActions> : never);
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
engine?: FormEngine<TElements, TRecipes, TActions, TOutputs>;
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Renders a form: its fields, its recipe and the provider that runs it.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* A normalized config (`engine.defineForm`, or `engine.validateForm` with a `values` schema) types `onSubmit`,
|
|
25
|
+
* `onAction` and `defaultValues` by the values it carries, so a callback needs no annotation and no cast. Validating a
|
|
26
|
+
* normalized config returns it unchanged, so it keeps that type; an authoring config has none and is {@link FormValues}.
|
|
27
|
+
*/
|
|
28
|
+
export declare function FormRenderer<TElements extends Record<string, unknown> = Record<string, unknown>, TRecipes extends Record<string, unknown> = Record<string, unknown>, TActions extends Record<string, unknown> = Record<string, unknown>, TOutputs extends EngineOutputMaps = EngineOutputMaps, TValues extends FormValues = FormValues>({ engine, ...props }: FormRendererProps<TElements, TRecipes, TActions, TOutputs, TValues>): React.JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FormRenderer
|
|
3
|
+
} from "../../chunk-QUZN42PL.js";
|
|
4
|
+
import "../../chunk-SED35QJC.js";
|
|
5
|
+
import "../../chunk-K3LLWGXU.js";
|
|
6
|
+
import "../../chunk-KG6Q7MNI.js";
|
|
7
|
+
import "../../chunk-HT43MPKW.js";
|
|
8
|
+
import "../../chunk-7RUFT6EJ.js";
|
|
9
|
+
import "../../chunk-WFRWVH4X.js";
|
|
10
|
+
import "../../chunk-7QNWPTT7.js";
|
|
11
|
+
import "../../chunk-WOTW7A2I.js";
|
|
12
|
+
import "../../chunk-ULKJHK3P.js";
|
|
13
|
+
import "../../chunk-NDFV5AQW.js";
|
|
14
|
+
import "../../chunk-MBN4WIAC.js";
|
|
15
|
+
import "../../chunk-K66J2V73.js";
|
|
16
|
+
import "../../chunk-DTJ64NZQ.js";
|
|
17
|
+
import "../../chunk-EYDB6NR6.js";
|
|
18
|
+
import "../../chunk-IXRV3YCF.js";
|
|
19
|
+
import "../../chunk-6RI4LMM6.js";
|
|
20
|
+
import "../../chunk-WRJWSEL7.js";
|
|
21
|
+
import "../../chunk-USRF3EEE.js";
|
|
22
|
+
import "../../chunk-CPJMN2IH.js";
|
|
23
|
+
import "../../chunk-H25SUEJE.js";
|
|
24
|
+
import "../../chunk-XWHP2AGG.js";
|
|
25
|
+
import "../../chunk-AALIXTCD.js";
|
|
26
|
+
import "../../chunk-ZWEYALBG.js";
|
|
27
|
+
import "../../chunk-GH2QO3WC.js";
|
|
28
|
+
import "../../chunk-5XCNXEJB.js";
|
|
29
|
+
export {
|
|
30
|
+
FormRenderer
|
|
31
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { type FormConfigView, type RecipeRegistration } from '@schema-engine/forms';
|
|
3
|
+
interface RecipeRendererProps {
|
|
4
|
+
config: FormConfigView;
|
|
5
|
+
recipe: RecipeRegistration | undefined;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
renderFields: () => React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function RecipeRenderer({ config, recipe, children, renderFields }: RecipeRendererProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RecipeRenderer
|
|
3
|
+
} from "../../chunk-SED35QJC.js";
|
|
4
|
+
import "../../chunk-ULKJHK3P.js";
|
|
5
|
+
import "../../chunk-NDFV5AQW.js";
|
|
6
|
+
import "../../chunk-MBN4WIAC.js";
|
|
7
|
+
import "../../chunk-K66J2V73.js";
|
|
8
|
+
import "../../chunk-DTJ64NZQ.js";
|
|
9
|
+
import "../../chunk-EYDB6NR6.js";
|
|
10
|
+
import "../../chunk-IXRV3YCF.js";
|
|
11
|
+
import "../../chunk-XWHP2AGG.js";
|
|
12
|
+
import "../../chunk-AALIXTCD.js";
|
|
13
|
+
import "../../chunk-ZWEYALBG.js";
|
|
14
|
+
import "../../chunk-GH2QO3WC.js";
|
|
15
|
+
export {
|
|
16
|
+
RecipeRenderer
|
|
17
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EngineOutputMaps, FormEngineRuntime as FormEngine } from '@schema-engine/forms';
|
|
2
|
+
/**
|
|
3
|
+
* Form Engine context value
|
|
4
|
+
*/
|
|
5
|
+
export interface FormEngineContextValue<TElements extends Record<string, unknown> = Record<string, unknown>, TRecipes extends Record<string, unknown> = Record<string, unknown>, TActions extends Record<string, unknown> = Record<string, unknown>, TOutputs extends EngineOutputMaps = EngineOutputMaps> {
|
|
6
|
+
engine: FormEngine<TElements, TRecipes, TActions, TOutputs>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Erases registration maps for context storage.
|
|
10
|
+
*
|
|
11
|
+
* @remarks `useFormEngine` reapplies the consumer's maps after reading context.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createFormEngineContextValue<TElements extends Record<string, unknown>, TRecipes extends Record<string, unknown>, TActions extends Record<string, unknown>, TOutputs extends EngineOutputMaps>(engine: FormEngine<TElements, TRecipes, TActions, TOutputs>): FormEngineContextValue;
|
|
14
|
+
/**
|
|
15
|
+
* Form Engine context
|
|
16
|
+
* Provides access to the FormEngine instance
|
|
17
|
+
*/
|
|
18
|
+
export declare const FormEngineContext: import("react").Context<FormEngineContextValue<Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, EngineOutputMaps> | null>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AppearanceSelection } from '@schema-engine/layout';
|
|
2
|
+
/**
|
|
3
|
+
* What a field host takes from the element `FormElement` is rendering.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Field hosts (`FieldGroupRoot`, `useFieldHost`) read it through `useFieldAppearanceAttributes` and
|
|
7
|
+
* `useFieldClassName`, so a registry component does not thread `appearance` or `className` into its
|
|
8
|
+
* host by hand. A nested element's own `FormElement` provides its own value, so a container's
|
|
9
|
+
* appearance and class never reach its children's hosts.
|
|
10
|
+
*/
|
|
11
|
+
export interface FieldHostConfig {
|
|
12
|
+
appearance?: AppearanceSelection;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const FieldHostContext: import("react").Context<FieldHostConfig | undefined>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type * as z from 'zod/mini';
|
|
3
|
+
import type { RecipeSlot, ViewModel, ViewNavigation } from '@schema-engine/forms/recipes';
|
|
4
|
+
export type { ViewModel as ViewContextValue, ViewNavigation, ViewStep } from '@schema-engine/forms/recipes';
|
|
5
|
+
export declare function ViewProvider({ children, value }: {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
value: ViewModel;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
export declare function useViewContext(): ViewModel;
|
|
10
|
+
export declare function useOptionalViewContext(): ViewModel | null;
|
|
11
|
+
export declare function useActiveStep(): import("@schema-engine/forms/recipes").ViewStep;
|
|
12
|
+
export declare function useFormNavigation(): ViewNavigation;
|
|
13
|
+
/** Reads the complete config of one slot, typed by the slot schema's output. */
|
|
14
|
+
export declare function useViewConfig<TSchema extends z.ZodMiniType>(slot: RecipeSlot, schema: TSchema): z.output<TSchema>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ViewProvider,
|
|
3
|
+
useActiveStep,
|
|
4
|
+
useFormNavigation,
|
|
5
|
+
useOptionalViewContext,
|
|
6
|
+
useViewConfig,
|
|
7
|
+
useViewContext
|
|
8
|
+
} from "../chunk-IXRV3YCF.js";
|
|
9
|
+
export {
|
|
10
|
+
ViewProvider,
|
|
11
|
+
useActiveStep,
|
|
12
|
+
useFormNavigation,
|
|
13
|
+
useOptionalViewContext,
|
|
14
|
+
useViewConfig,
|
|
15
|
+
useViewContext
|
|
16
|
+
};
|
package/dist/global.css
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* @schema-engine/forms-react styles */
|
|
2
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT MANUALLY */
|
|
3
|
+
/* This file is automatically generated during build */
|
|
4
|
+
/* To modify styles, edit the individual CSS files in src/components/ */
|
|
5
|
+
|
|
6
|
+
/* This file imports all component styles */
|
|
7
|
+
|
|
8
|
+
@import "./components/form-debugger/form-debugger.css";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A field value as the text of a text control: a string as it is, a number or boolean as its string, anything else as `''`.
|
|
3
|
+
*
|
|
4
|
+
* @remarks For a control whose value is text; a control that holds a list or a number narrows the value itself.
|
|
5
|
+
*/
|
|
6
|
+
export declare function fieldText(value: unknown): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FormIssueFormatter, FormStateContainer, FormStateSnapshot } from '@schema-engine/forms/state-container';
|
|
2
|
+
import type { FormRuntime } from '@schema-engine/forms';
|
|
3
|
+
import type { FieldRegistry } from './field-registry';
|
|
4
|
+
/**
|
|
5
|
+
* What a form instance provides to the hooks under it.
|
|
6
|
+
*
|
|
7
|
+
* @remarks The container is the only form state. The rest is what React adds around it: the issue text, the controls to focus and the runtime that owns the submission and the steps.
|
|
8
|
+
*/
|
|
9
|
+
export interface FormStateContextValue {
|
|
10
|
+
readonly container: FormStateContainer;
|
|
11
|
+
readonly formatIssue: FormIssueFormatter | undefined;
|
|
12
|
+
readonly fields: FieldRegistry;
|
|
13
|
+
/** The lifecycle around the container: submission, steps and every action; its `container` is the one above. */
|
|
14
|
+
readonly runtime: FormRuntime;
|
|
15
|
+
}
|
|
16
|
+
export declare const FormStateContext: import("react").Context<FormStateContextValue | null>;
|
|
17
|
+
export declare function useFormStateContext(): FormStateContextValue;
|
|
18
|
+
/**
|
|
19
|
+
* Reads a pure selector of the container's snapshot and re-renders when its result changes.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* The selectors of `@schema-engine/forms/state-container` return the same object while what they read is
|
|
23
|
+
* unchanged, so `useSyncExternalStore` compares results by reference. A selector that builds a new result on
|
|
24
|
+
* each call must be memoized by the caller. The first render, on the server and while hydrating, reads the
|
|
25
|
+
* container's server snapshot, so both render the same.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useContainerSelector<T>(selector: (snapshot: FormStateSnapshot) => T): T;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type FormStateContainer } from '@schema-engine/forms/state-container';
|
|
2
|
+
/**
|
|
3
|
+
* Who owns the value of a control. An uncontrolled control keeps its own value, which the registry reads and
|
|
4
|
+
* writes back, and `rendered` is the value React gave it when the field rendered. A controlled control is
|
|
5
|
+
* rendered by a component from the container's value, and the registry only reads its validity.
|
|
6
|
+
*/
|
|
7
|
+
export type FieldBinding = {
|
|
8
|
+
readonly mode: 'controlled';
|
|
9
|
+
} | {
|
|
10
|
+
readonly mode: 'uncontrolled';
|
|
11
|
+
readonly rendered: unknown;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The controls of a form by field path, which `setFocus` and a failed submit move focus to, and the only
|
|
15
|
+
* module that reads a native control, writes it back and reports what the browser says about it.
|
|
16
|
+
*/
|
|
17
|
+
export interface FieldRegistry {
|
|
18
|
+
/**
|
|
19
|
+
* Records a control of `path`; returns the function that removes that control.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* An uncontrolled native control that differs from the value React rendered it with was changed by the
|
|
23
|
+
* user before the form hydrated, so the container takes what it shows. One that still shows what React
|
|
24
|
+
* rendered takes the container's value instead, which is newer when the control is a new element of a
|
|
25
|
+
* field that has been edited since. Every native control reports its validity on attach and withdraws it
|
|
26
|
+
* when it leaves, unless another control of the path remains.
|
|
27
|
+
*/
|
|
28
|
+
register(path: string, element: HTMLElement, binding: FieldBinding): () => void;
|
|
29
|
+
/** Writes what the user did to `element` into the container and reports its validity. */
|
|
30
|
+
change(path: string, element: HTMLElement): void;
|
|
31
|
+
/** Reports the validity of the controls of `path`, then marks the path blurred. */
|
|
32
|
+
blur(path: string): void;
|
|
33
|
+
/** Reports the validity of the native controls of `path`. */
|
|
34
|
+
reportNative(path: string): void;
|
|
35
|
+
/** Whether something is registered for `path`, and whether any of it is an input, select or textarea. */
|
|
36
|
+
inspect(path: string): {
|
|
37
|
+
registered: boolean;
|
|
38
|
+
native: boolean;
|
|
39
|
+
};
|
|
40
|
+
focus(path: string): void;
|
|
41
|
+
/** Focuses the first control, in document order, of the fields at `paths` or below them, so an error on an array reaches its rows. */
|
|
42
|
+
focusFirst(paths: readonly string[]): void;
|
|
43
|
+
/** Focuses the first control, in document order, of the field at `path` or below it. */
|
|
44
|
+
focusWithin(path: string): void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @remarks
|
|
48
|
+
* A path can have several controls at once: a radio group or a list of checkboxes shares one path, and a
|
|
49
|
+
* row that is replaced has the old control beside the new one until it unmounts. The latest registered one
|
|
50
|
+
* that is still mounted answers for `focus`.
|
|
51
|
+
*
|
|
52
|
+
* One subscription to the container serves every control. On a change it compares each registered
|
|
53
|
+
* uncontrolled path with what its controls show and writes back only the difference, so a control that
|
|
54
|
+
* echoes the user's own change is never touched: that is what keeps the cursor, an IME composition and the
|
|
55
|
+
* text of a number input with `badInput` where they are. A change that adds, removes or moves the rows of
|
|
56
|
+
* an array is not written back below that array: the rows' controls keep their text and register again
|
|
57
|
+
* under their new paths, where they already agree with the container, and writing the old paths would put
|
|
58
|
+
* one row's text into another's control.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createFieldRegistry(container: FormStateContainer): FieldRegistry;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { FieldArrayValue, ControlledFormField, FormContextValue, FormControlProps, FormField, FormFieldConfig, FormFieldOptions, FormFieldStatus, NativeControlProps, FormProviderProps, FormSubmitHelpers, FormValues, } from './types';
|
|
2
|
+
export { useFormContext } from './use-form-context';
|
|
3
|
+
export { useFormField } from './use-form-field';
|
|
4
|
+
export { useWatch } from './use-watch';
|
|
5
|
+
export { useFieldArray } from './use-field-array';
|
|
6
|
+
export type { FormSubmissionState as SubmissionState, SubmissionStatus } from '@schema-engine/forms';
|
|
7
|
+
export { FORM_ROOT } from '@schema-engine/forms/state-container';
|
|
8
|
+
export type { FormIssueFormatter, FormStateError, FormStateErrorsInput, FormStateIssue, FormSubmissionIssue, } from '@schema-engine/forms/state-container';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FORM_ROOT
|
|
3
|
+
} from "../../chunk-ULKJHK3P.js";
|
|
4
|
+
import {
|
|
5
|
+
useWatch
|
|
6
|
+
} from "../../chunk-NDFV5AQW.js";
|
|
7
|
+
import {
|
|
8
|
+
useFieldArray
|
|
9
|
+
} from "../../chunk-MBN4WIAC.js";
|
|
10
|
+
import {
|
|
11
|
+
useFormContext
|
|
12
|
+
} from "../../chunk-K66J2V73.js";
|
|
13
|
+
import {
|
|
14
|
+
useFormField
|
|
15
|
+
} from "../../chunk-DTJ64NZQ.js";
|
|
16
|
+
import "../../chunk-EYDB6NR6.js";
|
|
17
|
+
import "../../chunk-XWHP2AGG.js";
|
|
18
|
+
import "../../chunk-AALIXTCD.js";
|
|
19
|
+
import "../../chunk-ZWEYALBG.js";
|
|
20
|
+
import "../../chunk-GH2QO3WC.js";
|
|
21
|
+
export {
|
|
22
|
+
FORM_ROOT,
|
|
23
|
+
useFieldArray,
|
|
24
|
+
useFormContext,
|
|
25
|
+
useFormField,
|
|
26
|
+
useWatch
|
|
27
|
+
};
|