@verbb/formie-browser 1.0.12 → 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 +57 -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-5CA_-zGb.js → date-picker-RUnevF7l.js} +456 -430
- package/dist/chunks/{dist-BdUy8m_p.js → dist-ZLeW0zZ3.js} +1280 -452
- 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-T0vDQPCr.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-xz4QO7CR.js → signature-7cldFbqj.js} +160 -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-Bn18WrPU.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/fields/_signature.css +2 -1
- 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 -1425
- 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/fields/_signature.css +2 -1
- 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 +119 -73
- 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 +40 -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 +64 -6
- 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-DERi2xaC.js +0 -299
- package/dist/chunks/conditions-65kBcFWW.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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ValidationContext, ValidationInput } from '#validation/types';
|
|
2
|
+
import { isValidationSkipped } from '#validation/skip';
|
|
2
3
|
|
|
3
4
|
export function stripTags(value: string): string {
|
|
4
5
|
const doc = new DOMParser().parseFromString(value, 'text/html');
|
|
@@ -43,5 +44,8 @@ export function getComparableInput(ctx: ValidationContext): ValidationInput | nu
|
|
|
43
44
|
return null;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
return sourceField.
|
|
47
|
+
return Array.from(sourceField.querySelectorAll(ctx.config.fieldsSelector)).find((node): node is ValidationInput => {
|
|
48
|
+
return (node instanceof HTMLInputElement || node instanceof HTMLSelectElement || node instanceof HTMLTextAreaElement)
|
|
49
|
+
&& !isValidationSkipped(node);
|
|
50
|
+
}) ?? null;
|
|
47
51
|
}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
+
import { validateBrowserValue } from '@verbb/formie-core';
|
|
1
2
|
import type { ValidationRuleDefinition } from '#validation/types';
|
|
2
3
|
|
|
3
4
|
const url: ValidationRuleDefinition = {
|
|
4
5
|
rule: ({ input, getRule }) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
new URL(input.value);
|
|
11
|
-
return true;
|
|
12
|
-
} catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
6
|
+
const rule = getRule('url');
|
|
7
|
+
return !rule || validateBrowserValue(input.value, { ...(typeof rule === 'object' ? rule : {}), type: 'url' }) === null;
|
|
15
8
|
},
|
|
16
9
|
message: ({ input, label, t }) => {
|
|
17
10
|
return input.getAttribute('data-formie-pattern-url-message')
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controls marked with this attribute are not value carriers.
|
|
3
|
+
* The validator, live handlers, and match lookups all skip them.
|
|
4
|
+
*/
|
|
5
|
+
export const VALIDATION_SKIP_ATTR = 'data-formie-validation-skip';
|
|
6
|
+
|
|
7
|
+
export function isValidationSkipped(element: Element | null): boolean {
|
|
8
|
+
return !!element && element.hasAttribute(VALIDATION_SKIP_ATTR);
|
|
9
|
+
}
|
|
@@ -6,7 +6,10 @@ const PRESERVED_DISABLED_ATTR = 'data-formie-preserve-disabled';
|
|
|
6
6
|
const SUBMIT_READY_ATTR = 'data-formie-submit-ready';
|
|
7
7
|
|
|
8
8
|
function isSubmitReadinessEnabled(form: HTMLFormElement): boolean {
|
|
9
|
-
|
|
9
|
+
const value = form.dataset.formieDisableSubmitUntilValid?.trim().toLowerCase();
|
|
10
|
+
|
|
11
|
+
// Twig renders enabled boolean data attributes without a value.
|
|
12
|
+
return value === '' || value === 'true' || value === '1';
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
function getPrimarySubmitButtons(form: HTMLFormElement): HTMLButtonElement[] {
|
|
@@ -65,7 +68,11 @@ export function syncSubmitReadiness(form: HTMLFormElement, validator: FormieVali
|
|
|
65
68
|
button.setAttribute(SUBMIT_VALIDATION_DISABLED_ATTR, 'true');
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
|
|
71
|
+
// Observing `disabled` also catches external changes. Avoid scheduling
|
|
72
|
+
// another observer pass when the button already has the required state.
|
|
73
|
+
if (!button.disabled) {
|
|
74
|
+
button.disabled = true;
|
|
75
|
+
}
|
|
69
76
|
});
|
|
70
77
|
}
|
|
71
78
|
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ensureFieldErrorContainer } from '#core/field-error-container';
|
|
2
|
+
import {
|
|
3
|
+
clearFieldErrorAria,
|
|
4
|
+
setErrorMessageReference,
|
|
5
|
+
} from '#core/field-error-aria';
|
|
2
6
|
import { syncPageTabErrors } from '#core/page-tab-errors';
|
|
3
7
|
import rules from '#validation/rules';
|
|
4
8
|
import { applyErrorAriaLive, resolveValidationErrorAriaLive } from '#core/error-aria-live';
|
|
@@ -12,6 +16,7 @@ import type {
|
|
|
12
16
|
import { t } from '#utils/i18n';
|
|
13
17
|
import { getValidatorEventName } from '#utils/event-names';
|
|
14
18
|
import { createDebug } from '#utils/debug';
|
|
19
|
+
import { isValidationSkipped } from '#validation/skip';
|
|
15
20
|
|
|
16
21
|
type ValidatorDefinition = {
|
|
17
22
|
validate: (ctx: ValidationContext) => boolean;
|
|
@@ -42,44 +47,8 @@ function isValidationInput(node: Element | null): node is ValidationInput {
|
|
|
42
47
|
);
|
|
43
48
|
}
|
|
44
49
|
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (!current) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const filtered = current.split(/\s+/).filter((item) => {
|
|
53
|
-
return item !== describedById;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (filtered.length) {
|
|
57
|
-
input.setAttribute('aria-describedby', filtered.join(' '));
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
input.removeAttribute('aria-describedby');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function appendDescribedBy(input: HTMLElement, describedById: string): void {
|
|
65
|
-
const current = (input.getAttribute('aria-describedby') || '').trim();
|
|
66
|
-
const items = current ? current.split(/\s+/) : [];
|
|
67
|
-
|
|
68
|
-
if (!items.includes(describedById)) {
|
|
69
|
-
items.push(describedById);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
input.setAttribute('aria-describedby', items.join(' ').trim());
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function setErrorMessageReference(input: HTMLElement, errorMessageId: string): void {
|
|
76
|
-
input.setAttribute('aria-errormessage', errorMessageId);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function clearErrorMessageReference(input: HTMLElement, errorMessageId: string): void {
|
|
80
|
-
if (input.getAttribute('aria-errormessage') === errorMessageId) {
|
|
81
|
-
input.removeAttribute('aria-errormessage');
|
|
82
|
-
}
|
|
50
|
+
function isPainted(element: HTMLElement): boolean {
|
|
51
|
+
return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
|
|
83
52
|
}
|
|
84
53
|
|
|
85
54
|
export class FormieValidator {
|
|
@@ -142,13 +111,13 @@ export class FormieValidator {
|
|
|
142
111
|
|
|
143
112
|
inputs(inputOrSelector: Element | null = null): ValidationInput[] {
|
|
144
113
|
if (isValidationInput(inputOrSelector)) {
|
|
145
|
-
return [inputOrSelector];
|
|
114
|
+
return isValidationSkipped(inputOrSelector) ? [] : [inputOrSelector];
|
|
146
115
|
}
|
|
147
116
|
|
|
148
117
|
const root = inputOrSelector || this.form;
|
|
149
118
|
|
|
150
119
|
return Array.from(root.querySelectorAll(this.config.fieldsSelector)).filter((input): input is ValidationInput => {
|
|
151
|
-
return isValidationInput(input);
|
|
120
|
+
return isValidationInput(input) && !isValidationSkipped(input);
|
|
152
121
|
});
|
|
153
122
|
}
|
|
154
123
|
|
|
@@ -266,7 +235,11 @@ export class FormieValidator {
|
|
|
266
235
|
}
|
|
267
236
|
|
|
268
237
|
const errorMessages = fieldContainer.querySelector('[data-formie-field-errors]') as HTMLElement | null;
|
|
269
|
-
|
|
238
|
+
// Capture message ids before nodes are removed so aria-errormessage / describedby
|
|
239
|
+
// can be cleared (querying after remove finds nothing).
|
|
240
|
+
const errorMessageIds = Array.from(fieldContainer.querySelectorAll('[data-formie-field-error]')).map((node) => {
|
|
241
|
+
return (node as HTMLElement).id;
|
|
242
|
+
}).filter(Boolean);
|
|
270
243
|
|
|
271
244
|
fieldContainer.querySelectorAll('[data-formie-field-error]').forEach((node) => {
|
|
272
245
|
node.remove();
|
|
@@ -283,18 +256,7 @@ export class FormieValidator {
|
|
|
283
256
|
element.classList.remove(...this.config.inputErrorClass);
|
|
284
257
|
}
|
|
285
258
|
element.removeAttribute('data-formie-input-has-error');
|
|
286
|
-
|
|
287
|
-
if (errorContainerId) {
|
|
288
|
-
removeDescribedBy(element, errorContainerId);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
fieldContainer.querySelectorAll('[data-formie-field-error]').forEach((errorNode) => {
|
|
292
|
-
const errorMessageId = (errorNode as HTMLElement).id;
|
|
293
|
-
|
|
294
|
-
if (errorMessageId) {
|
|
295
|
-
clearErrorMessageReference(element, errorMessageId);
|
|
296
|
-
}
|
|
297
|
-
});
|
|
259
|
+
clearFieldErrorAria(element, errorMessageIds);
|
|
298
260
|
});
|
|
299
261
|
|
|
300
262
|
// Nested field wrappers inherit error state so repeaters/groups can reflect
|
|
@@ -347,7 +309,6 @@ export class FormieValidator {
|
|
|
347
309
|
errorElement.setAttribute('data-formie-field-error', 'true');
|
|
348
310
|
errorElement.setAttribute(`data-formie-field-error-${validatorName}`, 'true');
|
|
349
311
|
errorElement.setAttribute('id', errorId);
|
|
350
|
-
errorElement.setAttribute('role', 'alert');
|
|
351
312
|
if (this.config.messageClass.length) {
|
|
352
313
|
errorElement.classList.add(...this.config.messageClass);
|
|
353
314
|
}
|
|
@@ -358,12 +319,17 @@ export class FormieValidator {
|
|
|
358
319
|
|
|
359
320
|
fieldContainer.querySelectorAll('input, select, textarea').forEach((fieldInput) => {
|
|
360
321
|
const element = fieldInput as HTMLElement;
|
|
322
|
+
|
|
323
|
+
if (isValidationSkipped(element)) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
361
327
|
element.setAttribute('aria-invalid', 'true');
|
|
362
328
|
if (this.config.inputErrorClass.length) {
|
|
363
329
|
element.classList.add(...this.config.inputErrorClass);
|
|
364
330
|
}
|
|
365
331
|
element.setAttribute('data-formie-input-has-error', 'true');
|
|
366
|
-
|
|
332
|
+
// Pair aria-errormessage + aria-describedby on the message id (#2946).
|
|
367
333
|
setErrorMessageReference(element, errorId);
|
|
368
334
|
});
|
|
369
335
|
|
|
@@ -509,11 +475,21 @@ export class FormieValidator {
|
|
|
509
475
|
return !!options.includeHiddenPages;
|
|
510
476
|
}
|
|
511
477
|
|
|
512
|
-
|
|
478
|
+
// Rich Text keeps the real <textarea> in a display:none wrapper while the
|
|
479
|
+
// contenteditable UI is painted. Geometry on the textarea is always zero,
|
|
480
|
+
// so validate against the editor host when present (#2947).
|
|
481
|
+
const field = element.closest('[data-formie-field-handle]');
|
|
482
|
+
const richTextHost = field?.querySelector('[data-formie-rich-text]');
|
|
483
|
+
|
|
484
|
+
if (richTextHost instanceof HTMLElement) {
|
|
485
|
+
return isPainted(richTextHost);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
return isPainted(element);
|
|
513
489
|
}
|
|
514
490
|
|
|
515
491
|
blurHandler(event: Event): void {
|
|
516
|
-
if (!(event.target instanceof HTMLElement) || !isValidationInput(event.target) || !event.target.form?.isSameNode(this.form)) {
|
|
492
|
+
if (!(event.target instanceof HTMLElement) || !isValidationInput(event.target) || isValidationSkipped(event.target) || !event.target.form?.isSameNode(this.form)) {
|
|
517
493
|
return;
|
|
518
494
|
}
|
|
519
495
|
|
|
@@ -539,7 +515,7 @@ export class FormieValidator {
|
|
|
539
515
|
}
|
|
540
516
|
|
|
541
517
|
changeHandler(event: Event): void {
|
|
542
|
-
if (!(event.target instanceof HTMLElement) || !isValidationInput(event.target) || !event.target.form?.isSameNode(this.form)) {
|
|
518
|
+
if (!(event.target instanceof HTMLElement) || !isValidationInput(event.target) || isValidationSkipped(event.target) || !event.target.form?.isSameNode(this.form)) {
|
|
543
519
|
return;
|
|
544
520
|
}
|
|
545
521
|
|
|
@@ -570,7 +546,7 @@ export class FormieValidator {
|
|
|
570
546
|
}
|
|
571
547
|
|
|
572
548
|
inputHandler(event: Event): void {
|
|
573
|
-
if (!(event.target instanceof HTMLElement) || !isValidationInput(event.target) || !event.target.form?.isSameNode(this.form)) {
|
|
549
|
+
if (!(event.target instanceof HTMLElement) || !isValidationInput(event.target) || isValidationSkipped(event.target) || !event.target.form?.isSameNode(this.form)) {
|
|
574
550
|
return;
|
|
575
551
|
}
|
|
576
552
|
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./debug-BV0DvdHx.js";
|
|
2
|
-
import { r as t, t as n } from "./field-references.keys-58ZSTrCW.js";
|
|
3
|
-
import { n as r, r as i } from "./field-references.resolver-CHwn0G0L.js";
|
|
4
|
-
import { r as a, t as o } from "./shared-Bx9s0i0P.js";
|
|
5
|
-
import { c as s, i as c, r as l, s as u, t as d } from "./dist-BdUy8m_p.js";
|
|
6
|
-
//#region src/js/utils/field-references.row-scope.ts
|
|
7
|
-
var f = new Set([
|
|
8
|
-
"first",
|
|
9
|
-
"last",
|
|
10
|
-
"index",
|
|
11
|
-
"all",
|
|
12
|
-
"count",
|
|
13
|
-
"rows"
|
|
14
|
-
]);
|
|
15
|
-
function p(e) {
|
|
16
|
-
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17
|
-
}
|
|
18
|
-
function m(e, t) {
|
|
19
|
-
let n = String(e || "").trim().toLowerCase();
|
|
20
|
-
if (!n || t <= 0) return [];
|
|
21
|
-
if (n === "even") {
|
|
22
|
-
let e = [];
|
|
23
|
-
for (let n = 1; n <= t; n++) n % 2 == 0 && e.push(n - 1);
|
|
24
|
-
return e;
|
|
25
|
-
}
|
|
26
|
-
if (n === "odd") {
|
|
27
|
-
let e = [];
|
|
28
|
-
for (let n = 1; n <= t; n++) n % 2 == 1 && e.push(n - 1);
|
|
29
|
-
return e;
|
|
30
|
-
}
|
|
31
|
-
let r = n.match(/^every:(\d+)$/);
|
|
32
|
-
if (r) {
|
|
33
|
-
let e = Math.max(1, Number.parseInt(r[1] || "1", 10)), n = [];
|
|
34
|
-
for (let r = 1; r <= t; r += e) n.push(r - 1);
|
|
35
|
-
return n;
|
|
36
|
-
}
|
|
37
|
-
let i = [];
|
|
38
|
-
return n.split(/\s*,\s*/).forEach((e) => {
|
|
39
|
-
let n = e.trim();
|
|
40
|
-
if (!n) return;
|
|
41
|
-
let r = n.match(/^(\d+)\s*-\s*(\d+)$/);
|
|
42
|
-
if (r) {
|
|
43
|
-
let e = Number.parseInt(r[1] || "0", 10), n = Number.parseInt(r[2] || "0", 10);
|
|
44
|
-
e > n && ([e, n] = [n, e]);
|
|
45
|
-
for (let r = e; r <= n; r++) r >= 1 && r <= t && i.push(r - 1);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
let a = Number.parseInt(n, 10);
|
|
49
|
-
Number.isFinite(a) && a >= 1 && a <= t && i.push(a - 1);
|
|
50
|
-
}), [...new Set(i)].sort((e, t) => e - t);
|
|
51
|
-
}
|
|
52
|
-
function h(e) {
|
|
53
|
-
let n = t(e), r = n.split(".").filter(Boolean);
|
|
54
|
-
return r.length < 2 ? {
|
|
55
|
-
fieldKey: n,
|
|
56
|
-
columnKey: r[r.length - 1] || ""
|
|
57
|
-
} : r.length >= 3 && /^\d+$/.test(r[1] || "") ? {
|
|
58
|
-
fieldKey: r[0] || "",
|
|
59
|
-
columnKey: r.slice(2).join(".")
|
|
60
|
-
} : {
|
|
61
|
-
fieldKey: r[0] || "",
|
|
62
|
-
columnKey: r.slice(1).join(".")
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function g(e, t, n) {
|
|
66
|
-
let r = RegExp(`^${p(e)}\\.(\\d+)\\.${p(t)}$`);
|
|
67
|
-
return [...n.keys()].filter((e) => r.test(e)).sort((e, t) => Number.parseInt(e.split(".")[1] || "0", 10) - Number.parseInt(t.split(".")[1] || "0", 10));
|
|
68
|
-
}
|
|
69
|
-
function _(e, t) {
|
|
70
|
-
return r(e, t).value;
|
|
71
|
-
}
|
|
72
|
-
function v(e, t, r) {
|
|
73
|
-
let i = /* @__PURE__ */ new Set(), { fieldKey: a, columnKey: o } = h(e), s = String(t.scope || "").trim().toLowerCase();
|
|
74
|
-
if (!a || !o || !f.has(s)) {
|
|
75
|
-
let t = n(e);
|
|
76
|
-
return t && (i.add(t), i.add(`${t}[]`)), i;
|
|
77
|
-
}
|
|
78
|
-
return g(a, o, r).forEach((e) => {
|
|
79
|
-
let t = r.get(e);
|
|
80
|
-
if (t?.names?.length) {
|
|
81
|
-
t.names.forEach((e) => {
|
|
82
|
-
i.add(e);
|
|
83
|
-
});
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
let a = n(e);
|
|
87
|
-
a && (i.add(a), i.add(`${a}[]`));
|
|
88
|
-
}), i;
|
|
89
|
-
}
|
|
90
|
-
function y(e, t, n) {
|
|
91
|
-
let i = String(t.scope || "").trim().toLowerCase();
|
|
92
|
-
if (!i || !f.has(i)) return r(e, n);
|
|
93
|
-
let { fieldKey: a, columnKey: o } = h(e);
|
|
94
|
-
if (!a || !o) return r(e, n);
|
|
95
|
-
let s = g(a, o, n), c = s.map((e) => _(e, n));
|
|
96
|
-
if (i === "count") return {
|
|
97
|
-
key: `${a}.${o}`,
|
|
98
|
-
value: String(s.length),
|
|
99
|
-
found: !0
|
|
100
|
-
};
|
|
101
|
-
if (i === "first") return {
|
|
102
|
-
key: s[0] || `${a}.0.${o}`,
|
|
103
|
-
value: c[0] ?? "",
|
|
104
|
-
found: s.length > 0
|
|
105
|
-
};
|
|
106
|
-
if (i === "last") return {
|
|
107
|
-
key: s[s.length - 1] || `${a}.0.${o}`,
|
|
108
|
-
value: c[c.length - 1] ?? "",
|
|
109
|
-
found: s.length > 0
|
|
110
|
-
};
|
|
111
|
-
if (i === "index") return r(`${a}.${Number.parseInt(String(t.index ?? "0"), 10)}.${o}`, n);
|
|
112
|
-
if (i === "all") {
|
|
113
|
-
let e = c.flatMap((e) => Array.isArray(e) ? e : e === "" ? [] : [e]);
|
|
114
|
-
return {
|
|
115
|
-
key: `${a}.${o}`,
|
|
116
|
-
value: e,
|
|
117
|
-
found: e.length > 0
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
if (i === "rows") {
|
|
121
|
-
let e = m(String(t.rows || ""), s.length);
|
|
122
|
-
if (e.length === 0) return {
|
|
123
|
-
key: `${a}.${o}`,
|
|
124
|
-
value: "",
|
|
125
|
-
found: !1
|
|
126
|
-
};
|
|
127
|
-
if (e.length === 1) return {
|
|
128
|
-
key: s[e[0]] || `${a}.${e[0]}.${o}`,
|
|
129
|
-
value: c[e[0]] ?? "",
|
|
130
|
-
found: !0
|
|
131
|
-
};
|
|
132
|
-
let n = e.flatMap((e) => {
|
|
133
|
-
let t = c[e];
|
|
134
|
-
return Array.isArray(t) ? t : t === "" ? [] : [t];
|
|
135
|
-
});
|
|
136
|
-
return {
|
|
137
|
-
key: `${a}.${o}`,
|
|
138
|
-
value: n,
|
|
139
|
-
found: n.length > 0
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
return r(e, n);
|
|
143
|
-
}
|
|
144
|
-
//#endregion
|
|
145
|
-
//#region src/js/modules/fields/calculations.ts
|
|
146
|
-
var b = "input[data-formie-calculation-input]";
|
|
147
|
-
function x(e) {
|
|
148
|
-
let t = e;
|
|
149
|
-
return {
|
|
150
|
-
scope: t.scope,
|
|
151
|
-
index: t.index,
|
|
152
|
-
rows: t.rows,
|
|
153
|
-
fieldKind: t.fieldKind
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
var S = "calculations", C = e("fields", "calculations");
|
|
157
|
-
function w(e, t, n) {
|
|
158
|
-
let a = i(e), o = {};
|
|
159
|
-
return t.forEach(([e, t]) => {
|
|
160
|
-
let n = x(t);
|
|
161
|
-
if (String(n.scope || "").trim()) {
|
|
162
|
-
o[e] = l(t, y(t.sourceKey || "", n, a).value);
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
o[e] = l(t, r(t.sourceKey || "", a).value);
|
|
166
|
-
}), d(o, n.formatting);
|
|
167
|
-
}
|
|
168
|
-
function T(e, r) {
|
|
169
|
-
let a = i(e), o = /* @__PURE__ */ new Set();
|
|
170
|
-
return r.forEach(([, e]) => {
|
|
171
|
-
let r = x(e);
|
|
172
|
-
if (String(r.scope || "").trim()) {
|
|
173
|
-
v(e.sourceKey || "", r, a).forEach((e) => {
|
|
174
|
-
o.add(e);
|
|
175
|
-
});
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
let i = t(e.sourceKey || ""), s = a.get(i);
|
|
179
|
-
if (s?.names?.length) {
|
|
180
|
-
s.names.forEach((e) => {
|
|
181
|
-
o.add(e);
|
|
182
|
-
});
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
let c = n(i);
|
|
186
|
-
c && (o.add(c), o.add(`${c}[]`));
|
|
187
|
-
}), o;
|
|
188
|
-
}
|
|
189
|
-
function E(e, t, n, r) {
|
|
190
|
-
let i = s(r), a = c(r), l = /* @__PURE__ */ new Map(), d = null, f = !1, p = !1, m = !1, h = () => {
|
|
191
|
-
l.forEach((e, t) => {
|
|
192
|
-
e.forEach((e, n) => {
|
|
193
|
-
t.removeEventListener(n, e);
|
|
194
|
-
});
|
|
195
|
-
}), l.clear();
|
|
196
|
-
}, g = (e) => {
|
|
197
|
-
!e || f || queueMicrotask(() => {
|
|
198
|
-
f || (n.dispatchEvent(new Event("input", { bubbles: !0 })), n.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
199
|
-
});
|
|
200
|
-
}, _ = (s = !1) => {
|
|
201
|
-
let c = w(e, a, r);
|
|
202
|
-
C.log("Evaluate requested.", {
|
|
203
|
-
fieldHandle: t.getAttribute("data-formie-field-handle") || null,
|
|
204
|
-
isInit: s
|
|
205
|
-
});
|
|
206
|
-
let l = {
|
|
207
|
-
calculations: n,
|
|
208
|
-
init: s,
|
|
209
|
-
formula: i,
|
|
210
|
-
variables: c
|
|
211
|
-
};
|
|
212
|
-
if (o(t, S, "before-evaluate", l), !l.formula) {
|
|
213
|
-
let e = n.value !== "";
|
|
214
|
-
n.value = "", g(e);
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
try {
|
|
218
|
-
let e = u(l.formula, l.variables, r), i = {
|
|
219
|
-
calculations: n,
|
|
220
|
-
init: s,
|
|
221
|
-
formula: l.formula,
|
|
222
|
-
variables: l.variables,
|
|
223
|
-
result: e
|
|
224
|
-
};
|
|
225
|
-
o(t, S, "after-evaluate", i);
|
|
226
|
-
let a = typeof i.result == "string" || typeof i.result == "number" ? String(i.result) : "", c = n.value !== a;
|
|
227
|
-
n.value = a, C.log("Evaluate complete.", {
|
|
228
|
-
fieldHandle: t.getAttribute("data-formie-field-handle") || null,
|
|
229
|
-
valueChanged: c,
|
|
230
|
-
nextValue: a
|
|
231
|
-
}), g(c);
|
|
232
|
-
} catch (e) {
|
|
233
|
-
let r = n.value !== "";
|
|
234
|
-
console.error("[formie] Failed to evaluate calculation.", e), C.warn("Evaluate failed.", {
|
|
235
|
-
fieldHandle: t.getAttribute("data-formie-field-handle") || null,
|
|
236
|
-
error: e instanceof Error ? e.message : e
|
|
237
|
-
}), n.value = "", g(r);
|
|
238
|
-
}
|
|
239
|
-
}, v = (e = !1) => {
|
|
240
|
-
p || f || (p = !0, queueMicrotask(() => {
|
|
241
|
-
p = !1, _(e);
|
|
242
|
-
}));
|
|
243
|
-
}, y = () => {
|
|
244
|
-
h();
|
|
245
|
-
let n = T(e, a);
|
|
246
|
-
if (C.log("Binding variable watchers.", {
|
|
247
|
-
fieldHandle: t.getAttribute("data-formie-field-handle") || null,
|
|
248
|
-
watchCount: n.size
|
|
249
|
-
}), !n.size) return;
|
|
250
|
-
let r = (e) => {
|
|
251
|
-
let r = e.target?.name || "";
|
|
252
|
-
!r || !n.has(r) || (C.log("Source change detected.", {
|
|
253
|
-
fieldHandle: t.getAttribute("data-formie-field-handle") || null,
|
|
254
|
-
sourceName: r,
|
|
255
|
-
eventType: e.type
|
|
256
|
-
}), v(!1));
|
|
257
|
-
};
|
|
258
|
-
["input", "change"].forEach((t) => {
|
|
259
|
-
e.addEventListener(t, r);
|
|
260
|
-
let n = l.get(e) || /* @__PURE__ */ new Map();
|
|
261
|
-
n.set(t, r), l.set(e, n);
|
|
262
|
-
});
|
|
263
|
-
}, b = () => {
|
|
264
|
-
m || f || (m = !0, queueMicrotask(() => {
|
|
265
|
-
m = !1, y(), v(!1);
|
|
266
|
-
}));
|
|
267
|
-
};
|
|
268
|
-
return y(), d = new MutationObserver(() => {
|
|
269
|
-
b();
|
|
270
|
-
}), d.observe(e, {
|
|
271
|
-
childList: !0,
|
|
272
|
-
subtree: !0
|
|
273
|
-
}), _(!0), () => {
|
|
274
|
-
f = !0, d?.disconnect(), h();
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
var D = {
|
|
278
|
-
id: S,
|
|
279
|
-
kind: "field",
|
|
280
|
-
match: (e) => !!e.target.querySelector(b),
|
|
281
|
-
setup: async (e) => {
|
|
282
|
-
let t = e.options || {}, n = a(e);
|
|
283
|
-
C.log("Module setup.", {
|
|
284
|
-
fieldCount: n.length,
|
|
285
|
-
formatting: t.formatting || null
|
|
286
|
-
});
|
|
287
|
-
let r = n.map((n) => {
|
|
288
|
-
let r = n.querySelector(b);
|
|
289
|
-
return r instanceof HTMLInputElement ? E(e.root, n, r, t) : () => {};
|
|
290
|
-
});
|
|
291
|
-
return await e.emit("formie:module:calculations:init", { count: r.length }), { destroy: () => {
|
|
292
|
-
C.log("Module destroy.", { fieldCount: r.length }), r.forEach((e) => {
|
|
293
|
-
e();
|
|
294
|
-
}), e.emit("formie:module:calculations:destroy", {});
|
|
295
|
-
} };
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
//#endregion
|
|
299
|
-
export { D as calculationsModule };
|