@schema-engine/forms-react 0.5.2 → 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.
Files changed (59) hide show
  1. package/README.md +7 -7
  2. package/dist/{chunk-WRJWSEL7.js → chunk-65FTA4N2.js} +1 -1
  3. package/dist/{chunk-DTJ64NZQ.js → chunk-7SE2EAS6.js} +1 -1
  4. package/dist/{chunk-ISDPSORR.js → chunk-BLBPZL42.js} +4 -4
  5. package/dist/{chunk-SED35QJC.js → chunk-CQB4L54B.js} +4 -4
  6. package/dist/chunk-CQB4L54B.js.map +7 -0
  7. package/dist/chunk-FV6KW2EK.js +16 -0
  8. package/dist/chunk-FV6KW2EK.js.map +7 -0
  9. package/dist/{chunk-AALIXTCD.js → chunk-HBXM7CPI.js} +4 -13
  10. package/dist/chunk-HBXM7CPI.js.map +7 -0
  11. package/dist/{chunk-K3LLWGXU.js → chunk-HNUS4XKC.js} +1 -1
  12. package/dist/{chunk-KG6Q7MNI.js → chunk-HX66MLOM.js} +4 -4
  13. package/dist/{chunk-QUZN42PL.js → chunk-J5P7HUMV.js} +13 -9
  14. package/dist/chunk-J5P7HUMV.js.map +7 -0
  15. package/dist/chunk-KYBOEYMM.js.map +7 -0
  16. package/dist/chunk-SEWP4GIN.js +34 -0
  17. package/dist/chunk-SEWP4GIN.js.map +7 -0
  18. package/dist/{chunk-WFRWVH4X.js → chunk-WJYJ3Q4J.js} +1 -1
  19. package/dist/components/form-debugger/form-debugger.js +5 -5
  20. package/dist/components/form-debugger/index.js +5 -5
  21. package/dist/components/form-provider.js +2 -2
  22. package/dist/components/index.js +13 -12
  23. package/dist/components/internals/child-grid.d.ts +43 -0
  24. package/dist/components/internals/child-grid.js +10 -0
  25. package/dist/components/internals/child-grid.js.map +7 -0
  26. package/dist/components/internals/field-renderer.js +8 -8
  27. package/dist/components/internals/form-elements.js +9 -9
  28. package/dist/components/internals/form-renderer.js +13 -12
  29. package/dist/components/internals/grid-container.d.ts +13 -0
  30. package/dist/components/internals/grid-container.js +9 -0
  31. package/dist/components/internals/grid-container.js.map +7 -0
  32. package/dist/components/internals/recipe-renderer.js +5 -5
  33. package/dist/contexts/index.js +1 -1
  34. package/dist/contexts/view-context.d.ts +2 -2
  35. package/dist/contexts/view-context.js +1 -1
  36. package/dist/hooks/form-state/index.js +7 -7
  37. package/dist/hooks/form-state/use-form-field.js +2 -2
  38. package/dist/hooks/index.js +15 -17
  39. package/dist/hooks/use-field.js +2 -2
  40. package/dist/hooks/use-form-context.d.ts +4 -36
  41. package/dist/hooks/use-form-context.js +3 -5
  42. package/dist/index.js +13 -12
  43. package/dist/primitives.d.ts +5 -3
  44. package/dist/primitives.js +14 -9
  45. package/dist/primitives.js.map +2 -2
  46. package/package.json +8 -7
  47. package/skill/SKILL.md +12 -11
  48. package/skill/reference/forms-react.md +1 -1
  49. package/dist/chunk-AALIXTCD.js.map +0 -7
  50. package/dist/chunk-IXRV3YCF.js.map +0 -7
  51. package/dist/chunk-QUZN42PL.js.map +0 -7
  52. package/dist/chunk-SED35QJC.js.map +0 -7
  53. /package/dist/{chunk-WRJWSEL7.js.map → chunk-65FTA4N2.js.map} +0 -0
  54. /package/dist/{chunk-DTJ64NZQ.js.map → chunk-7SE2EAS6.js.map} +0 -0
  55. /package/dist/{chunk-ISDPSORR.js.map → chunk-BLBPZL42.js.map} +0 -0
  56. /package/dist/{chunk-K3LLWGXU.js.map → chunk-HNUS4XKC.js.map} +0 -0
  57. /package/dist/{chunk-KG6Q7MNI.js.map → chunk-HX66MLOM.js.map} +0 -0
  58. /package/dist/{chunk-IXRV3YCF.js → chunk-KYBOEYMM.js} +0 -0
  59. /package/dist/{chunk-WFRWVH4X.js.map → chunk-WJYJ3Q4J.js.map} +0 -0
package/README.md CHANGED
@@ -65,13 +65,13 @@ export const Contact = () => <FormRenderer engine={engine} config={form} onSubmi
65
65
 
66
66
  ## Entry points
67
67
 
