@schema-engine/forms 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.
Files changed (265) hide show
  1. package/README.md +6 -5
  2. package/dist/agent-tool/index.js +13 -6
  3. package/dist/agent-tool/index.js.map +2 -2
  4. package/dist/builder/types.utils.d.ts +1 -0
  5. package/dist/chunk-2MKT7OIS.js +40 -0
  6. package/dist/chunk-2MKT7OIS.js.map +7 -0
  7. package/dist/{chunk-HPPFSWIV.js → chunk-2U4WRMPB.js} +26 -22
  8. package/dist/chunk-2U4WRMPB.js.map +7 -0
  9. package/dist/{chunk-YUUDXRBW.js → chunk-3ABPK4QP.js} +62 -2
  10. package/dist/chunk-3ABPK4QP.js.map +7 -0
  11. package/dist/chunk-3BMTC224.js +21 -0
  12. package/dist/chunk-3BMTC224.js.map +7 -0
  13. package/dist/chunk-3GZKJSXI.js +49 -0
  14. package/dist/chunk-3GZKJSXI.js.map +7 -0
  15. package/dist/{chunk-NJXKMF67.js → chunk-4HSGF4WX.js} +33 -52
  16. package/dist/chunk-4HSGF4WX.js.map +7 -0
  17. package/dist/chunk-4SWCTY7K.js +8 -0
  18. package/dist/chunk-4SWCTY7K.js.map +7 -0
  19. package/dist/{chunk-KLATKWUA.js → chunk-4YANBG3M.js} +1 -1
  20. package/dist/chunk-53SXH32V.js +43 -0
  21. package/dist/chunk-53SXH32V.js.map +7 -0
  22. package/dist/{chunk-DP7SYLLI.js → chunk-6OJ46PR2.js} +15 -20
  23. package/dist/chunk-6OJ46PR2.js.map +7 -0
  24. package/dist/chunk-AAOFZ27F.js +39 -0
  25. package/dist/chunk-AAOFZ27F.js.map +7 -0
  26. package/dist/{chunk-NJTLBSTR.js → chunk-AROD3D4R.js} +1 -1
  27. package/dist/{chunk-Q5LEK7CI.js → chunk-AT2NHSY3.js} +1 -1
  28. package/dist/chunk-B2PMISHZ.js +43 -0
  29. package/dist/chunk-B2PMISHZ.js.map +7 -0
  30. package/dist/chunk-BHCSZ4VO.js +27 -0
  31. package/dist/chunk-BHCSZ4VO.js.map +7 -0
  32. package/dist/chunk-BXGE5IXF.js +38 -0
  33. package/dist/chunk-BXGE5IXF.js.map +7 -0
  34. package/dist/chunk-CW7UMF3K.js +48 -0
  35. package/dist/chunk-CW7UMF3K.js.map +7 -0
  36. package/dist/{chunk-BLFLCSG3.js → chunk-DEWI6E3O.js} +2 -2
  37. package/dist/chunk-DSPTVDHL.js +45 -0
  38. package/dist/chunk-DSPTVDHL.js.map +7 -0
  39. package/dist/chunk-DU26WGQA.js +27 -0
  40. package/dist/chunk-DU26WGQA.js.map +7 -0
  41. package/dist/{chunk-GH34XFCC.js → chunk-EO5CW7XD.js} +2 -2
  42. package/dist/{chunk-A5VLMQAK.js → chunk-ERSCXYVE.js} +2 -2
  43. package/dist/chunk-EWNYEO6T.js.map +7 -0
  44. package/dist/{chunk-CRVXBWSY.js → chunk-FGL773EA.js} +1 -1
  45. package/dist/chunk-FVW5Z2CC.js +36 -0
  46. package/dist/chunk-FVW5Z2CC.js.map +7 -0
  47. package/dist/chunk-GDUF2SWI.js +32 -0
  48. package/dist/chunk-GDUF2SWI.js.map +7 -0
  49. package/dist/{chunk-GQHMU3AR.js → chunk-HEWLTCU4.js} +4 -4
  50. package/dist/{chunk-6R2MBQPL.js → chunk-HKLDRUFN.js} +4 -1
  51. package/dist/{chunk-6R2MBQPL.js.map → chunk-HKLDRUFN.js.map} +2 -2
  52. package/dist/{chunk-J2FC5K4B.js → chunk-IHXXPIFD.js} +1 -2
  53. package/dist/chunk-IHXXPIFD.js.map +7 -0
  54. package/dist/{chunk-GRZU6F7Q.js → chunk-KANWAQNI.js} +33 -38
  55. package/dist/chunk-KANWAQNI.js.map +7 -0
  56. package/dist/chunk-KWQJFQII.js +52 -0
  57. package/dist/chunk-KWQJFQII.js.map +7 -0
  58. package/dist/{chunk-PH3LWLYN.js → chunk-MFZYG6DN.js} +3 -2
  59. package/dist/chunk-MFZYG6DN.js.map +7 -0
  60. package/dist/{chunk-WUTGZYP4.js → chunk-MG7VFU6V.js} +2 -2
  61. package/dist/chunk-OG3OLZ5R.js +184 -0
  62. package/dist/chunk-OG3OLZ5R.js.map +7 -0
  63. package/dist/{chunk-WLDCYUN6.js → chunk-OKJLJ3GI.js} +1 -1
  64. package/dist/chunk-QDU55RCZ.js.map +7 -0
  65. package/dist/chunk-QFQB5EBY.js +38 -0
  66. package/dist/chunk-QFQB5EBY.js.map +7 -0
  67. package/dist/{chunk-6IZYNHZ3.js → chunk-RDQFBY6S.js} +45 -31
  68. package/dist/chunk-RDQFBY6S.js.map +7 -0
  69. package/dist/chunk-RMX7C43O.js.map +7 -0
  70. package/dist/chunk-T5JAAPFB.js +40 -0
  71. package/dist/chunk-T5JAAPFB.js.map +7 -0
  72. package/dist/chunk-TDXFT6Q5.js +57 -0
  73. package/dist/chunk-TDXFT6Q5.js.map +7 -0
  74. package/dist/{chunk-JA5ET6MC.js → chunk-TWQU2IGF.js} +6 -6
  75. package/dist/chunk-V3GYAG33.js +12 -0
  76. package/dist/chunk-V3GYAG33.js.map +7 -0
  77. package/dist/{chunk-V5H7L5PJ.js → chunk-WHLID5BN.js} +59 -23
  78. package/dist/{chunk-V5H7L5PJ.js.map → chunk-WHLID5BN.js.map} +2 -2
  79. package/dist/chunk-XKINCUXT.js +51 -0
  80. package/dist/chunk-XKINCUXT.js.map +7 -0
  81. package/dist/chunk-XLEOTW6H.js +50 -0
  82. package/dist/chunk-XLEOTW6H.js.map +7 -0
  83. package/dist/chunk-YHSOS3IH.js +53 -0
  84. package/dist/chunk-YHSOS3IH.js.map +7 -0
  85. package/dist/chunk-YKXOBPSU.js +19 -0
  86. package/dist/chunk-YKXOBPSU.js.map +7 -0
  87. package/dist/{chunk-ZYP3MIH3.js → chunk-YW2KZUAM.js} +5 -3
  88. package/dist/chunk-YW2KZUAM.js.map +7 -0
  89. package/dist/{chunk-E4VONSLO.js.map → chunk-YZFL6JPZ.js.map} +2 -2
  90. package/dist/{chunk-6EYX257T.js → chunk-Z5KZDT7V.js} +1 -1
  91. package/dist/chunk-ZZ4KB6GE.js +47 -0
  92. package/dist/chunk-ZZ4KB6GE.js.map +7 -0
  93. package/dist/default-elements/array-elements.d.ts +793 -0
  94. package/dist/default-elements/array-elements.js +34 -0
  95. package/dist/default-elements/array-elements.js.map +7 -0
  96. package/dist/default-elements/checkbox-group.d.ts +812 -0
  97. package/dist/default-elements/checkbox-group.js +40 -0
  98. package/dist/default-elements/checkbox-group.js.map +7 -0
  99. package/dist/default-elements/checkbox.d.ts +788 -0
  100. package/dist/default-elements/checkbox.js +38 -0
  101. package/dist/default-elements/checkbox.js.map +7 -0
  102. package/dist/default-elements/combobox.d.ts +806 -0
  103. package/dist/default-elements/combobox.js +40 -0
  104. package/dist/default-elements/combobox.js.map +7 -0
  105. package/dist/default-elements/define-contract.d.ts +25 -0
  106. package/dist/default-elements/define-contract.js +8 -0
  107. package/dist/default-elements/define-contract.js.map +7 -0
  108. package/dist/default-elements/drop-zone.d.ts +789 -0
  109. package/dist/default-elements/drop-zone.js +40 -0
  110. package/dist/default-elements/drop-zone.js.map +7 -0
  111. package/dist/default-elements/fieldset.d.ts +783 -0
  112. package/dist/default-elements/fieldset.js +34 -0
  113. package/dist/default-elements/fieldset.js.map +7 -0
  114. package/dist/default-elements/index.d.ts +75 -0
  115. package/dist/default-elements/index.js +240 -0
  116. package/dist/default-elements/index.js.map +7 -0
  117. package/dist/default-elements/input-otp.d.ts +1298 -0
  118. package/dist/default-elements/input-otp.js +38 -0
  119. package/dist/default-elements/input-otp.js.map +7 -0
  120. package/dist/default-elements/input.d.ts +843 -0
  121. package/dist/default-elements/input.js +40 -0
  122. package/dist/default-elements/input.js.map +7 -0
  123. package/dist/default-elements/masked-input.d.ts +835 -0
  124. package/dist/default-elements/masked-input.js +40 -0
  125. package/dist/default-elements/masked-input.js.map +7 -0
  126. package/dist/default-elements/number.d.ts +821 -0
  127. package/dist/default-elements/number.js +38 -0
  128. package/dist/default-elements/number.js.map +7 -0
  129. package/dist/default-elements/phone-input.d.ts +785 -0
  130. package/dist/default-elements/phone-input.js +40 -0
  131. package/dist/default-elements/phone-input.js.map +7 -0
  132. package/dist/default-elements/radio.d.ts +812 -0
  133. package/dist/default-elements/radio.js +40 -0
  134. package/dist/default-elements/radio.js.map +7 -0
  135. package/dist/default-elements/select.d.ts +809 -0
  136. package/dist/default-elements/select.js +40 -0
  137. package/dist/default-elements/select.js.map +7 -0
  138. package/dist/default-elements/slider.d.ts +800 -0
  139. package/dist/default-elements/slider.js +38 -0
  140. package/dist/default-elements/slider.js.map +7 -0
  141. package/dist/default-elements/submission-alert.d.ts +804 -0
  142. package/dist/default-elements/submission-alert.js +36 -0
  143. package/dist/default-elements/submission-alert.js.map +7 -0
  144. package/dist/default-elements/submit-button.d.ts +771 -0
  145. package/dist/default-elements/submit-button.js +34 -0
  146. package/dist/default-elements/submit-button.js.map +7 -0
  147. package/dist/default-elements/switch.d.ts +794 -0
  148. package/dist/default-elements/switch.js +38 -0
  149. package/dist/default-elements/switch.js.map +7 -0
  150. package/dist/default-elements/textarea.d.ts +815 -0
  151. package/dist/default-elements/textarea.js +40 -0
  152. package/dist/default-elements/textarea.js.map +7 -0
  153. package/dist/engine/build-form-engine.js +22 -18
  154. package/dist/engine/create-form-engine.js +23 -19
  155. package/dist/engine/form-engine.js +22 -18
  156. package/dist/engine/index.js +25 -21
  157. package/dist/engine/schema-artifacts.js +6 -2
  158. package/dist/engine/step-machine.d.ts +10 -0
  159. package/dist/engine/step-machine.js +5 -5
  160. package/dist/engine/submission-schema.js +8 -6
  161. package/dist/engine/value-validation.js +4 -4
  162. package/dist/index.d.ts +4 -2
  163. package/dist/index.js +40 -31
  164. package/dist/index.js.map +3 -3
  165. package/dist/lib/export-schema.d.ts +128 -0
  166. package/dist/lib/export-schema.js +15 -0
  167. package/dist/lib/export-schema.js.map +7 -0
  168. package/dist/lib/exported-recipe-view.d.ts +17 -0
  169. package/dist/lib/exported-recipe-view.js +10 -0
  170. package/dist/lib/exported-recipe-view.js.map +7 -0
  171. package/dist/lib/field-scope.js +2 -2
  172. package/dist/lib/grid-track-items.d.ts +26 -0
  173. package/dist/lib/grid-track-items.js +10 -0
  174. package/dist/lib/grid-track-items.js.map +7 -0
  175. package/dist/lib/is-zod-type.d.ts +5 -0
  176. package/dist/lib/is-zod-type.js +6 -0
  177. package/dist/lib/is-zod-type.js.map +7 -0
  178. package/dist/lib/submission-shape.js +3 -3
  179. package/dist/lib/validate-form/grid-checks.d.ts +24 -0
  180. package/dist/lib/validate-form/grid-checks.js +6 -1
  181. package/dist/lib/validate-form/parse-elements.d.ts +9 -7
  182. package/dist/lib/validate-form/parse-elements.js +5 -6
  183. package/dist/lib/validate-form/parse-owner-actions.js +1 -1
  184. package/dist/lib/validate-form/parse-view.js +1 -1
  185. package/dist/lib/validate-form/step-checks.js +3 -3
  186. package/dist/lib/validate-form/validation-error.d.ts +1 -10
  187. package/dist/lib/validate-form/validation-error.js +3 -5
  188. package/dist/lib/validate-form.d.ts +1 -1
  189. package/dist/lib/validate-form.js +14 -15
  190. package/dist/lib/zod-json-schema.d.ts +0 -4
  191. package/dist/lib/zod-json-schema.js +7 -5
  192. package/dist/recipes/built-in-specs.js +2 -2
  193. package/dist/recipes/built-in.js +2 -2
  194. package/dist/recipes/define-form-recipe.d.ts +2 -2
  195. package/dist/recipes/define-form-recipe.js +1 -1
  196. package/dist/recipes/define-recipe-spec.d.ts +3 -2
  197. package/dist/recipes/define-recipe-spec.js +1 -1
  198. package/dist/recipes/index.js +8 -8
  199. package/dist/recipes/types.d.ts +2 -2
  200. package/dist/recipes/view-model.d.ts +2 -2
  201. package/dist/recipes/view-model.js +6 -6
  202. package/dist/runtime/create-form-runtime.js +14 -13
  203. package/dist/runtime/index.d.ts +1 -1
  204. package/dist/runtime/index.js +14 -13
  205. package/dist/runtime/types.d.ts +11 -0
  206. package/dist/runtime/types.js +1 -1
  207. package/dist/schemas/base-field.d.ts +14 -6
  208. package/dist/schemas/base-field.js +5 -5
  209. package/dist/schemas/form-config-shape.d.ts +33 -21
  210. package/dist/schemas/form-config-shape.js +5 -5
  211. package/dist/schemas/form-config.d.ts +55 -35
  212. package/dist/schemas/form-config.js +5 -5
  213. package/dist/schemas/index.js +5 -5
  214. package/dist/schemas/validation/dependencies.js +4 -4
  215. package/dist/schemas/validation/index.js +5 -5
  216. package/dist/schemas/validation/utils.js +3 -3
  217. package/dist/schemas/validation/validation-registry.d.ts +1 -1
  218. package/dist/schemas/validation/validation-registry.js +4 -4
  219. package/dist/state-container/create-form-state-container.js +8 -8
  220. package/dist/state-container/index.js +9 -9
  221. package/dist/state-container/selectors.js +5 -5
  222. package/dist/state-container/submission.js +6 -6
  223. package/dist/testing/form-state-container-conformance.js +7 -7
  224. package/dist/testing/index.js +7 -7
  225. package/dist/types/define-element.d.ts +2 -2
  226. package/dist/types/define-element.js +1 -1
  227. package/dist/types/index.js +1 -1
  228. package/dist/types/registration.d.ts +7 -0
  229. package/package.json +8 -4
  230. package/skill/SKILL.md +26 -25
  231. package/skill/reference/forms.md +7 -7
  232. package/dist/chunk-25PLQDKN.js +0 -45
  233. package/dist/chunk-25PLQDKN.js.map +0 -7
  234. package/dist/chunk-2XWISGGM.js.map +0 -7
  235. package/dist/chunk-6IZYNHZ3.js.map +0 -7
  236. package/dist/chunk-DP7SYLLI.js.map +0 -7
  237. package/dist/chunk-GRZU6F7Q.js.map +0 -7
  238. package/dist/chunk-HPPFSWIV.js.map +0 -7
  239. package/dist/chunk-J2FC5K4B.js.map +0 -7
  240. package/dist/chunk-K22S7IZR.js.map +0 -7
  241. package/dist/chunk-NJXKMF67.js.map +0 -7
  242. package/dist/chunk-PH3LWLYN.js.map +0 -7
  243. package/dist/chunk-PHNMDWSK.js.map +0 -7
  244. package/dist/chunk-PN5EH6DM.js +0 -36
  245. package/dist/chunk-PN5EH6DM.js.map +0 -7
  246. package/dist/chunk-YUUDXRBW.js.map +0 -7
  247. package/dist/chunk-ZYP3MIH3.js.map +0 -7
  248. package/dist/{chunk-KLATKWUA.js.map → chunk-4YANBG3M.js.map} +0 -0
  249. package/dist/{chunk-S7I76ISM.js → chunk-7QLR5WM3.js} +3 -3
  250. /package/dist/{chunk-S7I76ISM.js.map → chunk-7QLR5WM3.js.map} +0 -0
  251. /package/dist/{chunk-NJTLBSTR.js.map → chunk-AROD3D4R.js.map} +0 -0
  252. /package/dist/{chunk-Q5LEK7CI.js.map → chunk-AT2NHSY3.js.map} +0 -0
  253. /package/dist/{chunk-BLFLCSG3.js.map → chunk-DEWI6E3O.js.map} +0 -0
  254. /package/dist/{chunk-GH34XFCC.js.map → chunk-EO5CW7XD.js.map} +0 -0
  255. /package/dist/{chunk-A5VLMQAK.js.map → chunk-ERSCXYVE.js.map} +0 -0
  256. /package/dist/{chunk-K22S7IZR.js → chunk-EWNYEO6T.js} +0 -0
  257. /package/dist/{chunk-CRVXBWSY.js.map → chunk-FGL773EA.js.map} +0 -0
  258. /package/dist/{chunk-GQHMU3AR.js.map → chunk-HEWLTCU4.js.map} +0 -0
  259. /package/dist/{chunk-WUTGZYP4.js.map → chunk-MG7VFU6V.js.map} +0 -0
  260. /package/dist/{chunk-WLDCYUN6.js.map → chunk-OKJLJ3GI.js.map} +0 -0
  261. /package/dist/{chunk-2XWISGGM.js → chunk-QDU55RCZ.js} +0 -0
  262. /package/dist/{chunk-PHNMDWSK.js → chunk-RMX7C43O.js} +0 -0
  263. /package/dist/{chunk-JA5ET6MC.js.map → chunk-TWQU2IGF.js.map} +0 -0
  264. /package/dist/{chunk-E4VONSLO.js → chunk-YZFL6JPZ.js} +0 -0
  265. /package/dist/{chunk-6EYX257T.js.map → chunk-Z5KZDT7V.js.map} +0 -0
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  buildDependencyIndex,
3
3
  shouldSurfaceDependentError
