@schema-engine/forms 0.0.0-stage → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (614) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +69 -2
  3. package/dist/actions/index.d.ts +3 -0
  4. package/dist/actions/index.js +50 -0
  5. package/dist/actions/index.js.map +7 -0
  6. package/dist/actions/plugins/auto-save.plugin.d.ts +39 -0
  7. package/dist/actions/plugins/auto-save.plugin.js +10 -0
  8. package/dist/actions/plugins/auto-save.plugin.js.map +7 -0
  9. package/dist/actions/plugins/form-reset.plugin.d.ts +23 -0
  10. package/dist/actions/plugins/form-reset.plugin.js +9 -0
  11. package/dist/actions/plugins/form-reset.plugin.js.map +7 -0
  12. package/dist/actions/plugins/form-submit.plugin.d.ts +31 -0
  13. package/dist/actions/plugins/form-submit.plugin.js +9 -0
  14. package/dist/actions/plugins/form-submit.plugin.js.map +7 -0
  15. package/dist/actions/plugins/form-submit.registration.d.ts +22 -0
  16. package/dist/actions/plugins/form-submit.registration.js +8 -0
  17. package/dist/actions/plugins/form-submit.registration.js.map +7 -0
  18. package/dist/actions/plugins/gtm.plugin.d.ts +30 -0
  19. package/dist/actions/plugins/gtm.plugin.js +8 -0
  20. package/dist/actions/plugins/gtm.plugin.js.map +7 -0
  21. package/dist/actions/plugins/index.d.ts +16 -0
  22. package/dist/actions/plugins/index.js +45 -0
  23. package/dist/actions/plugins/index.js.map +7 -0
  24. package/dist/actions/plugins/notification.plugin.d.ts +32 -0
  25. package/dist/actions/plugins/notification.plugin.js +9 -0
  26. package/dist/actions/plugins/notification.plugin.js.map +7 -0
  27. package/dist/actions/plugins/notification.registration.d.ts +22 -0
  28. package/dist/actions/plugins/notification.registration.js +8 -0
  29. package/dist/actions/plugins/notification.registration.js.map +7 -0
  30. package/dist/actions/plugins/registrations.d.ts +17 -0
  31. package/dist/actions/plugins/registrations.js +14 -0
  32. package/dist/actions/plugins/registrations.js.map +7 -0
  33. package/dist/actions/triggers.d.ts +42 -0
  34. package/dist/actions/triggers.js +6 -0
  35. package/dist/actions/triggers.js.map +7 -0
  36. package/dist/actions/types.d.ts +16 -0
  37. package/dist/actions/types.js +1 -0
  38. package/dist/actions/types.js.map +7 -0
  39. package/dist/agent-tool/index.d.ts +54 -0
  40. package/dist/agent-tool/index.js +128 -0
  41. package/dist/agent-tool/index.js.map +7 -0
  42. package/dist/browser/action-registrations.d.ts +46 -0
  43. package/dist/browser/action-registrations.js +19 -0
  44. package/dist/browser/action-registrations.js.map +7 -0
  45. package/dist/browser/index.d.ts +4 -0
  46. package/dist/browser/index.js +36 -0
  47. package/dist/browser/index.js.map +7 -0
  48. package/dist/browser/tools/auto-save-storage.d.ts +20 -0
  49. package/dist/browser/tools/auto-save-storage.js +12 -0
  50. package/dist/browser/tools/auto-save-storage.js.map +7 -0
  51. package/dist/browser/tools/gdpr-consent.d.ts +32 -0
  52. package/dist/browser/tools/gdpr-consent.js +11 -0
  53. package/dist/browser/tools/gdpr-consent.js.map +7 -0
  54. package/dist/browser/tools/gtm-tracker.d.ts +7 -0
  55. package/dist/browser/tools/gtm-tracker.js +7 -0
  56. package/dist/browser/tools/gtm-tracker.js.map +7 -0
  57. package/dist/builder/form-authoring.d.ts +159 -0
  58. package/dist/builder/form-authoring.js +1 -0
  59. package/dist/builder/form-authoring.js.map +7 -0
  60. package/dist/builder/form-values.d.ts +158 -0
  61. package/dist/builder/form-values.js +0 -0
  62. package/dist/builder/form-values.js.map +7 -0
  63. package/dist/builder/index.d.ts +5 -0
  64. package/dist/builder/index.js +2 -0
  65. package/dist/builder/index.js.map +7 -0
  66. package/dist/builder/types.utils.d.ts +137 -0
  67. package/dist/builder/types.utils.js +1 -0
  68. package/dist/builder/types.utils.js.map +7 -0
  69. package/dist/chunk-237BHPDH.js +88 -0
  70. package/dist/chunk-237BHPDH.js.map +7 -0
  71. package/dist/chunk-25PLQDKN.js +45 -0
  72. package/dist/chunk-25PLQDKN.js.map +7 -0
  73. package/dist/chunk-2XWISGGM.js +8 -0
  74. package/dist/chunk-2XWISGGM.js.map +7 -0
  75. package/dist/chunk-2YKQAVI2.js +8 -0
  76. package/dist/chunk-2YKQAVI2.js.map +7 -0
  77. package/dist/chunk-3B7CJOF6.js +18 -0
  78. package/dist/chunk-3B7CJOF6.js.map +7 -0
  79. package/dist/chunk-3YLRJVVN.js +17 -0
  80. package/dist/chunk-3YLRJVVN.js.map +7 -0
  81. package/dist/chunk-4CUGHU36.js +58 -0
  82. package/dist/chunk-4CUGHU36.js.map +7 -0
  83. package/dist/chunk-4FELFUCD.js +0 -0
  84. package/dist/chunk-4FELFUCD.js.map +7 -0
  85. package/dist/chunk-4XPLSYTK.js +82 -0
  86. package/dist/chunk-4XPLSYTK.js.map +7 -0
  87. package/dist/chunk-5Y6U3MR3.js +54 -0
  88. package/dist/chunk-5Y6U3MR3.js.map +7 -0
  89. package/dist/chunk-6BAJHAGL.js +29 -0
  90. package/dist/chunk-6BAJHAGL.js.map +7 -0
  91. package/dist/chunk-6EYX257T.js +23 -0
  92. package/dist/chunk-6EYX257T.js.map +7 -0
  93. package/dist/chunk-6FUGK5HQ.js +26 -0
  94. package/dist/chunk-6FUGK5HQ.js.map +7 -0
  95. package/dist/chunk-6IZYNHZ3.js +118 -0
  96. package/dist/chunk-6IZYNHZ3.js.map +7 -0
  97. package/dist/chunk-6NV2JDGI.js +8 -0
  98. package/dist/chunk-6NV2JDGI.js.map +7 -0
  99. package/dist/chunk-6R2MBQPL.js +19 -0
  100. package/dist/chunk-6R2MBQPL.js.map +7 -0
  101. package/dist/chunk-7EQJUI5N.js +40 -0
  102. package/dist/chunk-7EQJUI5N.js.map +7 -0
  103. package/dist/chunk-A5VLMQAK.js +2780 -0
  104. package/dist/chunk-A5VLMQAK.js.map +7 -0
  105. package/dist/chunk-AUZ45XPE.js +27 -0
  106. package/dist/chunk-AUZ45XPE.js.map +7 -0
  107. package/dist/chunk-BIHEIJG3.js +0 -0
  108. package/dist/chunk-BIHEIJG3.js.map +7 -0
  109. package/dist/chunk-BKNWW4PK.js +0 -0
  110. package/dist/chunk-BKNWW4PK.js.map +7 -0
  111. package/dist/chunk-BLFLCSG3.js +71 -0
  112. package/dist/chunk-BLFLCSG3.js.map +7 -0
  113. package/dist/chunk-BYYGAGNH.js +0 -0
  114. package/dist/chunk-BYYGAGNH.js.map +7 -0
  115. package/dist/chunk-CANRZY5A.js +87 -0
  116. package/dist/chunk-CANRZY5A.js.map +7 -0
  117. package/dist/chunk-CAZPWBQ4.js +18 -0
  118. package/dist/chunk-CAZPWBQ4.js.map +7 -0
  119. package/dist/chunk-CMPOBBRV.js +10 -0
  120. package/dist/chunk-CMPOBBRV.js.map +7 -0
  121. package/dist/chunk-CRQWKC67.js +118 -0
  122. package/dist/chunk-CRQWKC67.js.map +7 -0
  123. package/dist/chunk-CRVXBWSY.js +70 -0
  124. package/dist/chunk-CRVXBWSY.js.map +7 -0
  125. package/dist/chunk-D6ZHV6AT.js +0 -0
  126. package/dist/chunk-D6ZHV6AT.js.map +7 -0
  127. package/dist/chunk-DP7SYLLI.js +206 -0
  128. package/dist/chunk-DP7SYLLI.js.map +7 -0
  129. package/dist/chunk-DVDKPY2A.js +12 -0
  130. package/dist/chunk-DVDKPY2A.js.map +7 -0
  131. package/dist/chunk-E4VONSLO.js +15 -0
  132. package/dist/chunk-E4VONSLO.js.map +7 -0
  133. package/dist/chunk-EEYGPPLU.js +185 -0
  134. package/dist/chunk-EEYGPPLU.js.map +7 -0
  135. package/dist/chunk-EI5TMJDC.js +56 -0
  136. package/dist/chunk-EI5TMJDC.js.map +7 -0
  137. package/dist/chunk-EQ5AIF3T.js +117 -0
  138. package/dist/chunk-EQ5AIF3T.js.map +7 -0
  139. package/dist/chunk-EZZHO6DQ.js +26 -0
  140. package/dist/chunk-EZZHO6DQ.js.map +7 -0
  141. package/dist/chunk-FUHLRG3M.js +130 -0
  142. package/dist/chunk-FUHLRG3M.js.map +7 -0
  143. package/dist/chunk-FVOL3ZOJ.js +101 -0
  144. package/dist/chunk-FVOL3ZOJ.js.map +7 -0
  145. package/dist/chunk-G33EUV7N.js +288 -0
  146. package/dist/chunk-G33EUV7N.js.map +7 -0
  147. package/dist/chunk-GH34XFCC.js +56 -0
  148. package/dist/chunk-GH34XFCC.js.map +7 -0
  149. package/dist/chunk-GKWRJ6H4.js +27 -0
  150. package/dist/chunk-GKWRJ6H4.js.map +7 -0
  151. package/dist/chunk-GQHMU3AR.js +907 -0
  152. package/dist/chunk-GQHMU3AR.js.map +7 -0
  153. package/dist/chunk-GRZU6F7Q.js +80 -0
  154. package/dist/chunk-GRZU6F7Q.js.map +7 -0
  155. package/dist/chunk-GT2LARKT.js +107 -0
  156. package/dist/chunk-GT2LARKT.js.map +7 -0
  157. package/dist/chunk-H4ABGAAG.js +60 -0
  158. package/dist/chunk-H4ABGAAG.js.map +7 -0
  159. package/dist/chunk-H63UHX42.js +93 -0
  160. package/dist/chunk-H63UHX42.js.map +7 -0
  161. package/dist/chunk-HIS4MGIR.js +8 -0
  162. package/dist/chunk-HIS4MGIR.js.map +7 -0
  163. package/dist/chunk-HPPFSWIV.js +213 -0
  164. package/dist/chunk-HPPFSWIV.js.map +7 -0
  165. package/dist/chunk-J2FC5K4B.js +87 -0
  166. package/dist/chunk-J2FC5K4B.js.map +7 -0
  167. package/dist/chunk-J5BSFDVK.js +123 -0
  168. package/dist/chunk-J5BSFDVK.js.map +7 -0
  169. package/dist/chunk-J7GSNWXT.js +151 -0
  170. package/dist/chunk-J7GSNWXT.js.map +7 -0
  171. package/dist/chunk-JA5ET6MC.js +550 -0
  172. package/dist/chunk-JA5ET6MC.js.map +7 -0
  173. package/dist/chunk-K22S7IZR.js +12 -0
  174. package/dist/chunk-K22S7IZR.js.map +7 -0
  175. package/dist/chunk-K5TMXCMY.js +139 -0
  176. package/dist/chunk-K5TMXCMY.js.map +7 -0
  177. package/dist/chunk-KE53GN4Q.js +246 -0
  178. package/dist/chunk-KE53GN4Q.js.map +7 -0
  179. package/dist/chunk-KFQEDSYI.js +24 -0
  180. package/dist/chunk-KFQEDSYI.js.map +7 -0
  181. package/dist/chunk-KH6QWB5Y.js +51 -0
  182. package/dist/chunk-KH6QWB5Y.js.map +7 -0
  183. package/dist/chunk-KLATKWUA.js +116 -0
  184. package/dist/chunk-KLATKWUA.js.map +7 -0
  185. package/dist/chunk-KSKWSUOB.js +17 -0
  186. package/dist/chunk-KSKWSUOB.js.map +7 -0
  187. package/dist/chunk-LFWEJXWE.js +68 -0
  188. package/dist/chunk-LFWEJXWE.js.map +7 -0
  189. package/dist/chunk-LMWJAD3B.js +24 -0
  190. package/dist/chunk-LMWJAD3B.js.map +7 -0
  191. package/dist/chunk-MD23VADH.js +92 -0
  192. package/dist/chunk-MD23VADH.js.map +7 -0
  193. package/dist/chunk-MKMJT3XR.js +0 -0
  194. package/dist/chunk-MKMJT3XR.js.map +7 -0
  195. package/dist/chunk-NJTLBSTR.js +82 -0
  196. package/dist/chunk-NJTLBSTR.js.map +7 -0
  197. package/dist/chunk-NJXKMF67.js +182 -0
  198. package/dist/chunk-NJXKMF67.js.map +7 -0
  199. package/dist/chunk-OBQBIOGN.js +16 -0
  200. package/dist/chunk-OBQBIOGN.js.map +7 -0
  201. package/dist/chunk-OLYHNFKC.js +82 -0
  202. package/dist/chunk-OLYHNFKC.js.map +7 -0
  203. package/dist/chunk-OR2L7EKO.js +33 -0
  204. package/dist/chunk-OR2L7EKO.js.map +7 -0
  205. package/dist/chunk-OUF57UZ7.js +28 -0
  206. package/dist/chunk-OUF57UZ7.js.map +7 -0
  207. package/dist/chunk-PBMM2N77.js +56 -0
  208. package/dist/chunk-PBMM2N77.js.map +7 -0
  209. package/dist/chunk-PCL2KNHC.js +6 -0
  210. package/dist/chunk-PCL2KNHC.js.map +7 -0
  211. package/dist/chunk-PH3LWLYN.js +49 -0
  212. package/dist/chunk-PH3LWLYN.js.map +7 -0
  213. package/dist/chunk-PHNMDWSK.js +9 -0
  214. package/dist/chunk-PHNMDWSK.js.map +7 -0
  215. package/dist/chunk-PN5EH6DM.js +36 -0
  216. package/dist/chunk-PN5EH6DM.js.map +7 -0
  217. package/dist/chunk-POCAINUE.js +42 -0
  218. package/dist/chunk-POCAINUE.js.map +7 -0
  219. package/dist/chunk-Q5LEK7CI.js +64 -0
  220. package/dist/chunk-Q5LEK7CI.js.map +7 -0
  221. package/dist/chunk-QH7VW7IY.js +0 -0
  222. package/dist/chunk-QH7VW7IY.js.map +7 -0
  223. package/dist/chunk-QLGM2AZW.js +173 -0
  224. package/dist/chunk-QLGM2AZW.js.map +7 -0
  225. package/dist/chunk-QT3EYUL5.js +85 -0
  226. package/dist/chunk-QT3EYUL5.js.map +7 -0
  227. package/dist/chunk-QYHOFLRX.js +43 -0
  228. package/dist/chunk-QYHOFLRX.js.map +7 -0
  229. package/dist/chunk-R3MBVWVI.js +127 -0
  230. package/dist/chunk-R3MBVWVI.js.map +7 -0
  231. package/dist/chunk-R6V3LH7F.js +67 -0
  232. package/dist/chunk-R6V3LH7F.js.map +7 -0
  233. package/dist/chunk-RB22U6HI.js +64 -0
  234. package/dist/chunk-RB22U6HI.js.map +7 -0
  235. package/dist/chunk-RQRQYYTB.js +34 -0
  236. package/dist/chunk-RQRQYYTB.js.map +7 -0
  237. package/dist/chunk-S5D2QE4G.js +53 -0
  238. package/dist/chunk-S5D2QE4G.js.map +7 -0
  239. package/dist/chunk-S7I76ISM.js +245 -0
  240. package/dist/chunk-S7I76ISM.js.map +7 -0
  241. package/dist/chunk-TBDZOQ2C.js +66 -0
  242. package/dist/chunk-TBDZOQ2C.js.map +7 -0
  243. package/dist/chunk-TSKELYW7.js +55 -0
  244. package/dist/chunk-TSKELYW7.js.map +7 -0
  245. package/dist/chunk-U3YHTQHR.js +215 -0
  246. package/dist/chunk-U3YHTQHR.js.map +7 -0
  247. package/dist/chunk-UGL3KNOT.js +42 -0
  248. package/dist/chunk-UGL3KNOT.js.map +7 -0
  249. package/dist/chunk-UN3DARLG.js +35 -0
  250. package/dist/chunk-UN3DARLG.js.map +7 -0
  251. package/dist/chunk-V5H7L5PJ.js +587 -0
  252. package/dist/chunk-V5H7L5PJ.js.map +7 -0
  253. package/dist/chunk-VGGERKV2.js +7 -0
  254. package/dist/chunk-VGGERKV2.js.map +7 -0
  255. package/dist/chunk-VVFXYY65.js +0 -0
  256. package/dist/chunk-VVFXYY65.js.map +7 -0
  257. package/dist/chunk-WLDCYUN6.js +161 -0
  258. package/dist/chunk-WLDCYUN6.js.map +7 -0
  259. package/dist/chunk-WMDTQS36.js +0 -0
  260. package/dist/chunk-WMDTQS36.js.map +7 -0
  261. package/dist/chunk-WUTGZYP4.js +290 -0
  262. package/dist/chunk-WUTGZYP4.js.map +7 -0
  263. package/dist/chunk-XKN3WWK3.js +0 -0
  264. package/dist/chunk-XKN3WWK3.js.map +7 -0
  265. package/dist/chunk-XQ5VJ4QO.js +62 -0
  266. package/dist/chunk-XQ5VJ4QO.js.map +7 -0
  267. package/dist/chunk-XQVKX47O.js +174 -0
  268. package/dist/chunk-XQVKX47O.js.map +7 -0
  269. package/dist/chunk-Y5CNB57V.js +22 -0
  270. package/dist/chunk-Y5CNB57V.js.map +7 -0
  271. package/dist/chunk-YDGH7DTL.js +18 -0
  272. package/dist/chunk-YDGH7DTL.js.map +7 -0
  273. package/dist/chunk-YIFUBPJ3.js +0 -0
  274. package/dist/chunk-YIFUBPJ3.js.map +7 -0
  275. package/dist/chunk-YUUDXRBW.js +212 -0
  276. package/dist/chunk-YUUDXRBW.js.map +7 -0
  277. package/dist/chunk-Z6DQLJS2.js +23 -0
  278. package/dist/chunk-Z6DQLJS2.js.map +7 -0
  279. package/dist/chunk-ZDEZ2FOC.js +81 -0
  280. package/dist/chunk-ZDEZ2FOC.js.map +7 -0
  281. package/dist/chunk-ZUYSGCEH.js +65 -0
  282. package/dist/chunk-ZUYSGCEH.js.map +7 -0
  283. package/dist/chunk-ZYP3MIH3.js +115 -0
  284. package/dist/chunk-ZYP3MIH3.js.map +7 -0
  285. package/dist/constraints/constraint-evaluator.d.ts +57 -0
  286. package/dist/constraints/constraint-evaluator.js +17 -0
  287. package/dist/constraints/constraint-evaluator.js.map +7 -0
  288. package/dist/constraints/index.d.ts +1 -0
  289. package/dist/constraints/index.js +17 -0
  290. package/dist/constraints/index.js.map +7 -0
  291. package/dist/csrf/index.d.ts +43 -0
  292. package/dist/csrf/index.js +43 -0
  293. package/dist/csrf/index.js.map +7 -0
  294. package/dist/engine/build-form-engine.d.ts +27 -0
  295. package/dist/engine/build-form-engine.js +58 -0
  296. package/dist/engine/build-form-engine.js.map +7 -0
  297. package/dist/engine/component-type.d.ts +19 -0
  298. package/dist/engine/component-type.js +6 -0
  299. package/dist/engine/component-type.js.map +7 -0
  300. package/dist/engine/create-form-engine.d.ts +100 -0
  301. package/dist/engine/create-form-engine.js +59 -0
  302. package/dist/engine/create-form-engine.js.map +7 -0
  303. package/dist/engine/form-action-context.d.ts +70 -0
  304. package/dist/engine/form-action-context.js +10 -0
  305. package/dist/engine/form-action-context.js.map +7 -0
  306. package/dist/engine/form-engine.d.ts +236 -0
  307. package/dist/engine/form-engine.js +61 -0
  308. package/dist/engine/form-engine.js.map +7 -0
  309. package/dist/engine/index.d.ts +12 -0
  310. package/dist/engine/index.js +124 -0
  311. package/dist/engine/index.js.map +7 -0
  312. package/dist/engine/schema-artifacts.d.ts +87 -0
  313. package/dist/engine/schema-artifacts.js +14 -0
  314. package/dist/engine/schema-artifacts.js.map +7 -0
  315. package/dist/engine/schema-metadata-catalog.d.ts +41 -0
  316. package/dist/engine/schema-metadata-catalog.js +6 -0
  317. package/dist/engine/schema-metadata-catalog.js.map +7 -0
  318. package/dist/engine/step-machine.d.ts +59 -0
  319. package/dist/engine/step-machine.js +32 -0
  320. package/dist/engine/step-machine.js.map +7 -0
  321. package/dist/engine/submission-schema.d.ts +53 -0
  322. package/dist/engine/submission-schema.js +22 -0
  323. package/dist/engine/submission-schema.js.map +7 -0
  324. package/dist/engine/value-validation.d.ts +237 -0
  325. package/dist/engine/value-validation.js +39 -0
  326. package/dist/engine/value-validation.js.map +7 -0
  327. package/dist/index.d.ts +76 -0
  328. package/dist/index.js +283 -0
  329. package/dist/index.js.map +7 -0
  330. package/dist/lib/authoring-catalog.d.ts +5 -0
  331. package/dist/lib/authoring-catalog.js +11 -0
  332. package/dist/lib/authoring-catalog.js.map +7 -0
  333. package/dist/lib/container-kind-of.d.ts +5 -0
  334. package/dist/lib/container-kind-of.js +6 -0
  335. package/dist/lib/container-kind-of.js.map +7 -0
  336. package/dist/lib/debounce.d.ts +19 -0
  337. package/dist/lib/debounce.js +6 -0
  338. package/dist/lib/debounce.js.map +7 -0
  339. package/dist/lib/deep-readonly.d.ts +12 -0
  340. package/dist/lib/deep-readonly.js +0 -0
  341. package/dist/lib/deep-readonly.js.map +7 -0
  342. package/dist/lib/element-children.d.ts +35 -0
  343. package/dist/lib/element-children.js +16 -0
  344. package/dist/lib/element-children.js.map +7 -0
  345. package/dist/lib/exported-action-envelope.d.ts +11 -0
  346. package/dist/lib/exported-action-envelope.js +7 -0
  347. package/dist/lib/exported-action-envelope.js.map +7 -0
  348. package/dist/lib/exported-rules.d.ts +14 -0
  349. package/dist/lib/exported-rules.js +6 -0
  350. package/dist/lib/exported-rules.js.map +7 -0
  351. package/dist/lib/field-ref.d.ts +13 -0
  352. package/dist/lib/field-ref.js +6 -0
  353. package/dist/lib/field-ref.js.map +7 -0
  354. package/dist/lib/field-scope.d.ts +121 -0
  355. package/dist/lib/field-scope.js +41 -0
  356. package/dist/lib/field-scope.js.map +7 -0
  357. package/dist/lib/form-fetch.d.ts +36 -0
  358. package/dist/lib/form-fetch.js +10 -0
  359. package/dist/lib/form-fetch.js.map +7 -0
  360. package/dist/lib/form-view.d.ts +33 -0
  361. package/dist/lib/form-view.js +12 -0
  362. package/dist/lib/form-view.js.map +7 -0
  363. package/dist/lib/frozen-copy.d.ts +9 -0
  364. package/dist/lib/frozen-copy.js +7 -0
  365. package/dist/lib/frozen-copy.js.map +7 -0
  366. package/dist/lib/is-plain-object.d.ts +2 -0
  367. package/dist/lib/is-plain-object.js +6 -0
  368. package/dist/lib/is-plain-object.js.map +7 -0
  369. package/dist/lib/logger.d.ts +2 -0
  370. package/dist/lib/logger.js +6 -0
  371. package/dist/lib/logger.js.map +7 -0
  372. package/dist/lib/normalized-form-config.d.ts +106 -0
  373. package/dist/lib/normalized-form-config.js +19 -0
  374. package/dist/lib/normalized-form-config.js.map +7 -0
  375. package/dist/lib/omit-paths.d.ts +11 -0
  376. package/dist/lib/omit-paths.js +7 -0
  377. package/dist/lib/omit-paths.js.map +7 -0
  378. package/dist/lib/path-values.d.ts +47 -0
  379. package/dist/lib/path-values.js +22 -0
  380. package/dist/lib/path-values.js.map +7 -0
  381. package/dist/lib/renderer-data-attributes.d.ts +10 -0
  382. package/dist/lib/renderer-data-attributes.js +6 -0
  383. package/dist/lib/renderer-data-attributes.js.map +7 -0
  384. package/dist/lib/reserved-path-keys.d.ts +10 -0
  385. package/dist/lib/reserved-path-keys.js +10 -0
  386. package/dist/lib/reserved-path-keys.js.map +7 -0
  387. package/dist/lib/resolve-appearance.d.ts +48 -0
  388. package/dist/lib/resolve-appearance.js +10 -0
  389. package/dist/lib/resolve-appearance.js.map +7 -0
  390. package/dist/lib/standard-json-schema.d.ts +27 -0
  391. package/dist/lib/standard-json-schema.js +8 -0
  392. package/dist/lib/standard-json-schema.js.map +7 -0
  393. package/dist/lib/standard-schema.d.ts +19 -0
  394. package/dist/lib/standard-schema.js +8 -0
  395. package/dist/lib/standard-schema.js.map +7 -0
  396. package/dist/lib/submission-shape.d.ts +60 -0
  397. package/dist/lib/submission-shape.js +14 -0
  398. package/dist/lib/submission-shape.js.map +7 -0
  399. package/dist/lib/validate-form/grid-checks.d.ts +57 -0
  400. package/dist/lib/validate-form/grid-checks.js +16 -0
  401. package/dist/lib/validate-form/grid-checks.js.map +7 -0
  402. package/dist/lib/validate-form/issues.d.ts +43 -0
  403. package/dist/lib/validate-form/issues.js +13 -0
  404. package/dist/lib/validate-form/issues.js.map +7 -0
  405. package/dist/lib/validate-form/options.d.ts +22 -0
  406. package/dist/lib/validate-form/options.js +0 -0
  407. package/dist/lib/validate-form/options.js.map +7 -0
  408. package/dist/lib/validate-form/parse-elements.d.ts +23 -0
  409. package/dist/lib/validate-form/parse-elements.js +21 -0
  410. package/dist/lib/validate-form/parse-elements.js.map +7 -0
  411. package/dist/lib/validate-form/parse-owner-actions.d.ts +14 -0
  412. package/dist/lib/validate-form/parse-owner-actions.js +10 -0
  413. package/dist/lib/validate-form/parse-owner-actions.js.map +7 -0
  414. package/dist/lib/validate-form/parse-view.d.ts +11 -0
  415. package/dist/lib/validate-form/parse-view.js +11 -0
  416. package/dist/lib/validate-form/parse-view.js.map +7 -0
  417. package/dist/lib/validate-form/schema-issues.d.ts +16 -0
  418. package/dist/lib/validate-form/schema-issues.js +8 -0
  419. package/dist/lib/validate-form/schema-issues.js.map +7 -0
  420. package/dist/lib/validate-form/step-checks.d.ts +18 -0
  421. package/dist/lib/validate-form/step-checks.js +15 -0
  422. package/dist/lib/validate-form/step-checks.js.map +7 -0
  423. package/dist/lib/validate-form/validation-error.d.ts +26 -0
  424. package/dist/lib/validate-form/validation-error.js +8 -0
  425. package/dist/lib/validate-form/validation-error.js.map +7 -0
  426. package/dist/lib/validate-form.d.ts +34 -0
  427. package/dist/lib/validate-form.js +62 -0
  428. package/dist/lib/validate-form.js.map +7 -0
  429. package/dist/lib/zod-json-schema.d.ts +33 -0
  430. package/dist/lib/zod-json-schema.js +10 -0
  431. package/dist/lib/zod-json-schema.js.map +7 -0
  432. package/dist/recipes/built-in-specs.d.ts +1832 -0
  433. package/dist/recipes/built-in-specs.js +28 -0
  434. package/dist/recipes/built-in-specs.js.map +7 -0
  435. package/dist/recipes/built-in.d.ts +2 -0
  436. package/dist/recipes/built-in.js +49 -0
  437. package/dist/recipes/built-in.js.map +7 -0
  438. package/dist/recipes/define-form-recipe.d.ts +10 -0
  439. package/dist/recipes/define-form-recipe.js +6 -0
  440. package/dist/recipes/define-form-recipe.js.map +7 -0
  441. package/dist/recipes/define-recipe-spec.d.ts +13 -0
  442. package/dist/recipes/define-recipe-spec.js +8 -0
  443. package/dist/recipes/define-recipe-spec.js.map +7 -0
  444. package/dist/recipes/index.d.ts +6 -0
  445. package/dist/recipes/index.js +43 -0
  446. package/dist/recipes/index.js.map +7 -0
  447. package/dist/recipes/protocol.d.ts +24 -0
  448. package/dist/recipes/protocol.js +11 -0
  449. package/dist/recipes/protocol.js.map +7 -0
  450. package/dist/recipes/slot-schemas.d.ts +128 -0
  451. package/dist/recipes/slot-schemas.js +24 -0
  452. package/dist/recipes/slot-schemas.js.map +7 -0
  453. package/dist/recipes/types.d.ts +55 -0
  454. package/dist/recipes/types.js +1 -0
  455. package/dist/recipes/types.js.map +7 -0
  456. package/dist/recipes/view-model.d.ts +93 -0
  457. package/dist/recipes/view-model.js +29 -0
  458. package/dist/recipes/view-model.js.map +7 -0
  459. package/dist/registries/index.d.ts +8 -0
  460. package/dist/registries/index.js +0 -0
  461. package/dist/registries/index.js.map +7 -0
  462. package/dist/runtime/create-form-runtime.d.ts +43 -0
  463. package/dist/runtime/create-form-runtime.js +41 -0
  464. package/dist/runtime/create-form-runtime.js.map +7 -0
  465. package/dist/runtime/index.d.ts +3 -0
  466. package/dist/runtime/index.js +44 -0
  467. package/dist/runtime/index.js.map +7 -0
  468. package/dist/runtime/submission-lifecycle.d.ts +65 -0
  469. package/dist/runtime/submission-lifecycle.js +6 -0
  470. package/dist/runtime/submission-lifecycle.js.map +7 -0
  471. package/dist/runtime/types.d.ts +172 -0
  472. package/dist/runtime/types.js +6 -0
  473. package/dist/runtime/types.js.map +7 -0
  474. package/dist/schemas/base-field.d.ts +450 -0
  475. package/dist/schemas/base-field.js +36 -0
  476. package/dist/schemas/base-field.js.map +7 -0
  477. package/dist/schemas/field-config.d.ts +36 -0
  478. package/dist/schemas/field-config.js +1 -0
  479. package/dist/schemas/field-config.js.map +7 -0
  480. package/dist/schemas/form-config-shape.d.ts +763 -0
  481. package/dist/schemas/form-config-shape.js +35 -0
  482. package/dist/schemas/form-config-shape.js.map +7 -0
  483. package/dist/schemas/form-config.d.ts +1288 -0
  484. package/dist/schemas/form-config.js +41 -0
  485. package/dist/schemas/form-config.js.map +7 -0
  486. package/dist/schemas/html-attributes.d.ts +12 -0
  487. package/dist/schemas/html-attributes.js +12 -0
  488. package/dist/schemas/html-attributes.js.map +7 -0
  489. package/dist/schemas/index.d.ts +5 -0
  490. package/dist/schemas/index.js +165 -0
  491. package/dist/schemas/index.js.map +7 -0
  492. package/dist/schemas/validation/async/cache.d.ts +39 -0
  493. package/dist/schemas/validation/async/cache.js +6 -0
  494. package/dist/schemas/validation/async/cache.js.map +7 -0
  495. package/dist/schemas/validation/async/handler.d.ts +21 -0
  496. package/dist/schemas/validation/async/handler.js +11 -0
  497. package/dist/schemas/validation/async/handler.js.map +7 -0
  498. package/dist/schemas/validation/async/index.d.ts +8 -0
  499. package/dist/schemas/validation/async/index.js +14 -0
  500. package/dist/schemas/validation/async/index.js.map +7 -0
  501. package/dist/schemas/validation/defaults.d.ts +6 -0
  502. package/dist/schemas/validation/defaults.js +12 -0
  503. package/dist/schemas/validation/defaults.js.map +7 -0
  504. package/dist/schemas/validation/dependencies.d.ts +52 -0
  505. package/dist/schemas/validation/dependencies.js +17 -0
  506. package/dist/schemas/validation/dependencies.js.map +7 -0
  507. package/dist/schemas/validation/empty.d.ts +1 -0
  508. package/dist/schemas/validation/empty.js +6 -0
  509. package/dist/schemas/validation/empty.js.map +7 -0
  510. package/dist/schemas/validation/errors.d.ts +44 -0
  511. package/dist/schemas/validation/errors.js +12 -0
  512. package/dist/schemas/validation/errors.js.map +7 -0
  513. package/dist/schemas/validation/index.d.ts +9 -0
  514. package/dist/schemas/validation/index.js +130 -0
  515. package/dist/schemas/validation/index.js.map +7 -0
  516. package/dist/schemas/validation/presets.d.ts +66 -0
  517. package/dist/schemas/validation/presets.js +6 -0
  518. package/dist/schemas/validation/presets.js.map +7 -0
  519. package/dist/schemas/validation/relations.d.ts +12 -0
  520. package/dist/schemas/validation/relations.js +8 -0
  521. package/dist/schemas/validation/relations.js.map +7 -0
  522. package/dist/schemas/validation/types.d.ts +817 -0
  523. package/dist/schemas/validation/types.js +64 -0
  524. package/dist/schemas/validation/types.js.map +7 -0
  525. package/dist/schemas/validation/utils.d.ts +76 -0
  526. package/dist/schemas/validation/utils.js +24 -0
  527. package/dist/schemas/validation/utils.js.map +7 -0
  528. package/dist/schemas/validation/validation-registry.d.ts +124 -0
  529. package/dist/schemas/validation/validation-registry.js +27 -0
  530. package/dist/schemas/validation/validation-registry.js.map +7 -0
  531. package/dist/server-errors/from-json-api-errors.d.ts +13 -0
  532. package/dist/server-errors/from-json-api-errors.js +10 -0
  533. package/dist/server-errors/from-json-api-errors.js.map +7 -0
  534. package/dist/server-errors/from-problem-details.d.ts +15 -0
  535. package/dist/server-errors/from-problem-details.js +10 -0
  536. package/dist/server-errors/from-problem-details.js.map +7 -0
  537. package/dist/server-errors/index.d.ts +8 -0
  538. package/dist/server-errors/index.js +17 -0
  539. package/dist/server-errors/index.js.map +7 -0
  540. package/dist/server-errors/shared.d.ts +34 -0
  541. package/dist/server-errors/shared.js +23 -0
  542. package/dist/server-errors/shared.js.map +7 -0
  543. package/dist/state-container/create-form-state-container.d.ts +17 -0
  544. package/dist/state-container/create-form-state-container.js +31 -0
  545. package/dist/state-container/create-form-state-container.js.map +7 -0
  546. package/dist/state-container/dirty.d.ts +11 -0
  547. package/dist/state-container/dirty.js +9 -0
  548. package/dist/state-container/dirty.js.map +7 -0
  549. package/dist/state-container/field-array.d.ts +41 -0
  550. package/dist/state-container/field-array.js +8 -0
  551. package/dist/state-container/field-array.js.map +7 -0
  552. package/dist/state-container/hydration.d.ts +21 -0
  553. package/dist/state-container/hydration.js +11 -0
  554. package/dist/state-container/hydration.js.map +7 -0
  555. package/dist/state-container/index.d.ts +16 -0
  556. package/dist/state-container/index.js +51 -0
  557. package/dist/state-container/index.js.map +7 -0
  558. package/dist/state-container/issue-text.d.ts +11 -0
  559. package/dist/state-container/issue-text.js +6 -0
  560. package/dist/state-container/issue-text.js.map +7 -0
  561. package/dist/state-container/row-ids.d.ts +34 -0
  562. package/dist/state-container/row-ids.js +19 -0
  563. package/dist/state-container/row-ids.js.map +7 -0
  564. package/dist/state-container/selectors.d.ts +33 -0
  565. package/dist/state-container/selectors.js +22 -0
  566. package/dist/state-container/selectors.js.map +7 -0
  567. package/dist/state-container/stale-results.d.ts +28 -0
  568. package/dist/state-container/stale-results.js +9 -0
  569. package/dist/state-container/stale-results.js.map +7 -0
  570. package/dist/state-container/state-tree.d.ts +56 -0
  571. package/dist/state-container/state-tree.js +33 -0
  572. package/dist/state-container/state-tree.js.map +7 -0
  573. package/dist/state-container/submission.d.ts +45 -0
  574. package/dist/state-container/submission.js +26 -0
  575. package/dist/state-container/submission.js.map +7 -0
  576. package/dist/state-container/types.d.ts +404 -0
  577. package/dist/state-container/types.js +6 -0
  578. package/dist/state-container/types.js.map +7 -0
  579. package/dist/state-container/value-tree.d.ts +56 -0
  580. package/dist/state-container/value-tree.js +34 -0
  581. package/dist/state-container/value-tree.js.map +7 -0
  582. package/dist/testing/assert.d.ts +92 -0
  583. package/dist/testing/assert.js +42 -0
  584. package/dist/testing/assert.js.map +7 -0
  585. package/dist/testing/form-state-container-conformance.d.ts +63 -0
  586. package/dist/testing/form-state-container-conformance.js +44 -0
  587. package/dist/testing/form-state-container-conformance.js.map +7 -0
  588. package/dist/testing/index.d.ts +8 -0
  589. package/dist/testing/index.js +36 -0
  590. package/dist/testing/index.js.map +7 -0
  591. package/dist/types/actions.d.ts +75 -0
  592. package/dist/types/actions.js +1 -0
  593. package/dist/types/actions.js.map +7 -0
  594. package/dist/types/categories.d.ts +21 -0
  595. package/dist/types/categories.js +8 -0
  596. package/dist/types/categories.js.map +7 -0
  597. package/dist/types/define-element.d.ts +73 -0
  598. package/dist/types/define-element.js +8 -0
  599. package/dist/types/define-element.js.map +7 -0
  600. package/dist/types/index.d.ts +10 -0
  601. package/dist/types/index.js +17 -0
  602. package/dist/types/index.js.map +7 -0
  603. package/dist/types/metadata.d.ts +14 -0
  604. package/dist/types/metadata.js +1 -0
  605. package/dist/types/metadata.js.map +7 -0
  606. package/dist/types/registration.d.ts +142 -0
  607. package/dist/types/registration.js +1 -0
  608. package/dist/types/registration.js.map +7 -0
  609. package/package.json +113 -3
  610. package/skill/SKILL.md +79 -0
  611. package/skill/reference/forms-actions.md +51 -0
  612. package/skill/reference/forms-submission.md +44 -0
  613. package/skill/reference/forms-validation.md +91 -0
  614. package/skill/reference/forms.md +180 -0