68
- | Import | Holds |
69
- | ----------------------------------------------------- | ----------------------------------------------------------------------------------------- |
70
- | `@schema-engine/forms-react` | `FormRenderer`, `FormProvider` and `FormEngineProvider` |
71
- | `@schema-engine/forms-react/hooks` | `useFormField`, `useFormContext`, `useWatch`, `useFieldArray`, the runtime and view hooks |
72
- | `@schema-engine/forms-react/primitives` | `FormElement`, `FormElements` and `defineRecipe` |
73
- | `@schema-engine/forms-react/contexts` | The view provider and context types |
74
- | `@schema-engine/forms-react/components/form-debugger` | `FormDebugger`, a development panel |
68
+ | Import | Holds |
69
+ | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
70
+ | `@schema-engine/forms-react` | `FormRenderer`, `FormProvider` and `FormEngineProvider` |
71
+ | `@schema-engine/forms-react/hooks` | `useFormField`, `useFormContext`, `useWatch`, `useFieldArray`, the runtime and view hooks |
72
+ | `@schema-engine/forms-react/primitives` | `FormElement`, `FormElements`, `ChildGrid` (`subgrid` for a container whose `grid` sets it) and `defineRecipe` |
73
+ | `@schema-engine/forms-react/contexts` | The view provider and context types |
74
+ | `@schema-engine/forms-react/components/form-debugger` | `FormDebugger`, a development panel |
75
75
 
76
76
  ## Documentation
77
77
 
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-USRF3EEE.js";
4
4
  import {
5
5
  useFormEngine
6
- } from "./chunk-AALIXTCD.js";
6
+ } from "./chunk-HBXM7CPI.js";
7
7
  import {
8
8
  FormStateContext
9
9
  } from "./chunk-ZWEYALBG.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-XWHP2AGG.js";
7
7
  import {
8
8
  useOptionalFormEngine
9
- } from "./chunk-AALIXTCD.js";
9
+ } from "./chunk-HBXM7CPI.js";
10
10
  import {
11
11
  useContainerSelector,
12
12
  useFormStateContext
@@ -1,12 +1,12 @@
1
- import {
2
- useWatch
3
- } from "./chunk-NDFV5AQW.js";
4
1
  import {
5
2
  useFormContext
6
3
  } from "./chunk-K66J2V73.js";
4
+ import {
5
+ useWatch
6
+ } from "./chunk-NDFV5AQW.js";
7
7
  import {
8
8
  useOptionalViewContext
9
- } from "./chunk-IXRV3YCF.js";
9
+ } from "./chunk-KYBOEYMM.js";
10
10
 
11
11
  // src/components/form-debugger/form-debugger.tsx
12
12
  import { useEffect, useRef, useState } from "react";
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-K66J2V73.js";
4
4
  import {
5
5
  ViewProvider
6
- } from "./chunk-IXRV3YCF.js";
6
+ } from "./chunk-KYBOEYMM.js";
7
7
  import {
8
- useFormInstanceActions
9
- } from "./chunk-AALIXTCD.js";
8
+ useFormWizard
9
+ } from "./chunk-HBXM7CPI.js";
10
10
 
11
11
  // src/components/internals/recipe-renderer.tsx
12
12
  import { useMemo } from "react";
@@ -26,7 +26,7 @@ function renderSlotBlock(Component) {
26
26
  }
