@schema-engine/forms-react 0.5.1 → 0.5.3
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/README.md +7 -7
- package/dist/{chunk-WRJWSEL7.js → chunk-65FTA4N2.js} +1 -1
- package/dist/{chunk-DTJ64NZQ.js → chunk-7SE2EAS6.js} +1 -1
- package/dist/{chunk-ISDPSORR.js → chunk-BLBPZL42.js} +4 -4
- package/dist/{chunk-SED35QJC.js → chunk-CQB4L54B.js} +4 -4
- package/dist/chunk-CQB4L54B.js.map +7 -0
- package/dist/chunk-FV6KW2EK.js +16 -0
- package/dist/chunk-FV6KW2EK.js.map +7 -0
- package/dist/{chunk-AALIXTCD.js → chunk-HBXM7CPI.js} +4 -13
- package/dist/chunk-HBXM7CPI.js.map +7 -0
- package/dist/{chunk-K3LLWGXU.js → chunk-HNUS4XKC.js} +1 -1
- package/dist/{chunk-KG6Q7MNI.js → chunk-HX66MLOM.js} +4 -4
- package/dist/{chunk-QUZN42PL.js → chunk-J5P7HUMV.js} +13 -9
- package/dist/chunk-J5P7HUMV.js.map +7 -0
- package/dist/chunk-KYBOEYMM.js.map +7 -0
- package/dist/chunk-SEWP4GIN.js +34 -0
- package/dist/chunk-SEWP4GIN.js.map +7 -0
- package/dist/{chunk-WFRWVH4X.js → chunk-WJYJ3Q4J.js} +1 -1
- package/dist/components/form-debugger/form-debugger.js +5 -5
- package/dist/components/form-debugger/index.js +5 -5
- package/dist/components/form-provider.js +2 -2
- package/dist/components/index.js +13 -12
- package/dist/components/internals/child-grid.d.ts +43 -0
- package/dist/components/internals/child-grid.js +10 -0
- package/dist/components/internals/child-grid.js.map +7 -0
- package/dist/components/internals/field-renderer.js +8 -8
- package/dist/components/internals/form-elements.js +9 -9
- package/dist/components/internals/form-renderer.js +13 -12
- package/dist/components/internals/grid-container.d.ts +13 -0
- package/dist/components/internals/grid-container.js +9 -0
- package/dist/components/internals/grid-container.js.map +7 -0
- package/dist/components/internals/recipe-renderer.js +5 -5
- package/dist/contexts/index.js +1 -1
- package/dist/contexts/view-context.d.ts +2 -2
- package/dist/contexts/view-context.js +1 -1
- package/dist/hooks/form-state/index.js +7 -7
- package/dist/hooks/form-state/use-form-field.js +2 -2
- package/dist/hooks/index.js +15 -17
- package/dist/hooks/use-field.js +2 -2
- package/dist/hooks/use-form-context.d.ts +4 -36
- package/dist/hooks/use-form-context.js +3 -5
- package/dist/index.js +13 -12
- package/dist/primitives.d.ts +5 -3
- package/dist/primitives.js +14 -9
- package/dist/primitives.js.map +2 -2
- package/package.json +9 -8
- package/skill/SKILL.md +26 -25
- package/skill/reference/forms-react.md +1 -1
- package/dist/chunk-AALIXTCD.js.map +0 -7
- package/dist/chunk-IXRV3YCF.js.map +0 -7
- package/dist/chunk-QUZN42PL.js.map +0 -7
- package/dist/chunk-SED35QJC.js.map +0 -7
- /package/dist/{chunk-WRJWSEL7.js.map → chunk-65FTA4N2.js.map} +0 -0
- /package/dist/{chunk-DTJ64NZQ.js.map → chunk-7SE2EAS6.js.map} +0 -0
- /package/dist/{chunk-ISDPSORR.js.map → chunk-BLBPZL42.js.map} +0 -0
- /package/dist/{chunk-K3LLWGXU.js.map → chunk-HNUS4XKC.js.map} +0 -0
- /package/dist/{chunk-KG6Q7MNI.js.map → chunk-HX66MLOM.js.map} +0 -0
- /package/dist/{chunk-IXRV3YCF.js → chunk-KYBOEYMM.js} +0 -0
- /package/dist/{chunk-WFRWVH4X.js.map → chunk-WJYJ3Q4J.js.map} +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/hooks/use-form-context.ts"],
|
|
4
|
-
"sourcesContent": ["import { useContext, useMemo, useSyncExternalStore } from 'react';\nimport type { FormRuntime, FormStepState, EngineOutputMaps } from '@schema-engine/forms';\nimport { useFormStateContext } from './form-state/context';\nimport { GRID_CLASS, getDefaultLayoutTheme, getGridVariables, type CssVariables } from '@schema-engine/layout';\nimport { FormEngineContext } from '../components/provider';\nimport type { FormEngineContextValue } from '../components/provider';\n\n/**\n * What a component reads of the form's wizard: where it is, and the commands that move it.\n *\n * @remarks\n * The commands are those of the form's runtime and end with an outcome (`'moved'`, `'invalid'`, `'busy'`, ...). `steps` lists every\n * step in order with `skipped`, `visited`, `complete` and `invalid`; a skipped step is passed over by `next` and `back` and refused by `goTo`.\n */\nexport interface FormInstanceContextValue {\n\t/** The id of the current step. */\n\tcurrent: string;\n\tsteps: readonly FormStepState[];\n\t/** A `next`, `back` or `goTo` runs. */\n\tnavigating: boolean;\n\tnext: FormRuntime['next'];\n\tback: FormRuntime['back'];\n\tgoTo: FormRuntime['goTo'];\n}\n\n/**\n * Hook to access the form's wizard state and navigation\n * Must be used within a FormProvider\n */\nexport function useFormInstanceActions(): FormInstanceContextValue {\n\tconst { runtime } = useFormStateContext();\n\tconst { current, navigating, steps } = useSyncExternalStore(\n\t\truntime.subscribe,\n\t\truntime.getSnapshot,\n\t\truntime.getServerSnapshot,\n\t);\n\treturn useMemo(\n\t\t() => ({ current, steps, navigating, next: runtime.next, back: runtime.back, goTo: runtime.goTo }),\n\t\t[runtime, current, navigating, steps],\n\t);\n}\n\n/**\n * The form's runtime: its container, its submission and its wizard, for what takes a form over whole, such as `registerFormAgentTool`.\n *\n * @remarks\n * 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.\n */\nexport function useFormRuntime(): FormRuntime {\n\treturn useFormStateContext().runtime;\n}\n\n/**\n * Hook to access the form engine context\n * Must be used within a FormEngineProvider\n */\nexport function useFormEngine<\n\tTElements extends Record<string, unknown> = Record<string, unknown>,\n\tTRecipes extends Record<string, unknown> = Record<string, unknown>,\n\tTActions extends Record<string, unknown> = Record<string, unknown>,\n\tTOutputs extends EngineOutputMaps = EngineOutputMaps,\n>(): FormEngineContextValue<TElements, TRecipes, TActions, TOutputs> {\n\tconst context = useContext(FormEngineContext);\n\tif (!context) {\n\t\tthrow new Error('useFormEngine must be used within a FormEngineProvider');\n\t}\n\treturn context as unknown as FormEngineContextValue<TElements, TRecipes, TActions, TOutputs>;\n}\n\nexport function useOptionalFormEngine<\n\tTElements extends Record<string, unknown> = Record<string, unknown>,\n\tTRecipes extends Record<string, unknown> = Record<string, unknown>,\n\tTActions extends Record<string, unknown> = Record<string, unknown>,\n\tTOutputs extends EngineOutputMaps = EngineOutputMaps,\n>(): FormEngineContextValue<TElements, TRecipes, TActions, TOutputs> | null {\n\tconst context = useContext(FormEngineContext);\n\treturn context ? (context as unknown as FormEngineContextValue<TElements, TRecipes, TActions, TOutputs>) : null;\n}\n\n/**\n * Id of the layout theme that owns the field being rendered.\n *\n * @remarks\n * Field hosts set `data-se-theme` to this value so the engine's generated\n * stylesheet matches them and nested grids stay isolated. Single resolver for\n * the React renderer \u2014 the engine context is the only source, with the library\n * default for hosts rendered outside a `FormEngineProvider`.\n */\nexport function useLayoutThemeId(): string {\n\treturn (useOptionalFormEngine()?.engine.getLayout() ?? getDefaultLayoutTheme()).id;\n}\n\n/**\n * Props that make an element's children a grid of their own.\n *\n * @remarks\n * A container (a fieldset, an array row) lays its direct children out in a grid\n * the way a step does: spread the result on the wrapper of its `FormElements`.\n * The grid takes twelve tracks when a child sets `width` or `offset`, and\n * otherwise stays the engine's single column. The theme comes from the engine\n * context, with the library default outside a `FormEngineProvider`.\n */\nexport function useChildGridProps(elements: readonly unknown[]): {\n\tclassName: string;\n\t'data-se-theme': string;\n\tstyle: CssVariables;\n} {\n\tconst layout = useOptionalFormEngine()?.engine.getLayout() ?? getDefaultLayoutTheme();\n\treturn {\n\t\tclassName: `se-form-grid ${GRID_CLASS}`,\n\t\t'data-se-theme': layout.id,\n\t\tstyle: getGridVariables(undefined, layout.grid, elements),\n\t};\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAAA,SAAS,YAAY,SAAS,4BAA4B;AAG1D,SAAS,YAAY,uBAAuB,wBAA2C;AA0BhF,SAAS,yBAAmD;AAClE,QAAM,EAAE,QAAQ,IAAI,oBAAoB;AACxC,QAAM,EAAE,SAAS,YAAY,MAAM,IAAI;AAAA,IACtC,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,EACT;AACA,SAAO;AAAA,IACN,OAAO,EAAE,SAAS,OAAO,YAAY,MAAM,QAAQ,MAAM,MAAM,QAAQ,MAAM,MAAM,QAAQ,KAAK;AAAA,IAChG,CAAC,SAAS,SAAS,YAAY,KAAK;AAAA,EACrC;AACD;AAQO,SAAS,iBAA8B;AAC7C,SAAO,oBAAoB,EAAE;AAC9B;AAMO,SAAS,gBAKqD;AACpE,QAAM,UAAU,WAAW,iBAAiB;AAC5C,MAAI,CAAC,SAAS;AACb,UAAM,IAAI,MAAM,wDAAwD;AAAA,EACzE;AACA,SAAO;AACR;AAEO,SAAS,wBAK4D;AAC3E,QAAM,UAAU,WAAW,iBAAiB;AAC5C,SAAO,UAAW,UAAyF;AAC5G;AAWO,SAAS,mBAA2B;AAC1C,UAAQ,sBAAsB,GAAG,OAAO,UAAU,KAAK,sBAAsB,GAAG;AACjF;AAYO,SAAS,kBAAkB,UAIhC;AACD,QAAM,SAAS,sBAAsB,GAAG,OAAO,UAAU,KAAK,sBAAsB;AACpF,SAAO;AAAA,IACN,WAAW,gBAAgB,UAAU;AAAA,IACrC,iBAAiB,OAAO;AAAA,IACxB,OAAO,iBAAiB,QAAW,OAAO,MAAM,QAAQ;AAAA,EACzD;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/contexts/view-context.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createContext, useContext, type ReactNode } from 'react';\nimport type * as z from 'zod/mini';\nimport type { RecipeSlot, ViewModel, ViewNavigation } from '@schema-engine/forms/recipes';\nimport { getSlotConfig } from '@schema-engine/forms/recipes';\n\nexport type { ViewModel as ViewContextValue, ViewNavigation, ViewStep } from '@schema-engine/forms/recipes';\n\nconst ViewContext = createContext<ViewModel | null>(null);\n\nexport function ViewProvider({ children, value }: { children: ReactNode; value: ViewModel }) {\n\treturn <ViewContext.Provider value={value}>{children}</ViewContext.Provider>;\n}\n\nexport function useViewContext(): ViewModel {\n\tconst context = useContext(ViewContext);\n\tif (!context) {\n\t\tthrow new Error('useViewContext must be used within a ViewProvider');\n\t}\n\treturn context;\n}\n\nexport function useOptionalViewContext(): ViewModel | null {\n\treturn useContext(ViewContext);\n}\n\nexport function useActiveStep() {\n\treturn useViewContext().activeStep;\n}\n\nexport function useFormNavigation(): ViewNavigation {\n\treturn useViewContext().navigation;\n}\n\n/** Reads the complete config of one slot, typed by the slot schema's output. */\nexport function useViewConfig<TSchema extends z.ZodMiniType>(slot: RecipeSlot, schema: TSchema): z.output<TSchema> {\n\treturn getSlotConfig(useViewContext().viewConfig, slot, schema);\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,eAAe,kBAAkC;AAG1D,SAAS,qBAAqB;AAOtB;AAHR,IAAM,cAAc,cAAgC,IAAI;AAEjD,SAAS,aAAa,EAAE,UAAU,MAAM,GAA8C;AAC5F,SAAO,oBAAC,YAAY,UAAZ,EAAqB,OAAe,UAAS;AACtD;AAEO,SAAS,iBAA4B;AAC3C,QAAM,UAAU,WAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACb,UAAM,IAAI,MAAM,mDAAmD;AAAA,EACpE;AACA,SAAO;AACR;AAEO,SAAS,yBAA2C;AAC1D,SAAO,WAAW,WAAW;AAC9B;AAEO,SAAS,gBAAgB;AAC/B,SAAO,eAAe,EAAE;AACzB;AAEO,SAAS,oBAAoC;AACnD,SAAO,eAAe,EAAE;AACzB;AAGO,SAAS,cAA6C,MAAkB,QAAoC;AAClH,SAAO,cAAc,eAAe,EAAE,YAAY,MAAM,MAAM;AAC/D;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/components/internals/form-renderer.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * Form grid CSS variables and alignment properties.\n *\n * @remarks\n * Variable emission is shared with the Radiant renderer\n * (`@schema-engine/layout`); the responsive behavior lives in\n * the theme stylesheet the engine generates and the renderer emits inline.\n */\nimport { GRID_CLASS, getAppearanceAttributes, getGridVariables, type LayoutTheme } from '@schema-engine/layout';\nimport type React from 'react';\nimport { useMemo } from 'react';\nimport { FormProvider } from '../form-provider';\nimport type { FormProviderProps } from '../../hooks/form-state/types';\nimport { FormElements } from './form-elements';\nimport { useFormInstanceActions, useOptionalFormEngine } from '@/hooks/use-form-context';\nimport { FormEngineProvider } from '../form-engine-provider';\nimport {\n\ttype EngineOutputMaps,\n\ttype FormEngineRuntime as FormEngine,\n\ttype FormValues,\n\ttype NormalizedFormConfig,\n\tisNormalizedFormConfig,\n\ttype FormConfig,\n\tgetRenderableSteps,\n\tassertFormEngine,\n\tstepGrid,\n} from '@schema-engine/forms';\nimport { getViewRecipe } from '@schema-engine/forms/recipes';\nimport { RecipeRenderer } from './recipe-renderer';\n\nfunction LayoutThemeStyle({ themeId, css }: { themeId: string; css: string }) {\n\treturn (\n\t\t<style href={`se-layout-theme-${themeId}`} precedence=\"se-layout-theme\" data-se-theme-css={themeId}>\n\t\t\t{css}\n\t\t</style>\n\t);\n}\n\nfunction StepFields({\n\tstep,\n\tconfig,\n\tlayout,\n}: {\n\tstep: NormalizedFormConfig['steps'][number];\n\tconfig: NormalizedFormConfig;\n\tlayout: LayoutTheme;\n}) {\n\treturn (\n\t\t<div\n\t\t\tclassName={`se-form-step ${step.className ?? ''}`.trim()}\n\t\t\tdata-se-step={step.id}\n\t\t\tstyle={step.style}\n\t\t\t{...getAppearanceAttributes(step.appearance)}\n\t\t>\n\t\t\t{step.elements.length > 0 && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={`se-form-grid ${GRID_CLASS}`}\n\t\t\t\t\tdata-se-theme={layout.id}\n\t\t\t\t\tstyle={getGridVariables(stepGrid(config, step), layout.grid, step.elements)}\n\t\t\t\t>\n\t\t\t\t\t<FormElements elements={step.elements} />\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n\nfunction FormElementsRenderer<\n\tTElements extends Record<string, unknown>,\n\tTRecipes extends Record<string, unknown>,\n\tTActions extends Record<string, unknown>,\n\tTOutputs extends EngineOutputMaps,\n>({\n\tconfig,\n\tlayout,\n\tchildren,\n}: {\n\tconfig: NormalizedFormConfig<TOutputs['elements'], TOutputs['recipes'], TOutputs['actions']>;\n\tlayout: LayoutTheme;\n\tchildren?: React.ReactNode;\n}) {\n\tconst { current } = useFormInstanceActions();\n\tconst engineContext = useOptionalFormEngine<TElements, TRecipes, TActions, TOutputs>();\n\tconst recipe = engineContext ? getViewRecipe(engineContext.engine, config) : undefined;\n\tconst steps = getRenderableSteps(config, current);\n\n\tif (steps.length === 0) return null;\n\n\treturn (\n\t\t<RecipeRenderer\n\t\t\tconfig={config}\n\t\t\trecipe={recipe}\n\t\t\trenderFields={() => (\n\t\t\t\t<>\n\t\t\t\t\t{steps.map((step) => (\n\t\t\t\t\t\t<StepFields key={step.id} step={step} config={config} layout={layout} />\n\t\t\t\t\t))}\n\t\t\t\t</>\n\t\t\t)}\n\t\t>\n\t\t\t{children}\n\t\t</RecipeRenderer>\n\t);\n}\n\n/**\n * @template TValues - The values the form submits, which the normalized `config` carries: `onSubmit`, `onAction` and\n * `defaultValues` are typed by it. A config passed as authoring input has none, so they are {@link FormValues}.\n */\nexport interface FormRendererProps<\n\tTElements extends Record<string, unknown> = Record<string, unknown>,\n\tTRecipes extends Record<string, unknown> = Record<string, unknown>,\n\tTActions extends Record<string, unknown> = Record<string, unknown>,\n\tTOutputs extends EngineOutputMaps = EngineOutputMaps,\n\tTValues extends FormValues = FormValues,\n> extends Omit<FormProviderProps<TOutputs, TValues>, 'children' | 'config'> {\n\t/**\n\t * The form: the normalized config of `engine.defineForm` or `engine.validateForm`, or an authoring config.\n\t *\n\t * @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.\n\t */\n\tconfig:\n\t\t| NormalizedFormConfig<TOutputs['elements'], TOutputs['recipes'], TOutputs['actions'], TValues>\n\t\t| (FormValues extends TValues ? FormConfig<TElements, TRecipes, TActions> : never);\n\tclassName?: string;\n\tstyle?: React.CSSProperties;\n\tengine?: FormEngine<TElements, TRecipes, TActions, TOutputs>;\n\tchildren?: React.ReactNode;\n}\n\nfunction FormRendererInner<\n\tTElements extends Record<string, unknown>,\n\tTRecipes extends Record<string, unknown>,\n\tTActions extends Record<string, unknown>,\n\tTOutputs extends EngineOutputMaps,\n\tTValues extends FormValues,\n>({\n\tconfig,\n\tdefaultValues,\n\tonSubmit,\n\tonChange,\n\tonAction,\n\tonActionResults,\n\tnavigate,\n\tformatIssue,\n\tclassName = '',\n\tstyle,\n\tlayout,\n\tchildren,\n}: Omit<FormRendererProps<TElements, TRecipes, TActions, TOutputs, TValues>, 'engine' | 'config'> & {\n\tconfig: NormalizedFormConfig<TOutputs['elements'], TOutputs['recipes'], TOutputs['actions'], TValues>;\n\tlayout: LayoutTheme;\n}) {\n\treturn (\n\t\t<FormProvider\n\t\t\tconfig={config}\n\t\t\tdefaultValues={defaultValues}\n\t\t\tonSubmit={onSubmit}\n\t\t\tonChange={onChange}\n\t\t\tonAction={onAction}\n\t\t\tonActionResults={onActionResults}\n\t\t\tnavigate={navigate}\n\t\t\tformatIssue={formatIssue}\n\t\t>\n\t\t\t<div className={`se-form ${className}`.trim()} style={style}>\n\t\t\t\t<LayoutThemeStyle themeId={layout.id} css={layout.css} />\n\t\t\t\t<FormElementsRenderer config={config} layout={layout}>\n\t\t\t\t\t{children}\n\t\t\t\t</FormElementsRenderer>\n\t\t\t</div>\n\t\t</FormProvider>\n\t);\n}\n\n/**\n * The normalized form of a `FormRenderer` config, which keeps the values type of a normalized config.\n *\n * @remarks\n * A normalized config is validated as it is, so it keeps the type it carries. An authoring config carries none, and\n * `FormRendererProps['config']` accepts one only where `TValues` is `FormValues`, so the form it normalizes to is\n * a form of `TValues`; the engine has no signature that says so for a generic `TValues`.\n */\nfunction normalize<\n\tTElements extends Record<string, unknown>,\n\tTRecipes extends Record<string, unknown>,\n\tTActions extends Record<string, unknown>,\n\tTOutputs extends EngineOutputMaps,\n\tTValues extends FormValues,\n>(\n\tengine: FormEngine<TElements, TRecipes, TActions, TOutputs>,\n\tconfig: FormRendererProps<TElements, TRecipes, TActions, TOutputs, TValues>['config'],\n): NormalizedFormConfig<TOutputs['elements'], TOutputs['recipes'], TOutputs['actions'], TValues> {\n\tif (isNormalizedFormConfig(config)) return engine.validateForm(config);\n\treturn engine.validateForm(config) as NormalizedFormConfig<\n\t\tTOutputs['elements'],\n\t\tTOutputs['recipes'],\n\t\tTOutputs['actions'],\n\t\tTValues\n\t>;\n}\n\n/**\n * Renders a form: its fields, its recipe and the provider that runs it.\n *\n * @remarks\n * A normalized config (`engine.defineForm`, or `engine.validateForm` with a `values` schema) types `onSubmit`,\n * `onAction` and `defaultValues` by the values it carries, so a callback needs no annotation and no cast. Validating a\n * normalized config returns it unchanged, so it keeps that type; an authoring config has none and is {@link FormValues}.\n */\nexport function FormRenderer<\n\tTElements extends Record<string, unknown> = Record<string, unknown>,\n\tTRecipes extends Record<string, unknown> = Record<string, unknown>,\n\tTActions extends Record<string, unknown> = Record<string, unknown>,\n\tTOutputs extends EngineOutputMaps = EngineOutputMaps,\n\tTValues extends FormValues = FormValues,\n>({ engine, ...props }: FormRendererProps<TElements, TRecipes, TActions, TOutputs, TValues>) {\n\tconst inheritedEngine = useOptionalFormEngine<TElements, TRecipes, TActions, TOutputs>();\n\tconst resolvedEngine = engine ?? inheritedEngine?.engine;\n\tconst { config, layout } = useMemo(() => {\n\t\tassertFormEngine(resolvedEngine, props.config);\n\t\treturn { config: normalize(resolvedEngine, props.config), layout: resolvedEngine.getLayout() };\n\t}, [props.config, resolvedEngine]);\n\tconst innerProps = { ...props, config, layout };\n\n\tif (!resolvedEngine) {\n\t\treturn <FormRendererInner {...innerProps} />;\n\t}\n\n\treturn (\n\t\t<FormEngineProvider engine={resolvedEngine}>\n\t\t\t<FormRendererInner {...innerProps} />\n\t\t</FormEngineProvider>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAQA,SAAS,YAAY,yBAAyB,wBAA0C;AAExF,SAAS,eAAe;AAMxB;AAAA,EAKC;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,qBAAqB;AAK5B,SA6DE,UA7DF,KAoIC,YApID;AAFF,SAAS,iBAAiB,EAAE,SAAS,IAAI,GAAqC;AAC7E,SACC,oBAAC,WAAM,MAAM,mBAAmB,OAAO,IAAI,YAAW,mBAAkB,qBAAmB,SACzF,eACF;AAEF;AAEA,SAAS,WAAW;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AACD,GAIG;AACF,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAW,gBAAgB,KAAK,aAAa,EAAE,GAAG,KAAK;AAAA,MACvD,gBAAc,KAAK;AAAA,MACnB,OAAO,KAAK;AAAA,MACX,GAAG,wBAAwB,KAAK,UAAU;AAAA,MAE1C,eAAK,SAAS,SAAS,KACvB;AAAA,QAAC;AAAA;AAAA,UACA,WAAW,gBAAgB,UAAU;AAAA,UACrC,iBAAe,OAAO;AAAA,UACtB,OAAO,iBAAiB,SAAS,QAAQ,IAAI,GAAG,OAAO,MAAM,KAAK,QAAQ;AAAA,UAE1E,8BAAC,gBAAa,UAAU,KAAK,UAAU;AAAA;AAAA,MACxC;AAAA;AAAA,EAEF;AAEF;AAEA,SAAS,qBAKP;AAAA,EACD;AAAA,EACA;AAAA,EACA;AACD,GAIG;AACF,QAAM,EAAE,QAAQ,IAAI,uBAAuB;AAC3C,QAAM,gBAAgB,sBAA+D;AACrF,QAAM,SAAS,gBAAgB,cAAc,cAAc,QAAQ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AAC;AACjC,QAAM,aAAa,EAAE,GAAG,OAAO,QAAQ,OAAO;AAE9C,MAAI,CAAC,gBAAgB;AACpB,WAAO,oBAAC,qBAAmB,GAAG,YAAY;AAAA,EAC3C;AAEA,SACC,oBAAC,sBAAmB,QAAQ,gBAC3B,8BAAC,qBAAmB,GAAG,YAAY,GACpC;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/components/internals/recipe-renderer.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useMemo } from 'react';\nimport type React from 'react';\nimport { isSubmissionBusy, type FormConfigView, type RecipeRegistration } from '@schema-engine/forms';\nimport { buildViewModel, createViewNavigation } from '@schema-engine/forms/recipes';\nimport { useFormContext } from '@/hooks/form-state';\nimport { useFormInstanceActions } from '@/hooks/use-form-context';\nimport { ViewProvider } from '@/contexts/view-context';\nimport type { ReactRecipeAdapterPayload } from '@/primitives';\n\ntype ReactRecipeRegistration = RecipeRegistration<string, RecipeRegistration['schema'], ReactRecipeAdapterPayload>;\n\nfunction getRecipeAdapter(registration: ReactRecipeRegistration): ReactRecipeAdapterPayload {\n\tconst payload = registration.render;\n\tif (!payload?.slots) {\n\t\tthrow new Error(`Recipe '${registration.$type}' is missing a React render payload.`);\n\t}\n\n\treturn payload;\n}\n\nfunction renderSlotBlock(Component: React.FC | undefined): React.ReactNode {\n\tif (!Component) return null;\n\treturn <Component />;\n}\n\ninterface RecipeRendererProps {\n\tconfig: FormConfigView;\n\trecipe: RecipeRegistration | undefined;\n\tchildren?: React.ReactNode;\n\trenderFields: () => React.ReactNode;\n}\n\nexport function RecipeRenderer({ config, recipe, children, renderFields }: RecipeRendererProps) {\n\tconst { formState } = useFormContext();\n\tconst { current, steps, next, back, goTo } = useFormInstanceActions();\n\tconst isSubmitting = isSubmissionBusy(formState.submission.status);\n\tconst viewContext = useMemo(\n\t\t() =>\n\t\t\trecipe\n\t\t\t\t? buildViewModel({\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tkind: recipe.kind,\n\t\t\t\t\t\tstates: steps,\n\t\t\t\t\t\tcurrent,\n\t\t\t\t\t\tnavigation: createViewNavigation(steps, current, { next, back, goTo }),\n\t\t\t\t\t\tisSubmitting,\n\t\t\t\t\t\tviewConfig: config.view as Record<string, unknown>,\n\t\t\t\t\t})\n\t\t\t\t: undefined,\n\t\t[recipe, config, steps, current, next, back, goTo, isSubmitting],\n\t);\n\tconst adapter = recipe ? getRecipeAdapter(recipe as ReactRecipeRegistration) : undefined;\n\t/** @remarks Slot elements are built once per recipe so React skips a slot whose view context did not change. */\n\tconst blocks = useMemo(\n\t\t() =>\n\t\t\tadapter && {\n\t\t\t\theader: renderSlotBlock(adapter.slots.header),\n\t\t\t\tprogress: renderSlotBlock(adapter.slots.progress),\n\t\t\t\tactions: renderSlotBlock(adapter.slots.actions),\n\t\t\t},\n\t\t[adapter],\n\t);\n\tif (!adapter || !blocks || !viewContext) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{renderFields()}\n\t\t\t\t{children}\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst { viewConfig } = viewContext;\n\n\tconst content = (\n\t\t<>\n\t\t\t{renderFields()}\n\t\t\t{children}\n\t\t</>\n\t);\n\n\tconst slots = { ...blocks, content };\n\n\tconst Shell = adapter.shell;\n\tif (!Shell) {\n\t\treturn (\n\t\t\t<ViewProvider value={viewContext}>\n\t\t\t\t{slots.header}\n\t\t\t\t{slots.progress}\n\t\t\t\t{slots.content}\n\t\t\t\t{slots.actions}\n\t\t\t</ViewProvider>\n\t\t);\n\t}\n\n\treturn (\n\t\t<ViewProvider value={viewContext}>\n\t\t\t<Shell slots={slots} viewConfig={viewConfig} />\n\t\t</ViewProvider>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAAA,SAAS,eAAe;AAExB,SAAS,wBAAsE;AAC/E,SAAS,gBAAgB,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B,QAAM,UACL,iCACE;AAAA,iBAAa;AAAA,IACb;AAAA,KACF;AAGD,QAAM,QAAQ,EAAE,GAAG,QAAQ,QAAQ;AAEnC,QAAM,QAAQ,QAAQ;AACtB,MAAI,CAAC,OAAO;AACX,WACC,qBAAC,gBAAa,OAAO,aACnB;AAAA,YAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,OACR;AAAA,EAEF;AAEA,SACC,oBAAC,gBAAa,OAAO,aACpB,8BAAC,SAAM,OAAc,YAAwB,GAC9C;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|