@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.
- package/LICENSE +21 -0
- package/README.md +69 -2
- package/dist/actions/index.d.ts +3 -0
- package/dist/actions/index.js +50 -0
- package/dist/actions/index.js.map +7 -0
- package/dist/actions/plugins/auto-save.plugin.d.ts +39 -0
- package/dist/actions/plugins/auto-save.plugin.js +10 -0
- package/dist/actions/plugins/auto-save.plugin.js.map +7 -0
- package/dist/actions/plugins/form-reset.plugin.d.ts +23 -0
- package/dist/actions/plugins/form-reset.plugin.js +9 -0
- package/dist/actions/plugins/form-reset.plugin.js.map +7 -0
- package/dist/actions/plugins/form-submit.plugin.d.ts +31 -0
- package/dist/actions/plugins/form-submit.plugin.js +9 -0
- package/dist/actions/plugins/form-submit.plugin.js.map +7 -0
- package/dist/actions/plugins/form-submit.registration.d.ts +22 -0
- package/dist/actions/plugins/form-submit.registration.js +8 -0
- package/dist/actions/plugins/form-submit.registration.js.map +7 -0
- package/dist/actions/plugins/gtm.plugin.d.ts +30 -0
- package/dist/actions/plugins/gtm.plugin.js +8 -0
- package/dist/actions/plugins/gtm.plugin.js.map +7 -0
- package/dist/actions/plugins/index.d.ts +16 -0
- package/dist/actions/plugins/index.js +45 -0
- package/dist/actions/plugins/index.js.map +7 -0
- package/dist/actions/plugins/notification.plugin.d.ts +32 -0
- package/dist/actions/plugins/notification.plugin.js +9 -0
- package/dist/actions/plugins/notification.plugin.js.map +7 -0
- package/dist/actions/plugins/notification.registration.d.ts +22 -0
- package/dist/actions/plugins/notification.registration.js +8 -0
- package/dist/actions/plugins/notification.registration.js.map +7 -0
- package/dist/actions/plugins/registrations.d.ts +17 -0
- package/dist/actions/plugins/registrations.js +14 -0
- package/dist/actions/plugins/registrations.js.map +7 -0
- package/dist/actions/triggers.d.ts +42 -0
- package/dist/actions/triggers.js +6 -0
- package/dist/actions/triggers.js.map +7 -0
- package/dist/actions/types.d.ts +16 -0
- package/dist/actions/types.js +1 -0
- package/dist/actions/types.js.map +7 -0
- package/dist/agent-tool/index.d.ts +54 -0
- package/dist/agent-tool/index.js +128 -0
- package/dist/agent-tool/index.js.map +7 -0
- package/dist/browser/action-registrations.d.ts +46 -0
- package/dist/browser/action-registrations.js +19 -0
- package/dist/browser/action-registrations.js.map +7 -0
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.js +36 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/browser/tools/auto-save-storage.d.ts +20 -0
- package/dist/browser/tools/auto-save-storage.js +12 -0
- package/dist/browser/tools/auto-save-storage.js.map +7 -0
- package/dist/browser/tools/gdpr-consent.d.ts +32 -0
- package/dist/browser/tools/gdpr-consent.js +11 -0
- package/dist/browser/tools/gdpr-consent.js.map +7 -0
- package/dist/browser/tools/gtm-tracker.d.ts +7 -0
- package/dist/browser/tools/gtm-tracker.js +7 -0
- package/dist/browser/tools/gtm-tracker.js.map +7 -0
- package/dist/builder/form-authoring.d.ts +159 -0
- package/dist/builder/form-authoring.js +1 -0
- package/dist/builder/form-authoring.js.map +7 -0
- package/dist/builder/form-values.d.ts +158 -0
- package/dist/builder/form-values.js +0 -0
- package/dist/builder/form-values.js.map +7 -0
- package/dist/builder/index.d.ts +5 -0
- package/dist/builder/index.js +2 -0
- package/dist/builder/index.js.map +7 -0
- package/dist/builder/types.utils.d.ts +137 -0
- package/dist/builder/types.utils.js +1 -0
- package/dist/builder/types.utils.js.map +7 -0
- package/dist/chunk-237BHPDH.js +88 -0
- package/dist/chunk-237BHPDH.js.map +7 -0
- package/dist/chunk-25PLQDKN.js +45 -0
- package/dist/chunk-25PLQDKN.js.map +7 -0
- package/dist/chunk-2XWISGGM.js +8 -0
- package/dist/chunk-2XWISGGM.js.map +7 -0
- package/dist/chunk-2YKQAVI2.js +8 -0
- package/dist/chunk-2YKQAVI2.js.map +7 -0
- package/dist/chunk-3B7CJOF6.js +18 -0
- package/dist/chunk-3B7CJOF6.js.map +7 -0
- package/dist/chunk-3YLRJVVN.js +17 -0
- package/dist/chunk-3YLRJVVN.js.map +7 -0
- package/dist/chunk-4CUGHU36.js +58 -0
- package/dist/chunk-4CUGHU36.js.map +7 -0
- package/dist/chunk-4FELFUCD.js +0 -0
- package/dist/chunk-4FELFUCD.js.map +7 -0
- package/dist/chunk-4XPLSYTK.js +82 -0
- package/dist/chunk-4XPLSYTK.js.map +7 -0
- package/dist/chunk-5Y6U3MR3.js +54 -0
- package/dist/chunk-5Y6U3MR3.js.map +7 -0
- package/dist/chunk-6BAJHAGL.js +29 -0
- package/dist/chunk-6BAJHAGL.js.map +7 -0
- package/dist/chunk-6EYX257T.js +23 -0
- package/dist/chunk-6EYX257T.js.map +7 -0
- package/dist/chunk-6FUGK5HQ.js +26 -0
- package/dist/chunk-6FUGK5HQ.js.map +7 -0
- package/dist/chunk-6IZYNHZ3.js +118 -0
- package/dist/chunk-6IZYNHZ3.js.map +7 -0
- package/dist/chunk-6NV2JDGI.js +8 -0
- package/dist/chunk-6NV2JDGI.js.map +7 -0
- package/dist/chunk-6R2MBQPL.js +19 -0
- package/dist/chunk-6R2MBQPL.js.map +7 -0
- package/dist/chunk-7EQJUI5N.js +40 -0
- package/dist/chunk-7EQJUI5N.js.map +7 -0
- package/dist/chunk-A5VLMQAK.js +2780 -0
- package/dist/chunk-A5VLMQAK.js.map +7 -0
- package/dist/chunk-AUZ45XPE.js +27 -0
- package/dist/chunk-AUZ45XPE.js.map +7 -0
- package/dist/chunk-BIHEIJG3.js +0 -0
- package/dist/chunk-BIHEIJG3.js.map +7 -0
- package/dist/chunk-BKNWW4PK.js +0 -0
- package/dist/chunk-BKNWW4PK.js.map +7 -0
- package/dist/chunk-BLFLCSG3.js +71 -0
- package/dist/chunk-BLFLCSG3.js.map +7 -0
- package/dist/chunk-BYYGAGNH.js +0 -0
- package/dist/chunk-BYYGAGNH.js.map +7 -0
- package/dist/chunk-CANRZY5A.js +87 -0
- package/dist/chunk-CANRZY5A.js.map +7 -0
- package/dist/chunk-CAZPWBQ4.js +18 -0
- package/dist/chunk-CAZPWBQ4.js.map +7 -0
- package/dist/chunk-CMPOBBRV.js +10 -0
- package/dist/chunk-CMPOBBRV.js.map +7 -0
- package/dist/chunk-CRQWKC67.js +118 -0
- package/dist/chunk-CRQWKC67.js.map +7 -0
- package/dist/chunk-CRVXBWSY.js +70 -0
- package/dist/chunk-CRVXBWSY.js.map +7 -0
- package/dist/chunk-D6ZHV6AT.js +0 -0
- package/dist/chunk-D6ZHV6AT.js.map +7 -0
- package/dist/chunk-DP7SYLLI.js +206 -0
- package/dist/chunk-DP7SYLLI.js.map +7 -0
- package/dist/chunk-DVDKPY2A.js +12 -0
- package/dist/chunk-DVDKPY2A.js.map +7 -0
- package/dist/chunk-E4VONSLO.js +15 -0
- package/dist/chunk-E4VONSLO.js.map +7 -0
- package/dist/chunk-EEYGPPLU.js +185 -0
- package/dist/chunk-EEYGPPLU.js.map +7 -0
- package/dist/chunk-EI5TMJDC.js +56 -0
- package/dist/chunk-EI5TMJDC.js.map +7 -0
- package/dist/chunk-EQ5AIF3T.js +117 -0
- package/dist/chunk-EQ5AIF3T.js.map +7 -0
- package/dist/chunk-EZZHO6DQ.js +26 -0
- package/dist/chunk-EZZHO6DQ.js.map +7 -0
- package/dist/chunk-FUHLRG3M.js +130 -0
- package/dist/chunk-FUHLRG3M.js.map +7 -0
- package/dist/chunk-FVOL3ZOJ.js +101 -0
- package/dist/chunk-FVOL3ZOJ.js.map +7 -0
- package/dist/chunk-G33EUV7N.js +288 -0
- package/dist/chunk-G33EUV7N.js.map +7 -0
- package/dist/chunk-GH34XFCC.js +56 -0
- package/dist/chunk-GH34XFCC.js.map +7 -0
- package/dist/chunk-GKWRJ6H4.js +27 -0
- package/dist/chunk-GKWRJ6H4.js.map +7 -0
- package/dist/chunk-GQHMU3AR.js +907 -0
- package/dist/chunk-GQHMU3AR.js.map +7 -0
- package/dist/chunk-GRZU6F7Q.js +80 -0
- package/dist/chunk-GRZU6F7Q.js.map +7 -0
- package/dist/chunk-GT2LARKT.js +107 -0
- package/dist/chunk-GT2LARKT.js.map +7 -0
- package/dist/chunk-H4ABGAAG.js +60 -0
- package/dist/chunk-H4ABGAAG.js.map +7 -0
- package/dist/chunk-H63UHX42.js +93 -0
- package/dist/chunk-H63UHX42.js.map +7 -0
- package/dist/chunk-HIS4MGIR.js +8 -0
- package/dist/chunk-HIS4MGIR.js.map +7 -0
- package/dist/chunk-HPPFSWIV.js +213 -0
- package/dist/chunk-HPPFSWIV.js.map +7 -0
- package/dist/chunk-J2FC5K4B.js +87 -0
- package/dist/chunk-J2FC5K4B.js.map +7 -0
- package/dist/chunk-J5BSFDVK.js +123 -0
- package/dist/chunk-J5BSFDVK.js.map +7 -0
- package/dist/chunk-J7GSNWXT.js +151 -0
- package/dist/chunk-J7GSNWXT.js.map +7 -0
- package/dist/chunk-JA5ET6MC.js +550 -0
- package/dist/chunk-JA5ET6MC.js.map +7 -0
- package/dist/chunk-K22S7IZR.js +12 -0
- package/dist/chunk-K22S7IZR.js.map +7 -0
- package/dist/chunk-K5TMXCMY.js +139 -0
- package/dist/chunk-K5TMXCMY.js.map +7 -0
- package/dist/chunk-KE53GN4Q.js +246 -0
- package/dist/chunk-KE53GN4Q.js.map +7 -0
- package/dist/chunk-KFQEDSYI.js +24 -0
- package/dist/chunk-KFQEDSYI.js.map +7 -0
- package/dist/chunk-KH6QWB5Y.js +51 -0
- package/dist/chunk-KH6QWB5Y.js.map +7 -0
- package/dist/chunk-KLATKWUA.js +116 -0
- package/dist/chunk-KLATKWUA.js.map +7 -0
- package/dist/chunk-KSKWSUOB.js +17 -0
- package/dist/chunk-KSKWSUOB.js.map +7 -0
- package/dist/chunk-LFWEJXWE.js +68 -0
- package/dist/chunk-LFWEJXWE.js.map +7 -0
- package/dist/chunk-LMWJAD3B.js +24 -0
- package/dist/chunk-LMWJAD3B.js.map +7 -0
- package/dist/chunk-MD23VADH.js +92 -0
- package/dist/chunk-MD23VADH.js.map +7 -0
- package/dist/chunk-MKMJT3XR.js +0 -0
- package/dist/chunk-MKMJT3XR.js.map +7 -0
- package/dist/chunk-NJTLBSTR.js +82 -0
- package/dist/chunk-NJTLBSTR.js.map +7 -0
- package/dist/chunk-NJXKMF67.js +182 -0
- package/dist/chunk-NJXKMF67.js.map +7 -0
- package/dist/chunk-OBQBIOGN.js +16 -0
- package/dist/chunk-OBQBIOGN.js.map +7 -0
- package/dist/chunk-OLYHNFKC.js +82 -0
- package/dist/chunk-OLYHNFKC.js.map +7 -0
- package/dist/chunk-OR2L7EKO.js +33 -0
- package/dist/chunk-OR2L7EKO.js.map +7 -0
- package/dist/chunk-OUF57UZ7.js +28 -0
- package/dist/chunk-OUF57UZ7.js.map +7 -0
- package/dist/chunk-PBMM2N77.js +56 -0
- package/dist/chunk-PBMM2N77.js.map +7 -0
- package/dist/chunk-PCL2KNHC.js +6 -0
- package/dist/chunk-PCL2KNHC.js.map +7 -0
- package/dist/chunk-PH3LWLYN.js +49 -0
- package/dist/chunk-PH3LWLYN.js.map +7 -0
- package/dist/chunk-PHNMDWSK.js +9 -0
- package/dist/chunk-PHNMDWSK.js.map +7 -0
- package/dist/chunk-PN5EH6DM.js +36 -0
- package/dist/chunk-PN5EH6DM.js.map +7 -0
- package/dist/chunk-POCAINUE.js +42 -0
- package/dist/chunk-POCAINUE.js.map +7 -0
- package/dist/chunk-Q5LEK7CI.js +64 -0
- package/dist/chunk-Q5LEK7CI.js.map +7 -0
- package/dist/chunk-QH7VW7IY.js +0 -0
- package/dist/chunk-QH7VW7IY.js.map +7 -0
- package/dist/chunk-QLGM2AZW.js +173 -0
- package/dist/chunk-QLGM2AZW.js.map +7 -0
- package/dist/chunk-QT3EYUL5.js +85 -0
- package/dist/chunk-QT3EYUL5.js.map +7 -0
- package/dist/chunk-QYHOFLRX.js +43 -0
- package/dist/chunk-QYHOFLRX.js.map +7 -0
- package/dist/chunk-R3MBVWVI.js +127 -0
- package/dist/chunk-R3MBVWVI.js.map +7 -0
- package/dist/chunk-R6V3LH7F.js +67 -0
- package/dist/chunk-R6V3LH7F.js.map +7 -0
- package/dist/chunk-RB22U6HI.js +64 -0
- package/dist/chunk-RB22U6HI.js.map +7 -0
- package/dist/chunk-RQRQYYTB.js +34 -0
- package/dist/chunk-RQRQYYTB.js.map +7 -0
- package/dist/chunk-S5D2QE4G.js +53 -0
- package/dist/chunk-S5D2QE4G.js.map +7 -0
- package/dist/chunk-S7I76ISM.js +245 -0
- package/dist/chunk-S7I76ISM.js.map +7 -0
- package/dist/chunk-TBDZOQ2C.js +66 -0
- package/dist/chunk-TBDZOQ2C.js.map +7 -0
- package/dist/chunk-TSKELYW7.js +55 -0
- package/dist/chunk-TSKELYW7.js.map +7 -0
- package/dist/chunk-U3YHTQHR.js +215 -0
- package/dist/chunk-U3YHTQHR.js.map +7 -0
- package/dist/chunk-UGL3KNOT.js +42 -0
- package/dist/chunk-UGL3KNOT.js.map +7 -0
- package/dist/chunk-UN3DARLG.js +35 -0
- package/dist/chunk-UN3DARLG.js.map +7 -0
- package/dist/chunk-V5H7L5PJ.js +587 -0
- package/dist/chunk-V5H7L5PJ.js.map +7 -0
- package/dist/chunk-VGGERKV2.js +7 -0
- package/dist/chunk-VGGERKV2.js.map +7 -0
- package/dist/chunk-VVFXYY65.js +0 -0
- package/dist/chunk-VVFXYY65.js.map +7 -0
- package/dist/chunk-WLDCYUN6.js +161 -0
- package/dist/chunk-WLDCYUN6.js.map +7 -0
- package/dist/chunk-WMDTQS36.js +0 -0
- package/dist/chunk-WMDTQS36.js.map +7 -0
- package/dist/chunk-WUTGZYP4.js +290 -0
- package/dist/chunk-WUTGZYP4.js.map +7 -0
- package/dist/chunk-XKN3WWK3.js +0 -0
- package/dist/chunk-XKN3WWK3.js.map +7 -0
- package/dist/chunk-XQ5VJ4QO.js +62 -0
- package/dist/chunk-XQ5VJ4QO.js.map +7 -0
- package/dist/chunk-XQVKX47O.js +174 -0
- package/dist/chunk-XQVKX47O.js.map +7 -0
- package/dist/chunk-Y5CNB57V.js +22 -0
- package/dist/chunk-Y5CNB57V.js.map +7 -0
- package/dist/chunk-YDGH7DTL.js +18 -0
- package/dist/chunk-YDGH7DTL.js.map +7 -0
- package/dist/chunk-YIFUBPJ3.js +0 -0
- package/dist/chunk-YIFUBPJ3.js.map +7 -0
- package/dist/chunk-YUUDXRBW.js +212 -0
- package/dist/chunk-YUUDXRBW.js.map +7 -0
- package/dist/chunk-Z6DQLJS2.js +23 -0
- package/dist/chunk-Z6DQLJS2.js.map +7 -0
- package/dist/chunk-ZDEZ2FOC.js +81 -0
- package/dist/chunk-ZDEZ2FOC.js.map +7 -0
- package/dist/chunk-ZUYSGCEH.js +65 -0
- package/dist/chunk-ZUYSGCEH.js.map +7 -0
- package/dist/chunk-ZYP3MIH3.js +115 -0
- package/dist/chunk-ZYP3MIH3.js.map +7 -0
- package/dist/constraints/constraint-evaluator.d.ts +57 -0
- package/dist/constraints/constraint-evaluator.js +17 -0
- package/dist/constraints/constraint-evaluator.js.map +7 -0
- package/dist/constraints/index.d.ts +1 -0
- package/dist/constraints/index.js +17 -0
- package/dist/constraints/index.js.map +7 -0
- package/dist/csrf/index.d.ts +43 -0
- package/dist/csrf/index.js +43 -0
- package/dist/csrf/index.js.map +7 -0
- package/dist/engine/build-form-engine.d.ts +27 -0
- package/dist/engine/build-form-engine.js +58 -0
- package/dist/engine/build-form-engine.js.map +7 -0
- package/dist/engine/component-type.d.ts +19 -0
- package/dist/engine/component-type.js +6 -0
- package/dist/engine/component-type.js.map +7 -0
- package/dist/engine/create-form-engine.d.ts +100 -0
- package/dist/engine/create-form-engine.js +59 -0
- package/dist/engine/create-form-engine.js.map +7 -0
- package/dist/engine/form-action-context.d.ts +70 -0
- package/dist/engine/form-action-context.js +10 -0
- package/dist/engine/form-action-context.js.map +7 -0
- package/dist/engine/form-engine.d.ts +236 -0
- package/dist/engine/form-engine.js +61 -0
- package/dist/engine/form-engine.js.map +7 -0
- package/dist/engine/index.d.ts +12 -0
- package/dist/engine/index.js +124 -0
- package/dist/engine/index.js.map +7 -0
- package/dist/engine/schema-artifacts.d.ts +87 -0
- package/dist/engine/schema-artifacts.js +14 -0
- package/dist/engine/schema-artifacts.js.map +7 -0
- package/dist/engine/schema-metadata-catalog.d.ts +41 -0
- package/dist/engine/schema-metadata-catalog.js +6 -0
- package/dist/engine/schema-metadata-catalog.js.map +7 -0
- package/dist/engine/step-machine.d.ts +59 -0
- package/dist/engine/step-machine.js +32 -0
- package/dist/engine/step-machine.js.map +7 -0
- package/dist/engine/submission-schema.d.ts +53 -0
- package/dist/engine/submission-schema.js +22 -0
- package/dist/engine/submission-schema.js.map +7 -0
- package/dist/engine/value-validation.d.ts +237 -0
- package/dist/engine/value-validation.js +39 -0
- package/dist/engine/value-validation.js.map +7 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +283 -0
- package/dist/index.js.map +7 -0
- package/dist/lib/authoring-catalog.d.ts +5 -0
- package/dist/lib/authoring-catalog.js +11 -0
- package/dist/lib/authoring-catalog.js.map +7 -0
- package/dist/lib/container-kind-of.d.ts +5 -0
- package/dist/lib/container-kind-of.js +6 -0
- package/dist/lib/container-kind-of.js.map +7 -0
- package/dist/lib/debounce.d.ts +19 -0
- package/dist/lib/debounce.js +6 -0
- package/dist/lib/debounce.js.map +7 -0
- package/dist/lib/deep-readonly.d.ts +12 -0
- package/dist/lib/deep-readonly.js +0 -0
- package/dist/lib/deep-readonly.js.map +7 -0
- package/dist/lib/element-children.d.ts +35 -0
- package/dist/lib/element-children.js +16 -0
- package/dist/lib/element-children.js.map +7 -0
- package/dist/lib/exported-action-envelope.d.ts +11 -0
- package/dist/lib/exported-action-envelope.js +7 -0
- package/dist/lib/exported-action-envelope.js.map +7 -0
- package/dist/lib/exported-rules.d.ts +14 -0
- package/dist/lib/exported-rules.js +6 -0
- package/dist/lib/exported-rules.js.map +7 -0
- package/dist/lib/field-ref.d.ts +13 -0
- package/dist/lib/field-ref.js +6 -0
- package/dist/lib/field-ref.js.map +7 -0
- package/dist/lib/field-scope.d.ts +121 -0
- package/dist/lib/field-scope.js +41 -0
- package/dist/lib/field-scope.js.map +7 -0
- package/dist/lib/form-fetch.d.ts +36 -0
- package/dist/lib/form-fetch.js +10 -0
- package/dist/lib/form-fetch.js.map +7 -0
- package/dist/lib/form-view.d.ts +33 -0
- package/dist/lib/form-view.js +12 -0
- package/dist/lib/form-view.js.map +7 -0
- package/dist/lib/frozen-copy.d.ts +9 -0
- package/dist/lib/frozen-copy.js +7 -0
- package/dist/lib/frozen-copy.js.map +7 -0
- package/dist/lib/is-plain-object.d.ts +2 -0
- package/dist/lib/is-plain-object.js +6 -0
- package/dist/lib/is-plain-object.js.map +7 -0
- package/dist/lib/logger.d.ts +2 -0
- package/dist/lib/logger.js +6 -0
- package/dist/lib/logger.js.map +7 -0
- package/dist/lib/normalized-form-config.d.ts +106 -0
- package/dist/lib/normalized-form-config.js +19 -0
- package/dist/lib/normalized-form-config.js.map +7 -0
- package/dist/lib/omit-paths.d.ts +11 -0
- package/dist/lib/omit-paths.js +7 -0
- package/dist/lib/omit-paths.js.map +7 -0
- package/dist/lib/path-values.d.ts +47 -0
- package/dist/lib/path-values.js +22 -0
- package/dist/lib/path-values.js.map +7 -0
- package/dist/lib/renderer-data-attributes.d.ts +10 -0
- package/dist/lib/renderer-data-attributes.js +6 -0
- package/dist/lib/renderer-data-attributes.js.map +7 -0
- package/dist/lib/reserved-path-keys.d.ts +10 -0
- package/dist/lib/reserved-path-keys.js +10 -0
- package/dist/lib/reserved-path-keys.js.map +7 -0
- package/dist/lib/resolve-appearance.d.ts +48 -0
- package/dist/lib/resolve-appearance.js +10 -0
- package/dist/lib/resolve-appearance.js.map +7 -0
- package/dist/lib/standard-json-schema.d.ts +27 -0
- package/dist/lib/standard-json-schema.js +8 -0
- package/dist/lib/standard-json-schema.js.map +7 -0
- package/dist/lib/standard-schema.d.ts +19 -0
- package/dist/lib/standard-schema.js +8 -0
- package/dist/lib/standard-schema.js.map +7 -0
- package/dist/lib/submission-shape.d.ts +60 -0
- package/dist/lib/submission-shape.js +14 -0
- package/dist/lib/submission-shape.js.map +7 -0
- package/dist/lib/validate-form/grid-checks.d.ts +57 -0
- package/dist/lib/validate-form/grid-checks.js +16 -0
- package/dist/lib/validate-form/grid-checks.js.map +7 -0
- package/dist/lib/validate-form/issues.d.ts +43 -0
- package/dist/lib/validate-form/issues.js +13 -0
- package/dist/lib/validate-form/issues.js.map +7 -0
- package/dist/lib/validate-form/options.d.ts +22 -0
- package/dist/lib/validate-form/options.js +0 -0
- package/dist/lib/validate-form/options.js.map +7 -0
- package/dist/lib/validate-form/parse-elements.d.ts +23 -0
- package/dist/lib/validate-form/parse-elements.js +21 -0
- package/dist/lib/validate-form/parse-elements.js.map +7 -0
- package/dist/lib/validate-form/parse-owner-actions.d.ts +14 -0
- package/dist/lib/validate-form/parse-owner-actions.js +10 -0
- package/dist/lib/validate-form/parse-owner-actions.js.map +7 -0
- package/dist/lib/validate-form/parse-view.d.ts +11 -0
- package/dist/lib/validate-form/parse-view.js +11 -0
- package/dist/lib/validate-form/parse-view.js.map +7 -0
- package/dist/lib/validate-form/schema-issues.d.ts +16 -0
- package/dist/lib/validate-form/schema-issues.js +8 -0
- package/dist/lib/validate-form/schema-issues.js.map +7 -0
- package/dist/lib/validate-form/step-checks.d.ts +18 -0
- package/dist/lib/validate-form/step-checks.js +15 -0
- package/dist/lib/validate-form/step-checks.js.map +7 -0
- package/dist/lib/validate-form/validation-error.d.ts +26 -0
- package/dist/lib/validate-form/validation-error.js +8 -0
- package/dist/lib/validate-form/validation-error.js.map +7 -0
- package/dist/lib/validate-form.d.ts +34 -0
- package/dist/lib/validate-form.js +62 -0
- package/dist/lib/validate-form.js.map +7 -0
- package/dist/lib/zod-json-schema.d.ts +33 -0
- package/dist/lib/zod-json-schema.js +10 -0
- package/dist/lib/zod-json-schema.js.map +7 -0
- package/dist/recipes/built-in-specs.d.ts +1832 -0
- package/dist/recipes/built-in-specs.js +28 -0
- package/dist/recipes/built-in-specs.js.map +7 -0
- package/dist/recipes/built-in.d.ts +2 -0
- package/dist/recipes/built-in.js +49 -0
- package/dist/recipes/built-in.js.map +7 -0
- package/dist/recipes/define-form-recipe.d.ts +10 -0
- package/dist/recipes/define-form-recipe.js +6 -0
- package/dist/recipes/define-form-recipe.js.map +7 -0
- package/dist/recipes/define-recipe-spec.d.ts +13 -0
- package/dist/recipes/define-recipe-spec.js +8 -0
- package/dist/recipes/define-recipe-spec.js.map +7 -0
- package/dist/recipes/index.d.ts +6 -0
- package/dist/recipes/index.js +43 -0
- package/dist/recipes/index.js.map +7 -0
- package/dist/recipes/protocol.d.ts +24 -0
- package/dist/recipes/protocol.js +11 -0
- package/dist/recipes/protocol.js.map +7 -0
- package/dist/recipes/slot-schemas.d.ts +128 -0
- package/dist/recipes/slot-schemas.js +24 -0
- package/dist/recipes/slot-schemas.js.map +7 -0
- package/dist/recipes/types.d.ts +55 -0
- package/dist/recipes/types.js +1 -0
- package/dist/recipes/types.js.map +7 -0
- package/dist/recipes/view-model.d.ts +93 -0
- package/dist/recipes/view-model.js +29 -0
- package/dist/recipes/view-model.js.map +7 -0
- package/dist/registries/index.d.ts +8 -0
- package/dist/registries/index.js +0 -0
- package/dist/registries/index.js.map +7 -0
- package/dist/runtime/create-form-runtime.d.ts +43 -0
- package/dist/runtime/create-form-runtime.js +41 -0
- package/dist/runtime/create-form-runtime.js.map +7 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +44 -0
- package/dist/runtime/index.js.map +7 -0
- package/dist/runtime/submission-lifecycle.d.ts +65 -0
- package/dist/runtime/submission-lifecycle.js +6 -0
- package/dist/runtime/submission-lifecycle.js.map +7 -0
- package/dist/runtime/types.d.ts +172 -0
- package/dist/runtime/types.js +6 -0
- package/dist/runtime/types.js.map +7 -0
- package/dist/schemas/base-field.d.ts +450 -0
- package/dist/schemas/base-field.js +36 -0
- package/dist/schemas/base-field.js.map +7 -0
- package/dist/schemas/field-config.d.ts +36 -0
- package/dist/schemas/field-config.js +1 -0
- package/dist/schemas/field-config.js.map +7 -0
- package/dist/schemas/form-config-shape.d.ts +763 -0
- package/dist/schemas/form-config-shape.js +35 -0
- package/dist/schemas/form-config-shape.js.map +7 -0
- package/dist/schemas/form-config.d.ts +1288 -0
- package/dist/schemas/form-config.js +41 -0
- package/dist/schemas/form-config.js.map +7 -0
- package/dist/schemas/html-attributes.d.ts +12 -0
- package/dist/schemas/html-attributes.js +12 -0
- package/dist/schemas/html-attributes.js.map +7 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.js +165 -0
- package/dist/schemas/index.js.map +7 -0
- package/dist/schemas/validation/async/cache.d.ts +39 -0
- package/dist/schemas/validation/async/cache.js +6 -0
- package/dist/schemas/validation/async/cache.js.map +7 -0
- package/dist/schemas/validation/async/handler.d.ts +21 -0
- package/dist/schemas/validation/async/handler.js +11 -0
- package/dist/schemas/validation/async/handler.js.map +7 -0
- package/dist/schemas/validation/async/index.d.ts +8 -0
- package/dist/schemas/validation/async/index.js +14 -0
- package/dist/schemas/validation/async/index.js.map +7 -0
- package/dist/schemas/validation/defaults.d.ts +6 -0
- package/dist/schemas/validation/defaults.js +12 -0
- package/dist/schemas/validation/defaults.js.map +7 -0
- package/dist/schemas/validation/dependencies.d.ts +52 -0
- package/dist/schemas/validation/dependencies.js +17 -0
- package/dist/schemas/validation/dependencies.js.map +7 -0
- package/dist/schemas/validation/empty.d.ts +1 -0
- package/dist/schemas/validation/empty.js +6 -0
- package/dist/schemas/validation/empty.js.map +7 -0
- package/dist/schemas/validation/errors.d.ts +44 -0
- package/dist/schemas/validation/errors.js +12 -0
- package/dist/schemas/validation/errors.js.map +7 -0
- package/dist/schemas/validation/index.d.ts +9 -0
- package/dist/schemas/validation/index.js +130 -0
- package/dist/schemas/validation/index.js.map +7 -0
- package/dist/schemas/validation/presets.d.ts +66 -0
- package/dist/schemas/validation/presets.js +6 -0
- package/dist/schemas/validation/presets.js.map +7 -0
- package/dist/schemas/validation/relations.d.ts +12 -0
- package/dist/schemas/validation/relations.js +8 -0
- package/dist/schemas/validation/relations.js.map +7 -0
- package/dist/schemas/validation/types.d.ts +817 -0
- package/dist/schemas/validation/types.js +64 -0
- package/dist/schemas/validation/types.js.map +7 -0
- package/dist/schemas/validation/utils.d.ts +76 -0
- package/dist/schemas/validation/utils.js +24 -0
- package/dist/schemas/validation/utils.js.map +7 -0
- package/dist/schemas/validation/validation-registry.d.ts +124 -0
- package/dist/schemas/validation/validation-registry.js +27 -0
- package/dist/schemas/validation/validation-registry.js.map +7 -0
- package/dist/server-errors/from-json-api-errors.d.ts +13 -0
- package/dist/server-errors/from-json-api-errors.js +10 -0
- package/dist/server-errors/from-json-api-errors.js.map +7 -0
- package/dist/server-errors/from-problem-details.d.ts +15 -0
- package/dist/server-errors/from-problem-details.js +10 -0
- package/dist/server-errors/from-problem-details.js.map +7 -0
- package/dist/server-errors/index.d.ts +8 -0
- package/dist/server-errors/index.js +17 -0
- package/dist/server-errors/index.js.map +7 -0
- package/dist/server-errors/shared.d.ts +34 -0
- package/dist/server-errors/shared.js +23 -0
- package/dist/server-errors/shared.js.map +7 -0
- package/dist/state-container/create-form-state-container.d.ts +17 -0
- package/dist/state-container/create-form-state-container.js +31 -0
- package/dist/state-container/create-form-state-container.js.map +7 -0
- package/dist/state-container/dirty.d.ts +11 -0
- package/dist/state-container/dirty.js +9 -0
- package/dist/state-container/dirty.js.map +7 -0
- package/dist/state-container/field-array.d.ts +41 -0
- package/dist/state-container/field-array.js +8 -0
- package/dist/state-container/field-array.js.map +7 -0
- package/dist/state-container/hydration.d.ts +21 -0
- package/dist/state-container/hydration.js +11 -0
- package/dist/state-container/hydration.js.map +7 -0
- package/dist/state-container/index.d.ts +16 -0
- package/dist/state-container/index.js +51 -0
- package/dist/state-container/index.js.map +7 -0
- package/dist/state-container/issue-text.d.ts +11 -0
- package/dist/state-container/issue-text.js +6 -0
- package/dist/state-container/issue-text.js.map +7 -0
- package/dist/state-container/row-ids.d.ts +34 -0
- package/dist/state-container/row-ids.js +19 -0
- package/dist/state-container/row-ids.js.map +7 -0
- package/dist/state-container/selectors.d.ts +33 -0
- package/dist/state-container/selectors.js +22 -0
- package/dist/state-container/selectors.js.map +7 -0
- package/dist/state-container/stale-results.d.ts +28 -0
- package/dist/state-container/stale-results.js +9 -0
- package/dist/state-container/stale-results.js.map +7 -0
- package/dist/state-container/state-tree.d.ts +56 -0
- package/dist/state-container/state-tree.js +33 -0
- package/dist/state-container/state-tree.js.map +7 -0
- package/dist/state-container/submission.d.ts +45 -0
- package/dist/state-container/submission.js +26 -0
- package/dist/state-container/submission.js.map +7 -0
- package/dist/state-container/types.d.ts +404 -0
- package/dist/state-container/types.js +6 -0
- package/dist/state-container/types.js.map +7 -0
- package/dist/state-container/value-tree.d.ts +56 -0
- package/dist/state-container/value-tree.js +34 -0
- package/dist/state-container/value-tree.js.map +7 -0
- package/dist/testing/assert.d.ts +92 -0
- package/dist/testing/assert.js +42 -0
- package/dist/testing/assert.js.map +7 -0
- package/dist/testing/form-state-container-conformance.d.ts +63 -0
- package/dist/testing/form-state-container-conformance.js +44 -0
- package/dist/testing/form-state-container-conformance.js.map +7 -0
- package/dist/testing/index.d.ts +8 -0
- package/dist/testing/index.js +36 -0
- package/dist/testing/index.js.map +7 -0
- package/dist/types/actions.d.ts +75 -0
- package/dist/types/actions.js +1 -0
- package/dist/types/actions.js.map +7 -0
- package/dist/types/categories.d.ts +21 -0
- package/dist/types/categories.js +8 -0
- package/dist/types/categories.js.map +7 -0
- package/dist/types/define-element.d.ts +73 -0
- package/dist/types/define-element.js +8 -0
- package/dist/types/define-element.js.map +7 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.js +17 -0
- package/dist/types/index.js.map +7 -0
- package/dist/types/metadata.d.ts +14 -0
- package/dist/types/metadata.js +1 -0
- package/dist/types/metadata.js.map +7 -0
- package/dist/types/registration.d.ts +142 -0
- package/dist/types/registration.js +1 -0
- package/dist/types/registration.js.map +7 -0
- package/package.json +113 -3
- package/skill/SKILL.md +79 -0
- package/skill/reference/forms-actions.md +51 -0
- package/skill/reference/forms-submission.md +44 -0
- package/skill/reference/forms-validation.md +91 -0
- package/skill/reference/forms.md +180 -0
package/package.json
CHANGED
|
@@ -1,6 +1,116 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schema-engine/forms",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.5.1",
|
|
5
|
+
"description": "The forms domain of Schema Engine: JSON forms with elements, validation, constraints, steps, form state and submission, with no renderer",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"schema-engine",
|
|
8
|
+
"forms",
|
|
9
|
+
"json",
|
|
10
|
+
"validation",
|
|
11
|
+
"wizard",
|
|
12
|
+
"standard-schema"
|
|
13
|
+
],
|
|
14
|
+
"author": "Andrea Zanenghi",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/schema-engine/schema-engine.git",
|
|
19
|
+
"directory": "packages/forms"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": "^24.22.0 || >=26.0.0"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://schema-engine.com/docs/forms/overview",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"main": "dist/index.js",
|
|
30
|
+
"module": "dist/index.js",
|
|
31
|
+
"types": "dist/index.d.ts",
|
|
32
|
+
"files": [
|
|
33
|
+
"/dist/*",
|
|
34
|
+
"/skill"
|
|
35
|
+
],
|
|
36
|
+
"lint-staged": {
|
|
37
|
+
"**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}": [
|
|
38
|
+
"oxlint",
|
|
39
|
+
"prettier --write"
|
|
40
|
+
],
|
|
41
|
+
"**/*.{json,jsonc,md,yml,yaml}": [
|
|
42
|
+
"prettier --write"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"effect": "^3.22.1",
|
|
47
|
+
"esbuild": "^0.27.0",
|
|
48
|
+
"tsc-alias": "^1.8.16",
|
|
49
|
+
"typescript": "^5.9.3",
|
|
50
|
+
"valibot": "^1.4.2",
|
|
51
|
+
"vitest": "^5.1.1",
|
|
52
|
+
"yaml": "2.9.1",
|
|
53
|
+
"@schema-engine/scripts": "0.0.0"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@ecopages/logger": "^0.2.3",
|
|
57
|
+
"@standard-schema/spec": "^1.1.0",
|
|
58
|
+
"@schema-engine/actions": "^0.5.1",
|
|
59
|
+
"@schema-engine/registry": "^0.5.1",
|
|
60
|
+
"@schema-engine/layout": "^0.5.1"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"zod": "^4.0.17"
|
|
64
|
+
},
|
|
65
|
+
"exports": {
|
|
66
|
+
"./package.json": {
|
|
67
|
+
"import": "./package.json"
|
|
68
|
+
},
|
|
69
|
+
".": {
|
|
70
|
+
"types": "./dist/index.d.ts",
|
|
71
|
+
"import": "./dist/index.js"
|
|
72
|
+
},
|
|
73
|
+
"./browser": {
|
|
74
|
+
"types": "./dist/browser/index.d.ts",
|
|
75
|
+
"import": "./dist/browser/index.js"
|
|
76
|
+
},
|
|
77
|
+
"./state-container": {
|
|
78
|
+
"types": "./dist/state-container/index.d.ts",
|
|
79
|
+
"import": "./dist/state-container/index.js"
|
|
80
|
+
},
|
|
81
|
+
"./csrf": {
|
|
82
|
+
"types": "./dist/csrf/index.d.ts",
|
|
83
|
+
"import": "./dist/csrf/index.js"
|
|
84
|
+
},
|
|
85
|
+
"./server-errors": {
|
|
86
|
+
"types": "./dist/server-errors/index.d.ts",
|
|
87
|
+
"import": "./dist/server-errors/index.js"
|
|
88
|
+
},
|
|
89
|
+
"./testing": {
|
|
90
|
+
"types": "./dist/testing/index.d.ts",
|
|
91
|
+
"import": "./dist/testing/index.js"
|
|
92
|
+
},
|
|
93
|
+
"./recipes": {
|
|
94
|
+
"types": "./dist/recipes/index.d.ts",
|
|
95
|
+
"import": "./dist/recipes/index.js"
|
|
96
|
+
},
|
|
97
|
+
"./recipes/built-in": {
|
|
98
|
+
"types": "./dist/recipes/built-in.d.ts",
|
|
99
|
+
"import": "./dist/recipes/built-in.js"
|
|
100
|
+
},
|
|
101
|
+
"./agent-tool": {
|
|
102
|
+
"types": "./dist/agent-tool/index.d.ts",
|
|
103
|
+
"import": "./dist/agent-tool/index.js"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"scripts": {
|
|
107
|
+
"build:lib": "pnpm clean && pnpm build:files && pnpm build:types",
|
|
108
|
+
"build:files": "node ./build.ts",
|
|
109
|
+
"build:types": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
110
|
+
"watch:lib": "node ./build.ts --watch",
|
|
111
|
+
"clean": "rm -rf ./dist",
|
|
112
|
+
"test:all": "vitest run",
|
|
113
|
+
"lint-staged": "lint-staged",
|
|
114
|
+
"check-types": "tsc --noEmit"
|
|
115
|
+
}
|
|
6
116
|
}
|
package/skill/SKILL.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: schema-engine
|
|
3
|
+
description: |
|
|
4
|
+
Schema Engine is a common language for declarative interfaces: registrations
|
|
5
|
+
keyed by `$type`, actions that run in sequences, documents that are plain
|
|
6
|
+
data, and rendering from that data. Forms is its first domain. Use this
|
|
7
|
+
skill when an agent is asked to build, configure, validate, submit or extend
|
|
8
|
+
anything with @schema-engine/registry, @schema-engine/actions,
|
|
9
|
+
@schema-engine/layout, @schema-engine/forms, @schema-engine/forms-react or
|
|
10
|
+
@schema-engine/forms-radiant, or to write a form widget for React or Radiant.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Schema Engine
|
|
14
|
+
|
|
15
|
+
Schema Engine is one grammar for interfaces that are described as data. A team registers the pieces (elements, actions, rules, appearance axes) under a `$type`, and a document, plain JSON or YAML, names them. The engine checks the document against the registrations and the renderer draws what passed. Forms is the first domain: a framework-free engine owns validation, state and submission, and a renderer (React or Radiant) only draws the fields and bridges the user's controls into that state.
|
|
16
|
+
|
|
17
|
+
This file is the router. It defines the concepts once; the references assume them and never repeat them. Read a reference only when the task needs it.
|
|
18
|
+
|
|
19
|
+
## Core concepts
|
|
20
|
+
|
|
21
|
+
- **registration**: `{ $type, schema, metadata, ... }`, where `$type` is the stable key, `schema` is any Standard Schema that describes its config, and `metadata` names it. Elements, recipes, actions, validation rules and appearance axes are all registrations.
|
|
22
|
+
- **registry**: a read-only registry, `createRegistry(kind, registrations)` from `@schema-engine/registry`, built once from a list. The last registration of a `$type` wins without a warning, which is how you replace a built-in.
|
|
23
|
+
- **document**: serializable data whose every node names a registration by `$type`. It is checked against the registrations at the boundary, so what is rendered or run has passed its schema.
|
|
24
|
+
- **action**: a registration with `execute` that runs on a trigger. Actions run as a sequence, an inner array is a parallel group, and a failure that sets `shouldContinue: false` stops what follows and cancels the group's siblings through their `signal`.
|
|
25
|
+
|
|
26
|
+
## Forms concepts
|
|
27
|
+
|
|
28
|
+
- **config**: a form is plain data, a `FormConfig` of steps holding elements, each with a `$type`, a `name`, `rules` and `constraints`. `engine.defineForm()` (typed, in TypeScript) or `engine.validateForm(unknown)` (portable JSON) checks it against the engine's registrations and returns a frozen `NormalizedFormConfig` that the engine owns.
|
|
29
|
+
- **container**: the form's state, a `FormStateContainer` from `@schema-engine/forms/state-container`. It owns the nested values, errors, warnings, touched and dirty marks, field-array row ids and the validation in flight. Paths are dotted (`contacts.1.email`) and `FORM_ROOT` is the form itself. Every change is a command (`setValue`, `blur`, `reportNative`, `validate`, `submit`, `reset`, `fieldArray`), and every read is a pure selector over an immutable snapshot.
|
|
30
|
+
- **runtime**: `createFormRuntime` is the lifecycle every renderer shares. It builds the container and owns the submission, the wizard steps and their navigation, `form_mount` and `form_change`, and every action dispatch. A renderer supplies only what an element can do, such as focus.
|
|
31
|
+
- **issues and the formatter**: the engine reports what is wrong as an issue (`type`, `source`, `ruleId`, `params`, `message`) and never makes up text. `formatIssue`, a function of the application, turns an issue into the words shown, and falls back to the issue's own `message`.
|
|
32
|
+
|
|
33
|
+
Outcomes use one vocabulary: a check or a submission ends `passed`, `invalid` or `overtaken`. `overtaken` means an edit or a reset outran the check, so there is no verdict and nothing to show.
|
|
34
|
+
|
|
35
|
+
## Packages
|
|
36
|
+
|
|
37
|
+
| Package | Role |
|
|
38
|
+
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
39
|
+
| `@schema-engine/registry` | The registration contract and read-only registries every package builds on, and `/yaml` for documents authored as YAML. Ships this router |
|
|
40
|
+
| `@schema-engine/actions` | Actions: `parseActions`, and a dispatcher that runs a sequence with parallel groups, cancellation and results |
|
|
41
|
+
| `@schema-engine/layout` | Domain-neutral grid, appearance axes, layout themes and the recipe protocol |
|
|
42
|
+
| `@schema-engine/forms` | The forms engine: config, validation, constraints, the container, the runtime |
|
|
43
|
+
| `@schema-engine/forms-react` | React renderer: `FormRenderer` and the hooks. You write the widgets; ready-made ones come from the optional shadcn registry |
|
|
44
|
+
| `@schema-engine/forms-radiant` | Radiant renderer: `se-form-instance`, `FormController`, widgets and recipes in the package |
|
|
45
|
+
|
|
46
|
+
A symbol has one import path. `@schema-engine/forms` has these entries: `.` (the engine, the runtime and the types), `/state-container` (the container and its selectors), `/csrf`, `/server-errors`, `/recipes`, `/recipes/built-in`, `/browser` (browser-side actions such as auto-save), `/testing` (conformance suites; they need vitest) and `/agent-tool` (experimental).
|
|
47
|
+
|
|
48
|
+
## To do X, read Y
|
|
49
|
+
|
|
50
|
+
Each package ships this router as its own `skill/SKILL.md` and its references in its `skill/reference/` folder, so a reference is `node_modules/@schema-engine/<package>/skill/reference/<file>`, and any installed package has the router. Read the rows of the packages the project depends on and skip the others: a package that is not installed has no file. The deployed site serves the latest version of the router and of every reference at `/skill/`, with the references flat at `/skill/reference/<file>`.
|
|
51
|
+
|
|
52
|
+
| To do | Package | Reference |
|
|
53
|
+
| ---------------------------------------------------------------------------- | ------------------------------ | ------------------------------------ |
|
|
54
|
+
| Register something, build a registry, or read a YAML document | `@schema-engine/registry` | `reference/registry.md` |
|
|
55
|
+
| Parse, dispatch or cancel actions outside a form | `@schema-engine/actions` | `reference/actions.md` |
|
|
56
|
+
| Build a grid, an appearance axis or a layout theme | `@schema-engine/layout` | `reference/layout.md` |
|
|
57
|
+
| Create an engine, author a config, use the container or the runtime directly | `@schema-engine/forms` | `reference/forms.md` |
|
|
58
|
+
| Add a rule, explain a validation result, or translate messages | `@schema-engine/forms` | `reference/forms-validation.md` |
|
|
59
|
+
| Handle submit, server errors, CSRF or wizard steps | `@schema-engine/forms` | `reference/forms-submission.md` |
|
|
60
|
+
| Run code on a form event, or define a form action | `@schema-engine/forms` | `reference/forms-actions.md` |
|
|
61
|
+
| Render a form in React, or use its hooks | `@schema-engine/forms-react` | `reference/forms-react.md` |
|
|
62
|
+
| Write or change a React field widget, and test it | `@schema-engine/forms-react` | `reference/forms-react-widgets.md` |
|
|
63
|
+
| Render a form in Radiant, or reach the container from an element | `@schema-engine/forms-radiant` | `reference/forms-radiant.md` |
|
|
64
|
+
| Write or change a Radiant field widget, and test it | `@schema-engine/forms-radiant` | `reference/forms-radiant-widgets.md` |
|
|
65
|
+
|
|
66
|
+
## Documentation map
|
|
67
|
+
|
|
68
|
+
The full documentation is at `/docs` on the deployed site. The LLM-exported corpus is `/llms.txt` (index) and `/docs-llm/<section>/<slug>.md` (page bodies).
|
|
69
|
+
|
|
70
|
+
| Section | Path prefix |
|
|
71
|
+
| ------------------------------ | ---------------------------------- |
|
|
72
|
+
| Schema Engine | `/docs/schema-engine/introduction` |
|
|
73
|
+
| `@schema-engine/registry` | `/docs/registry/overview` |
|
|
74
|
+
| `@schema-engine/actions` | `/docs/actions/overview` |
|
|
75
|
+
| `@schema-engine/forms` | `/docs/forms/overview` |
|
|
76
|
+
| `@schema-engine/forms-react` | `/docs/forms-react/overview` |
|
|
77
|
+
| `@schema-engine/forms-radiant` | `/docs/forms-radiant/overview` |
|
|
78
|
+
| `@schema-engine/layout` | `/docs/layout/overview` |
|
|
79
|
+
| Examples | `/docs/examples/overview` |
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Actions in a form
|
|
2
|
+
|
|
3
|
+
Code that runs on a form event. The runtime runs a form's actions with the dispatcher of `@schema-engine/actions` (`actions.md`), which owns sequences, parallel groups, cancellation and results. The runtime and the submission sequence are in `forms.md` and `forms-submission.md`.
|
|
4
|
+
|
|
5
|
+
## An action
|
|
6
|
+
|
|
7
|
+
An action is a registration, `{ $type, schema, metadata, execute }`, written with `defineAction<BuilderActionBaseContext, FormActionTrigger>()` (`actions.md` explains `defineAction`), and an instance in the config, `{ $type, id, ...config, triggers? }`. `schema` is any Standard Schema and describes the action's own arguments: the engine checks `id`, `$type`, `enabled` and `triggers` (a form trigger name) itself, so a schema never lists them. `metadata.defaultTriggers` says when it runs unless the instance sets its own `triggers`. `execute` receives the form's context, with the instance as `config`, and returns `{ success, message?, error?, data?, shouldContinue? }`; `shouldContinue: false` stops the sequence. Register it in `createFormEngine({ actions })`. The engine checks the `actions` of a form and of a step against the registered schemas when it validates the form (`defineForm`, `validateForm`): a bad action is a config issue whose path is the owner's `actions`, the index of the entry (and of the member, in a group), then the path the action's schema reported, and only checked actions reach the dispatcher.
|
|
8
|
+
|
|
9
|
+
```ts title="forms/notify-action.ts"
|
|
10
|
+
import * as z from 'zod/mini';
|
|
11
|
+
import { defineAction, type ActionConfigBase } from '@schema-engine/actions';
|
|
12
|
+
import { createFormEngine, type BuilderActionBaseContext, type FormActionTrigger } from '@schema-engine/forms';
|
|
13
|
+
import { textRegistration } from './engine';
|
|
14
|
+
|
|
15
|
+
const defineFormAction = defineAction<BuilderActionBaseContext, FormActionTrigger>();
|
|
16
|
+
|
|
17
|
+
interface NotifyConfig extends ActionConfigBase<'notify'> {
|
|
18
|
+
channel: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const notifyAction = defineFormAction<NotifyConfig>({
|
|
22
|
+
$type: 'notify',
|
|
23
|
+
schema: z.object({ channel: z.string() }),
|
|
24
|
+
metadata: { name: 'Notify', defaultTriggers: ['form_submit'] },
|
|
25
|
+
execute: async ({ config, formData, fetch }) => {
|
|
26
|
+
const response = await fetch('/api/notify', {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
body: JSON.stringify({ channel: config.channel, formData }),
|
|
29
|
+
});
|
|
30
|
+
return response.ok ? { success: true } : { success: false, error: `Notify failed with ${response.status}` };
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const notifyEngine = createFormEngine({ elements: [textRegistration], actions: [notifyAction] });
|
|
35
|
+
|
|
36
|
+
export const notifyForm = notifyEngine.defineForm({
|
|
37
|
+
id: 'notify',
|
|
38
|
+
steps: [{ id: 'main', title: 'Main', elements: [{ $type: 'text', name: 'email' }] }],
|
|
39
|
+
actions: [{ $type: 'notify', id: 'notify-ops', channel: 'ops' }],
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Triggers
|
|
44
|
+
|
|
45
|
+
`form_mount`, `form_change`, `form_submit_start`, `form_submit`, `form_submit_success`, `form_submit_error`, `form_submit_complete`, `step_leave`, `step_change` and `step_enter`. Form-level `actions` are dispatched on every trigger, and an action runs when the trigger is one of its own; a step's own `actions` are dispatched too while that step is current. `actions` is a sequence: an inner array is a parallel group that starts together and joins before the next entry.
|
|
46
|
+
|
|
47
|
+
The step triggers fire only when the current step changes, and a reset fires none. Step and mount actions cannot block anything, and their failures reach `onActionResults`. The submit actions run after validation passed and before `onSubmit`. A submit action that fails with `shouldContinue: false` stops the ones after it and fails the submission. One that fails without it is reported and the rest still run, and `onSubmit` still runs.
|
|
48
|
+
|
|
49
|
+
## The context
|
|
50
|
+
|
|
51
|
+
The context carries the values (`formData`), the step (`stepId`, `currentStep`, `totalSteps`), `isValid` and `errors` by dotted path, `fetch` (the engine's, with the CSRF policy applied), an abort `signal` (observe it in a long handler, as `actions.md` explains) and `form`: `reset()`, `setValue(name, value)`, `getValue(name)`, `validate()` (resolving `{ outcome }`, as the container's does) and `checkValidity()` (a boolean). Use `context.fetch` for every request an action makes.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Submission
|
|
2
|
+
|
|
3
|
+
What happens between the submit button and the server, and how the server's answer comes back. The container and the runtime are in `forms.md`.
|
|
4
|
+
|
|
5
|
+
## The sequence
|
|
6
|
+
|
|
7
|
+
On the last active step a submit validates every active step, then runs the `form_submit_start` and `form_submit` actions, then `onSubmit`, then `form_submit_success` or `form_submit_error`, then `form_submit_complete`. `onSubmit(values, helpers)` runs unless a submit action failed with `shouldContinue: false`, and a rejection fails the submission; why it failed is in `snapshot.submission.failures`, as issues the formatter words. `values` are what passed, without the fields that took no part and without any key no field declares, with the config's `payload`. The values the derived schema returns are frozen; with `validateForm(json, { values })` they are the application schema's output, exactly as it returns it. After validation passes and before the actions, the runtime parses them with `engine.submissionSchema(config)`, the schema composed from each input's `value` declaration (and then with your own schema when the form was bound with `engine.validateForm(json, { values })`); a mismatch is a broken element, not a user error, so the submission fails with a `valueMismatch` issue at its path, is logged, and `onSubmit` is not called. A key is required in that schema only when its field has a `required` rule and nothing around it has `constraints` or `disabled`; an optional leaf field's empty value (`''` or `null`) is submitted as it is (a list or a group has none: its empty value is its empty list or object). `engine.defineForm` of a literal config types `onSubmit`, `onAction` and `defaultValues` from the config, and a JSON config gets `FormValues` or the output of its `values` schema.
|
|
8
|
+
|
|
9
|
+
## onSubmit, server errors and CSRF
|
|
10
|
+
|
|
11
|
+
`helpers.fetch` is the engine's `fetch` with its CSRF policy applied, so send the values with it and add no token yourself. `helpers.setServerErrors` shows the server's answer to this submission on the fields it names; `FORM_ROOT` stands for the form. Paths are those of `values`, an error is dropped when its row is gone, and it is cleared when its path (or a path its rules read) is edited. Two helpers turn a response into that input: `fromProblemDetails` (RFC 9457 with the `errors[]` extension) and `fromJsonApiErrors`. They throw a `ServerErrorsInputError` for a shape they do not know rather than guess.
|
|
12
|
+
|
|
13
|
+
`csrf.fromMeta`, `csrf.fromCookie` and `csrf.custom` build the policy. The token is read when a request is made and never kept. It goes as `header` on a same-origin `POST`, `PUT`, `PATCH` or `DELETE` made with the engine's `fetch`, and as a hidden `field` input in a native post.
|
|
14
|
+
|
|
15
|
+
```ts title="forms/submission.ts"
|
|
16
|
+
import { createFormEngine, type FormSubmitHelpers, type FormValues } from '@schema-engine/forms';
|
|
17
|
+
import { csrf } from '@schema-engine/forms/csrf';
|
|
18
|
+
import { fromProblemDetails } from '@schema-engine/forms/server-errors';
|
|
19
|
+
import { textRegistration } from './engine';
|
|
20
|
+
|
|
21
|
+
export const csrfEngine = createFormEngine({
|
|
22
|
+
elements: [textRegistration],
|
|
23
|
+
csrf: csrf.fromMeta('csrf-token', { header: 'x-csrf-token', field: '_csrf' }),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export async function onSubmit(values: FormValues, { fetch, setServerErrors }: FormSubmitHelpers) {
|
|
27
|
+
const response = await fetch('/api/contact', {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
headers: { 'content-type': 'application/json' },
|
|
30
|
+
body: JSON.stringify(values),
|
|
31
|
+
});
|
|
32
|
+
if (!response.ok) setServerErrors(fromProblemDetails(await response.json()));
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
An error set on an earlier step moves the wizard there. An error is applied only while it is the latest submission and no reset came between, so a late answer to an old submission does nothing.
|
|
37
|
+
|
|
38
|
+
## Outcomes
|
|
39
|
+
|
|
40
|
+
A submit command resolves `submitted`, `failed`, `invalid` (errors are shown and focused), `overtaken` (no verdict: show and focus nothing), `moved` or `refused` (a submit before the last step acts as `next()`: `moved` when it changed the step, `refused` when there is nowhere to go), `busy` or `cancelled`. Treat `overtaken` as "ask again", never as a failed field.
|
|
41
|
+
|
|
42
|
+
## Wizard steps
|
|
43
|
+
|
|
44
|
+
A form of several steps is a wizard. `next()` validates the current step and moves to the next active one (`refused` on the last), `back()` never validates, and `goTo(id)` refuses a skipped or unknown step, always allows going back and, going forward, follows `navigation`: `linear` needs the target visited and validates every step on the way, `free` reaches any active step. Submitting before the last step acts as `next()`. A step the answers skip is passed over by `next` and `back`, and its values are kept but not submitted. A reset returns the form to its first step with an idle submission and fires no step trigger; a submission whose values were already captured (`submitting`) is committed, runs to its end and publishes its outcome after the reset.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Validation and issues
|
|
2
|
+
|
|
3
|
+
Writing rules, reading what a check found, and putting it into words. Timing (`validationMode`) is in `forms.md`; the issue and the formatter are defined in the router (`SKILL.md`).
|
|
4
|
+
|
|
5
|
+
## Rules
|
|
6
|
+
|
|
7
|
+
A rule is an object in an element's `rules`. Every rule takes `message` (the fallback text), `id` (the author's stable name, which becomes the issue's `ruleId`) and `severity` (`error`, the default, or `warning`). The built-in types are `required`, `minLength`, `maxLength`, `min`, `max`, `minItems`, `maxItems`, `pattern`, `email`, `phone`, `url`, `uuid`, `ipv4`, `ipv6`, `cidr`, `jwt`, `hash`, `base64`, `cuid`, `cuid2`, `ulid`, `hex`, `datetime`, `date`, `time`, plus `async` (asks an endpoint, through the engine's `fetch`) and `relate` (compares with another field). The property is `rules`, not `validation`.
|
|
8
|
+
|
|
9
|
+
The config in `forms.md` has a `required` rule with an `id`, an `email` rule with a `message` and a `warning` rule.
|
|
10
|
+
|
|
11
|
+
A rule reports one issue however many checks its schema runs. A `warning` goes to `warnings`, has the shape of an error and never changes `isValid`, `validate` or `checkValidity`. A custom rule is a registration passed as `validations` (`$type`, `schema`, `metadata`, `category`, `handler`). The handler returns the Zod Mini schema that checks the value; the issue's `type` is the rule's type and its `message` is the one the author wrote on the rule. The last `$type` wins, so a registration can replace a built-in rule. An element that extends `BaseFieldSchema` accepts a rule of any registered `$type` in its `rules`: the engine checks the rule against the registration's `schema` when it validates the form, and rejects a `$type` nothing registers, so there is nothing to widen. The registration's `schema` owns the rule's options, so one that replaces a built-in decides that rule's options, and the JSON Schema export lists each registered rule with them when its schema is Zod (by its `type` only otherwise).
|
|
12
|
+
|
|
13
|
+
```ts title="forms/custom-rule.ts"
|
|
14
|
+
import * as z from 'zod/mini';
|
|
15
|
+
import { createFormEngine, defineInput, BaseFieldSchema, type ValidationRegistration } from '@schema-engine/forms';
|
|
16
|
+
|
|
17
|
+
type PostalCodeRule = { $type: 'postalCode'; message?: string };
|
|
18
|
+
|
|
19
|
+
export const postalCode: ValidationRegistration<PostalCodeRule> = {
|
|
20
|
+
$type: 'postalCode',
|
|
21
|
+
schema: z.looseObject({ $type: z.literal('postalCode') }),
|
|
22
|
+
metadata: { name: 'Postal code' },
|
|
23
|
+
category: 'string',
|
|
24
|
+
handler: () => z.string().check(z.regex(/^\d{5}(?:-\d{4})?$/)),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const addressTextRegistration = defineInput({
|
|
28
|
+
$type: 'text',
|
|
29
|
+
schema: z.extend(BaseFieldSchema, { $type: z.literal('text') }),
|
|
30
|
+
metadata: { name: 'Text', category: 'input' },
|
|
31
|
+
value: () => z.string(),
|
|
32
|
+
render: () => null,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const addressEngine = createFormEngine({ elements: [addressTextRegistration], validations: [postalCode] });
|
|
36
|
+
|
|
37
|
+
export const addressForm = addressEngine.defineForm({
|
|
38
|
+
id: 'address',
|
|
39
|
+
steps: [
|
|
40
|
+
{
|
|
41
|
+
id: 'main',
|
|
42
|
+
title: 'Address',
|
|
43
|
+
elements: [
|
|
44
|
+
{ $type: 'text', name: 'postalCode', rules: [{ $type: 'postalCode', message: 'Enter a postal code' }] },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## What an issue says
|
|
52
|
+
|
|
53
|
+
`type` names the problem for a program: a rule's type (`minLength`), a native flag (`typeMismatch`) or the server's code. `source` is `validation`, `native` or `server`. `ruleId` is the rule's `id`. `params` are the serializable numbers and names a text is built from (`{ minLength: 3 }`, under the constraint's own name). `message` is the author's, the server's or the control's text, and may be absent: the schema library's generic text is never used.
|
|
54
|
+
|
|
55
|
+
An error at a path is the issue to show plus `all`, a never-empty list in this order: what the server said, then each failing rule in authored order, then what the platform's own control reports. Errors are never inherited: an error on `contacts` is not an error on `contacts.0.email`. The form's own error is at `FORM_ROOT`.
|
|
56
|
+
|
|
57
|
+
## Native facts
|
|
58
|
+
|
|
59
|
+
A native control (`input`, `select`, `textarea`) also reports its own `validity` to the container as a fact of the path (`valueMissing`, `typeMismatch`, `patternMismatch`, `tooShort`, `tooLong`, `rangeUnderflow`, `rangeOverflow`, `stepMismatch`, `badInput`, and `customError` for a control a script made invalid with `setCustomValidity`), with the constraint as `params`. A fact is tied to the value it described, is dropped when that value changes, follows its row, and is counted by `validate` and `checkValidity`. A rule's error wins the display when both fail. How a control contributes one, or none, is in `forms-react-widgets.md` and `forms-radiant-widgets.md`.
|
|
60
|
+
|
|
61
|
+
## Words and translation
|
|
62
|
+
|
|
63
|
+
The formatter is one function, `FormIssueFormatter = (issue, { path }) => string`. `ruleId` picks the text of one rule, `type` the text of a kind of rule, and `params` fill its numbers. Return an empty string when you have nothing to say and the issue's own `message` is shown. The same formatter words submission failures, with `FORM_ROOT` as the path. It is set once on the engine, and a renderer (`FormRenderer` in React, the instance in Radiant) may override it for one form.
|
|
64
|
+
|
|
65
|
+
```ts title="forms/format-issue.ts"
|
|
66
|
+
import { createFormEngine } from '@schema-engine/forms';
|
|
67
|
+
import type { FormIssueFormatter } from '@schema-engine/forms/state-container';
|
|
68
|
+
import { textRegistration } from './engine';
|
|
69
|
+
|
|
70
|
+
type Text = (params: Readonly<Record<string, unknown>>) => string;
|
|
71
|
+
|
|
72
|
+
const byRuleId: Record<string, Text> = {
|
|
73
|
+
'name-required': () => 'Tell us your name',
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const byType: Record<string, Text> = {
|
|
77
|
+
required: () => 'This field is required',
|
|
78
|
+
minLength: ({ minLength }) => `Use at least ${String(minLength)} characters`,
|
|
79
|
+
taken: () => 'Already taken',
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const formatIssue: FormIssueFormatter = (issue) => {
|
|
83
|
+
const ruleId = issue.source === 'submission' ? undefined : issue.ruleId;
|
|
84
|
+
const text = byRuleId[ruleId ?? ''] ?? byType[issue.type];
|
|
85
|
+
return text?.(issue.params ?? {}) ?? '';
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const localizedEngine = createFormEngine({ elements: [textRegistration], formatIssue });
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
A field can be `invalid` with no text to show, when nothing says what is wrong in words, so a widget marks itself invalid from the flag and not from the text.
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# @schema-engine/forms
|
|
2
|
+
|
|
3
|
+
The engine, the config, validation timing, constraints, the container and the runtime. The terms are defined in the router (`SKILL.md`).
|
|
4
|
+
|
|
5
|
+
## Engine
|
|
6
|
+
|
|
7
|
+
`createFormEngine` takes `elements`, `recipes`, `actions`, `validations` (extra rules), `layout`, `formatIssue`, `fetch` and `csrf`. It builds read-only registries (a later `$type` replaces an earlier one) and returns an immutable engine: create it once and reuse it. `engine.extend({ ... })` adds registrations and inherits the layout theme. The package ships no field widgets; an element is registered with `defineInput({ $type, schema, metadata, value, render })` (see Registrations below), and renderer packages bring the widgets.
|
|
8
|
+
|
|
9
|
+
```ts title="forms/engine.ts"
|
|
10
|
+
import * as z from 'zod/mini';
|
|
11
|
+
import { createFormEngine, defineInput, BaseFieldSchema } from '@schema-engine/forms';
|
|
12
|
+
|
|
13
|
+
export const textRegistration = defineInput({
|
|
14
|
+
$type: 'text',
|
|
15
|
+
schema: z.extend(BaseFieldSchema, { $type: z.literal('text') }),
|
|
16
|
+
metadata: { name: 'Text', category: 'input' },
|
|
17
|
+
value: () => z.string(),
|
|
18
|
+
render: () => null,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const engine = createFormEngine({ elements: [textRegistration] });
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Registrations
|
|
25
|
+
|
|
26
|
+
You register with `createFormEngine({ elements, recipes, actions, validations })`: the engine builds one read-only registry of each from the lists, on `@schema-engine/registry`.
|
|
27
|
+
|
|
28
|
+
```ts title="forms/registry.ts"
|
|
29
|
+
import { createFormEngine } from '@schema-engine/forms';
|
|
30
|
+
import { postalCode } from './custom-rule';
|
|
31
|
+
import { textRegistration } from './engine';
|
|
32
|
+
|
|
33
|
+
export const appEngine = createFormEngine({ elements: [textRegistration], validations: [postalCode] });
|
|
34
|
+
|
|
35
|
+
export const elementTypes = appEngine.getAllElements().map(({ $type }) => $type);
|
|
36
|
+
|
|
37
|
+
export const ruleTypes = appEngine.getValidationRegistry().keys();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Registrations are stored by `$type`, and a later one replaces an earlier one with no warning, so a list ending in your own replaces a built-in. A schema that is not a Standard Schema (no `~standard.validate`) throws at build, naming the kind and the `$type`. The registries are read-only and frozen, and the objects you passed are left untouched, so there is no `register` or `clear` after the build. A registry of your own, outside a form engine, is in `registry.md`.
|
|
41
|
+
|
|
42
|
+
Every registration is `{ $type, schema, metadata }` (an element also has a `kind`, `'input'` or `'static'`, which `defineInput` and `defineStatic` set and a registration written by hand must state): `$type` is the stable key, `schema` is any Standard Schema (Zod, Zod Mini, Valibot, Effect Schema or a hand-written one) that describes the config, and `metadata` has a `name` and optionally a `description`, `icon`, `tags` and `version`. A renderable one adds `render`; an action adds `execute`; a validation rule adds `category` and `handler`.
|
|
43
|
+
|
|
44
|
+
The engine builds four registries from `createFormEngine`: `elements` (`defineInput` for a field, `defineStatic` for display-only content), `recipes`, `actions` and `validations`. `elements` and `recipes` are for the renderer, `actions` for the runtime and `validations` for the container. Authors supply the schema's input and renderers receive its output, so register elements with `defineInput` (which also takes the `value` the control writes) and `defineStatic`, which keep the two apart.
|
|
45
|
+
|
|
46
|
+
The engine lists what it holds with `getAllElements()`, `getAllRecipes()` and `getAllActions()`, looks one up with `getElement($type)`, `getRecipe($type)` and `getAction($type)`, and exposes its rules as `getValidationRegistry()`, itself a read-only registry. `engine.generateFormConfigSchema()` exports a JSON Schema of the form config for editors and other tools. The engine never changes after it is built: `engine.extend({ ... })` returns a new one.
|
|
47
|
+
|
|
48
|
+
### Registering a widget
|
|
49
|
+
|
|
50
|
+
A widget is a registration, `defineInput({ $type, schema, metadata, value, render })`, and the schema is the widget's config: `z.extend(BaseFieldSchema, { $type: z.literal('...'), ...yours })`. `defineInput` keeps the schema's input and output apart, so authors write the input and `render` receives the output with defaults applied. `value` declares what the control writes, as a function of the configured element that returns a Standard Schema (a rating's `max` is its bound; a select's options are an enum): `defineInput` requires it, the engine checks every submission against it, and the type of `onSubmit` comes from it. The control writes exactly what it declares (a number option is a number, not its text), and a control that writes something else fails the submission with a `valueMismatch` issue at its path. A container widget declares `elements: elementChildrenSchema`, no `value` (its value is its children's), and renders its children with `FormElements`, which composes the paths at render time. A display-only element uses `defineStatic` and declares none. Writing the `render` function is in `forms-react-widgets.md` and `forms-radiant-widgets.md`.
|
|
51
|
+
|
|
52
|
+
## Config
|
|
53
|
+
|
|
54
|
+
Authors supply schema input, so defaults stay optional; renderers receive schema output. `defineForm` and `validateForm` run one pipeline and throw a `FormValidationError` on an invalid form; `engine.safeValidateForm(json)` returns `{ success, data | issues }` with the config `path` of each issue. A step needs an `id` and a `title`.
|
|
55
|
+
|
|
56
|
+
```ts title="forms/contact-form.ts"
|
|
57
|
+
import { engine } from './engine';
|
|
58
|
+
|
|
59
|
+
export const contactForm = engine.defineForm({
|
|
60
|
+
id: 'contact',
|
|
61
|
+
validationMode: 'onBlur',
|
|
62
|
+
steps: [
|
|
63
|
+
{
|
|
64
|
+
id: 'details',
|
|
65
|
+
title: 'Details',
|
|
66
|
+
elements: [
|
|
67
|
+
{
|
|
68
|
+
$type: 'text',
|
|
69
|
+
name: 'name',
|
|
70
|
+
rules: [{ $type: 'required', id: 'name-required', message: 'Name is required' }],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
$type: 'text',
|
|
74
|
+
name: 'email',
|
|
75
|
+
rules: [{ $type: 'required' }, { $type: 'email', message: 'Not an email' }],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
$type: 'text',
|
|
79
|
+
name: 'nickname',
|
|
80
|
+
rules: [{ $type: 'minLength', value: 3, severity: 'warning', id: 'nickname-short' }],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
$type: 'text',
|
|
84
|
+
name: 'company',
|
|
85
|
+
constraints: [{ field: 'email', operator: 'contains', value: '@example.com', $type: 'hide' }],
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Form-level keys: `view` (a registered recipe, optional for a one-step form), `validationMode`, `reValidateMode`, `navigation` (`linear` or `free`), `payload`, `actions`, `grid` and `appearance`. A multi-step form with no `view` gets the engine's default wizard recipe.
|
|
94
|
+
|
|
95
|
+
## Validation timing
|
|
96
|
+
|
|
97
|
+
`validationMode` says when a field validates before a check of it has failed: `onSubmit` (default), `onChange`, `onBlur`, `onTouched` (the first blur, then every change) or `all`. `reValidateMode` (`onChange` default, `onBlur`, `onSubmit`) says when it validates once a check of it has failed. Writing the rules is in `forms-validation.md`.
|
|
98
|
+
|
|
99
|
+
## Constraints
|
|
100
|
+
|
|
101
|
+
A constraint is `{ field, operator, value, $type }` on an element, where `field` names a sibling (resolved from where the element is rendered, so inside `contacts.0.email` it means `contacts.0.<field>`).
|
|
102
|
+
|
|
103
|
+
- `operator`: `equals`, `not_equals`, `contains`, `not_contains`, `greater_than`, `less_than`, `is_empty`, `is_not_empty`.
|
|
104
|
+
- `$type`: `show`, `hide`, `enable`, `disable`, `require`.
|
|
105
|
+
|
|
106
|
+
A hidden or disabled field, and every field of a skipped step, takes no part: it is never validated and is left out of the submitted values. A step takes `show` and `hide` constraints on fields of earlier steps. A renderer never evaluates constraints itself: it reads them from the container (`selectFieldState(snapshot, path)` gives `hidden`, `disabled` and `required`).
|
|
107
|
+
|
|
108
|
+
## Container
|
|
109
|
+
|
|
110
|
+
`createFormStateContainer({ config, registry, defaults?, snapshot? })` builds the state of a form with no framework. `config` is the normalized form and `registry` is `engine.getValidationRegistry()`. The runtime and both renderers build theirs for you; build one directly for a server check, a script or a renderer of your own.
|
|
111
|
+
|
|
112
|
+
```ts title="forms/container.ts"
|
|
113
|
+
import { createFormStateContainer } from '@schema-engine/forms/state-container';
|
|
114
|
+
import { contactForm } from './contact-form';
|
|
115
|
+
import { engine } from './engine';
|
|
116
|
+
|
|
117
|
+
export function createContactContainer() {
|
|
118
|
+
return createFormStateContainer({ config: contactForm, registry: engine.getValidationRegistry() });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function submitContact(name: string, email: string) {
|
|
122
|
+
const container = createContactContainer();
|
|
123
|
+
container.setValue('name', name);
|
|
124
|
+
container.setValue('email', email);
|
|
125
|
+
|
|
126
|
+
const result = await container.submit();
|
|
127
|
+
if (result.outcome === 'passed') {
|
|
128
|
+
result.setServerErrors({ email: { type: 'taken' } });
|
|
129
|
+
}
|
|
130
|
+
return { container, result };
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- `validate(paths?)` records the findings and resolves `{ outcome: 'passed' | 'invalid' | 'overtaken' }`. An empty list validates nothing and omitting it validates the form. A check outrun by an edit runs once more over the same rows; only a second outrun, a removed row or a reset is `overtaken`. It rejects with a `FormValidationFailure` when a rule could not run.
|
|
135
|
+
- `checkValidity()` is a boolean for the state at the call. It writes nothing and is never overtaken.
|
|
136
|
+
- `submit()` resolves `{ outcome: 'passed', values, setServerErrors }`, `{ outcome: 'invalid' }` or `{ outcome: 'overtaken' }`. The values are frozen, exclude fields that took no part and carry the config's `payload`.
|
|
137
|
+
- `reportNative(facts)` takes what a platform control says about its value; renderers call it, not application code.
|
|
138
|
+
- `reset(values?)` restores the defaults, or replaces them first, and clears every error, mark and fact.
|
|
139
|
+
- `getSnapshot()` is stable until something changes. Read it with `selectValue` and `selectFieldState` (its `error` is the one of exactly that path), which return the same object while what they read is unchanged, so they are safe for `useSyncExternalStore`.
|
|
140
|
+
- `toHydration(container.getServerSnapshot())` is the serializable part a server hands to a client, which passes it as `snapshot` so row ids survive.
|
|
141
|
+
|
|
142
|
+
## Runtime
|
|
143
|
+
|
|
144
|
+
`createFormRuntime({ engine, config, host, onSubmit, ... })` wraps a container with the submission, the wizard and the actions. `host.focus(paths)` is the only required host member; a renderer adds `sync` and `submitNatively` when it needs them.
|
|
145
|
+
|
|
146
|
+
```ts title="forms/runtime.ts"
|
|
147
|
+
import { createFormRuntime, type FormValues } from '@schema-engine/forms';
|
|
148
|
+
import { notifyEngine, notifyForm } from './notify-action';
|
|
149
|
+
|
|
150
|
+
export function createNotifyRuntime(onSubmit: (values: FormValues) => void) {
|
|
151
|
+
const runtime = createFormRuntime({
|
|
152
|
+
engine: notifyEngine,
|
|
153
|
+
config: notifyForm,
|
|
154
|
+
host: { focus: () => {} },
|
|
155
|
+
onSubmit,
|
|
156
|
+
});
|
|
157
|
+
const unmount = runtime.mount();
|
|
158
|
+
return { runtime, unmount };
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Every command resolves one string: `moved`, `submitted`, `failed`, `invalid`, `overtaken`, `refused`, `busy` or `cancelled`. One lock covers navigation and submission, so a command made while another runs is `busy`, and a reset or `unmount` revokes the one in flight (`cancelled`); a submission whose values were already captured is committed and still completes. `runtime.getSnapshot()` is `{ submission, current, navigating, steps }`, each step with `skipped`, `visited`, `complete` and `invalid`; `runtime.container` is the state. Submitting is in `forms-submission.md`.
|
|
163
|
+
|
|
164
|
+
## Testing a container
|
|
165
|
+
|
|
166
|
+
A container of your own, or a store that must behave like this one, proves it with the conformance suite. It depends on no test runner: pass the `describe` and `test` of yours (Vitest below; Jest, Bun and `node:test` work the same), and import this entry only from a test file.
|
|
167
|
+
|
|
168
|
+
```ts title="forms/container-conformance.test.ts"
|
|
169
|
+
import { describe, test } from 'vitest';
|
|
170
|
+
import { createFormStateContainer } from '@schema-engine/forms/state-container';
|
|
171
|
+
import { formStateContainerConformance } from '@schema-engine/forms/testing';
|
|
172
|
+
|
|
173
|
+
formStateContainerConformance(createFormStateContainer, { describe, test });
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Save your copy as `container-conformance.test.ts`.
|
|
177
|
+
|
|
178
|
+
## Agent tool (experimental)
|
|
179
|
+
|
|
180
|
+
`registerFormAgentTool(runtime, { name, description })` from `@schema-engine/forms/agent-tool` offers a rendered form to a browser agent as a WebMCP tool: the tool's input is the runtime's `submissionSchema`, and calling it fills the form and, with `autoSubmit: true`, submits it. It returns the function that unregisters the tool. WebMCP is an origin trial and the API may change, so nothing else in the package imports it.
|