@schema-engine/forms 0.0.0-stage → 0.5.0
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-2PTM54FQ.js +51 -0
- package/dist/chunk-2PTM54FQ.js.map +7 -0
- package/dist/chunk-2VKEOE2L.js +907 -0
- package/dist/chunk-2VKEOE2L.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-56CJ2UZ7.js +55 -0
- package/dist/chunk-56CJ2UZ7.js.map +7 -0
- package/dist/chunk-5QXT7YAJ.js +87 -0
- package/dist/chunk-5QXT7YAJ.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-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-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-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-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-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-GY657L56.js +206 -0
- package/dist/chunk-GY657L56.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-HEAKWS27.js +2730 -0
- package/dist/chunk-HEAKWS27.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-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-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-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-PXWVKJGF.js +6 -0
- package/dist/chunk-PXWVKJGF.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-U2X3IYSD.js +23 -0
- package/dist/chunk-U2X3IYSD.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-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-WS7SLVXL.js +550 -0
- package/dist/chunk-WS7SLVXL.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-XPQRHO5E.js +587 -0
- package/dist/chunk-XPQRHO5E.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/form-state-container-conformance.d.ts +51 -0
- package/dist/testing/form-state-container-conformance.js +43 -0
- package/dist/testing/form-state-container-conformance.js.map +7 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.js +35 -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 +119 -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 +179 -0
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildDependencyIndex,
|
|
3
|
+
shouldSurfaceDependentError
|
|
4
|
+
} from "./chunk-GH34XFCC.js";
|
|
5
|
+
import {
|
|
6
|
+
createRunTracker
|
|
7
|
+
} from "./chunk-QYHOFLRX.js";
|
|
8
|
+
import {
|
|
9
|
+
clearAround,
|
|
10
|
+
clearAt,
|
|
11
|
+
clearSelfAt,
|
|
12
|
+
conformAt,
|
|
13
|
+
coveredAt,
|
|
14
|
+
entries,
|
|
15
|
+
fromEntries,
|
|
16
|
+
markAt,
|
|
17
|
+
nodeAt,
|
|
18
|
+
reorderAt,
|
|
19
|
+
selfAt,
|
|
20
|
+
setSelfAt,
|
|
21
|
+
stable
|
|
22
|
+
} from "./chunk-EEYGPPLU.js";
|
|
23
|
+
import {
|
|
24
|
+
submittedTree,
|
|
25
|
+
submittedValues,
|
|
26
|
+
toFormPath
|
|
27
|
+
} from "./chunk-BLFLCSG3.js";
|
|
28
|
+
import {
|
|
29
|
+
buildSubmissionShape
|
|
30
|
+
} from "./chunk-NJTLBSTR.js";
|
|
31
|
+
import {
|
|
32
|
+
dirtyTree
|
|
33
|
+
} from "./chunk-UN3DARLG.js";
|
|
34
|
+
import {
|
|
35
|
+
anchorOf,
|
|
36
|
+
flatIds,
|
|
37
|
+
idsAt,
|
|
38
|
+
replaceIdsAt,
|
|
39
|
+
resolveAnchor,
|
|
40
|
+
syncIds
|
|
41
|
+
} from "./chunk-EQ5AIF3T.js";
|
|
42
|
+
import {
|
|
43
|
+
logger
|
|
44
|
+
} from "./chunk-VGGERKV2.js";
|
|
45
|
+
import {
|
|
46
|
+
collectStepFieldPaths,
|
|
47
|
+
hasParticipationRules,
|
|
48
|
+
isPathExcluded,
|
|
49
|
+
planFormValidation,
|
|
50
|
+
resolveParticipation,
|
|
51
|
+
runValidationPlan
|
|
52
|
+
} from "./chunk-WUTGZYP4.js";
|
|
53
|
+
import {
|
|
54
|
+
frozenCopy
|
|
55
|
+
} from "./chunk-3B7CJOF6.js";
|
|
56
|
+
import {
|
|
57
|
+
resolveFieldRef
|
|
58
|
+
} from "./chunk-YDGH7DTL.js";
|
|
59
|
+
import {
|
|
60
|
+
getValueAtPath
|
|
61
|
+
} from "./chunk-QLGM2AZW.js";
|
|
62
|
+
import {
|
|
63
|
+
createDebounceScope
|
|
64
|
+
} from "./chunk-OR2L7EKO.js";
|
|
65
|
+
import {
|
|
66
|
+
FORM_ROOT
|
|
67
|
+
} from "./chunk-PXWVKJGF.js";
|
|
68
|
+
import {
|
|
69
|
+
readHydration
|
|
70
|
+
} from "./chunk-RB22U6HI.js";
|
|
71
|
+
import {
|
|
72
|
+
changedPaths,
|
|
73
|
+
createMap,
|
|
74
|
+
isStructural,
|
|
75
|
+
isWithin,
|
|
76
|
+
reconcile,
|
|
77
|
+
setIn,
|
|
78
|
+
stabilize,
|
|
79
|
+
toInternal,
|
|
80
|
+
toInternalRecord,
|
|
81
|
+
toPlain,
|
|
82
|
+
toPlainMap
|
|
83
|
+
} from "./chunk-K5TMXCMY.js";
|
|
84
|
+
import {
|
|
85
|
+
isReservedPathKey
|
|
86
|
+
} from "./chunk-3YLRJVVN.js";
|
|
87
|
+
|
|
88
|
+
// src/state-container/create-form-state-container.ts
|
|
89
|
+
var NO_ISSUES = Object.freeze([]);
|
|
90
|
+
var NO_PAYLOAD = Object.freeze({});
|
|
91
|
+
var readAt = (root, path) => getValueAtPath(root, path);
|
|
92
|
+
var isRow = (index, length) => Number.isInteger(index) && index >= 0 && index < length;
|
|
93
|
+
var asRows = (value) => Array.isArray(value) ? value : [value];
|
|
94
|
+
var arrayIn = (values) => (path) => Array.isArray(readAt(values, path));
|
|
95
|
+
var issue = (type, source, parts = {}) => Object.freeze({
|
|
96
|
+
type,
|
|
97
|
+
source,
|
|
98
|
+
...parts.ruleId === void 0 ? {} : { ruleId: parts.ruleId },
|
|
99
|
+
...parts.params === void 0 ? {} : { params: parts.params },
|
|
100
|
+
...parts.message === void 0 ? {} : { message: parts.message }
|
|
101
|
+
});
|
|
102
|
+
var ruleIssue = (found) => issue(found.type, "validation", { ruleId: found.ruleId, params: found.params, message: found.message });
|
|
103
|
+
var nativeIssue = (validity) => issue(validity.type, "native", { params: validity.params, message: validity.message });
|
|
104
|
+
var sameParams = (a, b) => Object.is(a, b) || JSON.stringify(a) === JSON.stringify(b);
|
|
105
|
+
var sameIssue = (a, b) => a.type === b.type && a.source === b.source && a.ruleId === b.ruleId && a.message === b.message && sameParams(a.params, b.params);
|
|
106
|
+
var sameIssues = (a, b) => a.length === b.length && a.every((known, index) => sameIssue(known, b[index]));
|
|
107
|
+
var reuseIssues = (previous, next) => previous && sameIssues(previous, next) ? previous : Object.freeze([...next]);
|
|
108
|
+
function reuseFinding(previous, errors, warnings) {
|
|
109
|
+
if (errors.length === 0 && warnings.length === 0) return void 0;
|
|
110
|
+
if (previous && sameIssues(previous.errors, errors) && sameIssues(previous.warnings, warnings)) return previous;
|
|
111
|
+
return Object.freeze({
|
|
112
|
+
errors: errors.length === 0 ? NO_ISSUES : Object.freeze([...errors]),
|
|
113
|
+
warnings: warnings.length === 0 ? NO_ISSUES : Object.freeze([...warnings])
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function errorOf(issues, previous) {
|
|
117
|
+
if (previous && sameIssues(previous.all, issues)) return previous;
|
|
118
|
+
return Object.freeze({ ...issues[0], all: Object.freeze([...issues]) });
|
|
119
|
+
}
|
|
120
|
+
var sameList = (a, b) => a.length === b.length && a.every((value, index) => value === b[index]);
|
|
121
|
+
var internalPath = (path) => path === FORM_ROOT ? "" : path;
|
|
122
|
+
var publicPath = (path) => path === "" ? FORM_ROOT : path;
|
|
123
|
+
var hasMarkAround = (tree, path) => coveredAt(tree, path) || nodeAt(tree, path) !== void 0;
|
|
124
|
+
function missingRow(path, values) {
|
|
125
|
+
const segments = internalPath(path).split(".").filter(Boolean);
|
|
126
|
+
for (const [depth, segment] of segments.entries()) {
|
|
127
|
+
const above = segments.slice(0, depth).join(".");
|
|
128
|
+
const value = depth === 0 ? values : readAt(values, above);
|
|
129
|
+
const isIndex = String(Number(segment)) === segment && Number.isInteger(Number(segment)) && Number(segment) >= 0;
|
|
130
|
+
if (Array.isArray(value) && !(isIndex && Number(segment) < value.length)) {
|
|
131
|
+
return { segment, above, length: value.length };
|
|
132
|
+
}
|
|
133
|
+
if (/^\d+$/.test(segment) && !Array.isArray(value) && !isStructural(value)) {
|
|
134
|
+
return { segment, above, length: 0 };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return void 0;
|
|
138
|
+
}
|
|
139
|
+
function withoutExcluded(flat, excluded) {
|
|
140
|
+
if (excluded.length === 0) return flat;
|
|
141
|
+
const kept = createMap();
|
|
142
|
+
for (const path of Object.keys(flat)) if (!isPathExcluded(excluded, path)) kept[path] = true;
|
|
143
|
+
return stabilize(flat, kept);
|
|
144
|
+
}
|
|
145
|
+
function shapeErrors(found, previous) {
|
|
146
|
+
const merged = createMap();
|
|
147
|
+
for (const [path, issues] of Object.entries(found)) merged[path] = errorOf(issues, previous?.[path]);
|
|
148
|
+
return stabilize(previous ?? createMap(), merged);
|
|
149
|
+
}
|
|
150
|
+
function factOf(previous, validity, value) {
|
|
151
|
+
if (previous && Object.is(previous.value, value) && previous.validity.type === validity.type && previous.validity.message === validity.message && sameParams(previous.validity.params, validity.params)) {
|
|
152
|
+
return previous;
|
|
153
|
+
}
|
|
154
|
+
return Object.freeze({
|
|
155
|
+
validity: Object.freeze({
|
|
156
|
+
type: validity.type,
|
|
157
|
+
...validity.params === void 0 ? {} : { params: frozenCopy(validity.params) },
|
|
158
|
+
...validity.message === void 0 ? {} : { message: validity.message }
|
|
159
|
+
}),
|
|
160
|
+
value
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function pruneNative(tree, values) {
|
|
164
|
+
return stable(
|
|
165
|
+
tree,
|
|
166
|
+
entries(tree).reduce(
|
|
167
|
+
(kept, [path, fact]) => Object.is(readAt(values, path), fact.value) ? kept : clearSelfAt(kept, path),
|
|
168
|
+
tree
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
function dependenciesOf(path, values, index) {
|
|
173
|
+
return index.referencesOf(path).map((reference) => ({ reference, value: readAt(values, resolveFieldRef(reference, path)) }));
|
|
174
|
+
}
|
|
175
|
+
function serverIssues(input) {
|
|
176
|
+
return (Array.isArray(input) ? input : [input]).map(
|
|
177
|
+
(given) => issue(given.type ?? "server", "server", {
|
|
178
|
+
params: given.params === void 0 ? void 0 : frozenCopy(given.params),
|
|
179
|
+
message: given.message
|
|
180
|
+
})
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
function assertFieldPath(path, command) {
|
|
184
|
+
const reserved = path.split(".").find(isReservedPathKey);
|
|
185
|
+
if (reserved !== void 0) {
|
|
186
|
+
throw new Error(
|
|
187
|
+
`${command}: '${path}' has the reserved segment '${reserved}'; a segment cannot start with '__' or be constructor, prototype or __proto__.`
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function assertRowsExist(path, values) {
|
|
192
|
+
const missing = missingRow(path, values);
|
|
193
|
+
if (missing) {
|
|
194
|
+
throw new Error(
|
|
195
|
+
`setServerErrors: '${path}' names row '${missing.segment}' of '${missing.above}', which has ${missing.length} rows.`
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function withFact(tree, path, reported, values) {
|
|
200
|
+
if (reported === null) return stable(tree, clearSelfAt(tree, path));
|
|
201
|
+
const known = selfAt(tree, path);
|
|
202
|
+
const fact = factOf(known, reported, readAt(values, path));
|
|
203
|
+
return fact === known ? tree : setSelfAt(tree, path, fact, arrayIn(values));
|
|
204
|
+
}
|
|
205
|
+
function createFormStateContainer(options) {
|
|
206
|
+
const { config, registry } = options;
|
|
207
|
+
const { validationMode, reValidateMode } = config;
|
|
208
|
+
const elements = config.steps.flatMap((step) => step.elements);
|
|
209
|
+
const tracker = createRunTracker();
|
|
210
|
+
const debounceScope = createDebounceScope();
|
|
211
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
212
|
+
const participates = hasParticipationRules(config.steps);
|
|
213
|
+
let rowCounter = 0;
|
|
214
|
+
const adoptedIds = /* @__PURE__ */ new Set();
|
|
215
|
+
const mintId = () => {
|
|
216
|
+
let id = `row-${++rowCounter}`;
|
|
217
|
+
while (adoptedIds.has(id)) id = `row-${++rowCounter}`;
|
|
218
|
+
return id;
|
|
219
|
+
};
|
|
220
|
+
const NO_PARTICIPATION = Object.freeze({
|
|
221
|
+
excluded: Object.freeze([]),
|
|
222
|
+
skippedSteps: Object.freeze([]),
|
|
223
|
+
fields: Object.freeze({})
|
|
224
|
+
});
|
|
225
|
+
function participationOf(values, previous = NO_PARTICIPATION) {
|
|
226
|
+
if (!participates) return NO_PARTICIPATION;
|
|
227
|
+
const next = resolveParticipation(config.steps, toPlain(values));
|
|
228
|
+
const excluded = sameList(next.excluded, previous.excluded) ? previous.excluded : Object.freeze(next.excluded);
|
|
229
|
+
const skippedSteps = sameList(next.skippedSteps, previous.skippedSteps) ? previous.skippedSteps : Object.freeze(next.skippedSteps);
|
|
230
|
+
const names = Object.keys(next.fields);
|
|
231
|
+
const same = names.length === Object.keys(previous.fields).length && names.every((name) => {
|
|
232
|
+
const before = Object.hasOwn(previous.fields, name) ? previous.fields[name] : void 0;
|
|
233
|
+
const now = next.fields[name];
|
|
234
|
+
return before?.hidden === now.hidden && before.disabled === now.disabled && before.required === now.required;
|
|
235
|
+
});
|
|
236
|
+
const fields = same ? previous.fields : Object.freeze(
|
|
237
|
+
Object.fromEntries(Object.entries(next.fields).map(([name, one]) => [name, Object.freeze(one)]))
|
|
238
|
+
);
|
|
239
|
+
return excluded === previous.excluded && skippedSteps === previous.skippedSteps && fields === previous.fields ? previous : Object.freeze({ excluded, skippedSteps, fields });
|
|
240
|
+
}
|
|
241
|
+
const submissionShape = buildSubmissionShape(config.steps);
|
|
242
|
+
const hydrated = options.snapshot === void 0 ? void 0 : readHydration(options.snapshot);
|
|
243
|
+
for (const id of hydrated?.taken ?? []) adoptedIds.add(id);
|
|
244
|
+
const initialDefaults = toInternalRecord(options.defaults ?? {});
|
|
245
|
+
const initialValues = hydrated?.values ?? initialDefaults;
|
|
246
|
+
const initialParticipation = participationOf(initialValues);
|
|
247
|
+
let state = {
|
|
248
|
+
values: initialValues,
|
|
249
|
+
defaults: initialDefaults,
|
|
250
|
+
validation: void 0,
|
|
251
|
+
server: void 0,
|
|
252
|
+
native: void 0,
|
|
253
|
+
touched: void 0,
|
|
254
|
+
failed: void 0,
|
|
255
|
+
validated: void 0,
|
|
256
|
+
validating: void 0,
|
|
257
|
+
dirty: hydrated ? dirtyTree(initialValues, initialDefaults) : void 0,
|
|
258
|
+
ids: hydrated ? hydrated.ids : syncIds(void 0, initialValues, mintId),
|
|
259
|
+
participation: initialParticipation,
|
|
260
|
+
excluded: initialParticipation.excluded,
|
|
261
|
+
exclusionVersion: 0,
|
|
262
|
+
generation: 0
|
|
263
|
+
};
|
|
264
|
+
const declaredFor = /* @__PURE__ */ new WeakMap();
|
|
265
|
+
function declaredPaths(values) {
|
|
266
|
+
const known = declaredFor.get(values);
|
|
267
|
+
if (known) return known;
|
|
268
|
+
const declared = /* @__PURE__ */ new Set();
|
|
269
|
+
for (const path of collectStepFieldPaths({ elements }, toPlain(values))) {
|
|
270
|
+
const segments = path.split(".");
|
|
271
|
+
for (let depth = 1; depth <= segments.length; depth += 1) declared.add(segments.slice(0, depth).join("."));
|
|
272
|
+
}
|
|
273
|
+
declaredFor.set(values, declared);
|
|
274
|
+
return declared;
|
|
275
|
+
}
|
|
276
|
+
const isArrayNow = (path) => Array.isArray(readAt(state.values, path));
|
|
277
|
+
let derivedFor;
|
|
278
|
+
function derive(current) {
|
|
279
|
+
if (derivedFor && derivedFor.validation === current.validation && derivedFor.server === current.server && derivedFor.excluded === current.excluded) {
|
|
280
|
+
return derivedFor;
|
|
281
|
+
}
|
|
282
|
+
const takesPart = ([path]) => !isPathExcluded(current.excluded, path);
|
|
283
|
+
const errors = createMap();
|
|
284
|
+
for (const [path, entry] of entries(current.server).filter(takesPart)) {
|
|
285
|
+
(errors[publicPath(path)] ??= []).push(...entry.issues);
|
|
286
|
+
}
|
|
287
|
+
const warnings = createMap();
|
|
288
|
+
const before = derivedFor;
|
|
289
|
+
for (const [path, finding] of entries(current.validation).filter(takesPart)) {
|
|
290
|
+
const where = publicPath(path);
|
|
291
|
+
if (finding.errors.length > 0) (errors[where] ??= []).push(...finding.errors);
|
|
292
|
+
if (finding.warnings.length > 0) warnings[where] = [...finding.warnings];
|
|
293
|
+
}
|
|
294
|
+
derivedFor = {
|
|
295
|
+
validation: current.validation,
|
|
296
|
+
server: current.server,
|
|
297
|
+
excluded: current.excluded,
|
|
298
|
+
errors: shapeErrors(errors, before?.errors),
|
|
299
|
+
warnings: shapeErrors(warnings, before?.warnings)
|
|
300
|
+
};
|
|
301
|
+
return derivedFor;
|
|
302
|
+
}
|
|
303
|
+
const marksFor = /* @__PURE__ */ new Map();
|
|
304
|
+
function marks(kind, tree, excluded = []) {
|
|
305
|
+
const known = marksFor.get(kind);
|
|
306
|
+
if (known && known.tree === tree && known.excluded === excluded) return known.flat;
|
|
307
|
+
const merged = createMap();
|
|
308
|
+
for (const [path] of entries(tree)) merged[publicPath(path)] = true;
|
|
309
|
+
const flat = stabilize(known?.flat ?? createMap(), withoutExcluded(merged, excluded));
|
|
310
|
+
marksFor.set(kind, { tree, excluded, flat });
|
|
311
|
+
return flat;
|
|
312
|
+
}
|
|
313
|
+
let flatIdsFor;
|
|
314
|
+
function flatRowIds(current) {
|
|
315
|
+
if (flatIdsFor && flatIdsFor.ids === current.ids) return flatIdsFor.flat;
|
|
316
|
+
const flat = stabilize(flatIdsFor?.flat ?? createMap(), flatIds(current.ids));
|
|
317
|
+
flatIdsFor = { ids: current.ids, flat };
|
|
318
|
+
return flat;
|
|
319
|
+
}
|
|
320
|
+
let publicFor;
|
|
321
|
+
function publicParticipation(from) {
|
|
322
|
+
if (publicFor?.from === from) return publicFor.view;
|
|
323
|
+
const view = Object.freeze({ skippedSteps: from.skippedSteps, fields: from.fields });
|
|
324
|
+
const reused = publicFor && publicFor.view.skippedSteps === view.skippedSteps && publicFor.view.fields === view.fields ? publicFor.view : view;
|
|
325
|
+
publicFor = { from, view: reused };
|
|
326
|
+
return reused;
|
|
327
|
+
}
|
|
328
|
+
function toSnapshot(current) {
|
|
329
|
+
const derived = derive(current);
|
|
330
|
+
return Object.freeze({
|
|
331
|
+
values: toPlain(current.values),
|
|
332
|
+
errors: toPlainMap(derived.errors),
|
|
333
|
+
warnings: toPlainMap(derived.warnings),
|
|
334
|
+
touched: toPlainMap(marks("touched", current.touched)),
|
|
335
|
+
dirty: toPlainMap(marks("dirty", current.dirty)),
|
|
336
|
+
rowIds: toPlainMap(flatRowIds(current)),
|
|
337
|
+
validating: toPlainMap(marks("validating", current.validating, current.excluded)),
|
|
338
|
+
isValid: Object.keys(derived.errors).length === 0,
|
|
339
|
+
generation: current.generation,
|
|
340
|
+
participation: publicParticipation(current.participation)
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
let snapshot = toSnapshot(state);
|
|
344
|
+
const serverSnapshot = snapshot;
|
|
345
|
+
let batchDepth = 0;
|
|
346
|
+
let notifyAfterBatch = false;
|
|
347
|
+
function notify() {
|
|
348
|
+
for (const listener of listeners) listener();
|
|
349
|
+
}
|
|
350
|
+
function batch(work) {
|
|
351
|
+
batchDepth += 1;
|
|
352
|
+
try {
|
|
353
|
+
return work();
|
|
354
|
+
} finally {
|
|
355
|
+
batchDepth -= 1;
|
|
356
|
+
if (batchDepth === 0 && notifyAfterBatch) {
|
|
357
|
+
notifyAfterBatch = false;
|
|
358
|
+
notify();
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function pruneServer(current) {
|
|
363
|
+
return stable(
|
|
364
|
+
current.server,
|
|
365
|
+
entries(current.server).reduce(
|
|
366
|
+
(kept, [path, entry]) => entry.dependencies.every(
|
|
367
|
+
({ reference, value }) => Object.is(readAt(current.values, resolveFieldRef(reference, path)), value)
|
|
368
|
+
) ? kept : clearSelfAt(kept, path),
|
|
369
|
+
current.server
|
|
370
|
+
)
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
function commit(change) {
|
|
374
|
+
const previous = state;
|
|
375
|
+
let next = { ...previous, ...change };
|
|
376
|
+
let reeligible = [];
|
|
377
|
+
if (next.values !== previous.values || next.defaults !== previous.defaults) {
|
|
378
|
+
next = { ...next, dirty: stable(previous.dirty, dirtyTree(next.values, next.defaults)) };
|
|
379
|
+
}
|
|
380
|
+
if (next.values !== previous.values) {
|
|
381
|
+
if (next.native) next = { ...next, native: pruneNative(next.native, next.values) };
|
|
382
|
+
if (next.server) next = { ...next, server: pruneServer(next) };
|
|
383
|
+
if (participates) {
|
|
384
|
+
const participation = participationOf(next.values, previous.participation);
|
|
385
|
+
const { excluded } = participation;
|
|
386
|
+
next = { ...next, participation };
|
|
387
|
+
if (excluded !== previous.excluded) {
|
|
388
|
+
const dropped = excluded.filter((path) => !isPathExcluded(previous.excluded, path));
|
|
389
|
+
reeligible = previous.excluded.filter(
|
|
390
|
+
(path) => !isPathExcluded(excluded, path) && (hasMarkAround(next.failed, path) || hasMarkAround(next.validated, path))
|
|
391
|
+
);
|
|
392
|
+
next = {
|
|
393
|
+
...next,
|
|
394
|
+
excluded,
|
|
395
|
+
exclusionVersion: previous.exclusionVersion + 1,
|
|
396
|
+
validation: dropped.reduce((tree, path) => clearAt(tree, path), next.validation),
|
|
397
|
+
validating: dropped.reduce((tree, path) => clearAt(tree, path), next.validating)
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
state = next;
|
|
403
|
+
const nextSnapshot = toSnapshot(next);
|
|
404
|
+
const changed = Object.keys(nextSnapshot).some(
|
|
405
|
+
(key) => nextSnapshot[key] !== snapshot[key]
|
|
406
|
+
);
|
|
407
|
+
if (changed) {
|
|
408
|
+
snapshot = nextSnapshot;
|
|
409
|
+
if (batchDepth > 0) notifyAfterBatch = true;
|
|
410
|
+
else notify();
|
|
411
|
+
}
|
|
412
|
+
if (reeligible.length > 0) validateQuietly(reeligible, { record: true, markFailed: false });
|
|
413
|
+
}
|
|
414
|
+
const isFailed = (path) => coveredAt(state.failed, path);
|
|
415
|
+
const isTouched = (path) => coveredAt(state.touched, path);
|
|
416
|
+
function validatesOn(event, path) {
|
|
417
|
+
const target = event === "change" ? "onChange" : "onBlur";
|
|
418
|
+
if (isFailed(path)) return reValidateMode === target;
|
|
419
|
+
if (validationMode === "onTouched") return event === "blur" || isTouched(path);
|
|
420
|
+
return validationMode === "all" || validationMode === target;
|
|
421
|
+
}
|
|
422
|
+
function validateQuietly(names, mode) {
|
|
423
|
+
runValidation(names, mode).catch((error) => {
|
|
424
|
+
logger.error("A validation the form state container started on its own failed.", { error });
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
async function runValidation(names, mode) {
|
|
428
|
+
if (names?.length === 0) return "passed";
|
|
429
|
+
const start = {
|
|
430
|
+
values: state.values,
|
|
431
|
+
ids: state.ids,
|
|
432
|
+
validation: state.validation,
|
|
433
|
+
native: state.native,
|
|
434
|
+
server: state.server,
|
|
435
|
+
excluded: state.excluded,
|
|
436
|
+
participation: state.participation,
|
|
437
|
+
exclusionVersion: state.exclusionVersion
|
|
438
|
+
};
|
|
439
|
+
const startIndex = mode.record ? dependencyIndex() : void 0;
|
|
440
|
+
const startValues = toPlain(start.values);
|
|
441
|
+
const plan = planFormValidation({
|
|
442
|
+
steps: config.steps,
|
|
443
|
+
values: startValues,
|
|
444
|
+
names,
|
|
445
|
+
exactNames: mode.exact,
|
|
446
|
+
participation: start.participation
|
|
447
|
+
});
|
|
448
|
+
const planned = [...new Set(plan.fields.map(({ fieldPath }) => fieldPath))];
|
|
449
|
+
const run = mode.record ? tracker.start(
|
|
450
|
+
names?.map((name) => anchorOf(start.ids, name)),
|
|
451
|
+
mode.exact === true
|
|
452
|
+
) : void 0;
|
|
453
|
+
if (run) {
|
|
454
|
+
commit({
|
|
455
|
+
validating: planned.reduce((tree, path) => setSelfAt(tree, path, true, isArrayNow), state.validating)
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
const finish = (extra = {}) => {
|
|
459
|
+
if (!run) return;
|
|
460
|
+
const resolveNow = (anchor) => resolveAnchor(anchor, state.ids);
|
|
461
|
+
let validating = state.validating;
|
|
462
|
+
for (const path of planned) {
|
|
463
|
+
const current = resolveAnchor(anchorOf(start.ids, path), state.ids);
|
|
464
|
+
if (current !== void 0 && !tracker.superseded(run, current, resolveNow)) {
|
|
465
|
+
validating = setSelfAt(validating, current, void 0, isArrayNow);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
tracker.finish(run);
|
|
469
|
+
commit({ ...extra, validating });
|
|
470
|
+
};
|
|
471
|
+
let outcome;
|
|
472
|
+
try {
|
|
473
|
+
outcome = await runValidationPlan(plan, {
|
|
474
|
+
registry,
|
|
475
|
+
debounceScope: mode.record ? debounceScope : createDebounceScope()
|
|
476
|
+
});
|
|
477
|
+
} catch (error) {
|
|
478
|
+
finish();
|
|
479
|
+
throw error;
|
|
480
|
+
}
|
|
481
|
+
const inScope = (path) => !names || (mode.exact ? names.includes(path) : names.some((name) => isWithin(path, name)));
|
|
482
|
+
const found = createMap();
|
|
483
|
+
const at = (path) => found[path] ??= { errors: [], warnings: [] };
|
|
484
|
+
for (const [path, issues] of Object.entries(outcome.issues)) {
|
|
485
|
+
for (const raised of issues) {
|
|
486
|
+
at(path)[raised.severity === "warning" ? "warnings" : "errors"].push(ruleIssue(raised));
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
for (const [path, fact] of entries(start.native)) {
|
|
490
|
+
if (inScope(path) && !isPathExcluded(start.excluded, path))
|
|
491
|
+
at(path).errors.push(nativeIssue(fact.validity));
|
|
492
|
+
}
|
|
493
|
+
const blocking = Object.values(found).some((entry) => entry.errors.length > 0);
|
|
494
|
+
const failures = Object.values(outcome.failures).flat();
|
|
495
|
+
const failure = failures[0];
|
|
496
|
+
if (!mode.reject) {
|
|
497
|
+
for (const unrun of failures) {
|
|
498
|
+
logger.error(`A rule could not run during an automatic validation of '${unrun.path}'.`, {
|
|
499
|
+
error: unrun
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
const unchecked = new Set(outcome.superseded);
|
|
504
|
+
if (!run || !startIndex) {
|
|
505
|
+
if (failure && mode.reject) throw failure;
|
|
506
|
+
const answeredByServer = entries(start.server).some(
|
|
507
|
+
([path]) => inScope(path) && !isPathExcluded(start.excluded, path)
|
|
508
|
+
);
|
|
509
|
+
return !blocking && !answeredByServer && unchecked.size === 0 ? "passed" : "invalid";
|
|
510
|
+
}
|
|
511
|
+
if (tracker.outdated(run)) {
|
|
512
|
+
finish();
|
|
513
|
+
return "overtaken";
|
|
514
|
+
}
|
|
515
|
+
const now = (path) => resolveAnchor(anchorOf(start.ids, path), state.ids);
|
|
516
|
+
const movedSince = (path) => {
|
|
517
|
+
const current = now(path);
|
|
518
|
+
return current === void 0 || !Object.is(readAt(state.values, current), readAt(start.values, path));
|
|
519
|
+
};
|
|
520
|
+
const factMoved = (path, current) => selfAt(start.native, path) !== selfAt(state.native, current);
|
|
521
|
+
const dependencyChanged = (path) => startIndex.referencesOf(path).some((reference) => {
|
|
522
|
+
const current = now(path);
|
|
523
|
+
if (current === void 0) return true;
|
|
524
|
+
return !Object.is(
|
|
525
|
+
readAt(state.values, resolveFieldRef(reference, current)),
|
|
526
|
+
readAt(start.values, resolveFieldRef(reference, path))
|
|
527
|
+
);
|
|
528
|
+
});
|
|
529
|
+
const lostContainer = (path) => path.split(".").slice(0, -1).some((_, depth, segments) => {
|
|
530
|
+
const above = segments.slice(0, depth + 1).join(".");
|
|
531
|
+
const current = now(above);
|
|
532
|
+
return current === void 0 || isStructural(readAt(start.values, above)) && !isStructural(readAt(state.values, current));
|
|
533
|
+
});
|
|
534
|
+
const outrun = (path, current) => lostContainer(path) || movedSince(path) || tracker.superseded(run, current, (anchor) => resolveAnchor(anchor, state.ids)) || dependencyChanged(path);
|
|
535
|
+
const stale = (path, current) => current === void 0 || outrun(path, current) || factMoved(path, current);
|
|
536
|
+
const plannedSet = new Set(planned);
|
|
537
|
+
const decided = [
|
|
538
|
+
.../* @__PURE__ */ new Set([
|
|
539
|
+
...planned,
|
|
540
|
+
...entries(start.validation).map(([path]) => path).filter(inScope),
|
|
541
|
+
...Object.keys(found)
|
|
542
|
+
])
|
|
543
|
+
].map((path) => ({ path, current: now(path) }));
|
|
544
|
+
const excludedNow = (current) => isPathExcluded(state.excluded, current);
|
|
545
|
+
const exclusionChanged = start.exclusionVersion !== state.exclusionVersion && (!names || [...start.excluded, ...state.excluded].some(
|
|
546
|
+
(path) => names.some((name) => isWithin(path, name) || isWithin(name, path))
|
|
547
|
+
));
|
|
548
|
+
const scopeStale = () => changedPaths(start.values, state.values).some(
|
|
549
|
+
(changed) => !names || names.some((name) => isWithin(changed, name) || isWithin(name, changed))
|
|
550
|
+
) || startIndex.watched.some(
|
|
551
|
+
(watched) => !Object.is(readAt(state.values, watched), readAt(start.values, watched)) && startIndex.dependentsOf(watched).some(inScope)
|
|
552
|
+
);
|
|
553
|
+
const overtaken = unchecked.size > 0 || exclusionChanged || scopeStale() || decided.some(
|
|
554
|
+
({ path, current }) => (current === void 0 || !excludedNow(current)) && stale(path, current)
|
|
555
|
+
);
|
|
556
|
+
if (mode.retry && overtaken) {
|
|
557
|
+
return batch(() => {
|
|
558
|
+
const again = names?.map((name) => now(name));
|
|
559
|
+
finish();
|
|
560
|
+
if (again?.some((name) => name === void 0)) return Promise.resolve("overtaken");
|
|
561
|
+
return runValidation(again, { ...mode, retry: false });
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
let validation = state.validation;
|
|
565
|
+
let validated = state.validated;
|
|
566
|
+
for (const { path, current } of decided) {
|
|
567
|
+
if (current === void 0 || excludedNow(current) || unchecked.has(path)) continue;
|
|
568
|
+
if (stale(path, current)) continue;
|
|
569
|
+
const entry = found[path];
|
|
570
|
+
validation = setSelfAt(
|
|
571
|
+
validation,
|
|
572
|
+
current,
|
|
573
|
+
reuseFinding(selfAt(validation, current), entry?.errors ?? NO_ISSUES, entry?.warnings ?? NO_ISSUES),
|
|
574
|
+
isArrayNow
|
|
575
|
+
);
|
|
576
|
+
if (plannedSet.has(path)) validated = setSelfAt(validated, current, true, isArrayNow);
|
|
577
|
+
}
|
|
578
|
+
let failed = state.failed;
|
|
579
|
+
if (mode.markFailed) {
|
|
580
|
+
failed = names ? names.reduce((tree, name) => {
|
|
581
|
+
const current = now(name);
|
|
582
|
+
return current === void 0 ? tree : markAt(tree, current, isArrayNow);
|
|
583
|
+
}, failed) : setSelfAt(failed, "", true, isArrayNow);
|
|
584
|
+
}
|
|
585
|
+
finish({ validation, validated, failed });
|
|
586
|
+
if (overtaken) return "overtaken";
|
|
587
|
+
if (failure && mode.reject) throw failure;
|
|
588
|
+
const scopeNow = names?.flatMap((name) => now(name) ?? []);
|
|
589
|
+
const stillInScope = (path) => !scopeNow || (mode.exact ? scopeNow.includes(path) : scopeNow.some((name) => isWithin(path, name)));
|
|
590
|
+
const passed = !blocking && !Object.keys(derive(state).errors).some(stillInScope);
|
|
591
|
+
if (passed && mode.submission && mode.submission.epoch === tracker.epoch()) {
|
|
592
|
+
mode.submission.values = start.values;
|
|
593
|
+
mode.submission.ids = start.ids;
|
|
594
|
+
mode.submission.excluded = start.excluded;
|
|
595
|
+
}
|
|
596
|
+
return passed ? "passed" : "invalid";
|
|
597
|
+
}
|
|
598
|
+
let cachedIndex;
|
|
599
|
+
function dependencyIndex(current = state) {
|
|
600
|
+
if (cachedIndex && cachedIndex.ids === current.ids) return cachedIndex.index;
|
|
601
|
+
const lengths = flatRowIds(current);
|
|
602
|
+
const shape = Object.keys(lengths).map((path) => `${path}:${lengths[path].length}`).toSorted().join("|");
|
|
603
|
+
if (cachedIndex?.shape === shape) {
|
|
604
|
+
cachedIndex = { ...cachedIndex, ids: current.ids };
|
|
605
|
+
return cachedIndex.index;
|
|
606
|
+
}
|
|
607
|
+
const index = buildDependencyIndex(elements, toPlain(current.values), registry);
|
|
608
|
+
cachedIndex = { ids: current.ids, shape, index };
|
|
609
|
+
return index;
|
|
610
|
+
}
|
|
611
|
+
function dependentsOfChange(previousValues) {
|
|
612
|
+
const index = dependencyIndex();
|
|
613
|
+
const changed = index.watched.filter(
|
|
614
|
+
(path) => !Object.is(readAt(previousValues, path), readAt(state.values, path))
|
|
615
|
+
);
|
|
616
|
+
return index.expand(changed).filter((path) => shouldSurfaceDependentError({ touched: isTouched(path), submitted: isFailed(path) }));
|
|
617
|
+
}
|
|
618
|
+
function afterChange(previousValues, changedPath, exact, events = { change: true, blur: false }) {
|
|
619
|
+
const names = new Set(dependentsOfChange(previousValues));
|
|
620
|
+
const validatesSelf = events.change && validatesOn("change", changedPath) || events.blur && validatesOn("blur", changedPath);
|
|
621
|
+
if (validatesSelf && !exact) names.add(changedPath);
|
|
622
|
+
const quiet = { record: true, markFailed: false };
|
|
623
|
+
if (names.size > 0) validateQuietly([...names], quiet);
|
|
624
|
+
if (validatesSelf && exact) validateQuietly([changedPath], { ...quiet, exact });
|
|
625
|
+
}
|
|
626
|
+
function dropHostErrors(path, includeBelow) {
|
|
627
|
+
const around = clearAround(state.server, path);
|
|
628
|
+
return includeBelow ? clearAt(around, path) : clearSelfAt(around, path);
|
|
629
|
+
}
|
|
630
|
+
function assertWritable(command, path) {
|
|
631
|
+
assertFieldPath(path, command);
|
|
632
|
+
const missing = missingRow(path, state.values);
|
|
633
|
+
if (missing) {
|
|
634
|
+
throw new Error(
|
|
635
|
+
`${command}: '${path}' names row '${missing.segment}' of '${missing.above}', which has ${missing.length} rows; add rows with fieldArray.`
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
function setValue(path, value) {
|
|
640
|
+
assertWritable("setValue", path);
|
|
641
|
+
const previousValues = state.values;
|
|
642
|
+
const branch = reconcile(readAt(previousValues, path), toInternal(value));
|
|
643
|
+
const values = setIn(previousValues, path, branch);
|
|
644
|
+
if (values === previousValues) return;
|
|
645
|
+
const root = path.split(".")[0];
|
|
646
|
+
batch(() => {
|
|
647
|
+
commit({
|
|
648
|
+
values,
|
|
649
|
+
ids: replaceIdsAt(state.ids, root, syncIds(idsAt(state.ids, root), readAt(values, root), mintId)),
|
|
650
|
+
server: dropHostErrors(path, true),
|
|
651
|
+
validation: conformAt(state.validation, path, branch),
|
|
652
|
+
native: stable(state.native, conformAt(state.native, path, branch)),
|
|
653
|
+
touched: conformAt(state.touched, path, branch),
|
|
654
|
+
failed: conformAt(state.failed, path, branch),
|
|
655
|
+
validated: conformAt(state.validated, path, branch),
|
|
656
|
+
validating: conformAt(state.validating, path, branch)
|
|
657
|
+
});
|
|
658
|
+
afterChange(previousValues, path, false);
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
function blur(path) {
|
|
662
|
+
assertWritable("blur", path);
|
|
663
|
+
batch(() => {
|
|
664
|
+
commit({ touched: markAt(state.touched, path, isArrayNow) });
|
|
665
|
+
afterChange(state.values, path, false, { change: false, blur: true });
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
function rowsAt(path) {
|
|
669
|
+
const value = readAt(state.values, path);
|
|
670
|
+
const rows = Array.isArray(value) ? value : [];
|
|
671
|
+
const nodes = idsAt(state.ids, path);
|
|
672
|
+
return rows.map((row, index) => ({
|
|
673
|
+
from: index,
|
|
674
|
+
value: row,
|
|
675
|
+
node: (Array.isArray(nodes) ? nodes[index] : void 0) ?? {
|
|
676
|
+
id: mintId(),
|
|
677
|
+
below: syncIds(void 0, row, mintId)
|
|
678
|
+
}
|
|
679
|
+
}));
|
|
680
|
+
}
|
|
681
|
+
function commitRows(path, rows) {
|
|
682
|
+
const previousValues = state.values;
|
|
683
|
+
const order = rows.map((row) => row.from);
|
|
684
|
+
const values = setIn(
|
|
685
|
+
previousValues,
|
|
686
|
+
path,
|
|
687
|
+
reconcile(
|
|
688
|
+
readAt(previousValues, path),
|
|
689
|
+
rows.map((row) => row.value)
|
|
690
|
+
)
|
|
691
|
+
);
|
|
692
|
+
const root = path.split(".")[0];
|
|
693
|
+
const placed = replaceIdsAt(
|
|
694
|
+
state.ids,
|
|
695
|
+
path,
|
|
696
|
+
rows.map((row) => row.node)
|
|
697
|
+
);
|
|
698
|
+
batch(() => {
|
|
699
|
+
commit({
|
|
700
|
+
values,
|
|
701
|
+
ids: replaceIdsAt(placed, root, syncIds(idsAt(placed, root), readAt(values, root), mintId)),
|
|
702
|
+
server: reorderAt(dropHostErrors(path, false), path, order),
|
|
703
|
+
validation: reorderAt(state.validation, path, order),
|
|
704
|
+
native: reorderAt(state.native, path, order),
|
|
705
|
+
touched: reorderAt(state.touched, path, order),
|
|
706
|
+
failed: reorderAt(state.failed, path, order),
|
|
707
|
+
validated: reorderAt(state.validated, path, order),
|
|
708
|
+
validating: reorderAt(state.validating, path, order)
|
|
709
|
+
});
|
|
710
|
+
afterChange(previousValues, path, true);
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
const fresh = (value) => {
|
|
714
|
+
const internal = toInternal(value);
|
|
715
|
+
return { value: internal, node: { id: mintId(), below: syncIds(void 0, internal, mintId) } };
|
|
716
|
+
};
|
|
717
|
+
const fieldArrays = /* @__PURE__ */ new Map();
|
|
718
|
+
function fieldArray(path) {
|
|
719
|
+
const known = fieldArrays.get(path);
|
|
720
|
+
if (known) return known;
|
|
721
|
+
const insert = (index, value) => {
|
|
722
|
+
const rows = rowsAt(path);
|
|
723
|
+
const added = asRows(value);
|
|
724
|
+
if (!Number.isInteger(index) || index < 0 || index > rows.length || added.length === 0) return;
|
|
725
|
+
rows.splice(index, 0, ...added.map(fresh));
|
|
726
|
+
commitRows(path, rows);
|
|
727
|
+
};
|
|
728
|
+
const rearrange = (indexes, change) => {
|
|
729
|
+
const rows = rowsAt(path);
|
|
730
|
+
if (!indexes.every((index) => isRow(index, rows.length))) return;
|
|
731
|
+
commitRows(path, change(rows));
|
|
732
|
+
};
|
|
733
|
+
const commands = {
|
|
734
|
+
append: (value) => insert(rowsAt(path).length, value),
|
|
735
|
+
prepend: (value) => insert(0, value),
|
|
736
|
+
insert,
|
|
737
|
+
swap: (indexA, indexB) => rearrange([indexA, indexB], (rows) => {
|
|
738
|
+
[rows[indexA], rows[indexB]] = [rows[indexB], rows[indexA]];
|
|
739
|
+
return rows;
|
|
740
|
+
}),
|
|
741
|
+
move: (indexA, indexB) => rearrange([indexA, indexB], (rows) => {
|
|
742
|
+
rows.splice(indexB, 0, ...rows.splice(indexA, 1));
|
|
743
|
+
return rows;
|
|
744
|
+
}),
|
|
745
|
+
update: (index, value) => rearrange([index], (rows) => {
|
|
746
|
+
rows[index] = fresh(value);
|
|
747
|
+
return rows;
|
|
748
|
+
}),
|
|
749
|
+
replace: (values) => commitRows(path, values.map(fresh)),
|
|
750
|
+
remove: (index) => {
|
|
751
|
+
const rows = rowsAt(path);
|
|
752
|
+
if (index === void 0) return rows.length > 0 ? commitRows(path, []) : void 0;
|
|
753
|
+
const removed = new Set((Array.isArray(index) ? index : [index]).filter((i) => isRow(i, rows.length)));
|
|
754
|
+
if (removed.size > 0)
|
|
755
|
+
commitRows(
|
|
756
|
+
path,
|
|
757
|
+
rows.filter((_, position) => !removed.has(position))
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
fieldArrays.set(path, commands);
|
|
762
|
+
return commands;
|
|
763
|
+
}
|
|
764
|
+
let latestSubmission;
|
|
765
|
+
function targetUnchanged(record, was, now, index) {
|
|
766
|
+
if (was === "") return Object.is(record.values, state.values);
|
|
767
|
+
if (!Object.is(readAt(record.values, was), readAt(state.values, now))) return false;
|
|
768
|
+
return index.referencesOf(now).every(
|
|
769
|
+
(reference) => Object.is(
|
|
770
|
+
readAt(record.values, resolveFieldRef(reference, was)),
|
|
771
|
+
readAt(state.values, resolveFieldRef(reference, now))
|
|
772
|
+
)
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
function reportNative(facts) {
|
|
776
|
+
const reported = Object.entries(facts);
|
|
777
|
+
for (const [path] of reported) assertFieldPath(path, "reportNative");
|
|
778
|
+
let native = state.native;
|
|
779
|
+
const changed = [];
|
|
780
|
+
for (const [path, validity] of reported) {
|
|
781
|
+
if (!declaredPaths(state.values).has(path)) continue;
|
|
782
|
+
const next = withFact(native, path, validity, state.values);
|
|
783
|
+
if (next === native) continue;
|
|
784
|
+
native = next;
|
|
785
|
+
changed.push(path);
|
|
786
|
+
}
|
|
787
|
+
if (changed.length === 0) return;
|
|
788
|
+
batch(() => {
|
|
789
|
+
commit({ native });
|
|
790
|
+
const again = changed.filter(
|
|
791
|
+
(path) => hasMarkAround(state.validated, path) || hasMarkAround(state.validating, path) || isFailed(path)
|
|
792
|
+
);
|
|
793
|
+
if (again.length > 0) validateQuietly(again, { record: true, markFailed: false });
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
function setServerErrors(record, errors) {
|
|
797
|
+
const submitted = submittedTree(record);
|
|
798
|
+
const declared = declaredPaths(submitted);
|
|
799
|
+
const given = [];
|
|
800
|
+
const undeclared = [];
|
|
801
|
+
for (const [path, input] of Object.entries(errors)) {
|
|
802
|
+
if (path !== FORM_ROOT) assertFieldPath(path, "setServerErrors");
|
|
803
|
+
assertRowsExist(path, submitted);
|
|
804
|
+
const issues = serverIssues(input);
|
|
805
|
+
if (path === FORM_ROOT) given.push([path, issues]);
|
|
806
|
+
else if (declared.has(path)) given.push([toFormPath(record, path), issues]);
|
|
807
|
+
else undeclared.push(...issues);
|
|
808
|
+
}
|
|
809
|
+
const root = given.findIndex(([path]) => path === FORM_ROOT);
|
|
810
|
+
if (undeclared.length > 0) {
|
|
811
|
+
if (root < 0) given.push([FORM_ROOT, undeclared]);
|
|
812
|
+
else given[root] = [FORM_ROOT, [...given[root][1], ...undeclared]];
|
|
813
|
+
}
|
|
814
|
+
if (record !== latestSubmission) return;
|
|
815
|
+
const index = dependencyIndex();
|
|
816
|
+
const known = state.server;
|
|
817
|
+
const applied = [];
|
|
818
|
+
for (const [path, issues] of given) {
|
|
819
|
+
if (issues.length === 0) continue;
|
|
820
|
+
const was = internalPath(path);
|
|
821
|
+
const where = resolveAnchor(anchorOf(record.ids, was), state.ids);
|
|
822
|
+
if (where === void 0 || !targetUnchanged(record, was, where, index)) continue;
|
|
823
|
+
const dependencies = where === "" ? [] : dependenciesOf(where, state.values, index);
|
|
824
|
+
const previous = selfAt(known, where);
|
|
825
|
+
const kept = reuseIssues(previous?.issues, issues);
|
|
826
|
+
applied.push([
|
|
827
|
+
where,
|
|
828
|
+
previous && previous.issues === kept && previous.dependencies.length === dependencies.length && previous.dependencies.every(
|
|
829
|
+
(one, position) => one.reference === dependencies[position].reference && Object.is(one.value, dependencies[position].value)
|
|
830
|
+
) ? previous : { issues: kept, dependencies }
|
|
831
|
+
]);
|
|
832
|
+
}
|
|
833
|
+
commit({ server: stable(known, fromEntries(applied, isArrayNow)) });
|
|
834
|
+
}
|
|
835
|
+
async function submit() {
|
|
836
|
+
const record = {
|
|
837
|
+
values: state.values,
|
|
838
|
+
ids: state.ids,
|
|
839
|
+
excluded: state.excluded,
|
|
840
|
+
payload: config.payload ?? NO_PAYLOAD,
|
|
841
|
+
shape: submissionShape,
|
|
842
|
+
epoch: tracker.epoch()
|
|
843
|
+
};
|
|
844
|
+
latestSubmission = record;
|
|
845
|
+
const outcome = await batch(() => {
|
|
846
|
+
commit({ server: void 0 });
|
|
847
|
+
return runValidation(void 0, {
|
|
848
|
+
record: true,
|
|
849
|
+
markFailed: true,
|
|
850
|
+
retry: true,
|
|
851
|
+
reject: true,
|
|
852
|
+
submission: record
|
|
853
|
+
});
|
|
854
|
+
});
|
|
855
|
+
if (latestSubmission !== record) return { outcome: "overtaken" };
|
|
856
|
+
if (outcome === "passed") {
|
|
857
|
+
return {
|
|
858
|
+
outcome,
|
|
859
|
+
values: submittedValues(record),
|
|
860
|
+
setServerErrors: (errors) => setServerErrors(record, errors)
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
return { outcome };
|
|
864
|
+
}
|
|
865
|
+
return {
|
|
866
|
+
subscribe(listener) {
|
|
867
|
+
listeners.add(listener);
|
|
868
|
+
return () => {
|
|
869
|
+
listeners.delete(listener);
|
|
870
|
+
};
|
|
871
|
+
},
|
|
872
|
+
getSnapshot: () => snapshot,
|
|
873
|
+
getServerSnapshot: () => serverSnapshot,
|
|
874
|
+
getValue: (path) => toPlain(readAt(state.values, path)),
|
|
875
|
+
setValue,
|
|
876
|
+
blur,
|
|
877
|
+
reportNative,
|
|
878
|
+
reset(values) {
|
|
879
|
+
const defaults = values ? toInternalRecord(values) : state.defaults;
|
|
880
|
+
tracker.reset();
|
|
881
|
+
latestSubmission = void 0;
|
|
882
|
+
commit({
|
|
883
|
+
values: defaults,
|
|
884
|
+
defaults,
|
|
885
|
+
validation: void 0,
|
|
886
|
+
server: void 0,
|
|
887
|
+
native: void 0,
|
|
888
|
+
touched: void 0,
|
|
889
|
+
failed: void 0,
|
|
890
|
+
validated: void 0,
|
|
891
|
+
validating: void 0,
|
|
892
|
+
ids: syncIds(void 0, defaults, mintId),
|
|
893
|
+
generation: state.generation + 1
|
|
894
|
+
});
|
|
895
|
+
},
|
|
896
|
+
validate: async (paths) => ({
|
|
897
|
+
outcome: await runValidation(paths, { record: true, markFailed: true, retry: true, reject: true })
|
|
898
|
+
}),
|
|
899
|
+
checkValidity: async () => await runValidation(void 0, { record: false, markFailed: false, reject: true }) === "passed",
|
|
900
|
+
submit,
|
|
901
|
+
fieldArray
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
export {
|
|
906
|
+
createFormStateContainer
|
|
907
|
+
};
|