27
27
  function RecipeRenderer({ config, recipe, children, renderFields }) {
28
28
  const { formState } = useFormContext();
29
- const { current, steps, next, back, goTo } = useFormInstanceActions();
29
+ const { current, steps, next, back, goTo } = useFormWizard();
30
30
  const isSubmitting = isSubmissionBusy(formState.submission.status);
31
31
  const viewContext = useMemo(
32
32
  () => recipe ? buildViewModel({
@@ -0,0 +1,7 @@
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 { useFormWizard } 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 } = useFormWizard();\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,4BAA4B;AAmB7C,SA0CL,UA1CK,KA0CL,YA1CK;AAXR,SAAS,iBAAiB,cAAkE;AAC3F,QAAM,UAAU,aAAa;AAC7B,MAAI,CAAC,SAAS,OAAO;AACpB,UAAM,IAAI,MAAM,WAAW,aAAa,KAAK,sCAAsC;AAAA,EACpF;AAEA,SAAO;AACR;AAEA,SAAS,gBAAgB,WAAkD;AAC1E,MAAI,CAAC,UAAW,QAAO;AACvB,SAAO,oBAAC,aAAU;AACnB;AASO,SAAS,eAAe,EAAE,QAAQ,QAAQ,UAAU,aAAa,GAAwB;AAC/F,QAAM,EAAE,UAAU,IAAI,eAAe;AACrC,QAAM,EAAE,SAAS,OAAO,MAAM,MAAM,KAAK,IAAI,cAAc;AAC3D,QAAM,eAAe,iBAAiB,UAAU,WAAW,MAAM;AACjE,QAAM,cAAc;AAAA,IACnB,MACC,SACG,eAAe;AAAA,MACf;AAAA,MACA,MAAM,OAAO;AAAA,MACb,QAAQ;AAAA,MACR;AAAA,MACA,YAAY,qBAAqB,OAAO,SAAS,EAAE,MAAM,MAAM,KAAK,CAAC;AAAA,MACrE;AAAA,MACA,YAAY,OAAO;AAAA,IACpB,CAAC,IACA;AAAA,IACJ,CAAC,QAAQ,QAAQ,OAAO,SAAS,MAAM,MAAM,MAAM,YAAY;AAAA,EAChE;AACA,QAAM,UAAU,SAAS,iBAAiB,MAAiC,IAAI;AAE/E,QAAM,SAAS;AAAA,IACd,MACC,WAAW;AAAA,MACV,QAAQ,gBAAgB,QAAQ,MAAM,MAAM;AAAA,MAC5C,UAAU,gBAAgB,QAAQ,MAAM,QAAQ;AAAA,MAChD,SAAS,gBAAgB,QAAQ,MAAM,OAAO;AAAA,IAC/C;AAAA,IACD,CAAC,OAAO;AAAA,EACT;AACA,MAAI,CAAC,WAAW,CAAC,UAAU,CAAC,aAAa;AACxC,WACC,iCACE;AAAA,mBAAa;AAAA,MACb;AAAA,OACF;AAAA,EAEF;AAEA,QAAM,EAAE,WAAW,IAAI;AAEvB,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
+ }
@@ -0,0 +1,16 @@
1
+ import {
2
+ useOptionalFormEngine
3
+ } from "./chunk-HBXM7CPI.js";
4
+
5
+ // src/components/internals/grid-container.tsx
6
+ import { GRID_CONTAINER_CLASS, getDefaultLayoutTheme } from "@schema-engine/layout";
7
+ import { Fragment, jsx } from "react/jsx-runtime";
8
+ function GridContainer({ children }) {
9
+ const layout = useOptionalFormEngine()?.engine.getLayout() ?? getDefaultLayoutTheme();
10
+ if (layout.grid.query !== "container") return /* @__PURE__ */ jsx(Fragment, { children });
11
+ return /* @__PURE__ */ jsx("div", { className: GRID_CONTAINER_CLASS, "data-se-theme": layout.id, children });
12
+ }
13
+
14
+ export {
15
+ GridContainer
16
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/components/internals/grid-container.tsx"],
4
+ "sourcesContent": ["import type React from 'react';\nimport { GRID_CONTAINER_CLASS, getDefaultLayoutTheme } from '@schema-engine/layout';\nimport { useOptionalFormEngine } from '@/hooks/use-form-context';\n\n/**\n * Wraps one grid in the element a `query: 'container'` layout theme measures its breakpoints against.\n *\n * @remarks\n * Renders only its children when the engine's theme queries the viewport, so the markup of a media\n * theme is unchanged. The step grid uses it directly; the grid of a container element gets it\n * through `ChildGrid`. The theme comes from the engine context, with the library default outside a\n * `FormEngineProvider`.\n */\nexport function GridContainer({ children }: { children: React.ReactNode }) {\n\tconst layout = useOptionalFormEngine()?.engine.getLayout() ?? getDefaultLayoutTheme();\n\tif (layout.grid.query !== 'container') return <>{children}</>;\n\treturn (\n\t\t<div className={GRID_CONTAINER_CLASS} data-se-theme={layout.id}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": ";;;;;AACA,SAAS,sBAAsB,6BAA6B;AAcb;AAFxC,SAAS,cAAc,EAAE,SAAS,GAAkC;AAC1E,QAAM,SAAS,sBAAsB,GAAG,OAAO,UAAU,KAAK,sBAAsB;AACpF,MAAI,OAAO,KAAK,UAAU,YAAa,QAAO,gCAAG,UAAS;AAC1D,SACC,oBAAC,SAAI,WAAW,sBAAsB,iBAAe,OAAO,IAC1D,UACF;AAEF;",
6
+ "names": []
7
+ }
@@ -7,8 +7,8 @@ import {
7
7
 
8
8
  // src/hooks/use-form-context.ts
9
9
  import { useContext, useMemo, useSyncExternalStore } from "react";
10
- import { GRID_CLASS, getDefaultLayoutTheme, getGridVariables } from "@schema-engine/layout";
11
- function useFormInstanceActions() {
10
+ import { getDefaultLayoutTheme } from "@schema-engine/layout";
11
+ function useFormWizard() {
12
12
  const { runtime } = useFormStateContext();
13
13
  const { current, navigating, steps } = useSyncExternalStore(
14
14
  runtime.subscribe,
@@ -37,20 +37,11 @@ function useOptionalFormEngine() {
37
37
  function useLayoutThemeId() {
38
38
  return (useOptionalFormEngine()?.engine.getLayout() ?? getDefaultLayoutTheme()).id;
39
39
  }
40
- function useChildGridProps(elements) {
41
- const layout = useOptionalFormEngine()?.engine.getLayout() ?? getDefaultLayoutTheme();
42
- return {
43
- className: `se-form-grid ${GRID_CLASS}`,
44
- "data-se-theme": layout.id,
45
- style: getGridVariables(void 0, layout.grid, elements)
46
- };
47
- }
48
40
 
49
41
  export {
50
- useFormInstanceActions,
42
+ useFormWizard,
51
43
  useFormRuntime,
52
44
  useFormEngine,
53
45
  useOptionalFormEngine,
54
- useLayoutThemeId,
55
- useChildGridProps
46
+ useLayoutThemeId
56
47
  };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/hooks/use-form-context.ts"],
4
+ "sourcesContent": ["import { useContext, useMemo, useSyncExternalStore } from 'react';\nimport type { EngineOutputMaps, FormRuntime, FormWizard } from '@schema-engine/forms';\nimport { useFormStateContext } from './form-state/context';\nimport { getDefaultLayoutTheme } from '@schema-engine/layout';\nimport { FormEngineContext } from '../components/provider';\nimport type { FormEngineContextValue } from '../components/provider';\n\n/**\n * The form's wizard: where it is, and the commands that move it.\n *\n * @remarks Must be used within a FormProvider. See {@link FormWizard} for the commands' outcomes and the steps' state.\n */\nexport function useFormWizard(): FormWizard {\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"],
5
+ "mappings": ";;;;;;;;AAAA,SAAS,YAAY,SAAS,4BAA4B;AAG1D,SAAS,6BAA6B;AAS/B,SAAS,gBAA4B;AAC3C,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;",
6
+ "names": []
7
+ }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  FormElement
3
- } from "./chunk-KG6Q7MNI.js";
3
+ } from "./chunk-HX66MLOM.js";
4
4
 
5
5
  // src/components/internals/form-elements.tsx
6
6
  import {
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  FieldHostContext
3
3
  } from "./chunk-WOTW7A2I.js";
4
+ import {
5
+ ElementError
6
+ } from "./chunk-5XCNXEJB.js";
4
7
  import {
5
8
  useFormEngine
6
- } from "./chunk-AALIXTCD.js";
9
+ } from "./chunk-HBXM7CPI.js";
7
10
  import {
8
11
  useContainerSelector
9
12
  } from "./chunk-ZWEYALBG.js";
10
- import {
11
- ElementError
12
- } from "./chunk-5XCNXEJB.js";
13
13
 
14
14
  // src/components/internals/field-renderer.tsx
15
15
  import { applyFieldOverlay, isNormalizedElementConfig } from "@schema-engine/forms";
@@ -1,19 +1,22 @@
1
1
  import {
2
2
  RecipeRenderer
3
- } from "./chunk-SED35QJC.js";
3
+ } from "./chunk-CQB4L54B.js";
4
4
  import {
5
5
  FormElements
6
- } from "./chunk-K3LLWGXU.js";
6
+ } from "./chunk-HNUS4XKC.js";
7
7
  import {
8
8
  FormEngineProvider
9
9
  } from "./chunk-6RI4LMM6.js";
10
10
  import {
11
11
  FormProvider
12
- } from "./chunk-WRJWSEL7.js";
12
+ } from "./chunk-65FTA4N2.js";
13
13
  import {
14
- useFormInstanceActions,
14
+ GridContainer
15
+ } from "./chunk-FV6KW2EK.js";
16
+ import {
17
+ useFormWizard,
15
18
  useOptionalFormEngine
16
- } from "./chunk-AALIXTCD.js";
19
+ } from "./chunk-HBXM7CPI.js";
17
20
 
