@verbb/formie-browser 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/chunks/address-finder-BjMuEiwF.js +37 -0
- package/dist/chunks/bpoint-KudsBCo2.js +26 -0
- package/dist/chunks/calculations-DlGSkQ3W.js +147 -0
- package/dist/chunks/captcha-eu-CterYFok.js +34 -0
- package/dist/chunks/checkbox-radio-CBvgk3hR.js +136 -0
- package/dist/chunks/conditions-DYy1-Hwt.js +459 -0
- package/dist/chunks/date-picker-BlD--zfe.js +4994 -0
- package/dist/chunks/eway-qwc-B5Us.js +74 -0
- package/dist/chunks/file-upload-CIgHrXfp.js +316 -0
- package/dist/chunks/friendly-captcha-v1-EDFac33c.js +33 -0
- package/dist/chunks/friendly-captcha-v2-BDpSvFGR.js +38 -0
- package/dist/chunks/go-cardless-DuDMVsnz.js +24 -0
- package/dist/chunks/google-address-Bmjp01pH.js +181 -0
- package/dist/chunks/hcaptcha-BTQ6An6g.js +56 -0
- package/dist/chunks/hidden-DbPdOxKb.js +31 -0
- package/dist/chunks/index-BEsfee-D.js +1839 -0
- package/dist/chunks/index-BP7Unm5Y.js +863 -0
- package/dist/chunks/index-BcqwpPNE.js +4314 -0
- package/dist/chunks/loqate-BdNGv93o.js +55 -0
- package/dist/chunks/mollie-DFOjTuGX.js +24 -0
- package/dist/chunks/moneris-BbFfl-EL.js +101 -0
- package/dist/chunks/opayo-CmgYa9ya.js +122 -0
- package/dist/chunks/paddle-BUi7w1_o.js +60 -0
- package/dist/chunks/paypal-A-ePfh6k.js +100 -0
- package/dist/chunks/payway-BqFCbhyo.js +56 -0
- package/dist/chunks/phone-country-DPMiqk4L.js +3765 -0
- package/dist/chunks/place-kit-CX7tamAg.js +42 -0
- package/dist/chunks/placekit-autocomplete.esm-LAwfbPZl.js +1299 -0
- package/dist/chunks/recaptcha-enterprise-DxF6cW95.js +71 -0
- package/dist/chunks/recaptcha-shared-DhGcbiaq.js +15 -0
- package/dist/chunks/recaptcha-v2-checkbox-R9EfbZ4k.js +41 -0
- package/dist/chunks/recaptcha-v2-invisible-DV9hswAp.js +59 -0
- package/dist/chunks/recaptcha-v3-V0xc-Edh.js +28 -0
- package/dist/chunks/repeater-DKUT6TGI.js +124 -0
- package/dist/chunks/rich-text-SH7KiaKH.js +304 -0
- package/dist/chunks/scripts-D9N2d5rN.js +36 -0
- package/dist/chunks/sdk-3SicTWby.js +1559 -0
- package/dist/chunks/shared-BmntPmnW.js +80 -0
- package/dist/chunks/signature-BA3tQsGT.js +550 -0
- package/dist/chunks/snaptcha-DV7p6J9k.js +8 -0
- package/dist/chunks/square-Bs-ndqYK.js +46 -0
- package/dist/chunks/stripe-DkZAHxtn.js +202 -0
- package/dist/chunks/styles-C3aqgtek.js +21 -0
- package/dist/chunks/summary-Dq2i9TQk.js +126 -0
- package/dist/chunks/table-Cu4WfVcw.js +95 -0
- package/dist/chunks/text-limit-2ycmB-Ae.js +135 -0
- package/dist/chunks/turnstile-CId90tRr.js +59 -0
- package/dist/chunks/utils-BntI3W4S.js +6149 -0
- package/dist/css/theme/forms/_form.css +28 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -3205
- package/dist/js/compatibility/dom-adapter.d.ts +12 -0
- package/dist/js/compatibility/dom-adapter.d.ts.map +1 -0
- package/dist/js/compatibility/event-map.d.ts +25 -0
- package/dist/js/compatibility/event-map.d.ts.map +1 -0
- package/dist/js/compatibility/validator-adapter.d.ts +17 -0
- package/dist/js/compatibility/validator-adapter.d.ts.map +1 -0
- package/dist/js/contracts/client.d.ts +40 -0
- package/dist/js/contracts/client.d.ts.map +1 -0
- package/dist/js/contracts/common.d.ts +5 -0
- package/dist/js/contracts/common.d.ts.map +1 -0
- package/dist/js/contracts/modules.d.ts +47 -0
- package/dist/js/contracts/modules.d.ts.map +1 -0
- package/dist/js/contracts/schema.d.ts +79 -0
- package/dist/js/contracts/schema.d.ts.map +1 -0
- package/dist/js/contracts/theme.d.ts +2 -0
- package/dist/js/contracts/theme.d.ts.map +1 -0
- package/dist/js/core/create-formie-client.d.ts +3 -0
- package/dist/js/core/create-formie-client.d.ts.map +1 -0
- package/dist/js/core/dom-events.d.ts +2 -0
- package/dist/js/core/dom-events.d.ts.map +1 -0
- package/dist/js/core/formie.d.ts +27 -0
- package/dist/js/core/formie.d.ts.map +1 -0
- package/dist/js/core/hydrate-modules.d.ts +22 -0
- package/dist/js/core/hydrate-modules.d.ts.map +1 -0
- package/dist/js/core/page-client-event.d.ts +9 -0
- package/dist/js/core/page-client-event.d.ts.map +1 -0
- package/dist/js/core/page-tab-errors.d.ts +2 -0
- package/dist/js/core/page-tab-errors.d.ts.map +1 -0
- package/dist/js/core/submit-flow.d.ts +21 -0
- package/dist/js/core/submit-flow.d.ts.map +1 -0
- package/dist/js/core/submit-result-state.d.ts +8 -0
- package/dist/js/core/submit-result-state.d.ts.map +1 -0
- package/dist/js/core/submit-result-ui.d.ts +10 -0
- package/dist/js/core/submit-result-ui.d.ts.map +1 -0
- package/dist/js/events/event-bus.d.ts +21 -0
- package/dist/js/events/event-bus.d.ts.map +1 -0
- package/dist/js/modules/address/address-finder.d.ts +2 -0
- package/dist/js/modules/address/address-finder.d.ts.map +1 -0
- package/dist/js/modules/address/api.d.ts +8 -0
- package/dist/js/modules/address/api.d.ts.map +1 -0
- package/dist/js/modules/address/constants.d.ts +15 -0
- package/dist/js/modules/address/constants.d.ts.map +1 -0
- package/dist/js/modules/address/factories.d.ts +35 -0
- package/dist/js/modules/address/factories.d.ts.map +1 -0
- package/dist/js/modules/address/google-address.d.ts +9 -0
- package/dist/js/modules/address/google-address.d.ts.map +1 -0
- package/dist/js/modules/address/host.d.ts +30 -0
- package/dist/js/modules/address/host.d.ts.map +1 -0
- package/dist/js/modules/address/index.d.ts +3 -0
- package/dist/js/modules/address/index.d.ts.map +1 -0
- package/dist/js/modules/address/loqate.d.ts +2 -0
- package/dist/js/modules/address/loqate.d.ts.map +1 -0
- package/dist/js/modules/address/place-kit.d.ts +2 -0
- package/dist/js/modules/address/place-kit.d.ts.map +1 -0
- package/dist/js/modules/captchas/api.d.ts +9 -0
- package/dist/js/modules/captchas/api.d.ts.map +1 -0
- package/dist/js/modules/captchas/captcha-eu.d.ts +2 -0
- package/dist/js/modules/captchas/captcha-eu.d.ts.map +1 -0
- package/dist/js/modules/captchas/constants.d.ts +5 -0
- package/dist/js/modules/captchas/constants.d.ts.map +1 -0
- package/dist/js/modules/captchas/factories.d.ts +63 -0
- package/dist/js/modules/captchas/factories.d.ts.map +1 -0
- package/dist/js/modules/captchas/friendly-captcha-v1.d.ts +2 -0
- package/dist/js/modules/captchas/friendly-captcha-v1.d.ts.map +1 -0
- package/dist/js/modules/captchas/friendly-captcha-v2.d.ts +2 -0
- package/dist/js/modules/captchas/friendly-captcha-v2.d.ts.map +1 -0
- package/dist/js/modules/captchas/hcaptcha.d.ts +2 -0
- package/dist/js/modules/captchas/hcaptcha.d.ts.map +1 -0
- package/dist/js/modules/captchas/host.d.ts +78 -0
- package/dist/js/modules/captchas/host.d.ts.map +1 -0
- package/dist/js/modules/captchas/index.d.ts +3 -0
- package/dist/js/modules/captchas/index.d.ts.map +1 -0
- package/dist/js/modules/captchas/recaptcha-enterprise.d.ts +2 -0
- package/dist/js/modules/captchas/recaptcha-enterprise.d.ts.map +1 -0
- package/dist/js/modules/captchas/recaptcha-shared.d.ts +26 -0
- package/dist/js/modules/captchas/recaptcha-shared.d.ts.map +1 -0
- package/dist/js/modules/captchas/recaptcha-v2-checkbox.d.ts +2 -0
- package/dist/js/modules/captchas/recaptcha-v2-checkbox.d.ts.map +1 -0
- package/dist/js/modules/captchas/recaptcha-v2-invisible.d.ts +2 -0
- package/dist/js/modules/captchas/recaptcha-v2-invisible.d.ts.map +1 -0
- package/dist/js/modules/captchas/recaptcha-v3.d.ts +2 -0
- package/dist/js/modules/captchas/recaptcha-v3.d.ts.map +1 -0
- package/dist/js/modules/captchas/snaptcha.d.ts +2 -0
- package/dist/js/modules/captchas/snaptcha.d.ts.map +1 -0
- package/dist/js/modules/captchas/turnstile.d.ts +2 -0
- package/dist/js/modules/captchas/turnstile.d.ts.map +1 -0
- package/dist/js/modules/captchas/utils.d.ts +13 -0
- package/dist/js/modules/captchas/utils.d.ts.map +1 -0
- package/dist/js/modules/fields/calculations.d.ts +3 -0
- package/dist/js/modules/fields/calculations.d.ts.map +1 -0
- package/dist/js/modules/fields/checkbox-radio.d.ts +3 -0
- package/dist/js/modules/fields/checkbox-radio.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/config.d.ts +5 -0
- package/dist/js/modules/fields/conditions/config.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/effects.d.ts +4 -0
- package/dist/js/modules/fields/conditions/effects.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/evaluator.d.ts +6 -0
- package/dist/js/modules/fields/conditions/evaluator.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/references.d.ts +5 -0
- package/dist/js/modules/fields/conditions/references.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/transforms.d.ts +3 -0
- package/dist/js/modules/fields/conditions/transforms.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/types.d.ts +30 -0
- package/dist/js/modules/fields/conditions/types.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/values.d.ts +5 -0
- package/dist/js/modules/fields/conditions/values.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions.d.ts +3 -0
- package/dist/js/modules/fields/conditions.d.ts.map +1 -0
- package/dist/js/modules/fields/date-picker.d.ts +3 -0
- package/dist/js/modules/fields/date-picker.d.ts.map +1 -0
- package/dist/js/modules/fields/file-upload.d.ts +3 -0
- package/dist/js/modules/fields/file-upload.d.ts.map +1 -0
- package/dist/js/modules/fields/hidden.d.ts +3 -0
- package/dist/js/modules/fields/hidden.d.ts.map +1 -0
- package/dist/js/modules/fields/index.d.ts +3 -0
- package/dist/js/modules/fields/index.d.ts.map +1 -0
- package/dist/js/modules/fields/phone-country.d.ts +3 -0
- package/dist/js/modules/fields/phone-country.d.ts.map +1 -0
- package/dist/js/modules/fields/repeater.d.ts +3 -0
- package/dist/js/modules/fields/repeater.d.ts.map +1 -0
- package/dist/js/modules/fields/rich-text.d.ts +3 -0
- package/dist/js/modules/fields/rich-text.d.ts.map +1 -0
- package/dist/js/modules/fields/shared.d.ts +20 -0
- package/dist/js/modules/fields/shared.d.ts.map +1 -0
- package/dist/js/modules/fields/signature.d.ts +3 -0
- package/dist/js/modules/fields/signature.d.ts.map +1 -0
- package/dist/js/modules/fields/summary.d.ts +3 -0
- package/dist/js/modules/fields/summary.d.ts.map +1 -0
- package/dist/js/modules/fields/table.d.ts +3 -0
- package/dist/js/modules/fields/table.d.ts.map +1 -0
- package/dist/js/modules/fields/text-limit.d.ts +3 -0
- package/dist/js/modules/fields/text-limit.d.ts.map +1 -0
- package/dist/js/modules/loader.d.ts +11 -0
- package/dist/js/modules/loader.d.ts.map +1 -0
- package/dist/js/modules/payments/api.d.ts +8 -0
- package/dist/js/modules/payments/api.d.ts.map +1 -0
- package/dist/js/modules/payments/bpoint.d.ts +2 -0
- package/dist/js/modules/payments/bpoint.d.ts.map +1 -0
- package/dist/js/modules/payments/constants.d.ts +5 -0
- package/dist/js/modules/payments/constants.d.ts.map +1 -0
- package/dist/js/modules/payments/eway.d.ts +9 -0
- package/dist/js/modules/payments/eway.d.ts.map +1 -0
- package/dist/js/modules/payments/factories.d.ts +54 -0
- package/dist/js/modules/payments/factories.d.ts.map +1 -0
- package/dist/js/modules/payments/go-cardless.d.ts +2 -0
- package/dist/js/modules/payments/go-cardless.d.ts.map +1 -0
- package/dist/js/modules/payments/host.d.ts +70 -0
- package/dist/js/modules/payments/host.d.ts.map +1 -0
- package/dist/js/modules/payments/index.d.ts +3 -0
- package/dist/js/modules/payments/index.d.ts.map +1 -0
- package/dist/js/modules/payments/mollie.d.ts +2 -0
- package/dist/js/modules/payments/mollie.d.ts.map +1 -0
- package/dist/js/modules/payments/moneris.d.ts +2 -0
- package/dist/js/modules/payments/moneris.d.ts.map +1 -0
- package/dist/js/modules/payments/opayo.d.ts +25 -0
- package/dist/js/modules/payments/opayo.d.ts.map +1 -0
- package/dist/js/modules/payments/paddle.d.ts +2 -0
- package/dist/js/modules/payments/paddle.d.ts.map +1 -0
- package/dist/js/modules/payments/paypal.d.ts +2 -0
- package/dist/js/modules/payments/paypal.d.ts.map +1 -0
- package/dist/js/modules/payments/payway.d.ts +2 -0
- package/dist/js/modules/payments/payway.d.ts.map +1 -0
- package/dist/js/modules/payments/square.d.ts +2 -0
- package/dist/js/modules/payments/square.d.ts.map +1 -0
- package/dist/js/modules/payments/stripe.d.ts +2 -0
- package/dist/js/modules/payments/stripe.d.ts.map +1 -0
- package/dist/js/modules/payments/utils.d.ts +17 -0
- package/dist/js/modules/payments/utils.d.ts.map +1 -0
- package/dist/js/modules/registry.d.ts +9 -0
- package/dist/js/modules/registry.d.ts.map +1 -0
- package/dist/js/modules/styles.d.ts +2 -0
- package/dist/js/modules/styles.d.ts.map +1 -0
- package/dist/js/submit/pipeline.d.ts +18 -0
- package/dist/js/submit/pipeline.d.ts.map +1 -0
- package/dist/js/theme/theme-classes.d.ts +10 -0
- package/dist/js/theme/theme-classes.d.ts.map +1 -0
- package/dist/js/transport/forms-api.d.ts +11 -0
- package/dist/js/transport/forms-api.d.ts.map +1 -0
- package/dist/js/utils/async.d.ts +8 -0
- package/dist/js/utils/async.d.ts.map +1 -0
- package/dist/js/utils/debug.d.ts +10 -0
- package/dist/js/utils/debug.d.ts.map +1 -0
- package/dist/js/utils/event-names.d.ts +13 -0
- package/dist/js/utils/event-names.d.ts.map +1 -0
- package/dist/js/utils/field-references.d.ts +6 -0
- package/dist/js/utils/field-references.d.ts.map +1 -0
- package/dist/js/utils/field-references.keys.d.ts +4 -0
- package/dist/js/utils/field-references.keys.d.ts.map +1 -0
- package/dist/js/utils/field-references.parser.d.ts +3 -0
- package/dist/js/utils/field-references.parser.d.ts.map +1 -0
- package/dist/js/utils/field-references.registry.d.ts +3 -0
- package/dist/js/utils/field-references.registry.d.ts.map +1 -0
- package/dist/js/utils/field-references.resolver.d.ts +4 -0
- package/dist/js/utils/field-references.resolver.d.ts.map +1 -0
- package/dist/js/utils/field-references.types.d.ts +27 -0
- package/dist/js/utils/field-references.types.d.ts.map +1 -0
- package/dist/js/utils/fields.d.ts +5 -0
- package/dist/js/utils/fields.d.ts.map +1 -0
- package/dist/js/utils/http.d.ts +9 -0
- package/dist/js/utils/http.d.ts.map +1 -0
- package/dist/js/utils/i18n.d.ts +7 -0
- package/dist/js/utils/i18n.d.ts.map +1 -0
- package/dist/js/utils/scripts.d.ts +13 -0
- package/dist/js/utils/scripts.d.ts.map +1 -0
- package/dist/js/utils/unload-warning.d.ts +10 -0
- package/dist/js/utils/unload-warning.d.ts.map +1 -0
- package/dist/js/validation/rules/email.d.ts +4 -0
- package/dist/js/validation/rules/email.d.ts.map +1 -0
- package/dist/js/validation/rules/match.d.ts +4 -0
- package/dist/js/validation/rules/match.d.ts.map +1 -0
- package/dist/js/validation/rules/number.d.ts +4 -0
- package/dist/js/validation/rules/number.d.ts.map +1 -0
- package/dist/js/validation/rules/required.d.ts +4 -0
- package/dist/js/validation/rules/required.d.ts.map +1 -0
- package/dist/js/validation/rules/shared.d.ts +7 -0
- package/dist/js/validation/rules/shared.d.ts.map +1 -0
- package/dist/js/validation/rules/url.d.ts +4 -0
- package/dist/js/validation/rules/url.d.ts.map +1 -0
- package/dist/js/validation/rules.d.ts +10 -0
- package/dist/js/validation/rules.d.ts.map +1 -0
- package/dist/js/validation/scope.d.ts +6 -0
- package/dist/js/validation/scope.d.ts.map +1 -0
- package/dist/js/validation/submit-readiness.d.ts +4 -0
- package/dist/js/validation/submit-readiness.d.ts.map +1 -0
- package/dist/js/validation/types.d.ts +44 -0
- package/dist/js/validation/types.d.ts.map +1 -0
- package/dist/js/validation/validator.d.ts +54 -0
- package/dist/js/validation/validator.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/css/theme/forms/_form.css +28 -0
- package/src/js/core/create-formie-client.ts +6 -0
- package/src/js/core/submit-result-state.ts +17 -0
- package/src/js/modules/address/google-address.ts +33 -1
- package/src/js/modules/fields/conditions/effects.ts +79 -2
- package/src/js/modules/fields/conditions.ts +53 -11
- package/src/js/modules/fields/file-upload.ts +189 -97
- package/src/js/modules/fields/repeater.ts +1 -1
- package/src/js/modules/fields/rich-text.ts +2 -2
- package/src/js/modules/fields/signature.ts +1 -1
- package/src/js/modules/fields/summary.ts +1 -1
- package/src/js/modules/fields/table.ts +1 -1
- package/src/js/modules/fields/text-limit.ts +1 -1
- package/src/js/modules/payments/paypal.ts +1 -1
- package/src/js/modules/payments/payway.ts +1 -1
- package/src/js/modules/payments/stripe.ts +1 -1
- package/src/js/submit/pipeline.ts +3 -28
- package/src/js/validation/scope.ts +25 -0
- package/src/js/validation/submit-readiness.ts +157 -0
- package/src/js/validation/validator.ts +4 -0
- package/dist/chunks/address-finder-DfMCiW89.js +0 -47
- package/dist/chunks/api-CbqEMQT5.js +0 -181
- package/dist/chunks/api-DE7LfK-R.js +0 -960
- package/dist/chunks/api-DOfDzYC_.js +0 -538
- package/dist/chunks/async-B3DUf1GZ.js +0 -26
- package/dist/chunks/bpoint-Ciy3yY9Q.js +0 -34
- package/dist/chunks/calculations-CkYAqO_-.js +0 -197
- package/dist/chunks/captcha-eu-DnOWhMwr.js +0 -43
- package/dist/chunks/checkbox-radio-0x7Tc0br.js +0 -197
- package/dist/chunks/chunk-K6L4z4UQ.js +0 -24
- package/dist/chunks/conditions-4fXKhEJS.js +0 -609
- package/dist/chunks/date-picker-B6iZkjHS.js +0 -6204
- package/dist/chunks/debug-KnZeKYBI.js +0 -39
- package/dist/chunks/dist-D09GnXMW.js +0 -2663
- package/dist/chunks/event-names-DamGPtXR.js +0 -51
- package/dist/chunks/eway-DEAYcwT0.js +0 -86
- package/dist/chunks/field-references.keys-BpBZ_quS.js +0 -24
- package/dist/chunks/field-references.resolver-Ba6xhiJC.js +0 -183
- package/dist/chunks/file-upload-BIj85NFH.js +0 -428
- package/dist/chunks/friendly-captcha-v1-CqO4WVre.js +0 -40
- package/dist/chunks/friendly-captcha-v2-CyykcJcM.js +0 -47
- package/dist/chunks/friendly-challenge-Dg8XkStd.js +0 -1101
- package/dist/chunks/go-cardless-CuND59rR.js +0 -26
- package/dist/chunks/google-address--uR8WDSm.js +0 -208
- package/dist/chunks/hcaptcha-CmaFUesv.js +0 -72
- package/dist/chunks/hidden-CYnZYple.js +0 -36
- package/dist/chunks/http-18nn97DZ.js +0 -29
- package/dist/chunks/i18n-vUh-KGiH.js +0 -55
- package/dist/chunks/loqate-BICNJlVK.js +0 -97
- package/dist/chunks/mollie-DwlsgHZ1.js +0 -26
- package/dist/chunks/moneris-B_IFZFTx.js +0 -159
- package/dist/chunks/opayo-U2x_TOII.js +0 -192
- package/dist/chunks/paddle-BqXFrc79.js +0 -75
- package/dist/chunks/paypal-VowQ3ilP.js +0 -121
- package/dist/chunks/payway-VOO-ajyg.js +0 -75
- package/dist/chunks/phone-country-B6Me4lK0.js +0 -3317
- package/dist/chunks/place-kit-ldUl-u9w.js +0 -56
- package/dist/chunks/placekit-autocomplete.esm-D-lGeaZl.js +0 -1771
- package/dist/chunks/recaptcha-enterprise-DPJNyv1X.js +0 -72
- package/dist/chunks/recaptcha-shared-DTI4qWVR.js +0 -22
- package/dist/chunks/recaptcha-v2-checkbox-zFjpvJ5c.js +0 -49
- package/dist/chunks/recaptcha-v2-invisible-CnYtkNvz.js +0 -62
- package/dist/chunks/recaptcha-v3-EAlWhnkX.js +0 -33
- package/dist/chunks/repeater-BPm7Mkyn.js +0 -149
- package/dist/chunks/rich-text-CHSly1Hq.js +0 -438
- package/dist/chunks/scripts-BGD_iU_6.js +0 -41
- package/dist/chunks/sdk-B7u9fTlP.js +0 -2103
- package/dist/chunks/shared-DC6_1u8X.js +0 -85
- package/dist/chunks/signature-DNMCgrMd.js +0 -763
- package/dist/chunks/snaptcha-CCDunGeb.js +0 -8
- package/dist/chunks/square-BLqK51rS.js +0 -61
- package/dist/chunks/stripe-B6ZcDQdx.js +0 -273
- package/dist/chunks/styles-BIh6g7V_.js +0 -22
- package/dist/chunks/summary-BTG0uIOt.js +0 -189
- package/dist/chunks/table-BTYc0Qm8.js +0 -122
- package/dist/chunks/text-limit-CgBMu4sJ.js +0 -177
- package/dist/chunks/theme-classes-vSHpdCUO.js +0 -59
- package/dist/chunks/turnstile-DP0bdR7T.js +0 -68
- package/dist/chunks/utils-ByrEVYrJ.js +0 -49584
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import fileUploadCss from '#theme/fields/_file.css?inline';
|
|
1
|
+
import fileUploadCss from '#theme-css/fields/_file.css?inline';
|
|
2
2
|
|
|
3
3
|
import type { FormieModuleDefinition } from '#contracts/modules';
|
|
4
|
-
import { dispatchFieldEvent,
|
|
4
|
+
import { dispatchFieldEvent, releaseFormValidators, retainFormValidators } from '#modules/fields/shared';
|
|
5
5
|
import { ensureModuleStyles } from '#modules/styles';
|
|
6
|
-
import { getFileUploadEventName, getFormStateEventName } from '#utils/event-names';
|
|
6
|
+
import { getFieldModuleEventName, getFileUploadEventName, getFormStateEventName } from '#utils/event-names';
|
|
7
7
|
import { requestJson } from '#utils/http';
|
|
8
8
|
|
|
9
9
|
const INPUT_SELECTOR = 'input[type="file"][data-formie-file-input]';
|
|
@@ -20,6 +20,8 @@ const FILE_VALIDATORS = [
|
|
|
20
20
|
] as const;
|
|
21
21
|
const VALIDATOR_SCOPE = 'file-upload';
|
|
22
22
|
const MODULE_ID = 'file-upload';
|
|
23
|
+
const REPEATER_INIT_ROW_EVENT = getFieldModuleEventName('repeater', 'init-row');
|
|
24
|
+
const FIELD_HANDLE_SELECTOR = '[data-formie-field-handle]';
|
|
23
25
|
|
|
24
26
|
ensureModuleStyles(MODULE_ID, [fileUploadCss]);
|
|
25
27
|
|
|
@@ -366,6 +368,47 @@ function updateUploadedAssetInputs(field: HTMLElement, input: HTMLInputElement,
|
|
|
366
368
|
input.value = '';
|
|
367
369
|
}
|
|
368
370
|
|
|
371
|
+
function getFormHandle(form: HTMLFormElement | null): string {
|
|
372
|
+
if (!form) {
|
|
373
|
+
return '';
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const handleInput = form.querySelector('input[name="handle"]');
|
|
377
|
+
|
|
378
|
+
if (handleInput instanceof HTMLInputElement && handleInput.value.trim()) {
|
|
379
|
+
return handleInput.value.trim();
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return form.getAttribute('data-formie-handle')?.trim() || '';
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function buildHydrateFormData(field: HTMLElement, input: HTMLInputElement, assetIds: number[]): FormData {
|
|
386
|
+
const form = input.form;
|
|
387
|
+
const body = new FormData();
|
|
388
|
+
const handle = getFormHandle(form);
|
|
389
|
+
const fieldHandle = getFieldHandle(field);
|
|
390
|
+
|
|
391
|
+
if (handle) {
|
|
392
|
+
body.append('handle', handle);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
if (fieldHandle) {
|
|
396
|
+
body.append('fieldHandle', fieldHandle);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const submissionUidInput = form?.querySelector('input[name="submissionUid"]');
|
|
400
|
+
|
|
401
|
+
if (submissionUidInput instanceof HTMLInputElement && submissionUidInput.value.trim()) {
|
|
402
|
+
body.append('submissionUid', submissionUidInput.value.trim());
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
assetIds.forEach((assetId) => {
|
|
406
|
+
body.append('assetIds[]', String(assetId));
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
return body;
|
|
410
|
+
}
|
|
411
|
+
|
|
369
412
|
async function hydrateUploadedAssets(field: HTMLElement, input: HTMLInputElement, uploadedAssets: UploadedAsset[]): Promise<UploadedAsset[]> {
|
|
370
413
|
const assetIds = uploadedAssets.map((asset) => {
|
|
371
414
|
return asset.assetId;
|
|
@@ -378,14 +421,9 @@ async function hydrateUploadedAssets(field: HTMLElement, input: HTMLInputElement
|
|
|
378
421
|
}
|
|
379
422
|
|
|
380
423
|
const hydrateEndpoint = input.getAttribute(HYDRATE_ENDPOINT_ATTR)?.trim() || '/actions/formie/file-upload/hydrate';
|
|
381
|
-
const body = new FormData();
|
|
382
|
-
assetIds.forEach((assetId) => {
|
|
383
|
-
body.append('assetIds[]', String(assetId));
|
|
384
|
-
});
|
|
385
|
-
|
|
386
424
|
const response = await requestJson<FileUploadHydrateResponse>(hydrateEndpoint, {
|
|
387
425
|
method: 'POST',
|
|
388
|
-
body,
|
|
426
|
+
body: buildHydrateFormData(field, input, assetIds),
|
|
389
427
|
});
|
|
390
428
|
const hydratedAssets = normalizeUploadedAssets(response.assets);
|
|
391
429
|
|
|
@@ -504,6 +542,118 @@ function getUploadedAssetsFromEvent(event: Event, matcher: FileUploadEventMatche
|
|
|
504
542
|
return [];
|
|
505
543
|
}
|
|
506
544
|
|
|
545
|
+
function getFieldContainer(input: HTMLInputElement): HTMLElement | null {
|
|
546
|
+
const field = input.closest(FIELD_HANDLE_SELECTOR);
|
|
547
|
+
|
|
548
|
+
return field instanceof HTMLElement ? field : null;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function collectFileUploadInputs(root: ParentNode): HTMLInputElement[] {
|
|
552
|
+
return Array.from(root.querySelectorAll(INPUT_SELECTOR)).filter((input): input is HTMLInputElement => {
|
|
553
|
+
return input instanceof HTMLInputElement;
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function bindFileUploadInput(field: HTMLElement, input: HTMLInputElement, form: HTMLFormElement | null): () => void {
|
|
558
|
+
const state: FileUploadState = {
|
|
559
|
+
field,
|
|
560
|
+
input,
|
|
561
|
+
summaryRoot: ensureSummaryRoot(field, input),
|
|
562
|
+
uploadedAssets: mergeUploadedAssets(
|
|
563
|
+
readUploadedAssetsFromHiddenInputs(field, input),
|
|
564
|
+
readSummaryItems(field.querySelector('[data-formie-file-summary]') as HTMLElement | null),
|
|
565
|
+
),
|
|
566
|
+
pendingFiles: [],
|
|
567
|
+
hydrationToken: 0,
|
|
568
|
+
};
|
|
569
|
+
const syncPendingFiles = () => {
|
|
570
|
+
state.pendingFiles = Array.from(input.files || []).map((file) => {
|
|
571
|
+
return file.name;
|
|
572
|
+
});
|
|
573
|
+
renderSummary(state);
|
|
574
|
+
};
|
|
575
|
+
const syncUploadedAssets = async(uploadedAssets: UploadedAsset[]) => {
|
|
576
|
+
state.hydrationToken += 1;
|
|
577
|
+
const hydrationToken = state.hydrationToken;
|
|
578
|
+
state.pendingFiles = [];
|
|
579
|
+
state.uploadedAssets = uploadedAssets;
|
|
580
|
+
updateUploadedAssetInputs(field, input, uploadedAssets);
|
|
581
|
+
renderSummary(state);
|
|
582
|
+
|
|
583
|
+
try {
|
|
584
|
+
const hydratedAssets = await hydrateUploadedAssets(field, input, uploadedAssets);
|
|
585
|
+
|
|
586
|
+
if (hydrationToken !== state.hydrationToken) {
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
state.uploadedAssets = hydratedAssets;
|
|
591
|
+
renderSummary(state);
|
|
592
|
+
dispatchFieldEvent(field, MODULE_ID, 'uploaded-assets-sync', {
|
|
593
|
+
fileUpload: field,
|
|
594
|
+
assets: hydratedAssets,
|
|
595
|
+
});
|
|
596
|
+
} catch (error) {
|
|
597
|
+
console.error('[formie] Failed to hydrate uploaded file details.', error);
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
const resetUploadedAssets = () => {
|
|
601
|
+
state.hydrationToken += 1;
|
|
602
|
+
state.pendingFiles = [];
|
|
603
|
+
state.uploadedAssets = [];
|
|
604
|
+
updateUploadedAssetInputs(field, input, []);
|
|
605
|
+
renderSummary(state);
|
|
606
|
+
};
|
|
607
|
+
const uploadedAssetHandler = (event: Event) => {
|
|
608
|
+
const fieldHandle = getFieldHandle(field);
|
|
609
|
+
|
|
610
|
+
if (!fieldHandle) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
const uploadedAssets = getUploadedAssetsFromEvent(event, {
|
|
615
|
+
fieldHandle,
|
|
616
|
+
inputKey: getFileUploadKey(input),
|
|
617
|
+
inputName: input.name,
|
|
618
|
+
pendingFiles: state.pendingFiles,
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
if (!uploadedAssets.length) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
void syncUploadedAssets(uploadedAssets);
|
|
626
|
+
};
|
|
627
|
+
const resetHandler = () => {
|
|
628
|
+
resetUploadedAssets();
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
input.addEventListener('change', syncPendingFiles);
|
|
632
|
+
form?.addEventListener(FILE_UPLOAD_EVENT, uploadedAssetHandler as EventListener);
|
|
633
|
+
form?.addEventListener(FORM_RESET_EVENT, resetHandler as EventListener);
|
|
634
|
+
|
|
635
|
+
const syncInitialState = () => {
|
|
636
|
+
const assetIdsFromDom = readUploadedAssetsFromHiddenInputs(field, input);
|
|
637
|
+
const summaryItems = readSummaryItems(state.summaryRoot);
|
|
638
|
+
state.uploadedAssets = mergeUploadedAssets(assetIdsFromDom, summaryItems);
|
|
639
|
+
|
|
640
|
+
if (state.uploadedAssets.some((asset) => asset.assetId && !asset.filename)) {
|
|
641
|
+
void syncUploadedAssets(state.uploadedAssets);
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
renderSummary(state);
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
syncInitialState();
|
|
649
|
+
|
|
650
|
+
return () => {
|
|
651
|
+
input.removeEventListener('change', syncPendingFiles);
|
|
652
|
+
form?.removeEventListener(FILE_UPLOAD_EVENT, uploadedAssetHandler as EventListener);
|
|
653
|
+
form?.removeEventListener(FORM_RESET_EVENT, resetHandler as EventListener);
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
|
|
507
657
|
export const fileUploadModule: FormieModuleDefinition = {
|
|
508
658
|
id: MODULE_ID,
|
|
509
659
|
kind: 'field',
|
|
@@ -511,111 +661,53 @@ export const fileUploadModule: FormieModuleDefinition = {
|
|
|
511
661
|
return !!ctx.target.querySelector(INPUT_SELECTOR);
|
|
512
662
|
},
|
|
513
663
|
setup: async(ctx) => {
|
|
514
|
-
const field = getModuleFieldTarget(ctx);
|
|
515
|
-
const scope = field || ctx.target;
|
|
516
|
-
const inputs = Array.from(scope.querySelectorAll(INPUT_SELECTOR)).filter((input): input is HTMLInputElement => {
|
|
517
|
-
return input instanceof HTMLInputElement;
|
|
518
|
-
});
|
|
519
664
|
const form = ctx.form;
|
|
665
|
+
const boundInputs = new WeakSet<HTMLInputElement>();
|
|
666
|
+
const unbinds: Array<() => void> = [];
|
|
520
667
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
if (!(field instanceof HTMLElement)) {
|
|
525
|
-
return () => {};
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
const state: FileUploadState = {
|
|
529
|
-
field,
|
|
530
|
-
input,
|
|
531
|
-
summaryRoot: ensureSummaryRoot(field, input),
|
|
532
|
-
uploadedAssets: mergeUploadedAssets(
|
|
533
|
-
readUploadedAssetsFromHiddenInputs(field, input),
|
|
534
|
-
readSummaryItems(field.querySelector('[data-formie-file-summary]') as HTMLElement | null)
|
|
535
|
-
),
|
|
536
|
-
pendingFiles: [],
|
|
537
|
-
hydrationToken: 0,
|
|
538
|
-
};
|
|
539
|
-
const syncPendingFiles = () => {
|
|
540
|
-
state.pendingFiles = Array.from(input.files || []).map((file) => {
|
|
541
|
-
return file.name;
|
|
542
|
-
});
|
|
543
|
-
renderSummary(state);
|
|
544
|
-
};
|
|
545
|
-
const syncUploadedAssets = async(uploadedAssets: UploadedAsset[]) => {
|
|
546
|
-
state.hydrationToken += 1;
|
|
547
|
-
const hydrationToken = state.hydrationToken;
|
|
548
|
-
state.pendingFiles = [];
|
|
549
|
-
state.uploadedAssets = uploadedAssets;
|
|
550
|
-
updateUploadedAssetInputs(field, input, uploadedAssets);
|
|
551
|
-
renderSummary(state);
|
|
552
|
-
|
|
553
|
-
try {
|
|
554
|
-
const hydratedAssets = await hydrateUploadedAssets(field, input, uploadedAssets);
|
|
555
|
-
|
|
556
|
-
if (hydrationToken !== state.hydrationToken) {
|
|
557
|
-
return;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
state.uploadedAssets = hydratedAssets;
|
|
561
|
-
renderSummary(state);
|
|
562
|
-
dispatchFieldEvent(field, MODULE_ID, 'uploaded-assets-sync', {
|
|
563
|
-
fileUpload: field,
|
|
564
|
-
assets: hydratedAssets,
|
|
565
|
-
});
|
|
566
|
-
} catch (error) {
|
|
567
|
-
console.error('[formie] Failed to hydrate uploaded file details.', error);
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
const resetUploadedAssets = () => {
|
|
571
|
-
state.hydrationToken += 1;
|
|
572
|
-
state.pendingFiles = [];
|
|
573
|
-
state.uploadedAssets = [];
|
|
574
|
-
updateUploadedAssetInputs(field, input, []);
|
|
575
|
-
renderSummary(state);
|
|
576
|
-
};
|
|
577
|
-
const uploadedAssetHandler = (event: Event) => {
|
|
578
|
-
const fieldHandle = getFieldHandle(field);
|
|
579
|
-
|
|
580
|
-
if (!fieldHandle) {
|
|
668
|
+
const bindInputsInRoot = (root: ParentNode) => {
|
|
669
|
+
collectFileUploadInputs(root).forEach((input) => {
|
|
670
|
+
if (boundInputs.has(input)) {
|
|
581
671
|
return;
|
|
582
672
|
}
|
|
583
673
|
|
|
584
|
-
const
|
|
585
|
-
fieldHandle,
|
|
586
|
-
inputKey: getFileUploadKey(input),
|
|
587
|
-
inputName: input.name,
|
|
588
|
-
pendingFiles: state.pendingFiles,
|
|
589
|
-
});
|
|
674
|
+
const field = getFieldContainer(input);
|
|
590
675
|
|
|
591
|
-
if (!
|
|
676
|
+
if (!field) {
|
|
592
677
|
return;
|
|
593
678
|
}
|
|
594
679
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
680
|
+
boundInputs.add(input);
|
|
681
|
+
unbinds.push(bindFileUploadInput(field, input, form));
|
|
682
|
+
});
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
registerValidators(form);
|
|
686
|
+
bindInputsInRoot(ctx.target);
|
|
600
687
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
form?.addEventListener(FORM_RESET_EVENT, resetHandler as EventListener);
|
|
604
|
-
renderSummary(state);
|
|
688
|
+
const repeaterInitRowHandler = (event: Event) => {
|
|
689
|
+
const detail = (event as CustomEvent<unknown>).detail;
|
|
605
690
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
691
|
+
if (!isRecord(detail)) {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
const row = detail.row;
|
|
696
|
+
|
|
697
|
+
if (row instanceof HTMLElement) {
|
|
698
|
+
bindInputsInRoot(row);
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
form?.addEventListener(REPEATER_INIT_ROW_EVENT, repeaterInitRowHandler as EventListener);
|
|
612
703
|
|
|
613
704
|
await ctx.emit('formie:module:file-upload:init', {
|
|
614
|
-
count:
|
|
705
|
+
count: unbinds.length,
|
|
615
706
|
});
|
|
616
707
|
|
|
617
708
|
return {
|
|
618
709
|
destroy: () => {
|
|
710
|
+
form?.removeEventListener(REPEATER_INIT_ROW_EVENT, repeaterInitRowHandler as EventListener);
|
|
619
711
|
unbinds.forEach((unbind) => {
|
|
620
712
|
unbind();
|
|
621
713
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import repeaterCss from '#theme/fields/_repeater.css?inline';
|
|
1
|
+
import repeaterCss from '#theme-css/fields/_repeater.css?inline';
|
|
2
2
|
|
|
3
3
|
import type { FormieModuleDefinition } from '#contracts/modules';
|
|
4
4
|
import { dispatchFieldEvent, getTemplateSource, getTemplateSourceHtml } from '#modules/fields/shared';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { exec, init as initPell } from 'pell';
|
|
2
2
|
import pellCss from 'pell/dist/pell.min.css?inline';
|
|
3
|
-
import tokensCss from '#theme/_tokens.css?inline';
|
|
4
|
-
import richTextCss from '#theme/fields/_rich-text.css?inline';
|
|
3
|
+
import tokensCss from '#theme-css/_tokens.css?inline';
|
|
4
|
+
import richTextCss from '#theme-css/fields/_rich-text.css?inline';
|
|
5
5
|
import alignCenterIcon from '#icons/rich-text/aligncenter.svg?raw';
|
|
6
6
|
import alignLeftIcon from '#icons/rich-text/alignleft.svg?raw';
|
|
7
7
|
import alignRightIcon from '#icons/rich-text/alignright.svg?raw';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import SignaturePad from 'signature_pad';
|
|
2
|
-
import signatureCss from '#theme/fields/_signature.css?inline';
|
|
2
|
+
import signatureCss from '#theme-css/fields/_signature.css?inline';
|
|
3
3
|
|
|
4
4
|
import type { FormieModuleDefinition } from '#contracts/modules';
|
|
5
5
|
import { dispatchFieldEvent, getModuleFieldContainers } from '#modules/fields/shared';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import summaryCss from '#theme/fields/_summary.css?inline';
|
|
1
|
+
import summaryCss from '#theme-css/fields/_summary.css?inline';
|
|
2
2
|
|
|
3
3
|
import type { FormieModuleDefinition } from '#contracts/modules';
|
|
4
4
|
import { dispatchFieldEvent, getModuleFieldContainers } from '#modules/fields/shared';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import tableCss from '#theme/fields/_table.css?inline';
|
|
1
|
+
import tableCss from '#theme-css/fields/_table.css?inline';
|
|
2
2
|
|
|
3
3
|
import type { FormieModuleDefinition } from '#contracts/modules';
|
|
4
4
|
import { dispatchFieldEvent, getTemplateSource, getTemplateSourceHtml } from '#modules/fields/shared';
|
|
@@ -3,6 +3,7 @@ import type { FormSubmitResult } from '#contracts/schema';
|
|
|
3
3
|
import { EventBus } from '#events/event-bus';
|
|
4
4
|
import { submitForm } from '#transport/forms-api';
|
|
5
5
|
import { createDebug } from '#utils/debug';
|
|
6
|
+
import { getFormPages, getValidationScope } from '#validation/scope';
|
|
6
7
|
import type { FormieValidator } from '#validation/validator';
|
|
7
8
|
|
|
8
9
|
export type SubmitPipelineContext = {
|
|
@@ -30,32 +31,6 @@ function getAbortedResult(stage: SubmitStage, reason?: string): FormSubmitResult
|
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
function getPages(form: HTMLFormElement): HTMLElement[] {
|
|
34
|
-
return Array.from(form.querySelectorAll('[data-formie-page]')) as HTMLElement[];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function getValidationScope(form: HTMLFormElement): { scope: Element; final: boolean } {
|
|
38
|
-
const pages = getPages(form);
|
|
39
|
-
|
|
40
|
-
if (!pages.length) {
|
|
41
|
-
return {
|
|
42
|
-
scope: form,
|
|
43
|
-
final: true,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Multi-page submits validate the visible page until the user reaches the
|
|
48
|
-
// final step, where hidden earlier pages are included again.
|
|
49
|
-
const currentPage = pages.find((page) => {
|
|
50
|
-
return !page.hasAttribute('data-formie-page-hidden');
|
|
51
|
-
}) || pages[pages.length - 1];
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
scope: currentPage,
|
|
55
|
-
final: currentPage === pages[pages.length - 1],
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
34
|
function isSubmittableControl(element: Element): element is HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement {
|
|
60
35
|
return element instanceof HTMLInputElement
|
|
61
36
|
|| element instanceof HTMLSelectElement
|
|
@@ -172,7 +147,7 @@ function appendMissingFieldClears(formData: FormData, fieldNames: Set<string>):
|
|
|
172
147
|
}
|
|
173
148
|
|
|
174
149
|
function buildSubmitFormData(form: HTMLFormElement, action: FormAction): FormData {
|
|
175
|
-
const pages =
|
|
150
|
+
const pages = getFormPages(form);
|
|
176
151
|
const currentPage = pages.find((page) => {
|
|
177
152
|
return !page.hasAttribute('data-formie-page-hidden');
|
|
178
153
|
}) || null;
|
|
@@ -200,7 +175,7 @@ function isFinalSubmitAttempt(form: HTMLFormElement, action: FormAction): boolea
|
|
|
200
175
|
return false;
|
|
201
176
|
}
|
|
202
177
|
|
|
203
|
-
const pages =
|
|
178
|
+
const pages = getFormPages(form);
|
|
204
179
|
|
|
205
180
|
if (!pages.length) {
|
|
206
181
|
return true;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function getFormPages(form: HTMLFormElement): HTMLElement[] {
|
|
2
|
+
return Array.from(form.querySelectorAll('[data-formie-page]')) as HTMLElement[];
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function getValidationScope(form: HTMLFormElement): { scope: Element; final: boolean } {
|
|
6
|
+
const pages = getFormPages(form);
|
|
7
|
+
|
|
8
|
+
if (!pages.length) {
|
|
9
|
+
return {
|
|
10
|
+
scope: form,
|
|
11
|
+
final: true,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Multi-page submits validate the visible page until the user reaches the
|
|
16
|
+
// final step, where hidden earlier pages are included again.
|
|
17
|
+
const currentPage = pages.find((page) => {
|
|
18
|
+
return !page.hasAttribute('data-formie-page-hidden');
|
|
19
|
+
}) || pages[pages.length - 1];
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
scope: currentPage,
|
|
23
|
+
final: currentPage === pages[pages.length - 1],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { getValidationScope } from '#validation/scope';
|
|
2
|
+
import type { FormieValidator } from '#validation/validator';
|
|
3
|
+
|
|
4
|
+
const SUBMIT_VALIDATION_DISABLED_ATTR = 'data-formie-submit-validation-disabled';
|
|
5
|
+
const PRESERVED_DISABLED_ATTR = 'data-formie-preserve-disabled';
|
|
6
|
+
const SUBMIT_READY_ATTR = 'data-formie-submit-ready';
|
|
7
|
+
|
|
8
|
+
function isSubmitReadinessEnabled(form: HTMLFormElement): boolean {
|
|
9
|
+
return form.dataset.formieDisableSubmitUntilValid === 'true';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getPrimarySubmitButtons(form: HTMLFormElement): HTMLButtonElement[] {
|
|
13
|
+
return Array.from(form.querySelectorAll('button[data-formie-action="submit"]')).filter((button): button is HTMLButtonElement => {
|
|
14
|
+
return button instanceof HTMLButtonElement;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isSubmitButtonVisible(button: HTMLButtonElement): boolean {
|
|
19
|
+
return !button.hasAttribute('data-formie-conditionally-hidden')
|
|
20
|
+
&& !button.closest('[data-formie-conditionally-hidden]');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function syncSubmitReadiness(form: HTMLFormElement, validator: FormieValidator): void {
|
|
24
|
+
if (!isSubmitReadinessEnabled(form)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (form.getAttribute('data-formie-loading') === 'true') {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const { scope, final } = getValidationScope(form);
|
|
33
|
+
const isReady = validator.isValid(scope, {
|
|
34
|
+
includeHiddenPages: final,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
form.setAttribute(SUBMIT_READY_ATTR, isReady ? 'true' : 'false');
|
|
38
|
+
|
|
39
|
+
getPrimarySubmitButtons(form).forEach((button) => {
|
|
40
|
+
if (!isSubmitButtonVisible(button)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (isReady) {
|
|
45
|
+
if (!button.hasAttribute(SUBMIT_VALIDATION_DISABLED_ATTR)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (button.hasAttribute(PRESERVED_DISABLED_ATTR)) {
|
|
50
|
+
button.disabled = true;
|
|
51
|
+
button.removeAttribute(PRESERVED_DISABLED_ATTR);
|
|
52
|
+
} else {
|
|
53
|
+
button.disabled = false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
button.removeAttribute(SUBMIT_VALIDATION_DISABLED_ATTR);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!button.hasAttribute(SUBMIT_VALIDATION_DISABLED_ATTR)) {
|
|
61
|
+
if (button.disabled) {
|
|
62
|
+
button.setAttribute(PRESERVED_DISABLED_ATTR, 'true');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
button.setAttribute(SUBMIT_VALIDATION_DISABLED_ATTR, 'true');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
button.disabled = true;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function bindSubmitReadiness(
|
|
73
|
+
form: HTMLFormElement,
|
|
74
|
+
validator: FormieValidator,
|
|
75
|
+
target: Element,
|
|
76
|
+
): () => void {
|
|
77
|
+
if (!isSubmitReadinessEnabled(form)) {
|
|
78
|
+
return () => {};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let syncQueued = false;
|
|
82
|
+
|
|
83
|
+
const scheduleSync = (): void => {
|
|
84
|
+
if (syncQueued) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
syncQueued = true;
|
|
89
|
+
|
|
90
|
+
queueMicrotask(() => {
|
|
91
|
+
syncQueued = false;
|
|
92
|
+
syncSubmitReadiness(form, validator);
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
scheduleSync();
|
|
97
|
+
|
|
98
|
+
const inputHandler = (): void => {
|
|
99
|
+
scheduleSync();
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
form.addEventListener('input', inputHandler, true);
|
|
103
|
+
form.addEventListener('change', inputHandler, true);
|
|
104
|
+
|
|
105
|
+
const resetHandler = (): void => {
|
|
106
|
+
window.setTimeout(() => {
|
|
107
|
+
scheduleSync();
|
|
108
|
+
}, 0);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
form.addEventListener('reset', resetHandler);
|
|
112
|
+
|
|
113
|
+
const conditionsHandler = (): void => {
|
|
114
|
+
scheduleSync();
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
target.addEventListener('formie:conditions:evaluated', conditionsHandler as EventListener);
|
|
118
|
+
|
|
119
|
+
const observer = new MutationObserver((mutations) => {
|
|
120
|
+
const shouldSync = mutations.some((mutation) => {
|
|
121
|
+
if (mutation.type === 'attributes') {
|
|
122
|
+
const attributeName = mutation.attributeName || '';
|
|
123
|
+
|
|
124
|
+
return attributeName === 'data-formie-page-hidden'
|
|
125
|
+
|| attributeName === 'data-formie-conditionally-hidden'
|
|
126
|
+
|| attributeName === 'data-formie-loading'
|
|
127
|
+
|| attributeName === 'disabled';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return mutation.type === 'childList';
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (shouldSync) {
|
|
134
|
+
scheduleSync();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
observer.observe(form, {
|
|
139
|
+
childList: true,
|
|
140
|
+
subtree: true,
|
|
141
|
+
attributes: true,
|
|
142
|
+
attributeFilter: [
|
|
143
|
+
'data-formie-page-hidden',
|
|
144
|
+
'data-formie-conditionally-hidden',
|
|
145
|
+
'data-formie-loading',
|
|
146
|
+
'disabled',
|
|
147
|
+
],
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
return () => {
|
|
151
|
+
form.removeEventListener('input', inputHandler, true);
|
|
152
|
+
form.removeEventListener('change', inputHandler, true);
|
|
153
|
+
form.removeEventListener('reset', resetHandler);
|
|
154
|
+
target.removeEventListener('formie:conditions:evaluated', conditionsHandler as EventListener);
|
|
155
|
+
observer.disconnect();
|
|
156
|
+
};
|
|
157
|
+
}
|
|
@@ -176,6 +176,10 @@ export class FormieValidator {
|
|
|
176
176
|
return this.submitted || this.activated.has(input);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
isValid(inputOrSelector: Element | null = null, options: ValidateOptions = {}): boolean {
|
|
180
|
+
return this.validate(inputOrSelector, options).length === 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
179
183
|
validate(inputOrSelector: Element | null = null, options: ValidateOptions = {}): ValidationError[] {
|
|
180
184
|
this.errors = [];
|
|
181
185
|
|