4
- } from "../../chunk-GH34XFCC.js";
5
- import "../../chunk-KLATKWUA.js";
4
+ } from "../../chunk-EO5CW7XD.js";
5
+ import "../../chunk-4YANBG3M.js";
6
6
  import "../../chunk-YDGH7DTL.js";
7
- import "../../chunk-S7I76ISM.js";
8
- import "../../chunk-CRQWKC67.js";
7
+ import "../../chunk-7QLR5WM3.js";
9
8
  import "../../chunk-QLGM2AZW.js";
9
+ import "../../chunk-CRQWKC67.js";
10
10
  import "../../chunk-ZUYSGCEH.js";
11
11
  import "../../chunk-OR2L7EKO.js";
12
12
  import "../../chunk-3YLRJVVN.js";
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  createDefaultValidationRegistry,
7
7
  createValidationRegistry
8
- } from "../../chunk-6IZYNHZ3.js";
8
+ } from "../../chunk-RDQFBY6S.js";
9
9
  import "../../chunk-FVOL3ZOJ.js";
10
10
  import "../../chunk-LMWJAD3B.js";
11
11
  import "../../chunk-OUF57UZ7.js";
@@ -52,7 +52,7 @@ import {
52
52
  import {
53
53
  buildDependencyIndex,
54
54
  shouldSurfaceDependentError
55
- } from "../../chunk-GH34XFCC.js";
55
+ } from "../../chunk-EO5CW7XD.js";
56
56
  import {
57
57
  collectValidatableFields,
58
58
  createValidationContext,
@@ -60,11 +60,11 @@ import {
60
60
  generateFormSchema,
61
61
  getValidationRulesForElement,
62
62
  isFieldRequired
63
- } from "../../chunk-KLATKWUA.js";
63
+ } from "../../chunk-4YANBG3M.js";
64
64
  import "../../chunk-YDGH7DTL.js";