18
21
  // src/components/internals/form-renderer.tsx
19
22
  import { GRID_CLASS, getAppearanceAttributes, getGridVariables } from "@schema-engine/layout";
@@ -22,6 +25,7 @@ import {
22
25
  isNormalizedFormConfig,
23
26
  getRenderableSteps,
24
27
  assertFormEngine,
28
+ gridTrackItems,
25
29
  stepGrid
26
30
  } from "@schema-engine/forms";
27
31
  import { getViewRecipe } from "@schema-engine/forms/recipes";
@@ -41,15 +45,15 @@ function StepFields({
41
45
  "data-se-step": step.id,
42
46
  style: step.style,
43
47
  ...getAppearanceAttributes(step.appearance),
44
- children: step.elements.length > 0 && /* @__PURE__ */ jsx(
48
+ children: step.elements.length > 0 && /* @__PURE__ */ jsx(GridContainer, { children: /* @__PURE__ */ jsx(
45
49
  "div",
46
50
  {
47
51
  className: `se-form-grid ${GRID_CLASS}`,
48
52
  "data-se-theme": layout.id,
49
- style: getGridVariables(stepGrid(config, step), layout.grid, step.elements),
53
+ style: getGridVariables(stepGrid(config, step), layout.grid, gridTrackItems(step.elements)),
50
54
  children: /* @__PURE__ */ jsx(FormElements, { elements: step.elements })
51
55
  }
52
- )
56
+ ) })
53
57
  }
54
58
  );
55
59
  }
