@verbb/formie-browser 1.0.13 → 1.0.14
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 +50 -0
- package/dist/chunks/{address-country-Rx6GQTND.js → address-country-Dn71jroa.js} +10 -4
- package/dist/chunks/{address-finder-k7_BXaRe.js → address-finder-O49uDRoR.js} +2 -2
- package/dist/chunks/{address-state-BwE01m2_.js → address-state-ByYatUur.js} +154 -143
- package/dist/chunks/{api-DqpfkZWL.js → api-D6kJ7kXZ.js} +183 -179
- package/dist/chunks/{api-BUb6P-xu.js → api-DYYsVIub.js} +77 -47
- package/dist/chunks/{api-sPqGbOww.js → api-ghNr2uxX.js} +15 -9
- package/dist/chunks/{bpoint-Dlq34XH1.js → bpoint-D0RKFM4F.js} +3 -3
- package/dist/chunks/calculations-YEoVCG2q.js +310 -0
- package/dist/chunks/{captcha-eu-CGm8Lbrj.js → captcha-eu-DERJbXnH.js} +5 -4
- package/dist/chunks/{checkbox-radio-BY2aTCOG.js → checkbox-radio-gsm8QPJg.js} +74 -75
- package/dist/chunks/{combobox-C0EuExSI.js → combobox-CWNdx4Fk.js} +290 -279
- package/dist/chunks/conditions-DqNHLTbN.js +464 -0
- package/dist/chunks/country-from-ip-DDj_mFki.js +29 -0
- package/dist/chunks/csrf-DxHg_ZYt.js +61 -0
- package/dist/chunks/{custom-google-maps-BsaSirEZ.js → custom-google-maps-C4l2S3GO.js} +9 -3
- package/dist/chunks/{custom-link-CJ1-FjEM.js → custom-link-CLazgKYH.js} +8 -2
- package/dist/chunks/{custom-maps-DYW_pBid.js → custom-maps-DqcAlD0v.js} +10 -4
- package/dist/chunks/{date-picker-F9BUBDSW.js → date-picker-RUnevF7l.js} +455 -432
- package/dist/chunks/{dist-D6i-VNgM.js → dist-ZLeW0zZ3.js} +1281 -453
- package/dist/chunks/{eway-D9_m8ooj.js → eway-or6dtjoT.js} +3 -3
- package/dist/chunks/field-references.resolver-Ca8MguFv.js +104 -0
- package/dist/chunks/{file-upload-rqfZNqlH.js → file-upload-Bm-TXyNB.js} +104 -96
- package/dist/chunks/friendly-captcha-v1-GFqCt1Mh.js +34 -0
- package/dist/chunks/{friendly-captcha-v2-CLSAbkqx.js → friendly-captcha-v2-WoW246JG.js} +6 -5
- package/dist/chunks/{friendly-challenge-8uPatWqk.js → friendly-challenge-DPG9MJb1.js} +111 -102
- package/dist/chunks/{go-cardless-DAT3ZaQf.js → go-cardless-DzJ-0FKg.js} +2 -2
- package/dist/chunks/google-address-C1P1nTDM.js +163 -0
- package/dist/chunks/{hcaptcha-CGLAmgjO.js → hcaptcha-D0T8aIHz.js} +3 -3
- package/dist/chunks/{hidden-D7_Ch-QN.js → hidden-BZhXnNPe.js} +8 -2
- package/dist/chunks/http-C2QdHuWO.js +27 -0
- package/dist/chunks/{leaflet-src-j-lHNmhR.js → leaflet-src-DE6rv6M-.js} +42 -46
- package/dist/chunks/{loqate-CJPzBmSm.js → loqate-DD1S7PY9.js} +2 -2
- package/dist/chunks/{mollie-Bibhl67p.js → mollie-DG8Ju83x.js} +2 -2
- package/dist/chunks/{moneris-H2wSqk9h.js → moneris-C8m3Fvqu.js} +3 -3
- package/dist/chunks/opayo-B3EvrVxw.js +188 -0
- package/dist/chunks/{paddle-DkvIxQdG.js → paddle-BIYR9Um3.js} +3 -3
- package/dist/chunks/{password-validation-D06uH9va.js → password-validation-C8_uO_c_.js} +18 -12
- package/dist/chunks/{paypal-CQpAF7Ua.js → paypal-B_yxIo2d.js} +7 -5
- package/dist/chunks/{payway-CwDkC7YZ.js → payway-CeOzS0sL.js} +3 -3
- package/dist/chunks/{phone-country-D3ayr60L.js → phone-country-bAqje17P.js} +80 -63
- package/dist/chunks/{place-kit-BGHklIZ-.js → place-kit-BE5gi3vo.js} +3 -3
- package/dist/chunks/{placekit-autocomplete.esm-DWVabQlq.js → placekit-autocomplete.esm-CZZERYur.js} +11 -15
- package/dist/chunks/{recaptcha-enterprise-XPId5-bS.js → recaptcha-enterprise-CruXddZq.js} +4 -4
- package/dist/chunks/{recaptcha-shared-CLYJvojk.js → recaptcha-shared-AQRMDMme.js} +1 -1
- package/dist/chunks/{recaptcha-v2-checkbox-Cy-0PEPc.js → recaptcha-v2-checkbox-CCnJYCnG.js} +4 -4
- package/dist/chunks/{recaptcha-v2-invisible-BwRH540O.js → recaptcha-v2-invisible-BuVqRRYn.js} +4 -4
- package/dist/chunks/{recaptcha-v3-No4Ykrhk.js → recaptcha-v3-CloqhO2A.js} +4 -4
- package/dist/chunks/{repeater-BVnPUqTj.js → repeater-DwE27jI1.js} +25 -19
- package/dist/chunks/request-profile-DhwkeCpS.js +10 -0
- package/dist/chunks/rich-text-uV4o_pGk.js +361 -0
- package/dist/chunks/{chunk-3b4jIN3o.js → rolldown-runtime-DtPi1Y-2.js} +2 -2
- package/dist/chunks/{sdk-BhHAYgga.js → sdk-lkwSvlpM.js} +282 -234
- package/dist/chunks/{shared-Bx9s0i0P.js → shared-OKhSay59.js} +27 -21
- package/dist/chunks/{signature-IOhuicje.js → signature-7cldFbqj.js} +138 -112
- package/dist/chunks/{snaptcha-DKx98oon.js → snaptcha-C04kNGYQ.js} +2 -2
- package/dist/chunks/{square-DwdcOI1G.js → square-DEzxv9D9.js} +8 -6
- package/dist/chunks/{stripe-DaoG2FT1.js → stripe-CVPQGDz3.js} +10 -11
- package/dist/chunks/{summary-Dks0gXS3.js → summary-BF_8mrXI.js} +47 -45
- package/dist/chunks/{survey-likert-DkE6bR7B.js → survey-likert-fk1hUPff.js} +7 -1
- package/dist/chunks/{survey-rank-DN6x4IZM.js → survey-rank-BsLGl2LX.js} +37 -25
- package/dist/chunks/{survey-rating-BnsNL9U5.js → survey-rating-DVS6e6fM.js} +17 -5
- package/dist/chunks/{table-CAjCJHrL.js → table-DnIBdeKF.js} +21 -15
- package/dist/chunks/{text-limit-BGaY0jhI.js → text-limit-LGMPhFuC.js} +40 -34
- package/dist/chunks/{theme-classes-Tv7q7ToE.js → theme-classes-DAQuEqdP.js} +1 -1
- package/dist/chunks/{turnstile-DJakPzQD.js → turnstile-n9DNyPxi.js} +3 -3
- package/dist/chunks/{upload-manager-W-QDgxKD.js → upload-manager-BbiUosZq.js} +410 -350
- package/dist/chunks/{utils-Vqp8i_RM.js → utils-DpUBPadZ.js} +20 -14
- package/dist/css/formie-base.css +104 -1
- package/dist/css/theme/_messages.css +2 -0
- package/dist/css/theme/_tokens.css +31 -25
- package/dist/css/theme/forms/_form.css +5 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1778 -1427
- package/dist/js/contracts/client.d.ts +5 -3
- package/dist/js/contracts/client.d.ts.map +1 -1
- package/dist/js/contracts/common.d.ts +2 -2
- package/dist/js/contracts/common.d.ts.map +1 -1
- package/dist/js/contracts/modules.d.ts +37 -12
- package/dist/js/contracts/modules.d.ts.map +1 -1
- package/dist/js/contracts/schema.d.ts +20 -38
- package/dist/js/contracts/schema.d.ts.map +1 -1
- package/dist/js/contracts/theme.d.ts +4 -1
- package/dist/js/contracts/theme.d.ts.map +1 -1
- package/dist/js/core/client-rendered-modules.d.ts +17 -0
- package/dist/js/core/client-rendered-modules.d.ts.map +1 -0
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/field-error-aria.d.ts +23 -0
- package/dist/js/core/field-error-aria.d.ts.map +1 -0
- package/dist/js/core/hydrate-modules.d.ts +10 -8
- package/dist/js/core/hydrate-modules.d.ts.map +1 -1
- package/dist/js/core/submit-result-state.d.ts.map +1 -1
- package/dist/js/core/submit-result-ui.d.ts.map +1 -1
- package/dist/js/core/validation-focus.d.ts.map +1 -1
- package/dist/js/modules/address/address-finder.d.ts +1 -1
- package/dist/js/modules/address/address-finder.d.ts.map +1 -1
- package/dist/js/modules/address/factories.d.ts +3 -3
- package/dist/js/modules/address/factories.d.ts.map +1 -1
- package/dist/js/modules/address/google-address.d.ts +2 -1
- package/dist/js/modules/address/google-address.d.ts.map +1 -1
- package/dist/js/modules/address/index.d.ts +2 -2
- package/dist/js/modules/address/index.d.ts.map +1 -1
- package/dist/js/modules/address/loqate.d.ts +1 -1
- package/dist/js/modules/address/loqate.d.ts.map +1 -1
- package/dist/js/modules/address/place-kit.d.ts +1 -1
- package/dist/js/modules/address/place-kit.d.ts.map +1 -1
- package/dist/js/modules/captchas/captcha-eu.d.ts +1 -1
- package/dist/js/modules/captchas/captcha-eu.d.ts.map +1 -1
- package/dist/js/modules/captchas/factories.d.ts +11 -11
- package/dist/js/modules/captchas/factories.d.ts.map +1 -1
- package/dist/js/modules/captchas/friendly-captcha-v1.d.ts +1 -1
- package/dist/js/modules/captchas/friendly-captcha-v1.d.ts.map +1 -1
- package/dist/js/modules/captchas/friendly-captcha-v2.d.ts +1 -1
- package/dist/js/modules/captchas/friendly-captcha-v2.d.ts.map +1 -1
- package/dist/js/modules/captchas/hcaptcha.d.ts +1 -1
- package/dist/js/modules/captchas/hcaptcha.d.ts.map +1 -1
- package/dist/js/modules/captchas/index.d.ts +2 -2
- package/dist/js/modules/captchas/index.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-enterprise.d.ts +1 -1
- package/dist/js/modules/captchas/recaptcha-enterprise.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-v2-checkbox.d.ts +1 -1
- package/dist/js/modules/captchas/recaptcha-v2-checkbox.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-v2-invisible.d.ts +1 -1
- package/dist/js/modules/captchas/recaptcha-v2-invisible.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-v3.d.ts +1 -1
- package/dist/js/modules/captchas/recaptcha-v3.d.ts.map +1 -1
- package/dist/js/modules/captchas/snaptcha.d.ts +1 -1
- package/dist/js/modules/captchas/snaptcha.d.ts.map +1 -1
- package/dist/js/modules/captchas/turnstile.d.ts +1 -1
- package/dist/js/modules/captchas/turnstile.d.ts.map +1 -1
- package/dist/js/modules/fields/address-country.d.ts +2 -2
- package/dist/js/modules/fields/address-country.d.ts.map +1 -1
- package/dist/js/modules/fields/address-state.d.ts +2 -2
- package/dist/js/modules/fields/address-state.d.ts.map +1 -1
- package/dist/js/modules/fields/calculations.d.ts +2 -2
- package/dist/js/modules/fields/calculations.d.ts.map +1 -1
- package/dist/js/modules/fields/checkbox-radio.d.ts +2 -2
- package/dist/js/modules/fields/checkbox-radio.d.ts.map +1 -1
- package/dist/js/modules/fields/combobox.d.ts +2 -2
- package/dist/js/modules/fields/combobox.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions/config.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions/effects.d.ts +1 -0
- package/dist/js/modules/fields/conditions/effects.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions/evaluator.d.ts +4 -1
- package/dist/js/modules/fields/conditions/evaluator.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions/references.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions/submission-context.d.ts +15 -0
- package/dist/js/modules/fields/conditions/submission-context.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/types.d.ts +3 -1
- package/dist/js/modules/fields/conditions/types.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions/values.d.ts +1 -1
- package/dist/js/modules/fields/conditions/values.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions.d.ts +2 -2
- package/dist/js/modules/fields/conditions.d.ts.map +1 -1
- package/dist/js/modules/fields/custom-google-maps.d.ts +2 -2
- package/dist/js/modules/fields/custom-google-maps.d.ts.map +1 -1
- package/dist/js/modules/fields/custom-link.d.ts +2 -2
- package/dist/js/modules/fields/custom-link.d.ts.map +1 -1
- package/dist/js/modules/fields/custom-maps.d.ts +2 -2
- package/dist/js/modules/fields/custom-maps.d.ts.map +1 -1
- package/dist/js/modules/fields/date-picker.d.ts +2 -2
- package/dist/js/modules/fields/date-picker.d.ts.map +1 -1
- package/dist/js/modules/fields/file-upload.d.ts +2 -2
- package/dist/js/modules/fields/file-upload.d.ts.map +1 -1
- package/dist/js/modules/fields/hidden.d.ts +2 -2
- package/dist/js/modules/fields/hidden.d.ts.map +1 -1
- package/dist/js/modules/fields/index.d.ts +2 -2
- package/dist/js/modules/fields/index.d.ts.map +1 -1
- package/dist/js/modules/fields/password-validation.d.ts +2 -2
- package/dist/js/modules/fields/password-validation.d.ts.map +1 -1
- package/dist/js/modules/fields/phone-country.d.ts +2 -2
- package/dist/js/modules/fields/phone-country.d.ts.map +1 -1
- package/dist/js/modules/fields/repeater.d.ts +2 -2
- package/dist/js/modules/fields/repeater.d.ts.map +1 -1
- package/dist/js/modules/fields/rich-text.d.ts +2 -2
- package/dist/js/modules/fields/rich-text.d.ts.map +1 -1
- package/dist/js/modules/fields/shared.d.ts +1 -0
- package/dist/js/modules/fields/shared.d.ts.map +1 -1
- package/dist/js/modules/fields/signature.d.ts +2 -2
- package/dist/js/modules/fields/signature.d.ts.map +1 -1
- package/dist/js/modules/fields/summary.d.ts +2 -2
- package/dist/js/modules/fields/summary.d.ts.map +1 -1
- package/dist/js/modules/fields/survey-likert.d.ts +2 -2
- package/dist/js/modules/fields/survey-likert.d.ts.map +1 -1
- package/dist/js/modules/fields/survey-rank.d.ts +2 -2
- package/dist/js/modules/fields/survey-rank.d.ts.map +1 -1
- package/dist/js/modules/fields/survey-rating.d.ts +2 -2
- package/dist/js/modules/fields/survey-rating.d.ts.map +1 -1
- package/dist/js/modules/fields/table.d.ts +2 -2
- package/dist/js/modules/fields/table.d.ts.map +1 -1
- package/dist/js/modules/fields/text-limit.d.ts +2 -2
- package/dist/js/modules/fields/text-limit.d.ts.map +1 -1
- package/dist/js/modules/fields/upload-manager.d.ts +2 -2
- package/dist/js/modules/fields/upload-manager.d.ts.map +1 -1
- package/dist/js/modules/loader.d.ts +10 -4
- package/dist/js/modules/loader.d.ts.map +1 -1
- package/dist/js/modules/payments/bpoint.d.ts +1 -1
- package/dist/js/modules/payments/bpoint.d.ts.map +1 -1
- package/dist/js/modules/payments/eway.d.ts +1 -1
- package/dist/js/modules/payments/eway.d.ts.map +1 -1
- package/dist/js/modules/payments/factories.d.ts +7 -7
- package/dist/js/modules/payments/factories.d.ts.map +1 -1
- package/dist/js/modules/payments/go-cardless.d.ts +1 -1
- package/dist/js/modules/payments/go-cardless.d.ts.map +1 -1
- package/dist/js/modules/payments/index.d.ts +2 -2
- package/dist/js/modules/payments/index.d.ts.map +1 -1
- package/dist/js/modules/payments/mollie.d.ts +1 -1
- package/dist/js/modules/payments/mollie.d.ts.map +1 -1
- package/dist/js/modules/payments/moneris.d.ts +1 -1
- package/dist/js/modules/payments/moneris.d.ts.map +1 -1
- package/dist/js/modules/payments/opayo.d.ts +1 -1
- package/dist/js/modules/payments/opayo.d.ts.map +1 -1
- package/dist/js/modules/payments/paddle.d.ts +1 -1
- package/dist/js/modules/payments/paddle.d.ts.map +1 -1
- package/dist/js/modules/payments/paypal.d.ts +1 -1
- package/dist/js/modules/payments/paypal.d.ts.map +1 -1
- package/dist/js/modules/payments/payway.d.ts +1 -1
- package/dist/js/modules/payments/payway.d.ts.map +1 -1
- package/dist/js/modules/payments/square.d.ts +1 -1
- package/dist/js/modules/payments/square.d.ts.map +1 -1
- package/dist/js/modules/payments/stripe.d.ts +1 -1
- package/dist/js/modules/payments/stripe.d.ts.map +1 -1
- package/dist/js/modules/payments/utils.d.ts +6 -0
- package/dist/js/modules/payments/utils.d.ts.map +1 -1
- package/dist/js/modules/registry.d.ts +6 -4
- package/dist/js/modules/registry.d.ts.map +1 -1
- package/dist/js/submit/pipeline.d.ts.map +1 -1
- package/dist/js/theme/browser-theme-state.generated.d.ts +24 -0
- package/dist/js/theme/browser-theme-state.generated.d.ts.map +1 -0
- package/dist/js/theme/theme-classes.d.ts +3 -3
- package/dist/js/theme/theme-classes.d.ts.map +1 -1
- package/dist/js/transport/forms-api.d.ts +5 -3
- package/dist/js/transport/forms-api.d.ts.map +1 -1
- package/dist/js/utils/country-from-ip.d.ts +2 -2
- package/dist/js/utils/country-from-ip.d.ts.map +1 -1
- package/dist/js/utils/csrf.d.ts +17 -0
- package/dist/js/utils/csrf.d.ts.map +1 -0
- package/dist/js/utils/field-references.parser.d.ts +1 -0
- package/dist/js/utils/field-references.parser.d.ts.map +1 -1
- package/dist/js/utils/field-references.resolver.d.ts.map +1 -1
- package/dist/js/utils/field-references.types.d.ts +1 -0
- package/dist/js/utils/field-references.types.d.ts.map +1 -1
- package/dist/js/utils/http.d.ts +3 -1
- package/dist/js/utils/http.d.ts.map +1 -1
- package/dist/js/utils/request-profile.d.ts +4 -0
- package/dist/js/utils/request-profile.d.ts.map +1 -0
- package/dist/js/utils/unload-warning.d.ts.map +1 -1
- package/dist/js/validation/rules/email.d.ts.map +1 -1
- package/dist/js/validation/rules/match.d.ts.map +1 -1
- package/dist/js/validation/rules/number.d.ts.map +1 -1
- package/dist/js/validation/rules/required.d.ts.map +1 -1
- package/dist/js/validation/rules/shared.d.ts.map +1 -1
- package/dist/js/validation/rules/url.d.ts.map +1 -1
- package/dist/js/validation/skip.d.ts +7 -0
- package/dist/js/validation/skip.d.ts.map +1 -0
- package/dist/js/validation/submit-readiness.d.ts.map +1 -1
- package/dist/js/validation/validator.d.ts.map +1 -1
- package/package.json +43 -12
- package/src/css/formie-base.css +104 -1
- package/src/css/theme/_messages.css +2 -0
- package/src/css/theme/_tokens.css +31 -25
- package/src/css/theme/forms/_form.css +5 -1
- package/src/index.ts +13 -8
- package/src/js/contracts/client.ts +5 -3
- package/src/js/contracts/common.ts +5 -6
- package/src/js/contracts/modules.ts +41 -12
- package/src/js/contracts/schema.ts +21 -43
- package/src/js/contracts/theme.ts +6 -1
- package/src/js/core/client-rendered-modules.ts +69 -0
- package/src/js/core/create-formie-client.ts +116 -77
- package/src/js/core/field-error-aria.ts +93 -0
- package/src/js/core/hydrate-modules.ts +54 -29
- package/src/js/core/submit-result-state.ts +34 -45
- package/src/js/core/submit-result-ui.ts +21 -65
- package/src/js/core/validation-focus.ts +20 -20
- package/src/js/modules/address/address-finder.ts +1 -1
- package/src/js/modules/address/factories.ts +15 -13
- package/src/js/modules/address/google-address.ts +10 -6
- package/src/js/modules/address/index.ts +2 -2
- package/src/js/modules/address/loqate.ts +1 -1
- package/src/js/modules/address/place-kit.ts +1 -1
- package/src/js/modules/captchas/captcha-eu.ts +2 -2
- package/src/js/modules/captchas/factories.ts +66 -42
- package/src/js/modules/captchas/friendly-captcha-v1.ts +12 -2
- package/src/js/modules/captchas/friendly-captcha-v2.ts +4 -2
- package/src/js/modules/captchas/hcaptcha.ts +5 -5
- package/src/js/modules/captchas/index.ts +2 -2
- package/src/js/modules/captchas/recaptcha-enterprise.ts +2 -2
- package/src/js/modules/captchas/recaptcha-v2-checkbox.ts +3 -3
- package/src/js/modules/captchas/recaptcha-v2-invisible.ts +2 -2
- package/src/js/modules/captchas/recaptcha-v3.ts +2 -2
- package/src/js/modules/captchas/snaptcha.ts +1 -1
- package/src/js/modules/captchas/turnstile.ts +3 -3
- package/src/js/modules/fields/address-country.ts +6 -4
- package/src/js/modules/fields/address-state.ts +20 -12
- package/src/js/modules/fields/calculations.ts +5 -3
- package/src/js/modules/fields/checkbox-radio.ts +24 -42
- package/src/js/modules/fields/combobox.ts +25 -9
- package/src/js/modules/fields/conditions/config.ts +17 -20
- package/src/js/modules/fields/conditions/effects.ts +23 -26
- package/src/js/modules/fields/conditions/evaluator.ts +21 -29
- package/src/js/modules/fields/conditions/references.ts +16 -5
- package/src/js/modules/fields/conditions/submission-context.ts +80 -0
- package/src/js/modules/fields/conditions/types.ts +3 -1
- package/src/js/modules/fields/conditions/values.ts +31 -6
- package/src/js/modules/fields/conditions.ts +59 -18
- package/src/js/modules/fields/custom-google-maps.ts +5 -3
- package/src/js/modules/fields/custom-link.ts +5 -3
- package/src/js/modules/fields/custom-maps.ts +5 -3
- package/src/js/modules/fields/date-picker.ts +34 -4
- package/src/js/modules/fields/file-upload.ts +19 -10
- package/src/js/modules/fields/hidden.ts +5 -3
- package/src/js/modules/fields/index.ts +2 -2
- package/src/js/modules/fields/password-validation.ts +5 -3
- package/src/js/modules/fields/phone-country.ts +33 -6
- package/src/js/modules/fields/repeater.ts +5 -3
- package/src/js/modules/fields/rich-text.ts +20 -4
- package/src/js/modules/fields/shared.ts +13 -0
- package/src/js/modules/fields/signature.ts +24 -4
- package/src/js/modules/fields/summary.ts +8 -20
- package/src/js/modules/fields/survey-likert.ts +5 -3
- package/src/js/modules/fields/survey-rank.ts +21 -3
- package/src/js/modules/fields/survey-rating.ts +17 -3
- package/src/js/modules/fields/table.ts +5 -3
- package/src/js/modules/fields/text-limit.ts +5 -3
- package/src/js/modules/fields/upload-manager.ts +190 -49
- package/src/js/modules/loader.ts +345 -281
- package/src/js/modules/payments/bpoint.ts +2 -2
- package/src/js/modules/payments/eway.ts +2 -2
- package/src/js/modules/payments/factories.ts +53 -52
- package/src/js/modules/payments/go-cardless.ts +1 -1
- package/src/js/modules/payments/index.ts +2 -2
- package/src/js/modules/payments/mollie.ts +1 -1
- package/src/js/modules/payments/moneris.ts +2 -2
- package/src/js/modules/payments/opayo.ts +21 -8
- package/src/js/modules/payments/paddle.ts +10 -6
- package/src/js/modules/payments/payment.ts +22 -18
- package/src/js/modules/payments/paypal.ts +1 -1
- package/src/js/modules/payments/payway.ts +2 -2
- package/src/js/modules/payments/square.ts +2 -2
- package/src/js/modules/payments/stripe.ts +5 -5
- package/src/js/modules/payments/utils.ts +14 -0
- package/src/js/modules/registry.ts +19 -11
- package/src/js/submit/pipeline.ts +10 -11
- package/src/js/theme/browser-theme-state.generated.ts +25 -0
- package/src/js/theme/theme-classes.ts +3 -3
- package/src/js/transport/forms-api.ts +66 -67
- package/src/js/utils/country-from-ip.ts +14 -9
- package/src/js/utils/csrf.ts +136 -0
- package/src/js/utils/field-references.parser.ts +13 -113
- package/src/js/utils/field-references.resolver.ts +27 -64
- package/src/js/utils/field-references.row-scope.ts +1 -1
- package/src/js/utils/field-references.types.ts +1 -0
- package/src/js/utils/http.ts +5 -5
- package/src/js/utils/request-profile.ts +10 -0
- package/src/js/utils/unload-warning.ts +12 -4
- package/src/js/validation/rules/email.ts +3 -5
- package/src/js/validation/rules/match.ts +2 -1
- package/src/js/validation/rules/minmax.ts +4 -43
- package/src/js/validation/rules/number.ts +3 -47
- package/src/js/validation/rules/pattern.ts +3 -8
- package/src/js/validation/rules/required.ts +2 -1
- package/src/js/validation/rules/shared.ts +5 -1
- package/src/js/validation/rules/url.ts +3 -10
- package/src/js/validation/skip.ts +9 -0
- package/src/js/validation/submit-readiness.ts +9 -2
- package/src/js/validation/validator.ts +35 -59
- package/dist/chunks/calculations-Dv3hYb8_.js +0 -299
- package/dist/chunks/conditions-CPH1snCx.js +0 -424
- package/dist/chunks/country-from-ip-BwxKaBuJ.js +0 -26
- package/dist/chunks/field-references.resolver-CHwn0G0L.js +0 -145
- package/dist/chunks/friendly-captcha-v1-C_2reOXr.js +0 -31
- package/dist/chunks/google-address-BH3Zhi06.js +0 -161
- package/dist/chunks/http-D-JExro7.js +0 -27
- package/dist/chunks/opayo-CR0DtsLa.js +0 -179
- package/dist/chunks/rich-text-Bg_--4TG.js +0 -349
- package/dist/js/modules/fields/conditions/transforms.d.ts +0 -3
- package/dist/js/modules/fields/conditions/transforms.d.ts.map +0 -1
- package/src/js/modules/fields/conditions/transforms.ts +0 -206
- package/src/js/modules/payments/stub-payment-module.ts +0 -87
package/dist/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import { t as T } from "./chunks/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { n as
|
|
9
|
-
import { i as
|
|
10
|
-
import { t as
|
|
1
|
+
import { n as e } from "./chunks/request-profile-DhwkeCpS.js";
|
|
2
|
+
import { i as t, m as n, t as r } from "./chunks/dist-ZLeW0zZ3.js";
|
|
3
|
+
import { c as i, d as a, l as o, o as s, r as c, t as l, u } from "./chunks/event-names-BCI2FLD8.js";
|
|
4
|
+
import { a as d, c as f, d as p, f as m, i as h, l as g, n as _, o as v, p as y, r as b, s as x, t as S, u as C } from "./chunks/api-D6kJ7kXZ.js";
|
|
5
|
+
import { a as ee, i as te, n as ne, r as w, t as T } from "./chunks/debug-BV0DvdHx.js";
|
|
6
|
+
import { i as E, r as re, t as D } from "./chunks/theme-classes-DAQuEqdP.js";
|
|
7
|
+
import { i as O, t as ie } from "./chunks/csrf-DxHg_ZYt.js";
|
|
8
|
+
import { n as k, t as ae } from "./chunks/http-C2QdHuWO.js";
|
|
9
|
+
import { a as oe, i as se, n as ce, r as le, t as ue } from "./chunks/i18n-BY1ds1BL.js";
|
|
10
|
+
import { n as de, t as fe } from "./chunks/api-DYYsVIub.js";
|
|
11
|
+
import { n as pe, r as me, t as he } from "./chunks/field-references.keys-58ZSTrCW.js";
|
|
12
|
+
import { i as ge, n as _e, r as ve, t as ye } from "./chunks/field-references.resolver-Ca8MguFv.js";
|
|
13
|
+
import { t as be } from "./chunks/api-ghNr2uxX.js";
|
|
11
14
|
//#region src/js/compatibility/event-map.ts
|
|
12
|
-
var
|
|
15
|
+
var xe = [
|
|
13
16
|
{
|
|
14
17
|
legacyEvent: "onFormieLoaded",
|
|
15
18
|
canonicalEvent: "formie:mount:after",
|
|
@@ -62,7 +65,7 @@ var ge = [
|
|
|
62
65
|
canonicalEvent: "formie:submit:after",
|
|
63
66
|
disposition: "approximate"
|
|
64
67
|
}
|
|
65
|
-
],
|
|
68
|
+
], Se = [
|
|
66
69
|
{
|
|
67
70
|
legacyEvent: "formieValidatorInitialized",
|
|
68
71
|
canonicalEvent: "formie:validator:ready",
|
|
@@ -84,7 +87,7 @@ var ge = [
|
|
|
84
87
|
disposition: "safe"
|
|
85
88
|
}
|
|
86
89
|
];
|
|
87
|
-
function
|
|
90
|
+
function Ce(e) {
|
|
88
91
|
if (!e) return {
|
|
89
92
|
enabled: !1,
|
|
90
93
|
legacyDomEvents: !1,
|
|
@@ -104,18 +107,18 @@ function ve(e) {
|
|
|
104
107
|
}
|
|
105
108
|
//#endregion
|
|
106
109
|
//#region src/js/compatibility/dom-adapter.ts
|
|
107
|
-
function
|
|
110
|
+
function we(e, t, n) {
|
|
108
111
|
e.dispatchEvent(new CustomEvent(t, {
|
|
109
112
|
bubbles: !0,
|
|
110
113
|
detail: n
|
|
111
114
|
}));
|
|
112
115
|
}
|
|
113
|
-
function
|
|
116
|
+
function Te(e, t) {
|
|
114
117
|
if (e.canonicalEvent !== "formie:submit:result") return !0;
|
|
115
118
|
let n = t;
|
|
116
|
-
return e.legacyEvent === "onAfterFormieSubmit" ? !!n?.ok : e.legacyEvent
|
|
119
|
+
return e.legacyEvent === "onAfterFormieSubmit" ? !!n?.ok : e.legacyEvent !== "onFormieSubmitError" || n?.ok === !1;
|
|
117
120
|
}
|
|
118
|
-
function
|
|
121
|
+
function Ee(e, t) {
|
|
119
122
|
let n = t && typeof t == "object" ? t : {}, r = typeof n.pageId == "string" ? n.pageId : "", i = Array.from(e.querySelectorAll("[data-formie-page-id]"));
|
|
120
123
|
return { data: {
|
|
121
124
|
nextPageId: r,
|
|
@@ -123,7 +126,7 @@ function xe(e, t) {
|
|
|
123
126
|
totalPages: i.length
|
|
124
127
|
} };
|
|
125
128
|
}
|
|
126
|
-
function
|
|
129
|
+
function De(e, t, n, r, i) {
|
|
127
130
|
let a = globalThis.Formie || i;
|
|
128
131
|
return e.legacyEvent === "onFormieLoaded" ? { formie: a } : e.legacyEvent === "onFormieInit" ? {
|
|
129
132
|
formie: a,
|
|
@@ -135,44 +138,44 @@ function Se(e, t, n, r, i) {
|
|
|
135
138
|
form: r,
|
|
136
139
|
target: n,
|
|
137
140
|
instance: i
|
|
138
|
-
} : e.legacyEvent === "onFormiePageToggle" ?
|
|
141
|
+
} : e.legacyEvent === "onFormiePageToggle" ? Ee(r, t) : t;
|
|
139
142
|
}
|
|
140
|
-
function
|
|
141
|
-
|
|
142
|
-
let o = (
|
|
143
|
-
|
|
143
|
+
function Oe({ target: e, form: t, instance: n, options: r, unbinds: i }) {
|
|
144
|
+
r.legacyDomEvents && xe.forEach((r) => {
|
|
145
|
+
let o = (i) => {
|
|
146
|
+
i instanceof CustomEvent && Te(r, i.detail) && we(r.target === "document" ? document : t, r.legacyEvent, De(r, i.detail, e, t, n));
|
|
144
147
|
};
|
|
145
|
-
e.addEventListener(
|
|
146
|
-
e.removeEventListener(
|
|
148
|
+
e.addEventListener(a(r.canonicalEvent), o), i.push(() => {
|
|
149
|
+
e.removeEventListener(a(r.canonicalEvent), o);
|
|
147
150
|
});
|
|
148
151
|
});
|
|
149
152
|
}
|
|
150
153
|
//#endregion
|
|
151
154
|
//#region src/js/compatibility/validator-adapter.ts
|
|
152
|
-
function
|
|
155
|
+
function A(e, t, n) {
|
|
153
156
|
e.dispatchEvent(new CustomEvent(t, {
|
|
154
157
|
bubbles: !0,
|
|
155
158
|
detail: n
|
|
156
159
|
}));
|
|
157
160
|
}
|
|
158
|
-
function
|
|
161
|
+
function j(e, t) {
|
|
159
162
|
return !!e && typeof e == "object" && e.validator === t;
|
|
160
163
|
}
|
|
161
|
-
function
|
|
164
|
+
function ke({ target: e, form: t, validatorDetail: n, options: r, unbinds: i }) {
|
|
162
165
|
if (!r.legacyValidatorEvents || !n) return;
|
|
163
166
|
let { validator: a, addValidator: o, removeValidator: s } = n, c = {
|
|
164
167
|
...n,
|
|
165
168
|
form: t,
|
|
166
169
|
target: e
|
|
167
170
|
};
|
|
168
|
-
|
|
171
|
+
A(document, "formieValidatorInitialized", c);
|
|
169
172
|
let l = (e) => {
|
|
170
|
-
|
|
173
|
+
e instanceof CustomEvent && j(e.detail, a) && A(document, "formieValidatorDestroyed", {
|
|
171
174
|
...c,
|
|
172
175
|
...e.detail
|
|
173
176
|
});
|
|
174
177
|
}, u = (n) => {
|
|
175
|
-
|
|
178
|
+
n instanceof CustomEvent && j(n.detail, a) && n.target instanceof Element && t.contains(n.target) && A(n.target, "formieValidatorShowError", {
|
|
176
179
|
...n.detail,
|
|
177
180
|
addValidator: o,
|
|
178
181
|
removeValidator: s,
|
|
@@ -180,7 +183,7 @@ function we({ target: e, form: t, validatorDetail: n, options: r, unbinds: i })
|
|
|
180
183
|
target: e
|
|
181
184
|
});
|
|
182
185
|
}, d = (n) => {
|
|
183
|
-
|
|
186
|
+
n instanceof CustomEvent && j(n.detail, a) && n.target instanceof Element && t.contains(n.target) && A(n.target, "formieValidatorClearError", {
|
|
184
187
|
...n.detail,
|
|
185
188
|
addValidator: o,
|
|
186
189
|
removeValidator: s,
|
|
@@ -194,17 +197,17 @@ function we({ target: e, form: t, validatorDetail: n, options: r, unbinds: i })
|
|
|
194
197
|
}
|
|
195
198
|
//#endregion
|
|
196
199
|
//#region src/js/core/error-aria-live.ts
|
|
197
|
-
function
|
|
200
|
+
function M(e) {
|
|
198
201
|
let t = (e.dataset.formieErrorAriaLive || "polite").trim().toLowerCase();
|
|
199
202
|
return t === "assertive" || t === "off" ? t : "polite";
|
|
200
203
|
}
|
|
201
|
-
function
|
|
204
|
+
function Ae(e, t) {
|
|
202
205
|
return e === "off" ? null : t ? e : "polite";
|
|
203
206
|
}
|
|
204
|
-
function
|
|
207
|
+
function je(e) {
|
|
205
208
|
return e === "off" ? null : e;
|
|
206
209
|
}
|
|
207
|
-
function
|
|
210
|
+
function N(e, t) {
|
|
208
211
|
if (t) {
|
|
209
212
|
e.setAttribute("aria-live", t), e.setAttribute("aria-atomic", "true");
|
|
210
213
|
return;
|
|
@@ -212,39 +215,65 @@ function Oe(e, t) {
|
|
|
212
215
|
e.removeAttribute("aria-live"), e.removeAttribute("aria-atomic");
|
|
213
216
|
}
|
|
214
217
|
//#endregion
|
|
215
|
-
//#region src/js/core/
|
|
216
|
-
function
|
|
218
|
+
//#region src/js/core/field-error-aria.ts
|
|
219
|
+
function Me(e, t) {
|
|
217
220
|
let n = (e.getAttribute("aria-describedby") || "").trim(), r = n ? n.split(/\s+/) : [];
|
|
218
221
|
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
219
222
|
}
|
|
220
|
-
function
|
|
221
|
-
|
|
223
|
+
function Ne(e, t = document) {
|
|
224
|
+
let n = (e.getAttribute("aria-describedby") || "").trim();
|
|
225
|
+
if (!n) return;
|
|
226
|
+
let r = n.split(/\s+/).filter((e) => !!e && !!t.getElementById(e));
|
|
227
|
+
if (r.length) {
|
|
228
|
+
e.setAttribute("aria-describedby", r.join(" "));
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
e.removeAttribute("aria-describedby");
|
|
232
|
+
}
|
|
233
|
+
function Pe(e, t) {
|
|
234
|
+
e.setAttribute("aria-errormessage", t), Me(e, t);
|
|
222
235
|
}
|
|
223
|
-
function
|
|
224
|
-
|
|
236
|
+
function Fe(e, t = []) {
|
|
237
|
+
t.forEach((t) => {
|
|
238
|
+
e.getAttribute("aria-errormessage") === t && e.removeAttribute("aria-errormessage");
|
|
239
|
+
}), !t.length && e.hasAttribute("aria-errormessage") && e.removeAttribute("aria-errormessage"), Ne(e);
|
|
240
|
+
}
|
|
241
|
+
function P(e) {
|
|
242
|
+
return !!e && e.hasAttribute("data-formie-validation-skip");
|
|
225
243
|
}
|
|
226
|
-
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/js/core/validation-focus.ts
|
|
246
|
+
function Ie(e) {
|
|
247
|
+
return Array.from(e.querySelectorAll("[data-formie-field-handle]")).find((e) => e.getAttribute("data-formie-field-has-error") === "true" || e.querySelector("[data-formie-field-error]") !== null) || null;
|
|
248
|
+
}
|
|
249
|
+
function Le(e) {
|
|
250
|
+
return Array.from(e.querySelectorAll("[aria-invalid=\"true\"]")).find((e) => !P(e)) || (Array.from(e.querySelectorAll("input:not([type=\"hidden\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])")).find((e) => !P(e)) ?? null);
|
|
251
|
+
}
|
|
252
|
+
function Re(e) {
|
|
227
253
|
return e.querySelector("[data-formie-message-error], [data-formie-error-container], [data-formie-errors]");
|
|
228
254
|
}
|
|
229
|
-
function
|
|
255
|
+
function ze(e) {
|
|
230
256
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
231
257
|
let n = t;
|
|
232
|
-
if (
|
|
233
|
-
n.setAttribute("data-formie-field-has-error", "true"),
|
|
234
|
-
let r = n.querySelector("[data-formie-field-
|
|
258
|
+
if (n.getAttribute("data-formie-field-has-error") !== "true" && n.querySelector("[data-formie-field-error]") === null) return;
|
|
259
|
+
n.setAttribute("data-formie-field-has-error", "true"), D(n, e, "fieldLayoutError");
|
|
260
|
+
let r = n.querySelector("[data-formie-field-error]")?.id || "";
|
|
235
261
|
n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
236
|
-
let
|
|
237
|
-
|
|
262
|
+
let i = t;
|
|
263
|
+
if (P(i)) return;
|
|
264
|
+
i.setAttribute("aria-invalid", "true"), D(i, e, "fieldControlError"), i.setAttribute("data-formie-input-has-error", "true"), r && Pe(i, r);
|
|
265
|
+
let a = n.querySelector("[data-formie-instructions]");
|
|
266
|
+
a?.id && Me(i, a.id);
|
|
238
267
|
});
|
|
239
268
|
});
|
|
240
269
|
}
|
|
241
|
-
function
|
|
242
|
-
return !!
|
|
270
|
+
function Be(e) {
|
|
271
|
+
return !!Ie(e) || !!Re(e);
|
|
243
272
|
}
|
|
244
|
-
function
|
|
245
|
-
let t =
|
|
273
|
+
function Ve(e) {
|
|
274
|
+
let t = Ie(e);
|
|
246
275
|
if (t) {
|
|
247
|
-
let e =
|
|
276
|
+
let e = Le(t);
|
|
248
277
|
if (e) {
|
|
249
278
|
if (e.scrollIntoView({
|
|
250
279
|
behavior: "smooth",
|
|
@@ -261,72 +290,16 @@ function Fe(e) {
|
|
|
261
290
|
block: "center"
|
|
262
291
|
}), !0;
|
|
263
292
|
}
|
|
264
|
-
let n =
|
|
293
|
+
let n = Re(e);
|
|
265
294
|
return n ? (n.scrollIntoView({
|
|
266
295
|
behavior: "smooth",
|
|
267
296
|
block: "center"
|
|
268
297
|
}), !0) : !1;
|
|
269
298
|
}
|
|
270
299
|
//#endregion
|
|
271
|
-
//#region src/js/
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
this.listeners = /* @__PURE__ */ new Map();
|
|
275
|
-
}
|
|
276
|
-
on(e, t) {
|
|
277
|
-
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e)?.add(t), () => {
|
|
278
|
-
this.listeners.get(e)?.delete(t);
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
async emit(e, t) {
|
|
282
|
-
let n = this.listeners.get(e);
|
|
283
|
-
if (!(!n || n.size === 0)) for (let e of n) await e(t);
|
|
284
|
-
}
|
|
285
|
-
async emitSafe(e, t) {
|
|
286
|
-
let n = this.listeners.get(e), r = {
|
|
287
|
-
eventName: e,
|
|
288
|
-
total: n?.size || 0,
|
|
289
|
-
succeeded: 0,
|
|
290
|
-
failed: []
|
|
291
|
-
};
|
|
292
|
-
if (!n || n.size === 0) return r;
|
|
293
|
-
let i = 0;
|
|
294
|
-
for (let e of n) {
|
|
295
|
-
try {
|
|
296
|
-
await e(t), r.succeeded += 1;
|
|
297
|
-
} catch (e) {
|
|
298
|
-
r.failed.push({
|
|
299
|
-
index: i,
|
|
300
|
-
error: e
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
i += 1;
|
|
304
|
-
}
|
|
305
|
-
return r;
|
|
306
|
-
}
|
|
307
|
-
async emitParallelSafe(e, t) {
|
|
308
|
-
let n = this.listeners.get(e), r = {
|
|
309
|
-
eventName: e,
|
|
310
|
-
total: n?.size || 0,
|
|
311
|
-
succeeded: 0,
|
|
312
|
-
failed: []
|
|
313
|
-
};
|
|
314
|
-
return !n || n.size === 0 || (await Promise.allSettled(Array.from(n).map(async (e) => e(t)))).forEach((e, t) => {
|
|
315
|
-
if (e.status === "fulfilled") {
|
|
316
|
-
r.succeeded += 1;
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
r.failed.push({
|
|
320
|
-
index: t,
|
|
321
|
-
error: e.reason
|
|
322
|
-
});
|
|
323
|
-
}), r;
|
|
324
|
-
}
|
|
325
|
-
clear() {
|
|
326
|
-
this.listeners.clear();
|
|
327
|
-
}
|
|
328
|
-
}, A = S("general", "transport");
|
|
329
|
-
function Le(e) {
|
|
300
|
+
//#region src/js/transport/forms-api.ts
|
|
301
|
+
var F = T("general", "transport");
|
|
302
|
+
function He(e) {
|
|
330
303
|
let t = {};
|
|
331
304
|
return [
|
|
332
305
|
"theme",
|
|
@@ -337,90 +310,98 @@ function Le(e) {
|
|
|
337
310
|
e[n] !== void 0 && (t[n] = e[n]);
|
|
338
311
|
}), t;
|
|
339
312
|
}
|
|
340
|
-
function
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
function ze(e, t) {
|
|
350
|
-
let n = e.success === !0, r = e.keepSubmitLoading === !0, i = e.errors, a = Re(i || {}), o = a.form || [], s = {};
|
|
351
|
-
Object.entries(a).forEach(([e, t]) => {
|
|
352
|
-
if (e === "form") return;
|
|
353
|
-
let n = e.split(".")[0];
|
|
354
|
-
s[n] = (s[n] || []).concat(t);
|
|
313
|
+
function Ue(e, t) {
|
|
314
|
+
let n = e.success === !0, r = e.completion && typeof e.completion == "object" ? e.completion : null, i = e.payment && typeof e.payment == "object" ? e.payment : null, a = [
|
|
315
|
+
"requiresAction",
|
|
316
|
+
"pending",
|
|
317
|
+
"unknown"
|
|
318
|
+
].includes(i?.status || ""), o = e.errors, s = Object.fromEntries(Object.entries(o && typeof o == "object" ? o : {}).map(([e, t]) => [e, Array.isArray(t) ? t.filter((e) => typeof e == "string") : []])), c = s.form || [], l = {};
|
|
319
|
+
Object.entries(s).forEach(([e, t]) => {
|
|
320
|
+
e !== "form" && (l[e] = t);
|
|
355
321
|
});
|
|
356
|
-
let
|
|
322
|
+
let u = !n && c.length === 0 && Object.keys(l).length > 0 ? [t || "Submission failed."] : c, d = !n && a && u.length === 0 && Object.keys(l).length === 0;
|
|
357
323
|
return {
|
|
358
324
|
ok: n,
|
|
325
|
+
outcome: typeof e.outcome == "string" ? e.outcome : void 0,
|
|
326
|
+
version: typeof e.version == "number" ? e.version : null,
|
|
327
|
+
submissionUid: typeof e.submissionUid == "string" ? e.submissionUid : null,
|
|
328
|
+
errors: e.errors,
|
|
329
|
+
session: e.session,
|
|
330
|
+
completion: r,
|
|
359
331
|
action: e.submitAction === "back" || e.submitAction === "save" || e.submitAction === "submit" ? e.submitAction : void 0,
|
|
360
|
-
message: e.submitActionMessage || (n ? "Submission completed." :
|
|
332
|
+
message: r?.message || e.successMessage || e.submitActionMessage || (n ? "Submission completed." : d ? "" : u[0] || "Submission failed."),
|
|
361
333
|
code: n ? void 0 : String(e.code || "SUBMIT_ERROR"),
|
|
362
|
-
keepSubmitLoading:
|
|
363
|
-
|
|
364
|
-
|
|
334
|
+
keepSubmitLoading: a,
|
|
335
|
+
payment: i,
|
|
336
|
+
fieldErrors: Object.keys(l).length ? l : void 0,
|
|
337
|
+
formErrors: u.length ? u : void 0,
|
|
365
338
|
nextPage: e.nextPageId ? { id: String(e.nextPageId) } : null,
|
|
366
|
-
redirect:
|
|
339
|
+
redirect: i?.status === "requiresAction" && i.action?.type === "redirect" && i.action.url ? {
|
|
340
|
+
url: i.action.url,
|
|
341
|
+
target: "same-tab"
|
|
342
|
+
} : r?.url ? {
|
|
343
|
+
url: r.url,
|
|
344
|
+
target: r.target
|
|
345
|
+
} : e.redirectUrl ? {
|
|
367
346
|
url: String(e.redirectUrl),
|
|
368
|
-
target: e.
|
|
347
|
+
target: e.redirectTarget === "new-tab" ? "new-tab" : "same-tab"
|
|
369
348
|
} : null,
|
|
370
349
|
submitData: Array.isArray(e.submitData) ? e.submitData : void 0,
|
|
371
350
|
clientEvents: Array.isArray(e.clientEvents) ? e.clientEvents : void 0,
|
|
372
351
|
meta: e
|
|
373
352
|
};
|
|
374
353
|
}
|
|
375
|
-
async function
|
|
376
|
-
let
|
|
354
|
+
async function We(e, t, n = {}, r = {}) {
|
|
355
|
+
let i = JSON.stringify({
|
|
377
356
|
handle: t,
|
|
378
357
|
renderOptions: n
|
|
379
358
|
});
|
|
380
|
-
|
|
359
|
+
F.log("requestRender start.", {
|
|
381
360
|
endpoint: e,
|
|
382
361
|
handle: t
|
|
383
362
|
});
|
|
384
|
-
let
|
|
363
|
+
let a = await k(e, {
|
|
364
|
+
...r,
|
|
385
365
|
method: "POST",
|
|
386
|
-
body:
|
|
366
|
+
body: i,
|
|
387
367
|
headers: { "Content-Type": "application/json" }
|
|
388
368
|
});
|
|
389
|
-
return
|
|
369
|
+
return F.log("requestRender complete.", { hasHtml: !!a.html }), a;
|
|
390
370
|
}
|
|
391
|
-
async function
|
|
392
|
-
let
|
|
371
|
+
async function Ge(e, t, n = {}, r = {}) {
|
|
372
|
+
let i = JSON.stringify({
|
|
393
373
|
query: "\nquery FormieHtmlForm($handle: String!, $input: ServerRenderPayloadInput) {\n formieHtmlForm(handle: $handle, input: $input) {\n html\n }\n}",
|
|
394
374
|
variables: {
|
|
395
375
|
handle: t,
|
|
396
|
-
input:
|
|
376
|
+
input: He(n)
|
|
397
377
|
}
|
|
398
378
|
});
|
|
399
|
-
|
|
379
|
+
F.log("requestGraphqlRender start.", {
|
|
400
380
|
endpoint: e,
|
|
401
381
|
handle: t
|
|
402
382
|
});
|
|
403
|
-
let
|
|
383
|
+
let a = await k(e, {
|
|
384
|
+
...r,
|
|
404
385
|
method: "POST",
|
|
405
|
-
body:
|
|
386
|
+
body: i,
|
|
406
387
|
headers: { "Content-Type": "application/json" }
|
|
407
388
|
});
|
|
408
|
-
if (Array.isArray(
|
|
409
|
-
if (!
|
|
410
|
-
let
|
|
411
|
-
return
|
|
412
|
-
}
|
|
413
|
-
async function
|
|
414
|
-
let
|
|
415
|
-
|
|
416
|
-
endpoint:
|
|
389
|
+
if (Array.isArray(a.errors) && a.errors.length > 0) throw Error(a.errors.map((e) => e.message || "Unknown GraphQL error").join("; "));
|
|
390
|
+
if (!a.data?.formieHtmlForm) throw Error(`Form not found for handle "${t}".`);
|
|
391
|
+
let o = a.data.formieHtmlForm;
|
|
392
|
+
return F.log("requestGraphqlRender complete.", { hasHtml: !!o.html }), o;
|
|
393
|
+
}
|
|
394
|
+
async function Ke(e, t, n, r = {}, i) {
|
|
395
|
+
let a = new URL(e, window.location.origin);
|
|
396
|
+
a.searchParams.set("handle", t), n && a.searchParams.set("renderId", n), i && a.searchParams.set("requestToken", i), F.log("requestRefreshTokens start.", {
|
|
397
|
+
endpoint: a.toString(),
|
|
417
398
|
handle: t,
|
|
418
399
|
hasRenderId: !!n
|
|
419
400
|
});
|
|
420
|
-
let
|
|
421
|
-
return
|
|
401
|
+
let o = await k(a.toString(), r);
|
|
402
|
+
return F.log("requestRefreshTokens complete.", { hasRefreshTokens: !!o.refreshTokens }), o.refreshTokens || o;
|
|
422
403
|
}
|
|
423
|
-
async function
|
|
404
|
+
async function qe(e, t, n) {
|
|
424
405
|
let r = new URL(e, window.location.origin), i = new FormData();
|
|
425
406
|
if (n && i.append("pageId", n), t) {
|
|
426
407
|
[
|
|
@@ -428,26 +409,32 @@ async function He(e, t, n) {
|
|
|
428
409
|
"renderId",
|
|
429
410
|
"draftContextToken",
|
|
430
411
|
"draftContext",
|
|
431
|
-
"
|
|
412
|
+
"progressId",
|
|
413
|
+
"requestToken",
|
|
414
|
+
"expectedVersion"
|
|
432
415
|
].forEach((e) => {
|
|
433
416
|
let n = t.querySelector(`input[name="${e}"]`)?.value?.trim();
|
|
434
417
|
n && i.append(e, n);
|
|
435
|
-
});
|
|
436
|
-
let e
|
|
437
|
-
e && i.append("CRAFT_CSRF_TOKEN", e);
|
|
418
|
+
}), ie(i, t);
|
|
419
|
+
for (let [e, n] of new FormData(t)) e.startsWith("fields[") && i.append(e, n);
|
|
438
420
|
}
|
|
439
|
-
|
|
421
|
+
F.log("requestSetPage start.", {
|
|
440
422
|
requestUrl: r.toString(),
|
|
441
423
|
pageId: n || null
|
|
442
424
|
});
|
|
443
|
-
let a = await
|
|
425
|
+
let a = await (await ae(r.toString(), {
|
|
444
426
|
method: "POST",
|
|
445
|
-
body: i
|
|
446
|
-
|
|
447
|
-
|
|
427
|
+
body: i,
|
|
428
|
+
profile: t?.dataset.formieRequestProfile
|
|
429
|
+
})).json();
|
|
430
|
+
if (t && a.session) {
|
|
431
|
+
let e = a.session, n = t.querySelector("input[name=\"expectedVersion\"]"), r = t.querySelector("input[name=\"requestToken\"]");
|
|
432
|
+
n && (n.value = String(e.version)), r && e.tokens?.request && (r.value = e.tokens.request);
|
|
433
|
+
}
|
|
434
|
+
return F.log("requestSetPage complete.", a), a;
|
|
448
435
|
}
|
|
449
|
-
function
|
|
450
|
-
let n = new URL(e, window.location.origin),
|
|
436
|
+
function Je(e, t) {
|
|
437
|
+
let n = new URL(e, window.location.origin), i = new FormData();
|
|
451
438
|
[
|
|
452
439
|
"handle",
|
|
453
440
|
"renderId",
|
|
@@ -455,75 +442,69 @@ function Ue(e, t) {
|
|
|
455
442
|
"draftContext"
|
|
456
443
|
].forEach((e) => {
|
|
457
444
|
let n = t.querySelector(`input[name="${e}"]`)?.value?.trim();
|
|
458
|
-
n &&
|
|
459
|
-
});
|
|
460
|
-
let i = t.querySelector("input[name=\"CRAFT_CSRF_TOKEN\"]")?.value?.trim();
|
|
461
|
-
i && r.append("CRAFT_CSRF_TOKEN", i), A.log("clearSubmissionOnUnload start.", { requestUrl: n.toString() });
|
|
445
|
+
n && i.append(e, n);
|
|
446
|
+
}), ie(i, t), F.log("clearSubmissionOnUnload start.", { requestUrl: n.toString() });
|
|
462
447
|
try {
|
|
463
|
-
if (typeof navigator.sendBeacon == "function" && navigator.sendBeacon(n.toString(),
|
|
448
|
+
if (t.dataset.formieRequestProfile !== "cross-origin-public" && typeof navigator.sendBeacon == "function" && navigator.sendBeacon(n.toString(), i)) return;
|
|
464
449
|
} catch {}
|
|
465
|
-
|
|
450
|
+
r(n.toString(), {
|
|
466
451
|
method: "POST",
|
|
467
|
-
body:
|
|
468
|
-
credentials: "include",
|
|
452
|
+
body: i,
|
|
469
453
|
keepalive: !0,
|
|
470
454
|
headers: { Accept: "application/json" }
|
|
471
|
-
});
|
|
455
|
+
}, { profile: t.dataset.formieRequestProfile });
|
|
472
456
|
}
|
|
473
|
-
async function
|
|
474
|
-
let n = (e.getAttribute("method") || "POST").toUpperCase(),
|
|
475
|
-
|
|
457
|
+
async function Ye(e, t) {
|
|
458
|
+
let n = (e.getAttribute("method") || "POST").toUpperCase(), i = e.getAttribute("action") || window.location.href, a = e.dataset.formieErrorMessage?.trim() || "Submission failed.";
|
|
459
|
+
F.log("submitForm start.", {
|
|
476
460
|
method: n,
|
|
477
|
-
action:
|
|
461
|
+
action: i,
|
|
478
462
|
submitAction: t.get("submitAction")
|
|
479
463
|
});
|
|
480
|
-
let
|
|
464
|
+
let o = await r(i, {
|
|
481
465
|
method: n,
|
|
482
466
|
body: t,
|
|
483
|
-
credentials: "include",
|
|
484
467
|
headers: { Accept: "application/json" }
|
|
485
|
-
}),
|
|
486
|
-
if (!
|
|
487
|
-
status:
|
|
488
|
-
contentType:
|
|
468
|
+
}, { profile: e.dataset.formieRequestProfile }), s = o.headers.get("content-type") || "";
|
|
469
|
+
if (!s.includes("application/json")) return o.ok ? (F.log("submitForm non-JSON success response.", {
|
|
470
|
+
status: o.status,
|
|
471
|
+
contentType: s
|
|
489
472
|
}), {
|
|
490
473
|
ok: !0,
|
|
491
474
|
message: "Submission completed."
|
|
492
|
-
}) : (
|
|
493
|
-
status:
|
|
494
|
-
contentType:
|
|
475
|
+
}) : (F.warn("submitForm non-JSON HTTP error.", {
|
|
476
|
+
status: o.status,
|
|
477
|
+
contentType: s
|
|
495
478
|
}), {
|
|
496
479
|
ok: !1,
|
|
497
480
|
code: "HTTP_ERROR",
|
|
498
|
-
message: `Request failed (${
|
|
499
|
-
formErrors: [`Request failed (${
|
|
481
|
+
message: `Request failed (${o.status}).`,
|
|
482
|
+
formErrors: [`Request failed (${o.status}).`]
|
|
500
483
|
});
|
|
501
|
-
let
|
|
502
|
-
return
|
|
503
|
-
ok:
|
|
504
|
-
code:
|
|
505
|
-
hasRedirect: !!
|
|
506
|
-
hasSubmitData: Array.isArray(
|
|
507
|
-
}),
|
|
484
|
+
let c = Ue(await o.json(), a);
|
|
485
|
+
return F.log("submitForm JSON response normalized.", {
|
|
486
|
+
ok: c.ok,
|
|
487
|
+
code: c.code,
|
|
488
|
+
hasRedirect: !!c.redirect?.url,
|
|
489
|
+
hasSubmitData: Array.isArray(c.submitData) && c.submitData.length > 0
|
|
490
|
+
}), c;
|
|
508
491
|
}
|
|
509
492
|
//#endregion
|
|
510
493
|
//#region src/js/submit/pipeline.ts
|
|
511
|
-
var
|
|
494
|
+
var Xe = [
|
|
512
495
|
"prepare",
|
|
513
|
-
"normalize",
|
|
514
496
|
"validate",
|
|
515
|
-
"
|
|
516
|
-
"
|
|
517
|
-
"
|
|
518
|
-
"
|
|
519
|
-
],
|
|
497
|
+
"challenge",
|
|
498
|
+
"payment",
|
|
499
|
+
"send",
|
|
500
|
+
"result"
|
|
501
|
+
], Ze = [
|
|
520
502
|
"prepare",
|
|
521
|
-
"normalize",
|
|
522
503
|
"validate",
|
|
523
|
-
"
|
|
524
|
-
"
|
|
525
|
-
],
|
|
526
|
-
function
|
|
504
|
+
"challenge",
|
|
505
|
+
"payment"
|
|
506
|
+
], I = T("general", "pipeline");
|
|
507
|
+
function Qe(e, t) {
|
|
527
508
|
return {
|
|
528
509
|
ok: !1,
|
|
529
510
|
stage: e,
|
|
@@ -532,13 +513,13 @@ function qe(e, t) {
|
|
|
532
513
|
formErrors: [t || "Submission aborted."]
|
|
533
514
|
};
|
|
534
515
|
}
|
|
535
|
-
function
|
|
516
|
+
function $e(e) {
|
|
536
517
|
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
|
|
537
518
|
}
|
|
538
|
-
function
|
|
519
|
+
function et(e) {
|
|
539
520
|
return !(!e.name || e.disabled || e instanceof HTMLInputElement && (e.type === "submit" || e.type === "button" || e.type === "reset" || e.type === "image" || (e.type === "checkbox" || e.type === "radio") && !e.checked || e.type === "file" && (!e.files || e.files.length === 0)));
|
|
540
521
|
}
|
|
541
|
-
function
|
|
522
|
+
function tt(e, t) {
|
|
542
523
|
if (t instanceof HTMLInputElement) {
|
|
543
524
|
if (t.type === "file") {
|
|
544
525
|
Array.from(t.files || []).forEach((n) => {
|
|
@@ -557,49 +538,49 @@ function Xe(e, t) {
|
|
|
557
538
|
}
|
|
558
539
|
e.append(t.name, t.value);
|
|
559
540
|
}
|
|
560
|
-
function
|
|
541
|
+
function nt(e, t) {
|
|
561
542
|
t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
562
|
-
let n =
|
|
563
|
-
|
|
543
|
+
let n = $e(t) ? t : null;
|
|
544
|
+
n && !n.closest("[data-formie-page]") && et(n) && tt(e, n);
|
|
564
545
|
});
|
|
565
546
|
}
|
|
566
|
-
function
|
|
547
|
+
function rt(e, t) {
|
|
567
548
|
let n = /* @__PURE__ */ new Set();
|
|
568
549
|
return t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
569
|
-
let r =
|
|
570
|
-
|
|
550
|
+
let r = $e(t) ? t : null;
|
|
551
|
+
r && r.name && !r.disabled && (r instanceof HTMLInputElement && (r.type === "submit" || r.type === "button" || r.type === "reset" || r.type === "image") || (r.name.startsWith("fields[") && n.add(r.name), et(r) && tt(e, r)));
|
|
571
552
|
}), n;
|
|
572
553
|
}
|
|
573
|
-
function
|
|
554
|
+
function it(e, t) {
|
|
574
555
|
t.forEach((t) => {
|
|
575
556
|
e.has(t) || e.append(t, "");
|
|
576
557
|
});
|
|
577
558
|
}
|
|
578
|
-
function
|
|
579
|
-
let n =
|
|
559
|
+
function at(e, t) {
|
|
560
|
+
let n = f(e), r = n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || null;
|
|
580
561
|
if (!n.length || !r) {
|
|
581
562
|
let n = new FormData(e);
|
|
582
563
|
return n.set("submitAction", t), n;
|
|
583
564
|
}
|
|
584
565
|
let i = new FormData();
|
|
585
|
-
return
|
|
566
|
+
return nt(i, e), it(i, rt(i, r)), i.set("submitAction", t), i;
|
|
586
567
|
}
|
|
587
|
-
function
|
|
568
|
+
function ot(e, t) {
|
|
588
569
|
if (t !== "submit") return !1;
|
|
589
|
-
let n =
|
|
590
|
-
return n.length
|
|
570
|
+
let n = f(e);
|
|
571
|
+
return !n.length || (n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || n[n.length - 1]) === n[n.length - 1];
|
|
591
572
|
}
|
|
592
|
-
async function
|
|
593
|
-
|
|
573
|
+
async function st(e, t, n, r = {}) {
|
|
574
|
+
I.log("Starting submit pipeline.", {
|
|
594
575
|
action: t,
|
|
595
576
|
preflightOnly: r.preflightOnly === !0
|
|
596
577
|
});
|
|
597
|
-
let i = !1, a, o = null, s =
|
|
578
|
+
let i = !1, a, o = null, s = ot(e, t), c = {
|
|
598
579
|
form: e,
|
|
599
580
|
action: t,
|
|
600
|
-
formData:
|
|
581
|
+
formData: at(e, t),
|
|
601
582
|
abort: (e) => {
|
|
602
|
-
i = !0, a = e,
|
|
583
|
+
i = !0, a = e, I.warn("Pipeline aborted.", { reason: e });
|
|
603
584
|
},
|
|
604
585
|
isAborted: () => i,
|
|
605
586
|
abortReason: () => a
|
|
@@ -608,11 +589,10 @@ async function nt(e, t, n, r = {}) {
|
|
|
608
589
|
let t = e.form.querySelector("input[name=\"submitAction\"]");
|
|
609
590
|
return t && (t.value = e.action), e.formData.set("submitAction", e.action), null;
|
|
610
591
|
},
|
|
611
|
-
normalize: async () => null,
|
|
612
592
|
validate: async (e) => {
|
|
613
593
|
if (e.action !== "submit" || r.validateOnSubmit === !1) return null;
|
|
614
594
|
if (r.validator) {
|
|
615
|
-
let { scope: t, final: n } =
|
|
595
|
+
let { scope: t, final: n } = g(e.form), i = r.validator.submit(n ? e.form : t, { final: n });
|
|
616
596
|
if (i.length > 0) {
|
|
617
597
|
let e = i[0]?.input;
|
|
618
598
|
if (e) {
|
|
@@ -645,71 +625,71 @@ async function nt(e, t, n, r = {}) {
|
|
|
645
625
|
formErrors: ["Validation failed."]
|
|
646
626
|
});
|
|
647
627
|
},
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
e.formData =
|
|
652
|
-
let t = await
|
|
628
|
+
challenge: async () => null,
|
|
629
|
+
payment: async () => null,
|
|
630
|
+
send: async (e) => {
|
|
631
|
+
e.formData = at(e.form, e.action);
|
|
632
|
+
let t = await Ye(e.form, e.formData);
|
|
653
633
|
return o = t, t;
|
|
654
634
|
},
|
|
655
|
-
|
|
635
|
+
result: async (e) => (o && o.ok && o.redirect?.url && (o.redirect.target === "new-tab" ? window.open(o.redirect.url, "_blank", "noopener,noreferrer") : (e.form.setAttribute("data-formie-internal-navigation", "redirect"), window.location.href = o.redirect.url)), null)
|
|
656
636
|
};
|
|
657
637
|
{
|
|
658
638
|
let e = await n.emitSafe("formie:submit:before", c);
|
|
659
|
-
e.failed.length > 0 &&
|
|
639
|
+
e.failed.length > 0 && I.warn("Submit before listeners failed.", {
|
|
660
640
|
eventName: e.eventName,
|
|
661
641
|
failed: e.failed.length
|
|
662
642
|
});
|
|
663
643
|
}
|
|
664
644
|
if (s) {
|
|
665
645
|
let e = await n.emitSafe("formie:submit:final:before", c);
|
|
666
|
-
e.failed.length > 0 &&
|
|
646
|
+
e.failed.length > 0 && I.warn("Final submit before listeners failed.", {
|
|
667
647
|
eventName: e.eventName,
|
|
668
648
|
failed: e.failed.length
|
|
669
649
|
});
|
|
670
650
|
}
|
|
671
|
-
let u = r.preflightOnly ?
|
|
651
|
+
let u = r.preflightOnly ? Ze : Xe;
|
|
672
652
|
for (let e of u) {
|
|
673
|
-
if (
|
|
653
|
+
if (I.log("Stage start.", {
|
|
674
654
|
stage: e,
|
|
675
655
|
action: t
|
|
676
|
-
}), i) return
|
|
656
|
+
}), i) return I.warn("Stage skipped due to abort.", {
|
|
677
657
|
stage: e,
|
|
678
658
|
reason: a
|
|
679
|
-
}),
|
|
659
|
+
}), Qe(e, a);
|
|
680
660
|
{
|
|
681
661
|
let t = await n.emitSafe(`formie:stage:${e}:before`, {
|
|
682
662
|
...c,
|
|
683
663
|
stage: e
|
|
684
664
|
});
|
|
685
|
-
t.failed.length > 0 &&
|
|
665
|
+
t.failed.length > 0 && I.warn("Stage before listeners failed.", {
|
|
686
666
|
stage: e,
|
|
687
667
|
failed: t.failed.length
|
|
688
668
|
});
|
|
689
669
|
}
|
|
690
670
|
if (i) {
|
|
691
|
-
let t =
|
|
671
|
+
let t = Qe(e, a);
|
|
692
672
|
{
|
|
693
673
|
let r = await n.emitSafe("formie:submit:after", t);
|
|
694
|
-
r.failed.length > 0 &&
|
|
674
|
+
r.failed.length > 0 && I.warn("Submit after listeners failed (abort before stage).", {
|
|
695
675
|
stage: e,
|
|
696
676
|
failed: r.failed.length
|
|
697
677
|
});
|
|
698
678
|
}
|
|
699
679
|
if (s) {
|
|
700
680
|
let r = await n.emitSafe("formie:submit:final:after", t);
|
|
701
|
-
r.failed.length > 0 &&
|
|
681
|
+
r.failed.length > 0 && I.warn("Final submit after listeners failed (abort before stage).", {
|
|
702
682
|
stage: e,
|
|
703
683
|
failed: r.failed.length
|
|
704
684
|
});
|
|
705
685
|
}
|
|
706
|
-
return
|
|
686
|
+
return I.warn("Aborted after stage before-hooks.", {
|
|
707
687
|
stage: e,
|
|
708
688
|
reason: a
|
|
709
689
|
}), t;
|
|
710
690
|
}
|
|
711
691
|
let r = await l[e](c);
|
|
712
|
-
|
|
692
|
+
I.log("Stage runner complete.", {
|
|
713
693
|
stage: e,
|
|
714
694
|
hasResult: !!r,
|
|
715
695
|
ok: r ? r.ok : void 0,
|
|
@@ -721,28 +701,28 @@ async function nt(e, t, n, r = {}) {
|
|
|
721
701
|
stage: e,
|
|
722
702
|
result: r
|
|
723
703
|
});
|
|
724
|
-
t.failed.length > 0 &&
|
|
704
|
+
t.failed.length > 0 && I.warn("Stage after listeners failed.", {
|
|
725
705
|
stage: e,
|
|
726
706
|
failed: t.failed.length
|
|
727
707
|
});
|
|
728
708
|
}
|
|
729
709
|
if (i) {
|
|
730
|
-
let t =
|
|
710
|
+
let t = Qe(e, a);
|
|
731
711
|
{
|
|
732
712
|
let r = await n.emitSafe("formie:submit:after", t);
|
|
733
|
-
r.failed.length > 0 &&
|
|
713
|
+
r.failed.length > 0 && I.warn("Submit after listeners failed (abort after stage).", {
|
|
734
714
|
stage: e,
|
|
735
715
|
failed: r.failed.length
|
|
736
716
|
});
|
|
737
717
|
}
|
|
738
718
|
if (s) {
|
|
739
719
|
let r = await n.emitSafe("formie:submit:final:after", t);
|
|
740
|
-
r.failed.length > 0 &&
|
|
720
|
+
r.failed.length > 0 && I.warn("Final submit after listeners failed (abort after stage).", {
|
|
741
721
|
stage: e,
|
|
742
722
|
failed: r.failed.length
|
|
743
723
|
});
|
|
744
724
|
}
|
|
745
|
-
return
|
|
725
|
+
return I.warn("Aborted after stage after-hooks.", {
|
|
746
726
|
stage: e,
|
|
747
727
|
reason: a
|
|
748
728
|
}), t;
|
|
@@ -750,19 +730,19 @@ async function nt(e, t, n, r = {}) {
|
|
|
750
730
|
if (r && !r.ok) {
|
|
751
731
|
{
|
|
752
732
|
let t = await n.emitSafe("formie:submit:after", r);
|
|
753
|
-
t.failed.length > 0 &&
|
|
733
|
+
t.failed.length > 0 && I.warn("Submit after listeners failed (failed stage).", {
|
|
754
734
|
stage: e,
|
|
755
735
|
failed: t.failed.length
|
|
756
736
|
});
|
|
757
737
|
}
|
|
758
738
|
if (s) {
|
|
759
739
|
let t = await n.emitSafe("formie:submit:final:after", r);
|
|
760
|
-
t.failed.length > 0 &&
|
|
740
|
+
t.failed.length > 0 && I.warn("Final submit after listeners failed (failed stage).", {
|
|
761
741
|
stage: e,
|
|
762
742
|
failed: t.failed.length
|
|
763
743
|
});
|
|
764
744
|
}
|
|
765
|
-
return
|
|
745
|
+
return I.warn("Pipeline short-circuited by failed stage.", {
|
|
766
746
|
stage: e,
|
|
767
747
|
code: r.code,
|
|
768
748
|
message: r.message
|
|
@@ -771,18 +751,19 @@ async function nt(e, t, n, r = {}) {
|
|
|
771
751
|
}
|
|
772
752
|
let d = o || {
|
|
773
753
|
ok: !0,
|
|
774
|
-
stage: r.preflightOnly ? "
|
|
754
|
+
stage: r.preflightOnly ? "payment" : "result",
|
|
755
|
+
code: r.preflightOnly ? "PREFLIGHT_COMPLETE" : void 0,
|
|
775
756
|
message: r.preflightOnly ? "Submission preflight completed." : "Submission completed."
|
|
776
757
|
};
|
|
777
758
|
{
|
|
778
759
|
let e = await n.emitSafe("formie:submit:after", d);
|
|
779
|
-
e.failed.length > 0 &&
|
|
760
|
+
e.failed.length > 0 && I.warn("Submit after listeners failed (success).", { failed: e.failed.length });
|
|
780
761
|
}
|
|
781
762
|
if (s) {
|
|
782
763
|
let e = await n.emitSafe("formie:submit:final:after", d);
|
|
783
|
-
e.failed.length > 0 &&
|
|
764
|
+
e.failed.length > 0 && I.warn("Final submit after listeners failed (success).", { failed: e.failed.length });
|
|
784
765
|
}
|
|
785
|
-
return
|
|
766
|
+
return I.log("Pipeline completed.", {
|
|
786
767
|
ok: d.ok,
|
|
787
768
|
stage: d.stage,
|
|
788
769
|
code: d.code
|
|
@@ -790,169 +771,864 @@ async function nt(e, t, n, r = {}) {
|
|
|
790
771
|
}
|
|
791
772
|
//#endregion
|
|
792
773
|
//#region src/js/core/field-error-container.ts
|
|
793
|
-
function
|
|
774
|
+
function ct(e) {
|
|
794
775
|
return e.querySelector("[data-formie-field-layout]")?.getAttribute("data-formie-error-position")?.trim() === "above" ? "above" : "below";
|
|
795
776
|
}
|
|
796
|
-
function
|
|
777
|
+
function lt(e, t) {
|
|
797
778
|
let n = e.querySelector("[data-formie-field-errors]");
|
|
798
779
|
if (n) return n;
|
|
799
|
-
let r = e.querySelector("[data-formie-field-content]"), i = e.querySelector("[data-formie-field-control]"), a =
|
|
780
|
+
let r = e.querySelector("[data-formie-field-content]"), i = e.querySelector("[data-formie-field-control]"), a = ct(e), o = document.createElement("div");
|
|
800
781
|
return o.setAttribute("data-formie-field-errors", "true"), t?.(o), r && i ? a === "above" ? r.insertBefore(o, i) : r.appendChild(o) : e.appendChild(o), o;
|
|
801
782
|
}
|
|
802
783
|
//#endregion
|
|
803
|
-
//#region src/js/
|
|
804
|
-
var
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
};
|
|
808
|
-
//#endregion
|
|
809
|
-
//#region src/js/validation/rules/shared.ts
|
|
810
|
-
function ot(e) {
|
|
811
|
-
return e?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() || "";
|
|
784
|
+
//#region src/js/core/submit-result-ui.ts
|
|
785
|
+
var L = /* @__PURE__ */ new WeakMap();
|
|
786
|
+
function ut(e) {
|
|
787
|
+
return (e.dataset.formieCompletionBehavior || e.dataset.formieSubmitAction || "").trim();
|
|
812
788
|
}
|
|
813
|
-
function
|
|
814
|
-
|
|
815
|
-
if (!t || t === !0 || typeof t != "object" || !e.field) return null;
|
|
816
|
-
let n = typeof t.fieldHandle == "string" ? t.fieldHandle.trim() : "";
|
|
817
|
-
if (!n) return null;
|
|
818
|
-
let r = e.form.querySelector(`[data-formie-field-handle="${n}"]`);
|
|
819
|
-
return r ? r.querySelector(e.config.fieldsSelector) : null;
|
|
789
|
+
function dt(e) {
|
|
790
|
+
return (e.dataset.formieErrorMessagePosition || "top-form").trim() || "top-form";
|
|
820
791
|
}
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
var ct = {
|
|
824
|
-
required: {
|
|
825
|
-
rule: ({ input: e, getRule: t }) => {
|
|
826
|
-
if (!t("required") || e.type === "hidden") return !0;
|
|
827
|
-
if (e.type === "checkbox" || e.type === "radio") {
|
|
828
|
-
let t = e.form?.querySelectorAll(`[name="${e.name}"]:not([type="hidden"]):not([disabled])`) || [];
|
|
829
|
-
return t.length ? Array.from(t).some((e) => e instanceof HTMLInputElement && e.checked) : e instanceof HTMLInputElement ? e.checked : !0;
|
|
830
|
-
}
|
|
831
|
-
return e.value.trim() !== "";
|
|
832
|
-
},
|
|
833
|
-
message: ({ input: e, label: t, t: n }) => e.getAttribute("data-formie-required-message") ?? e.getAttribute("data-required-message") ?? n("{label} cannot be blank.", { label: t })
|
|
834
|
-
},
|
|
835
|
-
email: at,
|
|
836
|
-
url: {
|
|
837
|
-
rule: ({ input: e, getRule: t }) => {
|
|
838
|
-
if (!t("url") || !e.value || e.value.length < 1) return !0;
|
|
839
|
-
try {
|
|
840
|
-
return new URL(e.value), !0;
|
|
841
|
-
} catch {
|
|
842
|
-
return !1;
|
|
843
|
-
}
|
|
844
|
-
},
|
|
845
|
-
message: ({ input: e, label: t, t: n }) => e.getAttribute("data-formie-pattern-url-message") ?? e.getAttribute("data-pattern-url-message") ?? n("{label} is not a valid URL.", { label: t })
|
|
846
|
-
},
|
|
847
|
-
number: {
|
|
848
|
-
rule: ({ input: e, getRule: t }) => {
|
|
849
|
-
let n = t("number");
|
|
850
|
-
if (!n || !e.value || e.value.trim() === "") return !0;
|
|
851
|
-
let r = parseFloat(e.value);
|
|
852
|
-
if (Number.isNaN(r)) return !1;
|
|
853
|
-
if (n !== !0 && typeof n == "object") {
|
|
854
|
-
let e = typeof n.min == "number" ? n.min : null, t = typeof n.max == "number" ? n.max : null;
|
|
855
|
-
if (e !== null && r < e || t !== null && r > t) return !1;
|
|
856
|
-
}
|
|
857
|
-
return !0;
|
|
858
|
-
},
|
|
859
|
-
message: ({ input: e, label: t, getRule: n, t: r }) => {
|
|
860
|
-
let i = n("number"), a = i !== !0 && i && typeof i == "object" && typeof i.min == "number" ? i.min : null, o = i !== !0 && i && typeof i == "object" && typeof i.max == "number" ? i.max : null;
|
|
861
|
-
return a !== null && o !== null || a !== null ? e.getAttribute("data-formie-validation-number-min-message") ?? r("{label} must be no less than {min}.", {
|
|
862
|
-
label: t,
|
|
863
|
-
min: a
|
|
864
|
-
}) : o === null ? e.getAttribute("data-formie-validation-number-message") ?? e.getAttribute("data-formie-pattern-number-message") ?? e.getAttribute("data-pattern-number-message") ?? r("{label} is not a valid number.", { label: t }) : e.getAttribute("data-formie-validation-number-max-message") ?? r("{label} must be no greater than {max}.", {
|
|
865
|
-
label: t,
|
|
866
|
-
max: o
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
|
-
},
|
|
870
|
-
match: {
|
|
871
|
-
rule: (e) => {
|
|
872
|
-
let t = st(e);
|
|
873
|
-
return t ? t.value === e.input.value : !0;
|
|
874
|
-
},
|
|
875
|
-
message: (e) => {
|
|
876
|
-
let t = st(e)?.closest("[data-formie-field-handle]"), n = ot(t);
|
|
877
|
-
return e.input.getAttribute("data-formie-validation-match-message") ?? e.t("{label} must match {value}.", {
|
|
878
|
-
label: e.label,
|
|
879
|
-
value: n
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
}, lt = {
|
|
884
|
-
email: /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*(\.\w{2,})+$/,
|
|
885
|
-
url: /^(?:(?:https?|HTTPS?|ftp|FTP):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)(?:\.(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)*(?:\.(?:[a-zA-Z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/,
|
|
886
|
-
number: /^(?:[-+]?[0-9]*[.,]?[0-9]+)$/,
|
|
887
|
-
color: /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,
|
|
888
|
-
date: /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))/,
|
|
889
|
-
time: /^(?:(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]))$/,
|
|
890
|
-
month: /^(?:(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])))$/
|
|
891
|
-
}, N = S("general", "validator");
|
|
892
|
-
function P(e) {
|
|
893
|
-
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement);
|
|
792
|
+
function ft(e) {
|
|
793
|
+
return (e.dataset.formieSuccessMessagePosition || e.dataset.formieSubmitActionMessagePosition || "").trim();
|
|
894
794
|
}
|
|
895
|
-
function
|
|
896
|
-
let
|
|
897
|
-
if (!
|
|
898
|
-
let
|
|
899
|
-
|
|
900
|
-
e.setAttribute("aria-describedby", r.join(" "));
|
|
901
|
-
return;
|
|
902
|
-
}
|
|
903
|
-
e.removeAttribute("aria-describedby");
|
|
795
|
+
function pt(e) {
|
|
796
|
+
let t = (e.dataset.formieSuccessMessageTimeout || e.dataset.formieSubmitActionMessageTimeout || "").trim();
|
|
797
|
+
if (!t) return null;
|
|
798
|
+
let n = Number.parseFloat(t);
|
|
799
|
+
return !Number.isFinite(n) || n < 0 ? null : Math.round(n * 1e3);
|
|
904
800
|
}
|
|
905
|
-
function
|
|
906
|
-
let
|
|
907
|
-
|
|
801
|
+
function mt(e) {
|
|
802
|
+
let t = e.dataset.formieHideFormAfterSubmit ?? e.dataset.formieSubmitActionFormHide;
|
|
803
|
+
if (t === void 0) return !1;
|
|
804
|
+
let n = t.trim().toLowerCase();
|
|
805
|
+
return n === "true" || n === "1" || n === "";
|
|
908
806
|
}
|
|
909
|
-
function
|
|
910
|
-
|
|
807
|
+
function ht(e) {
|
|
808
|
+
let t = L.get(e);
|
|
809
|
+
typeof t == "number" && (window.clearTimeout(t), L.delete(e));
|
|
911
810
|
}
|
|
912
|
-
function
|
|
913
|
-
e.
|
|
811
|
+
function gt(e) {
|
|
812
|
+
return e.querySelector("[data-formie-form-messages-top]") || e;
|
|
914
813
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
814
|
+
function _t(e) {
|
|
815
|
+
return e.querySelector("[data-formie-form-messages-bottom]") || e;
|
|
816
|
+
}
|
|
817
|
+
function vt(e, t) {
|
|
818
|
+
return t === "bottom-form" ? _t(e) : gt(e);
|
|
819
|
+
}
|
|
820
|
+
function yt(e, t) {
|
|
821
|
+
return t === "top-form" ? gt(e) : t === "bottom-form" && !mt(e) ? _t(e) : e;
|
|
822
|
+
}
|
|
823
|
+
function bt(e) {
|
|
824
|
+
let t = dt(e), n = vt(e, t), r = n.querySelector("[data-formie-error-container], [data-formie-errors]");
|
|
825
|
+
return r || (r = document.createElement("div"), r.setAttribute("data-formie-errors", "true"), D(r, e, "errors")), r.setAttribute("data-formie-error-container", "true"), t === "bottom-form" ? n.append(r) : n.prepend(r), r;
|
|
826
|
+
}
|
|
827
|
+
function xt(e, t) {
|
|
828
|
+
let n = t.querySelector("[data-formie-error-message-container], [data-formie-message][data-formie-message-error]");
|
|
829
|
+
return n || (n = document.createElement("div"), n.setAttribute("data-formie-error-message-container", "true"), t.appendChild(n)), n.setAttribute("data-formie-message", "true"), n.setAttribute("data-formie-message-error", "true"), D(n, e, "message", "messageError"), n.setAttribute("role", "alert"), N(n, je(M(e))), n;
|
|
830
|
+
}
|
|
831
|
+
function St(e, t) {
|
|
832
|
+
let n = e.querySelector("[data-formie-success-container]"), r = yt(e, t);
|
|
833
|
+
return n || (n = document.createElement("div"), n.setAttribute("data-formie-success-container", "true"), D(n, e, "successes")), t === "bottom-form" ? r.append(n) : r.prepend(n), n;
|
|
834
|
+
}
|
|
835
|
+
function Ct(e) {
|
|
836
|
+
return lt(e, (t) => {
|
|
837
|
+
D(t, e, "fieldErrors");
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
function wt(e) {
|
|
841
|
+
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
842
|
+
let n = t, r = n.querySelector("[data-formie-field-errors]"), i = Array.from(n.querySelectorAll("[data-formie-field-error]")).map((e) => e.id).filter(Boolean);
|
|
843
|
+
E(n, e, "fieldLayoutError"), n.removeAttribute("data-formie-field-has-error"), n.querySelectorAll("[data-formie-field-error]").forEach((e) => {
|
|
844
|
+
e.remove();
|
|
845
|
+
}), r && !r.querySelector("[data-formie-field-error]") && (r.innerHTML = ""), n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
846
|
+
let n = t;
|
|
847
|
+
n.removeAttribute("aria-invalid"), E(n, e, "fieldControlError"), n.removeAttribute("data-formie-input-has-error"), Fe(n, i);
|
|
848
|
+
});
|
|
849
|
+
}), C(e);
|
|
850
|
+
}
|
|
851
|
+
function Tt(e) {
|
|
852
|
+
e.querySelectorAll("[data-formie-error-container], [data-formie-errors]").forEach((t) => {
|
|
853
|
+
let n = t;
|
|
854
|
+
n.querySelectorAll("[data-formie-error]").forEach((e) => {
|
|
855
|
+
e.remove();
|
|
856
|
+
}), E(n, e, "message", "messageError"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-error"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-error]") || (n.innerHTML = "");
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
function Et(e) {
|
|
860
|
+
ht(e), e.querySelectorAll("[data-formie-message-success]:not([data-formie-success-container])").forEach((e) => {
|
|
861
|
+
e.remove();
|
|
862
|
+
}), e.querySelectorAll("[data-formie-success-container]").forEach((t) => {
|
|
863
|
+
let n = t;
|
|
864
|
+
n.querySelectorAll("[data-formie-success]").forEach((e) => {
|
|
865
|
+
e.remove();
|
|
866
|
+
}), E(n, e, "message", "messageSuccess"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-success"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-success]") || (n.innerHTML = "");
|
|
867
|
+
}), ut(e) === "message" && mt(e) || d(e, !1);
|
|
868
|
+
}
|
|
869
|
+
function Dt(e) {
|
|
870
|
+
e.querySelectorAll("[aria-invalid=\"true\"]").forEach((e) => {
|
|
871
|
+
e.removeAttribute("aria-invalid");
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
function Ot(e, t) {
|
|
875
|
+
let n = je(M(e));
|
|
876
|
+
Object.entries(t).forEach(([t, r]) => {
|
|
877
|
+
let i = `fields[${t.split(".").join("][")}]`, a = e.querySelector(`[name="${CSS.escape(i)}"], [name="${CSS.escape(i + "[]")}"]`)?.closest("[data-formie-field-handle]") || e.querySelector(`[data-formie-field-handle="${CSS.escape(t)}"]`);
|
|
878
|
+
if (!a) return;
|
|
879
|
+
let o = Ct(a), s = o.id && o.id.trim() ? o.id : `${t}-errors`;
|
|
880
|
+
o.id = s, N(o, n), D(a, e, "fieldLayoutError"), a.setAttribute("data-formie-field-has-error", "true"), r.forEach((t, n) => {
|
|
881
|
+
let r = document.createElement("div");
|
|
882
|
+
r.setAttribute("data-formie-field-error", "true"), r.id = `${s}-${n + 1}`, D(r, e, "fieldError"), r.textContent = t, o.appendChild(r);
|
|
883
|
+
});
|
|
884
|
+
let c = o.querySelector("[data-formie-field-error]")?.id;
|
|
885
|
+
a.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
886
|
+
let n = t;
|
|
887
|
+
n.setAttribute("aria-invalid", "true"), D(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), c && Pe(n, c);
|
|
888
|
+
let r = a.querySelector("[data-formie-instructions]");
|
|
889
|
+
r?.id && Me(n, r.id);
|
|
890
|
+
});
|
|
891
|
+
}), C(e);
|
|
892
|
+
}
|
|
893
|
+
function kt(e, t) {
|
|
894
|
+
let n = bt(e), r = xt(e, n);
|
|
895
|
+
D(n, e, "errors"), t.forEach((t) => {
|
|
896
|
+
let n = document.createElement("div");
|
|
897
|
+
n.setAttribute("data-formie-error", "true"), n.setAttribute("role", "alert"), D(n, e, "error"), n.innerHTML = t, r.appendChild(n);
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
function At(e) {
|
|
901
|
+
if (e.ok || e.keepSubmitLoading !== !0) return !1;
|
|
902
|
+
let t = e.payment?.status;
|
|
903
|
+
return t === "requiresAction" || t === "pending" || t === "unknown";
|
|
904
|
+
}
|
|
905
|
+
function jt(e, t) {
|
|
906
|
+
let n = bt(e), r = xt(e, n);
|
|
907
|
+
D(n, e, "errors");
|
|
908
|
+
let i = document.createElement("div");
|
|
909
|
+
i.setAttribute("data-formie-notice", "true"), i.setAttribute("role", "status"), D(i, e, "message"), i.textContent = t, r.appendChild(i);
|
|
910
|
+
}
|
|
911
|
+
function Mt(e, t) {
|
|
912
|
+
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" || ut(e) === "message" && ft(e) !== "";
|
|
913
|
+
}
|
|
914
|
+
function Nt(e, t) {
|
|
915
|
+
let n = ft(e);
|
|
916
|
+
if (!n) return;
|
|
917
|
+
let r = St(e, n);
|
|
918
|
+
D(r, e, "message", "messageSuccess"), r.setAttribute("data-formie-message", "true"), r.setAttribute("data-formie-message-success", "true"), r.setAttribute("role", "status"), r.setAttribute("aria-live", "polite"), r.setAttribute("aria-atomic", "true");
|
|
919
|
+
let i = document.createElement("div");
|
|
920
|
+
i.setAttribute("data-formie-success", "true"), D(i, e, "success"), i.innerHTML = t, r.appendChild(i), mt(e) && d(e, !0);
|
|
921
|
+
let a = pt(e);
|
|
922
|
+
if (a !== null) {
|
|
923
|
+
let t = window.setTimeout(() => {
|
|
924
|
+
L.delete(e), Et(e);
|
|
925
|
+
}, a);
|
|
926
|
+
L.set(e, t);
|
|
947
927
|
}
|
|
948
|
-
|
|
949
|
-
|
|
928
|
+
}
|
|
929
|
+
function R(e, t) {
|
|
930
|
+
if (wt(e), Tt(e), Et(e), Dt(e), t.ok) {
|
|
931
|
+
Mt(e, t) && Nt(e, t.message || "");
|
|
932
|
+
return;
|
|
950
933
|
}
|
|
951
|
-
|
|
952
|
-
|
|
934
|
+
if (!t.ok) {
|
|
935
|
+
if (At(t)) {
|
|
936
|
+
let n = String(t.payment?.message || "").trim();
|
|
937
|
+
n && jt(e, n);
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
t.fieldErrors && Ot(e, t.fieldErrors), t.formErrors?.length ? kt(e, t.formErrors) : !t.fieldErrors && t.message && kt(e, [t.message]), Ve(e);
|
|
953
941
|
}
|
|
954
|
-
|
|
955
|
-
|
|
942
|
+
}
|
|
943
|
+
//#endregion
|
|
944
|
+
//#region src/js/core/submit-flow.ts
|
|
945
|
+
var Pt = T("general", "submit-flow");
|
|
946
|
+
function Ft(e) {
|
|
947
|
+
return !(!e.ok && e.stage === "validate");
|
|
948
|
+
}
|
|
949
|
+
function It(e) {
|
|
950
|
+
return e ? !!(e.keepSubmitLoading === !0 || e.ok && e.redirect?.url && e.redirect.target !== "new-tab") : !1;
|
|
951
|
+
}
|
|
952
|
+
function z(e) {
|
|
953
|
+
wt(e), Tt(e), Et(e), Dt(e);
|
|
954
|
+
}
|
|
955
|
+
async function Lt(e) {
|
|
956
|
+
let { id: t, target: n, form: r, bus: i, validator: a, validateOnSubmit: o, action: s, submitter: c, waitForSubmitDelay: l, onRefreshTokensAfterSubmit: u, dispatchSubmitResult: d } = e;
|
|
957
|
+
z(r), v(r, c || null);
|
|
958
|
+
let f = {
|
|
959
|
+
ok: !1,
|
|
960
|
+
code: "SUBMIT_ERROR",
|
|
961
|
+
message: "Submission failed.",
|
|
962
|
+
formErrors: ["Submission failed."]
|
|
963
|
+
};
|
|
964
|
+
try {
|
|
965
|
+
await l(r), f = await st(r, s, i, {
|
|
966
|
+
validator: a,
|
|
967
|
+
validateOnSubmit: o
|
|
968
|
+
}), R(r, f), d(f), b(r, f, s), Ft(f) && await u(f);
|
|
969
|
+
} catch (e) {
|
|
970
|
+
f = {
|
|
971
|
+
ok: !1,
|
|
972
|
+
code: "SUBMIT_ERROR",
|
|
973
|
+
message: e instanceof Error ? e.message : "Submission failed.",
|
|
974
|
+
formErrors: [e instanceof Error ? e.message : "Submission failed."]
|
|
975
|
+
}, R(r, f), d(f), Pt.warn("Submit failed with exception.", {
|
|
976
|
+
id: t,
|
|
977
|
+
action: s,
|
|
978
|
+
target: n,
|
|
979
|
+
error: e instanceof Error ? e.message : e
|
|
980
|
+
});
|
|
981
|
+
} finally {
|
|
982
|
+
It(f) || h(r);
|
|
983
|
+
}
|
|
984
|
+
return f;
|
|
985
|
+
}
|
|
986
|
+
//#endregion
|
|
987
|
+
//#region src/js/events/event-bus.ts
|
|
988
|
+
var Rt = class {
|
|
989
|
+
listeners = /* @__PURE__ */ new Map();
|
|
990
|
+
on(e, t) {
|
|
991
|
+
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e)?.add(t), () => {
|
|
992
|
+
this.listeners.get(e)?.delete(t);
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
async emit(e, t) {
|
|
996
|
+
let n = this.listeners.get(e);
|
|
997
|
+
if (n && n.size !== 0) for (let e of n) await e(t);
|
|
998
|
+
}
|
|
999
|
+
async emitSafe(e, t) {
|
|
1000
|
+
let n = this.listeners.get(e), r = {
|
|
1001
|
+
eventName: e,
|
|
1002
|
+
total: n?.size || 0,
|
|
1003
|
+
succeeded: 0,
|
|
1004
|
+
failed: []
|
|
1005
|
+
};
|
|
1006
|
+
if (!n || n.size === 0) return r;
|
|
1007
|
+
let i = 0;
|
|
1008
|
+
for (let e of n) {
|
|
1009
|
+
try {
|
|
1010
|
+
await e(t), r.succeeded += 1;
|
|
1011
|
+
} catch (e) {
|
|
1012
|
+
r.failed.push({
|
|
1013
|
+
index: i,
|
|
1014
|
+
error: e
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
i += 1;
|
|
1018
|
+
}
|
|
1019
|
+
return r;
|
|
1020
|
+
}
|
|
1021
|
+
async emitParallelSafe(e, t) {
|
|
1022
|
+
let n = this.listeners.get(e), r = {
|
|
1023
|
+
eventName: e,
|
|
1024
|
+
total: n?.size || 0,
|
|
1025
|
+
succeeded: 0,
|
|
1026
|
+
failed: []
|
|
1027
|
+
};
|
|
1028
|
+
return !n || n.size === 0 || (await Promise.allSettled(Array.from(n).map(async (e) => e(t)))).forEach((e, t) => {
|
|
1029
|
+
if (e.status === "fulfilled") {
|
|
1030
|
+
r.succeeded += 1;
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
r.failed.push({
|
|
1034
|
+
index: t,
|
|
1035
|
+
error: e.reason
|
|
1036
|
+
});
|
|
1037
|
+
}), r;
|
|
1038
|
+
}
|
|
1039
|
+
clear() {
|
|
1040
|
+
this.listeners.clear();
|
|
1041
|
+
}
|
|
1042
|
+
}, B = class {
|
|
1043
|
+
modules = /* @__PURE__ */ new Map();
|
|
1044
|
+
register(e, t = {}) {
|
|
1045
|
+
if (!/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/.test(e.moduleId) || e.version !== 2 || !Array.isArray(e.surfaces) || e.surfaces.length === 0 || e.surfaces.some((e) => ![
|
|
1046
|
+
"server-rendered",
|
|
1047
|
+
"client-rendered",
|
|
1048
|
+
"cp-edit"
|
|
1049
|
+
].includes(e)) || ![
|
|
1050
|
+
"field",
|
|
1051
|
+
"captcha",
|
|
1052
|
+
"payment",
|
|
1053
|
+
"address",
|
|
1054
|
+
"core"
|
|
1055
|
+
].includes(e.kind) || typeof e.match != "function" || typeof e.setup != "function") throw Error("Unsupported browser module definition. Register a namespaced moduleId compatible with version 2.");
|
|
1056
|
+
let n = this.modules.get(e.moduleId);
|
|
1057
|
+
return n === e ? !0 : n && !t.replace ? (console.warn(`[formie] Module "${e.moduleId}" is already registered. Pass { replace: true } to override the existing definition.`), !1) : (this.modules.set(e.moduleId, e), !0);
|
|
1058
|
+
}
|
|
1059
|
+
unregister(e) {
|
|
1060
|
+
this.modules.delete(e);
|
|
1061
|
+
}
|
|
1062
|
+
get(e) {
|
|
1063
|
+
return this.modules.get(e) || null;
|
|
1064
|
+
}
|
|
1065
|
+
getAll() {
|
|
1066
|
+
return Array.from(this.modules.values());
|
|
1067
|
+
}
|
|
1068
|
+
}, zt = new B(), Bt = {
|
|
1069
|
+
"address-finder": () => import("./chunks/address-finder-O49uDRoR.js").then((e) => e.addressFinderModule),
|
|
1070
|
+
"google-address": () => import("./chunks/google-address-C1P1nTDM.js").then((e) => e.googleAddressModule),
|
|
1071
|
+
loqate: () => import("./chunks/loqate-DD1S7PY9.js").then((e) => e.loqateModule),
|
|
1072
|
+
"place-kit": () => import("./chunks/place-kit-BE5gi3vo.js").then((e) => e.placeKitModule)
|
|
1073
|
+
}, Vt = {
|
|
1074
|
+
"captcha-eu": () => import("./chunks/captcha-eu-DERJbXnH.js").then((e) => e.captchaEuModule),
|
|
1075
|
+
"friendly-captcha-v1": () => import("./chunks/friendly-captcha-v1-GFqCt1Mh.js").then((e) => e.friendlyCaptchaV1Module),
|
|
1076
|
+
"friendly-captcha-v2": () => import("./chunks/friendly-captcha-v2-WoW246JG.js").then((e) => e.friendlyCaptchaV2Module),
|
|
1077
|
+
hcaptcha: () => import("./chunks/hcaptcha-D0T8aIHz.js").then((e) => e.hcaptchaModule),
|
|
1078
|
+
"recaptcha-enterprise": () => import("./chunks/recaptcha-enterprise-CruXddZq.js").then((e) => e.recaptchaEnterpriseModule),
|
|
1079
|
+
"recaptcha-v2-checkbox": () => import("./chunks/recaptcha-v2-checkbox-CCnJYCnG.js").then((e) => e.recaptchaV2CheckboxModule),
|
|
1080
|
+
"recaptcha-v2-invisible": () => import("./chunks/recaptcha-v2-invisible-BuVqRRYn.js").then((e) => e.recaptchaV2InvisibleModule),
|
|
1081
|
+
"recaptcha-v3": () => import("./chunks/recaptcha-v3-CloqhO2A.js").then((e) => e.recaptchaV3Module),
|
|
1082
|
+
snaptcha: () => import("./chunks/snaptcha-C04kNGYQ.js").then((e) => e.snaptchaModule),
|
|
1083
|
+
turnstile: () => import("./chunks/turnstile-n9DNyPxi.js").then((e) => e.turnstileModule)
|
|
1084
|
+
}, Ht = {
|
|
1085
|
+
calculations: () => import("./chunks/calculations-YEoVCG2q.js").then((e) => e.calculationsModule),
|
|
1086
|
+
"checkbox-radio": () => import("./chunks/checkbox-radio-gsm8QPJg.js").then((e) => e.checkboxRadioModule),
|
|
1087
|
+
combobox: () => import("./chunks/combobox-CWNdx4Fk.js").then((e) => e.comboboxModule),
|
|
1088
|
+
conditions: () => import("./chunks/conditions-DqNHLTbN.js").then((e) => e.conditionsModule),
|
|
1089
|
+
"custom-google-maps": () => import("./chunks/custom-google-maps-C4l2S3GO.js").then((e) => e.customGoogleMapsModule),
|
|
1090
|
+
"custom-link": () => import("./chunks/custom-link-CLazgKYH.js").then((e) => e.customLinkModule),
|
|
1091
|
+
"custom-maps": () => import("./chunks/custom-maps-DqcAlD0v.js").then((e) => e.customMapsModule),
|
|
1092
|
+
"date-picker": () => import("./chunks/date-picker-RUnevF7l.js").then((e) => e.datePickerModule),
|
|
1093
|
+
"file-upload": () => import("./chunks/file-upload-Bm-TXyNB.js").then((e) => e.fileUploadModule),
|
|
1094
|
+
"upload-manager": () => import("./chunks/upload-manager-BbiUosZq.js").then((e) => e.uploadManagerModule),
|
|
1095
|
+
hidden: () => import("./chunks/hidden-BZhXnNPe.js").then((e) => e.hiddenModule),
|
|
1096
|
+
"phone-country": () => import("./chunks/phone-country-bAqje17P.js").then((e) => e.phoneCountryModule),
|
|
1097
|
+
"password-validation": () => import("./chunks/password-validation-C8_uO_c_.js").then((e) => e.passwordValidationModule),
|
|
1098
|
+
"address-country": () => import("./chunks/address-country-Dn71jroa.js").then((e) => e.addressCountryModule),
|
|
1099
|
+
"address-state": () => import("./chunks/address-state-ByYatUur.js").then((e) => e.addressStateModule),
|
|
1100
|
+
repeater: () => import("./chunks/repeater-DwE27jI1.js").then((e) => e.repeaterModule),
|
|
1101
|
+
"rich-text": () => import("./chunks/rich-text-uV4o_pGk.js").then((e) => e.richTextModule),
|
|
1102
|
+
signature: () => import("./chunks/signature-7cldFbqj.js").then((e) => e.signatureModule),
|
|
1103
|
+
summary: () => import("./chunks/summary-BF_8mrXI.js").then((e) => e.summaryModule),
|
|
1104
|
+
"survey-likert": () => import("./chunks/survey-likert-fk1hUPff.js").then((e) => e.surveyLikertModule),
|
|
1105
|
+
"survey-rank": () => import("./chunks/survey-rank-BsLGl2LX.js").then((e) => e.surveyRankModule),
|
|
1106
|
+
"survey-rating": () => import("./chunks/survey-rating-DVS6e6fM.js").then((e) => e.surveyRatingModule),
|
|
1107
|
+
table: () => import("./chunks/table-DnIBdeKF.js").then((e) => e.tableModule),
|
|
1108
|
+
"text-limit": () => import("./chunks/text-limit-LGMPhFuC.js").then((e) => e.textLimitModule)
|
|
1109
|
+
}, Ut = {
|
|
1110
|
+
bpoint: () => import("./chunks/bpoint-D0RKFM4F.js").then((e) => e.bpointModule),
|
|
1111
|
+
eway: () => import("./chunks/eway-or6dtjoT.js").then((e) => e.ewayModule),
|
|
1112
|
+
"go-cardless": () => import("./chunks/go-cardless-DzJ-0FKg.js").then((e) => e.goCardlessModule),
|
|
1113
|
+
mollie: () => import("./chunks/mollie-DG8Ju83x.js").then((e) => e.mollieModule),
|
|
1114
|
+
moneris: () => import("./chunks/moneris-C8m3Fvqu.js").then((e) => e.monerisModule),
|
|
1115
|
+
opayo: () => import("./chunks/opayo-B3EvrVxw.js").then((e) => e.opayoModule),
|
|
1116
|
+
paddle: () => import("./chunks/paddle-BIYR9Um3.js").then((e) => e.paddleModule),
|
|
1117
|
+
paypal: () => import("./chunks/paypal-B_yxIo2d.js").then((e) => e.paypalModule),
|
|
1118
|
+
payway: () => import("./chunks/payway-CeOzS0sL.js").then((e) => e.paywayModule),
|
|
1119
|
+
square: () => import("./chunks/square-DEzxv9D9.js").then((e) => e.squareModule),
|
|
1120
|
+
stripe: () => import("./chunks/stripe-CVPQGDz3.js").then((e) => e.stripeModule)
|
|
1121
|
+
}, Wt = {
|
|
1122
|
+
...Ht,
|
|
1123
|
+
...Bt,
|
|
1124
|
+
...Vt,
|
|
1125
|
+
...Ut
|
|
1126
|
+
}, V = /* @__PURE__ */ new Map();
|
|
1127
|
+
function Gt(e) {
|
|
1128
|
+
if (e instanceof Error) return {
|
|
1129
|
+
name: e.name || "Error",
|
|
1130
|
+
message: e.message || "No error message was provided.",
|
|
1131
|
+
stack: e.stack
|
|
1132
|
+
};
|
|
1133
|
+
if (typeof e == "string") return {
|
|
1134
|
+
name: "Error",
|
|
1135
|
+
message: e
|
|
1136
|
+
};
|
|
1137
|
+
try {
|
|
1138
|
+
return {
|
|
1139
|
+
name: "Error",
|
|
1140
|
+
message: JSON.stringify(e) || String(e)
|
|
1141
|
+
};
|
|
1142
|
+
} catch {
|
|
1143
|
+
return {
|
|
1144
|
+
name: "Error",
|
|
1145
|
+
message: String(e)
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
function Kt(e, t, n) {
|
|
1150
|
+
let r = [...t].filter((e) => e.required), i = [
|
|
1151
|
+
"Formie browser module diagnostics",
|
|
1152
|
+
`Surface: ${e}`,
|
|
1153
|
+
`Browser: ${typeof navigator > "u" ? "Unavailable" : navigator.userAgent}`
|
|
1154
|
+
];
|
|
1155
|
+
return e === "cp-edit" && typeof location < "u" && i.push(`Page: ${location.origin}${location.pathname}`), r.forEach((t, r) => {
|
|
1156
|
+
let a = n.get(t.key);
|
|
1157
|
+
i.push("", `Failure ${r + 1}`, `Module: ${t.moduleId}`, `Key: ${t.key}`, `Code: ${t.code}`), e === "cp-edit" && a && (i.push(`Error: ${a.name}: ${a.message}`), a.stack && i.push("Stack:", a.stack));
|
|
1158
|
+
}), i.join("\n");
|
|
1159
|
+
}
|
|
1160
|
+
async function qt(e) {
|
|
1161
|
+
if (navigator.clipboard?.writeText) {
|
|
1162
|
+
await navigator.clipboard.writeText(e);
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
let t = document.createElement("textarea");
|
|
1166
|
+
t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select();
|
|
1167
|
+
try {
|
|
1168
|
+
if (!document.execCommand("copy")) throw Error("The browser did not allow clipboard access.");
|
|
1169
|
+
} finally {
|
|
1170
|
+
t.remove();
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
async function Jt(e, t) {
|
|
1174
|
+
let n = t.get(e);
|
|
1175
|
+
if (n) return n;
|
|
1176
|
+
let r = e.startsWith("formie:") && Object.prototype.hasOwnProperty.call(Wt, e.slice(7)) ? Wt[e.slice(7)] : void 0;
|
|
1177
|
+
if (!r) throw Error(`Browser module ${e} is not registered.`);
|
|
1178
|
+
V.has(e) || V.set(e, r().catch((t) => {
|
|
1179
|
+
throw V.delete(e), t;
|
|
1180
|
+
}));
|
|
1181
|
+
let i = await V.get(e);
|
|
1182
|
+
if (i.moduleId !== e) throw Error(`Module definition does not match ${e}.`);
|
|
1183
|
+
return t.register(i), i;
|
|
1184
|
+
}
|
|
1185
|
+
function Yt(e, t, n) {
|
|
1186
|
+
return [...new Set(e.targets.flatMap((e) => {
|
|
1187
|
+
if (e.type === "form") return [n || t];
|
|
1188
|
+
let r = e.type === "selector" ? e.selector : e.type === "field" ? `[data-formie-field-uid="${CSS.escape(e.uid)}"]` : e.type === "page" ? `[data-formie-page-id="${CSS.escape(e.id)}"]` : `[data-formie-action="${CSS.escape(e.action)}"]`;
|
|
1189
|
+
return [...t.matches(r) ? [t] : [], ...t.querySelectorAll(r)];
|
|
1190
|
+
}))].filter((e) => !e.closest("[hidden], [data-formie-hidden=\"true\"], [data-formie-conditionally-hidden], [data-formie-page-hidden]"));
|
|
1191
|
+
}
|
|
1192
|
+
async function Xt(e, t) {
|
|
1193
|
+
n(e);
|
|
1194
|
+
let r = e.surface;
|
|
1195
|
+
if (t.matchContext.surface !== r || t.setupContext.surface !== r) throw Error(`Browser module manifest surface ${r} cannot mount as ${t.matchContext.surface}.`);
|
|
1196
|
+
let { root: i, form: a } = t.setupContext, o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = [], u = !1, d = Promise.resolve(), f = !1, p = async (e, n) => {
|
|
1197
|
+
let i = {
|
|
1198
|
+
key: e.key,
|
|
1199
|
+
moduleId: e.moduleId,
|
|
1200
|
+
required: e.required,
|
|
1201
|
+
surface: r,
|
|
1202
|
+
code: "MODULE_UNAVAILABLE",
|
|
1203
|
+
message: "A form feature could not start. Reload the page or contact the site administrator."
|
|
1204
|
+
};
|
|
1205
|
+
s.set(e.key, i), c.set(e.key, Gt(n)), console.error("[formie] Browser module failure", i, n), await t.setupContext.emit("formie:browser:module:error", i);
|
|
1206
|
+
}, m = async (e) => {
|
|
1207
|
+
try {
|
|
1208
|
+
await e.destroy();
|
|
1209
|
+
} catch (n) {
|
|
1210
|
+
console.error("[formie] Browser module disposal failed", n), await t.setupContext.emit("formie:browser:module:error", {
|
|
1211
|
+
key: e.key,
|
|
1212
|
+
moduleId: e.moduleId,
|
|
1213
|
+
surface: r,
|
|
1214
|
+
code: "MODULE_DISPOSE_FAILED",
|
|
1215
|
+
message: "A form feature could not clean up. Reload the page before continuing."
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
}, h = () => [...s.values()].some((e) => e.required), g = () => {
|
|
1219
|
+
if (!a) return;
|
|
1220
|
+
let e = a.querySelector("[data-formie-module-error]");
|
|
1221
|
+
if (!e) {
|
|
1222
|
+
let t = document.createElement("p");
|
|
1223
|
+
t.textContent = r === "cp-edit" ? "Reload the page. If the problem continues, copy the technical details below." : "Reload the page or contact the site administrator.";
|
|
1224
|
+
let n = document.createElement("pre");
|
|
1225
|
+
if (n.dataset.formieModuleErrorDetails = "true", n.tabIndex = 0, r === "cp-edit") e = document.createElement("pk-alert"), e.className = "formie-module-error", e.setAttribute("variant", "error"), e.setAttribute("announce", "assertive"), e.setAttribute("heading", "A required form feature could not start."), e.setAttribute("details-label", "Details"), e.setAttribute("copy-label", "Copy details"), e.setAttribute("copied-label", "Details copied."), e.setAttribute("copyable", ""), n.slot = "details", e.append(t, n);
|
|
1226
|
+
else {
|
|
1227
|
+
e = document.createElement("div"), e.className = "formie-module-error formie-module-error--fallback";
|
|
1228
|
+
let r = document.createElement("div");
|
|
1229
|
+
r.className = "formie-module-error__notice", r.setAttribute("role", "alert");
|
|
1230
|
+
let i = document.createElement("span");
|
|
1231
|
+
i.className = "formie-module-error__indicator", i.setAttribute("aria-hidden", "true"), i.textContent = "!";
|
|
1232
|
+
let a = document.createElement("div");
|
|
1233
|
+
a.className = "formie-module-error__content";
|
|
1234
|
+
let o = document.createElement("strong");
|
|
1235
|
+
o.className = "formie-module-error__title", o.textContent = "A required form feature could not start.", a.append(o, t), r.append(i, a);
|
|
1236
|
+
let s = document.createElement("details");
|
|
1237
|
+
s.className = "formie-module-error__details";
|
|
1238
|
+
let c = document.createElement("summary");
|
|
1239
|
+
c.textContent = "Details";
|
|
1240
|
+
let l = document.createElement("div");
|
|
1241
|
+
l.className = "formie-module-error__actions";
|
|
1242
|
+
let u = document.createElement("button");
|
|
1243
|
+
u.className = "formie-module-error__copy", u.type = "button", u.textContent = "Copy details";
|
|
1244
|
+
let d = document.createElement("span");
|
|
1245
|
+
d.className = "formie-module-error__copy-status", d.setAttribute("role", "status"), d.setAttribute("aria-live", "polite"), u.addEventListener("click", async () => {
|
|
1246
|
+
try {
|
|
1247
|
+
await qt(n.textContent || ""), d.textContent = "Details copied.";
|
|
1248
|
+
} catch {
|
|
1249
|
+
d.textContent = "Copy failed. Select the details above and copy them manually.";
|
|
1250
|
+
let e = document.createRange();
|
|
1251
|
+
e.selectNodeContents(n), window.getSelection()?.removeAllRanges(), window.getSelection()?.addRange(e);
|
|
1252
|
+
}
|
|
1253
|
+
}), l.append(u, d), s.append(c, n, l), e.append(r, s);
|
|
1254
|
+
}
|
|
1255
|
+
e.dataset.formieModuleError = "true", i !== a && a.contains(i) ? i.before(e) : a.prepend(e);
|
|
1256
|
+
}
|
|
1257
|
+
let t = e.querySelector("[data-formie-module-error-details]"), n = Kt(r, s.values(), c);
|
|
1258
|
+
t && t.textContent !== n && (t.textContent = n);
|
|
1259
|
+
}, _ = (e) => {
|
|
1260
|
+
h() && (e.preventDefault(), e.stopImmediatePropagation(), g());
|
|
1261
|
+
}, v = async () => {
|
|
1262
|
+
let n = new Set(e.entries.map((e) => e.key));
|
|
1263
|
+
for (let e of s.keys()) n.has(e) || (s.delete(e), c.delete(e));
|
|
1264
|
+
let d = [];
|
|
1265
|
+
for (let [e, t] of o) n.has(e) || (d.push(...Array.from(t.values(), ({ instance: e }) => e)), o.delete(e), s.delete(e), c.delete(e));
|
|
1266
|
+
for (let e of d.reverse()) await m(e), l.splice(l.indexOf(e), 1);
|
|
1267
|
+
for (let n of e.entries) {
|
|
1268
|
+
if (u) continue;
|
|
1269
|
+
let e = s.get(n.key);
|
|
1270
|
+
e && s.set(n.key, {
|
|
1271
|
+
...e,
|
|
1272
|
+
required: n.required
|
|
1273
|
+
});
|
|
1274
|
+
let d;
|
|
1275
|
+
try {
|
|
1276
|
+
d = Yt(n, i, a);
|
|
1277
|
+
} catch (e) {
|
|
1278
|
+
s.has(n.key) || await p(n, e);
|
|
1279
|
+
continue;
|
|
1280
|
+
}
|
|
1281
|
+
let f = o.get(n.key) ?? /* @__PURE__ */ new Map();
|
|
1282
|
+
o.set(n.key, f);
|
|
1283
|
+
for (let [e, t] of Array.from(f.entries()).reverse()) d.includes(e) || (await m(t.instance), f.delete(e), l.splice(l.indexOf(t.instance), 1));
|
|
1284
|
+
let h;
|
|
1285
|
+
try {
|
|
1286
|
+
h = await Jt(n.moduleId, t.registry);
|
|
1287
|
+
} catch (e) {
|
|
1288
|
+
s.has(n.key) || await p(n, e);
|
|
1289
|
+
continue;
|
|
1290
|
+
}
|
|
1291
|
+
let g = !1, _ = !1;
|
|
1292
|
+
for (let e of d) {
|
|
1293
|
+
if (u) return;
|
|
1294
|
+
let a = JSON.stringify([
|
|
1295
|
+
n.moduleId,
|
|
1296
|
+
n.config,
|
|
1297
|
+
n.required
|
|
1298
|
+
]), o = f.get(e);
|
|
1299
|
+
if (o?.config === a) continue;
|
|
1300
|
+
let c = {
|
|
1301
|
+
...t.setupContext,
|
|
1302
|
+
target: e,
|
|
1303
|
+
entryKey: n.key,
|
|
1304
|
+
surface: r,
|
|
1305
|
+
scope: n.targets[0]?.type ?? "form",
|
|
1306
|
+
options: n.config
|
|
1307
|
+
};
|
|
1308
|
+
try {
|
|
1309
|
+
if (o) {
|
|
1310
|
+
if (o.instance.update && o.moduleId === n.moduleId && o.required === n.required) {
|
|
1311
|
+
await o.instance.update(c), o.config = a;
|
|
1312
|
+
continue;
|
|
1313
|
+
}
|
|
1314
|
+
await m(o.instance), f.delete(e), l.splice(l.indexOf(o.instance), 1);
|
|
1315
|
+
}
|
|
1316
|
+
if (h.surfaces && !h.surfaces.includes(r)) throw Error(`Module ${n.moduleId} does not support ${r}.`);
|
|
1317
|
+
if (h.kind !== n.kind) throw Error(`Module ${n.moduleId} is registered as ${h.kind}, not ${n.kind}.`);
|
|
1318
|
+
if (!h.match({
|
|
1319
|
+
...t.matchContext,
|
|
1320
|
+
target: e,
|
|
1321
|
+
scope: c.scope,
|
|
1322
|
+
manifestItem: n
|
|
1323
|
+
})) throw Error(`Module ${n.moduleId} does not support the rendered target.`);
|
|
1324
|
+
let s = await h.setup(c);
|
|
1325
|
+
if (!s) throw Error(`Module ${n.moduleId} did not initialize.`);
|
|
1326
|
+
if (u || !i.contains(e) && e !== i) {
|
|
1327
|
+
await m(s);
|
|
1328
|
+
continue;
|
|
1329
|
+
}
|
|
1330
|
+
s.key = n.key, s.moduleId = n.moduleId, s.kind = n.kind, s.target = e;
|
|
1331
|
+
let d = s.assertReady;
|
|
1332
|
+
s.assertReady = () => {
|
|
1333
|
+
try {
|
|
1334
|
+
d?.();
|
|
1335
|
+
} catch (e) {
|
|
1336
|
+
if (p(n, e), n.required) throw Error("A required form feature could not start.");
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
let g = s.beforeSubmit, v = s.afterSubmit;
|
|
1340
|
+
s.beforeSubmit = async (e) => {
|
|
1341
|
+
try {
|
|
1342
|
+
await g?.(e);
|
|
1343
|
+
} catch (t) {
|
|
1344
|
+
await p(n, t), n.required && e.abort("A required form feature could not complete. Reload the page or contact the site administrator.");
|
|
1345
|
+
}
|
|
1346
|
+
}, s.afterSubmit = async (e, t) => {
|
|
1347
|
+
try {
|
|
1348
|
+
await v?.(e, t);
|
|
1349
|
+
} catch (e) {
|
|
1350
|
+
await p(n, e);
|
|
1351
|
+
}
|
|
1352
|
+
}, f.set(e, {
|
|
1353
|
+
instance: s,
|
|
1354
|
+
config: a,
|
|
1355
|
+
moduleId: n.moduleId,
|
|
1356
|
+
required: n.required
|
|
1357
|
+
}), l.push(s), _ = !0, await t.setupContext.emit("formie:browser:module:mount", {
|
|
1358
|
+
key: n.key,
|
|
1359
|
+
moduleId: n.moduleId,
|
|
1360
|
+
target: e
|
|
1361
|
+
});
|
|
1362
|
+
} catch (e) {
|
|
1363
|
+
g = !0, s.has(n.key) || await p(n, e);
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
!g && (_ || d.length === 0) && (s.delete(n.key), c.delete(n.key));
|
|
1367
|
+
}
|
|
1368
|
+
h() ? g() : a?.querySelector("[data-formie-module-error]")?.remove();
|
|
1369
|
+
}, y = new MutationObserver(() => {
|
|
1370
|
+
f || u || (f = !0, d = d.then(async () => {
|
|
1371
|
+
f = !1, u || await v();
|
|
1372
|
+
}), d.catch((e) => console.error("[formie] Module reconciliation failed", e)));
|
|
1373
|
+
});
|
|
1374
|
+
return a?.addEventListener("submit", _, !0), await v(), y.observe(i, {
|
|
1375
|
+
childList: !0,
|
|
1376
|
+
subtree: !0,
|
|
1377
|
+
attributes: !0,
|
|
1378
|
+
attributeFilter: [
|
|
1379
|
+
"hidden",
|
|
1380
|
+
"data-formie-hidden",
|
|
1381
|
+
"data-formie-conditionally-hidden",
|
|
1382
|
+
"data-formie-page-hidden",
|
|
1383
|
+
"data-formie-field-uid",
|
|
1384
|
+
"data-formie-page-id",
|
|
1385
|
+
"data-formie-action"
|
|
1386
|
+
]
|
|
1387
|
+
}), {
|
|
1388
|
+
get instances() {
|
|
1389
|
+
return l;
|
|
1390
|
+
},
|
|
1391
|
+
get failures() {
|
|
1392
|
+
return [...s.values()];
|
|
1393
|
+
},
|
|
1394
|
+
assertReady: () => {
|
|
1395
|
+
if (h()) throw Error("A required form feature could not start. Reload the page or contact the site administrator.");
|
|
1396
|
+
},
|
|
1397
|
+
destroy: async () => {
|
|
1398
|
+
u = !0, y.disconnect(), a?.removeEventListener("submit", _, !0), await d;
|
|
1399
|
+
for (let e of Array.from(o.values()).reverse()) for (let { instance: t } of Array.from(e.values()).reverse()) await m(t);
|
|
1400
|
+
o.clear(), l.splice(0), s.clear(), c.clear(), a?.querySelector("[data-formie-module-error]")?.remove();
|
|
1401
|
+
},
|
|
1402
|
+
updateManifest: async (t) => {
|
|
1403
|
+
if (n(t), t.surface !== r) throw Error("A mounted browser module runtime cannot change surfaces.");
|
|
1404
|
+
e = t, d = d.then(v), await d;
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
//#endregion
|
|
1409
|
+
//#region src/js/utils/form-started-at.ts
|
|
1410
|
+
var Zt = "formie:formStartedAt:";
|
|
1411
|
+
function Qt(e) {
|
|
1412
|
+
let t = e.querySelector("input[name=\"formStartedAt\"]");
|
|
1413
|
+
if (!t) return;
|
|
1414
|
+
let n = e.querySelector("input[name=\"renderId\"]")?.value?.trim() ?? "", r = n ? `${Zt}${n}` : null, i = r ? sessionStorage.getItem(r) : null;
|
|
1415
|
+
i || (i = String(Date.now()), r && sessionStorage.setItem(r, i)), t.value = i;
|
|
1416
|
+
}
|
|
1417
|
+
//#endregion
|
|
1418
|
+
//#region src/js/utils/unload-warning.ts
|
|
1419
|
+
var $t = /* @__PURE__ */ new Set([
|
|
1420
|
+
"action",
|
|
1421
|
+
"redirect",
|
|
1422
|
+
"requestToken",
|
|
1423
|
+
"uploadCreateToken",
|
|
1424
|
+
"renderId",
|
|
1425
|
+
"formStartedAt",
|
|
1426
|
+
"submitAction",
|
|
1427
|
+
"pageId",
|
|
1428
|
+
"draftContextToken",
|
|
1429
|
+
"draftContext",
|
|
1430
|
+
"progressId"
|
|
1431
|
+
]);
|
|
1432
|
+
function H(e, t) {
|
|
1433
|
+
if (e == null) return String(e);
|
|
1434
|
+
if (typeof e == "string") return JSON.stringify(e);
|
|
1435
|
+
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1436
|
+
if (typeof e == "function") return "[function]";
|
|
1437
|
+
if (typeof File < "u" && e instanceof File) return `[file:${e.name}:${e.size}:${e.type}]`;
|
|
1438
|
+
if (typeof Blob < "u" && e instanceof Blob) return `[blob:${e.size}:${e.type}]`;
|
|
1439
|
+
if (Array.isArray(e)) return `[${e.map((e) => H(e, t)).join(",")}]`;
|
|
1440
|
+
if (typeof e == "object") {
|
|
1441
|
+
if (t.has(e)) return "[circular]";
|
|
1442
|
+
t.add(e);
|
|
1443
|
+
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${H(n, t)}`);
|
|
1444
|
+
return t.delete(e), `{${n.join(",")}}`;
|
|
1445
|
+
}
|
|
1446
|
+
return JSON.stringify(String(e));
|
|
1447
|
+
}
|
|
1448
|
+
function en(e) {
|
|
1449
|
+
return H(e, /* @__PURE__ */ new WeakSet());
|
|
1450
|
+
}
|
|
1451
|
+
function tn(e, t) {
|
|
1452
|
+
if (!e) return !1;
|
|
1453
|
+
let n = e.endsWith("[]") ? e.slice(0, -2) : e;
|
|
1454
|
+
return !O(n, t) && !$t.has(n);
|
|
1455
|
+
}
|
|
1456
|
+
function nn(e) {
|
|
1457
|
+
return en(Array.from(new FormData(e).entries()).filter(([t]) => tn(String(t || ""), e)));
|
|
1458
|
+
}
|
|
1459
|
+
function rn(e, t = {}) {
|
|
1460
|
+
let n = null, r = !1, i = !1, a = null, o = null, s = null, c = () => {
|
|
1461
|
+
a !== null && (window.cancelAnimationFrame(a), a = null), o !== null && (window.clearTimeout(o), o = null), s !== null && (window.clearTimeout(s), s = null);
|
|
1462
|
+
}, l = () => r ? (i = nn(e) !== n, i) : !1, u = () => {
|
|
1463
|
+
n = nn(e), r = !0, i = !1;
|
|
1464
|
+
}, d = () => {
|
|
1465
|
+
c(), r = !1, a = window.requestAnimationFrame(() => {
|
|
1466
|
+
a = null, s = window.setTimeout(() => {
|
|
1467
|
+
s = null, u();
|
|
1468
|
+
}, 0);
|
|
1469
|
+
});
|
|
1470
|
+
}, f = () => {
|
|
1471
|
+
o !== null && window.clearTimeout(o), o = window.setTimeout(() => {
|
|
1472
|
+
o = null, l();
|
|
1473
|
+
}, 120);
|
|
1474
|
+
}, p = (e) => {
|
|
1475
|
+
(!t.shouldWarn || t.shouldWarn()) && l() && (e.preventDefault(), e.returnValue = "");
|
|
1476
|
+
};
|
|
1477
|
+
return e.addEventListener("input", f), e.addEventListener("change", f), window.addEventListener("beforeunload", p), d(), {
|
|
1478
|
+
captureBaseline: u,
|
|
1479
|
+
scheduleBaselineCapture: d,
|
|
1480
|
+
refreshDirtyState: l,
|
|
1481
|
+
destroy: () => {
|
|
1482
|
+
c(), e.removeEventListener("input", f), e.removeEventListener("change", f), window.removeEventListener("beforeunload", p);
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
//#endregion
|
|
1487
|
+
//#region src/js/validation/rules/email.ts
|
|
1488
|
+
var an = {
|
|
1489
|
+
rule: ({ input: e, getRule: n }) => {
|
|
1490
|
+
let r = n("email");
|
|
1491
|
+
return !r || t(e.value, {
|
|
1492
|
+
...typeof r == "object" ? r : {},
|
|
1493
|
+
type: "email"
|
|
1494
|
+
}) === null;
|
|
1495
|
+
},
|
|
1496
|
+
message: ({ input: e, label: t, t: n }) => e.getAttribute("data-formie-validation-email-message") ?? e.getAttribute("data-formie-pattern-email-message") ?? e.getAttribute("data-pattern-email-message") ?? n("{label} is not a valid email address.", { label: t })
|
|
1497
|
+
};
|
|
1498
|
+
//#endregion
|
|
1499
|
+
//#region src/js/validation/rules/shared.ts
|
|
1500
|
+
function on(e) {
|
|
1501
|
+
return e?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() || "";
|
|
1502
|
+
}
|
|
1503
|
+
function sn(e) {
|
|
1504
|
+
let t = e.getRule("match");
|
|
1505
|
+
if (!t || t === !0 || typeof t != "object" || !e.field) return null;
|
|
1506
|
+
let n = typeof t.fieldHandle == "string" ? t.fieldHandle.trim() : "";
|
|
1507
|
+
if (!n) return null;
|
|
1508
|
+
let r = e.form.querySelector(`[data-formie-field-handle="${n}"]`);
|
|
1509
|
+
return r ? Array.from(r.querySelectorAll(e.config.fieldsSelector)).find((e) => (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement) && !P(e)) ?? null : null;
|
|
1510
|
+
}
|
|
1511
|
+
//#endregion
|
|
1512
|
+
//#region src/js/validation/rules.ts
|
|
1513
|
+
var cn = {
|
|
1514
|
+
required: {
|
|
1515
|
+
rule: ({ input: e, getRule: n }) => {
|
|
1516
|
+
if (!n("required") || e.type === "hidden") return !0;
|
|
1517
|
+
if (e.type === "checkbox" || e.type === "radio") {
|
|
1518
|
+
let t = e.form?.querySelectorAll(`[name="${e.name}"]:not([type="hidden"]):not([disabled])`) || [];
|
|
1519
|
+
return t.length ? Array.from(t).some((e) => e instanceof HTMLInputElement && e.checked) : e instanceof HTMLInputElement ? e.checked : !0;
|
|
1520
|
+
}
|
|
1521
|
+
return t(e.value, { type: "required" }) === null;
|
|
1522
|
+
},
|
|
1523
|
+
message: ({ input: e, label: t, t: n }) => e.getAttribute("data-formie-required-message") ?? e.getAttribute("data-required-message") ?? n("{label} cannot be blank.", { label: t })
|
|
1524
|
+
},
|
|
1525
|
+
email: an,
|
|
1526
|
+
url: {
|
|
1527
|
+
rule: ({ input: e, getRule: n }) => {
|
|
1528
|
+
let r = n("url");
|
|
1529
|
+
return !r || t(e.value, {
|
|
1530
|
+
...typeof r == "object" ? r : {},
|
|
1531
|
+
type: "url"
|
|
1532
|
+
}) === null;
|
|
1533
|
+
},
|
|
1534
|
+
message: ({ input: e, label: t, t: n }) => e.getAttribute("data-formie-pattern-url-message") ?? e.getAttribute("data-pattern-url-message") ?? n("{label} is not a valid URL.", { label: t })
|
|
1535
|
+
},
|
|
1536
|
+
number: {
|
|
1537
|
+
rule: ({ input: e, getRule: n }) => {
|
|
1538
|
+
let r = n("number");
|
|
1539
|
+
return !r || t(e.value, {
|
|
1540
|
+
...typeof r == "object" ? r : {},
|
|
1541
|
+
type: "number"
|
|
1542
|
+
}) === null;
|
|
1543
|
+
},
|
|
1544
|
+
message: ({ input: e, label: n, getRule: r, t: i }) => {
|
|
1545
|
+
let a = r("number");
|
|
1546
|
+
return t(e.value, {
|
|
1547
|
+
...typeof a == "object" ? a : {},
|
|
1548
|
+
type: "number"
|
|
1549
|
+
}, { label: n }) ?? i("{label} is not a valid number.", { label: n });
|
|
1550
|
+
}
|
|
1551
|
+
},
|
|
1552
|
+
match: {
|
|
1553
|
+
rule: (e) => {
|
|
1554
|
+
let n = sn(e);
|
|
1555
|
+
return !n || t(e.input.value, { type: "match" }, { comparison: n.value }) === null;
|
|
1556
|
+
},
|
|
1557
|
+
message: (e) => {
|
|
1558
|
+
let t = sn(e)?.closest("[data-formie-field-handle]"), n = on(t);
|
|
1559
|
+
return e.input.getAttribute("data-formie-validation-match-message") ?? e.t("{label} must match {value}.", {
|
|
1560
|
+
label: e.label,
|
|
1561
|
+
value: n
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
}, ln = {
|
|
1566
|
+
email: /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*(\.\w{2,})+$/,
|
|
1567
|
+
url: /^(?:(?:https?|HTTPS?|ftp|FTP):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)(?:\.(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)*(?:\.(?:[a-zA-Z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/,
|
|
1568
|
+
number: /^(?:[-+]?[0-9]*[.,]?[0-9]+)$/,
|
|
1569
|
+
color: /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,
|
|
1570
|
+
date: /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))/,
|
|
1571
|
+
time: /^(?:(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]))$/,
|
|
1572
|
+
month: /^(?:(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])))$/
|
|
1573
|
+
}, U = T("general", "validator");
|
|
1574
|
+
function W(e) {
|
|
1575
|
+
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement);
|
|
1576
|
+
}
|
|
1577
|
+
function un(e) {
|
|
1578
|
+
return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
1579
|
+
}
|
|
1580
|
+
var dn = class {
|
|
1581
|
+
form;
|
|
1582
|
+
errors = [];
|
|
1583
|
+
validators = {};
|
|
1584
|
+
boundListeners = !1;
|
|
1585
|
+
activated = /* @__PURE__ */ new WeakSet();
|
|
1586
|
+
submitted = !1;
|
|
1587
|
+
initialValues = /* @__PURE__ */ new WeakMap();
|
|
1588
|
+
onBlur;
|
|
1589
|
+
onChange;
|
|
1590
|
+
onInput;
|
|
1591
|
+
config;
|
|
1592
|
+
constructor(e, t = {}) {
|
|
1593
|
+
this.form = e, this.onBlur = this.blurHandler.bind(this), this.onChange = this.changeHandler.bind(this), this.onInput = this.inputHandler.bind(this), this.config = {
|
|
1594
|
+
live: !1,
|
|
1595
|
+
errorAriaLive: "polite",
|
|
1596
|
+
errorMessage: "",
|
|
1597
|
+
fieldContainerErrorClass: [],
|
|
1598
|
+
inputErrorClass: [],
|
|
1599
|
+
messagesClass: [],
|
|
1600
|
+
messageClass: [],
|
|
1601
|
+
fieldsSelector: "input:not([type=\"hidden\"]):not([type=\"submit\"]):not([type=\"button\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])",
|
|
1602
|
+
patterns: ln,
|
|
1603
|
+
...t
|
|
1604
|
+
}, Object.entries(cn).forEach(([e, t]) => {
|
|
1605
|
+
this.addValidator(e, t.rule, t.message);
|
|
1606
|
+
}), this.init();
|
|
1607
|
+
}
|
|
1608
|
+
init() {
|
|
1609
|
+
U.log("Initializing validator.", {
|
|
1610
|
+
formId: this.form.id || null,
|
|
1611
|
+
live: this.config.live
|
|
1612
|
+
}), this.form.setAttribute("novalidate", "true"), this.inputs().forEach((e) => {
|
|
1613
|
+
this.initialValues.set(e, this.getInputValue(e));
|
|
1614
|
+
}), this.config.live && this.addEventListeners(), this.emitEvent(document, o("ready"), { validator: this });
|
|
1615
|
+
}
|
|
1616
|
+
inputs(e = null) {
|
|
1617
|
+
if (W(e)) return P(e) ? [] : [e];
|
|
1618
|
+
let t = e || this.form;
|
|
1619
|
+
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) => W(e) && !P(e));
|
|
1620
|
+
}
|
|
1621
|
+
getInputValue(e) {
|
|
1622
|
+
return e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ? e.checked : e instanceof HTMLInputElement && e.type === "file" ? e.files?.length ? Array.from(e.files).map((e) => e.name).join("|") : "" : e.value ?? "";
|
|
1623
|
+
}
|
|
1624
|
+
isDirty(e) {
|
|
1625
|
+
return this.initialValues.has(e) ? this.getInputValue(e) !== this.initialValues.get(e) : (this.initialValues.set(e, this.getInputValue(e)), !1);
|
|
1626
|
+
}
|
|
1627
|
+
shouldShowError(e) {
|
|
1628
|
+
return this.submitted || this.activated.has(e);
|
|
1629
|
+
}
|
|
1630
|
+
isValid(e = null, t = {}) {
|
|
1631
|
+
return this.validate(e, t).length === 0;
|
|
956
1632
|
}
|
|
957
1633
|
validate(e = null, t = {}) {
|
|
958
1634
|
this.errors = [];
|
|
@@ -980,7 +1656,7 @@ var mt = class {
|
|
|
980
1656
|
}), r = !0;
|
|
981
1657
|
}
|
|
982
1658
|
}), !r && this.shouldShowError(e) && this.removeError(e);
|
|
983
|
-
}),
|
|
1659
|
+
}), U.log("Validation pass complete.", {
|
|
984
1660
|
errorCount: this.errors.length,
|
|
985
1661
|
includeHiddenPages: t.includeHiddenPages === !0
|
|
986
1662
|
}), this.errors;
|
|
@@ -996,685 +1672,155 @@ var mt = class {
|
|
|
996
1672
|
e.removeAttribute("aria-invalid");
|
|
997
1673
|
return;
|
|
998
1674
|
}
|
|
999
|
-
let
|
|
1675
|
+
let n = t.querySelector("[data-formie-field-errors]"), r = Array.from(t.querySelectorAll("[data-formie-field-error]")).map((e) => e.id).filter(Boolean);
|
|
1000
1676
|
t.querySelectorAll("[data-formie-field-error]").forEach((e) => {
|
|
1001
1677
|
e.remove();
|
|
1002
|
-
}),
|
|
1003
|
-
let
|
|
1004
|
-
|
|
1005
|
-
let t = e.id;
|
|
1006
|
-
t && pt(n, t);
|
|
1007
|
-
});
|
|
1678
|
+
}), n && (n.innerHTML = ""), t.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
1679
|
+
let t = e;
|
|
1680
|
+
t.removeAttribute("aria-invalid"), this.config.inputErrorClass.length && t.classList.remove(...this.config.inputErrorClass), t.removeAttribute("data-formie-input-has-error"), Fe(t, r);
|
|
1008
1681
|
});
|
|
1009
1682
|
for (let e = t; e; e = e.parentElement?.closest("[data-formie-field-handle]")) this.config.fieldContainerErrorClass.length && e.classList.remove(...this.config.fieldContainerErrorClass), e.removeAttribute("data-formie-field-has-error");
|
|
1010
|
-
this.emitEvent(e,
|
|
1683
|
+
this.emitEvent(e, o("clear-error"), { validator: this }), C(this.form);
|
|
1011
1684
|
}
|
|
1012
|
-
showError(e, t,
|
|
1013
|
-
let
|
|
1014
|
-
if (!
|
|
1015
|
-
let
|
|
1016
|
-
|
|
1685
|
+
showError(e, t, n) {
|
|
1686
|
+
let r = e.closest("[data-formie-field-handle]");
|
|
1687
|
+
if (!r) return;
|
|
1688
|
+
let i = r.querySelector("[data-formie-field-errors]");
|
|
1689
|
+
i ||= lt(r, (e) => {
|
|
1017
1690
|
this.config.messagesClass.length && e.classList.add(...this.config.messagesClass);
|
|
1018
|
-
}), this.config.messagesClass.length &&
|
|
1019
|
-
let
|
|
1020
|
-
|
|
1691
|
+
}), this.config.messagesClass.length && i.classList.add(...this.config.messagesClass), i.innerHTML = "";
|
|
1692
|
+
let a = r.getAttribute("data-formie-field-handle") || "field", s = `${a}-error`;
|
|
1693
|
+
i.id = i.id || `${a}-errors`, N(i, Ae(this.config.errorAriaLive, this.submitted));
|
|
1021
1694
|
let c = document.createElement("div");
|
|
1022
|
-
c.setAttribute("data-formie-field-error", "true"), c.setAttribute(`data-formie-field-error-${t}`, "true"), c.setAttribute("id", s),
|
|
1695
|
+
c.setAttribute("data-formie-field-error", "true"), c.setAttribute(`data-formie-field-error-${t}`, "true"), c.setAttribute("id", s), this.config.messageClass.length && c.classList.add(...this.config.messageClass), c.textContent = n, i.appendChild(c), r.setAttribute("data-formie-field-has-error", "true"), r.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
1023
1696
|
let t = e;
|
|
1024
|
-
t.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && t.classList.add(...this.config.inputErrorClass), t.setAttribute("data-formie-input-has-error", "true"),
|
|
1697
|
+
P(t) || (t.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && t.classList.add(...this.config.inputErrorClass), t.setAttribute("data-formie-input-has-error", "true"), Pe(t, s));
|
|
1025
1698
|
});
|
|
1026
|
-
for (let e =
|
|
1027
|
-
this.emitEvent(e,
|
|
1699
|
+
for (let e = r; e; e = e.parentElement?.closest("[data-formie-field-handle]")) this.config.fieldContainerErrorClass.length && e.classList.add(...this.config.fieldContainerErrorClass), e.setAttribute("data-formie-field-has-error", "true");
|
|
1700
|
+
this.emitEvent(e, o("show-error"), {
|
|
1028
1701
|
validator: this,
|
|
1029
1702
|
validatorName: t,
|
|
1030
|
-
errorMessage:
|
|
1031
|
-
}),
|
|
1703
|
+
errorMessage: n
|
|
1704
|
+
}), C(this.form);
|
|
1032
1705
|
}
|
|
1033
1706
|
getValidatorCallbackOptions(e) {
|
|
1034
1707
|
let t = e.closest("[data-formie-field-handle]"), n = t?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() ?? "", r = this.parseValidationRules(t?.getAttribute("data-formie-validation"));
|
|
1035
1708
|
return {
|
|
1036
|
-
t:
|
|
1037
|
-
input: e,
|
|
1038
|
-
label: n,
|
|
1039
|
-
field: t,
|
|
1040
|
-
form: this.form,
|
|
1041
|
-
config: this.config,
|
|
1042
|
-
rules: r,
|
|
1043
|
-
getRule: (e) => this.getRule(t, e)
|
|
1044
|
-
};
|
|
1045
|
-
}
|
|
1046
|
-
getErrorMessage(e, t, n, r) {
|
|
1047
|
-
return (typeof n.errorMessage == "function" ? n.errorMessage(r) : n.errorMessage) ?? D("{label} is invalid.", { label: r.label });
|
|
1048
|
-
}
|
|
1049
|
-
getErrors() {
|
|
1050
|
-
return this.errors;
|
|
1051
|
-
}
|
|
1052
|
-
getFieldErrors(e = this.errors) {
|
|
1053
|
-
let t = {};
|
|
1054
|
-
return e.forEach((e) => {
|
|
1055
|
-
!e.handle || t[e.handle]?.length || (t[e.handle] = [e.message]);
|
|
1056
|
-
}), t;
|
|
1057
|
-
}
|
|
1058
|
-
getRule(e, t) {
|
|
1059
|
-
if (!e) return !1;
|
|
1060
|
-
let n = this.parseValidationRules(e.getAttribute("data-formie-validation"));
|
|
1061
|
-
return Object.prototype.hasOwnProperty.call(n, t) ? n[t] : !1;
|
|
1062
|
-
}
|
|
1063
|
-
parseValidationRules(e) {
|
|
1064
|
-
let t = {};
|
|
1065
|
-
if (!e) return t;
|
|
1066
|
-
let n = null;
|
|
1067
|
-
try {
|
|
1068
|
-
n = JSON.parse(e);
|
|
1069
|
-
} catch {
|
|
1070
|
-
return N.warn("Invalid validation rules payload.", { formId: this.form.id || null }), t;
|
|
1071
|
-
}
|
|
1072
|
-
return Array.isArray(n) && n.forEach((e) => {
|
|
1073
|
-
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
1074
|
-
let n = e, r = typeof n.type == "string" ? n.type.trim() : "";
|
|
1075
|
-
r && (t[r] = n);
|
|
1076
|
-
}), t;
|
|
1077
|
-
}
|
|
1078
|
-
destroy() {
|
|
1079
|
-
N.log("Destroying validator.", { formId: this.form.id || null }), this.removeEventListeners(), this.form.removeAttribute("novalidate"), this.emitEvent(document, n("destroy"), { validator: this });
|
|
1080
|
-
}
|
|
1081
|
-
isVisible(e, t = {}) {
|
|
1082
|
-
return e.disabled || e.hasAttribute("data-formie-conditions-disabled") || e.closest("[data-formie-conditions-disabled]") || e.closest("[data-formie-conditionally-hidden]") ? !1 : e.closest("[data-formie-page-hidden]") ? !!t.includeHiddenPages : !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
1083
|
-
}
|
|
1084
|
-
blurHandler(e) {
|
|
1085
|
-
!(e.target instanceof HTMLElement) || !P(e.target) || !e.target.form?.isSameNode(this.form) || e instanceof CustomEvent || e.target instanceof HTMLInputElement && e.target.type === "file" || e.target instanceof HTMLInputElement && (e.target.type === "checkbox" || e.target.type === "radio") || (this.isDirty(e.target) && this.activated.add(e.target), this.shouldShowError(e.target) && this.validate(e.target));
|
|
1086
|
-
}
|
|
1087
|
-
changeHandler(e) {
|
|
1088
|
-
if (!(!(e.target instanceof HTMLElement) || !P(e.target) || !e.target.form?.isSameNode(this.form)) && !(e instanceof CustomEvent)) {
|
|
1089
|
-
if (e.target instanceof HTMLSelectElement) {
|
|
1090
|
-
this.activated.add(e.target), this.validate(e.target);
|
|
1091
|
-
return;
|
|
1092
|
-
}
|
|
1093
|
-
e.target instanceof HTMLInputElement && (e.target.type !== "file" && e.target.type !== "checkbox" && e.target.type !== "radio" || (this.activated.add(e.target), this.validate(e.target)));
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
inputHandler(e) {
|
|
1097
|
-
!(e.target instanceof HTMLElement) || !P(e.target) || !e.target.form?.isSameNode(this.form) || e instanceof CustomEvent || e.target instanceof HTMLInputElement && (e.target.type === "checkbox" || e.target.type === "radio") || this.shouldShowError(e.target) && this.validate(e.target);
|
|
1098
|
-
}
|
|
1099
|
-
submit(e = null, { final: t = !1 } = {}) {
|
|
1100
|
-
return this.submitted = !0, N.log("Submit validation requested.", { final: t }), this.boundListeners || this.addEventListeners(), this.removeAllErrors(), this.validate(e, { includeHiddenPages: t });
|
|
1101
|
-
}
|
|
1102
|
-
resetLiveState() {
|
|
1103
|
-
this.submitted = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.errors = [], this.removeAllErrors();
|
|
1104
|
-
}
|
|
1105
|
-
addEventListeners() {
|
|
1106
|
-
this.boundListeners || (this.form.addEventListener("blur", this.onBlur, !0), this.form.addEventListener("change", this.onChange, !1), this.form.addEventListener("input", this.onInput, !1), this.boundListeners = !0, N.log("Event listeners attached."));
|
|
1107
|
-
}
|
|
1108
|
-
removeEventListeners() {
|
|
1109
|
-
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1, N.log("Event listeners removed.");
|
|
1110
|
-
}
|
|
1111
|
-
emitEvent(e, t, n = {}) {
|
|
1112
|
-
e.dispatchEvent(new CustomEvent(t, {
|
|
1113
|
-
bubbles: !0,
|
|
1114
|
-
detail: n
|
|
1115
|
-
}));
|
|
1116
|
-
}
|
|
1117
|
-
addValidator(e, t, n) {
|
|
1118
|
-
this.validators[e] = {
|
|
1119
|
-
validate: t,
|
|
1120
|
-
errorMessage: n
|
|
1121
|
-
};
|
|
1122
|
-
}
|
|
1123
|
-
removeValidator(e) {
|
|
1124
|
-
delete this.validators[e];
|
|
1125
|
-
}
|
|
1126
|
-
}, F = /* @__PURE__ */ new WeakMap();
|
|
1127
|
-
function ht(e) {
|
|
1128
|
-
return (e.dataset.formieSubmitAction || "").trim();
|
|
1129
|
-
}
|
|
1130
|
-
function gt(e) {
|
|
1131
|
-
return (e.dataset.formieErrorMessagePosition || "top-form").trim() || "top-form";
|
|
1132
|
-
}
|
|
1133
|
-
function _t(e) {
|
|
1134
|
-
return (e.dataset.formieSubmitActionMessagePosition || "").trim();
|
|
1135
|
-
}
|
|
1136
|
-
function vt(e) {
|
|
1137
|
-
let t = (e.dataset.formieSubmitActionMessageTimeout || "").trim();
|
|
1138
|
-
if (!t) return null;
|
|
1139
|
-
let n = Number.parseFloat(t);
|
|
1140
|
-
return !Number.isFinite(n) || n < 0 ? null : Math.round(n * 1e3);
|
|
1141
|
-
}
|
|
1142
|
-
function yt(e) {
|
|
1143
|
-
let t = e.dataset.formieSubmitActionFormHide;
|
|
1144
|
-
if (t === void 0) return !1;
|
|
1145
|
-
let n = t.trim().toLowerCase();
|
|
1146
|
-
return n === "true" || n === "1" || n === "";
|
|
1147
|
-
}
|
|
1148
|
-
function bt(e) {
|
|
1149
|
-
let t = F.get(e);
|
|
1150
|
-
typeof t == "number" && (window.clearTimeout(t), F.delete(e));
|
|
1151
|
-
}
|
|
1152
|
-
function xt(e) {
|
|
1153
|
-
return e.querySelector("[data-formie-form-messages-top]") || e;
|
|
1154
|
-
}
|
|
1155
|
-
function St(e) {
|
|
1156
|
-
return e.querySelector("[data-formie-form-messages-bottom]") || e;
|
|
1157
|
-
}
|
|
1158
|
-
function Ct(e, t) {
|
|
1159
|
-
return t === "bottom-form" ? St(e) : xt(e);
|
|
1160
|
-
}
|
|
1161
|
-
function wt(e, t) {
|
|
1162
|
-
return t === "top-form" ? xt(e) : t === "bottom-form" && !yt(e) ? St(e) : e;
|
|
1163
|
-
}
|
|
1164
|
-
function Tt(e) {
|
|
1165
|
-
let t = gt(e), n = Ct(e, t), r = n.querySelector("[data-formie-error-container], [data-formie-errors]");
|
|
1166
|
-
return r || (r = document.createElement("div"), r.setAttribute("data-formie-errors", "true"), w(r, e, "errors")), r.setAttribute("data-formie-error-container", "true"), t === "bottom-form" ? n.append(r) : n.prepend(r), r;
|
|
1167
|
-
}
|
|
1168
|
-
function Et(e, t) {
|
|
1169
|
-
let n = t.querySelector("[data-formie-error-message-container], [data-formie-message][data-formie-message-error]");
|
|
1170
|
-
return n || (n = document.createElement("div"), n.setAttribute("data-formie-error-message-container", "true"), t.appendChild(n)), n.setAttribute("data-formie-message", "true"), n.setAttribute("data-formie-message-error", "true"), w(n, e, "message", "messageError"), n.setAttribute("role", "alert"), Oe(n, De(Te(e))), n;
|
|
1171
|
-
}
|
|
1172
|
-
function Dt(e, t) {
|
|
1173
|
-
let n = e.querySelector("[data-formie-success-container]"), r = wt(e, t);
|
|
1174
|
-
return n || (n = document.createElement("div"), n.setAttribute("data-formie-success-container", "true"), w(n, e, "successes")), t === "bottom-form" ? r.append(n) : r.prepend(n), n;
|
|
1175
|
-
}
|
|
1176
|
-
function Ot(e) {
|
|
1177
|
-
return it(e, (t) => {
|
|
1178
|
-
w(t, e, "fieldErrors");
|
|
1179
|
-
});
|
|
1180
|
-
}
|
|
1181
|
-
function kt(e, t) {
|
|
1182
|
-
let n = (e.getAttribute("aria-describedby") || "").trim();
|
|
1183
|
-
if (!n) return;
|
|
1184
|
-
let r = n.split(/\s+/).filter((e) => e !== t).join(" ").trim();
|
|
1185
|
-
if (r) {
|
|
1186
|
-
e.setAttribute("aria-describedby", r);
|
|
1187
|
-
return;
|
|
1188
|
-
}
|
|
1189
|
-
e.removeAttribute("aria-describedby");
|
|
1190
|
-
}
|
|
1191
|
-
function At(e, t) {
|
|
1192
|
-
e.setAttribute("aria-errormessage", t);
|
|
1193
|
-
}
|
|
1194
|
-
function jt(e, t) {
|
|
1195
|
-
e.getAttribute("aria-errormessage") === t && e.removeAttribute("aria-errormessage");
|
|
1196
|
-
}
|
|
1197
|
-
function Mt(e) {
|
|
1198
|
-
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
1199
|
-
let n = t, r = n.querySelector("[data-formie-field-errors]"), i = r?.id || "", a = Array.from(n.querySelectorAll("[data-formie-field-error]")).map((e) => e.id).filter(Boolean);
|
|
1200
|
-
C(n, e, "fieldLayoutError"), n.removeAttribute("data-formie-field-has-error"), n.querySelectorAll("[data-formie-field-error]").forEach((e) => {
|
|
1201
|
-
e.remove();
|
|
1202
|
-
}), r && !r.querySelector("[data-formie-field-error]") && (r.innerHTML = ""), n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
1203
|
-
let n = t;
|
|
1204
|
-
n.removeAttribute("aria-invalid"), C(n, e, "fieldControlError"), n.removeAttribute("data-formie-input-has-error"), i && kt(n, i), a.forEach((e) => {
|
|
1205
|
-
jt(n, e);
|
|
1206
|
-
});
|
|
1207
|
-
});
|
|
1208
|
-
}), y(e);
|
|
1209
|
-
}
|
|
1210
|
-
function Nt(e) {
|
|
1211
|
-
e.querySelectorAll("[data-formie-error-container], [data-formie-errors]").forEach((t) => {
|
|
1212
|
-
let n = t;
|
|
1213
|
-
n.querySelectorAll("[data-formie-error]").forEach((e) => {
|
|
1214
|
-
e.remove();
|
|
1215
|
-
}), C(n, e, "message", "messageError"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-error"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-error]") || (n.innerHTML = "");
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
function Pt(e) {
|
|
1219
|
-
bt(e), e.querySelectorAll("[data-formie-message-success]:not([data-formie-success-container])").forEach((e) => {
|
|
1220
|
-
e.remove();
|
|
1221
|
-
}), e.querySelectorAll("[data-formie-success-container]").forEach((t) => {
|
|
1222
|
-
let n = t;
|
|
1223
|
-
n.querySelectorAll("[data-formie-success]").forEach((e) => {
|
|
1224
|
-
e.remove();
|
|
1225
|
-
}), C(n, e, "message", "messageSuccess"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-success"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-success]") || (n.innerHTML = "");
|
|
1226
|
-
}), ht(e) === "message" && yt(e) || s(e, !1);
|
|
1227
|
-
}
|
|
1228
|
-
function Ft(e) {
|
|
1229
|
-
e.querySelectorAll("[aria-invalid=\"true\"]").forEach((e) => {
|
|
1230
|
-
e.removeAttribute("aria-invalid");
|
|
1231
|
-
});
|
|
1232
|
-
}
|
|
1233
|
-
function It(e, t) {
|
|
1234
|
-
let n = (e.getAttribute("aria-describedby") || "").trim(), r = n ? n.split(/\s+/) : [];
|
|
1235
|
-
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
1236
|
-
}
|
|
1237
|
-
function Lt(e, t) {
|
|
1238
|
-
let n = De(Te(e));
|
|
1239
|
-
Object.entries(t).forEach(([t, r]) => {
|
|
1240
|
-
let i = e.querySelector(`[data-formie-field-handle="${t}"]`);
|
|
1241
|
-
if (!i) return;
|
|
1242
|
-
let a = Ot(i), o = a.id && a.id.trim() ? a.id : `${t}-errors`;
|
|
1243
|
-
a.id = o, Oe(a, n), w(i, e, "fieldLayoutError"), i.setAttribute("data-formie-field-has-error", "true"), r.forEach((t, n) => {
|
|
1244
|
-
let r = document.createElement("div");
|
|
1245
|
-
r.setAttribute("data-formie-field-error", "true"), r.setAttribute("role", "alert"), r.id = `${o}-${n + 1}`, w(r, e, "fieldError"), r.textContent = t, a.appendChild(r);
|
|
1246
|
-
});
|
|
1247
|
-
let s = a.querySelector("[data-formie-field-error]")?.id;
|
|
1248
|
-
i.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
1249
|
-
let n = t;
|
|
1250
|
-
n.setAttribute("aria-invalid", "true"), w(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), It(n, o), s && At(n, s);
|
|
1251
|
-
let r = i.querySelector("[data-formie-instructions]");
|
|
1252
|
-
r?.id && It(n, r.id);
|
|
1253
|
-
});
|
|
1254
|
-
}), y(e);
|
|
1255
|
-
}
|
|
1256
|
-
function Rt(e, t) {
|
|
1257
|
-
let n = Tt(e), r = Et(e, n);
|
|
1258
|
-
w(n, e, "errors"), t.forEach((t) => {
|
|
1259
|
-
let n = document.createElement("div");
|
|
1260
|
-
n.setAttribute("data-formie-error", "true"), n.setAttribute("role", "alert"), w(n, e, "error"), n.innerHTML = t, r.appendChild(n);
|
|
1261
|
-
});
|
|
1262
|
-
}
|
|
1263
|
-
function zt(e) {
|
|
1264
|
-
if (e.ok || e.keepSubmitLoading !== !0) return !1;
|
|
1265
|
-
let t = e.meta || {}, n = String(t.paymentStatus || "");
|
|
1266
|
-
return n === "actionRequired" || n === "pending";
|
|
1267
|
-
}
|
|
1268
|
-
function Bt(e, t) {
|
|
1269
|
-
let n = Tt(e), r = Et(e, n);
|
|
1270
|
-
w(n, e, "errors");
|
|
1271
|
-
let i = document.createElement("div");
|
|
1272
|
-
i.setAttribute("data-formie-notice", "true"), i.setAttribute("role", "status"), w(i, e, "message"), i.textContent = t, r.appendChild(i);
|
|
1273
|
-
}
|
|
1274
|
-
function Vt(e, t) {
|
|
1275
|
-
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" ? !0 : ht(e) === "message" && _t(e) !== "";
|
|
1276
|
-
}
|
|
1277
|
-
function Ht(e, t) {
|
|
1278
|
-
let n = _t(e);
|
|
1279
|
-
if (!n) return;
|
|
1280
|
-
let r = Dt(e, n);
|
|
1281
|
-
w(r, e, "message", "messageSuccess"), r.setAttribute("data-formie-message", "true"), r.setAttribute("data-formie-message-success", "true"), r.setAttribute("role", "status"), r.setAttribute("aria-live", "polite"), r.setAttribute("aria-atomic", "true");
|
|
1282
|
-
let i = document.createElement("div");
|
|
1283
|
-
i.setAttribute("data-formie-success", "true"), w(i, e, "success"), i.innerHTML = t, r.appendChild(i), yt(e) && s(e, !0);
|
|
1284
|
-
let a = vt(e);
|
|
1285
|
-
if (a !== null) {
|
|
1286
|
-
let t = window.setTimeout(() => {
|
|
1287
|
-
F.delete(e), Pt(e);
|
|
1288
|
-
}, a);
|
|
1289
|
-
F.set(e, t);
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
function I(e, t) {
|
|
1293
|
-
if (Mt(e), Nt(e), Pt(e), Ft(e), t.ok) {
|
|
1294
|
-
Vt(e, t) && Ht(e, t.message || "");
|
|
1295
|
-
return;
|
|
1296
|
-
}
|
|
1297
|
-
if (!t.ok) {
|
|
1298
|
-
if (zt(t)) {
|
|
1299
|
-
let n = t.meta || {}, r = String(n.paymentMessage || "").trim();
|
|
1300
|
-
r && Bt(e, r);
|
|
1301
|
-
return;
|
|
1302
|
-
}
|
|
1303
|
-
t.fieldErrors && Lt(e, t.fieldErrors), t.formErrors?.length ? Rt(e, t.formErrors) : !t.fieldErrors && t.message && Rt(e, [t.message]), Fe(e);
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
//#endregion
|
|
1307
|
-
//#region src/js/core/submit-flow.ts
|
|
1308
|
-
var Ut = S("general", "submit-flow");
|
|
1309
|
-
function Wt(e) {
|
|
1310
|
-
return !(!e.ok && e.stage === "validate");
|
|
1311
|
-
}
|
|
1312
|
-
function Gt(e) {
|
|
1313
|
-
return e ? !!(e.keepSubmitLoading === !0 || e.ok && e.redirect?.url && e.redirect.target !== "new-tab") : !1;
|
|
1314
|
-
}
|
|
1315
|
-
function Kt(e) {
|
|
1316
|
-
Mt(e), Nt(e), Pt(e), Ft(e);
|
|
1317
|
-
}
|
|
1318
|
-
async function qt(e) {
|
|
1319
|
-
let { id: t, target: n, form: r, bus: i, validator: a, validateOnSubmit: o, action: s, submitter: c, waitForSubmitDelay: l, onRefreshTokensAfterSubmit: u, dispatchSubmitResult: f } = e;
|
|
1320
|
-
Kt(r), m(r, c || null);
|
|
1321
|
-
let p = {
|
|
1322
|
-
ok: !1,
|
|
1323
|
-
code: "SUBMIT_ERROR",
|
|
1324
|
-
message: "Submission failed.",
|
|
1325
|
-
formErrors: ["Submission failed."]
|
|
1326
|
-
};
|
|
1327
|
-
try {
|
|
1328
|
-
await l(r), p = await nt(r, s, i, {
|
|
1329
|
-
validator: a,
|
|
1330
|
-
validateOnSubmit: o
|
|
1331
|
-
}), I(r, p), f(p), g(r, p, s), Wt(p) && await u(p);
|
|
1332
|
-
} catch (e) {
|
|
1333
|
-
p = {
|
|
1334
|
-
ok: !1,
|
|
1335
|
-
code: "SUBMIT_ERROR",
|
|
1336
|
-
message: e instanceof Error ? e.message : "Submission failed.",
|
|
1337
|
-
formErrors: [e instanceof Error ? e.message : "Submission failed."]
|
|
1338
|
-
}, I(r, p), f(p), Ut.warn("Submit failed with exception.", {
|
|
1339
|
-
id: t,
|
|
1340
|
-
action: s,
|
|
1341
|
-
target: n,
|
|
1342
|
-
error: e instanceof Error ? e.message : e
|
|
1343
|
-
});
|
|
1344
|
-
} finally {
|
|
1345
|
-
Gt(p) || d(r);
|
|
1346
|
-
}
|
|
1347
|
-
return p;
|
|
1348
|
-
}
|
|
1349
|
-
//#endregion
|
|
1350
|
-
//#region src/js/modules/registry.ts
|
|
1351
|
-
var L = class {
|
|
1352
|
-
constructor() {
|
|
1353
|
-
this.modules = /* @__PURE__ */ new Map();
|
|
1709
|
+
t: se,
|
|
1710
|
+
input: e,
|
|
1711
|
+
label: n,
|
|
1712
|
+
field: t,
|
|
1713
|
+
form: this.form,
|
|
1714
|
+
config: this.config,
|
|
1715
|
+
rules: r,
|
|
1716
|
+
getRule: (e) => this.getRule(t, e)
|
|
1717
|
+
};
|
|
1354
1718
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
return n === e ? !0 : n && !t.replace ? (console.warn(`[formie] Module "${e.id}" is already registered. Pass { replace: true } to override the existing definition.`), !1) : (this.modules.set(e.id, e), !0);
|
|
1719
|
+
getErrorMessage(e, t, n, r) {
|
|
1720
|
+
return (typeof n.errorMessage == "function" ? n.errorMessage(r) : n.errorMessage) ?? se("{label} is invalid.", { label: r.label });
|
|
1358
1721
|
}
|
|
1359
|
-
|
|
1360
|
-
this.
|
|
1722
|
+
getErrors() {
|
|
1723
|
+
return this.errors;
|
|
1361
1724
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1725
|
+
getFieldErrors(e = this.errors) {
|
|
1726
|
+
let t = {};
|
|
1727
|
+
return e.forEach((e) => {
|
|
1728
|
+
e.handle && !t[e.handle]?.length && (t[e.handle] = [e.message]);
|
|
1729
|
+
}), t;
|
|
1364
1730
|
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1731
|
+
getRule(e, t) {
|
|
1732
|
+
if (!e) return !1;
|
|
1733
|
+
let n = this.parseValidationRules(e.getAttribute("data-formie-validation"));
|
|
1734
|
+
return Object.prototype.hasOwnProperty.call(n, t) ? n[t] : !1;
|
|
1367
1735
|
}
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
"place-kit": () => import("./chunks/place-kit-BGHklIZ-.js").then((e) => e.placeKitModule)
|
|
1373
|
-
}, Yt = {
|
|
1374
|
-
"captcha-eu": () => import("./chunks/captcha-eu-CGm8Lbrj.js").then((e) => e.captchaEuModule),
|
|
1375
|
-
"friendly-captcha-v1": () => import("./chunks/friendly-captcha-v1-C_2reOXr.js").then((e) => e.friendlyCaptchaV1Module),
|
|
1376
|
-
"friendly-captcha-v2": () => import("./chunks/friendly-captcha-v2-CLSAbkqx.js").then((e) => e.friendlyCaptchaV2Module),
|
|
1377
|
-
hcaptcha: () => import("./chunks/hcaptcha-CGLAmgjO.js").then((e) => e.hcaptchaModule),
|
|
1378
|
-
"recaptcha-enterprise": () => import("./chunks/recaptcha-enterprise-XPId5-bS.js").then((e) => e.recaptchaEnterpriseModule),
|
|
1379
|
-
"recaptcha-v2-checkbox": () => import("./chunks/recaptcha-v2-checkbox-Cy-0PEPc.js").then((e) => e.recaptchaV2CheckboxModule),
|
|
1380
|
-
"recaptcha-v2-invisible": () => import("./chunks/recaptcha-v2-invisible-BwRH540O.js").then((e) => e.recaptchaV2InvisibleModule),
|
|
1381
|
-
"recaptcha-v3": () => import("./chunks/recaptcha-v3-No4Ykrhk.js").then((e) => e.recaptchaV3Module),
|
|
1382
|
-
snaptcha: () => import("./chunks/snaptcha-DKx98oon.js").then((e) => e.snaptchaModule),
|
|
1383
|
-
turnstile: () => import("./chunks/turnstile-DJakPzQD.js").then((e) => e.turnstileModule)
|
|
1384
|
-
}, Xt = {
|
|
1385
|
-
calculations: () => import("./chunks/calculations-Dv3hYb8_.js").then((e) => e.calculationsModule),
|
|
1386
|
-
"checkbox-radio": () => import("./chunks/checkbox-radio-BY2aTCOG.js").then((e) => e.checkboxRadioModule),
|
|
1387
|
-
combobox: () => import("./chunks/combobox-C0EuExSI.js").then((e) => e.comboboxModule),
|
|
1388
|
-
conditions: () => import("./chunks/conditions-CPH1snCx.js").then((e) => e.conditionsModule),
|
|
1389
|
-
"custom-google-maps": () => import("./chunks/custom-google-maps-BsaSirEZ.js").then((e) => e.customGoogleMapsModule),
|
|
1390
|
-
"custom-link": () => import("./chunks/custom-link-CJ1-FjEM.js").then((e) => e.customLinkModule),
|
|
1391
|
-
"custom-maps": () => import("./chunks/custom-maps-DYW_pBid.js").then((e) => e.customMapsModule),
|
|
1392
|
-
"date-picker": () => import("./chunks/date-picker-F9BUBDSW.js").then((e) => e.datePickerModule),
|
|
1393
|
-
"file-upload": () => import("./chunks/file-upload-rqfZNqlH.js").then((e) => e.fileUploadModule),
|
|
1394
|
-
"upload-manager": () => import("./chunks/upload-manager-W-QDgxKD.js").then((e) => e.uploadManagerModule),
|
|
1395
|
-
hidden: () => import("./chunks/hidden-D7_Ch-QN.js").then((e) => e.hiddenModule),
|
|
1396
|
-
"phone-country": () => import("./chunks/phone-country-D3ayr60L.js").then((e) => e.phoneCountryModule),
|
|
1397
|
-
"password-validation": () => import("./chunks/password-validation-D06uH9va.js").then((e) => e.passwordValidationModule),
|
|
1398
|
-
"address-country": () => import("./chunks/address-country-Rx6GQTND.js").then((e) => e.addressCountryModule),
|
|
1399
|
-
"address-state": () => import("./chunks/address-state-BwE01m2_.js").then((e) => e.addressStateModule),
|
|
1400
|
-
repeater: () => import("./chunks/repeater-BVnPUqTj.js").then((e) => e.repeaterModule),
|
|
1401
|
-
"rich-text": () => import("./chunks/rich-text-Bg_--4TG.js").then((e) => e.richTextModule),
|
|
1402
|
-
signature: () => import("./chunks/signature-IOhuicje.js").then((e) => e.signatureModule),
|
|
1403
|
-
summary: () => import("./chunks/summary-Dks0gXS3.js").then((e) => e.summaryModule),
|
|
1404
|
-
"survey-likert": () => import("./chunks/survey-likert-DkE6bR7B.js").then((e) => e.surveyLikertModule),
|
|
1405
|
-
"survey-rank": () => import("./chunks/survey-rank-DN6x4IZM.js").then((e) => e.surveyRankModule),
|
|
1406
|
-
"survey-rating": () => import("./chunks/survey-rating-BnsNL9U5.js").then((e) => e.surveyRatingModule),
|
|
1407
|
-
table: () => import("./chunks/table-CAjCJHrL.js").then((e) => e.tableModule),
|
|
1408
|
-
"text-limit": () => import("./chunks/text-limit-BGaY0jhI.js").then((e) => e.textLimitModule)
|
|
1409
|
-
}, Zt = {
|
|
1410
|
-
bpoint: () => import("./chunks/bpoint-Dlq34XH1.js").then((e) => e.bpointModule),
|
|
1411
|
-
eway: () => import("./chunks/eway-D9_m8ooj.js").then((e) => e.ewayModule),
|
|
1412
|
-
"go-cardless": () => import("./chunks/go-cardless-DAT3ZaQf.js").then((e) => e.goCardlessModule),
|
|
1413
|
-
mollie: () => import("./chunks/mollie-Bibhl67p.js").then((e) => e.mollieModule),
|
|
1414
|
-
moneris: () => import("./chunks/moneris-H2wSqk9h.js").then((e) => e.monerisModule),
|
|
1415
|
-
opayo: () => import("./chunks/opayo-CR0DtsLa.js").then((e) => e.opayoModule),
|
|
1416
|
-
paddle: () => import("./chunks/paddle-DkvIxQdG.js").then((e) => e.paddleModule),
|
|
1417
|
-
paypal: () => import("./chunks/paypal-CQpAF7Ua.js").then((e) => e.paypalModule),
|
|
1418
|
-
payway: () => import("./chunks/payway-CwDkC7YZ.js").then((e) => e.paywayModule),
|
|
1419
|
-
square: () => import("./chunks/square-DwdcOI1G.js").then((e) => e.squareModule),
|
|
1420
|
-
stripe: () => import("./chunks/stripe-DaoG2FT1.js").then((e) => e.stripeModule)
|
|
1421
|
-
}, Qt = {
|
|
1422
|
-
...Xt,
|
|
1423
|
-
...Jt,
|
|
1424
|
-
...Yt,
|
|
1425
|
-
...Zt
|
|
1426
|
-
}, R = /* @__PURE__ */ new Map(), z = S("general", "loader"), $t = Function("src", "return import(src);");
|
|
1427
|
-
async function B(t, n, i, a) {
|
|
1428
|
-
await t(r(i), a), await t(e(n, i), a);
|
|
1429
|
-
}
|
|
1430
|
-
function en(e) {
|
|
1431
|
-
return !!e && typeof e == "object" && typeof e.id == "string" && typeof e.setup == "function" && typeof e.match == "function";
|
|
1432
|
-
}
|
|
1433
|
-
async function tn(e, t) {
|
|
1434
|
-
let n = Qt[e];
|
|
1435
|
-
return n ? (R.has(e) || R.set(e, (async () => {
|
|
1736
|
+
parseValidationRules(e) {
|
|
1737
|
+
let t = {};
|
|
1738
|
+
if (!e) return t;
|
|
1739
|
+
let n = null;
|
|
1436
1740
|
try {
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
return console.error("[formie] Failed to load builtin module:", e, t), z.warn("Failed loading builtin module.", {
|
|
1441
|
-
moduleId: e,
|
|
1442
|
-
error: t
|
|
1443
|
-
}), null;
|
|
1741
|
+
n = JSON.parse(e);
|
|
1742
|
+
} catch {
|
|
1743
|
+
return U.warn("Invalid validation rules payload.", { formId: this.form.id || null }), t;
|
|
1444
1744
|
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
return en(n) ? n : null;
|
|
1451
|
-
} catch (t) {
|
|
1452
|
-
return console.error("[formie] Failed to load module from src:", e, t), z.warn("Failed loading module from src.", {
|
|
1453
|
-
src: e,
|
|
1454
|
-
error: t
|
|
1455
|
-
}), null;
|
|
1745
|
+
return Array.isArray(n) && n.forEach((e) => {
|
|
1746
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
1747
|
+
let n = e, r = typeof n.type == "string" ? n.type.trim() : "";
|
|
1748
|
+
r && (t[r] = n);
|
|
1749
|
+
}), t;
|
|
1456
1750
|
}
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
let n = t.registry.get(e.id);
|
|
1460
|
-
if (n) return n;
|
|
1461
|
-
let r = await tn(e.id, t);
|
|
1462
|
-
if (r) return r;
|
|
1463
|
-
if (e.src) {
|
|
1464
|
-
let n = await nn(e.src);
|
|
1465
|
-
if (n) return t.registry.register(n), n;
|
|
1751
|
+
destroy() {
|
|
1752
|
+
U.log("Destroying validator.", { formId: this.form.id || null }), this.removeEventListeners(), this.form.removeAttribute("novalidate"), this.emitEvent(document, o("destroy"), { validator: this });
|
|
1466
1753
|
}
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
scope: i,
|
|
1482
|
-
element: e
|
|
1483
|
-
})) : i === "page" ? H(n, `[data-formie-page-id="${V(a)}"]`).map((e) => ({
|
|
1484
|
-
scope: i,
|
|
1485
|
-
element: e
|
|
1486
|
-
})) : i === "button" ? H(n, `[data-formie-action="${V(a)}"]`).map((e) => ({
|
|
1487
|
-
scope: i,
|
|
1488
|
-
element: e
|
|
1489
|
-
})) : [{
|
|
1490
|
-
scope: "form",
|
|
1491
|
-
element: r || n
|
|
1492
|
-
}];
|
|
1493
|
-
}
|
|
1494
|
-
function on(e, t) {
|
|
1495
|
-
return (e.targets && e.targets.length > 0 ? e.targets : [{
|
|
1496
|
-
targetType: "form",
|
|
1497
|
-
targetId: "form"
|
|
1498
|
-
}]).flatMap((e) => an(e, t));
|
|
1499
|
-
}
|
|
1500
|
-
async function sn(e, t) {
|
|
1501
|
-
let n = [];
|
|
1502
|
-
z.log("Loading module manifest.", { manifestCount: e.length });
|
|
1503
|
-
for (let r of e) {
|
|
1504
|
-
let e = await rn(r, t);
|
|
1505
|
-
if (!e) {
|
|
1506
|
-
z.warn("Skipping manifest item (definition not resolved).", {
|
|
1507
|
-
moduleId: r.id,
|
|
1508
|
-
src: r.src
|
|
1509
|
-
});
|
|
1510
|
-
continue;
|
|
1511
|
-
}
|
|
1512
|
-
let i = on(r, t);
|
|
1513
|
-
z.log("Resolved module targets.", {
|
|
1514
|
-
moduleId: e.id,
|
|
1515
|
-
targets: r.targets || [],
|
|
1516
|
-
targetCount: i.length
|
|
1517
|
-
}), i.length === 0 && e.kind === "address" && console.warn(`[formie] Address module "${r.id}" skipped: no target element found for fieldHandle="${r.targets?.find((e) => e.targetType === "field")?.targetId ?? "?"}". Check that the Address field exists in the rendered form.`);
|
|
1518
|
-
for (let a of i) {
|
|
1519
|
-
let i = {
|
|
1520
|
-
...t.matchContext,
|
|
1521
|
-
target: a.element,
|
|
1522
|
-
scope: a.scope,
|
|
1523
|
-
manifestItem: r
|
|
1524
|
-
};
|
|
1525
|
-
if (!e.match(i)) {
|
|
1526
|
-
e.kind === "address" && console.warn(`[formie] Address module "${e.id}" skipped: target element does not contain [data-formie-address-autocomplete-input]. Enable the Auto-Complete subfield.`), z.log("Module target did not match predicate.", {
|
|
1527
|
-
moduleId: e.id,
|
|
1528
|
-
scope: a.scope
|
|
1529
|
-
});
|
|
1530
|
-
continue;
|
|
1531
|
-
}
|
|
1532
|
-
let o = r.config || t.setupContext.options, s = e.id, c = {
|
|
1533
|
-
moduleId: e.id,
|
|
1534
|
-
moduleKind: e.kind,
|
|
1535
|
-
target: a.element,
|
|
1536
|
-
scope: a.scope,
|
|
1537
|
-
options: o,
|
|
1538
|
-
manifestItem: r
|
|
1539
|
-
};
|
|
1540
|
-
await B(t.setupContext.emit, s, "before-setup", c);
|
|
1541
|
-
let l = null;
|
|
1542
|
-
try {
|
|
1543
|
-
let n = await e.setup({
|
|
1544
|
-
...t.setupContext,
|
|
1545
|
-
target: a.element,
|
|
1546
|
-
scope: a.scope,
|
|
1547
|
-
options: o
|
|
1548
|
-
});
|
|
1549
|
-
n && (l = n);
|
|
1550
|
-
} catch (t) {
|
|
1551
|
-
console.error(`[formie] Module "${e.id}" setup failed:`, t), z.warn("Module setup failed.", {
|
|
1552
|
-
moduleId: e.id,
|
|
1553
|
-
scope: a.scope,
|
|
1554
|
-
error: t
|
|
1555
|
-
});
|
|
1754
|
+
isVisible(e, t = {}) {
|
|
1755
|
+
if (e.disabled || e.hasAttribute("data-formie-conditions-disabled") || e.closest("[data-formie-conditions-disabled]") || e.closest("[data-formie-conditionally-hidden]")) return !1;
|
|
1756
|
+
if (e.closest("[data-formie-page-hidden]")) return !!t.includeHiddenPages;
|
|
1757
|
+
let n = e.closest("[data-formie-field-handle]")?.querySelector("[data-formie-rich-text]");
|
|
1758
|
+
return n instanceof HTMLElement ? un(n) : un(e);
|
|
1759
|
+
}
|
|
1760
|
+
blurHandler(e) {
|
|
1761
|
+
e.target instanceof HTMLElement && W(e.target) && !P(e.target) && e.target.form?.isSameNode(this.form) && (e instanceof CustomEvent || e.target instanceof HTMLInputElement && e.target.type === "file" || e.target instanceof HTMLInputElement && (e.target.type === "checkbox" || e.target.type === "radio") || (this.isDirty(e.target) && this.activated.add(e.target), this.shouldShowError(e.target) && this.validate(e.target)));
|
|
1762
|
+
}
|
|
1763
|
+
changeHandler(e) {
|
|
1764
|
+
if (e.target instanceof HTMLElement && W(e.target) && !P(e.target) && e.target.form?.isSameNode(this.form) && !(e instanceof CustomEvent)) {
|
|
1765
|
+
if (e.target instanceof HTMLSelectElement) {
|
|
1766
|
+
this.activated.add(e.target), this.validate(e.target);
|
|
1767
|
+
return;
|
|
1556
1768
|
}
|
|
1557
|
-
|
|
1558
|
-
...c,
|
|
1559
|
-
instanceCreated: !!l
|
|
1560
|
-
}), l && (z.log("Module instance created.", {
|
|
1561
|
-
moduleId: e.id,
|
|
1562
|
-
scope: a.scope
|
|
1563
|
-
}), n.push({
|
|
1564
|
-
...l,
|
|
1565
|
-
destroy: async () => {
|
|
1566
|
-
z.log("Destroying module instance.", {
|
|
1567
|
-
moduleId: e.id,
|
|
1568
|
-
scope: a.scope
|
|
1569
|
-
}), await B(t.setupContext.emit, s, "before-destroy", c), await l.destroy(), await B(t.setupContext.emit, s, "after-destroy", c), z.log("Module instance destroyed.", {
|
|
1570
|
-
moduleId: e.id,
|
|
1571
|
-
scope: a.scope
|
|
1572
|
-
});
|
|
1573
|
-
}
|
|
1574
|
-
}));
|
|
1769
|
+
e.target instanceof HTMLInputElement && (e.target.type === "file" || e.target.type === "checkbox" || e.target.type === "radio") && (this.activated.add(e.target), this.validate(e.target));
|
|
1575
1770
|
}
|
|
1576
1771
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
//#endregion
|
|
1580
|
-
//#region src/js/utils/form-started-at.ts
|
|
1581
|
-
var cn = "formie:formStartedAt:";
|
|
1582
|
-
function ln(e) {
|
|
1583
|
-
let t = e.querySelector("input[name=\"formStartedAt\"]");
|
|
1584
|
-
if (!t) return;
|
|
1585
|
-
let n = e.querySelector("input[name=\"renderId\"]")?.value?.trim() ?? "", r = n ? `${cn}${n}` : null, i = r ? sessionStorage.getItem(r) : null;
|
|
1586
|
-
i || (i = String(Date.now()), r && sessionStorage.setItem(r, i)), t.value = i;
|
|
1587
|
-
}
|
|
1588
|
-
//#endregion
|
|
1589
|
-
//#region src/js/utils/unload-warning.ts
|
|
1590
|
-
var un = new Set([
|
|
1591
|
-
"CRAFT_CSRF_TOKEN",
|
|
1592
|
-
"action",
|
|
1593
|
-
"redirect",
|
|
1594
|
-
"requestToken",
|
|
1595
|
-
"renderId",
|
|
1596
|
-
"formStartedAt",
|
|
1597
|
-
"submitAction",
|
|
1598
|
-
"pageId",
|
|
1599
|
-
"draftContextToken",
|
|
1600
|
-
"draftContext",
|
|
1601
|
-
"continuationToken"
|
|
1602
|
-
]);
|
|
1603
|
-
function dn(e, t) {
|
|
1604
|
-
if (e == null) return String(e);
|
|
1605
|
-
if (typeof e == "string") return JSON.stringify(e);
|
|
1606
|
-
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1607
|
-
if (typeof e == "function") return "[function]";
|
|
1608
|
-
if (typeof File < "u" && e instanceof File) return `[file:${e.name}:${e.size}:${e.type}]`;
|
|
1609
|
-
if (typeof Blob < "u" && e instanceof Blob) return `[blob:${e.size}:${e.type}]`;
|
|
1610
|
-
if (Array.isArray(e)) return `[${e.map((e) => dn(e, t)).join(",")}]`;
|
|
1611
|
-
if (typeof e == "object") {
|
|
1612
|
-
if (t.has(e)) return "[circular]";
|
|
1613
|
-
t.add(e);
|
|
1614
|
-
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${dn(n, t)}`);
|
|
1615
|
-
return t.delete(e), `{${n.join(",")}}`;
|
|
1772
|
+
inputHandler(e) {
|
|
1773
|
+
e.target instanceof HTMLElement && W(e.target) && !P(e.target) && e.target.form?.isSameNode(this.form) && (e instanceof CustomEvent || e.target instanceof HTMLInputElement && (e.target.type === "checkbox" || e.target.type === "radio") || this.shouldShowError(e.target) && this.validate(e.target));
|
|
1616
1774
|
}
|
|
1617
|
-
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
}
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
}, p = (e) => {
|
|
1646
|
-
t.shouldWarn && !t.shouldWarn() || l() && (e.preventDefault(), e.returnValue = "");
|
|
1647
|
-
};
|
|
1648
|
-
return e.addEventListener("input", f), e.addEventListener("change", f), window.addEventListener("beforeunload", p), d(), {
|
|
1649
|
-
captureBaseline: u,
|
|
1650
|
-
scheduleBaselineCapture: d,
|
|
1651
|
-
refreshDirtyState: l,
|
|
1652
|
-
destroy: () => {
|
|
1653
|
-
c(), e.removeEventListener("input", f), e.removeEventListener("change", f), window.removeEventListener("beforeunload", p);
|
|
1654
|
-
}
|
|
1655
|
-
};
|
|
1656
|
-
}
|
|
1775
|
+
submit(e = null, { final: t = !1 } = {}) {
|
|
1776
|
+
return this.submitted = !0, U.log("Submit validation requested.", { final: t }), this.boundListeners || this.addEventListeners(), this.removeAllErrors(), this.validate(e, { includeHiddenPages: t });
|
|
1777
|
+
}
|
|
1778
|
+
resetLiveState() {
|
|
1779
|
+
this.submitted = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.errors = [], this.removeAllErrors();
|
|
1780
|
+
}
|
|
1781
|
+
addEventListeners() {
|
|
1782
|
+
this.boundListeners || (this.form.addEventListener("blur", this.onBlur, !0), this.form.addEventListener("change", this.onChange, !1), this.form.addEventListener("input", this.onInput, !1), this.boundListeners = !0, U.log("Event listeners attached."));
|
|
1783
|
+
}
|
|
1784
|
+
removeEventListeners() {
|
|
1785
|
+
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1, U.log("Event listeners removed.");
|
|
1786
|
+
}
|
|
1787
|
+
emitEvent(e, t, n = {}) {
|
|
1788
|
+
e.dispatchEvent(new CustomEvent(t, {
|
|
1789
|
+
bubbles: !0,
|
|
1790
|
+
detail: n
|
|
1791
|
+
}));
|
|
1792
|
+
}
|
|
1793
|
+
addValidator(e, t, n) {
|
|
1794
|
+
this.validators[e] = {
|
|
1795
|
+
validate: t,
|
|
1796
|
+
errorMessage: n
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
removeValidator(e) {
|
|
1800
|
+
delete this.validators[e];
|
|
1801
|
+
}
|
|
1802
|
+
};
|
|
1657
1803
|
//#endregion
|
|
1658
1804
|
//#region src/js/validation/enter-key-guard.ts
|
|
1659
|
-
function
|
|
1805
|
+
function fn(e) {
|
|
1660
1806
|
return e.hasAttribute("data-formie-conditionally-hidden") || !!e.closest("[data-formie-conditionally-hidden]") || e.hasAttribute("data-formie-page-hidden") || !!e.closest("[data-formie-page-hidden]");
|
|
1661
1807
|
}
|
|
1662
|
-
function
|
|
1808
|
+
function pn(e, t) {
|
|
1663
1809
|
let n = e.querySelectorAll(`[data-formie-action="${t}"]`);
|
|
1664
|
-
return Array.from(n).some((e) => !
|
|
1810
|
+
return Array.from(n).some((e) => !fn(e));
|
|
1665
1811
|
}
|
|
1666
|
-
function
|
|
1667
|
-
let { final: t } =
|
|
1812
|
+
function mn(e) {
|
|
1813
|
+
let { final: t } = g(e);
|
|
1668
1814
|
return "submit";
|
|
1669
1815
|
}
|
|
1670
|
-
function
|
|
1671
|
-
return !
|
|
1816
|
+
function hn(e) {
|
|
1817
|
+
return !pn(e, mn(e));
|
|
1672
1818
|
}
|
|
1673
|
-
function
|
|
1819
|
+
function gn(e) {
|
|
1674
1820
|
let t = (t) => {
|
|
1675
1821
|
if (t.key !== "Enter" || t.defaultPrevented) return;
|
|
1676
1822
|
let n = t.target;
|
|
1677
|
-
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") ||
|
|
1823
|
+
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") || hn(e) && t.preventDefault());
|
|
1678
1824
|
};
|
|
1679
1825
|
return e.addEventListener("keydown", t, !0), () => {
|
|
1680
1826
|
e.removeEventListener("keydown", t, !0);
|
|
@@ -1682,40 +1828,42 @@ function bn(e) {
|
|
|
1682
1828
|
}
|
|
1683
1829
|
//#endregion
|
|
1684
1830
|
//#region src/js/core/create-formie-client.ts
|
|
1685
|
-
var
|
|
1686
|
-
function
|
|
1831
|
+
var G = "[data-formie]:not([data-formie-init=\"false\"]), [data-formie-form]:not([data-formie-init=\"false\"])", _n = 300, vn = "/actions/formie/server/forms/render", yn = "/api", bn = "/actions/formie/server/forms/refresh-tokens", xn = "/actions/formie/server/submissions/submit", Sn = "/actions/formie/server/submissions/set-page", Cn = "/actions/formie/server/submissions/clear-submission", wn = "/actions/formie/file-upload/hydrate", K = T("general", "client"), Tn = /* @__PURE__ */ new Set();
|
|
1832
|
+
function q(e, t) {
|
|
1687
1833
|
if (e == null || e === "") return t;
|
|
1688
1834
|
let n = e.toLowerCase();
|
|
1689
|
-
return
|
|
1835
|
+
return n !== "false" && n !== "0" && n !== "off";
|
|
1690
1836
|
}
|
|
1691
|
-
function
|
|
1692
|
-
return e.formieRefreshTokens
|
|
1837
|
+
function En(e) {
|
|
1838
|
+
return e.formieRefreshTokens == null ? e.formieStaticCache != null && q(e.formieStaticCache, !0) : q(e.formieRefreshTokens, !0);
|
|
1693
1839
|
}
|
|
1694
|
-
function
|
|
1840
|
+
function J(e) {
|
|
1695
1841
|
let t = e instanceof HTMLElement ? e.dataset : {};
|
|
1696
1842
|
return {
|
|
1697
1843
|
mode: "server-rendered",
|
|
1698
1844
|
transport: t.formieTransport || "rest",
|
|
1845
|
+
profile: t.formieRequestProfile,
|
|
1699
1846
|
formHandle: t.formieHandle,
|
|
1700
1847
|
endpoint: t.formieEndpoint,
|
|
1701
|
-
staticCache:
|
|
1702
|
-
autoVisible:
|
|
1703
|
-
compatibility:
|
|
1848
|
+
staticCache: En(t),
|
|
1849
|
+
autoVisible: q(t.formieAutoVisible, !0),
|
|
1850
|
+
compatibility: q(t.formieCompatibility, !1)
|
|
1704
1851
|
};
|
|
1705
1852
|
}
|
|
1706
|
-
function
|
|
1707
|
-
|
|
1853
|
+
function Dn(e) {
|
|
1854
|
+
if (e && e !== "server-rendered") throw Error("@verbb/formie-browser enhances server-rendered HTML only. Use @verbb/formie-core for client-rendered forms.");
|
|
1855
|
+
return "server-rendered";
|
|
1708
1856
|
}
|
|
1709
|
-
function
|
|
1857
|
+
function On(e) {
|
|
1710
1858
|
return e || "rest";
|
|
1711
1859
|
}
|
|
1712
|
-
function
|
|
1860
|
+
function kn(e) {
|
|
1713
1861
|
return e instanceof HTMLFormElement ? e : e.querySelector("form");
|
|
1714
1862
|
}
|
|
1715
|
-
function
|
|
1716
|
-
|
|
1863
|
+
function An(e, t) {
|
|
1864
|
+
Tn.has(e) || (Tn.add(e), K.warn(t));
|
|
1717
1865
|
}
|
|
1718
|
-
function
|
|
1866
|
+
function jn(e, t) {
|
|
1719
1867
|
if (!e) return e;
|
|
1720
1868
|
try {
|
|
1721
1869
|
return new URL(e).toString();
|
|
@@ -1727,21 +1875,21 @@ function Mn(e, t) {
|
|
|
1727
1875
|
return e;
|
|
1728
1876
|
}
|
|
1729
1877
|
}
|
|
1730
|
-
function
|
|
1878
|
+
function Y(e, t) {
|
|
1731
1879
|
let n = (e || "").trim();
|
|
1732
|
-
return n ? n.includes(
|
|
1880
|
+
return n ? n.includes(t) ? n : jn(t, n) : t;
|
|
1881
|
+
}
|
|
1882
|
+
function Mn(e, t) {
|
|
1883
|
+
return Y(e.endpoint || t.dataset.formieEndpoint, vn);
|
|
1733
1884
|
}
|
|
1734
1885
|
function Nn(e, t) {
|
|
1735
|
-
|
|
1886
|
+
let n = (e.endpoint || t.dataset.formieEndpoint || "").trim();
|
|
1887
|
+
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n : jn(yn, n) : yn;
|
|
1736
1888
|
}
|
|
1737
1889
|
function Pn(e, t) {
|
|
1738
|
-
|
|
1739
|
-
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n : Mn(Cn, n) : Cn;
|
|
1890
|
+
return Y(t.dataset.formieRefreshTokensEndpoint || e.endpoint || t.dataset.formieEndpoint, bn);
|
|
1740
1891
|
}
|
|
1741
1892
|
function Fn(e, t) {
|
|
1742
|
-
return X(t.dataset.formieRefreshTokensEndpoint || e.endpoint || t.dataset.formieEndpoint, wn);
|
|
1743
|
-
}
|
|
1744
|
-
function In(e, t) {
|
|
1745
1893
|
if (!e) return t;
|
|
1746
1894
|
try {
|
|
1747
1895
|
let n = new URL(e, window.location.origin), r = new URL(t, window.location.origin);
|
|
@@ -1752,42 +1900,39 @@ function In(e, t) {
|
|
|
1752
1900
|
return t;
|
|
1753
1901
|
}
|
|
1754
1902
|
}
|
|
1755
|
-
function
|
|
1756
|
-
let r = n.endpoint || e.dataset.formieEndpoint, i =
|
|
1757
|
-
t.setAttribute("action",
|
|
1758
|
-
let t = e.getAttribute("href"), n =
|
|
1759
|
-
e.setAttribute("href",
|
|
1903
|
+
function In(e, t, n) {
|
|
1904
|
+
let r = n.endpoint || e.dataset.formieEndpoint, i = Y(r, xn), a = t.getAttribute("action");
|
|
1905
|
+
t.setAttribute("action", Fn(a, i)), t.querySelectorAll("[data-formie-tab-link]").forEach((e) => {
|
|
1906
|
+
let t = e.getAttribute("href"), n = Y(r, Sn);
|
|
1907
|
+
e.setAttribute("href", Fn(t, n));
|
|
1760
1908
|
}), t.querySelectorAll("[data-formie-file-upload-hydrate-endpoint]").forEach((e) => {
|
|
1761
|
-
e.setAttribute("data-formie-file-upload-hydrate-endpoint",
|
|
1909
|
+
e.setAttribute("data-formie-file-upload-hydrate-endpoint", Y(r, wn));
|
|
1762
1910
|
});
|
|
1763
1911
|
}
|
|
1764
|
-
function
|
|
1765
|
-
if (e === "graphql" && t !== "server-rendered") throw Error(`Formie ${t} mode does not support GraphQL transport yet.`);
|
|
1766
|
-
}
|
|
1767
|
-
function zn(e) {
|
|
1912
|
+
function Ln(e) {
|
|
1768
1913
|
if (e == null) return !1;
|
|
1769
1914
|
let t = e.trim().toLowerCase();
|
|
1770
1915
|
return t === "true" || t === "1" || t === "";
|
|
1771
1916
|
}
|
|
1772
|
-
function
|
|
1773
|
-
return
|
|
1917
|
+
function Rn(e) {
|
|
1918
|
+
return q(e.dataset.formieAutomaticSubmissionState, !0);
|
|
1774
1919
|
}
|
|
1775
|
-
function
|
|
1776
|
-
return
|
|
1920
|
+
function zn(e, t, n) {
|
|
1921
|
+
return Y(n.dataset.formieClearSubmissionEndpoint || e.endpoint || t.dataset.formieEndpoint, Cn);
|
|
1777
1922
|
}
|
|
1778
|
-
function
|
|
1779
|
-
return
|
|
1923
|
+
function Bn(e) {
|
|
1924
|
+
return Ln(e.dataset.formieUnloadWarning);
|
|
1780
1925
|
}
|
|
1781
|
-
function
|
|
1926
|
+
function Vn(e, t) {
|
|
1782
1927
|
e.setAttribute("data-formie-internal-navigation", t);
|
|
1783
1928
|
}
|
|
1784
|
-
function
|
|
1929
|
+
function Hn(e) {
|
|
1785
1930
|
e.removeAttribute("data-formie-internal-navigation");
|
|
1786
1931
|
}
|
|
1787
|
-
function
|
|
1932
|
+
function Un(e) {
|
|
1788
1933
|
return e.getAttribute("data-formie-internal-navigation") !== null;
|
|
1789
1934
|
}
|
|
1790
|
-
function
|
|
1935
|
+
function Wn(e, t) {
|
|
1791
1936
|
if (!e) return !1;
|
|
1792
1937
|
try {
|
|
1793
1938
|
return new URL(e, window.location.origin).searchParams.has(t);
|
|
@@ -1795,65 +1940,66 @@ function Kn(e, t) {
|
|
|
1795
1940
|
return !1;
|
|
1796
1941
|
}
|
|
1797
1942
|
}
|
|
1798
|
-
function
|
|
1799
|
-
return
|
|
1943
|
+
function Gn(e) {
|
|
1944
|
+
return Wn(window.location.href, "resumeToken") || Wn(e.getAttribute("action"), "resumeToken");
|
|
1800
1945
|
}
|
|
1801
|
-
function
|
|
1946
|
+
function Kn(e) {
|
|
1802
1947
|
return e instanceof MouseEvent ? e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey : !0;
|
|
1803
1948
|
}
|
|
1804
|
-
function
|
|
1949
|
+
function qn(e, t = 0) {
|
|
1805
1950
|
if (!e) return t;
|
|
1806
1951
|
let n = Number.parseInt(e, 10);
|
|
1807
1952
|
return Number.isFinite(n) ? n : t;
|
|
1808
1953
|
}
|
|
1809
|
-
function
|
|
1810
|
-
return Math.max(0,
|
|
1954
|
+
function Jn(e) {
|
|
1955
|
+
return Math.max(0, qn(e.dataset.formieSubmitDelay, _n));
|
|
1811
1956
|
}
|
|
1812
|
-
function
|
|
1813
|
-
return
|
|
1957
|
+
function X(e) {
|
|
1958
|
+
return Ln(e.dataset.formieValidationOnSubmit);
|
|
1814
1959
|
}
|
|
1815
|
-
async function
|
|
1816
|
-
let t =
|
|
1960
|
+
async function Yn(e) {
|
|
1961
|
+
let t = Jn(e);
|
|
1817
1962
|
t < 1 || await new Promise((e) => {
|
|
1818
1963
|
window.setTimeout(e, t);
|
|
1819
1964
|
});
|
|
1820
1965
|
}
|
|
1821
|
-
function
|
|
1966
|
+
function Z(e, t) {
|
|
1822
1967
|
let n = e?.getAttribute(t)?.trim();
|
|
1823
1968
|
if (!n) return null;
|
|
1824
1969
|
try {
|
|
1825
1970
|
return JSON.parse(n);
|
|
1826
1971
|
} catch (e) {
|
|
1972
|
+
if (t === "data-formie-modules") throw Error("Invalid browser-module manifest JSON. Update Formie and its browser packages together.");
|
|
1827
1973
|
return console.error(`[formie] Failed to parse ${t}.`, e), null;
|
|
1828
1974
|
}
|
|
1829
1975
|
}
|
|
1830
|
-
function
|
|
1976
|
+
function Xn(e, t) {
|
|
1831
1977
|
let n = t || (e instanceof HTMLFormElement ? e : null);
|
|
1832
1978
|
if (!n) return null;
|
|
1833
|
-
let r =
|
|
1979
|
+
let r = Z(n, "data-formie-modules"), i = Z(n, "data-formie-theme-classes") || Z(n, "data-formie-theme");
|
|
1834
1980
|
return !r && !i ? null : {
|
|
1835
1981
|
modules: r || void 0,
|
|
1836
1982
|
theme: i || void 0
|
|
1837
1983
|
};
|
|
1838
1984
|
}
|
|
1839
|
-
function
|
|
1985
|
+
function Zn(e) {
|
|
1840
1986
|
if (!(e instanceof HTMLElement)) return !0;
|
|
1841
1987
|
if (!e.isConnected || e.hidden || e.closest("[hidden]")) return !1;
|
|
1842
1988
|
let t = window.getComputedStyle(e);
|
|
1843
1989
|
return t.display === "none" || t.visibility === "hidden" ? !1 : e.getClientRects().length > 0;
|
|
1844
1990
|
}
|
|
1845
|
-
function
|
|
1991
|
+
function Qn(e, t) {
|
|
1846
1992
|
return t === document ? !0 : t instanceof Element ? t === e || t.contains(e) : !0;
|
|
1847
1993
|
}
|
|
1848
1994
|
function Q(e) {
|
|
1849
1995
|
let t = e, n = t.id ? `#${t.id}` : "", r = t.dataset?.formieHandle ? `[handle="${t.dataset.formieHandle}"]` : "";
|
|
1850
1996
|
return `${t.tagName ? t.tagName.toLowerCase() : "element"}${n}${r}`;
|
|
1851
1997
|
}
|
|
1852
|
-
function
|
|
1998
|
+
function $n(e, t) {
|
|
1853
1999
|
if (t) {
|
|
1854
2000
|
if (t.csrf?.param && t.csrf?.token) {
|
|
1855
2001
|
let n = e.querySelector(`input[name="${t.csrf.param}"]`);
|
|
1856
|
-
n ? n.value = t.csrf.token : (n = document.createElement("input"), n.type = "hidden", n.name = t.csrf.param, n.value = t.csrf.token, n.setAttribute("autocomplete", "off"), e.prepend(n));
|
|
2002
|
+
n ? n.value = t.csrf.token : (n = document.createElement("input"), n.type = "hidden", n.name = t.csrf.param, n.value = t.csrf.token, n.setAttribute("autocomplete", "off"), n.setAttribute("data-formie-csrf", ""), e.prepend(n));
|
|
1857
2003
|
}
|
|
1858
2004
|
if (t.requestToken) {
|
|
1859
2005
|
let n = e.querySelector("input[name=\"requestToken\"]");
|
|
@@ -1863,6 +2009,10 @@ function nr(e, t) {
|
|
|
1863
2009
|
let n = e.querySelector("input[name=\"renderId\"]");
|
|
1864
2010
|
n && (n.value = t.renderId);
|
|
1865
2011
|
}
|
|
2012
|
+
if (t.uploadCreateToken) {
|
|
2013
|
+
let n = e.querySelector("input[name=\"uploadCreateToken\"]");
|
|
2014
|
+
n || (n = document.createElement("input"), n.type = "hidden", n.name = "uploadCreateToken", e.append(n)), n.value = t.uploadCreateToken;
|
|
2015
|
+
}
|
|
1866
2016
|
t.captchas && typeof t.captchas == "object" && Object.values(t.captchas).forEach((t) => {
|
|
1867
2017
|
if (!t || typeof t != "object") return;
|
|
1868
2018
|
let n = t;
|
|
@@ -1872,12 +2022,11 @@ function nr(e, t) {
|
|
|
1872
2022
|
});
|
|
1873
2023
|
}
|
|
1874
2024
|
}
|
|
1875
|
-
async function
|
|
1876
|
-
let n =
|
|
2025
|
+
async function er(e, t) {
|
|
2026
|
+
let n = Dn(t.mode), r = On(t.transport);
|
|
1877
2027
|
if (n !== "server-rendered") return null;
|
|
1878
2028
|
if (t.payload) return t.payload.html && (e.innerHTML = t.payload.html), t.payload;
|
|
1879
|
-
|
|
1880
|
-
let i = !!Y(e), a = t.formHandle || e.dataset.formieHandle;
|
|
2029
|
+
let i = !!kn(e), a = t.formHandle || e.dataset.formieHandle;
|
|
1881
2030
|
if (i || !a) return null;
|
|
1882
2031
|
let o = {
|
|
1883
2032
|
mode: n,
|
|
@@ -1886,33 +2035,36 @@ async function rr(e, t) {
|
|
|
1886
2035
|
siteId: t.siteId,
|
|
1887
2036
|
theme: t.theme,
|
|
1888
2037
|
themeConfig: t.themeConfig
|
|
1889
|
-
}, s = r === "graphql" ?
|
|
2038
|
+
}, s = r === "graphql" ? Nn(t, e) : Mn(t, e), c = r === "graphql" ? await Ge(s, a, o, t) : await We(s, a, {
|
|
1890
2039
|
...o,
|
|
1891
2040
|
endpoint: s
|
|
1892
|
-
});
|
|
2041
|
+
}, t);
|
|
1893
2042
|
return c?.html && (e.innerHTML = c.html), c;
|
|
1894
2043
|
}
|
|
1895
|
-
async function
|
|
2044
|
+
async function tr(e, t, n) {
|
|
1896
2045
|
if (t.refreshTokens === !1) return;
|
|
1897
|
-
Rn(J(t.transport), q(t.mode));
|
|
1898
2046
|
let r = t.formHandle || e.dataset.formieHandle;
|
|
1899
2047
|
if (!r) return;
|
|
1900
|
-
let i = await
|
|
1901
|
-
|
|
2048
|
+
let i = await Ke(Pn(t, e), r, n.querySelector("input[name=\"renderId\"]")?.value || void 0, t, n?.querySelector("input[name=\"requestToken\"]")?.value);
|
|
2049
|
+
$n(n, i), y(e, "formie:refresh-tokens:refreshed", i);
|
|
1902
2050
|
}
|
|
1903
|
-
function
|
|
1904
|
-
let o =
|
|
2051
|
+
function nr(e, t, n, r, i, a) {
|
|
2052
|
+
let o = () => {};
|
|
2053
|
+
t.dataset.formieRequestProfile = n.profile ?? "same-origin-browser", n.profile === "cross-origin-public" && (t.dataset.formieSubmitMethod = "ajax");
|
|
2054
|
+
let s = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), c = zn(n, e, t), l = !1, u = t.querySelectorAll("[data-formie-action]"), d = (e) => {
|
|
1905
2055
|
if (e) {
|
|
1906
2056
|
t.setAttribute("data-formie-pending-action", e);
|
|
1907
2057
|
return;
|
|
1908
2058
|
}
|
|
1909
2059
|
t.removeAttribute("data-formie-pending-action");
|
|
1910
2060
|
};
|
|
1911
|
-
if (
|
|
1912
|
-
let n =
|
|
2061
|
+
if (Bn(t)) {
|
|
2062
|
+
let n = rn(t, { shouldWarn: () => !Un(t) });
|
|
2063
|
+
o = n.scheduleBaselineCapture;
|
|
2064
|
+
let r = (e) => {
|
|
1913
2065
|
if (!(e instanceof CustomEvent)) return;
|
|
1914
2066
|
let t = e.detail;
|
|
1915
|
-
t?.ok && t.action === "save" && n.scheduleBaselineCapture();
|
|
2067
|
+
t?.ok && (t.action === "save" || t.outcome === "revised") && n.scheduleBaselineCapture();
|
|
1916
2068
|
}, i = () => {
|
|
1917
2069
|
n.scheduleBaselineCapture();
|
|
1918
2070
|
};
|
|
@@ -1923,32 +2075,38 @@ function ar(e, t, n, r, i, a) {
|
|
|
1923
2075
|
if (u.forEach((e) => {
|
|
1924
2076
|
let n = (e) => {
|
|
1925
2077
|
let n = e.currentTarget.getAttribute("data-formie-action"), r = t.querySelector("input[name=\"submitAction\"]");
|
|
1926
|
-
|
|
2078
|
+
d(n), n && r && (r.value = n);
|
|
1927
2079
|
};
|
|
1928
2080
|
e.addEventListener("click", n), a.push(() => {
|
|
1929
2081
|
e.removeEventListener("click", n);
|
|
1930
2082
|
});
|
|
1931
2083
|
}), t.querySelectorAll("[data-formie-tab-link]").forEach((n) => {
|
|
1932
2084
|
let r = async (n) => {
|
|
1933
|
-
if (
|
|
1934
|
-
|
|
2085
|
+
if (s !== "ajax") {
|
|
2086
|
+
Kn(n) && Vn(t, "set-page");
|
|
1935
2087
|
return;
|
|
1936
2088
|
}
|
|
1937
2089
|
n.preventDefault();
|
|
1938
2090
|
let r = n.currentTarget, i = r?.getAttribute("data-formie-page-id"), a = r?.getAttribute("href");
|
|
1939
|
-
if (
|
|
1940
|
-
|
|
2091
|
+
if (i && a) {
|
|
2092
|
+
y(e, "formie:page:navigate", {
|
|
1941
2093
|
pageId: i,
|
|
1942
2094
|
href: a
|
|
1943
2095
|
});
|
|
1944
2096
|
try {
|
|
1945
|
-
|
|
2097
|
+
let n = await qe(a, t, i);
|
|
2098
|
+
if (n.pageId && _(t, String(n.pageId)), !n.success) {
|
|
2099
|
+
let { form: e = [], ...r } = n.errors ?? {};
|
|
2100
|
+
z(t), Ot(t, r), kt(t, e), Ve(t);
|
|
2101
|
+
return;
|
|
2102
|
+
}
|
|
2103
|
+
y(e, "formie:page:navigate:after", {
|
|
1946
2104
|
pageId: i,
|
|
1947
2105
|
href: a,
|
|
1948
|
-
response:
|
|
2106
|
+
response: n
|
|
1949
2107
|
});
|
|
1950
2108
|
} catch (t) {
|
|
1951
|
-
console.error("[formie] Failed to persist page navigation state.", t),
|
|
2109
|
+
console.error("[formie] Failed to persist page navigation state.", t), y(e, "formie:page:navigate:error", {
|
|
1952
2110
|
pageId: i,
|
|
1953
2111
|
href: a,
|
|
1954
2112
|
error: t
|
|
@@ -1959,50 +2117,50 @@ function ar(e, t, n, r, i, a) {
|
|
|
1959
2117
|
n.addEventListener("click", r), a.push(() => {
|
|
1960
2118
|
n.removeEventListener("click", r);
|
|
1961
2119
|
});
|
|
1962
|
-
}), !
|
|
2120
|
+
}), !Rn(t)) {
|
|
1963
2121
|
let e = !1, n = () => {
|
|
1964
|
-
e ||
|
|
2122
|
+
e || Un(t) || Gn(t) || (e = !0, Je(c, t));
|
|
1965
2123
|
};
|
|
1966
2124
|
window.addEventListener("pagehide", n), window.addEventListener("beforeunload", n), a.push(() => {
|
|
1967
2125
|
window.removeEventListener("pagehide", n), window.removeEventListener("beforeunload", n);
|
|
1968
2126
|
});
|
|
1969
2127
|
}
|
|
1970
|
-
let
|
|
1971
|
-
if (
|
|
1972
|
-
let
|
|
2128
|
+
let f = async (a) => {
|
|
2129
|
+
if (l) return;
|
|
2130
|
+
let o = s === "ajax";
|
|
1973
2131
|
if (a.preventDefault(), t.getAttribute("data-formie-loading") === "true") {
|
|
1974
2132
|
if (t.getAttribute("data-formie-internal-resubmit") !== "true") return;
|
|
1975
2133
|
t.removeAttribute("data-formie-internal-resubmit");
|
|
1976
2134
|
} else t.removeAttribute("data-formie-internal-resubmit");
|
|
1977
|
-
let
|
|
2135
|
+
let c = a.submitter, u = c?.getAttribute("data-formie-action"), f = t.getAttribute("data-formie-pending-action"), m = t.querySelector("input[name=\"submitAction\"]"), _ = u || f || m?.value || "submit", b = null, x = !1;
|
|
1978
2136
|
try {
|
|
1979
|
-
if (
|
|
2137
|
+
if (o) b = await Lt({
|
|
1980
2138
|
target: e,
|
|
1981
2139
|
form: t,
|
|
1982
2140
|
bus: r,
|
|
1983
2141
|
validator: i,
|
|
1984
|
-
validateOnSubmit:
|
|
1985
|
-
action:
|
|
1986
|
-
submitter:
|
|
1987
|
-
waitForSubmitDelay:
|
|
2142
|
+
validateOnSubmit: X(t),
|
|
2143
|
+
action: _,
|
|
2144
|
+
submitter: c,
|
|
2145
|
+
waitForSubmitDelay: Yn,
|
|
1988
2146
|
onRefreshTokensAfterSubmit: async () => {
|
|
1989
|
-
await
|
|
2147
|
+
await tr(e, n, t);
|
|
1990
2148
|
},
|
|
1991
2149
|
dispatchSubmitResult: (t) => {
|
|
1992
|
-
|
|
2150
|
+
y(e, "formie:submit:result", t);
|
|
1993
2151
|
}
|
|
1994
2152
|
});
|
|
1995
2153
|
else {
|
|
1996
|
-
if (
|
|
2154
|
+
if (z(t), v(t, c), await Yn(t), b = await st(t, _, r, {
|
|
1997
2155
|
validator: i,
|
|
1998
|
-
validateOnSubmit:
|
|
2156
|
+
validateOnSubmit: X(t),
|
|
1999
2157
|
preflightOnly: !0
|
|
2000
2158
|
}), b.ok) {
|
|
2001
|
-
|
|
2159
|
+
p(t, _), l = !0, Vn(t, "submit"), d(null);
|
|
2002
2160
|
let e = !1, n = () => {
|
|
2003
|
-
if (e = !0,
|
|
2004
|
-
let { scope: e, final: n } =
|
|
2005
|
-
r.length > 0 &&
|
|
2161
|
+
if (e = !0, l = !1, Hn(t), h(t), i && X(t)) {
|
|
2162
|
+
let { scope: e, final: n } = g(t), r = i.submit(n ? t : e, { final: n });
|
|
2163
|
+
r.length > 0 && R(t, {
|
|
2006
2164
|
ok: !1,
|
|
2007
2165
|
stage: "validate",
|
|
2008
2166
|
code: "VALIDATION_FAILED",
|
|
@@ -2024,153 +2182,166 @@ function ar(e, t, n, r, i, a) {
|
|
|
2024
2182
|
x = !0;
|
|
2025
2183
|
return;
|
|
2026
2184
|
}
|
|
2027
|
-
|
|
2185
|
+
R(t, b), y(e, "formie:submit:result", b), Hn(t);
|
|
2028
2186
|
}
|
|
2029
2187
|
} catch (n) {
|
|
2030
|
-
|
|
2188
|
+
l = !1, b = {
|
|
2031
2189
|
ok: !1,
|
|
2032
2190
|
code: "SUBMIT_ERROR",
|
|
2033
2191
|
message: n instanceof Error ? n.message : "Submission failed.",
|
|
2034
2192
|
formErrors: [n instanceof Error ? n.message : "Submission failed."]
|
|
2035
|
-
},
|
|
2193
|
+
}, R(t, b), y(e, "formie:submit:result", b), Hn(t);
|
|
2036
2194
|
} finally {
|
|
2037
|
-
|
|
2195
|
+
d(null), !o && !x && !It(b) && h(t);
|
|
2038
2196
|
}
|
|
2039
2197
|
};
|
|
2040
|
-
t.addEventListener("submit",
|
|
2041
|
-
t.removeEventListener("submit",
|
|
2042
|
-
});
|
|
2198
|
+
return t.addEventListener("submit", f), a.push(() => {
|
|
2199
|
+
t.removeEventListener("submit", f);
|
|
2200
|
+
}), o;
|
|
2043
2201
|
}
|
|
2044
|
-
async function
|
|
2202
|
+
async function rr(e, t, n) {
|
|
2045
2203
|
if (t.refreshTokens === !1 || !t.staticCache) return;
|
|
2046
|
-
|
|
2047
|
-
let r = t.formHandle || e.dataset.formieHandle, i = Fn(t, e), a = n?.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2204
|
+
let r = t.formHandle || e.dataset.formieHandle, i = Pn(t, e), a = n?.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2048
2205
|
if (!r) return;
|
|
2049
|
-
let o = await
|
|
2050
|
-
|
|
2206
|
+
let o = await Ke(i, r, a, t, n?.querySelector("input[name=\"requestToken\"]")?.value);
|
|
2207
|
+
o && n && ($n(n, o), y(e, "formie:refresh-tokens:after", o));
|
|
2051
2208
|
}
|
|
2052
|
-
function
|
|
2053
|
-
let
|
|
2209
|
+
function ir() {
|
|
2210
|
+
let t = /* @__PURE__ */ new Map(), r = new B(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = [
|
|
2054
2211
|
"prepare",
|
|
2055
2212
|
"normalize",
|
|
2056
2213
|
"validate",
|
|
2057
|
-
"
|
|
2058
|
-
"
|
|
2059
|
-
"
|
|
2060
|
-
"
|
|
2061
|
-
],
|
|
2062
|
-
let
|
|
2063
|
-
if (
|
|
2064
|
-
await
|
|
2214
|
+
"challenge",
|
|
2215
|
+
"payment",
|
|
2216
|
+
"send",
|
|
2217
|
+
"result"
|
|
2218
|
+
], s = async (e) => {
|
|
2219
|
+
let n = a.get(e);
|
|
2220
|
+
if (n) {
|
|
2221
|
+
await n;
|
|
2065
2222
|
return;
|
|
2066
2223
|
}
|
|
2067
|
-
let
|
|
2068
|
-
|
|
2069
|
-
let
|
|
2070
|
-
|
|
2071
|
-
let
|
|
2072
|
-
if (!
|
|
2073
|
-
|
|
2224
|
+
let r = (async () => {
|
|
2225
|
+
K.log("Unmount requested.", { target: Q(e) });
|
|
2226
|
+
let n = i.get(e);
|
|
2227
|
+
n && (n(), i.delete(e));
|
|
2228
|
+
let r = t.get(e);
|
|
2229
|
+
if (!r) {
|
|
2230
|
+
K.log("Unmount skipped (no mounted state).", { target: Q(e) });
|
|
2074
2231
|
return;
|
|
2075
2232
|
}
|
|
2076
|
-
|
|
2233
|
+
y(e, "formie:unmount:before", { id: r.instance.id }), r.unbinds.forEach((e) => {
|
|
2077
2234
|
e();
|
|
2078
|
-
}),
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
id: i.instance.id,
|
|
2082
|
-
target: Q(t)
|
|
2235
|
+
}), r.unbinds = [], r.validator?.destroy(), r.validator = null, await r.modules.destroy(), r.bus.clear(), t.delete(e), y(e, "formie:unmount:after", { id: r.instance.id }), K.log("Unmount complete.", {
|
|
2236
|
+
id: r.instance.id,
|
|
2237
|
+
target: Q(e)
|
|
2083
2238
|
});
|
|
2084
2239
|
})().finally(() => {
|
|
2085
|
-
|
|
2240
|
+
a.delete(e);
|
|
2086
2241
|
});
|
|
2087
|
-
|
|
2088
|
-
},
|
|
2089
|
-
|
|
2090
|
-
target: Q(
|
|
2091
|
-
mode:
|
|
2092
|
-
autoVisible:
|
|
2242
|
+
a.set(e, r), await r;
|
|
2243
|
+
}, c = async (a, c) => {
|
|
2244
|
+
K.log("Mount requested.", {
|
|
2245
|
+
target: Q(a),
|
|
2246
|
+
mode: c.mode,
|
|
2247
|
+
autoVisible: c.autoVisible
|
|
2093
2248
|
});
|
|
2094
|
-
let
|
|
2095
|
-
|
|
2096
|
-
let
|
|
2097
|
-
if (
|
|
2098
|
-
id:
|
|
2099
|
-
target: Q(
|
|
2100
|
-
}),
|
|
2101
|
-
let
|
|
2102
|
-
...
|
|
2103
|
-
...
|
|
2104
|
-
mode:
|
|
2105
|
-
transport:
|
|
2106
|
-
},
|
|
2107
|
-
|
|
2108
|
-
let
|
|
2109
|
-
|
|
2110
|
-
|
|
2249
|
+
let l = i.get(a);
|
|
2250
|
+
l && (l(), i.delete(a));
|
|
2251
|
+
let u = t.get(a);
|
|
2252
|
+
if (u) return K.log("Mount skipped (already mounted).", {
|
|
2253
|
+
id: u.instance.id,
|
|
2254
|
+
target: Q(a)
|
|
2255
|
+
}), u.instance;
|
|
2256
|
+
let d = new Rt(), f = [], p = a?.id || `formie-${t.size + 1}`, h = J(a), g = {
|
|
2257
|
+
...h,
|
|
2258
|
+
...c,
|
|
2259
|
+
mode: Dn(c.mode ?? h.mode),
|
|
2260
|
+
transport: On(c.transport ?? h.transport)
|
|
2261
|
+
}, _ = Ce(g.compatibility), v = await er(a, g), b = kn(a);
|
|
2262
|
+
b && e(b, g), g.staticCache = c.staticCache ?? En(b ? b.dataset : a.dataset);
|
|
2263
|
+
let S;
|
|
2264
|
+
try {
|
|
2265
|
+
S = Xn(a, b), v?.modules && n(v.modules), S?.modules && n(S.modules);
|
|
2266
|
+
} catch (e) {
|
|
2267
|
+
if (b) {
|
|
2268
|
+
b.addEventListener("submit", (e) => {
|
|
2269
|
+
e.preventDefault(), e.stopImmediatePropagation();
|
|
2270
|
+
}, !0);
|
|
2271
|
+
let e = document.createElement("div");
|
|
2272
|
+
e.setAttribute("role", "alert"), e.textContent = "This form requires a compatible Formie browser package. Update Formie and its browser packages together.", b.prepend(e);
|
|
2273
|
+
}
|
|
2274
|
+
throw e;
|
|
2275
|
+
}
|
|
2276
|
+
let ee = v || S ? {
|
|
2111
2277
|
...v || {},
|
|
2112
|
-
...
|
|
2113
|
-
} : null, te = ee?.theme,
|
|
2114
|
-
|
|
2115
|
-
|
|
2278
|
+
...S || {}
|
|
2279
|
+
} : null, te = ee?.theme, ne = {}, w = ee?.modules ?? {
|
|
2280
|
+
contractVersion: 2,
|
|
2281
|
+
surface: "server-rendered",
|
|
2282
|
+
entries: []
|
|
2283
|
+
};
|
|
2284
|
+
n(w), K.log("Resolved mount payload.", {
|
|
2285
|
+
target: Q(a),
|
|
2116
2286
|
hasRenderPayload: !!v,
|
|
2117
|
-
hasEmbeddedPayload: !!
|
|
2118
|
-
moduleCount:
|
|
2287
|
+
hasEmbeddedPayload: !!S,
|
|
2288
|
+
moduleCount: w.entries.length
|
|
2119
2289
|
});
|
|
2120
|
-
let
|
|
2121
|
-
live:
|
|
2122
|
-
errorAriaLive:
|
|
2290
|
+
let T = re(a, te, b), E = b ? new dn(b, {
|
|
2291
|
+
live: Ln(b.dataset.formieValidationOnFocus),
|
|
2292
|
+
errorAriaLive: M(b),
|
|
2123
2293
|
errorMessage: b.dataset.formieErrorMessage || "",
|
|
2124
|
-
fieldContainerErrorClass:
|
|
2125
|
-
inputErrorClass:
|
|
2126
|
-
messagesClass:
|
|
2127
|
-
messageClass:
|
|
2294
|
+
fieldContainerErrorClass: T.fieldLayoutError || [],
|
|
2295
|
+
inputErrorClass: T.fieldControlError || [],
|
|
2296
|
+
messagesClass: T.fieldErrors || [],
|
|
2297
|
+
messageClass: T.fieldError || []
|
|
2128
2298
|
}) : null;
|
|
2129
|
-
if (b &&
|
|
2299
|
+
if (b && E) {
|
|
2130
2300
|
let e = b;
|
|
2131
|
-
e.formieValidation =
|
|
2301
|
+
e.formieValidation = E, ne.validation = E;
|
|
2132
2302
|
let t = {
|
|
2133
|
-
validator:
|
|
2134
|
-
addValidator:
|
|
2135
|
-
removeValidator:
|
|
2303
|
+
validator: E,
|
|
2304
|
+
addValidator: E.addValidator.bind(E),
|
|
2305
|
+
removeValidator: E.removeValidator.bind(E)
|
|
2136
2306
|
};
|
|
2137
|
-
|
|
2307
|
+
y(b, "formie:validator:ready", t), y(a, "formie:validator:ready", t);
|
|
2138
2308
|
}
|
|
2139
|
-
b && (
|
|
2140
|
-
let
|
|
2141
|
-
registry:
|
|
2309
|
+
b && (Qt(b), g.theme && g.theme !== "formie" && b.setAttribute("data-formie-frontend-theme", g.theme), (v || g.endpoint || a.dataset.formieEndpoint) && In(a, b, g), g.mode === "server-rendered" && Be(b) && (ze(b), Ve(b)), C(b)), Object.keys(T).length && y(a, "formie:theme:applied", { hasClasses: !0 });
|
|
2310
|
+
let D = await Xt(w, {
|
|
2311
|
+
registry: r,
|
|
2142
2312
|
matchContext: {
|
|
2143
|
-
root:
|
|
2313
|
+
root: a,
|
|
2144
2314
|
form: b,
|
|
2145
|
-
|
|
2315
|
+
surface: w.surface
|
|
2146
2316
|
},
|
|
2147
2317
|
setupContext: {
|
|
2148
|
-
formId:
|
|
2149
|
-
root:
|
|
2318
|
+
formId: p,
|
|
2319
|
+
root: a,
|
|
2150
2320
|
form: b,
|
|
2151
|
-
target:
|
|
2321
|
+
target: a,
|
|
2152
2322
|
scope: "form",
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2323
|
+
surface: w.surface,
|
|
2324
|
+
state: ne,
|
|
2325
|
+
on: (e, t) => d.on(e, t),
|
|
2326
|
+
emit: (e, t) => (y(a, e, t), d.emitSafe(e, t).then((t) => {
|
|
2327
|
+
t.failed.length > 0 && K.warn("Lifecycle listeners failed.", {
|
|
2157
2328
|
eventName: e,
|
|
2158
2329
|
failed: t.failed.length
|
|
2159
2330
|
});
|
|
2160
2331
|
}))
|
|
2161
2332
|
}
|
|
2162
2333
|
});
|
|
2163
|
-
|
|
2164
|
-
target: Q(
|
|
2165
|
-
moduleInstances:
|
|
2334
|
+
K.log("Module setup complete.", {
|
|
2335
|
+
target: Q(a),
|
|
2336
|
+
moduleInstances: D.instances.length
|
|
2166
2337
|
});
|
|
2167
|
-
let
|
|
2168
|
-
id:
|
|
2169
|
-
root:
|
|
2338
|
+
let O = {
|
|
2339
|
+
id: p,
|
|
2340
|
+
root: a,
|
|
2170
2341
|
submit: async (e = "submit") => {
|
|
2171
|
-
if (
|
|
2172
|
-
id:
|
|
2173
|
-
target: Q(
|
|
2342
|
+
if (K.log("Submit requested.", {
|
|
2343
|
+
id: p,
|
|
2344
|
+
target: Q(a),
|
|
2174
2345
|
action: e
|
|
2175
2346
|
}), !b) return {
|
|
2176
2347
|
ok: !1,
|
|
@@ -2185,113 +2356,145 @@ function sr() {
|
|
|
2185
2356
|
message: "Submission already in progress.",
|
|
2186
2357
|
formErrors: []
|
|
2187
2358
|
};
|
|
2188
|
-
let n = b.querySelector(`[data-formie-action="${e}"]`),
|
|
2189
|
-
id:
|
|
2190
|
-
target:
|
|
2359
|
+
let n = b.querySelector(`[data-formie-action="${e}"]`), r = await Lt({
|
|
2360
|
+
id: p,
|
|
2361
|
+
target: a,
|
|
2191
2362
|
form: b,
|
|
2192
|
-
bus:
|
|
2193
|
-
validator:
|
|
2194
|
-
validateOnSubmit:
|
|
2363
|
+
bus: d,
|
|
2364
|
+
validator: E,
|
|
2365
|
+
validateOnSubmit: X(b),
|
|
2195
2366
|
action: e,
|
|
2196
2367
|
submitter: n,
|
|
2197
|
-
waitForSubmitDelay:
|
|
2368
|
+
waitForSubmitDelay: Yn,
|
|
2198
2369
|
onRefreshTokensAfterSubmit: async () => {
|
|
2199
|
-
await
|
|
2370
|
+
await tr(a, g, b);
|
|
2200
2371
|
},
|
|
2201
2372
|
dispatchSubmitResult: (e) => {
|
|
2202
|
-
|
|
2373
|
+
y(a, "formie:submit:result", e);
|
|
2203
2374
|
}
|
|
2204
2375
|
});
|
|
2205
|
-
return
|
|
2206
|
-
id:
|
|
2376
|
+
return K.log("Submit completed.", {
|
|
2377
|
+
id: p,
|
|
2207
2378
|
action: e,
|
|
2208
|
-
ok:
|
|
2209
|
-
code:
|
|
2210
|
-
message:
|
|
2211
|
-
}),
|
|
2379
|
+
ok: r.ok,
|
|
2380
|
+
code: r.code,
|
|
2381
|
+
message: r.message
|
|
2382
|
+
}), r;
|
|
2212
2383
|
},
|
|
2213
2384
|
destroy: async () => {
|
|
2214
|
-
await a
|
|
2385
|
+
await s(a);
|
|
2215
2386
|
},
|
|
2216
|
-
on: (e, t) =>
|
|
2387
|
+
on: (e, t) => d.on(e, t)
|
|
2217
2388
|
};
|
|
2218
|
-
b && (
|
|
2219
|
-
target:
|
|
2389
|
+
if (b && (ke({
|
|
2390
|
+
target: a,
|
|
2220
2391
|
form: b,
|
|
2221
|
-
validatorDetail:
|
|
2222
|
-
validator:
|
|
2223
|
-
addValidator:
|
|
2224
|
-
removeValidator:
|
|
2392
|
+
validatorDetail: E ? {
|
|
2393
|
+
validator: E,
|
|
2394
|
+
addValidator: E.addValidator.bind(E),
|
|
2395
|
+
removeValidator: E.removeValidator.bind(E)
|
|
2225
2396
|
} : null,
|
|
2226
|
-
options:
|
|
2227
|
-
unbinds:
|
|
2228
|
-
}),
|
|
2229
|
-
target:
|
|
2397
|
+
options: _,
|
|
2398
|
+
unbinds: f
|
|
2399
|
+
}), Oe({
|
|
2400
|
+
target: a,
|
|
2230
2401
|
form: b,
|
|
2231
|
-
instance:
|
|
2232
|
-
options:
|
|
2233
|
-
unbinds:
|
|
2234
|
-
})), b
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
let t =
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
}),
|
|
2244
|
-
let
|
|
2245
|
-
|
|
2402
|
+
instance: O,
|
|
2403
|
+
options: _,
|
|
2404
|
+
unbinds: f
|
|
2405
|
+
})), b) {
|
|
2406
|
+
let e = nr(a, b, g, d, E, f);
|
|
2407
|
+
E && (f.push(x(b, E, a)), f.push(gn(b))), await rr(a, g, b), e();
|
|
2408
|
+
let t = window.setTimeout(e, 350);
|
|
2409
|
+
f.push(() => window.clearTimeout(t));
|
|
2410
|
+
}
|
|
2411
|
+
o.forEach((e) => {
|
|
2412
|
+
let t = d.on(`formie:stage:${e}:before`, async (t) => {
|
|
2413
|
+
y(a, `formie:stage:${e}:before`, t);
|
|
2414
|
+
}), n = d.on(`formie:stage:${e}:before`, async (t) => {
|
|
2415
|
+
let n = {
|
|
2416
|
+
core: "prepare",
|
|
2417
|
+
field: "prepare",
|
|
2418
|
+
address: "prepare",
|
|
2419
|
+
captcha: "challenge",
|
|
2420
|
+
payment: "payment"
|
|
2421
|
+
}, r = t;
|
|
2422
|
+
if (e === "prepare") try {
|
|
2423
|
+
D.assertReady();
|
|
2424
|
+
} catch {
|
|
2425
|
+
r.abort("A required form feature could not start. Reload the page or contact the site administrator.");
|
|
2426
|
+
return;
|
|
2427
|
+
}
|
|
2428
|
+
for (let t of D.instances) if (t.beforeSubmit && n[t.kind ?? "core"] === e) {
|
|
2429
|
+
let { form: e, action: n, formData: i, abort: a, isAborted: o, abortReason: s } = r;
|
|
2430
|
+
await t.beforeSubmit({
|
|
2431
|
+
form: e,
|
|
2432
|
+
action: n,
|
|
2433
|
+
formData: i,
|
|
2434
|
+
abort: a,
|
|
2435
|
+
isAborted: o,
|
|
2436
|
+
abortReason: s
|
|
2437
|
+
});
|
|
2438
|
+
}
|
|
2439
|
+
}), r = d.on(`formie:stage:${e}:after`, async (t) => {
|
|
2440
|
+
y(a, `formie:stage:${e}:after`, t);
|
|
2246
2441
|
});
|
|
2247
|
-
|
|
2442
|
+
f.push(t, n, r);
|
|
2248
2443
|
});
|
|
2249
|
-
let
|
|
2250
|
-
|
|
2251
|
-
}),
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2444
|
+
let ie = d.on("formie:submit:before", async (e) => {
|
|
2445
|
+
y(a, "formie:submit:before", e);
|
|
2446
|
+
}), k = d.on("formie:submit:after", async (e) => {
|
|
2447
|
+
if (y(a, "formie:submit:after", e), !b) return;
|
|
2448
|
+
let t = e;
|
|
2449
|
+
if (t.code === "PREFLIGHT_COMPLETE") return;
|
|
2450
|
+
let n = {
|
|
2451
|
+
form: b,
|
|
2452
|
+
action: t.action ?? "submit",
|
|
2453
|
+
formData: new FormData(b)
|
|
2454
|
+
};
|
|
2455
|
+
for (let e of D.instances) await e.afterSubmit?.(n, t);
|
|
2456
|
+
}), ae = d.on("formie:submit:final:before", async (e) => {
|
|
2457
|
+
y(a, "formie:submit:final:before", e);
|
|
2458
|
+
}), oe = d.on("formie:submit:final:after", async (e) => {
|
|
2459
|
+
y(a, "formie:submit:final:after", e);
|
|
2257
2460
|
});
|
|
2258
|
-
return
|
|
2259
|
-
options:
|
|
2260
|
-
bus:
|
|
2461
|
+
return f.push(ie, k, ae, oe), t.set(a, {
|
|
2462
|
+
options: g,
|
|
2463
|
+
bus: d,
|
|
2261
2464
|
form: b,
|
|
2262
|
-
validator:
|
|
2263
|
-
modules:
|
|
2264
|
-
unbinds:
|
|
2265
|
-
instance:
|
|
2266
|
-
}),
|
|
2267
|
-
id:
|
|
2268
|
-
mode:
|
|
2269
|
-
}), b instanceof HTMLFormElement &&
|
|
2270
|
-
id:
|
|
2271
|
-
target: Q(
|
|
2272
|
-
mode:
|
|
2273
|
-
}),
|
|
2274
|
-
},
|
|
2275
|
-
if (!
|
|
2276
|
-
if (
|
|
2277
|
-
if (
|
|
2278
|
-
let
|
|
2279
|
-
|
|
2280
|
-
...
|
|
2465
|
+
validator: E,
|
|
2466
|
+
modules: D,
|
|
2467
|
+
unbinds: f,
|
|
2468
|
+
instance: O
|
|
2469
|
+
}), y(a, "formie:mount:after", {
|
|
2470
|
+
id: p,
|
|
2471
|
+
mode: g.mode
|
|
2472
|
+
}), b instanceof HTMLFormElement && m(b), K.log("Mount complete.", {
|
|
2473
|
+
id: p,
|
|
2474
|
+
target: Q(a),
|
|
2475
|
+
mode: g.mode
|
|
2476
|
+
}), O;
|
|
2477
|
+
}, l = (e, n) => {
|
|
2478
|
+
if (!n.autoVisible || Zn(e) || typeof IntersectionObserver > "u") return c(e, n);
|
|
2479
|
+
if (t.has(e)) return Promise.resolve(t.get(e)?.instance || null);
|
|
2480
|
+
if (i.has(e)) return K.log("Mount deferred (already waiting visibility).", { target: Q(e) }), Promise.resolve(null);
|
|
2481
|
+
let r = new IntersectionObserver((t) => {
|
|
2482
|
+
t.some((t) => t.target === e && t.isIntersecting) && (r.disconnect(), i.delete(e), K.log("Visibility reached, proceeding mount.", { target: Q(e) }), c(e, {
|
|
2483
|
+
...n,
|
|
2281
2484
|
autoVisible: !1
|
|
2282
2485
|
}));
|
|
2283
2486
|
}, { threshold: .01 });
|
|
2284
|
-
return
|
|
2285
|
-
|
|
2286
|
-
}),
|
|
2487
|
+
return r.observe(e), i.set(e, () => {
|
|
2488
|
+
r.disconnect();
|
|
2489
|
+
}), K.log("Mount deferred until visible.", { target: Q(e) }), Promise.resolve(null);
|
|
2287
2490
|
};
|
|
2288
2491
|
return {
|
|
2289
|
-
mount:
|
|
2290
|
-
unmount:
|
|
2291
|
-
update: async (
|
|
2292
|
-
let r =
|
|
2293
|
-
if (!r) return
|
|
2294
|
-
...
|
|
2492
|
+
mount: c,
|
|
2493
|
+
unmount: s,
|
|
2494
|
+
update: async (e, n) => {
|
|
2495
|
+
let r = t.get(e);
|
|
2496
|
+
if (!r) return c(e, {
|
|
2497
|
+
...J(e),
|
|
2295
2498
|
...n,
|
|
2296
2499
|
mode: n.mode || "server-rendered"
|
|
2297
2500
|
});
|
|
@@ -2299,79 +2502,82 @@ function sr() {
|
|
|
2299
2502
|
...r.options,
|
|
2300
2503
|
...n
|
|
2301
2504
|
};
|
|
2302
|
-
let i =
|
|
2303
|
-
return r.validator && (r.validator.config.fieldContainerErrorClass =
|
|
2505
|
+
let i = n.payload?.theme || r.options.payload?.theme || Xn(e, r.form)?.theme, a = re(e, i, r.form);
|
|
2506
|
+
return r.validator && (r.validator.config.fieldContainerErrorClass = a.fieldLayoutError || [], r.validator.config.inputErrorClass = a.fieldControlError || [], r.validator.config.messagesClass = a.fieldErrors || [], r.validator.config.messageClass = a.fieldError || []), Object.keys(a).length && y(e, "formie:theme:applied", {
|
|
2304
2507
|
hasClasses: !0,
|
|
2305
2508
|
reason: "update"
|
|
2306
2509
|
}), r.instance;
|
|
2307
2510
|
},
|
|
2308
|
-
getInstance: (
|
|
2309
|
-
refreshForCache: async (
|
|
2310
|
-
|
|
2511
|
+
getInstance: (e) => t.get(e)?.instance || null,
|
|
2512
|
+
refreshForCache: async (e) => {
|
|
2513
|
+
An("refreshForCache", "Global `Formie.refreshForCache()` has been deprecated. Use built-in static-cache token refresh handling instead.");
|
|
2311
2514
|
let n = null;
|
|
2312
|
-
if (n = typeof
|
|
2313
|
-
|
|
2515
|
+
if (n = typeof e == "string" ? document.getElementById(e) || document.querySelector(`[data-formie-form-id="${e}"]`) : e, !n) {
|
|
2516
|
+
K.warn("refreshForCache target not found.", { targetOrId: e });
|
|
2314
2517
|
return;
|
|
2315
2518
|
}
|
|
2316
|
-
let r =
|
|
2519
|
+
let r = t.get(n), i = kn(n), a = r?.options || J(n);
|
|
2317
2520
|
if (!i) {
|
|
2318
|
-
|
|
2521
|
+
K.warn("refreshForCache found no form element for target.", { target: Q(n) });
|
|
2319
2522
|
return;
|
|
2320
2523
|
}
|
|
2321
|
-
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s =
|
|
2524
|
+
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s = Pn(a, n), c = i.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2322
2525
|
if (!o) {
|
|
2323
|
-
|
|
2526
|
+
K.warn("refreshForCache found no form handle for target.", { target: Q(n) });
|
|
2324
2527
|
return;
|
|
2325
2528
|
}
|
|
2326
|
-
let l = await
|
|
2327
|
-
l && (
|
|
2529
|
+
let l = await Ke(s, o, c, a, i?.querySelector("input[name=\"requestToken\"]")?.value);
|
|
2530
|
+
l && ($n(i, l), y(n, "formie:refresh-tokens:after", l));
|
|
2328
2531
|
},
|
|
2329
|
-
registerModule: (e,
|
|
2532
|
+
registerModule: (e, t) => r.register(e, t),
|
|
2330
2533
|
unregisterModule: (e) => {
|
|
2331
|
-
|
|
2534
|
+
r.unregister(e);
|
|
2332
2535
|
},
|
|
2333
|
-
getRegisteredModules: () =>
|
|
2536
|
+
getRegisteredModules: () => r.getAll(),
|
|
2334
2537
|
scan: async (e) => {
|
|
2335
|
-
let t = e || document, n = Array.from(t.querySelectorAll(
|
|
2336
|
-
|
|
2538
|
+
let t = e || document, n = Array.from(t.querySelectorAll(G));
|
|
2539
|
+
K.log("Scan started.", {
|
|
2337
2540
|
scope: t === document ? "document" : t,
|
|
2338
2541
|
targetCount: n.length
|
|
2339
2542
|
});
|
|
2340
|
-
let r = (await Promise.all(n.map((e) =>
|
|
2341
|
-
|
|
2543
|
+
let r = (await Promise.all(n.map((e) => {
|
|
2544
|
+
let t = J(e);
|
|
2545
|
+
return l(e, t);
|
|
2546
|
+
}))).filter((e) => !!e);
|
|
2547
|
+
return K.log("Scan finished.", {
|
|
2342
2548
|
mountedCount: r.length,
|
|
2343
2549
|
deferredCount: n.length - r.length
|
|
2344
2550
|
}), r;
|
|
2345
2551
|
},
|
|
2346
|
-
observe: (
|
|
2552
|
+
observe: (e) => {
|
|
2347
2553
|
if (typeof MutationObserver > "u") return () => {};
|
|
2348
|
-
let
|
|
2349
|
-
|
|
2350
|
-
let
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
e instanceof Element && (e.matches(
|
|
2354
|
-
|
|
2554
|
+
let n = e || document;
|
|
2555
|
+
K.log("Observer started.", { scope: n === document ? "document" : n });
|
|
2556
|
+
let r = new MutationObserver((e) => {
|
|
2557
|
+
e.forEach((e) => {
|
|
2558
|
+
e.addedNodes.forEach((e) => {
|
|
2559
|
+
e instanceof Element && (e.matches(G) && (K.log("Observer detected new root.", { target: Q(e) }), l(e, J(e))), e.querySelectorAll(G).forEach((e) => {
|
|
2560
|
+
K.log("Observer detected new nested root.", { target: Q(e) }), l(e, J(e));
|
|
2355
2561
|
}));
|
|
2356
|
-
}),
|
|
2357
|
-
|
|
2358
|
-
|
|
2562
|
+
}), e.removedNodes.forEach((e) => {
|
|
2563
|
+
e instanceof Element && (t.has(e) && (K.log("Observer detected removed root.", { target: Q(e) }), s(e)), e.querySelectorAll(G).forEach((e) => {
|
|
2564
|
+
t.has(e) && (K.log("Observer detected removed nested root.", { target: Q(e) }), s(e));
|
|
2359
2565
|
}));
|
|
2360
2566
|
});
|
|
2361
2567
|
});
|
|
2362
2568
|
});
|
|
2363
|
-
return
|
|
2569
|
+
return r.observe(n, {
|
|
2364
2570
|
childList: !0,
|
|
2365
2571
|
subtree: !0
|
|
2366
2572
|
}), () => {
|
|
2367
|
-
|
|
2368
|
-
|
|
2573
|
+
r.disconnect(), K.log("Observer stopped."), i.forEach((e, t) => {
|
|
2574
|
+
Qn(t, n) && (e(), i.delete(t));
|
|
2369
2575
|
});
|
|
2370
|
-
let
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
}),
|
|
2374
|
-
|
|
2576
|
+
let e = [];
|
|
2577
|
+
n instanceof Element && n.matches(G) && e.push(n), n.querySelectorAll(G).forEach((t) => {
|
|
2578
|
+
e.push(t);
|
|
2579
|
+
}), e.forEach((e) => {
|
|
2580
|
+
t.has(e) && s(e);
|
|
2375
2581
|
});
|
|
2376
2582
|
};
|
|
2377
2583
|
}
|
|
@@ -2379,9 +2585,13 @@ function sr() {
|
|
|
2379
2585
|
}
|
|
2380
2586
|
//#endregion
|
|
2381
2587
|
//#region src/js/core/hydrate-modules.ts
|
|
2382
|
-
var
|
|
2383
|
-
async function
|
|
2384
|
-
let t = e.root, n = e.form ?? (t instanceof HTMLFormElement ? t : t.closest("form")
|
|
2588
|
+
var ar = T("general", "module-hydrator");
|
|
2589
|
+
async function or(e) {
|
|
2590
|
+
let t = e.root, n = e.form ?? (t instanceof HTMLFormElement ? t : t.closest("form") ?? t.querySelector("form")), r = e.surface ?? "cp-edit", i = e.modules ?? {
|
|
2591
|
+
contractVersion: 2,
|
|
2592
|
+
surface: r,
|
|
2593
|
+
entries: []
|
|
2594
|
+
}, a = e.registry ?? new B(), o = new Rt(), s = await Xt(i, {
|
|
2385
2595
|
registry: a,
|
|
2386
2596
|
setupContext: {
|
|
2387
2597
|
formId: n?.id || t.id || "formie-modules",
|
|
@@ -2389,26 +2599,76 @@ async function lr(e) {
|
|
|
2389
2599
|
form: n,
|
|
2390
2600
|
target: t,
|
|
2391
2601
|
scope: "form",
|
|
2602
|
+
surface: r,
|
|
2392
2603
|
state: {},
|
|
2393
2604
|
options: {},
|
|
2394
2605
|
on: (e, t) => o.on(e, t),
|
|
2395
|
-
emit: async (e,
|
|
2396
|
-
|
|
2606
|
+
emit: async (e, n) => {
|
|
2607
|
+
t.dispatchEvent(new CustomEvent(e, {
|
|
2608
|
+
detail: n,
|
|
2609
|
+
bubbles: !0
|
|
2610
|
+
})), await o.emit(e, n);
|
|
2397
2611
|
}
|
|
2398
2612
|
},
|
|
2399
2613
|
matchContext: {
|
|
2400
2614
|
root: t,
|
|
2401
2615
|
form: n,
|
|
2402
|
-
|
|
2616
|
+
surface: r
|
|
2403
2617
|
}
|
|
2404
2618
|
});
|
|
2405
|
-
return
|
|
2406
|
-
moduleCount:
|
|
2407
|
-
instanceCount: s.length,
|
|
2408
|
-
|
|
2619
|
+
return ar.log("Hydrated module manifest.", {
|
|
2620
|
+
moduleCount: i.entries.length,
|
|
2621
|
+
instanceCount: s.instances.length,
|
|
2622
|
+
surface: r
|
|
2409
2623
|
}), {
|
|
2624
|
+
get instances() {
|
|
2625
|
+
return s.instances;
|
|
2626
|
+
},
|
|
2627
|
+
get failures() {
|
|
2628
|
+
return s.failures;
|
|
2629
|
+
},
|
|
2630
|
+
prepare: async (e) => {
|
|
2631
|
+
if (!n) throw Error("Browser modules require a mounted form element.");
|
|
2632
|
+
s.assertReady(), s.instances.forEach((e) => e.assertReady?.());
|
|
2633
|
+
let t, r = {
|
|
2634
|
+
form: n,
|
|
2635
|
+
action: e === "back" || e === "save" ? e : "submit",
|
|
2636
|
+
formData: new FormData(n),
|
|
2637
|
+
abort: (e) => {
|
|
2638
|
+
t = e || "A form feature could not complete.";
|
|
2639
|
+
},
|
|
2640
|
+
isAborted: () => !!t,
|
|
2641
|
+
abortReason: () => t
|
|
2642
|
+
}, i = {
|
|
2643
|
+
core: 0,
|
|
2644
|
+
field: 0,
|
|
2645
|
+
address: 0,
|
|
2646
|
+
captcha: 1,
|
|
2647
|
+
payment: 2
|
|
2648
|
+
};
|
|
2649
|
+
for (let e of [...s.instances].sort((e, t) => i[e.kind ?? "core"] - i[t.kind ?? "core"])) if (await e.beforeSubmit?.(r), t) throw Error(t);
|
|
2650
|
+
return Object.fromEntries(Array.from(n.querySelectorAll("input[type=\"hidden\"][name]")).map((e) => [e.name, e.value]));
|
|
2651
|
+
},
|
|
2652
|
+
result: async (e) => {
|
|
2653
|
+
if (!n) return;
|
|
2654
|
+
let t = {
|
|
2655
|
+
form: n,
|
|
2656
|
+
action: e.action ?? "submit",
|
|
2657
|
+
formData: new FormData(n)
|
|
2658
|
+
};
|
|
2659
|
+
await o.emit("formie:submit:result", e);
|
|
2660
|
+
for (let n of s.instances) await n.afterSubmit?.(t, e);
|
|
2661
|
+
n.dispatchEvent(new CustomEvent("formie:submit:result", {
|
|
2662
|
+
detail: e,
|
|
2663
|
+
bubbles: !0
|
|
2664
|
+
}));
|
|
2665
|
+
},
|
|
2666
|
+
update: (e) => s.updateManifest(e),
|
|
2667
|
+
assertReady: () => {
|
|
2668
|
+
s.assertReady(), s.instances.forEach((e) => e.assertReady?.());
|
|
2669
|
+
},
|
|
2410
2670
|
destroy: async () => {
|
|
2411
|
-
await
|
|
2671
|
+
await s.destroy(), o.clear();
|
|
2412
2672
|
},
|
|
2413
2673
|
on: (e, t) => o.on(e, t),
|
|
2414
2674
|
emit: async (e, t) => {
|
|
@@ -2421,81 +2681,74 @@ async function lr(e) {
|
|
|
2421
2681
|
getRegisteredModules: () => a.getAll()
|
|
2422
2682
|
};
|
|
2423
2683
|
}
|
|
2424
|
-
async function ur(e) {
|
|
2425
|
-
for (let t of e) try {
|
|
2426
|
-
await t.destroy();
|
|
2427
|
-
} catch (e) {
|
|
2428
|
-
console.error("[formie] Failed to destroy module instance.", e), cr.warn("Failed destroying module instance.", { error: e });
|
|
2429
|
-
}
|
|
2430
|
-
}
|
|
2431
2684
|
//#endregion
|
|
2432
2685
|
//#region src/js/core/formie.ts
|
|
2433
2686
|
function $(e) {
|
|
2434
2687
|
return e instanceof Element;
|
|
2435
2688
|
}
|
|
2436
|
-
function
|
|
2689
|
+
function sr(e) {
|
|
2437
2690
|
return e.ok;
|
|
2438
2691
|
}
|
|
2439
|
-
function
|
|
2692
|
+
function cr(e) {
|
|
2440
2693
|
return typeof e == "string" ? `selector "${e}"` : $(e) ? `element "${e.tagName.toLowerCase()}"` : "provided element collection";
|
|
2441
2694
|
}
|
|
2442
|
-
function
|
|
2695
|
+
function lr(e) {
|
|
2443
2696
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2444
|
-
for (let r of e)
|
|
2697
|
+
for (let r of e) $(r) && !t.has(r) && (t.add(r), n.push(r));
|
|
2445
2698
|
return n;
|
|
2446
2699
|
}
|
|
2447
|
-
function
|
|
2448
|
-
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : $(e) ? [e] :
|
|
2700
|
+
function ur(e) {
|
|
2701
|
+
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : $(e) ? [e] : lr(e);
|
|
2449
2702
|
}
|
|
2450
|
-
function
|
|
2703
|
+
function dr() {
|
|
2451
2704
|
return document.readyState === "loading" ? new Promise((e) => {
|
|
2452
2705
|
document.addEventListener("DOMContentLoaded", () => e(), { once: !0 });
|
|
2453
2706
|
}) : Promise.resolve();
|
|
2454
2707
|
}
|
|
2455
|
-
async function
|
|
2456
|
-
let t =
|
|
2457
|
-
return t.length > 0 || typeof e != "string" ? t : (await
|
|
2708
|
+
async function fr(e) {
|
|
2709
|
+
let t = ur(e);
|
|
2710
|
+
return t.length > 0 || typeof e != "string" ? t : (await dr(), ur(e));
|
|
2458
2711
|
}
|
|
2459
|
-
function
|
|
2712
|
+
function pr(e) {
|
|
2460
2713
|
return typeof e == "string" ? document : $(e) ? e.getRootNode() : document;
|
|
2461
2714
|
}
|
|
2462
|
-
function
|
|
2715
|
+
function mr(e) {
|
|
2463
2716
|
let { element: t, observe: n, allowEmpty: r, client: i, onReady: a, onResult: o, onSuccess: s, onError: c, onEvent: l, ...u } = e;
|
|
2464
2717
|
return {
|
|
2465
2718
|
mode: "server-rendered",
|
|
2466
2719
|
...u
|
|
2467
2720
|
};
|
|
2468
2721
|
}
|
|
2469
|
-
async function
|
|
2470
|
-
let i = [],
|
|
2471
|
-
for (let
|
|
2472
|
-
let r = n.get(
|
|
2722
|
+
async function hr(e, t, n, r) {
|
|
2723
|
+
let i = [], a = mr(e);
|
|
2724
|
+
for (let o of r) {
|
|
2725
|
+
let r = n.get(o);
|
|
2473
2726
|
if (r) {
|
|
2474
2727
|
i.push(r.instance);
|
|
2475
2728
|
continue;
|
|
2476
2729
|
}
|
|
2477
|
-
let
|
|
2478
|
-
if (e.onReady?.(
|
|
2730
|
+
let s = await t.mount(o, a), c = [];
|
|
2731
|
+
if (e.onReady?.(s), c.push(s.on("formie:submit:result", (t) => {
|
|
2479
2732
|
let n = t;
|
|
2480
|
-
e.onResult?.(n,
|
|
2481
|
-
})), e.onEvent) for (let t of
|
|
2733
|
+
e.onResult?.(n, s), sr(n) ? e.onSuccess?.(n, s) : e.onError?.(n, s);
|
|
2734
|
+
})), e.onEvent) for (let t of l) c.push(s.on(t, (n) => {
|
|
2482
2735
|
e.onEvent?.({
|
|
2483
2736
|
name: t,
|
|
2484
2737
|
payload: n
|
|
2485
|
-
},
|
|
2738
|
+
}, s);
|
|
2486
2739
|
}));
|
|
2487
|
-
n.set(
|
|
2488
|
-
instance:
|
|
2489
|
-
unsubs:
|
|
2490
|
-
}), i.push(
|
|
2740
|
+
n.set(o, {
|
|
2741
|
+
instance: s,
|
|
2742
|
+
unsubs: c
|
|
2743
|
+
}), i.push(s);
|
|
2491
2744
|
}
|
|
2492
2745
|
return i;
|
|
2493
2746
|
}
|
|
2494
|
-
async function
|
|
2495
|
-
let t = e.client ??
|
|
2496
|
-
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${
|
|
2497
|
-
await
|
|
2498
|
-
let i = e.observe ? t.observe(
|
|
2747
|
+
async function gr(e) {
|
|
2748
|
+
let t = e.client ?? ir(), n = /* @__PURE__ */ new Map(), r = await fr(e.element);
|
|
2749
|
+
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${cr(e.element)}.`);
|
|
2750
|
+
await hr(e, t, n, r);
|
|
2751
|
+
let i = e.observe ? t.observe(pr(e.element)) : null;
|
|
2499
2752
|
return {
|
|
2500
2753
|
client: t,
|
|
2501
2754
|
get instances() {
|
|
@@ -2506,8 +2759,8 @@ async function br(e) {
|
|
|
2506
2759
|
return r ? n.get(r)?.instance ?? t.getInstance(r) : null;
|
|
2507
2760
|
},
|
|
2508
2761
|
async rescan() {
|
|
2509
|
-
let r =
|
|
2510
|
-
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) :
|
|
2762
|
+
let r = ur(e.element);
|
|
2763
|
+
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) : hr(e, t, n, r);
|
|
2511
2764
|
},
|
|
2512
2765
|
async destroy() {
|
|
2513
2766
|
i?.();
|
|
@@ -2517,4 +2770,102 @@ async function br(e) {
|
|
|
2517
2770
|
};
|
|
2518
2771
|
}
|
|
2519
2772
|
//#endregion
|
|
2520
|
-
|
|
2773
|
+
//#region src/js/core/client-rendered-modules.ts
|
|
2774
|
+
var _r = {
|
|
2775
|
+
conditions: {
|
|
2776
|
+
kind: "core",
|
|
2777
|
+
reason: "Core evaluates structured conditions and the adapter renders visibility."
|
|
2778
|
+
},
|
|
2779
|
+
repeater: {
|
|
2780
|
+
kind: "field",
|
|
2781
|
+
reason: "The adapter owns row markup and core owns row values."
|
|
2782
|
+
},
|
|
2783
|
+
signature: {
|
|
2784
|
+
kind: "field",
|
|
2785
|
+
reason: "The adapter owns its signature control and cleanup."
|
|
2786
|
+
},
|
|
2787
|
+
"file-upload": {
|
|
2788
|
+
kind: "field",
|
|
2789
|
+
reason: "The shared transport stages selected files and submits attachment capabilities."
|
|
2790
|
+
},
|
|
2791
|
+
"upload-manager": {
|
|
2792
|
+
kind: "field",
|
|
2793
|
+
reason: "Native file selection uses the shared staged upload transport."
|
|
2794
|
+
},
|
|
2795
|
+
"checkbox-radio": {
|
|
2796
|
+
kind: "field",
|
|
2797
|
+
reason: "Framework controls own checked state."
|
|
2798
|
+
},
|
|
2799
|
+
"text-limit": {
|
|
2800
|
+
kind: "field",
|
|
2801
|
+
reason: "Core validation enforces the structured minimum and maximum rules."
|
|
2802
|
+
},
|
|
2803
|
+
"date-picker": {
|
|
2804
|
+
kind: "field",
|
|
2805
|
+
reason: "The adapter renders the structured date input contract."
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2808
|
+
async function vr(t, n, r = zt) {
|
|
2809
|
+
for (let [e, t] of Object.entries(_r)) {
|
|
2810
|
+
let n = `formie:${e}`;
|
|
2811
|
+
r.get(n) || r.register({
|
|
2812
|
+
moduleId: n,
|
|
2813
|
+
version: 2,
|
|
2814
|
+
surfaces: ["client-rendered"],
|
|
2815
|
+
kind: t.kind,
|
|
2816
|
+
match: () => !0,
|
|
2817
|
+
setup: async (e) => (await e.emit("formie:browser:module:delegated", {
|
|
2818
|
+
moduleId: n,
|
|
2819
|
+
reason: t.reason,
|
|
2820
|
+
target: e.target
|
|
2821
|
+
}), { destroy: () => void 0 })
|
|
2822
|
+
});
|
|
2823
|
+
}
|
|
2824
|
+
let i = t instanceof HTMLFormElement ? t : t.querySelector("form"), a = () => {
|
|
2825
|
+
if (!i) return;
|
|
2826
|
+
let t = n.getState();
|
|
2827
|
+
e(i, n.getBrowserRequestOptions()), i.action = t.definition.submission.endpoint, t.session.tokens.csrf && i.setAttribute("data-formie-csrf-param", t.session.tokens.csrf.name);
|
|
2828
|
+
for (let [e, n] of Object.entries({
|
|
2829
|
+
handle: t.definition.handle,
|
|
2830
|
+
...t.session.tokens.csrf ? { [t.session.tokens.csrf.name]: t.session.tokens.csrf.value } : {}
|
|
2831
|
+
})) {
|
|
2832
|
+
let t = i.querySelector(`input[type="hidden"][name="${CSS.escape(e)}"]`);
|
|
2833
|
+
t || (t = document.createElement("input"), t.type = "hidden", t.name = e, i.append(t)), t.value = n;
|
|
2834
|
+
}
|
|
2835
|
+
};
|
|
2836
|
+
a();
|
|
2837
|
+
let o = n.subscribe(a), s = await or({
|
|
2838
|
+
root: t,
|
|
2839
|
+
modules: n.getState().definition.modules,
|
|
2840
|
+
surface: "client-rendered",
|
|
2841
|
+
registry: r
|
|
2842
|
+
});
|
|
2843
|
+
n.setBrowserModuleGuard(s.assertReady), n.setBrowserModulePreparation(s.prepare);
|
|
2844
|
+
let c = n.on("formie:submit:result", (e) => {
|
|
2845
|
+
let t = e, r = t.completion;
|
|
2846
|
+
t.success && r && (r.behavior === "redirect" && typeof r.url == "string" ? r.target === "new-tab" ? window.open(r.url, "_blank", "noopener,noreferrer") : window.location.assign(r.url) : r.behavior === "reload" ? window.location.reload() : r.behavior === "reset" && n.reset()), s.result({
|
|
2847
|
+
ok: t.success,
|
|
2848
|
+
outcome: t.outcome,
|
|
2849
|
+
version: t.version,
|
|
2850
|
+
submissionUid: t.submissionUid,
|
|
2851
|
+
errors: t.errors,
|
|
2852
|
+
session: t.session,
|
|
2853
|
+
completion: t.completion,
|
|
2854
|
+
meta: t
|
|
2855
|
+
});
|
|
2856
|
+
});
|
|
2857
|
+
return {
|
|
2858
|
+
...s,
|
|
2859
|
+
get instances() {
|
|
2860
|
+
return s.instances;
|
|
2861
|
+
},
|
|
2862
|
+
get failures() {
|
|
2863
|
+
return s.failures;
|
|
2864
|
+
},
|
|
2865
|
+
destroy: async () => {
|
|
2866
|
+
c(), o(), await s.destroy();
|
|
2867
|
+
}
|
|
2868
|
+
};
|
|
2869
|
+
}
|
|
2870
|
+
//#endregion
|
|
2871
|
+
export { l as FORMIE_HTML_EVENT_NAMES, dn as FormieValidator, xe as LEGACY_FORMIE_DOM_EVENT_BRIDGES, Se as LEGACY_FORMIE_VALIDATOR_EVENT_BRIDGES, B as ModuleRegistry, Oe as bindLegacyDomEventCompatibility, ke as bindLegacyValidatorCompatibility, ve as buildFieldValueRegistry, zt as clientRenderedModuleRegistry, T as createDebug, ir as createFormieClient, ne as debugLog, w as debugWarn, be as defineAddressModule, fe as defineCaptchaModule, de as definePassiveCaptchaModule, S as definePaymentModule, he as fieldKeyToInputName, gr as formie, c as getFieldModuleEventName, ue as getFormieTranslations, s as getGlobalModuleLifecycleEventName, i as getScopedModuleLifecycleEventName, or as hydrateFormieModules, pe as inputNameToFieldKey, te as isFormieDebugEnabled, ce as mergeFormieTranslations, vr as mountClientRenderedModules, me as normalizeFieldKey, u as normalizeFormieEventName, ge as parseFieldReference, ye as resolveFieldReferenceFromFormData, _e as resolveFieldReferenceLive, Ce as resolveLegacyCompatibilityOptions, ee as setFormieDebugEnabled, le as setFormieTranslations, se as t, a as toDomEventName, oe as translate };
|