65
- import "../../chunk-S7I76ISM.js";
66
- import "../../chunk-CRQWKC67.js";
65
+ import "../../chunk-7QLR5WM3.js";
67
66
  import "../../chunk-QLGM2AZW.js";
67
+ import "../../chunk-CRQWKC67.js";
68
68
  import "../../chunk-ZUYSGCEH.js";
69
69
  import "../../chunk-OR2L7EKO.js";
70
70
  import {
@@ -5,11 +5,11 @@ import {
5
5
  generateFormSchema,
6
6
  getValidationRulesForElement,
7
7
  isFieldRequired
8
- } from "../../chunk-KLATKWUA.js";
8
+ } from "../../chunk-4YANBG3M.js";
9
9
  import "../../chunk-YDGH7DTL.js";
10
- import "../../chunk-S7I76ISM.js";
11
- import "../../chunk-CRQWKC67.js";
10
+ import "../../chunk-7QLR5WM3.js";
12
11
  import "../../chunk-QLGM2AZW.js";
12
+ import "../../chunk-CRQWKC67.js";
13
13
  import "../../chunk-ZUYSGCEH.js";
14
14
  import "../../chunk-OR2L7EKO.js";
15
15
  import "../../chunk-3YLRJVVN.js";
@@ -2,7 +2,7 @@ import * as z from 'zod/mini';
2
2
  import { type ReadOnlyRegistry } from '@schema-engine/registry';
3
3
  import type { AnyValidationRegistration, BaseValidationRule, ValidationScope, ValidationRegistrationConstraint } from './types.js';
4
4
  import { type FormFetch } from '../../lib/form-fetch.js';