@@ -58,7 +62,7 @@ function FormElementsRenderer({
58
62
  layout,
59
63
  children
60
64
  }) {
61
- const { current } = useFormInstanceActions();
65
+ const { current } = useFormWizard();
62
66
  const engineContext = useOptionalFormEngine();
63
67
  const recipe = engineContext ? getViewRecipe(engineContext.engine, config) : void 0;
64
68
  const steps = getRenderableSteps(config, current);
@@ -0,0 +1,7 @@
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 { GridContainer } from './grid-container';\nimport { useFormWizard, 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\tgridTrackItems,\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<GridContainer>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={`se-form-grid ${GRID_CLASS}`}\n\t\t\t\t\t\tdata-se-theme={layout.id}\n\t\t\t\t\t\tstyle={getGridVariables(stepGrid(config, step), layout.grid, gridTrackItems(step.elements))}\n\t\t\t\t\t>\n\t\t\t\t\t\t<FormElements elements={step.elements} />\n\t\t\t\t\t</div>\n\t\t\t\t</GridContainer>\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 } = useFormWizard();\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;AAOxB;AAAA,EAKC;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,qBAAqB;AAK5B,SA+DE,UA/DF,KAsIC,YAtID;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,oBAAC,iBACA;AAAA,QAAC;AAAA;AAAA,UACA,WAAW,gBAAgB,UAAU;AAAA,UACrC,iBAAe,OAAO;AAAA,UACtB,OAAO,iBAAiB,SAAS,QAAQ,IAAI,GAAG,OAAO,MAAM,eAAe,KAAK,QAAQ,CAAC;AAAA,UAE1F,8BAAC,gBAAa,UAAU,KAAK,UAAU;AAAA;AAAA,MACxC,GACD;AAAA;AAAA,EAEF;AAEF;AAEA,SAAS,qBAKP;AAAA,EACD;AAAA,EACA;AAAA,EACA;AACD,GAIG;AACF,QAAM,EAAE,QAAQ,IAAI,cAAc;AAClC,QAAM,gBAAgB,sBAA+D;AACrF,QAAM,SAAS,gBAAgB,cAAc,cAAc,QAAQ,MAAM,IAAI;AAC7E,QAAM,QAAQ,mBAAmB,QAAQ,OAAO;AAEhD,MAAI,MAAM,WAAW,EAAG,QAAO;AAE/B,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc,MACb,gCACE,gBAAM,IAAI,CAAC,SACX,oBAAC,cAAyB,MAAY,QAAgB,UAArC,KAAK,EAAgD,CACtE,GACF;AAAA,MAGA;AAAA;AAAA,EACF;AAEF;AA2BA,SAAS,kBAMP;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AACD,GAGG;AACF,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA,+BAAC,SAAI,WAAW,WAAW,SAAS,GAAG,KAAK,GAAG,OAC9C;AAAA,4BAAC,oBAAiB,SAAS,OAAO,IAAI,KAAK,OAAO,KAAK;AAAA,QACvD,oBAAC,wBAAqB,QAAgB,QACpC,UACF;AAAA,SACD;AAAA;AAAA,EACD;AAEF;AAUA,SAAS,UAOR,QACA,QACgG;AAChG,MAAI,uBAAuB,MAAM,EAAG,QAAO,OAAO,aAAa,MAAM;AACrE,SAAO,OAAO,aAAa,MAAM;AAMlC;AAUO,SAAS,aAMd,EAAE,QAAQ,GAAG,MAAM,GAAwE;AAC5F,QAAM,kBAAkB,sBAA+D;AACvF,QAAM,iBAAiB,UAAU,iBAAiB;AAClD,QAAM,EAAE,QAAQ,OAAO,IAAI,QAAQ,MAAM;AACxC,qBAAiB,gBAAgB,MAAM,MAAM;AAC7C,WAAO,EAAE,QAAQ,UAAU,gBAAgB,MAAM,MAAM,GAAG,QAAQ,eAAe,UAAU,EAAE;AAAA,EAC9F,GAAG,CAAC,MAAM,QAAQ,cAAc,CAAC;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
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/contexts/view-context.tsx"],
4
+ "sourcesContent": ["import { createContext, useContext, type ReactNode } from 'react';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\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 StandardSchemaV1>(\n\tslot: RecipeSlot,\n\tschema: TSchema,\n): StandardSchemaV1.InferOutput<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,cACf,MACA,QACwC;AACxC,SAAO,cAAc,eAAe,EAAE,YAAY,MAAM,MAAM;AAC/D;",
6
+ "names": []
7
+ }
@@ -0,0 +1,34 @@
1
+ import {
2
+ GridContainer
3
+ } from "./chunk-FV6KW2EK.js";
4
+ import {
5
+ useOptionalFormEngine
6
+ } from "./chunk-HBXM7CPI.js";
7
+
8
+ // src/components/internals/child-grid.tsx
9
+ import { GRID_CLASS, GRID_SUBGRID_CLASS, getDefaultLayoutTheme, getGridVariables } from "@schema-engine/layout";
10
+ import { gridTrackItems } from "@schema-engine/forms";
11
+ import { jsx } from "react/jsx-runtime";
12
+ function ChildGrid(props) {
13
+ const { className, children } = props;
14
+ const layout = useOptionalFormEngine()?.engine.getLayout() ?? getDefaultLayoutTheme();
15
+ const classes = (subgrid) => ["se-form-grid", GRID_CLASS, ...subgrid ? [GRID_SUBGRID_CLASS] : [], ...className ? [className] : []].join(
16
+ " "
17
+ );
18
+ if (props.subgrid) {
19
+ return /* @__PURE__ */ jsx("div", { className: classes(true), "data-se-theme": layout.id, children });
20
+ }
21
+ return /* @__PURE__ */ jsx(GridContainer, { children: /* @__PURE__ */ jsx(
22
+ "div",
23
+ {
24
+ className: classes(false),
25
+ "data-se-theme": layout.id,
26
+ style: getGridVariables(void 0, layout.grid, gridTrackItems(props.elements)),
27
+ children
28
+ }
29
+ ) });
30
+ }
31
+
32
+ export {
33
+ ChildGrid
34
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/components/internals/child-grid.tsx"],
4
+ "sourcesContent": ["import type React from 'react';\nimport { GRID_CLASS, GRID_SUBGRID_CLASS, getDefaultLayoutTheme, getGridVariables } from '@schema-engine/layout';\nimport { gridTrackItems } from '@schema-engine/forms';\nimport { useOptionalFormEngine } from '@/hooks/use-form-context';\nimport { GridContainer } from './grid-container';\n\ninterface ChildGridBaseProps {\n\t/** Classes added to the grid element, after `se-form-grid se-grid`. */\n\tclassName?: string;\n\tchildren?: React.ReactNode;\n}\n\n/** A grid with tracks of its own, decided by the elements it places. */\ninterface OwnTracksChildGridProps extends ChildGridBaseProps {\n\t/** The elements the grid places, which decide its tracks. */\n\telements: readonly unknown[];\n\tsubgrid?: false;\n}\n\n/** A grid on the tracks of the grid its container sits in, which has no `elements` to read. */\ninterface SubgridChildGridProps extends ChildGridBaseProps {\n\t/**\n\t * Lay the children out on the column tracks and gap of the grid this container sits in, instead of tracks of its own.\n\t *\n\t * @remarks\n\t * Set it when the container's own `grid` has `subgrid: true`. Every box between that container's item\n\t * and this grid must carry the `se-subgrid` class (`GRID_SUBGRID_CLASS` of `@schema-engine/layout`),\n\t * and none may be a query container or a `<fieldset>`, or the browser drops the tracks without a warning.\n\t */\n\tsubgrid: true;\n\telements?: never;\n}\n\n/** Either `elements`, for tracks of its own, or `subgrid`, for the tracks of the grid around the container; never both. */\nexport type ChildGridProps = OwnTracksChildGridProps | SubgridChildGridProps;\n\n/**\n * The grid of a container element's children, such as a fieldset's or an array row's.\n *\n * @remarks\n * The grid lays its direct children out the way a step does. It takes twelve tracks when an element sets `width`\n * or `offset`, counting the children of a subgrid element among them, and otherwise stays the engine's single\n * column. The theme comes from the engine context, with the library default outside a `FormEngineProvider`. Under\n * a `query: 'container'` layout theme it also renders the `se-grid-container` wrapper around the grid, so the\n * breakpoints follow that wrapper and a nested grid follows its own box; under a theme that queries the window it\n * renders the grid alone.\n *\n * With `subgrid` the grid has no tracks and no wrapper of its own: it carries the `se-subgrid` class, no\n * inline track variables, and queries the breakpoints of the grid around the container.\n */\nexport function ChildGrid(props: ChildGridProps) {\n\tconst { className, children } = props;\n\tconst layout = useOptionalFormEngine()?.engine.getLayout() ?? getDefaultLayoutTheme();\n\tconst classes = (subgrid: boolean) =>\n\t\t['se-form-grid', GRID_CLASS, ...(subgrid ? [GRID_SUBGRID_CLASS] : []), ...(className ? [className] : [])].join(\n\t\t\t' ',\n\t\t);\n\tif (props.subgrid) {\n\t\treturn (\n\t\t\t<div className={classes(true)} data-se-theme={layout.id}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t}\n\treturn (\n\t\t<GridContainer>\n\t\t\t<div\n\t\t\t\tclassName={classes(false)}\n\t\t\t\tdata-se-theme={layout.id}\n\t\t\t\tstyle={getGridVariables(undefined, layout.grid, gridTrackItems(props.elements))}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</GridContainer>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;AACA,SAAS,YAAY,oBAAoB,uBAAuB,wBAAwB;AACxF,SAAS,sBAAsB;AAyD5B;AATI,SAAS,UAAU,OAAuB;AAChD,QAAM,EAAE,WAAW,SAAS,IAAI;AAChC,QAAM,SAAS,sBAAsB,GAAG,OAAO,UAAU,KAAK,sBAAsB;AACpF,QAAM,UAAU,CAAC,YAChB,CAAC,gBAAgB,YAAY,GAAI,UAAU,CAAC,kBAAkB,IAAI,CAAC,GAAI,GAAI,YAAY,CAAC,SAAS,IAAI,CAAC,CAAE,EAAE;AAAA,IACzG;AAAA,EACD;AACD,MAAI,MAAM,SAAS;AAClB,WACC,oBAAC,SAAI,WAAW,QAAQ,IAAI,GAAG,iBAAe,OAAO,IACnD,UACF;AAAA,EAEF;AACA,SACC,oBAAC,iBACA;AAAA,IAAC;AAAA;AAAA,MACA,WAAW,QAAQ,KAAK;AAAA,MACxB,iBAAe,OAAO;AAAA,MACtB,OAAO,iBAAiB,QAAW,OAAO,MAAM,eAAe,MAAM,QAAQ,CAAC;AAAA,MAE7E;AAAA;AAAA,EACF,GACD;AAEF;",
6
+ "names": []
7
+ }
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-WOTW7A2I.js";
4
4
  import {
5
5
  useLayoutThemeId
6
- } from "./chunk-AALIXTCD.js";
6
+ } from "./chunk-HBXM7CPI.js";
7
7
 
8
8
  // src/hooks/use-field.ts
9
9
  import { useContext } from "react";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  FormDebugger
3
- } from "../../chunk-ISDPSORR.js";
3
+ } from "../../chunk-BLBPZL42.js";
4
4
  import "../../chunk-ULKJHK3P.js";