@@ -0,0 +1,182 @@
1
+ import {
2
+ areaPlacementIssue,
3
+ namedPlacementIssue
4
+ } from "./chunk-YUUDXRBW.js";
5
+ import {
6
+ resolveAppearance,
7
+ withAppearance
8
+ } from "./chunk-RQRQYYTB.js";
9
+ import {
10
+ containerKindOf
11
+ } from "./chunk-2YKQAVI2.js";
12
+ import {
13
+ fromSchemaIssues
14
+ } from "./chunk-FVOL3ZOJ.js";
15
+ import {
16
+ childPath,
17
+ isTaggedConfig,
18
+ issueAt
19
+ } from "./chunk-LMWJAD3B.js";
20
+ import {
21
+ markNormalizedElementConfig
22
+ } from "./chunk-CRQWKC67.js";
23
+ import {
24
+ getElementChildren,
25
+ withElementChildren
26
+ } from "./chunk-ZUYSGCEH.js";
27
+ import {
28
+ ENGINE_KEY_PREFIX,
29
+ isReservedPathKey
30
+ } from "./chunk-3YLRJVVN.js";
31
+
32
+ // src/lib/validate-form/parse-elements.ts
33
+ import { safeParseStandardSchema } from "@schema-engine/registry";
34
+ function parseRegistration(schema, config, path) {
35
+ const result = safeParseStandardSchema(schema, config);
36
+ if (!result.success) {
37
+ return { ok: false, issues: fromSchemaIssues(result.error.issues, path) };
38
+ }
39
+ return { ok: true, data: result.data };
40
+ }
41
+ function parseTypedConfig(item, getRegistration, registerHint, path) {
42
+ const registration = getRegistration(item.$type);
43
+ if (!registration) {
44
+ return {
45
+ ok: false,
46
+ issues: [
47
+ issueAt([...path, "$type"], `Unknown element type '${item.$type}'. Register it with ${registerHint}.`)
48
+ ]
49
+ };
50
+ }
51
+ const parsed = parseRegistration(registration.schema, item, path);
52
+ if (!parsed.ok) return parsed;
53
+ if (!isTaggedConfig(parsed.data)) {
54
+ return {
55
+ ok: false,
56
+ issues: [
57
+ issueAt(
58
+ [...path, "$type"],
59
+ `Invalid element configuration for '${item.$type}': parsed output is missing $type.`
60
+ )
61
+ ]
62
+ };
63
+ }
64
+ return { ok: true, data: parsed.data };
65
+ }
66
+ function checkElementRules(item, checkRule, path) {
67
+ if (!Array.isArray(item.rules)) return { issues: [], item };
68
+ const issues = [];
69
+ const rules = [];
70
+ for (const [index, rule] of item.rules.entries()) {
71
+ if (typeof rule !== "object" || rule === null || !("$type" in rule) || typeof rule.$type !== "string") {
72
+ rules.push(rule);
73
+ continue;
74
+ }
75
+ const checked = checkRule(rule);
76
+ if (checked.ok) {
77
+ rules.push(checked.rule);
78
+ continue;
79
+ }
80
+ for (const issue of checked.issues) {
81
+ issues.push({ ...issue, path: [...path, "rules", index, ...issue.path] });
82
+ }
83
+ }
84
+ return { issues, item: { ...item, rules } };
85
+ }
86
+ function reservedNameSegment(item) {
87
+ return typeof item.name === "string" ? item.name.split(".").find(isReservedPathKey) : void 0;
88
+ }
89
+ function parseElementNode(item, getElement, checkRule, path, appearance, nested = false) {
90
+ const fail = (message, relative = []) => ({ issues: [issueAt([...path, ...relative], message)] });
91
+ if (!isTaggedConfig(item)) {
92
+ return fail("Invalid element configuration: missing $type.", ["$type"]);
93
+ }
94
+ const reserved = reservedNameSegment(item);
95
+ if (reserved) {
96
+ return fail(
97
+ `Field name '${String(item.name)}' uses the reserved segment '${reserved}': a name cannot start with '${ENGINE_KEY_PREFIX}' or be one of __proto__, constructor and prototype.`,
98
+ ["name"]
99
+ );
100
+ }
101
+ const { appearance: authoredAppearance, ...authored } = item;
102
+ const parsed = parseTypedConfig(
103
+ authored,
104
+ getElement,
105
+ "createFormEngine({ elements: [...] })",
106
+ path
107
+ );
108
+ if (!parsed.ok) {
109
+ return { issues: parsed.issues };
110
+ }
111
+ const checkedRules = checkElementRules(parsed.data, checkRule, path);
112
+ if (checkedRules.issues.length > 0) return { issues: checkedRules.issues };
113
+ const config = checkedRules.item;
114
+ const parsedReserved = reservedNameSegment(config);
115
+ if (parsedReserved) {
116
+ return fail(
117
+ `Field name '${String(config.name)}' uses the reserved segment '${parsedReserved}': a name cannot start with '${ENGINE_KEY_PREFIX}' or be one of __proto__, constructor and prototype.`,
118
+ ["name"]
119
+ );
120
+ }
121
+ const placementIssue = namedPlacementIssue(config);
122
+ if (placementIssue) return fail(placementIssue.message, placementIssue.path);
123
+ const areaIssue = areaPlacementIssue(config, nested);
124
+ if (areaIssue) return fail(areaIssue.message, areaIssue.path);
125
+ const elementAppearance = resolveAppearance(authoredAppearance, appearance, {
126
+ subject: `Element '${item.$type}'`,
127
+ path,
128
+ supported: getElement(item.$type)?.appearanceAxes ?? []
129
+ });
130
+ const issues = elementAppearance.issues;
131
+ const resolved = withAppearance(config, elementAppearance.selection);
132
+ const children = getElementChildren(config);
133
+ if (!children) {
134
+ return issues.length > 0 ? { issues } : { issues: [], item: resolved };
135
+ }
136
+ const nextChildren = [];
137
+ const childScope = elementAppearance.childScope;
138
+ for (let index = 0; index < children.length; index += 1) {
139
+ const parsedChild = parseElementNode(
140
+ children[index],
141
+ getElement,
142
+ checkRule,
143
+ childPath(path, index),
144
+ childScope,
145
+ true
146
+ );
147
+ issues.push(...parsedChild.issues);
148
+ if (parsedChild.item) nextChildren.push(parsedChild.item);
149
+ }
150
+ if (issues.length > 0) {
151
+ return { issues };
152
+ }
153
+ return { issues: [], item: withElementChildren(resolved, nextChildren) };
154
+ }
155
+ function parseElementList(items, getElement, checkRule, parentPath, appearance) {
156
+ if (!items) return { issues: [], byIndex: [] };
157
+ const next = [];
158
+ const byIndex = [];
159
+ const issues = [];
160
+ for (let index = 0; index < items.length; index += 1) {
161
+ const parsed = parseElementNode(items[index], getElement, checkRule, childPath(parentPath, index), appearance);
162
+ issues.push(...parsed.issues);
163
+ byIndex.push(parsed.item);
164
+ if (parsed.item) next.push(parsed.item);
165
+ }
166
+ return { issues, items: next, byIndex };
167
+ }
168
+ function brandElementTree(config, getElement) {
169
+ const children = getElementChildren(config);
170
+ const next = children ? withElementChildren(
171
+ config,
172
+ children.map((child) => brandElementTree(child, getElement))
173
+ ) : config;
174
+ return markNormalizedElementConfig(next, containerKindOf(getElement(config.$type)));
175
+ }
176
+
177
+ export {
178
+ parseTypedConfig,
179
+ parseElementNode,
180
+ parseElementList,
181
+ brandElementTree
182
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lib/validate-form/parse-elements.ts"],
4
+ "sourcesContent": ["import type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { FormTaggedConfig } from '@/schemas/form-config';\nimport type { ElementConfig } from '@/schemas/field-config';\nimport { safeParseStandardSchema } from '@schema-engine/registry';\nimport { markNormalizedElementConfig, type NormalizedElementConfig } from '@/lib/normalized-form-config';\nimport { getElementChildren, withElementChildren } from '@/lib/element-children';\nimport { resolveAppearance, withAppearance, type AppearanceScope } from '@/lib/resolve-appearance';\nimport { areaPlacementIssue, namedPlacementIssue } from './grid-checks';\nimport { childPath, isTaggedConfig, issueAt, type FormValidationIssue, type ParseResult, type Path } from './issues';\nimport type { ValidateFormOptions } from './options';\nimport { fromSchemaIssues } from './schema-issues';\nimport { containerKindOf } from '@/lib/container-kind-of';\nimport { ENGINE_KEY_PREFIX, isReservedPathKey } from '@/lib/reserved-path-keys';\n\nfunction parseRegistration(schema: StandardSchemaV1, config: object, path: Path): ParseResult<unknown> {\n\tconst result = safeParseStandardSchema(schema, config);\n\tif (!result.success) {\n\t\treturn { ok: false, issues: fromSchemaIssues(result.error.issues, path) };\n\t}\n\treturn { ok: true, data: result.data };\n}\n\nexport function parseTypedConfig(\n\titem: FormTaggedConfig,\n\tgetRegistration: (id: string) => { schema: StandardSchemaV1 } | undefined,\n\tregisterHint: string,\n\tpath: Path,\n): ParseResult<FormTaggedConfig> {\n\tconst registration = getRegistration(item.$type);\n\tif (!registration) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\tissues: [\n\t\t\t\tissueAt([...path, '$type'], `Unknown element type '${item.$type}'. Register it with ${registerHint}.`),\n\t\t\t],\n\t\t};\n\t}\n\n\tconst parsed = parseRegistration(registration.schema, item, path);\n\tif (!parsed.ok) return parsed;\n\tif (!isTaggedConfig(parsed.data)) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\tissues: [\n\t\t\t\tissueAt(\n\t\t\t\t\t[...path, '$type'],\n\t\t\t\t\t`Invalid element configuration for '${item.$type}': parsed output is missing $type.`,\n\t\t\t\t),\n\t\t\t],\n\t\t};\n\t}\n\treturn { ok: true, data: parsed.data };\n}\n\n/**\n * Holds each rule of an element to its registration, and replaces it with the rule as the registration parses it.\n *\n * @remarks\n * The element's own schema accepts a rule of any `$type`, so this is where a rule is held to the\n * registry. Every rule is checked, so a form with two bad rules reports both. An issue keeps the path\n * the registry gave it, laid under the rule: a refused option is at its key, a type nothing registers or\n * a handler that throws is at the rule's `$type`.\n */\nfunction checkElementRules(\n\titem: FormTaggedConfig,\n\tcheckRule: ValidateFormOptions['checkRule'],\n\tpath: Path,\n): { issues: FormValidationIssue[]; item: FormTaggedConfig } {\n\tif (!Array.isArray(item.rules)) return { issues: [], item };\n\n\tconst issues: FormValidationIssue[] = [];\n\tconst rules: unknown[] = [];\n\tfor (const [index, rule] of item.rules.entries()) {\n\t\tif (typeof rule !== 'object' || rule === null || !('$type' in rule) || typeof rule.$type !== 'string') {\n\t\t\trules.push(rule);\n\t\t\tcontinue;\n\t\t}\n\t\tconst checked = checkRule(rule as { $type: string });\n\t\tif (checked.ok) {\n\t\t\trules.push(checked.rule);\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const issue of checked.issues) {\n\t\t\tissues.push({ ...issue, path: [...path, 'rules', index, ...issue.path] });\n\t\t}\n\t}\n\treturn { issues, item: { ...item, rules } };\n}\n\n/** The first segment of an element's name that the engine reserves. */\nfunction reservedNameSegment(item: FormTaggedConfig): string | undefined {\n\treturn typeof item.name === 'string' ? item.name.split('.').find(isReservedPathKey) : undefined;\n}\n\nexport function parseElementNode(\n\titem: unknown,\n\tgetElement: ValidateFormOptions['getElement'],\n\tcheckRule: ValidateFormOptions['checkRule'],\n\tpath: Path,\n\tappearance: AppearanceScope,\n\tnested = false,\n): { issues: FormValidationIssue[]; item?: FormTaggedConfig } {\n\tconst fail = (message: string, relative: Path = []) => ({ issues: [issueAt([...path, ...relative], message)] });\n\n\tif (!isTaggedConfig(item)) {\n\t\treturn fail('Invalid element configuration: missing $type.', ['$type']);\n\t}\n\tconst reserved = reservedNameSegment(item);\n\tif (reserved) {\n\t\treturn fail(\n\t\t\t`Field name '${String(item.name)}' uses the reserved segment '${reserved}': a name cannot start with '${ENGINE_KEY_PREFIX}' or be one of __proto__, constructor and prototype.`,\n\t\t\t['name'],\n\t\t);\n\t}\n\tconst { appearance: authoredAppearance, ...authored } = item;\n\tconst parsed = parseTypedConfig(\n\t\tauthored as FormTaggedConfig,\n\t\tgetElement,\n\t\t'createFormEngine({ elements: [...] })',\n\t\tpath,\n\t);\n\tif (!parsed.ok) {\n\t\treturn { issues: parsed.issues };\n\t}\n\tconst checkedRules = checkElementRules(parsed.data, checkRule, path);\n\tif (checkedRules.issues.length > 0) return { issues: checkedRules.issues };\n\tconst config = checkedRules.item;\n\tconst parsedReserved = reservedNameSegment(config);\n\tif (parsedReserved) {\n\t\treturn fail(\n\t\t\t`Field name '${String(config.name)}' uses the reserved segment '${parsedReserved}': a name cannot start with '${ENGINE_KEY_PREFIX}' or be one of __proto__, constructor and prototype.`,\n\t\t\t['name'],\n\t\t);\n\t}\n\tconst placementIssue = namedPlacementIssue(config);\n\tif (placementIssue) return fail(placementIssue.message, placementIssue.path);\n\tconst areaIssue = areaPlacementIssue(config, nested);\n\tif (areaIssue) return fail(areaIssue.message, areaIssue.path);\n\n\tconst elementAppearance = resolveAppearance(authoredAppearance, appearance, {\n\t\tsubject: `Element '${item.$type}'`,\n\t\tpath,\n\t\tsupported: getElement(item.$type)?.appearanceAxes ?? [],\n\t});\n\tconst issues = elementAppearance.issues;\n\tconst resolved = withAppearance(config, elementAppearance.selection);\n\n\tconst children = getElementChildren(config);\n\tif (!children) {\n\t\treturn issues.length > 0 ? { issues } : { issues: [], item: resolved };\n\t}\n\n\tconst nextChildren: FormTaggedConfig[] = [];\n\tconst childScope = elementAppearance.childScope;\n\tfor (let index = 0; index < children.length; index += 1) {\n\t\tconst parsedChild = parseElementNode(\n\t\t\tchildren[index],\n\t\t\tgetElement,\n\t\t\tcheckRule,\n\t\t\tchildPath(path, index),\n\t\t\tchildScope,\n\t\t\ttrue,\n\t\t);\n\t\tissues.push(...parsedChild.issues);\n\t\tif (parsedChild.item) nextChildren.push(parsedChild.item);\n\t}\n\n\tif (issues.length > 0) {\n\t\treturn { issues };\n\t}\n\n\treturn { issues: [], item: withElementChildren(resolved, nextChildren) };\n}\n\n/**\n * Validates the elements of a step. `byIndex` keeps each element at the index it was authored at\n * (`undefined` where it failed), so later checks name the right path.\n */\nexport function parseElementList(\n\titems: unknown[] | undefined,\n\tgetElement: ValidateFormOptions['getElement'],\n\tcheckRule: ValidateFormOptions['checkRule'],\n\tparentPath: Path,\n\tappearance: AppearanceScope,\n): { issues: FormValidationIssue[]; items?: FormTaggedConfig[]; byIndex: Array<FormTaggedConfig | undefined> } {\n\tif (!items) return { issues: [], byIndex: [] };\n\n\tconst next: FormTaggedConfig[] = [];\n\tconst byIndex: Array<FormTaggedConfig | undefined> = [];\n\tconst issues: FormValidationIssue[] = [];\n\tfor (let index = 0; index < items.length; index += 1) {\n\t\tconst parsed = parseElementNode(items[index], getElement, checkRule, childPath(parentPath, index), appearance);\n\t\tissues.push(...parsed.issues);\n\t\tbyIndex.push(parsed.item);\n\t\tif (parsed.item) next.push(parsed.item);\n\t}\n\treturn { issues, items: next, byIndex };\n}\n\nexport function brandElementTree(\n\tconfig: FormTaggedConfig,\n\tgetElement: ValidateFormOptions['getElement'],\n): NormalizedElementConfig {\n\tconst children = getElementChildren(config);\n\tconst next = children\n\t\t? withElementChildren(\n\t\t\t\tconfig,\n\t\t\t\tchildren.map((child) => brandElementTree(child as FormTaggedConfig, getElement)),\n\t\t\t)\n\t\t: config;\n\treturn markNormalizedElementConfig(next as unknown as ElementConfig, containerKindOf(getElement(config.$type)));\n}\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }
@@ -0,0 +1,16 @@
1
+ // src/types/categories.ts
2
+ var ElementCategory = {
3
+ INPUT: "input",
4
+ CONTENT: "content",
5
+ ACTION: "action",
6
+ DECORATION: "decoration",
7
+ INTERACTIVE: "interactive"
8
+ };
9
+ function isElementCategory(value) {
10
+ return typeof value === "string" && Object.values(ElementCategory).includes(value);
11
+ }
12
+
13
+ export {
14
+ ElementCategory,
15
+ isElementCategory
16
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/types/categories.ts"],
4
+ "sourcesContent": ["/**\n * Element categories define the semantic type and behavior of form elements.\n *\n * These categories are used to:\n * - Organize elements in form builders\n * - Apply category-specific validation rules\n * - Filter and search elements by type\n * - Determine if 'name' field is required (only 'input' category)\n */\nexport const ElementCategory = {\n\tINPUT: 'input',\n\tCONTENT: 'content',\n\tACTION: 'action',\n\tDECORATION: 'decoration',\n\tINTERACTIVE: 'interactive',\n} as const;\n\nexport type ElementCategory = (typeof ElementCategory)[keyof typeof ElementCategory];\n\n/**\n * Type guard to check if a value is a valid ElementCategory\n */\nexport function isElementCategory(value: unknown): value is ElementCategory {\n\treturn typeof value === 'string' && Object.values(ElementCategory).includes(value as ElementCategory);\n}\n"],
5
+ "mappings": ";AASO,IAAM,kBAAkB;AAAA,EAC9B,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,aAAa;AACd;AAOO,SAAS,kBAAkB,OAA0C;AAC3E,SAAO,OAAO,UAAU,YAAY,OAAO,OAAO,eAAe,EAAE,SAAS,KAAwB;AACrG;",
6
+ "names": []
7
+ }
@@ -0,0 +1,82 @@
1
+ import {
2
+ RelateRuleSchema
3
+ } from "./chunk-KE53GN4Q.js";
4
+ import {
5
+ isEmpty
6
+ } from "./chunk-6NV2JDGI.js";
7
+
8
+ // src/schemas/validation/relations.ts
9
+ import * as z from "zod/mini";
10
+ function stringifyComparable(value) {
11
+ if (typeof value === "string") {
12
+ return value;
13
+ }
14
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
15
+ return `${value}`;
16
+ }
17
+ if (typeof value === "symbol") {
18
+ return `Symbol(${value.description ?? ""})`;
19
+ }
20
+ if (value instanceof Date) {
21
+ return Date.prototype.toString.call(value);
22
+ }
23
+ return void 0;
24
+ }
25
+ var RelationValueSchema = z.any();
26
+ function coerce(value, as) {
27
+ if (value === void 0 || value === null) {
28
+ return value;
29
+ }
30
+ switch (as) {
31
+ case "string":
32
+ return stringifyComparable(value) ?? value;
33
+ case "number":
34
+ return Number(value);
35
+ case "date":
36
+ return value instanceof Date ? value.getTime() : new Date(stringifyComparable(value) ?? "").getTime();
37
+ case "boolean":
38
+ return Boolean(value);
39
+ default:
40
+ return value;
41
+ }
42
+ }
43
+ var ASSERTIONS = {
44
+ allEqual: (values) => values.every((value) => Object.is(value, values[0])),
45
+ allDifferent: (values) => new Set(values.map((value) => JSON.stringify(value))).size === values.length,
46
+ ascending: (values) => values.every((value, index) => index === 0 || value >= values[index - 1]),
47
+ strictlyAscending: (values) => values.every((value, index) => index === 0 || value > values[index - 1]),
48
+ descending: (values) => values.every((value, index) => index === 0 || value <= values[index - 1]),
49
+ strictlyDescending: (values) => values.every((value, index) => index === 0 || value < values[index - 1]),
50
+ atLeastOne: (values) => values.some((value) => !isEmpty(value)),
51
+ exactlyOne: (values) => values.filter((value) => !isEmpty(value)).length === 1,
52
+ allOrNone: (values) => {
53
+ const filled = values.filter((value) => !isEmpty(value)).length;
54
+ return filled === 0 || filled === values.length;
55
+ }
56
+ };
57
+ var EMPTINESS_ASSERTIONS = /* @__PURE__ */ new Set(["atLeastOne", "exactlyOne", "allOrNone"]);
58
+ var relateValidation = {
59
+ $type: "relate",
60
+ schema: RelateRuleSchema,
61
+ metadata: {
62
+ name: "Relate",
63
+ description: "The value holds a named comparison with other fields, such as ascending dates or at least one filled."
64
+ },
65
+ category: "cross-field",
66
+ dependsOn: (rule) => rule.fields,
67
+ params: (rule) => ({ assert: rule.assert }),
68
+ handler: (rule, context) => RelationValueSchema.check(
69
+ z.refine((value) => {
70
+ const referenced = rule.fields.map((fieldRef) => context.resolve(fieldRef));
71
+ const participating = rule.includeSelf ? [value, ...referenced] : referenced;
72
+ if (rule.skipWhenIncomplete && !EMPTINESS_ASSERTIONS.has(rule.assert) && participating.some(isEmpty)) {
73
+ return true;
74
+ }
75
+ return ASSERTIONS[rule.assert](participating.map((entry) => coerce(entry, rule.as)));
76
+ }, rule.message)
77
+ )
78
+ };
79
+
80
+ export {
81
+ relateValidation
82
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/schemas/validation/relations.ts"],
4
+ "sourcesContent": ["import * as z from 'zod/mini';\nimport { RelateRuleSchema } from './types.js';\nimport type { RelateRule, RelationAssert, ValidationRegistration } from './types.js';\nimport { isEmpty } from './empty.js';\n\nfunction stringifyComparable(value: unknown): string | undefined {\n\tif (typeof value === 'string') {\n\t\treturn value;\n\t}\n\n\tif (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {\n\t\treturn `${value}`;\n\t}\n\n\tif (typeof value === 'symbol') {\n\t\treturn `Symbol(${value.description ?? ''})`;\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn Date.prototype.toString.call(value);\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Relation operands are values from registered fields.\n * @remarks Their concrete types are selected by the engine's element registrations.\n */\nconst RelationValueSchema = z.any();\n\n/**\n * Brings a referenced value onto the rule's comparison basis.\n *\n * @remarks\n * `auto` leaves values untouched, which is right when the fields share a control\n * type. `date` yields a timestamp, and an unparseable string yields `NaN`: every\n * comparison against `NaN` is false, so an ordering assertion fails rather than\n * passing by accident. `null` and `undefined` are left alone so the emptiness\n * checks below still see them.\n */\nfunction coerce(value: unknown, as: RelateRule['as']): unknown {\n\tif (value === undefined || value === null) {\n\t\treturn value;\n\t}\n\n\tswitch (as) {\n\t\tcase 'string':\n\t\t\treturn stringifyComparable(value) ?? value;\n\t\tcase 'number':\n\t\t\treturn Number(value);\n\t\tcase 'date':\n\t\t\treturn value instanceof Date ? value.getTime() : new Date(stringifyComparable(value) ?? '').getTime();\n\t\tcase 'boolean':\n\t\t\treturn Boolean(value);\n\t\tdefault:\n\t\t\treturn value;\n\t}\n}\n\nconst ASSERTIONS: Record<RelationAssert, (values: readonly unknown[]) => boolean> = {\n\tallEqual: (values) => values.every((value) => Object.is(value, values[0])),\n\tallDifferent: (values) => new Set(values.map((value) => JSON.stringify(value))).size === values.length,\n\tascending: (values) =>\n\t\tvalues.every((value, index) => index === 0 || (value as number) >= (values[index - 1] as number)),\n\tstrictlyAscending: (values) =>\n\t\tvalues.every((value, index) => index === 0 || (value as number) > (values[index - 1] as number)),\n\tdescending: (values) =>\n\t\tvalues.every((value, index) => index === 0 || (value as number) <= (values[index - 1] as number)),\n\tstrictlyDescending: (values) =>\n\t\tvalues.every((value, index) => index === 0 || (value as number) < (values[index - 1] as number)),\n\tatLeastOne: (values) => values.some((value) => !isEmpty(value)),\n\texactlyOne: (values) => values.filter((value) => !isEmpty(value)).length === 1,\n\tallOrNone: (values) => {\n\t\tconst filled = values.filter((value) => !isEmpty(value)).length;\n\t\treturn filled === 0 || filled === values.length;\n\t},\n};\n\n/**\n * Assertions whose whole job is to fire on a partly filled group.\n *\n * @remarks\n * `skipWhenIncomplete` would make these no-ops, so it does not apply to them.\n */\nconst EMPTINESS_ASSERTIONS = new Set<RelationAssert>(['atLeastOne', 'exactlyOne', 'allOrNone']);\n\n/**\n * One rule for every comparison between a field and its siblings.\n *\n * @remarks\n * Password confirmation, date ordering, \"one of these two\", and mutual exclusion\n * are the same operation with a different assertion, so they share one\n * registration rather than each getting a handler with its own emptiness and\n * reference-scoping semantics to keep in step. Authoring sugar belongs in\n * `relation-presets.ts`, which returns plain rule objects a CMS can round-trip.\n */\nexport const relateValidation: ValidationRegistration<RelateRule> = {\n\t$type: 'relate',\n\tschema: RelateRuleSchema,\n\tmetadata: {\n\t\tname: 'Relate',\n\t\tdescription:\n\t\t\t'The value holds a named comparison with other fields, such as ascending dates or at least one filled.',\n\t},\n\tcategory: 'cross-field',\n\tdependsOn: (rule) => rule.fields,\n\tparams: (rule) => ({ assert: rule.assert }),\n\thandler: (rule, context) =>\n\t\tRelationValueSchema.check(\n\t\t\tz.refine((value: unknown) => {\n\t\t\t\tconst referenced = rule.fields.map((fieldRef) => context.resolve(fieldRef));\n\t\t\t\tconst participating = rule.includeSelf ? [value, ...referenced] : referenced;\n\n\t\t\t\tif (rule.skipWhenIncomplete && !EMPTINESS_ASSERTIONS.has(rule.assert) && participating.some(isEmpty)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn ASSERTIONS[rule.assert](participating.map((entry) => coerce(entry, rule.as)));\n\t\t\t}, rule.message),\n\t\t),\n};\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }
@@ -0,0 +1,33 @@
1
+ // src/lib/debounce.ts
2
+ function createDebounceScope() {
3
+ const pending = /* @__PURE__ */ new Map();
4
+ return {
5
+ debounce(fn, delay, key, input) {
6
+ const existing = pending.get(key);
7
+ const outcome = new Promise((resolve, reject) => {
8
+ const timeout = setTimeout(async () => {
9
+ pending.delete(key);
10
+ try {
11
+ resolve({ status: "completed", value: await fn() });
12
+ } catch (error) {
13
+ reject(error);
14
+ }
15
+ }, delay);
16
+ pending.set(key, {
17
+ timeout,
18
+ input,
19
+ settle: (next) => resolve(next)
20
+ });
21
+ });
22
+ if (existing) {
23
+ clearTimeout(existing.timeout);
24
+ existing.settle(existing.input === input ? outcome : { status: "skipped" });
25
+ }
26
+ return outcome;
27
+ }
28
+ };
29
+ }
30
+
31
+ export {
32
+ createDebounceScope
33
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lib/debounce.ts"],
4
+ "sourcesContent": ["export type DebounceOutcome<T> = { status: 'completed'; value: T } | { status: 'skipped' };\n\nexport interface DebounceScope {\n\t/**\n\t * Runs `fn` after `delay` unless a later call with the same `key` replaces it.\n\t *\n\t * @remarks\n\t * A replaced call whose `input` equals the replacing call's settles with that\n\t * call's outcome, since the same work is still running. Any other replaced call\n\t * resolves `skipped` at once.\n\t */\n\tdebounce<T>(fn: () => Promise<T> | T, delay: number, key: string, input: string): Promise<DebounceOutcome<T>>;\n}\n\n/**\n * @remarks\n * `settle` takes `unknown` results because one map holds calls of every result\n * type; a key is reused only by calls of the same type, so the replaced call\n * narrows the outcome back to its own.\n */\ninterface PendingDebounce {\n\ttimeout: ReturnType<typeof setTimeout>;\n\tinput: string;\n\tsettle: (outcome: DebounceOutcome<unknown> | Promise<DebounceOutcome<unknown>>) => void;\n}\n\n/** Creates keyed debounce state private to its owner. */\nexport function createDebounceScope(): DebounceScope {\n\tconst pending = new Map<string, PendingDebounce>();\n\n\treturn {\n\t\tdebounce<T>(fn: () => Promise<T> | T, delay: number, key: string, input: string): Promise<DebounceOutcome<T>> {\n\t\t\tconst existing = pending.get(key);\n\t\t\tconst outcome = new Promise<DebounceOutcome<T>>((resolve, reject) => {\n\t\t\t\tconst timeout = setTimeout(async () => {\n\t\t\t\t\tpending.delete(key);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresolve({ status: 'completed', value: await fn() });\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t}\n\t\t\t\t}, delay);\n\n\t\t\t\tpending.set(key, {\n\t\t\t\t\ttimeout,\n\t\t\t\t\tinput,\n\t\t\t\t\tsettle: (next) => resolve(next as DebounceOutcome<T> | Promise<DebounceOutcome<T>>),\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tif (existing) {\n\t\t\t\tclearTimeout(existing.timeout);\n\t\t\t\texisting.settle(existing.input === input ? outcome : { status: 'skipped' });\n\t\t\t}\n\n\t\t\treturn outcome;\n\t\t},\n\t};\n}\n"],
5
+ "mappings": ";AA2BO,SAAS,sBAAqC;AACpD,QAAM,UAAU,oBAAI,IAA6B;AAEjD,SAAO;AAAA,IACN,SAAY,IAA0B,OAAe,KAAa,OAA4C;AAC7G,YAAM,WAAW,QAAQ,IAAI,GAAG;AAChC,YAAM,UAAU,IAAI,QAA4B,CAAC,SAAS,WAAW;AACpE,cAAM,UAAU,WAAW,YAAY;AACtC,kBAAQ,OAAO,GAAG;AAClB,cAAI;AACH,oBAAQ,EAAE,QAAQ,aAAa,OAAO,MAAM,GAAG,EAAE,CAAC;AAAA,UACnD,SAAS,OAAO;AACf,mBAAO,KAAK;AAAA,UACb;AAAA,QACD,GAAG,KAAK;AAER,gBAAQ,IAAI,KAAK;AAAA,UAChB;AAAA,UACA;AAAA,UACA,QAAQ,CAAC,SAAS,QAAQ,IAAwD;AAAA,QACnF,CAAC;AAAA,MACF,CAAC;AAED,UAAI,UAAU;AACb,qBAAa,SAAS,OAAO;AAC7B,iBAAS,OAAO,SAAS,UAAU,QAAQ,UAAU,EAAE,QAAQ,UAAU,CAAC;AAAA,MAC3E;AAEA,aAAO;AAAA,IACR;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,28 @@
1
+ // src/lib/form-fetch.ts
2
+ var globalFetch = (input, init) => globalThis.fetch(input, init);
3
+ var UNSAFE_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
4
+ function isSameOrigin(input) {
5
+ if (typeof location === "undefined") return false;
6
+ try {
7
+ const own = new URL(location.href).origin;
8
+ const base = typeof document === "undefined" || !document.baseURI ? location.href : document.baseURI;
9
+ return own !== "null" && new URL(input, base).origin === own;
10
+ } catch {
11
+ return false;
12
+ }
13
+ }
14
+ function withCsrf(base, policy) {
15
+ return (input, init) => {
16
+ const token = UNSAFE_METHODS.has((init?.method ?? "GET").toUpperCase()) ? policy.token() : void 0;
17
+ if (!token || !isSameOrigin(input)) return base(input, init);
18
+ const headers = new Headers(init?.headers);
19
+ headers.set(policy.header, token);
20
+ return base(input, { ...init, headers });
21
+ };
22
+ }
23
+
24
+ export {
25
+ globalFetch,
26
+ isSameOrigin,
27
+ withCsrf
28
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lib/form-fetch.ts"],
4
+ "sourcesContent": ["/**\n * The request function every request of a form goes through: the engine's `fetch`.\n *\n * @remarks Takes a URL as a string or a `URL`, which the global `fetch` and the engine's both accept.\n */\nexport type FormFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;\n\n/**\n * Where a CSRF token comes from and where it goes.\n *\n * @remarks\n * `token` is read at request time and never stored, so a rotated token is picked up, and `undefined` means there\n * is none to send. `header` carries it on a same-origin unsafe request; `field` is the name of the hidden input a\n * native post carries it in, for a binding to add.\n */\nexport interface CsrfPolicy {\n\ttoken(): string | undefined;\n\treadonly header: string;\n\treadonly field?: string;\n}\n\n/** The global `fetch`, looked up at each call so a replaced global is honoured. */\nexport const globalFetch: FormFetch = (input, init) => globalThis.fetch(input, init);\n\nconst UNSAFE_METHODS: ReadonlySet<string> = new Set(['POST', 'PUT', 'PATCH', 'DELETE']);\n\n/**\n * Whether `input` is a URL of the page's own origin. Without a page location nothing can be shown to be, so nothing is.\n *\n * @remarks A relative URL is resolved against the document's base URL (`<base href>` included), as the browser resolves it for the request.\n */\nexport function isSameOrigin(input: string | URL): boolean {\n\tif (typeof location === 'undefined') return false;\n\ttry {\n\t\tconst own = new URL(location.href).origin;\n\t\tconst base = typeof document === 'undefined' || !document.baseURI ? location.href : document.baseURI;\n\t\treturn own !== 'null' && new URL(input, base).origin === own;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * `base` with the policy's token added as a header.\n *\n * @remarks\n * Only to a same-origin request with an unsafe method (`POST`, `PUT`, `PATCH`, `DELETE`), and only while the policy\n * has a token: a cross-origin request never carries it, and a missing token sends no header. A header the caller\n * set under the same name is replaced.\n */\nexport function withCsrf(base: FormFetch, policy: CsrfPolicy): FormFetch {\n\treturn (input, init) => {\n\t\tconst token = UNSAFE_METHODS.has((init?.method ?? 'GET').toUpperCase()) ? policy.token() : undefined;\n\t\tif (!token || !isSameOrigin(input)) return base(input, init);\n\t\tconst headers = new Headers(init?.headers);\n\t\theaders.set(policy.header, token);\n\t\treturn base(input, { ...init, headers });\n\t};\n}\n"],
5
+ "mappings": ";AAsBO,IAAM,cAAyB,CAAC,OAAO,SAAS,WAAW,MAAM,OAAO,IAAI;AAEnF,IAAM,iBAAsC,oBAAI,IAAI,CAAC,QAAQ,OAAO,SAAS,QAAQ,CAAC;AAO/E,SAAS,aAAa,OAA8B;AAC1D,MAAI,OAAO,aAAa,YAAa,QAAO;AAC5C,MAAI;AACH,UAAM,MAAM,IAAI,IAAI,SAAS,IAAI,EAAE;AACnC,UAAM,OAAO,OAAO,aAAa,eAAe,CAAC,SAAS,UAAU,SAAS,OAAO,SAAS;AAC7F,WAAO,QAAQ,UAAU,IAAI,IAAI,OAAO,IAAI,EAAE,WAAW;AAAA,EAC1D,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAUO,SAAS,SAAS,MAAiB,QAA+B;AACxE,SAAO,CAAC,OAAO,SAAS;AACvB,UAAM,QAAQ,eAAe,KAAK,MAAM,UAAU,OAAO,YAAY,CAAC,IAAI,OAAO,MAAM,IAAI;AAC3F,QAAI,CAAC,SAAS,CAAC,aAAa,KAAK,EAAG,QAAO,KAAK,OAAO,IAAI;AAC3D,UAAM,UAAU,IAAI,QAAQ,MAAM,OAAO;AACzC,YAAQ,IAAI,OAAO,QAAQ,KAAK;AAChC,WAAO,KAAK,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC;AAAA,EACxC;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,56 @@
1
+ // src/engine/schema-metadata-catalog.ts
2
+ var SchemaMetadataCatalog = class _SchemaMetadataCatalog {
3
+ entries = /* @__PURE__ */ new Map();
4
+ schemasById = /* @__PURE__ */ new Map();
5
+ idBySchema = /* @__PURE__ */ new WeakMap();
6
+ /** Catalog and JSON Schema id of a registration, such as `element:text`. */
7
+ static entryId(componentType, $type) {
8
+ return `${componentType}:${$type}`;
9
+ }
10
+ /**
11
+ * Associate a validator schema with catalog metadata.
12
+ */
13
+ register(schema, entry) {
14
+ const previousSchema = this.schemasById.get(entry.id);
15
+ if (previousSchema && previousSchema !== schema) {
16
+ this.idBySchema.delete(previousSchema);
17
+ }
18
+ this.entries.set(entry.id, entry);
19
+ this.schemasById.set(entry.id, schema);
20
+ this.idBySchema.set(schema, entry.id);
21
+ }
22
+ /** Create an independent catalog with the same schema and metadata entries. */
23
+ clone() {
24
+ const catalog = new _SchemaMetadataCatalog();
25
+ for (const { schema, entry } of this.getRegisteredSchemas()) {
26
+ catalog.register(schema, entry);
27
+ }
28
+ return catalog;
29
+ }
30
+ get(id) {
31
+ return this.entries.get(id);
32
+ }
33
+ getBySchema(schema) {
34
+ const id = this.idBySchema.get(schema);
35
+ return id ? this.entries.get(id) : void 0;
36
+ }
37
+ getAll() {
38
+ return Array.from(this.entries.values());
39
+ }
40
+ has(schema) {
41
+ return this.idBySchema.has(schema);
42
+ }
43
+ /**
44
+ * All registered schema/metadata pairs for adapters (e.g. z.registry bridge).
45
+ */
46
+ getRegisteredSchemas() {
47
+ return Array.from(this.schemasById.entries()).map(([id, schema]) => ({
48
+ schema,
49
+ entry: this.entries.get(id)
50
+ }));
51
+ }
52
+ };
53
+
54
+ export {
55
+ SchemaMetadataCatalog
56
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/engine/schema-metadata-catalog.ts"],
4
+ "sourcesContent": ["import type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { ComponentType } from './component-type';\n\n/**\n * Metadata entry for a registered component schema.\n * Used by JSON Schema collection and tooling without coupling to Zod's registry.\n */\nexport interface SchemaMetadataEntry {\n\tid: string;\n\ttitle: string;\n\tdescription?: string;\n\tcomponentType: ComponentType;\n\tcategory?: string;\n}\n\n/**\n * Catalog of schema metadata keyed by stable component ids (e.g. `element:text`).\n * Replaces direct use of `z.registry()` for metadata storage in engine construction.\n */\nexport class SchemaMetadataCatalog {\n\tprivate entries = new Map<string, SchemaMetadataEntry>();\n\tprivate schemasById = new Map<string, StandardSchemaV1>();\n\tprivate idBySchema = new WeakMap<object, string>();\n\n\t/** Catalog and JSON Schema id of a registration, such as `element:text`. */\n\tstatic entryId(componentType: ComponentType, $type: string): string {\n\t\treturn `${componentType}:${$type}`;\n\t}\n\n\t/**\n\t * Associate a validator schema with catalog metadata.\n\t */\n\tregister(schema: StandardSchemaV1, entry: SchemaMetadataEntry): void {\n\t\tconst previousSchema = this.schemasById.get(entry.id);\n\t\tif (previousSchema && previousSchema !== schema) {\n\t\t\tthis.idBySchema.delete(previousSchema);\n\t\t}\n\t\tthis.entries.set(entry.id, entry);\n\t\tthis.schemasById.set(entry.id, schema);\n\t\tthis.idBySchema.set(schema, entry.id);\n\t}\n\n\t/** Create an independent catalog with the same schema and metadata entries. */\n\tclone(): SchemaMetadataCatalog {\n\t\tconst catalog = new SchemaMetadataCatalog();\n\t\tfor (const { schema, entry } of this.getRegisteredSchemas()) {\n\t\t\tcatalog.register(schema, entry);\n\t\t}\n\t\treturn catalog;\n\t}\n\n\tget(id: string): SchemaMetadataEntry | undefined {\n\t\treturn this.entries.get(id);\n\t}\n\n\tgetBySchema(schema: StandardSchemaV1): SchemaMetadataEntry | undefined {\n\t\tconst id = this.idBySchema.get(schema);\n\t\treturn id ? this.entries.get(id) : undefined;\n\t}\n\n\tgetAll(): SchemaMetadataEntry[] {\n\t\treturn Array.from(this.entries.values());\n\t}\n\n\thas(schema: StandardSchemaV1): boolean {\n\t\treturn this.idBySchema.has(schema);\n\t}\n\n\t/**\n\t * All registered schema/metadata pairs for adapters (e.g. z.registry bridge).\n\t */\n\tgetRegisteredSchemas(): Array<{ schema: StandardSchemaV1; entry: SchemaMetadataEntry }> {\n\t\treturn Array.from(this.schemasById.entries()).map(([id, schema]) => ({\n\t\t\tschema,\n\t\t\tentry: this.entries.get(id)!,\n\t\t}));\n\t}\n}\n"],
5
+ "mappings": ";AAmBO,IAAM,wBAAN,MAAM,uBAAsB;AAAA,EAC1B,UAAU,oBAAI,IAAiC;AAAA,EAC/C,cAAc,oBAAI,IAA8B;AAAA,EAChD,aAAa,oBAAI,QAAwB;AAAA;AAAA,EAGjD,OAAO,QAAQ,eAA8B,OAAuB;AACnE,WAAO,GAAG,aAAa,IAAI,KAAK;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,SAAS,QAA0B,OAAkC;AACpE,UAAM,iBAAiB,KAAK,YAAY,IAAI,MAAM,EAAE;AACpD,QAAI,kBAAkB,mBAAmB,QAAQ;AAChD,WAAK,WAAW,OAAO,cAAc;AAAA,IACtC;AACA,SAAK,QAAQ,IAAI,MAAM,IAAI,KAAK;AAChC,SAAK,YAAY,IAAI,MAAM,IAAI,MAAM;AACrC,SAAK,WAAW,IAAI,QAAQ,MAAM,EAAE;AAAA,EACrC;AAAA;AAAA,EAGA,QAA+B;AAC9B,UAAM,UAAU,IAAI,uBAAsB;AAC1C,eAAW,EAAE,QAAQ,MAAM,KAAK,KAAK,qBAAqB,GAAG;AAC5D,cAAQ,SAAS,QAAQ,KAAK;AAAA,IAC/B;AACA,WAAO;AAAA,EACR;AAAA,EAEA,IAAI,IAA6C;AAChD,WAAO,KAAK,QAAQ,IAAI,EAAE;AAAA,EAC3B;AAAA,EAEA,YAAY,QAA2D;AACtE,UAAM,KAAK,KAAK,WAAW,IAAI,MAAM;AACrC,WAAO,KAAK,KAAK,QAAQ,IAAI,EAAE,IAAI;AAAA,EACpC;AAAA,EAEA,SAAgC;AAC/B,WAAO,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC;AAAA,EACxC;AAAA,EAEA,IAAI,QAAmC;AACtC,WAAO,KAAK,WAAW,IAAI,MAAM;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA,EAKA,uBAAwF;AACvF,WAAO,MAAM,KAAK,KAAK,YAAY,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,MAAM,OAAO;AAAA,MACpE;AAAA,MACA,OAAO,KAAK,QAAQ,IAAI,EAAE;AAAA,IAC3B,EAAE;AAAA,EACH;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,6 @@
1
+ // src/state-container/types.ts
2
+ var FORM_ROOT = "__root__";
3
+
4
+ export {
5
+ FORM_ROOT
6
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/state-container/types.ts"],
4
+ "sourcesContent": ["import type { FieldParticipation, ValidationStep } from '@/engine/value-validation';\nimport type { ValidationRegistry } from '@/schemas/validation/validation-registry';\nimport type { FieldArrayCommands } from './field-array';\n\n/**\n * The internal form state contract: what a form's state container owns, and what it leaves to others.\n *\n * @remarks\n * The container owns the nested value tree, field state (errors, touched, dirty), field-array row ids and\n * the atomic updates that keep them consistent. A path is a plain dotted path with the row index in it\n * (`contacts.1.email`) wherever the API takes one, and {@link FORM_ROOT} names the form itself. It holds\n * no submission state (`isSubmitting`, `submitCount`, a submit guard): the runtime owns those. Focus,\n * native controls and native submit belong to the host, and there is no control registration: a host\n * bridges a control into the container with {@link FormStateContainer.setValue} and\n * {@link FormStateContainer.blur}, reports the control's native validity with\n * {@link FormStateContainer.reportNative}, and submits with {@link FormStateContainer.submit}, whose result\n * carries the way to hand back the server's answer.\n *\n * The container is named for what it holds, not `FormStore`, which is a class of Radiant UI. The contract is\n * public through `@schema-engine/forms/state-container`, with `@schema-engine/forms/csrf` and\n * `@schema-engine/forms/server-errors` beside it. Its conformance suite is `formStateContainerConformance` from\n * `@schema-engine/forms/testing`, which takes the `describe` and `test` of any test runner.\n */\n\n/**\n * The key of an error about the form itself rather than a field, in `snapshot.errors` and in `setServerErrors`.\n *\n * @remarks Path segments that start with `__` are reserved, so no field can have this name.\n */\nexport const FORM_ROOT = '__root__';\n\n/**\n * When a field validates before a check of it has failed: on `change`, on `blur`, on both (`all`), on the\n * first `blur` and on every change after it (`onTouched`, as React Hook Form's mode of that name) or only on\n * an explicit {@link FormStateContainer.validate}.\n */\nexport type FormValidationMode = 'onSubmit' | 'onChange' | 'onBlur' | 'onTouched' | 'all';\n\n/** When a field validates once a {@link FormStateContainer.validate} over it has failed. */\nexport type FormReValidateMode = 'onSubmit' | 'onChange' | 'onBlur';\n\n/** Who reported an issue. */\nexport type FormStateSource = 'server' | 'validation' | 'native';\n\n/**\n * One thing wrong with a path, who said so, and what a translation needs to say it.\n *\n * @remarks\n * `type` names the problem for a program: the rule's type (`'minLength'`), the `ValidityState` flag of a\n * native control (`'typeMismatch'`) or the server's code. `ruleId` is the author's stable name for the\n * rule, so two `pattern` rules stay distinguishable. `params` are the numbers and names the text is\n * built from, serializable (`{ minLength: 8 }` for a rule, `{ minLength: 8 }` for a native control).\n * `message` is only the text the author wrote on the rule, or the server or control sent, for a host with no\n * translation of the issue, and may be absent. Text the schema library would make up is never used.\n */\nexport interface FormStateIssue {\n\treadonly type: string;\n\treadonly source: FormStateSource;\n\treadonly ruleId?: string;\n\treadonly params?: Readonly<Record<string, unknown>>;\n\treadonly message?: string;\n}\n\n/**\n * The error of a path: the issue to show, and every issue the path has.\n *\n * @remarks\n * The fields of the issue are those of `all[0]`, so the error reads like a single issue, and `all` is\n * never empty. `all` lists, in this order, what the server said, then each rule the value fails in\n * authored order (never the order the checks finished in), then what the platform's own control reports.\n * The same error object comes back while none of that changes.\n */\nexport interface FormStateError extends FormStateIssue {\n\treadonly all: readonly FormStateIssue[];\n}\n\n/**\n * Advice about a path: shaped and timed exactly like an error, and never blocking.\n *\n * @remarks\n * It comes from rules declared with `severity: 'warning'`, so its issues have the source `'validation'`.\n * It never affects `isValid`, `validate` or `checkValidity`. A server cannot send warnings yet.\n */\nexport type FormStateWarning = FormStateError;\n\n/**\n * Why a submission as a whole failed, in the shape of an issue, so a host words it with the one formatter.\n *\n * @remarks\n * It is not a {@link FormStateIssue}: a submission failure (the action that threw, the callback that\n * rejected, the service that was down) concerns no field and the snapshot never holds one. `type` names the\n * failure for a program, `params` fill the text, and `message` is only the text the failure itself carried.\n */\nexport interface FormSubmissionIssue {\n\treadonly type: string;\n\treadonly source: 'submission';\n\treadonly params?: Readonly<Record<string, unknown>>;\n\treadonly message?: string;\n}\n\n/**\n * Turns an issue into the text to show, for the field at `field.path`.\n *\n * @remarks\n * The one seam between the engine, which reports what is wrong (`type`, `ruleId`, `params`), and the text\n * of the application's language, which the engine does not own. A binding takes one from its host and\n * calls it for the issue to show (an error or warning is itself an issue) and for each of `all` it lists,\n * falling back to `issue.message` when the host gives none or the formatter returns nothing worth showing.\n * `ruleId` picks a text of one rule, `type` a text of a kind of rule, and `params` fill its numbers. The\n * action context and the bindings use this same issue type, so one formatter serves them all. A\n * {@link FormSubmissionIssue} goes through it too, with the path of the form ({@link FORM_ROOT}).\n */\nexport type FormIssueFormatter = (\n\tissue: FormStateIssue | FormSubmissionIssue,\n\tfield: { readonly path: string },\n) => string;\n\n/**\n * An issue as a caller of `setServerErrors` may give it.\n *\n * @remarks\n * Every part is optional, as a server response may carry only a code or only a message. A missing `type`\n * is kept as `'server'`. An issue with nothing but a type still counts as an error: it blocks\n * {@link FormStateContainer.validate}.\n */\nexport interface FormStateErrorInput {\n\treadonly type?: string;\n\treadonly params?: Readonly<Record<string, unknown>>;\n\treadonly message?: string;\n}\n\n/** What `setServerErrors` takes: one issue or a list of them for each path. */\nexport type FormStateErrorsInput = Readonly<Record<string, FormStateErrorInput | readonly FormStateErrorInput[]>>;\n\n/**\n * What a platform control reports about its value.\n *\n * @remarks\n * `type` is the `ValidityState` flag (`'valueMissing'`, `'typeMismatch'`, `'tooShort'`), `params` the\n * constraint behind it that a text needs (`{ minLength: 8 }`, `{ pattern: '[0-9]+' }`), `message` the\n * control's own text, a fallback only.\n */\nexport interface NativeValidity {\n\treadonly type: string;\n\treadonly params?: Readonly<Record<string, unknown>>;\n\treadonly message?: string;\n}\n\n/**\n * How a check of the form ended, and what the host may do next.\n *\n * @remarks\n * `'passed'`: the scope was current and no error from any source remains at the paths that take part.\n * `'invalid'`: the scope was current and an error blocks. `'overtaken'`: an edit, a row move or a reset outran the\n * check, and the retry over the same rows was outrun too or the rows are gone, so there is no verdict and nothing\n * stale was written: ask again, and do not show errors the user did not cause. A {@link FormSubmitResult} is built on\n * it, so the outcomes are listed here only.\n */\nexport type FormValidateResult =\n\t{ readonly outcome: 'passed' } | { readonly outcome: 'invalid' } | { readonly outcome: 'overtaken' };\n\n/**\n * How a submission ended, and what the host may do next.\n *\n * @remarks\n * `'passed'`: the scope was current and nothing blocks; `values` are exactly the values that passed, frozen,\n * nested like `snapshot.values`, without the paths that took no part and with the config's `payload`. An\n * edit during the check followed by a retry that passes leaves the edit in them. `setServerErrors` hands back\n * the server's answer to that submission. `'invalid'`: the scope was current and an error blocks, so show the\n * errors and focus. `'overtaken'`: an edit, a row move, a reset, a later submission or a superseded check outran\n * it, so there is no verdict on anything: ask again, and do not show errors the user did not cause.\n */\nexport type FormSubmitResult =\n\t| Exclude<FormValidateResult, { readonly outcome: 'passed' }>\n\t| {\n\t\t\treadonly outcome: 'passed';\n\t\t\treadonly values: Readonly<Record<string, unknown>>;\n\t\t\t/**\n\t\t\t * Shows the server's answer to this submission, replacing the answer shown so far.\n\t\t\t *\n\t\t\t * @remarks\n\t\t\t * Each path takes one issue or a list, and {@link FORM_ROOT} stands for the form. Throws for a path with\n\t\t\t * a reserved `__` segment other than `FORM_ROOT`, and for a path that names a row the submitted values\n\t\t\t * did not have. Paths are as they are in `values`: an index counts only the rows that took part, and the container maps it to the form's row (so with the middle one of three rows left out, `rows.1` is the third row). An error for `contacts.0.email` lands\n\t\t\t * on that row wherever it is now, and is dropped when the row is gone. A path no field declares cannot be\n\t\t\t * shown at a field, so its issues move to `FORM_ROOT`, keeping their type, params and message. An error is applied only when its\n\t\t\t * target, and every value its rules read, are unchanged since the submission, and only while this is the\n\t\t\t * latest submission and no reset came between: otherwise the call does nothing. An error is cleared\n\t\t\t * when its path, or a path its rules read, is edited.\n\t\t\t */\n\t\t\treadonly setServerErrors: (errors: FormStateErrorsInput) => void;\n\t };\n\n/**\n * The immutable state a subscriber reads.\n *\n * @remarks\n * Stable: {@link FormStateContainer.getSnapshot} returns the same object until something changes, and a\n * branch that did not change keeps its reference, in `values` and in every map. Maps are plain records,\n * frozen, keyed by dotted path. An opaque value, such as an array holding `File` objects, is kept and\n * compared by reference: it is never copied, frozen or diffed.\n *\n * Paths that take no part in validation (hidden or disabled fields, and what is inside them) are absent\n * from `errors`, `warnings` and `validating`.\n */\nexport interface FormStateSnapshot {\n\t/** The nested value tree. */\n\treadonly values: Readonly<Record<string, unknown>>;\n\t/**\n\t * The error of each path, with every issue it has in `all`.\n\t *\n\t * @remarks\n\t * Never inherited: an error on `contacts` is not an error on `contacts.0.email`, and both can be present.\n\t * An error about the form itself is at {@link FORM_ROOT}.\n\t */\n\treadonly errors: Readonly<Record<string, FormStateError>>;\n\t/** The advice of each path, shaped like `errors` and never blocking. */\n\treadonly warnings: Readonly<Record<string, FormStateWarning>>;\n\t/** The paths the user has blurred; a mark on a container covers the fields below it. Moves with its row. */\n\treadonly touched: Readonly<Record<string, true>>;\n\t/**\n\t * The paths whose value differs from the defaults.\n\t *\n\t * @remarks An array's own mark means its row count changed; its rows are compared by index, so appending a row does not make the existing rows dirty.\n\t */\n\treadonly dirty: Readonly<Record<string, true>>;\n\t/** The ids of an array's rows, by array path, in row order. */\n\treadonly rowIds: Readonly<Record<string, readonly string[]>>;\n\t/**\n\t * The paths a check the container started is still running for.\n\t *\n\t * @remarks\n\t * A path is listed while the latest check that asked for it is running: a check overtaken by a later one\n\t * for the same path does not keep it pending. Pending is state, never an issue. It moves with its row.\n\t */\n\treadonly validating: Readonly<Record<string, true>>;\n\t/** Whether no error from any source is recorded for a path that takes part. Cheap, and not a fresh check. */\n\treadonly isValid: boolean;\n\t/**\n\t * How many times the form was reset: it goes up by one on every {@link FormStateContainer.reset} and on nothing else.\n\t *\n\t * @remarks\n\t * It lets what lives around the container, such as a runtime's submission and step state, notice a reset\n\t * that no one told it about, since `reset` is the only way back and any caller may use it.\n\t */\n\treadonly generation: number;\n\t/**\n\t * What the form's constraints say, resolved in order against the values with whatever took no part absent.\n\t *\n\t * @remarks\n\t * `skippedSteps` lists the ids of the steps its constraints hide. `fields` has an entry for each rendered path that has a constraint,\n\t * is disabled by authoring or is held by a skipped step; `selectFieldState` folds the ancestors in. The same object comes back\n\t * while nothing in it changes, however much else does.\n\t */\n\treadonly participation: {\n\t\treadonly skippedSteps: readonly string[];\n\t\treadonly fields: Readonly<Record<string, FieldParticipation>>;\n\t};\n}\n\n/**\n * The commands over a form's state, and the stable reads a binding builds on.\n *\n * @remarks\n * Every command is one atomic update: subscribers are notified once, and never see an array's values\n * and its row state out of step. No member depends on how it is called, so a binding may pass any of\n * them as a callback. Read state with `getSnapshot` and the selectors of `selectors.ts`.\n */\nexport interface FormStateContainer {\n\t/** Registers a listener for every snapshot change; returns the function that removes it. */\n\tsubscribe(listener: () => void): () => void;\n\tgetSnapshot(): FormStateSnapshot;\n\t/** The snapshot to render on the server and during hydration: the initial state, never replaced. */\n\tgetServerSnapshot(): FormStateSnapshot;\n\n\t/** The value at a dotted path, from the current state. */\n\tgetValue(path: string): unknown;\n\t/**\n\t * Replaces the whole branch at `path`.\n\t *\n\t * @remarks\n\t * Throws for a path with a reserved segment (one that starts with `__`, or `constructor`, `prototype`, `__proto__`) and for a path that names a row its array does not\n\t * have: rows are made with `fieldArray`, so a write cannot leave holes or rows without an id. It is a change: it validates when the mode says so, re-validates dependents, and drops what describes\n\t * a value that is gone: the errors a server answered with at the path and below, and on the paths around it, the form included,\n\t * and the native facts of the value. The state of rows and objects the branch no longer holds is dropped with\n\t * them. A write that leaves the value as it is changes nothing.\n\t */\n\tsetValue(path: string, value: unknown): void;\n\t/**\n\t * Marks `path` touched, and validates it when the mode says so.\n\t *\n\t * @remarks\n\t * The path is checked as in `setValue`. A control whose value the host has not written yet is written with\n\t * `setValue` first: the two are separate commands, and the end state is the one a single command would\n\t * leave.\n\t */\n\tblur(path: string): void;\n\t/**\n\t * Reports what the platform's controls say about the values the container holds, with no input from the user.\n\t *\n\t * @remarks\n\t * The one channel for native validity, for a host that owns controls: a path with its fact, `null` for a\n\t * control that reports itself valid or goes away, which withdraws the fact. A host reports a fact on a\n\t * change, a blur, a reset, or when a control's constraints change, and withdraws it when its control\n\t * disconnects. A fact is bound to the value held now and is dropped when that value changes, and it moves with\n\t * its row. A fact that is already held is a no-op. Reporting is no change: nothing becomes dirty or touched,\n\t * and one call is one commit that re-validates, in a single run, only the changed paths that were validated\n\t * before, are in a failed scope, or have a check in flight, never to start validating a pristine one. A path no field\n\t * of the config expands to for the values held (a name no field has, a removed row, anything below a scalar) is\n\t * ignored. A reserved path throws, for the whole\n\t * call and before anything is written. A fact is not part of the snapshot, so reporting alone notifies nobody.\n\t */\n\treportNative(facts: Readonly<Record<string, NativeValidity | null>>): void;\n\t/**\n\t * Replaces the defaults with `values` when given, then restores the values to the defaults and clears\n\t * every error, native fact, touched and dirty mark and the failed-check state.\n\t *\n\t * @remarks Validation still running when this is called is dropped and not run again, and so are the submissions begun before it; every row gets a new id.\n\t */\n\treset(values?: Record<string, unknown>): void;\n\t/**\n\t * Validates `paths` (the whole form when omitted, nothing when empty), records the findings and says how that ended.\n\t *\n\t * @remarks\n\t * Every check records the scope it covered: the values it read, the values its rules depend on, the\n\t * native facts, the reset generation and the rows by id. It is `'passed'` only when no error from any\n\t * source remains at the paths that take part and that scope was still current when it finished. A check\n\t * overtaken by an edit, a row move or a reset runs once more over the same rows, wherever they are now,\n\t * and one that is overtaken again, or whose rows are gone, is `'overtaken'` without writing anything stale:\n\t * it is not `'invalid'`, so the host must not read it as a failed field.\n\t * It rejects with a `FormValidationFailure` naming the path and rule when a rule could not run. A failure\n\t * of its own validation starts the failed-check state for those paths, so they re-validate by\n\t * `reValidateMode` from then on. It does not mark anything submitted or touched.\n\t */\n\tvalidate(paths?: readonly string[]): Promise<FormValidateResult>;\n\t/**\n\t * Whether the form is valid for the state at the moment of the call, by the same count as `validate`, without its writes.\n\t *\n\t * @remarks\n\t * It answers for the values, native facts, server errors and participation current when it was called,\n\t * and for no later state: it is never retried and never mixes those with errors set afterwards, so the\n\t * answer may already be out of date when it resolves. It writes no error and\n\t * changes no state. Errors recorded earlier do not count, as the check validates afresh. It rejects with\n\t * a `FormValidationFailure`, which keeps the `reason` and the `cause`, when a rule could not run.\n\t */\n\tcheckValidity(): Promise<boolean>;\n\t/**\n\t * Submits the form: clears the server's answer to the last submission, validates the whole form and says how that ended.\n\t *\n\t * @remarks\n\t * It validates as `validate()` does, with the same freshness and the one retry over the same rows, and\n\t * captures the submission the result speaks for: a later `submit` or a `reset` supersedes it, and the\n\t * earlier one ends `'overtaken'` or has its `setServerErrors` ignored. Like `validate`, it rejects with a\n\t * `FormValidationFailure` when a rule could not run, and a rejected call is no outcome.\n\t */\n\tsubmit(): Promise<FormSubmitResult>;\n\t/**\n\t * The commands of the array at `path`, the same object each time.\n\t *\n\t * @remarks\n\t * Cached per path, and a path names a position: `contacts.0.phones` is whatever row is at index 0 now,\n\t * not the row that was there when the commands were first asked for. Rows are read from\n\t * `snapshot.rowIds[path]`; `toFieldArrayValue` combines the two for a widget.\n\t */\n\tfieldArray(path: string): FieldArrayCommands;\n}\n\n/** What {@link createFormStateContainer} reads from a normalized form config. */\nexport interface FormStateContainerConfig {\n\t/**\n\t * The steps whose elements make up the form: fields, rules and constraints.\n\t *\n\t * @remarks A step's own `constraints` decide whether it is skipped; a skipped step's fields take no part, as hidden fields do not.\n\t */\n\treadonly steps: readonly ValidationStep[];\n\t/** When a field validates before a check of it has failed; the config schema always fills it. */\n\treadonly validationMode: FormValidationMode;\n\t/** When a field validates once a check of it has run; the config schema always fills it. */\n\treadonly reValidateMode: FormReValidateMode;\n\t/**\n\t * Data that travels with every submission.\n\t *\n\t * @remarks It is merged into the `values` of a passed submission and is never a value of the form: not in the snapshot, not dirty, not validated. Its keys cannot name fields, which the config validation checks.\n\t */\n\treadonly payload?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * The part of a snapshot that a server hands to a client so the client starts from the same state.\n *\n * @remarks\n * The `values` and `rowIds` of a snapshot are plain, frozen and serializable (but for opaque values such as\n * files), so `JSON.stringify(toHydration(container.getServerSnapshot()))` is the payload, and a snapshot is itself\n * accepted. The rest of a snapshot is derived from what the server's container did, not state to restore.\n */\nexport interface FormStateHydration {\n\treadonly values: Readonly<Record<string, unknown>>;\n\treadonly rowIds: Readonly<Record<string, readonly string[]>>;\n}\n\n/** What {@link FormStateContainerFactory} builds a container from. */\nexport interface FormStateContainerOptions {\n\t/** The normalized form config: the elements, the validation timing and the payload all come from it, so no renderer can differ. */\n\treadonly config: FormStateContainerConfig;\n\treadonly registry: ValidationRegistry;\n\treadonly defaults?: Record<string, unknown>;\n\t/**\n\t * The snapshot of a container that rendered the form elsewhere, to start from: its values and its row ids.\n\t *\n\t * @remarks\n\t * Without it the container starts from `defaults` and mints deterministic row ids (walk order, one counter per\n\t * container). With it the container starts from the values of the snapshot and adopts its row ids, so a client\n\t * keeps the identity a server rendered, whatever rows the user had added there. Values and ids come from the same\n\t * object, so there is nothing to compare; one whose ids do not match its own values cannot come from a real\n\t * snapshot and throws. `defaults` still say what the form started from, and what\n\t * `reset` restores, so pass the same ones the server used: the fields that differ from them are dirty.\n\t */\n\treadonly snapshot?: FormStateHydration;\n}\n\n/** What `formStateContainerConformance` builds the container under test with. */\nexport type FormStateContainerFactory = (options: FormStateContainerOptions) => FormStateContainer;\n"],
5
+ "mappings": ";AA6BO,IAAM,YAAY;",
6
+ "names": []
7
+ }
@@ -0,0 +1,49 @@
1
+ import {
2
+ collectStepFieldPaths
3
+ } from "./chunk-WUTGZYP4.js";
4
+
5
+ // src/engine/step-machine.ts
6
+ var startProgress = (first) => ({ current: first, visited: [first], complete: [] });
7
+ var including = (ids, added) => added.every((id) => ids.includes(id)) ? ids : [...ids, ...added.filter((id) => !ids.includes(id))];
8
+ function moveProgress(progress, to, completed = []) {
9
+ const visited = including(progress.visited, [to]);
10
+ const complete = including(progress.complete, completed);
11
+ return progress.current === to && visited === progress.visited && complete === progress.complete ? progress : { current: to, visited, complete };
12
+ }
13
+ function deriveStepStates(steps, progress, derived, mode) {
14
+ const at = steps.findIndex(({ id }) => id === progress.current);
15
+ return steps.map(({ id }, index) => {
16
+ const skipped = derived.skipped.includes(id);
17
+ const visited = progress.visited.includes(id);
18
+ return {
19
+ id,
20
+ skipped,
21
+ visited,
22
+ complete: progress.complete.includes(id),
23
+ invalid: derived.invalid.includes(id),
24
+ reachable: !skipped && id !== progress.current && (index < at || mode === "free" || visited)
25
+ };
26
+ });
27
+ }
28
+ var activeStepIds = (states) => states.filter(({ skipped }) => !skipped).map(({ id }) => id);
29
+ function stepAfter(states, id) {
30
+ const at = states.findIndex((state) => state.id === id);
31
+ return states.slice(at + 1).find(({ skipped }) => !skipped)?.id;
32
+ }
33
+ function stepBefore(states, id) {
34
+ const at = states.findIndex((state) => state.id === id);
35
+ return states.slice(0, Math.max(at, 0)).findLast(({ skipped }) => !skipped)?.id;
36
+ }
37
+ function stepsWithErrors(steps, values, errors) {
38
+ return steps.filter((step) => collectStepFieldPaths(step, values).some((path) => Object.hasOwn(errors, path))).map(({ id }) => id);
39
+ }
40
+
41
+ export {
42
+ startProgress,
43
+ moveProgress,
44
+ deriveStepStates,
45
+ activeStepIds,
46
+ stepAfter,
47
+ stepBefore,
48
+ stepsWithErrors
49
+ };