5
- import { type FormValidationIssue } from '../../lib/validate-form/issues.js';
5
+ import type { FormValidationIssue } from '../../lib/validate-form/issues.js';
6
6
  /**
7
7
  * Read-only store of validation registrations, with the lookups the renderers and the engine need.
8
8
  *
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createDefaultValidationRegistry,
3
3
  createValidationRegistry
4
- } from "../../chunk-6IZYNHZ3.js";
4
+ } from "../../chunk-RDQFBY6S.js";
5
5
  import "../../chunk-FVOL3ZOJ.js";
6
6
  import "../../chunk-LMWJAD3B.js";
7
7
  import "../../chunk-OUF57UZ7.js";
@@ -10,11 +10,11 @@ import "../../chunk-J7GSNWXT.js";
10
10
  import "../../chunk-MD23VADH.js";
11
11
  import "../../chunk-OLYHNFKC.js";
12
12
  import "../../chunk-KE53GN4Q.js";
13
- import "../../chunk-KLATKWUA.js";
13
+ import "../../chunk-4YANBG3M.js";
14
14
  import "../../chunk-YDGH7DTL.js";
15
- import "../../chunk-S7I76ISM.js";
16
- import "../../chunk-CRQWKC67.js";
15
+ import "../../chunk-7QLR5WM3.js";
17
16
  import "../../chunk-QLGM2AZW.js";
17
+ import "../../chunk-CRQWKC67.js";
18
18
  import "../../chunk-ZUYSGCEH.js";
19
19
  import "../../chunk-OR2L7EKO.js";
20
20
  import "../../chunk-6BAJHAGL.js";
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  createFormStateContainer
3
- } from "../chunk-GQHMU3AR.js";
4
- import "../chunk-GH34XFCC.js";
3
+ } from "../chunk-HEWLTCU4.js";
4
+ import "../chunk-EO5CW7XD.js";
5
5
  import "../chunk-EQ5AIF3T.js";
6
6
  import "../chunk-QYHOFLRX.js";
7
7
  import "../chunk-EEYGPPLU.js";
8
- import "../chunk-BLFLCSG3.js";
9
- import "../chunk-NJTLBSTR.js";
8
+ import "../chunk-DEWI6E3O.js";
9
+ import "../chunk-AROD3D4R.js";
10
10
  import "../chunk-VGGERKV2.js";
11
- import "../chunk-WUTGZYP4.js";
11
+ import "../chunk-MG7VFU6V.js";
12
12
  import "../chunk-R3MBVWVI.js";
13
13
  import "../chunk-3B7CJOF6.js";
14
- import "../chunk-KLATKWUA.js";
14
+ import "../chunk-4YANBG3M.js";
15
15
  import "../chunk-YDGH7DTL.js";
16
- import "../chunk-S7I76ISM.js";
17
- import "../chunk-CRQWKC67.js";
16
+ import "../chunk-7QLR5WM3.js";
18
17
  import "../chunk-QLGM2AZW.js";
18
+ import "../chunk-CRQWKC67.js";
19
19
  import "../chunk-ZUYSGCEH.js";
20
20
  import "../chunk-OR2L7EKO.js";
21
21
  import "../chunk-6BAJHAGL.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  selectFieldState,
3
3
  selectValue
4
- } from "../chunk-CRVXBWSY.js";
4
+ } from "../chunk-FGL773EA.js";
5
5
  import {
6
6
  toFieldArrayValue
7
7
  } from "../chunk-KFQEDSYI.js";
@@ -10,22 +10,22 @@ import {
10
10
  } from "../chunk-HIS4MGIR.js";
11
11
  import {
12
12
  createFormStateContainer
13
- } from "../chunk-GQHMU3AR.js";
14
- import "../chunk-GH34XFCC.js";
13
+ } from "../chunk-HEWLTCU4.js";
14
+ import "../chunk-EO5CW7XD.js";
15
15
  import "../chunk-EQ5AIF3T.js";
16
16
  import "../chunk-QYHOFLRX.js";
17
17
  import "../chunk-EEYGPPLU.js";
18
- import "../chunk-BLFLCSG3.js";
19
- import "../chunk-NJTLBSTR.js";
18
+ import "../chunk-DEWI6E3O.js";
19
+ import "../chunk-AROD3D4R.js";
20
20
  import "../chunk-VGGERKV2.js";
21
- import "../chunk-WUTGZYP4.js";
21
+ import "../chunk-MG7VFU6V.js";
22
22
  import "../chunk-R3MBVWVI.js";
23
23
  import "../chunk-3B7CJOF6.js";
24
- import "../chunk-KLATKWUA.js";
24
+ import "../chunk-4YANBG3M.js";
25
25
  import "../chunk-YDGH7DTL.js";
26
- import "../chunk-S7I76ISM.js";
27
- import "../chunk-CRQWKC67.js";
26
+ import "../chunk-7QLR5WM3.js";
28
27
  import "../chunk-QLGM2AZW.js";
28
+ import "../chunk-CRQWKC67.js";
29
29
  import "../chunk-ZUYSGCEH.js";
30
30
  import "../chunk-OR2L7EKO.js";
31
31
  import "../chunk-6BAJHAGL.js";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  selectFieldState,
3
3
  selectValue
4
- } from "../chunk-CRVXBWSY.js";
5
- import "../chunk-WUTGZYP4.js";
4
+ } from "../chunk-FGL773EA.js";
5
+ import "../chunk-MG7VFU6V.js";
6
6
  import "../chunk-R3MBVWVI.js";
7
7
  import "../chunk-3B7CJOF6.js";
8
- import "../chunk-KLATKWUA.js";
8
+ import "../chunk-4YANBG3M.js";
9
9
  import "../chunk-YDGH7DTL.js";
10
- import "../chunk-S7I76ISM.js";
11
- import "../chunk-CRQWKC67.js";
10
+ import "../chunk-7QLR5WM3.js";
12
11
  import "../chunk-QLGM2AZW.js";
12
+ import "../chunk-CRQWKC67.js";
13
13
  import "../chunk-ZUYSGCEH.js";
14
14
  import "../chunk-OR2L7EKO.js";
15
15
  import "../chunk-6BAJHAGL.js";
@@ -2,16 +2,16 @@ import {
2
2
  submittedTree,
3
3
  submittedValues,
4
4
  toFormPath
5
- } from "../chunk-BLFLCSG3.js";
6
- import "../chunk-NJTLBSTR.js";
7
- import "../chunk-WUTGZYP4.js";
5
+ } from "../chunk-DEWI6E3O.js";
6
+ import "../chunk-AROD3D4R.js";
7
+ import "../chunk-MG7VFU6V.js";
8
8
  import "../chunk-R3MBVWVI.js";
9
9
  import "../chunk-3B7CJOF6.js";
10
- import "../chunk-KLATKWUA.js";
10
+ import "../chunk-4YANBG3M.js";
11
11
  import "../chunk-YDGH7DTL.js";
12
- import "../chunk-S7I76ISM.js";
13
- import "../chunk-CRQWKC67.js";
12
+ import "../chunk-7QLR5WM3.js";
14
13
  import "../chunk-QLGM2AZW.js";
14
+ import "../chunk-CRQWKC67.js";
15
15
  import "../chunk-ZUYSGCEH.js";
16
16
  import "../chunk-OR2L7EKO.js";
17
17
  import "../chunk-6BAJHAGL.js";
@@ -4,10 +4,10 @@ import {
4
4
  formStateContainerCases,
5
5
  formStateContainerConformance,
6
6
  watchValidation
7
- } from "../chunk-A5VLMQAK.js";
8
- import "../chunk-CRVXBWSY.js";
7
+ } from "../chunk-ERSCXYVE.js";
8
+ import "../chunk-FGL773EA.js";
9
9
  import "../chunk-KFQEDSYI.js";
10
- import "../chunk-6IZYNHZ3.js";
10
+ import "../chunk-RDQFBY6S.js";
11
11
  import "../chunk-FVOL3ZOJ.js";
12
12
  import "../chunk-LMWJAD3B.js";
13
13
  import "../chunk-OUF57UZ7.js";
@@ -17,14 +17,14 @@ import "../chunk-MD23VADH.js";
17
17
  import "../chunk-OLYHNFKC.js";
18
18
  import "../chunk-KE53GN4Q.js";
19
19
  import "../chunk-VGGERKV2.js";
20
- import "../chunk-WUTGZYP4.js";
20
+ import "../chunk-MG7VFU6V.js";
21
21
  import "../chunk-R3MBVWVI.js";
22
22
  import "../chunk-3B7CJOF6.js";
23
- import "../chunk-KLATKWUA.js";
23
+ import "../chunk-4YANBG3M.js";
24
24
  import "../chunk-YDGH7DTL.js";
25
- import "../chunk-S7I76ISM.js";
26
- import "../chunk-CRQWKC67.js";
25
+ import "../chunk-7QLR5WM3.js";
27
26
  import "../chunk-QLGM2AZW.js";
27
+ import "../chunk-CRQWKC67.js";
28
28
  import "../chunk-ZUYSGCEH.js";
29
29
  import "../chunk-OR2L7EKO.js";
30
30
  import "../chunk-6BAJHAGL.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  formStateContainerConformance
3
- } from "../chunk-A5VLMQAK.js";
4
- import "../chunk-CRVXBWSY.js";
3
+ } from "../chunk-ERSCXYVE.js";
4
+ import "../chunk-FGL773EA.js";
5
5
  import "../chunk-KFQEDSYI.js";
6
- import "../chunk-6IZYNHZ3.js";
6
+ import "../chunk-RDQFBY6S.js";
7
7
  import "../chunk-FVOL3ZOJ.js";
8
8
  import "../chunk-LMWJAD3B.js";
9
9
  import "../chunk-OUF57UZ7.js";
@@ -13,14 +13,14 @@ import "../chunk-MD23VADH.js";
13
13
  import "../chunk-OLYHNFKC.js";
14
14
  import "../chunk-KE53GN4Q.js";
15
15
  import "../chunk-VGGERKV2.js";
16
- import "../chunk-WUTGZYP4.js";
16
+ import "../chunk-MG7VFU6V.js";
17
17
  import "../chunk-R3MBVWVI.js";
18
18
  import "../chunk-3B7CJOF6.js";
19
- import "../chunk-KLATKWUA.js";
19
+ import "../chunk-4YANBG3M.js";
20
20
  import "../chunk-YDGH7DTL.js";
21
- import "../chunk-S7I76ISM.js";
22
- import "../chunk-CRQWKC67.js";
21
+ import "../chunk-7QLR5WM3.js";
23
22
  import "../chunk-QLGM2AZW.js";
23
+ import "../chunk-CRQWKC67.js";
24
24
  import "../chunk-ZUYSGCEH.js";
25
25
  import "../chunk-OR2L7EKO.js";
26
26
  import "../chunk-6BAJHAGL.js";
@@ -18,7 +18,7 @@ export type ElementRenderProps<TSchema extends StandardSchemaV1, THandlers = unk
18
18
  /** Stable array-item identity overlaid at render time. Not part of authoring. */