5
+ import "../../chunk-K66J2V73.js";
6
+ import "../../chunk-7SE2EAS6.js";
5
7
  import "../../chunk-NDFV5AQW.js";
6
8
  import "../../chunk-MBN4WIAC.js";
7
- import "../../chunk-K66J2V73.js";
8
- import "../../chunk-DTJ64NZQ.js";
9
+ import "../../chunk-KYBOEYMM.js";
9
10
  import "../../chunk-EYDB6NR6.js";
10
- import "../../chunk-IXRV3YCF.js";
11
11
  import "../../chunk-XWHP2AGG.js";
12
- import "../../chunk-AALIXTCD.js";
12
+ import "../../chunk-HBXM7CPI.js";
13
13
  import "../../chunk-ZWEYALBG.js";
14
14
  import "../../chunk-GH2QO3WC.js";
15
15
  export {
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  FormDebugger
3
- } from "../../chunk-ISDPSORR.js";
3
+ } from "../../chunk-BLBPZL42.js";
4
4
  import "../../chunk-ULKJHK3P.js";
5
+ import "../../chunk-K66J2V73.js";
6
+ import "../../chunk-7SE2EAS6.js";
5
7
  import "../../chunk-NDFV5AQW.js";
6
8
  import "../../chunk-MBN4WIAC.js";
