@schema-engine/forms-react 0.0.0-stage → 0.5.1
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,63 @@
|
|
|
1
|
+
import type { FormRuntime, FormStepState, EngineOutputMaps } from '@schema-engine/forms';
|
|
2
|
+
import { type CssVariables } from '@schema-engine/layout';
|
|
3
|
+
import type { FormEngineContextValue } from '../components/provider';
|
|
4
|
+
/**
|
|
5
|
+
* What a component reads of the form's wizard: where it is, and the commands that move it.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The commands are those of the form's runtime and end with an outcome (`'moved'`, `'invalid'`, `'busy'`, ...). `steps` lists every
|
|
9
|
+
* step in order with `skipped`, `visited`, `complete` and `invalid`; a skipped step is passed over by `next` and `back` and refused by `goTo`.
|
|
10
|
+
*/
|
|
11
|
+
export interface FormInstanceContextValue {
|
|
12
|
+
/** The id of the current step. */
|
|
13
|
+
current: string;
|
|
14
|
+
steps: readonly FormStepState[];
|
|
15
|
+
/** A `next`, `back` or `goTo` runs. */
|
|
16
|
+
navigating: boolean;
|
|
17
|
+
next: FormRuntime['next'];
|
|
18
|
+
back: FormRuntime['back'];
|
|
19
|
+
goTo: FormRuntime['goTo'];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Hook to access the form's wizard state and navigation
|
|
23
|
+
* Must be used within a FormProvider
|
|
24
|
+
*/
|
|
25
|
+
export declare function useFormInstanceActions(): FormInstanceContextValue;
|
|
26
|
+
/**
|
|
27
|
+
* The form's runtime: its container, its submission and its wizard, for what takes a form over whole, such as `registerFormAgentTool`.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* Must be used within a FormProvider. A new config or engine starts a new runtime, and the provider's children remount with it, so an effect that registers it runs again.
|
|
31
|
+
*/
|
|
32
|
+
export declare function useFormRuntime(): FormRuntime;
|
|
33
|
+
/**
|
|
34
|
+
* Hook to access the form engine context
|
|
35
|
+
* Must be used within a FormEngineProvider
|
|
36
|
+
*/
|
|
37
|
+
export declare function useFormEngine<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>(): FormEngineContextValue<TElements, TRecipes, TActions, TOutputs>;
|
|
38
|
+
export declare function useOptionalFormEngine<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>(): FormEngineContextValue<TElements, TRecipes, TActions, TOutputs> | null;
|
|
39
|
+
/**
|
|
40
|
+
* Id of the layout theme that owns the field being rendered.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Field hosts set `data-se-theme` to this value so the engine's generated
|
|
44
|
+
* stylesheet matches them and nested grids stay isolated. Single resolver for
|
|
45
|
+
* the React renderer — the engine context is the only source, with the library
|
|
46
|
+
* default for hosts rendered outside a `FormEngineProvider`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function useLayoutThemeId(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Props that make an element's children a grid of their own.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* A container (a fieldset, an array row) lays its direct children out in a grid
|
|
54
|
+
* the way a step does: spread the result on the wrapper of its `FormElements`.
|
|
55
|
+
* The grid takes twelve tracks when a child sets `width` or `offset`, and
|
|
56
|
+
* otherwise stays the engine's single column. The theme comes from the engine
|
|
57
|
+
* context, with the library default outside a `FormEngineProvider`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function useChildGridProps(elements: readonly unknown[]): {
|
|
60
|
+
className: string;
|
|
61
|
+
'data-se-theme': string;
|
|
62
|
+
style: CssVariables;
|
|
63
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useChildGridProps,
|
|
3
|
+
useFormEngine,
|
|
4
|
+
useFormInstanceActions,
|
|
5
|
+
useFormRuntime,
|
|
6
|
+
useLayoutThemeId,
|
|
7
|
+
useOptionalFormEngine
|
|
8
|
+
} from "../chunk-AALIXTCD.js";
|
|
9
|
+
import "../chunk-ZWEYALBG.js";
|
|
10
|
+
import "../chunk-GH2QO3WC.js";
|
|
11
|
+
export {
|
|
12
|
+
useChildGridProps,
|
|
13
|
+
useFormEngine,
|
|
14
|
+
useFormInstanceActions,
|
|
15
|
+
useFormRuntime,
|
|
16
|
+
useLayoutThemeId,
|
|
17
|
+
useOptionalFormEngine
|
|
18
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the viewport is narrower than the mobile breakpoint.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Subscribes to `matchMedia` as an external store, so the first client render
|
|
6
|
+
* already has the real value instead of flashing `false` through an effect.
|
|
7
|
+
* Server and hydration renders report `false`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useIsMobile(): boolean;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -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,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A number that names an object for as long as it lives, to use as a React `key`.
|
|
3
|
+
*
|
|
4
|
+
* @remarks A form instance lives as long as the identities of its normalized config and its engine do not change.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getObjectIdentity(value: object): number;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable runtime contracts used by consumer-owned form registrations.
|
|
3
|
+
*
|
|
4
|
+
* Registry components must use this entrypoint instead of reaching into
|
|
5
|
+
* package implementation paths.
|
|
6
|
+
*/
|
|
7
|
+
import type React from 'react';
|
|
8
|
+
import { type FormShellLayout, type RecipeRenderPayload, type RecipeSlot, type RecipeSpec } from '@schema-engine/forms/recipes';
|
|
9
|
+
import type * as z from 'zod/mini';
|
|
10
|
+
export { FormElement } from './components/internals/field-renderer';
|
|
11
|
+
export type { FormElementProps } from './components/internals/field-renderer';
|
|
12
|
+
export { FormElements } from './components/internals/form-elements';
|
|
13
|
+
export type { FormElementsProps } from './components/internals/form-elements';
|
|
14
|
+
/** Stable React recipe contracts for consumer-owned view implementations. */
|
|
15
|
+
export type FormShellProps = FormShellLayout<React.ReactNode>;
|
|
16
|
+
export type FormShellComponent = React.FC<FormShellProps>;
|
|
17
|
+
export interface ReactRecipeAdapterPayload {
|
|
18
|
+
shell?: FormShellComponent;
|
|
19
|
+
slots: Partial<Record<'header' | 'progress' | 'actions', React.FC>>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Binds a recipe spec to React components, requiring exactly the slots the spec declares.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Wraps the renderer-neutral `defineFormRecipe`; the payload type is what makes a missing or
|
|
26
|
+
* extra slot a compile error.
|
|
27
|
+
*/
|
|
28
|
+
export declare function defineRecipe<const TType extends string, TSlots extends Partial<Record<RecipeSlot, z.ZodMiniType>>, TSchema extends z.ZodMiniType>(spec: RecipeSpec<TType, TSchema, TSlots>, payload: RecipeRenderPayload<TSlots, FormShellComponent, React.FC>): import("@schema-engine/forms").RecipeRegistration<TType, TSchema, RecipeRenderPayload<TSlots, FormShellComponent, React.FC<{}>>>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FormElements
|
|
3
|
+
} from "./chunk-K3LLWGXU.js";
|
|
4
|
+
import {
|
|
5
|
+
FormElement
|
|
6
|
+
} from "./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-H25SUEJE.js";
|
|
20
|
+
import "./chunk-XWHP2AGG.js";
|
|
21
|
+
import "./chunk-AALIXTCD.js";
|
|
22
|
+
import "./chunk-ZWEYALBG.js";
|
|
23
|
+
import "./chunk-GH2QO3WC.js";
|
|
24
|
+
import "./chunk-5XCNXEJB.js";
|
|
25
|
+
|
|
26
|
+
// src/primitives.ts
|
|
27
|
+
import {
|
|
28
|
+
defineFormRecipe
|
|
29
|
+
} from "@schema-engine/forms/recipes";
|
|
30
|
+
function defineRecipe(spec, payload) {
|
|
31
|
+
return defineFormRecipe(spec, payload);
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
FormElement,
|
|
35
|
+
FormElements,
|
|
36
|
+
defineRecipe
|
|
37
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/primitives.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Stable runtime contracts used by consumer-owned form registrations.\n *\n * Registry components must use this entrypoint instead of reaching into\n * package implementation paths.\n */\nimport type React from 'react';\nimport {\n\tdefineFormRecipe,\n\ttype FormShellLayout,\n\ttype RecipeRenderPayload,\n\ttype RecipeSlot,\n\ttype RecipeSpec,\n} from '@schema-engine/forms/recipes';\nimport type * as z from 'zod/mini';\n\nexport { FormElement } from './components/internals/field-renderer';\nexport type { FormElementProps } from './components/internals/field-renderer';\nexport { FormElements } from './components/internals/form-elements';\nexport type { FormElementsProps } from './components/internals/form-elements';\n\n/** Stable React recipe contracts for consumer-owned view implementations. */\nexport type FormShellProps = FormShellLayout<React.ReactNode>;\nexport type FormShellComponent = React.FC<FormShellProps>;\nexport interface ReactRecipeAdapterPayload {\n\tshell?: FormShellComponent;\n\tslots: Partial<Record<'header' | 'progress' | 'actions', React.FC>>;\n}\n\n/**\n * Binds a recipe spec to React components, requiring exactly the slots the spec declares.\n *\n * @remarks\n * Wraps the renderer-neutral `defineFormRecipe`; the payload type is what makes a missing or\n * extra slot a compile error.\n */\nexport function defineRecipe<\n\tconst TType extends string,\n\tTSlots extends Partial<Record<RecipeSlot, z.ZodMiniType>>,\n\tTSchema extends z.ZodMiniType,\n>(spec: RecipeSpec<TType, TSchema, TSlots>, payload: RecipeRenderPayload<TSlots, FormShellComponent, React.FC>) {\n\treturn defineFormRecipe(spec, payload);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;AAAA,EACC;AAAA,OAKM;AAuBA,SAAS,aAId,MAA0C,SAAoE;AAC/G,SAAO,iBAAiB,MAAM,OAAO;AACtC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,142 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schema-engine/forms-react",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.5.1",
|
|
5
|
+
"description": "The React renderer for Schema Engine forms",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"schema-engine",
|
|
8
|
+
"forms",
|
|
9
|
+
"react",
|
|
10
|
+
"json"
|
|
11
|
+
],
|
|
12
|
+
"author": "Andrea Zanenghi",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/schema-engine/schema-engine.git",
|
|
17
|
+
"directory": "packages/forms-react"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": "^24.22.0 || >=26.0.0"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://schema-engine.com/docs/forms-react/overview",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": [
|
|
27
|
+
"**/*.css"
|
|
28
|
+
],
|
|
29
|
+
"main": "dist/index.js",
|
|
30
|
+
"module": "dist/index.js",
|
|
31
|
+
"types": "dist/index.d.ts",
|
|
32
|
+
"style": "dist/global.css",
|
|
33
|
+
"files": [
|
|
34
|
+
"/dist/*",
|
|
35
|
+
"/skill"
|
|
36
|
+
],
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@base-ui/react": "^1.1.0",
|
|
39
|
+
"@storybook/addon-docs": "^10.6.9",
|
|
40
|
+
"@storybook/addon-vitest": "^10.6.9",
|
|
41
|
+
"@storybook/react-vite": "^10.6.9",
|
|
42
|
+
"@tailwindcss/postcss": "^4.1.18",
|
|
43
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
44
|
+
"@testing-library/dom": "^10.4.1",
|
|
45
|
+
"@testing-library/jest-dom": "^6.8.0",
|
|
46
|
+
"@testing-library/react": "^16.3.0",
|
|
47
|
+
"@types/node": "^24.13.2",
|
|
48
|
+
"@types/react": "^19",
|
|
49
|
+
"@types/react-dom": "^19",
|
|
50
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
51
|
+
"@vitest/browser": "^5.1.1",
|
|
52
|
+
"@vitest/browser-playwright": "^5.1.1",
|
|
53
|
+
"autoprefixer": "^10.4.21",
|
|
54
|
+
"class-variance-authority": "^0.7.1",
|
|
55
|
+
"clsx": "^2.1.1",
|
|
56
|
+
"cmdk": "^1.1.1",
|
|
57
|
+
"date-fns": "4.1.0",
|
|
58
|
+
"esbuild": "^0.27.0",
|
|
59
|
+
"imask": "^7.6.1",
|
|
60
|
+
"input-otp": "1.4.1",
|
|
61
|
+
"libphonenumber-js": "^1.13.12",
|
|
62
|
+
"lucide-react": "^0.539.0",
|
|
63
|
+
"msw": "^2.11.6",
|
|
64
|
+
"msw-storybook-addon": "^2.0.6",
|
|
65
|
+
"postcss": "^8.5.26",
|
|
66
|
+
"postcss-import": "^16.1.1",
|
|
67
|
+
"postcss-nested": "^7.0.2",
|
|
68
|
+
"react": "^19",
|
|
69
|
+
"react-aria-components": "^1.13.0",
|
|
70
|
+
"react-day-picker": "^10.0.1",
|
|
71
|
+
"react-dom": "^19",
|
|
72
|
+
"react-dropzone": "^14.3.8",
|
|
73
|
+
"react-phone-number-input": "^3.4.12",
|
|
74
|
+
"remark-gfm": "^4.0.1",
|
|
75
|
+
"storybook": "^10.6.9",
|
|
76
|
+
"tailwind-merge": "^3.4.0",
|
|
77
|
+
"tailwindcss": "^4",
|
|
78
|
+
"tsc-alias": "^1.8.16",
|
|
79
|
+
"tw-animate-css": "^1.4.0",
|
|
80
|
+
"typescript": "^5.9.3",
|
|
81
|
+
"vitest": "^5.1.1",
|
|
82
|
+
"vitest-browser-react": "^2.3.0",
|
|
83
|
+
"zod": "^4.0.17",
|
|
84
|
+
"@schema-engine/actions": "0.5.1",
|
|
85
|
+
"@schema-engine/forms": "0.5.1",
|
|
86
|
+
"@schema-engine/scripts": "0.0.0",
|
|
87
|
+
"@schema-engine/layout": "0.5.1"
|
|
88
|
+
},
|
|
89
|
+
"peerDependencies": {
|
|
90
|
+
"react": "^19",
|
|
91
|
+
"react-dom": "^19",
|
|
92
|
+
"zod": "^4.0.17",
|
|
93
|
+
"@schema-engine/forms": "^0.5.1",
|
|
94
|
+
"@schema-engine/layout": "^0.5.1"
|
|
95
|
+
},
|
|
96
|
+
"dependencies": {
|
|
97
|
+
"@ecopages/logger": "^0.2.3"
|
|
98
|
+
},
|
|
99
|
+
"exports": {
|
|
100
|
+
"./package.json": {
|
|
101
|
+
"import": "./package.json"
|
|
102
|
+
},
|
|
103
|
+
".": {
|
|
104
|
+
"types": "./dist/index.d.ts",
|
|
105
|
+
"import": "./dist/index.js"
|
|
106
|
+
},
|
|
107
|
+
"./primitives": {
|
|
108
|
+
"types": "./dist/primitives.d.ts",
|
|
109
|
+
"import": "./dist/primitives.js"
|
|
110
|
+
},
|
|
111
|
+
"./hooks": {
|
|
112
|
+
"types": "./dist/hooks/index.d.ts",
|
|
113
|
+
"import": "./dist/hooks/index.js"
|
|
114
|
+
},
|
|
115
|
+
"./contexts": {
|
|
116
|
+
"types": "./dist/contexts/index.d.ts",
|
|
117
|
+
"import": "./dist/contexts/index.js"
|
|
118
|
+
},
|
|
119
|
+
"./components/form-debugger": {
|
|
120
|
+
"types": "./dist/components/form-debugger/index.d.ts",
|
|
121
|
+
"import": "./dist/components/form-debugger/index.js"
|
|
122
|
+
},
|
|
123
|
+
"./global.css": "./dist/global.css"
|
|
124
|
+
},
|
|
125
|
+
"msw": {
|
|
126
|
+
"workerDirectory": [
|
|
127
|
+
"public"
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
"scripts": {
|
|
131
|
+
"build:lib": "pnpm clean && pnpm build:files && pnpm build:types",
|
|
132
|
+
"build:files": "node ./build.ts",
|
|
133
|
+
"build:types": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
134
|
+
"watch:lib": "node ./build.ts --watch",
|
|
135
|
+
"clean": "rm -rf ./dist",
|
|
136
|
+
"test:all": "vitest run",
|
|
137
|
+
"storybook": "storybook dev -p 6006",
|
|
138
|
+
"build-storybook": "storybook build -o ./storybook-static",
|
|
139
|
+
"check-types": "tsc --noEmit && tsc --noEmit -p tsconfig.test-types.json",
|
|
140
|
+
"test:storybook": "vitest run --project storybook"
|
|
141
|
+
}
|
|
6
142
|
}
|
package/skill/SKILL.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: schema-engine
|
|
3
|
+
description: |
|
|
4
|
+
Schema Engine is a common language for declarative interfaces: registrations
|
|
5
|
+
keyed by `$type`, actions that run in sequences, documents that are plain
|
|
6
|
+
data, and rendering from that data. Forms is its first domain. Use this
|
|
7
|
+
skill when an agent is asked to build, configure, validate, submit or extend
|
|
8
|
+
anything with @schema-engine/registry, @schema-engine/actions,
|
|
9
|
+
@schema-engine/layout, @schema-engine/forms, @schema-engine/forms-react or
|
|
10
|
+
@schema-engine/forms-radiant, or to write a form widget for React or Radiant.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Schema Engine
|
|
14
|
+
|
|
15
|
+
Schema Engine is one grammar for interfaces that are described as data. A team registers the pieces (elements, actions, rules, appearance axes) under a `$type`, and a document, plain JSON or YAML, names them. The engine checks the document against the registrations and the renderer draws what passed. Forms is the first domain: a framework-free engine owns validation, state and submission, and a renderer (React or Radiant) only draws the fields and bridges the user's controls into that state.
|
|
16
|
+
|
|
17
|
+
This file is the router. It defines the concepts once; the references assume them and never repeat them. Read a reference only when the task needs it.
|
|
18
|
+
|
|
19
|
+
## Core concepts
|
|
20
|
+
|
|
21
|
+
- **registration**: `{ $type, schema, metadata, ... }`, where `$type` is the stable key, `schema` is any Standard Schema that describes its config, and `metadata` names it. Elements, recipes, actions, validation rules and appearance axes are all registrations.
|
|
22
|
+
- **registry**: a read-only registry, `createRegistry(kind, registrations)` from `@schema-engine/registry`, built once from a list. The last registration of a `$type` wins without a warning, which is how you replace a built-in.
|
|
23
|
+
- **document**: serializable data whose every node names a registration by `$type`. It is checked against the registrations at the boundary, so what is rendered or run has passed its schema.
|
|
24
|
+
- **action**: a registration with `execute` that runs on a trigger. Actions run as a sequence, an inner array is a parallel group, and a failure that sets `shouldContinue: false` stops what follows and cancels the group's siblings through their `signal`.
|
|
25
|
+
|
|
26
|
+
## Forms concepts
|
|
27
|
+
|
|
28
|
+
- **config**: a form is plain data, a `FormConfig` of steps holding elements, each with a `$type`, a `name`, `rules` and `constraints`. `engine.defineForm()` (typed, in TypeScript) or `engine.validateForm(unknown)` (portable JSON) checks it against the engine's registrations and returns a frozen `NormalizedFormConfig` that the engine owns.
|
|
29
|
+
- **container**: the form's state, a `FormStateContainer` from `@schema-engine/forms/state-container`. It owns the nested values, errors, warnings, touched and dirty marks, field-array row ids and the validation in flight. Paths are dotted (`contacts.1.email`) and `FORM_ROOT` is the form itself. Every change is a command (`setValue`, `blur`, `reportNative`, `validate`, `submit`, `reset`, `fieldArray`), and every read is a pure selector over an immutable snapshot.
|
|
30
|
+
- **runtime**: `createFormRuntime` is the lifecycle every renderer shares. It builds the container and owns the submission, the wizard steps and their navigation, `form_mount` and `form_change`, and every action dispatch. A renderer supplies only what an element can do, such as focus.
|
|
31
|
+
- **issues and the formatter**: the engine reports what is wrong as an issue (`type`, `source`, `ruleId`, `params`, `message`) and never makes up text. `formatIssue`, a function of the application, turns an issue into the words shown, and falls back to the issue's own `message`.
|
|
32
|
+
|
|
33
|
+
Outcomes use one vocabulary: a check or a submission ends `passed`, `invalid` or `overtaken`. `overtaken` means an edit or a reset outran the check, so there is no verdict and nothing to show.
|
|
34
|
+
|
|
35
|
+
## Packages
|
|
36
|
+
|
|
37
|
+
| Package | Role |
|
|
38
|
+
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
39
|
+
| `@schema-engine/registry` | The registration contract and read-only registries every package builds on, and `/yaml` for documents authored as YAML. Ships this router |
|
|
40
|
+
| `@schema-engine/actions` | Actions: `parseActions`, and a dispatcher that runs a sequence with parallel groups, cancellation and results |
|
|
41
|
+
| `@schema-engine/layout` | Domain-neutral grid, appearance axes, layout themes and the recipe protocol |
|
|
42
|
+
| `@schema-engine/forms` | The forms engine: config, validation, constraints, the container, the runtime |
|
|
43
|
+
| `@schema-engine/forms-react` | React renderer: `FormRenderer` and the hooks. You write the widgets; ready-made ones come from the optional shadcn registry |
|
|
44
|
+
| `@schema-engine/forms-radiant` | Radiant renderer: `se-form-instance`, `FormController`, widgets and recipes in the package |
|
|
45
|
+
|
|
46
|
+
A symbol has one import path. `@schema-engine/forms` has these entries: `.` (the engine, the runtime and the types), `/state-container` (the container and its selectors), `/csrf`, `/server-errors`, `/recipes`, `/recipes/built-in`, `/browser` (browser-side actions such as auto-save), `/testing` (conformance suites; they need vitest) and `/agent-tool` (experimental).
|
|
47
|
+
|
|
48
|
+
## To do X, read Y
|
|
49
|
+
|
|
50
|
+
Each package ships this router as its own `skill/SKILL.md` and its references in its `skill/reference/` folder, so a reference is `node_modules/@schema-engine/<package>/skill/reference/<file>`, and any installed package has the router. Read the rows of the packages the project depends on and skip the others: a package that is not installed has no file. The deployed site serves the latest version of the router and of every reference at `/skill/`, with the references flat at `/skill/reference/<file>`.
|
|
51
|
+
|
|
52
|
+
| To do | Package | Reference |
|
|
53
|
+
| ---------------------------------------------------------------------------- | ------------------------------ | ------------------------------------ |
|
|
54
|
+
| Register something, build a registry, or read a YAML document | `@schema-engine/registry` | `reference/registry.md` |
|
|
55
|
+
| Parse, dispatch or cancel actions outside a form | `@schema-engine/actions` | `reference/actions.md` |
|
|
56
|
+
| Build a grid, an appearance axis or a layout theme | `@schema-engine/layout` | `reference/layout.md` |
|
|
57
|
+
| Create an engine, author a config, use the container or the runtime directly | `@schema-engine/forms` | `reference/forms.md` |
|
|
58
|
+
| Add a rule, explain a validation result, or translate messages | `@schema-engine/forms` | `reference/forms-validation.md` |
|
|
59
|
+
| Handle submit, server errors, CSRF or wizard steps | `@schema-engine/forms` | `reference/forms-submission.md` |
|
|
60
|
+
| Run code on a form event, or define a form action | `@schema-engine/forms` | `reference/forms-actions.md` |
|
|
61
|
+
| Render a form in React, or use its hooks | `@schema-engine/forms-react` | `reference/forms-react.md` |
|
|
62
|
+
| Write or change a React field widget, and test it | `@schema-engine/forms-react` | `reference/forms-react-widgets.md` |
|
|
63
|
+
| Render a form in Radiant, or reach the container from an element | `@schema-engine/forms-radiant` | `reference/forms-radiant.md` |
|
|
64
|
+
| Write or change a Radiant field widget, and test it | `@schema-engine/forms-radiant` | `reference/forms-radiant-widgets.md` |
|
|
65
|
+
|
|
66
|
+
## Documentation map
|
|
67
|
+
|
|
68
|
+
The full documentation is at `/docs` on the deployed site. The LLM-exported corpus is `/llms.txt` (index) and `/docs-llm/<section>/<slug>.md` (page bodies).
|
|
69
|
+
|
|
70
|
+
| Section | Path prefix |
|
|
71
|
+
| ------------------------------ | ---------------------------------- |
|
|
72
|
+
| Schema Engine | `/docs/schema-engine/introduction` |
|
|
73
|
+
| `@schema-engine/registry` | `/docs/registry/overview` |
|
|
74
|
+
| `@schema-engine/actions` | `/docs/actions/overview` |
|
|
75
|
+
| `@schema-engine/forms` | `/docs/forms/overview` |
|
|
76
|
+
| `@schema-engine/forms-react` | `/docs/forms-react/overview` |
|
|
77
|
+
| `@schema-engine/forms-radiant` | `/docs/forms-radiant/overview` |
|
|
78
|
+
| `@schema-engine/layout` | `/docs/layout/overview` |
|
|
79
|
+
| Examples | `/docs/examples/overview` |
|