19
19
  instanceId?: string;
20
20
  } & THandlers;
21
- type DefineElementRegistration<TType extends string, TSchema extends StandardSchemaV1, TProps, TKind extends ContainerKind | undefined = ContainerKind | undefined> = {
21
+ export type DefineElementRegistration<TType extends string, TSchema extends StandardSchemaV1, TProps, TKind extends ContainerKind | undefined = ContainerKind | undefined> = {
22
22
  $type: TType;
23
23
  schema: TSchema;
24
24
  metadata: ElementMetadata;
@@ -35,7 +35,7 @@ type DefineElementRegistration<TType extends string, TSchema extends StandardSch
35
35
  * `value`, which is how a registration whose control writes a value the engine cannot check is a type error. A schema
36
36
  * that merely allows any key (an index signature) does not declare `elements`.
37
37
  */
38
- type InputValueDeclaration<TSchema extends StandardSchemaV1, TValue extends StandardSchemaV1> = DeclaresChildren<InferOutput<TSchema>> extends true ? {
38
+ export type InputValueDeclaration<TSchema extends StandardSchemaV1, TValue extends StandardSchemaV1> = DeclaresChildren<InferOutput<TSchema>> extends true ? {
39
39
  containerKind?: ContainerKind;
40
40
  value?: never;
41
41
  } : {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  defineInput,
3
3
  defineStatic
4
- } from "../chunk-K22S7IZR.js";
4
+ } from "../chunk-EWNYEO6T.js";
5
5
  export {
6
6
  defineInput,
7
7
  defineStatic
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  defineInput,
8
8
  defineStatic
9
- } from "../chunk-K22S7IZR.js";
9
+ } from "../chunk-EWNYEO6T.js";
10
10
  import "../chunk-WMDTQS36.js";
11
11
  import "../chunk-VVFXYY65.js";
12
12
  export {
@@ -96,6 +96,13 @@ export type RecipeRegistration<TType extends string = string, TSchema extends St
96
96
  slotDefaults?: Partial<Record<import('../recipes/types.js').RecipeSlot, Record<string, unknown>>>;
97
97
  /** Appearance axes each slot supports; see {@link import('../recipes/types.js').RecipeSpec.appearanceAxes}. */
98
98
  appearanceAxes?: SlotAppearanceAxes<import('../recipes/types.js').RecipeSlot>;
99
+ /**
100
+ * The schema of each declared slot; see {@link import('@schema-engine/layout').ProtocolRecipeRegistration.slotSchemas}.
101
+ *
102
+ * @remarks
103
+ * The JSON Schema export reads it to list each slot. A registration written by hand may leave it out.
104
+ */
105
+ slotSchemas?: Readonly<Partial<Record<import('../recipes/types.js').RecipeSlot, StandardSchemaV1>>>;
99
106
  /** Adapter render payload (shell + slot components). */
100
107
  render: TRender;
101
108
  }, 'Recipe'>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@schema-engine/forms",
3
3
  "type": "module",
4
- "version": "0.5.1",
4
+ "version": "0.5.3",
5
5
  "description": "The forms domain of Schema Engine: JSON forms with elements, validation, constraints, steps, form state and submission, with no renderer",
6
6
  "keywords": [
7
7
  "schema-engine",
@@ -55,9 +55,9 @@
55
55
  "dependencies": {
56
56
  "@ecopages/logger": "^0.2.3",
57
57
  "@standard-schema/spec": "^1.1.0",
58
- "@schema-engine/actions": "^0.5.1",
59
- "@schema-engine/registry": "^0.5.1",
60
- "@schema-engine/layout": "^0.5.1"
58
+ "@schema-engine/actions": "^0.5.2",
59
+ "@schema-engine/registry": "^0.5.2",
60
+ "@schema-engine/layout": "^0.5.2"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "zod": "^4.0.17"
@@ -70,6 +70,10 @@
70
70
  "types": "./dist/index.d.ts",
71
71
  "import": "./dist/index.js"
72
72
  },
73
+ "./default-elements": {
74
+ "types": "./dist/default-elements/index.d.ts",
75
+ "import": "./dist/default-elements/index.js"
76
+ },
73
77
  "./browser": {
74
78
  "types": "./dist/browser/index.d.ts",
75
79
  "import": "./dist/browser/index.js"
package/skill/SKILL.md CHANGED
@@ -19,7 +19,7 @@ This file is the router. It defines the concepts once; the references assume the
19
19
  ## Core concepts
20
20
 
21
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.
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; pass `{ duplicates: 'error' }` to make a repeat a build error instead.
23
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
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
25
 
@@ -27,7 +27,7 @@ This file is the router. It defines the concepts once; the references assume the
27
27
 
28
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
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.
30
+ - **runtime**: for renderer authors, `createFormRuntime` is the lifecycle every renderer shares, and a renderer creates one for each form it draws. 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. An app does not create one: it gives the engine and a config to a renderer.
31
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
32
 
33
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.
@@ -49,31 +49,32 @@ A symbol has one import path. `@schema-engine/forms` has these entries: `.` (the
49
49
 
50
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
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` |
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, or use the container 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
65
 
66
66
  ## Documentation map
67
67
 
68
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
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` |
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` |
80
+ | Renderer authors | `/docs/renderer-authors/write-a-renderer` |
@@ -1,10 +1,10 @@
1
1
  # @schema-engine/forms
2
2
 
3
- The engine, the config, validation timing, constraints, the container and the runtime. The terms are defined in the router (`SKILL.md`).
3
+ The engine, the config, validation timing, constraints, the container and, for renderer authors, the runtime. The terms are defined in the router (`SKILL.md`).
4
4
 
5
5
  ## Engine
6
6
 
7
- `createFormEngine` takes `elements`, `recipes`, `actions`, `validations` (extra rules), `layout`, `formatIssue`, `fetch` and `csrf`. It builds read-only registries (a later `$type` replaces an earlier one) and returns an immutable engine: create it once and reuse it. `engine.extend({ ... })` adds registrations and inherits the layout theme. The package ships no field widgets; an element is registered with `defineInput({ $type, schema, metadata, value, render })` (see Registrations below), and renderer packages bring the widgets.
7
+ `createFormEngine` takes `elements`, `recipes`, `actions`, `validations` (extra rules), `layout`, `formatIssue`, `fetch` and `csrf`. It builds read-only registries (a later `$type` replaces an earlier one) and returns an immutable engine: create it once and reuse it. `engine.extend({ ... })` adds registrations and inherits the layout theme. An app gives the engine and a config to a renderer: `FormRenderer` in `forms-react.md` or `forms-radiant.md`. The package ships no field widgets, only the contracts of the 18 default elements in `@schema-engine/forms/default-elements` (`defaultElementContracts`, and per element a schema such as `CheckboxFieldConfigSchema`, its types, its value declaration and `CheckboxElementContract`: a registration without `render`); a renderer binds `render` to a contract, and an element of your own is registered with `defineInput({ $type, schema, metadata, value, render })` (see Registrations below), and renderer packages bring the widgets.
8
8
 
9
9
  ```ts title="forms/engine.ts"
10
10
  import * as z from 'zod/mini';
@@ -43,7 +43,7 @@ Every registration is `{ $type, schema, metadata }` (an element also has a `kind
43
43
 
44
44
  The engine builds four registries from `createFormEngine`: `elements` (`defineInput` for a field, `defineStatic` for display-only content), `recipes`, `actions` and `validations`. `elements` and `recipes` are for the renderer, `actions` for the runtime and `validations` for the container. Authors supply the schema's input and renderers receive its output, so register elements with `defineInput` (which also takes the `value` the control writes) and `defineStatic`, which keep the two apart.
45
45
 
46
- The engine lists what it holds with `getAllElements()`, `getAllRecipes()` and `getAllActions()`, looks one up with `getElement($type)`, `getRecipe($type)` and `getAction($type)`, and exposes its rules as `getValidationRegistry()`, itself a read-only registry. `engine.generateFormConfigSchema()` exports a JSON Schema of the form config for editors and other tools. The engine never changes after it is built: `engine.extend({ ... })` returns a new one.
46
+ The engine lists what it holds with `getAllElements()`, `getAllRecipes()` and `getAllActions()`, looks one up with `getElement($type)`, `getRecipe($type)` and `getAction($type)`, and exposes its rules as `getValidationRegistry()`, itself a read-only registry. `engine.generateFormConfigSchema()` exports a JSON Schema of the form config for editors, agents and other tools. The export reads the schema of every registration (element, action, rule and recipe slot) the same way: a Zod schema (classic or Mini) through the Zod converter, any other schema that sets `~standard.jsonSchema` as what its `input()` or `output()` returns (ArkType does; Valibot and Effect Schema do not without an adapter), and any other schema as an open object listed by its `$type` or, for a recipe slot, its appearance axes. A hand-written schema exports exactly when it adds `~standard.jsonSchema`. The export drops that schema's `$schema`, moves a recursive one (a root `$ref` with `$defs`) to where its references resolve, and lists it by its shape when its converter throws for the target (ArkType for `openapi-3.0`). The engine never changes after it is built: `engine.extend({ ... })` returns a new one.
47
47
 
48
48
  ### Registering a widget
49
49
 
@@ -51,7 +51,7 @@ A widget is a registration, `defineInput({ $type, schema, metadata, value, rende
51
51
 
52
52
  ## Config
53
53
 
54
- Authors supply schema input, so defaults stay optional; renderers receive schema output. `defineForm` and `validateForm` run one pipeline and throw a `FormValidationError` on an invalid form; `engine.safeValidateForm(json)` returns `{ success, data | issues }` with the config `path` of each issue. A step needs an `id` and a `title`.
54
+ Authors supply schema input, so defaults stay optional; renderers receive schema output. `defineForm` and `validateForm` run one pipeline and throw a `FormValidationError` on an invalid form; `engine.safeValidateForm(json)` returns `{ success, data | issues }` with the config `path` of each issue; `formatIssuePath(path)` from `@schema-engine/registry` writes a path as `steps[0].elements[2].name`. A step needs an `id` and a `title`.
55
55
 
56
56
  ```ts title="forms/contact-form.ts"
57
57
  import { engine } from './engine';
@@ -139,9 +139,9 @@ export async function submitContact(name: string, email: string) {
139
139
  - `getSnapshot()` is stable until something changes. Read it with `selectValue` and `selectFieldState` (its `error` is the one of exactly that path), which return the same object while what they read is unchanged, so they are safe for `useSyncExternalStore`.
140
140
  - `toHydration(container.getServerSnapshot())` is the serializable part a server hands to a client, which passes it as `snapshot` so row ids survive.
141
141
 
142
- ## Runtime
142
+ ## Runtime (for renderer authors)
143
143
 
144
- `createFormRuntime({ engine, config, host, onSubmit, ... })` wraps a container with the submission, the wizard and the actions. `host.focus(paths)` is the only required host member; a renderer adds `sync` and `submitNatively` when it needs them.
144
+ An app does not create a runtime: a renderer creates one for each form it draws, and an app reaches it with a hook or a controller (`useFormRuntime`, `FormController`). `createFormRuntime({ engine, config, host, onSubmit, ... })` wraps a container with the submission, the wizard and the actions. `host.focus(paths)` is the only required host member; a renderer adds `sync` and `submitNatively` when it needs them.
145
145
 
146
146
  ```ts title="forms/runtime.ts"
147
147
  import { createFormRuntime, type FormValues } from '@schema-engine/forms';
@@ -159,7 +159,7 @@ export function createNotifyRuntime(onSubmit: (values: FormValues) => void) {
159
159
  }
160
160
  ```
161
161
 
162
- Every command resolves one string: `moved`, `submitted`, `failed`, `invalid`, `overtaken`, `refused`, `busy` or `cancelled`. One lock covers navigation and submission, so a command made while another runs is `busy`, and a reset or `unmount` revokes the one in flight (`cancelled`); a submission whose values were already captured is committed and still completes. `runtime.getSnapshot()` is `{ submission, current, navigating, steps }`, each step with `skipped`, `visited`, `complete` and `invalid`; `runtime.container` is the state. Submitting is in `forms-submission.md`.
162
+ Every command resolves one string: `moved`, `submitted`, `failed`, `invalid`, `overtaken`, `refused`, `busy` or `cancelled`. One lock covers navigation and submission, so a command made while another runs is `busy`, and a reset or `unmount` revokes the one in flight (`cancelled`); a submission whose values were already captured is committed and still completes. `runtime.getSnapshot()` is `{ submission, current, navigating, steps }`, each step with `id`, `title`, `skipped`, `visited`, `complete`, `invalid` and `reachable` (`goTo` can move there); `runtime.container` is the state. Submitting is in `forms-submission.md`. The docs page is `/docs/renderer-authors/runtime`.
163
163
 
164
164
  ## Testing a container
165
165
 
@@ -1,45 +0,0 @@
1
- // src/lib/zod-json-schema.ts
2
- import * as z from "zod/mini";
3
- function isZodType(schema) {
4
- return typeof schema === "object" && schema !== null && typeof schema.parse === "function" && typeof schema.safeParse === "function";
5
- }
6
- function generateZodJSONSchemaCollection(metadataRegistry, options) {
7
- return z.toJSONSchema(metadataRegistry, {
8
- target: options?.target || "draft-2020-12",
9
- io: options?.io || "input",
10
- uri: options?.uri || ((id) => `#/definitions/${id}`)
11
- });
12
- }
13
- var LayeredMetadataRegistry = class extends z.core.$ZodRegistry {
14
- constructor(primary) {
15
- super();
16
- this.primary = primary;
17
- }
18
- primary;
19
- get(schema) {
20
- const own = z.globalRegistry.get(schema);
21
- const layered = this.primary.get(schema);
22
- if (!layered) {
23
- return own;
24
- }
25
- const defined = Object.fromEntries(Object.entries(layered).filter(([, value]) => value !== void 0));
26
- return { ...own, ...defined };
27
- }
28
- };
29
- function generateZodJSONSchemaDocument(validator, metadataRegistry, options) {
30
- const schema = z.toJSONSchema(validator, {
31
- target: options?.target || "draft-2020-12",
32
- io: options?.io || "input",
33
- metadata: new LayeredMetadataRegistry(metadataRegistry)
34
- });
35
- if (options?.schemaId) {
36
- schema.$id = options.schemaId;
37
- }
38
- return schema;
39
- }
40
-
41
- export {
42
- isZodType,
43
- generateZodJSONSchemaCollection,
44
- generateZodJSONSchemaDocument
45
- };
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/lib/zod-json-schema.ts"],
4
- "sourcesContent": ["import * as z from 'zod/mini';\nimport type { JSONSchemaObject, JSONSchemaTarget } from '@/lib/standard-json-schema';\n\n/**\n * Duck-type a Zod validator. Native Standard Schema objects only expose `~standard`.\n */\nexport function isZodType(schema: unknown): schema is z.ZodMiniType {\n\treturn (\n\t\ttypeof schema === 'object' &&\n\t\tschema !== null &&\n\t\ttypeof (schema as { parse?: unknown }).parse === 'function' &&\n\t\ttypeof (schema as { safeParse?: unknown }).safeParse === 'function'\n\t);\n}\n\n/**\n * Shared alias for the Zod registry type used during JSON Schema generation.\n * Keeping this in one place reduces the amount of Zod-specific typing that\n * leaks into higher-level schema artifact code.\n * @remarks Zod accepts heterogeneous metadata through this existential registry.\n */\nexport type ZodJSONSchemaRegistry = ReturnType<typeof z.registry<Record<string, any>>>;\n\n/**\n * Generate a JSON Schema collection from a Zod metadata registry.\n * This is the lowest-level adapter around `z.toJSONSchema(...)` for registry\n * collections and is intended to stay reusable if the artifact layer moves.\n */\nexport function generateZodJSONSchemaCollection(\n\tmetadataRegistry: ZodJSONSchemaRegistry,\n\toptions?: {\n\t\ttarget?: JSONSchemaTarget;\n\t\turi?: (id: string) => string;\n\t\tio?: 'input' | 'output';\n\t},\n): JSONSchemaObject {\n\treturn z.toJSONSchema(metadataRegistry, {\n\t\ttarget: options?.target || 'draft-2020-12',\n\t\tio: options?.io || 'input',\n\t\turi: options?.uri || ((id: string) => `#/definitions/${id}`),\n\t}) as JSONSchemaObject;\n}\n\n/**\n * Registry that answers metadata lookups from a primary registry laid over `z.globalRegistry`.\n *\n * @remarks\n * `z.toJSONSchema` reads metadata from the single registry passed as `metadata`, which replaces\n * `z.globalRegistry`. That is where `.describe(...)` and `.meta(...)` store a schema's own\n * description, so passing only the catalog registry dropped every author-written description.\n * Entries of the primary registry win key by key, except that an undefined value (a catalog entry\n * without a description) does not hide the one the schema declares.\n */\nclass LayeredMetadataRegistry extends z.core.$ZodRegistry<Record<string, unknown>> {\n\tconstructor(private readonly primary: ZodJSONSchemaRegistry) {\n\t\tsuper();\n\t}\n\n\toverride get(schema: z.core.$ZodType): Record<string, unknown> | undefined {\n\t\tconst own = z.globalRegistry.get(schema);\n\t\tconst layered = this.primary.get(schema);\n\t\tif (!layered) {\n\t\t\treturn own;\n\t\t}\n\t\tconst defined = Object.fromEntries(Object.entries(layered).filter(([, value]) => value !== undefined));\n\t\treturn { ...own, ...defined };\n\t}\n}\n\n/**\n * Generate a JSON Schema document from a Zod validator using registry metadata.\n * An optional `$id` can be applied centrally so higher layers do not repeat that\n * concern for each emitted schema.\n */\nexport function generateZodJSONSchemaDocument(\n\tvalidator: z.ZodMiniType,\n\tmetadataRegistry: ZodJSONSchemaRegistry,\n\toptions?: {\n\t\ttarget?: JSONSchemaTarget;\n\t\tschemaId?: string;\n\t\tio?: 'input' | 'output';\n\t},\n): JSONSchemaObject {\n\tconst schema = z.toJSONSchema(validator, {\n\t\ttarget: options?.target || 'draft-2020-12',\n\t\tio: options?.io || 'input',\n\t\tmetadata: new LayeredMetadataRegistry(metadataRegistry),\n\t}) as JSONSchemaObject & { $id?: string };\n\n\tif (options?.schemaId) {\n\t\tschema.$id = options.schemaId;\n\t}\n\n\treturn schema;\n}\n"],
5
- "mappings": ";AAAA,YAAY,OAAO;AAMZ,SAAS,UAAU,QAA0C;AACnE,SACC,OAAO,WAAW,YAClB,WAAW,QACX,OAAQ,OAA+B,UAAU,cACjD,OAAQ,OAAmC,cAAc;AAE3D;AAeO,SAAS,gCACf,kBACA,SAKmB;AACnB,SAAS,eAAa,kBAAkB;AAAA,IACvC,QAAQ,SAAS,UAAU;AAAA,IAC3B,IAAI,SAAS,MAAM;AAAA,IACnB,KAAK,SAAS,QAAQ,CAAC,OAAe,iBAAiB,EAAE;AAAA,EAC1D,CAAC;AACF;AAYA,IAAM,0BAAN,cAAwC,OAAK,aAAsC;AAAA,EAClF,YAA6B,SAAgC;AAC5D,UAAM;AADsB;AAAA,EAE7B;AAAA,EAF6B;AAAA,EAIpB,IAAI,QAA8D;AAC1E,UAAM,MAAQ,iBAAe,IAAI,MAAM;AACvC,UAAM,UAAU,KAAK,QAAQ,IAAI,MAAM;AACvC,QAAI,CAAC,SAAS;AACb,aAAO;AAAA,IACR;AACA,UAAM,UAAU,OAAO,YAAY,OAAO,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS,CAAC;AACrG,WAAO,EAAE,GAAG,KAAK,GAAG,QAAQ;AAAA,EAC7B;AACD;AAOO,SAAS,8BACf,WACA,kBACA,SAKmB;AACnB,QAAM,SAAW,eAAa,WAAW;AAAA,IACxC,QAAQ,SAAS,UAAU;AAAA,IAC3B,IAAI,SAAS,MAAM;AAAA,IACnB,UAAU,IAAI,wBAAwB,gBAAgB;AAAA,EACvD,CAAC;AAED,MAAI,SAAS,UAAU;AACtB,WAAO,MAAM,QAAQ;AAAA,EACtB;AAEA,SAAO;AACR;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/runtime/types.ts"],
4
- "sourcesContent": ["import type { ParsedActionSequence } from '@schema-engine/actions';\nimport type { FormEngineRuntime } from '@/engine/form-engine';\nimport type { FormActionConfig, SubmissionActionResult } from '@/runtime/submission-lifecycle';\nimport type { FormStepState, StepNavigationMode } from '@/engine/step-machine';\nimport type { ValidationStep } from '@/engine/value-validation';\nimport type { SubmissionSchema } from '@/engine/submission-schema';\nimport type { FormFetch } from '@/lib/form-fetch';\nimport type { FormActionTrigger } from '@/actions';\nimport type { DefaultValuesOf } from '@/builder/form-values';\nimport type { ValuesBrand } from '@/lib/normalized-form-config';\nimport type {\n\tFormStateContainer,\n\tFormStateContainerConfig,\n\tFormStateErrorsInput,\n\tFormIssueFormatter,\n\tFormStateHydration,\n\tFormSubmissionIssue,\n} from '@/state-container/types';\n\n/** The nested values of a form, as the container holds them and a submission hands them over. */\nexport type FormValues = Readonly<Record<string, unknown>>;\n\n/** What `onSubmit` is given besides the values that passed. */\nexport interface FormSubmitHelpers {\n\t/** Shows the server's answer to this submission, by path; `FORM_ROOT` stands for the form. */\n\tsetServerErrors: (errors: FormStateErrorsInput) => void;\n\t/**\n\t * The engine's `fetch`: the request to send the values with.\n\t *\n\t * @remarks It applies the engine's CSRF policy to a same-origin unsafe request, so a submit callback adds no token itself.\n\t */\n\tfetch: FormFetch;\n}\n\n/**\n * How a command ended.\n *\n * @remarks\n * - `moved`: the current step changed.\n * - `submitted` and `failed`: a submission ran and its actions and `onSubmit` succeeded or did not. Why it\n * failed is in `snapshot.submission.failures`, never in the return value.\n * - `invalid`: validation found errors, which are shown and focused.\n * - `overtaken`: an edit or a row move outran the check, so there is no verdict: nothing is shown or focused.\n * - `refused`: there was nowhere to go, or the step is unknown, skipped or not reachable.\n * - `busy`: another command was running.\n * - `cancelled`: a reset or an unmount revoked the command, which then wrote nothing.\n */\nexport type FormRuntimeOutcome =\n\t'moved' | 'submitted' | 'failed' | 'invalid' | 'overtaken' | 'refused' | 'busy' | 'cancelled';\n\n/** How `next()`, `back()` and `goTo()` ended. */\nexport type NavigationOutcome = Extract<\n\tFormRuntimeOutcome,\n\t'moved' | 'failed' | 'invalid' | 'overtaken' | 'refused' | 'busy' | 'cancelled'\n>;\n\n/** How `submit()` ended: before the last active step it acts as `next()`, so it can end `moved`. */\nexport type SubmitOutcome = Extract<\n\tFormRuntimeOutcome,\n\t'moved' | 'submitted' | 'failed' | 'invalid' | 'overtaken' | 'refused' | 'busy' | 'cancelled'\n>;\n\n/**\n * Where a submission is: `idle` until one starts, `validating` while its validation runs, `submitting` once it passed and the actions and `onSubmit` run, then how it ended.\n *\n * @remarks A submission that is `invalid` or `overtaken` goes from `validating` back to `idle` and is never `submitting`: submission starts, for the `form_submit_start` trigger and for a renderer's own start event, once it passed validation.\n */\nexport type SubmissionStatus = 'idle' | 'validating' | 'submitting' | 'success' | 'error';\n\n/**\n * Whether a submission is in progress: its validation or its actions are running.\n *\n * @remarks The one definition of busy, which the runtime's revoke and every renderer's submit button, label and busy state share.\n */\nexport function isSubmissionBusy(status: SubmissionStatus): boolean {\n\treturn status === 'validating' || status === 'submitting';\n}\n\n/**\n * What the form reports about its submissions.\n *\n * @remarks `failures` explain an `error` status and are empty otherwise. They are issues, so the form's one formatter words them.\n */\nexport interface FormSubmissionState {\n\treadonly status: SubmissionStatus;\n\treadonly failures: readonly FormSubmissionIssue[];\n\t/** The submissions that ended, whether they passed or failed validation, since the form was created or reset. */\n\treadonly submitCount: number;\n}\n\n/** What a runtime reports: its submission, and its steps. */\nexport interface FormRuntimeSnapshot {\n\treadonly submission: FormSubmissionState;\n\t/** The id of the current step. */\n\treadonly current: string;\n\t/** A `next`, `back`, `goTo` or a submit that acts as `next` is running. */\n\treadonly navigating: boolean;\n\t/** Every step in config order, skipped ones included. */\n\treadonly steps: readonly FormStepState[];\n}\n\n/** What only the renderer can do. */\nexport interface FormRuntimeHost {\n\t/**\n\t * Focuses the first control with an error among `paths`.\n\t *\n\t * @remarks The paths are those of the fields that have an error; the host picks the first in the document. The list may be empty (a rule that could not run records no field error), and the host then focuses nothing.\n\t */\n\tfocus(paths: readonly string[]): void;\n\t/** Writes the controls' values to the container and reports their native validity, as a submit does, before a check. */\n\tsync?(): void;\n\t/**\n\t * Called once a submission succeeded, after its actions and `onSubmit`, with the values the form declares, so a host whose form can post natively may do it with them.\n\t *\n\t * @remarks The values are what the form's elements write, checked by the schema derived from them, and not what the application's schema made of them (a `Date`, a class): a form posts what its fields hold. The host decides whether it posts, because a renderer always passes a stable `onSubmit` wrapper and the runtime cannot tell whether the application gave one: Radiant posts when it did not. The navigation cannot cut off the success and complete triggers, which ran first.\n\t */\n\tsubmitNatively?(values: FormValues): void;\n}\n\n/** A step of the config the runtime reads. */\nexport interface FormRuntimeStep<TAction extends FormActionConfig = FormActionConfig> extends ValidationStep {\n\treadonly id: string;\n\t/** Actions dispatched after the form's on every trigger while this step is current. */\n\treadonly actions?: ParsedActionSequence<TAction>;\n}\n\n/** The normalized form config, in the shape the runtime reads. */\nexport interface FormRuntimeConfig<\n\tTAction extends FormActionConfig = FormActionConfig,\n> extends FormStateContainerConfig {\n\treadonly id?: string;\n\treadonly navigation?: StepNavigationMode;\n\treadonly actions?: ParsedActionSequence<TAction>;\n\treadonly steps: readonly FormRuntimeStep<TAction>[];\n}\n\n/**\n * What {@link createFormRuntime} builds a runtime from.\n *\n * @template TValues - The values a submission holds, which the form's config carries ({@link ValuesBrand}); {@link FormValues} when it is not typed. It is inferred from `config`, which the runtime has parsed every submission against before it reaches a callback.\n */\nexport interface CreateFormRuntimeOptions<TAction extends FormActionConfig = FormActionConfig, TValues = FormValues> {\n\t/** The engine, for its validation registry, its actions and its `fetch`. */\n\tengine: FormEngineRuntime;\n\tconfig: FormRuntimeConfig<TAction> & ValuesBrand<TValues>;\n\t/** Values the form starts from, over the defaults of its fields. */\n\tdefaults?: DefaultValuesOf<TValues>;\n\t/** The snapshot of a container that rendered the form on the server, to start from. */\n\tsnapshot?: FormStateHydration;\n\thost: FormRuntimeHost;\n\t/** Called with the values that passed validation and matched the form's value schemas, after the submit actions and before the success trigger. */\n\tonSubmit?: (data: TValues, helpers: FormSubmitHelpers) => void | Promise<void>;\n\t/** Called when the values change, never for an error, a touch or a validation result. */\n\tonChange?: (data: FormValues) => void;\n\t/** Called with each submit action that succeeded, and the values that passed. Typed by the engine's actions. */\n\tonAction?: (action: TAction, data: TValues) => void | Promise<void>;\n\t/**\n\t * Takes the page to the `redirectUrl` a submit action asked for, once the whole submission succeeded.\n\t *\n\t * @remarks\n\t * Called at most once, after every submit action and `onSubmit` succeeded and the success trigger ran, with the\n\t * `redirectUrl` of the last successful submit action that set one. It replaces\n\t * {@link FormRuntimeHost.submitNatively} for that submission, since a native post would load a page of its own.\n\t * Defaults to {@link defaultNavigate}: `location.assign` where `globalThis.location` exists, and nothing on a server.\n\t */\n\tnavigate?: (url: string) => void;\n\t/** Called with the results of every trigger that ran actions, and once with those of the submit actions. */\n\tonActionResults?: (results: readonly SubmissionActionResult[], trigger: FormActionTrigger) => void | Promise<void>;\n}\n\n/** One instance of a form's lifecycle and wizard navigation, shared by every renderer. */\nexport interface FormRuntime {\n\t/** The form state: values, field state, validation and the captured submission. */\n\treadonly container: FormStateContainer;\n\t/** The normalized config the runtime was created from. */\n\treadonly config: FormRuntimeConfig;\n\t/**\n\t * The submitted values of the form as a Standard Schema, composed once from the config's elements.\n\t *\n\t * @remarks The schema every submission is checked against, so a tool that builds values for the form reads it from here and cannot drift from the runtime's.\n\t */\n\treadonly submissionSchema: SubmissionSchema;\n\t/** The engine's `formatIssue`, which a form without one of its own words its issues with. */\n\treadonly formatIssue: FormIssueFormatter | undefined;\n\t/**\n\t * Starts the runtime: dispatches `form_mount` the first time, and watches the values for `form_change` and `onChange`.\n\t *\n\t * @remarks The returned function stops the watch and revokes any command in flight (`next`, `back`, `goTo`, `submit`), which ends `'cancelled'`. Mounting again is allowed and dispatches `form_mount` no more.\n\t */\n\tmount: () => () => void;\n\tgetSnapshot: () => FormRuntimeSnapshot;\n\tgetServerSnapshot: () => FormRuntimeSnapshot;\n\tsubscribe: (listener: () => void) => () => void;\n\t/** Validates the current step and moves to the next active one. */\n\tnext: () => Promise<NavigationOutcome>;\n\t/** Moves to the previous active step, without validating. */\n\tback: () => Promise<NavigationOutcome>;\n\t/** Moves to the step `id`: back always, forward as the form's `navigation` allows. */\n\tgoTo: (id: string) => Promise<NavigationOutcome>;\n\t/** Acts as `next()` before the last active step; on it, validates every active step, runs the actions and `onSubmit`. */\n\tsubmit: () => Promise<SubmitOutcome>;\n\t/** Hides the outcome of the last submission: the status goes back to `idle` and the failures are dropped. */\n\tclearSubmission: () => void;\n}\n"],
5
- "mappings": ";AA0EO,SAAS,iBAAiB,QAAmC;AACnE,SAAO,WAAW,gBAAgB,WAAW;AAC9C;",
6
- "names": []
7
- }