7
- import "../../chunk-K66J2V73.js";
8
- import "../../chunk-DTJ64NZQ.js";
9
+ import "../../chunk-KYBOEYMM.js";
9
10
  import "../../chunk-EYDB6NR6.js";
10
- import "../../chunk-IXRV3YCF.js";
11
11
  import "../../chunk-XWHP2AGG.js";
12
- import "../../chunk-AALIXTCD.js";
12
+ import "../../chunk-HBXM7CPI.js";
13
13
  import "../../chunk-ZWEYALBG.js";
14
14
  import "../../chunk-GH2QO3WC.js";
15
15
  export {
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  FormProvider
3
- } from "../chunk-WRJWSEL7.js";
3
+ } from "../chunk-65FTA4N2.js";
4
4
  import "../chunk-USRF3EEE.js";
5
5
  import "../chunk-CPJMN2IH.js";
6
6
  import "../chunk-H25SUEJE.js";
7
7
  import "../chunk-XWHP2AGG.js";
8
- import "../chunk-AALIXTCD.js";
8
+ import "../chunk-HBXM7CPI.js";
9
9
  import "../chunk-ZWEYALBG.js";
10
10
  import "../chunk-GH2QO3WC.js";
11
11
  export {
@@ -1,39 +1,40 @@
1
1
  import "../chunk-IHX6VMAQ.js";
2
2
  import {
3
3
  FormRenderer
4
- } from "../chunk-QUZN42PL.js";
5
- import "../chunk-SED35QJC.js";
6
- import "../chunk-K3LLWGXU.js";
7
- import "../chunk-KG6Q7MNI.js";
4
+ } from "../chunk-J5P7HUMV.js";
5
+ import "../chunk-CQB4L54B.js";
6
+ import "../chunk-HNUS4XKC.js";
7
+ import "../chunk-HX66MLOM.js";
8
8
  import "../chunk-HT43MPKW.js";
9
- import "../chunk-7RUFT6EJ.js";
10
- import "../chunk-WFRWVH4X.js";
11
9
  import "../chunk-7QNWPTT7.js";
10
+ import "../chunk-7RUFT6EJ.js";
11
+ import "../chunk-WJYJ3Q4J.js";
12
12
  import "../chunk-WOTW7A2I.js";
13
+ import "../chunk-5XCNXEJB.js";
13
14
  import "../chunk-ULKJHK3P.js";
15
+ import "../chunk-K66J2V73.js";
16
+ import "../chunk-7SE2EAS6.js";
14
17
  import "../chunk-NDFV5AQW.js";
15
18
  import "../chunk-MBN4WIAC.js";
16
- import "../chunk-K66J2V73.js";
17
- import "../chunk-DTJ64NZQ.js";
19
+ import "../chunk-KYBOEYMM.js";
18
20
  import "../chunk-EYDB6NR6.js";
19
- import "../chunk-IXRV3YCF.js";
20
21
  import {
21
22
  FormEngineProvider
22
23
  } from "../chunk-6RI4LMM6.js";
23
24
  import {
24
25
  FormProvider
25
- } from "../chunk-WRJWSEL7.js";
26
+ } from "../chunk-65FTA4N2.js";
26
27
  import "../chunk-USRF3EEE.js";
27
28
  import "../chunk-CPJMN2IH.js";
28
29
  import "../chunk-H25SUEJE.js";
29
30
  import "../chunk-XWHP2AGG.js";
30
- import "../chunk-AALIXTCD.js";
31
+ import "../chunk-FV6KW2EK.js";
32
+ import "../chunk-HBXM7CPI.js";
31
33
  import "../chunk-ZWEYALBG.js";
32
34
  import {
33
35
  FormEngineContext,
34
36
  createFormEngineContextValue
35
37
  } from "../chunk-GH2QO3WC.js";
36
- import "../chunk-5XCNXEJB.js";
37
38
  export {
38
39
  FormEngineContext,
39
40
  FormEngineProvider,
@@ -0,0 +1,43 @@
1
+ import type React from 'react';
2
+ interface ChildGridBaseProps {
3
+ /** Classes added to the grid element, after `se-form-grid se-grid`. */
4
+ className?: string;
5
+ children?: React.ReactNode;
6
+ }
7
+ /** A grid with tracks of its own, decided by the elements it places. */
8
+ interface OwnTracksChildGridProps extends ChildGridBaseProps {
9
+ /** The elements the grid places, which decide its tracks. */
10
+ elements: readonly unknown[];
11
+ subgrid?: false;
12
+ }
13
+ /** A grid on the tracks of the grid its container sits in, which has no `elements` to read. */
14
+ interface SubgridChildGridProps extends ChildGridBaseProps {
15
+ /**
16
+ * Lay the children out on the column tracks and gap of the grid this container sits in, instead of tracks of its own.
17
+ *
18
+ * @remarks
19
+ * Set it when the container's own `grid` has `subgrid: true`. Every box between that container's item
20
+ * and this grid must carry the `se-subgrid` class (`GRID_SUBGRID_CLASS` of `@schema-engine/layout`),
21
+ * and none may be a query container or a `<fieldset>`, or the browser drops the tracks without a warning.
22
+ */
23
+ subgrid: true;
24
+ elements?: never;
25
+ }
26
+ /** Either `elements`, for tracks of its own, or `subgrid`, for the tracks of the grid around the container; never both. */
27
+ export type ChildGridProps = OwnTracksChildGridProps | SubgridChildGridProps;
28
+ /**
29
+ * The grid of a container element's children, such as a fieldset's or an array row's.
30
+ *
31
+ * @remarks
32
+ * The grid lays its direct children out the way a step does. It takes twelve tracks when an element sets `width`
33
+ * or `offset`, counting the children of a subgrid element among them, and otherwise stays the engine's single
34
+ * column. The theme comes from the engine context, with the library default outside a `FormEngineProvider`. Under
35
+ * a `query: 'container'` layout theme it also renders the `se-grid-container` wrapper around the grid, so the
36
+ * breakpoints follow that wrapper and a nested grid follows its own box; under a theme that queries the window it
37
+ * renders the grid alone.
38
+ *
39
+ * With `subgrid` the grid has no tracks and no wrapper of its own: it carries the `se-subgrid` class, no
40
+ * inline track variables, and queries the breakpoints of the grid around the container.
41
+ */
42
+ export declare function ChildGrid(props: ChildGridProps): React.JSX.Element;
43
+ export {};
@@ -0,0 +1,10 @@
1
+ import {
2
+ ChildGrid
3
+ } from "../../chunk-SEWP4GIN.js";
4
+ import "../../chunk-FV6KW2EK.js";
5
+ import "../../chunk-HBXM7CPI.js";
6
+ import "../../chunk-ZWEYALBG.js";
7
+ import "../../chunk-GH2QO3WC.js";
8
+ export {
9
+ ChildGrid
10
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  FormElement
3
- } from "../../chunk-KG6Q7MNI.js";
3
+ } from "../../chunk-HX66MLOM.js";
4
4
  import "../../chunk-HT43MPKW.js";
5
- import "../../chunk-7RUFT6EJ.js";
6
- import "../../chunk-WFRWVH4X.js";
7
5
  import "../../chunk-7QNWPTT7.js";
6
+ import "../../chunk-7RUFT6EJ.js";
7
+ import "../../chunk-WJYJ3Q4J.js";
8
8
  import "../../chunk-WOTW7A2I.js";
9
+ import "../../chunk-5XCNXEJB.js";
9
10
  import "../../chunk-ULKJHK3P.js";
11
+ import "../../chunk-K66J2V73.js";
12
+ import "../../chunk-7SE2EAS6.js";
10
13
  import "../../chunk-NDFV5AQW.js";
11
14
  import "../../chunk-MBN4WIAC.js";
12
- import "../../chunk-K66J2V73.js";
13
- import "../../chunk-DTJ64NZQ.js";
15
+ import "../../chunk-KYBOEYMM.js";
14
16
  import "../../chunk-EYDB6NR6.js";
15
- import "../../chunk-IXRV3YCF.js";
16
17
  import "../../chunk-H25SUEJE.js";
17
18
  import "../../chunk-XWHP2AGG.js";
18
- import "../../chunk-AALIXTCD.js";
19
+ import "../../chunk-HBXM7CPI.js";
19
20
  import "../../chunk-ZWEYALBG.js";
20
21
  import "../../chunk-GH2QO3WC.js";
21
- import "../../chunk-5XCNXEJB.js";
22
22
  export {
23
23
  FormElement
24
24
  };
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  FormElements
3
- } from "../../chunk-K3LLWGXU.js";
4
- import "../../chunk-KG6Q7MNI.js";
3
+ } from "../../chunk-HNUS4XKC.js";
4
+ import "../../chunk-HX66MLOM.js";
5
5
  import "../../chunk-HT43MPKW.js";
6
- import "../../chunk-7RUFT6EJ.js";
7
- import "../../chunk-WFRWVH4X.js";
8
6
  import "../../chunk-7QNWPTT7.js";
7
+ import "../../chunk-7RUFT6EJ.js";
8
+ import "../../chunk-WJYJ3Q4J.js";
9
9
  import "../../chunk-WOTW7A2I.js";
10
+ import "../../chunk-5XCNXEJB.js";
10
11
  import "../../chunk-ULKJHK3P.js";
12
+ import "../../chunk-K66J2V73.js";
13
+ import "../../chunk-7SE2EAS6.js";
11
14
  import "../../chunk-NDFV5AQW.js";
12
15
  import "../../chunk-MBN4WIAC.js";
13
- import "../../chunk-K66J2V73.js";
14
- import "../../chunk-DTJ64NZQ.js";
16
+ import "../../chunk-KYBOEYMM.js";
15
17
  import "../../chunk-EYDB6NR6.js";
16
- import "../../chunk-IXRV3YCF.js";
17
18
  import "../../chunk-H25SUEJE.js";
18
19
  import "../../chunk-XWHP2AGG.js";
19
- import "../../chunk-AALIXTCD.js";
20
+ import "../../chunk-HBXM7CPI.js";
20
21
  import "../../chunk-ZWEYALBG.js";
21
22
  import "../../chunk-GH2QO3WC.js";
22
- import "../../chunk-5XCNXEJB.js";
23
23
  export {
24
24
  FormElements
25
25
  };