@verbb/formie-browser 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/LICENSE.md +40 -0
- package/README.md +34 -0
- package/dist/chunks/address-finder-DfMCiW89.js +47 -0
- package/dist/chunks/api-CbqEMQT5.js +181 -0
- package/dist/chunks/api-DE7LfK-R.js +960 -0
- package/dist/chunks/api-DOfDzYC_.js +538 -0
- package/dist/chunks/async-B3DUf1GZ.js +26 -0
- package/dist/chunks/bpoint-Ciy3yY9Q.js +34 -0
- package/dist/chunks/calculations-CkYAqO_-.js +197 -0
- package/dist/chunks/captcha-eu-DnOWhMwr.js +43 -0
- package/dist/chunks/checkbox-radio-0x7Tc0br.js +197 -0
- package/dist/chunks/chunk-K6L4z4UQ.js +24 -0
- package/dist/chunks/conditions-4fXKhEJS.js +609 -0
- package/dist/chunks/date-picker-B6iZkjHS.js +6204 -0
- package/dist/chunks/debug-KnZeKYBI.js +39 -0
- package/dist/chunks/dist-D09GnXMW.js +2663 -0
- package/dist/chunks/event-names-DamGPtXR.js +51 -0
- package/dist/chunks/eway-DEAYcwT0.js +86 -0
- package/dist/chunks/field-references.keys-BpBZ_quS.js +24 -0
- package/dist/chunks/field-references.resolver-Ba6xhiJC.js +183 -0
- package/dist/chunks/file-upload-Bh63PQSE.js +430 -0
- package/dist/chunks/friendly-captcha-v1-CqO4WVre.js +40 -0
- package/dist/chunks/friendly-captcha-v2-CyykcJcM.js +47 -0
- package/dist/chunks/friendly-challenge-Dg8XkStd.js +1101 -0
- package/dist/chunks/go-cardless-CuND59rR.js +26 -0
- package/dist/chunks/google-address--uR8WDSm.js +208 -0
- package/dist/chunks/hcaptcha-CmaFUesv.js +72 -0
- package/dist/chunks/hidden-CYnZYple.js +36 -0
- package/dist/chunks/http-18nn97DZ.js +29 -0
- package/dist/chunks/i18n-vUh-KGiH.js +55 -0
- package/dist/chunks/loqate-BICNJlVK.js +97 -0
- package/dist/chunks/mollie-DwlsgHZ1.js +26 -0
- package/dist/chunks/moneris-B_IFZFTx.js +159 -0
- package/dist/chunks/opayo-U2x_TOII.js +192 -0
- package/dist/chunks/paddle-BqXFrc79.js +75 -0
- package/dist/chunks/paypal-Cn_DYGDb.js +121 -0
- package/dist/chunks/payway-Rnq796eC.js +75 -0
- package/dist/chunks/phone-country-B6Me4lK0.js +3317 -0
- package/dist/chunks/place-kit-ldUl-u9w.js +56 -0
- package/dist/chunks/placekit-autocomplete.esm-D-lGeaZl.js +1771 -0
- package/dist/chunks/recaptcha-enterprise-DPJNyv1X.js +72 -0
- package/dist/chunks/recaptcha-shared-DTI4qWVR.js +22 -0
- package/dist/chunks/recaptcha-v2-checkbox-zFjpvJ5c.js +49 -0
- package/dist/chunks/recaptcha-v2-invisible-CnYtkNvz.js +62 -0
- package/dist/chunks/recaptcha-v3-EAlWhnkX.js +33 -0
- package/dist/chunks/repeater-CXD1eLSn.js +151 -0
- package/dist/chunks/rich-text-DkmZRhGj.js +442 -0
- package/dist/chunks/scripts-BGD_iU_6.js +41 -0
- package/dist/chunks/sdk-B7u9fTlP.js +2103 -0
- package/dist/chunks/shared-DC6_1u8X.js +85 -0
- package/dist/chunks/signature-E9KyYXS1.js +765 -0
- package/dist/chunks/snaptcha-CCDunGeb.js +8 -0
- package/dist/chunks/square-BLqK51rS.js +61 -0
- package/dist/chunks/stripe-B8gHpZNC.js +273 -0
- package/dist/chunks/styles-BIh6g7V_.js +22 -0
- package/dist/chunks/summary-EcNE0cvg.js +191 -0
- package/dist/chunks/table-yxEDL6kA.js +124 -0
- package/dist/chunks/text-limit-D0H_Ca2c.js +179 -0
- package/dist/chunks/theme-classes-vSHpdCUO.js +59 -0
- package/dist/chunks/turnstile-DP0bdR7T.js +68 -0
- package/dist/chunks/utils-ByrEVYrJ.js +49584 -0
- package/dist/css/formie-base.css +78 -0
- package/dist/css/formie-theme.css +19 -0
- package/dist/css/formie.css +2 -0
- package/dist/css/theme/_buttons.css +249 -0
- package/dist/css/theme/_loading.css +37 -0
- package/dist/css/theme/_messages.css +39 -0
- package/dist/css/theme/_progress.css +62 -0
- package/dist/css/theme/_tokens.css +361 -0
- package/dist/css/theme/_typography.css +70 -0
- package/dist/css/theme/fields/_address.css +17 -0
- package/dist/css/theme/fields/_check-radio.css +108 -0
- package/dist/css/theme/fields/_file.css +58 -0
- package/dist/css/theme/fields/_group.css +13 -0
- package/dist/css/theme/fields/_input.css +48 -0
- package/dist/css/theme/fields/_nested.css +19 -0
- package/dist/css/theme/fields/_repeater.css +69 -0
- package/dist/css/theme/fields/_rich-text.css +201 -0
- package/dist/css/theme/fields/_select.css +37 -0
- package/dist/css/theme/fields/_signature.css +39 -0
- package/dist/css/theme/fields/_summary.css +53 -0
- package/dist/css/theme/fields/_table.css +121 -0
- package/dist/css/theme/fields/_text-limit.css +10 -0
- package/dist/css/theme/forms/_field.css +62 -0
- package/dist/css/theme/forms/_form.css +166 -0
- package/dist/css/theme/integrations/_payment-modal.css +32 -0
- package/dist/css/theme/integrations/_paypal.css +10 -0
- package/dist/css/theme/integrations/_payway.css +10 -0
- package/dist/css/theme/integrations/_stripe.css +24 -0
- package/dist/css/theme/utilities/_accessibility.css +13 -0
- package/dist/css/theme-base/_controls.css +41 -0
- package/dist/css/theme-base/_primitives.css +34 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3206 -0
- package/dist/js/compatibility/dom-adapter.d.ts +12 -0
- package/dist/js/compatibility/dom-adapter.d.ts.map +1 -0
- package/dist/js/compatibility/event-map.d.ts +25 -0
- package/dist/js/compatibility/event-map.d.ts.map +1 -0
- package/dist/js/compatibility/validator-adapter.d.ts +17 -0
- package/dist/js/compatibility/validator-adapter.d.ts.map +1 -0
- package/dist/js/contracts/client.d.ts +40 -0
- package/dist/js/contracts/client.d.ts.map +1 -0
- package/dist/js/contracts/common.d.ts +5 -0
- package/dist/js/contracts/common.d.ts.map +1 -0
- package/dist/js/contracts/modules.d.ts +47 -0
- package/dist/js/contracts/modules.d.ts.map +1 -0
- package/dist/js/contracts/schema.d.ts +79 -0
- package/dist/js/contracts/schema.d.ts.map +1 -0
- package/dist/js/contracts/theme.d.ts +2 -0
- package/dist/js/contracts/theme.d.ts.map +1 -0
- package/dist/js/core/create-formie-client.d.ts +3 -0
- package/dist/js/core/create-formie-client.d.ts.map +1 -0
- package/dist/js/core/dom-events.d.ts +2 -0
- package/dist/js/core/dom-events.d.ts.map +1 -0
- package/dist/js/core/formie.d.ts +27 -0
- package/dist/js/core/formie.d.ts.map +1 -0
- package/dist/js/core/hydrate-modules.d.ts +22 -0
- package/dist/js/core/hydrate-modules.d.ts.map +1 -0
- package/dist/js/core/page-client-event.d.ts +9 -0
- package/dist/js/core/page-client-event.d.ts.map +1 -0
- package/dist/js/core/page-tab-errors.d.ts +2 -0
- package/dist/js/core/page-tab-errors.d.ts.map +1 -0
- package/dist/js/core/submit-flow.d.ts +21 -0
- package/dist/js/core/submit-flow.d.ts.map +1 -0
- package/dist/js/core/submit-result-state.d.ts +8 -0
- package/dist/js/core/submit-result-state.d.ts.map +1 -0
- package/dist/js/core/submit-result-ui.d.ts +10 -0
- package/dist/js/core/submit-result-ui.d.ts.map +1 -0
- package/dist/js/events/event-bus.d.ts +21 -0
- package/dist/js/events/event-bus.d.ts.map +1 -0
- package/dist/js/modules/address/address-finder.d.ts +2 -0
- package/dist/js/modules/address/address-finder.d.ts.map +1 -0
- package/dist/js/modules/address/api.d.ts +8 -0
- package/dist/js/modules/address/api.d.ts.map +1 -0
- package/dist/js/modules/address/constants.d.ts +15 -0
- package/dist/js/modules/address/constants.d.ts.map +1 -0
- package/dist/js/modules/address/factories.d.ts +35 -0
- package/dist/js/modules/address/factories.d.ts.map +1 -0
- package/dist/js/modules/address/google-address.d.ts +2 -0
- package/dist/js/modules/address/google-address.d.ts.map +1 -0
- package/dist/js/modules/address/host.d.ts +30 -0
- package/dist/js/modules/address/host.d.ts.map +1 -0
- package/dist/js/modules/address/index.d.ts +3 -0
- package/dist/js/modules/address/index.d.ts.map +1 -0
- package/dist/js/modules/address/loqate.d.ts +2 -0
- package/dist/js/modules/address/loqate.d.ts.map +1 -0
- package/dist/js/modules/address/place-kit.d.ts +2 -0
- package/dist/js/modules/address/place-kit.d.ts.map +1 -0
- package/dist/js/modules/captchas/api.d.ts +9 -0
- package/dist/js/modules/captchas/api.d.ts.map +1 -0
- package/dist/js/modules/captchas/captcha-eu.d.ts +2 -0
- package/dist/js/modules/captchas/captcha-eu.d.ts.map +1 -0
- package/dist/js/modules/captchas/constants.d.ts +5 -0
- package/dist/js/modules/captchas/constants.d.ts.map +1 -0
- package/dist/js/modules/captchas/factories.d.ts +63 -0
- package/dist/js/modules/captchas/factories.d.ts.map +1 -0
- package/dist/js/modules/captchas/friendly-captcha-v1.d.ts +2 -0
- package/dist/js/modules/captchas/friendly-captcha-v1.d.ts.map +1 -0
- package/dist/js/modules/captchas/friendly-captcha-v2.d.ts +2 -0
- package/dist/js/modules/captchas/friendly-captcha-v2.d.ts.map +1 -0
- package/dist/js/modules/captchas/hcaptcha.d.ts +2 -0
- package/dist/js/modules/captchas/hcaptcha.d.ts.map +1 -0
- package/dist/js/modules/captchas/host.d.ts +78 -0
- package/dist/js/modules/captchas/host.d.ts.map +1 -0
- package/dist/js/modules/captchas/index.d.ts +3 -0
- package/dist/js/modules/captchas/index.d.ts.map +1 -0
- package/dist/js/modules/captchas/recaptcha-enterprise.d.ts +2 -0
- package/dist/js/modules/captchas/recaptcha-enterprise.d.ts.map +1 -0
- package/dist/js/modules/captchas/recaptcha-shared.d.ts +26 -0
- package/dist/js/modules/captchas/recaptcha-shared.d.ts.map +1 -0
- package/dist/js/modules/captchas/recaptcha-v2-checkbox.d.ts +2 -0
- package/dist/js/modules/captchas/recaptcha-v2-checkbox.d.ts.map +1 -0
- package/dist/js/modules/captchas/recaptcha-v2-invisible.d.ts +2 -0
- package/dist/js/modules/captchas/recaptcha-v2-invisible.d.ts.map +1 -0
- package/dist/js/modules/captchas/recaptcha-v3.d.ts +2 -0
- package/dist/js/modules/captchas/recaptcha-v3.d.ts.map +1 -0
- package/dist/js/modules/captchas/snaptcha.d.ts +2 -0
- package/dist/js/modules/captchas/snaptcha.d.ts.map +1 -0
- package/dist/js/modules/captchas/turnstile.d.ts +2 -0
- package/dist/js/modules/captchas/turnstile.d.ts.map +1 -0
- package/dist/js/modules/captchas/utils.d.ts +13 -0
- package/dist/js/modules/captchas/utils.d.ts.map +1 -0
- package/dist/js/modules/fields/calculations.d.ts +3 -0
- package/dist/js/modules/fields/calculations.d.ts.map +1 -0
- package/dist/js/modules/fields/checkbox-radio.d.ts +3 -0
- package/dist/js/modules/fields/checkbox-radio.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/config.d.ts +5 -0
- package/dist/js/modules/fields/conditions/config.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/effects.d.ts +2 -0
- package/dist/js/modules/fields/conditions/effects.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/evaluator.d.ts +6 -0
- package/dist/js/modules/fields/conditions/evaluator.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/references.d.ts +5 -0
- package/dist/js/modules/fields/conditions/references.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/transforms.d.ts +3 -0
- package/dist/js/modules/fields/conditions/transforms.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/types.d.ts +30 -0
- package/dist/js/modules/fields/conditions/types.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions/values.d.ts +5 -0
- package/dist/js/modules/fields/conditions/values.d.ts.map +1 -0
- package/dist/js/modules/fields/conditions.d.ts +3 -0
- package/dist/js/modules/fields/conditions.d.ts.map +1 -0
- package/dist/js/modules/fields/date-picker.d.ts +3 -0
- package/dist/js/modules/fields/date-picker.d.ts.map +1 -0
- package/dist/js/modules/fields/file-upload.d.ts +3 -0
- package/dist/js/modules/fields/file-upload.d.ts.map +1 -0
- package/dist/js/modules/fields/hidden.d.ts +3 -0
- package/dist/js/modules/fields/hidden.d.ts.map +1 -0
- package/dist/js/modules/fields/index.d.ts +3 -0
- package/dist/js/modules/fields/index.d.ts.map +1 -0
- package/dist/js/modules/fields/phone-country.d.ts +3 -0
- package/dist/js/modules/fields/phone-country.d.ts.map +1 -0
- package/dist/js/modules/fields/repeater.d.ts +3 -0
- package/dist/js/modules/fields/repeater.d.ts.map +1 -0
- package/dist/js/modules/fields/rich-text.d.ts +3 -0
- package/dist/js/modules/fields/rich-text.d.ts.map +1 -0
- package/dist/js/modules/fields/shared.d.ts +20 -0
- package/dist/js/modules/fields/shared.d.ts.map +1 -0
- package/dist/js/modules/fields/signature.d.ts +3 -0
- package/dist/js/modules/fields/signature.d.ts.map +1 -0
- package/dist/js/modules/fields/summary.d.ts +3 -0
- package/dist/js/modules/fields/summary.d.ts.map +1 -0
- package/dist/js/modules/fields/table.d.ts +3 -0
- package/dist/js/modules/fields/table.d.ts.map +1 -0
- package/dist/js/modules/fields/text-limit.d.ts +3 -0
- package/dist/js/modules/fields/text-limit.d.ts.map +1 -0
- package/dist/js/modules/loader.d.ts +11 -0
- package/dist/js/modules/loader.d.ts.map +1 -0
- package/dist/js/modules/payments/api.d.ts +8 -0
- package/dist/js/modules/payments/api.d.ts.map +1 -0
- package/dist/js/modules/payments/bpoint.d.ts +2 -0
- package/dist/js/modules/payments/bpoint.d.ts.map +1 -0
- package/dist/js/modules/payments/constants.d.ts +5 -0
- package/dist/js/modules/payments/constants.d.ts.map +1 -0
- package/dist/js/modules/payments/eway.d.ts +9 -0
- package/dist/js/modules/payments/eway.d.ts.map +1 -0
- package/dist/js/modules/payments/factories.d.ts +54 -0
- package/dist/js/modules/payments/factories.d.ts.map +1 -0
- package/dist/js/modules/payments/go-cardless.d.ts +2 -0
- package/dist/js/modules/payments/go-cardless.d.ts.map +1 -0
- package/dist/js/modules/payments/host.d.ts +70 -0
- package/dist/js/modules/payments/host.d.ts.map +1 -0
- package/dist/js/modules/payments/index.d.ts +3 -0
- package/dist/js/modules/payments/index.d.ts.map +1 -0
- package/dist/js/modules/payments/mollie.d.ts +2 -0
- package/dist/js/modules/payments/mollie.d.ts.map +1 -0
- package/dist/js/modules/payments/moneris.d.ts +2 -0
- package/dist/js/modules/payments/moneris.d.ts.map +1 -0
- package/dist/js/modules/payments/opayo.d.ts +25 -0
- package/dist/js/modules/payments/opayo.d.ts.map +1 -0
- package/dist/js/modules/payments/paddle.d.ts +2 -0
- package/dist/js/modules/payments/paddle.d.ts.map +1 -0
- package/dist/js/modules/payments/paypal.d.ts +2 -0
- package/dist/js/modules/payments/paypal.d.ts.map +1 -0
- package/dist/js/modules/payments/payway.d.ts +2 -0
- package/dist/js/modules/payments/payway.d.ts.map +1 -0
- package/dist/js/modules/payments/square.d.ts +2 -0
- package/dist/js/modules/payments/square.d.ts.map +1 -0
- package/dist/js/modules/payments/stripe.d.ts +2 -0
- package/dist/js/modules/payments/stripe.d.ts.map +1 -0
- package/dist/js/modules/payments/utils.d.ts +17 -0
- package/dist/js/modules/payments/utils.d.ts.map +1 -0
- package/dist/js/modules/registry.d.ts +9 -0
- package/dist/js/modules/registry.d.ts.map +1 -0
- package/dist/js/modules/styles.d.ts +2 -0
- package/dist/js/modules/styles.d.ts.map +1 -0
- package/dist/js/submit/pipeline.d.ts +18 -0
- package/dist/js/submit/pipeline.d.ts.map +1 -0
- package/dist/js/theme/theme-classes.d.ts +10 -0
- package/dist/js/theme/theme-classes.d.ts.map +1 -0
- package/dist/js/transport/forms-api.d.ts +11 -0
- package/dist/js/transport/forms-api.d.ts.map +1 -0
- package/dist/js/utils/async.d.ts +8 -0
- package/dist/js/utils/async.d.ts.map +1 -0
- package/dist/js/utils/debug.d.ts +10 -0
- package/dist/js/utils/debug.d.ts.map +1 -0
- package/dist/js/utils/event-names.d.ts +13 -0
- package/dist/js/utils/event-names.d.ts.map +1 -0
- package/dist/js/utils/field-references.d.ts +6 -0
- package/dist/js/utils/field-references.d.ts.map +1 -0
- package/dist/js/utils/field-references.keys.d.ts +4 -0
- package/dist/js/utils/field-references.keys.d.ts.map +1 -0
- package/dist/js/utils/field-references.parser.d.ts +3 -0
- package/dist/js/utils/field-references.parser.d.ts.map +1 -0
- package/dist/js/utils/field-references.registry.d.ts +3 -0
- package/dist/js/utils/field-references.registry.d.ts.map +1 -0
- package/dist/js/utils/field-references.resolver.d.ts +4 -0
- package/dist/js/utils/field-references.resolver.d.ts.map +1 -0
- package/dist/js/utils/field-references.types.d.ts +27 -0
- package/dist/js/utils/field-references.types.d.ts.map +1 -0
- package/dist/js/utils/fields.d.ts +5 -0
- package/dist/js/utils/fields.d.ts.map +1 -0
- package/dist/js/utils/http.d.ts +9 -0
- package/dist/js/utils/http.d.ts.map +1 -0
- package/dist/js/utils/i18n.d.ts +7 -0
- package/dist/js/utils/i18n.d.ts.map +1 -0
- package/dist/js/utils/scripts.d.ts +13 -0
- package/dist/js/utils/scripts.d.ts.map +1 -0
- package/dist/js/utils/unload-warning.d.ts +10 -0
- package/dist/js/utils/unload-warning.d.ts.map +1 -0
- package/dist/js/validation/rules/email.d.ts +4 -0
- package/dist/js/validation/rules/email.d.ts.map +1 -0
- package/dist/js/validation/rules/match.d.ts +4 -0
- package/dist/js/validation/rules/match.d.ts.map +1 -0
- package/dist/js/validation/rules/number.d.ts +4 -0
- package/dist/js/validation/rules/number.d.ts.map +1 -0
- package/dist/js/validation/rules/required.d.ts +4 -0
- package/dist/js/validation/rules/required.d.ts.map +1 -0
- package/dist/js/validation/rules/shared.d.ts +7 -0
- package/dist/js/validation/rules/shared.d.ts.map +1 -0
- package/dist/js/validation/rules/url.d.ts +4 -0
- package/dist/js/validation/rules/url.d.ts.map +1 -0
- package/dist/js/validation/rules.d.ts +10 -0
- package/dist/js/validation/rules.d.ts.map +1 -0
- package/dist/js/validation/types.d.ts +44 -0
- package/dist/js/validation/types.d.ts.map +1 -0
- package/dist/js/validation/validator.d.ts +53 -0
- package/dist/js/validation/validator.d.ts.map +1 -0
- package/package.json +78 -0
- package/src/css/formie-base.css +78 -0
- package/src/css/formie-theme.css +19 -0
- package/src/css/formie.css +2 -0
- package/src/css/theme/_buttons.css +249 -0
- package/src/css/theme/_loading.css +37 -0
- package/src/css/theme/_messages.css +39 -0
- package/src/css/theme/_progress.css +62 -0
- package/src/css/theme/_tokens.css +361 -0
- package/src/css/theme/_typography.css +70 -0
- package/src/css/theme/fields/_address.css +17 -0
- package/src/css/theme/fields/_check-radio.css +108 -0
- package/src/css/theme/fields/_file.css +58 -0
- package/src/css/theme/fields/_group.css +13 -0
- package/src/css/theme/fields/_input.css +48 -0
- package/src/css/theme/fields/_nested.css +19 -0
- package/src/css/theme/fields/_repeater.css +69 -0
- package/src/css/theme/fields/_rich-text.css +201 -0
- package/src/css/theme/fields/_select.css +37 -0
- package/src/css/theme/fields/_signature.css +39 -0
- package/src/css/theme/fields/_summary.css +53 -0
- package/src/css/theme/fields/_table.css +121 -0
- package/src/css/theme/fields/_text-limit.css +10 -0
- package/src/css/theme/forms/_field.css +62 -0
- package/src/css/theme/forms/_form.css +166 -0
- package/src/css/theme/integrations/_payment-modal.css +32 -0
- package/src/css/theme/integrations/_paypal.css +10 -0
- package/src/css/theme/integrations/_payway.css +10 -0
- package/src/css/theme/integrations/_stripe.css +24 -0
- package/src/css/theme/utilities/_accessibility.css +13 -0
- package/src/css/theme-base/_controls.css +41 -0
- package/src/css/theme-base/_primitives.css +34 -0
- package/src/icons/rich-text/aligncenter.svg +6 -0
- package/src/icons/rich-text/alignleft.svg +6 -0
- package/src/icons/rich-text/alignright.svg +6 -0
- package/src/icons/rich-text/bold.svg +4 -0
- package/src/icons/rich-text/clear.svg +6 -0
- package/src/icons/rich-text/code.svg +4 -0
- package/src/icons/rich-text/heading1.svg +3 -0
- package/src/icons/rich-text/heading2.svg +3 -0
- package/src/icons/rich-text/image.svg +6 -0
- package/src/icons/rich-text/italic.svg +5 -0
- package/src/icons/rich-text/line.svg +3 -0
- package/src/icons/rich-text/link.svg +4 -0
- package/src/icons/rich-text/olist.svg +8 -0
- package/src/icons/rich-text/paragraph.svg +3 -0
- package/src/icons/rich-text/quote.svg +4 -0
- package/src/icons/rich-text/strikethrough.svg +4 -0
- package/src/icons/rich-text/ulist.svg +8 -0
- package/src/icons/rich-text/underline.svg +4 -0
- package/src/index.ts +125 -0
- package/src/js/compatibility/dom-adapter.ts +129 -0
- package/src/js/compatibility/event-map.ts +72 -0
- package/src/js/compatibility/validator-adapter.ts +105 -0
- package/src/js/contracts/client.ts +43 -0
- package/src/js/contracts/common.ts +14 -0
- package/src/js/contracts/modules.ts +53 -0
- package/src/js/contracts/schema.ts +83 -0
- package/src/js/contracts/theme.ts +1 -0
- package/src/js/core/create-formie-client.ts +1519 -0
- package/src/js/core/dom-events.ts +8 -0
- package/src/js/core/formie.ts +242 -0
- package/src/js/core/hydrate-modules.ts +102 -0
- package/src/js/core/page-client-event.ts +129 -0
- package/src/js/core/page-tab-errors.ts +37 -0
- package/src/js/core/submit-flow.ts +120 -0
- package/src/js/core/submit-result-state.ts +597 -0
- package/src/js/core/submit-result-ui.ts +448 -0
- package/src/js/events/event-bus.ts +109 -0
- package/src/js/modules/address/address-finder.ts +85 -0
- package/src/js/modules/address/api.ts +22 -0
- package/src/js/modules/address/constants.ts +15 -0
- package/src/js/modules/address/factories.ts +203 -0
- package/src/js/modules/address/google-address.ts +345 -0
- package/src/js/modules/address/host.ts +137 -0
- package/src/js/modules/address/index.ts +10 -0
- package/src/js/modules/address/loqate.ts +128 -0
- package/src/js/modules/address/place-kit.ts +94 -0
- package/src/js/modules/captchas/api.ts +25 -0
- package/src/js/modules/captchas/captcha-eu.ts +86 -0
- package/src/js/modules/captchas/constants.ts +4 -0
- package/src/js/modules/captchas/factories.ts +485 -0
- package/src/js/modules/captchas/friendly-captcha-v1.ts +65 -0
- package/src/js/modules/captchas/friendly-captcha-v2.ts +84 -0
- package/src/js/modules/captchas/hcaptcha.ts +153 -0
- package/src/js/modules/captchas/host.ts +448 -0
- package/src/js/modules/captchas/index.ts +16 -0
- package/src/js/modules/captchas/recaptcha-enterprise.ts +138 -0
- package/src/js/modules/captchas/recaptcha-shared.ts +69 -0
- package/src/js/modules/captchas/recaptcha-v2-checkbox.ts +72 -0
- package/src/js/modules/captchas/recaptcha-v2-invisible.ts +108 -0
- package/src/js/modules/captchas/recaptcha-v3.ts +62 -0
- package/src/js/modules/captchas/snaptcha.ts +10 -0
- package/src/js/modules/captchas/turnstile.ts +131 -0
- package/src/js/modules/captchas/utils.ts +85 -0
- package/src/js/modules/fields/calculations.ts +273 -0
- package/src/js/modules/fields/checkbox-radio.ts +295 -0
- package/src/js/modules/fields/conditions/config.ts +79 -0
- package/src/js/modules/fields/conditions/effects.ts +166 -0
- package/src/js/modules/fields/conditions/evaluator.ts +44 -0
- package/src/js/modules/fields/conditions/references.ts +165 -0
- package/src/js/modules/fields/conditions/transforms.ts +206 -0
- package/src/js/modules/fields/conditions/types.ts +33 -0
- package/src/js/modules/fields/conditions/values.ts +115 -0
- package/src/js/modules/fields/conditions.ts +229 -0
- package/src/js/modules/fields/date-picker.ts +272 -0
- package/src/js/modules/fields/file-upload.ts +628 -0
- package/src/js/modules/fields/hidden.ts +58 -0
- package/src/js/modules/fields/index.ts +19 -0
- package/src/js/modules/fields/phone-country.ts +226 -0
- package/src/js/modules/fields/repeater.ts +231 -0
- package/src/js/modules/fields/rich-text.ts +217 -0
- package/src/js/modules/fields/shared.ts +238 -0
- package/src/js/modules/fields/signature.ts +202 -0
- package/src/js/modules/fields/summary.ts +272 -0
- package/src/js/modules/fields/table.ts +197 -0
- package/src/js/modules/fields/text-limit.ts +280 -0
- package/src/js/modules/loader.ts +331 -0
- package/src/js/modules/payments/api.ts +20 -0
- package/src/js/modules/payments/bpoint.ts +48 -0
- package/src/js/modules/payments/constants.ts +17 -0
- package/src/js/modules/payments/eway.ts +132 -0
- package/src/js/modules/payments/factories.ts +332 -0
- package/src/js/modules/payments/go-cardless.ts +37 -0
- package/src/js/modules/payments/host.ts +459 -0
- package/src/js/modules/payments/index.ts +17 -0
- package/src/js/modules/payments/mollie.ts +38 -0
- package/src/js/modules/payments/moneris.ts +216 -0
- package/src/js/modules/payments/opayo.ts +272 -0
- package/src/js/modules/payments/paddle.ts +111 -0
- package/src/js/modules/payments/payment.ts +183 -0
- package/src/js/modules/payments/paypal.ts +214 -0
- package/src/js/modules/payments/payway.ts +114 -0
- package/src/js/modules/payments/square.ts +106 -0
- package/src/js/modules/payments/stripe.ts +426 -0
- package/src/js/modules/payments/stub-payment-module.ts +87 -0
- package/src/js/modules/payments/utils.ts +60 -0
- package/src/js/modules/registry.ts +38 -0
- package/src/js/modules/styles.ts +29 -0
- package/src/js/submit/pipeline.ts +514 -0
- package/src/js/theme/theme-classes.ts +106 -0
- package/src/js/transport/forms-api.ts +345 -0
- package/src/js/utils/async.ts +81 -0
- package/src/js/utils/debug.ts +59 -0
- package/src/js/utils/event-names.ts +60 -0
- package/src/js/utils/field-references.keys.ts +47 -0
- package/src/js/utils/field-references.parser.ts +121 -0
- package/src/js/utils/field-references.registry.ts +50 -0
- package/src/js/utils/field-references.resolver.ts +115 -0
- package/src/js/utils/field-references.ts +11 -0
- package/src/js/utils/field-references.types.ts +31 -0
- package/src/js/utils/fields.ts +58 -0
- package/src/js/utils/http.ts +51 -0
- package/src/js/utils/i18n.ts +98 -0
- package/src/js/utils/scripts.ts +84 -0
- package/src/js/utils/unload-warning.ts +190 -0
- package/src/js/validation/rules/email.ts +18 -0
- package/src/js/validation/rules/match.ts +26 -0
- package/src/js/validation/rules/minmax.ts +47 -0
- package/src/js/validation/rules/number.ts +55 -0
- package/src/js/validation/rules/pattern.ts +29 -0
- package/src/js/validation/rules/required.ts +30 -0
- package/src/js/validation/rules/shared.ts +47 -0
- package/src/js/validation/rules/url.ts +23 -0
- package/src/js/validation/rules.ts +16 -0
- package/src/js/validation/types.ts +50 -0
- package/src/js/validation/validator.ts +643 -0
- package/src/vendor.d.ts +100 -0
- package/src/vite-env.d.ts +22 -0
- package/vite-dev.mjs +22 -0
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
import { syncPageTabErrors } from '#core/page-tab-errors';
|
|
2
|
+
import rules from '#validation/rules';
|
|
3
|
+
import type {
|
|
4
|
+
ValidationConfig,
|
|
5
|
+
ValidationContext,
|
|
6
|
+
ValidationError,
|
|
7
|
+
ValidationInput,
|
|
8
|
+
ValidationRules,
|
|
9
|
+
} from '#validation/types';
|
|
10
|
+
import { t } from '#utils/i18n';
|
|
11
|
+
import { getValidatorEventName } from '#utils/event-names';
|
|
12
|
+
import { createDebug } from '#utils/debug';
|
|
13
|
+
|
|
14
|
+
type ValidatorDefinition = {
|
|
15
|
+
validate: (ctx: ValidationContext) => boolean;
|
|
16
|
+
errorMessage?: (ctx: ValidationContext) => string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type ValidateOptions = {
|
|
20
|
+
includeHiddenPages?: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const DEFAULT_PATTERNS: Record<string, RegExp> = {
|
|
24
|
+
// eslint-disable-next-line
|
|
25
|
+
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,})+$/,
|
|
26
|
+
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*)?$/,
|
|
27
|
+
number: /^(?:[-+]?[0-9]*[.,]?[0-9]+)$/,
|
|
28
|
+
color: /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,
|
|
29
|
+
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))/,
|
|
30
|
+
time: /^(?:(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]))$/,
|
|
31
|
+
month: /^(?:(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])))$/,
|
|
32
|
+
};
|
|
33
|
+
const debug = createDebug('general', 'validator');
|
|
34
|
+
|
|
35
|
+
function isValidationInput(node: Element | null): node is ValidationInput {
|
|
36
|
+
return !!node && (
|
|
37
|
+
node instanceof HTMLInputElement ||
|
|
38
|
+
node instanceof HTMLSelectElement ||
|
|
39
|
+
node instanceof HTMLTextAreaElement
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function removeDescribedBy(input: HTMLElement, describedById: string): void {
|
|
44
|
+
const current = (input.getAttribute('aria-describedby') || '').trim();
|
|
45
|
+
|
|
46
|
+
if (!current) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const filtered = current.split(/\s+/).filter((item) => {
|
|
51
|
+
return item !== describedById;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (filtered.length) {
|
|
55
|
+
input.setAttribute('aria-describedby', filtered.join(' '));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
input.removeAttribute('aria-describedby');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function appendDescribedBy(input: HTMLElement, describedById: string): void {
|
|
63
|
+
const current = (input.getAttribute('aria-describedby') || '').trim();
|
|
64
|
+
const items = current ? current.split(/\s+/) : [];
|
|
65
|
+
|
|
66
|
+
if (!items.includes(describedById)) {
|
|
67
|
+
items.push(describedById);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
input.setAttribute('aria-describedby', items.join(' ').trim());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function setErrorMessageReference(input: HTMLElement, errorMessageId: string): void {
|
|
74
|
+
input.setAttribute('aria-errormessage', errorMessageId);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function clearErrorMessageReference(input: HTMLElement, errorMessageId: string): void {
|
|
78
|
+
if (input.getAttribute('aria-errormessage') === errorMessageId) {
|
|
79
|
+
input.removeAttribute('aria-errormessage');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export class FormieValidator {
|
|
84
|
+
form: HTMLFormElement;
|
|
85
|
+
errors: ValidationError[] = [];
|
|
86
|
+
validators: Record<string, ValidatorDefinition> = {};
|
|
87
|
+
boundListeners = false;
|
|
88
|
+
activated = new WeakSet<ValidationInput>();
|
|
89
|
+
submitted = false;
|
|
90
|
+
initialValues = new WeakMap<ValidationInput, string | boolean>();
|
|
91
|
+
onBlur: EventListener;
|
|
92
|
+
onChange: EventListener;
|
|
93
|
+
onInput: EventListener;
|
|
94
|
+
config: ValidationConfig;
|
|
95
|
+
|
|
96
|
+
constructor(form: HTMLFormElement, config: Partial<ValidationConfig> = {}) {
|
|
97
|
+
this.form = form;
|
|
98
|
+
this.onBlur = this.blurHandler.bind(this);
|
|
99
|
+
this.onChange = this.changeHandler.bind(this);
|
|
100
|
+
this.onInput = this.inputHandler.bind(this);
|
|
101
|
+
this.config = {
|
|
102
|
+
live: false,
|
|
103
|
+
errorMessage: '',
|
|
104
|
+
fieldContainerErrorClass: [],
|
|
105
|
+
inputErrorClass: [],
|
|
106
|
+
messagesClass: [],
|
|
107
|
+
messageClass: [],
|
|
108
|
+
fieldsSelector: 'input:not([type="hidden"]):not([type="submit"]):not([type="button"]):not([disabled]), select:not([disabled]), textarea:not([disabled])',
|
|
109
|
+
patterns: DEFAULT_PATTERNS,
|
|
110
|
+
...config,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
Object.entries(rules).forEach(([validatorName, validator]) => {
|
|
114
|
+
this.addValidator(validatorName, validator.rule, validator.message);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
this.init();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
init(): void {
|
|
121
|
+
debug.log('Initializing validator.', {
|
|
122
|
+
formId: this.form.id || null,
|
|
123
|
+
live: this.config.live,
|
|
124
|
+
});
|
|
125
|
+
this.form.setAttribute('novalidate', 'true');
|
|
126
|
+
|
|
127
|
+
this.inputs().forEach((input) => {
|
|
128
|
+
this.initialValues.set(input, this.getInputValue(input));
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
if (this.config.live) {
|
|
132
|
+
this.addEventListeners();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this.emitEvent(document, getValidatorEventName('ready'), {
|
|
136
|
+
validator: this,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
inputs(inputOrSelector: Element | null = null): ValidationInput[] {
|
|
141
|
+
if (isValidationInput(inputOrSelector)) {
|
|
142
|
+
return [inputOrSelector];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const root = inputOrSelector || this.form;
|
|
146
|
+
|
|
147
|
+
return Array.from(root.querySelectorAll(this.config.fieldsSelector)).filter((input): input is ValidationInput => {
|
|
148
|
+
return isValidationInput(input);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
getInputValue(input: ValidationInput): string | boolean {
|
|
153
|
+
if (input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio')) {
|
|
154
|
+
return input.checked;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (input instanceof HTMLInputElement && input.type === 'file') {
|
|
158
|
+
return input.files?.length ? Array.from(input.files).map((file) => {
|
|
159
|
+
return file.name;
|
|
160
|
+
}).join('|') : '';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return input.value ?? '';
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
isDirty(input: ValidationInput): boolean {
|
|
167
|
+
if (!this.initialValues.has(input)) {
|
|
168
|
+
this.initialValues.set(input, this.getInputValue(input));
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return this.getInputValue(input) !== this.initialValues.get(input);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
shouldShowError(input: ValidationInput): boolean {
|
|
176
|
+
return this.submitted || this.activated.has(input);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
validate(inputOrSelector: Element | null = null, options: ValidateOptions = {}): ValidationError[] {
|
|
180
|
+
this.errors = [];
|
|
181
|
+
|
|
182
|
+
// Checkbox/radio fields often render as many inputs for one logical field.
|
|
183
|
+
// We validate and render errors once per group to avoid duplicate messages.
|
|
184
|
+
const seenGroups = new Set<string>();
|
|
185
|
+
|
|
186
|
+
this.inputs(inputOrSelector).forEach((input) => {
|
|
187
|
+
let errorShown = false;
|
|
188
|
+
|
|
189
|
+
if (!this.isVisible(input, options)) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const field = input.closest('[data-formie-field-handle]') as HTMLElement | null;
|
|
194
|
+
const groupKey = (input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio'))
|
|
195
|
+
? `${field?.getAttribute('data-formie-field-handle') || ''}:${input.name}`
|
|
196
|
+
: null;
|
|
197
|
+
|
|
198
|
+
if (groupKey) {
|
|
199
|
+
if (seenGroups.has(groupKey)) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
seenGroups.add(groupKey);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (this.shouldShowError(input)) {
|
|
207
|
+
this.removeError(input);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const opts = this.getValidatorCallbackOptions(input);
|
|
211
|
+
|
|
212
|
+
Object.entries(this.validators).forEach(([validatorName, validatorConfig]) => {
|
|
213
|
+
const isValid = validatorConfig.validate(opts);
|
|
214
|
+
|
|
215
|
+
if (!isValid) {
|
|
216
|
+
const errorMessage = this.getErrorMessage(input, validatorName, validatorConfig, opts);
|
|
217
|
+
|
|
218
|
+
if (this.shouldShowError(input) && !errorShown) {
|
|
219
|
+
this.showError(input, validatorName, errorMessage);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
this.errors.push({
|
|
223
|
+
input,
|
|
224
|
+
field: opts.field,
|
|
225
|
+
validator: validatorName,
|
|
226
|
+
message: errorMessage,
|
|
227
|
+
handle: opts.field?.getAttribute('data-formie-field-handle') || null,
|
|
228
|
+
result: false,
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
errorShown = true;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
if (!errorShown && this.shouldShowError(input)) {
|
|
236
|
+
this.removeError(input);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
debug.log('Validation pass complete.', {
|
|
241
|
+
errorCount: this.errors.length,
|
|
242
|
+
includeHiddenPages: options.includeHiddenPages === true,
|
|
243
|
+
});
|
|
244
|
+
return this.errors;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
removeAllErrors(): void {
|
|
248
|
+
this.inputs().forEach((input) => {
|
|
249
|
+
this.removeError(input);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
removeError(input: ValidationInput): void {
|
|
254
|
+
const fieldContainer = input.closest('[data-formie-field-handle]') as HTMLElement | null;
|
|
255
|
+
|
|
256
|
+
if (!fieldContainer) {
|
|
257
|
+
input.removeAttribute('aria-invalid');
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const errorMessages = fieldContainer.querySelector('[data-formie-field-errors]') as HTMLElement | null;
|
|
262
|
+
const errorContainerId = errorMessages?.id || '';
|
|
263
|
+
|
|
264
|
+
fieldContainer.querySelectorAll('[data-formie-field-error]').forEach((node) => {
|
|
265
|
+
node.remove();
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
if (errorMessages) {
|
|
269
|
+
errorMessages.innerHTML = '';
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
fieldContainer.querySelectorAll('input, select, textarea').forEach((fieldInput) => {
|
|
273
|
+
const element = fieldInput as HTMLElement;
|
|
274
|
+
element.removeAttribute('aria-invalid');
|
|
275
|
+
if (this.config.inputErrorClass.length) {
|
|
276
|
+
element.classList.remove(...this.config.inputErrorClass);
|
|
277
|
+
}
|
|
278
|
+
element.removeAttribute('data-formie-input-has-error');
|
|
279
|
+
|
|
280
|
+
if (errorContainerId) {
|
|
281
|
+
removeDescribedBy(element, errorContainerId);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
fieldContainer.querySelectorAll('[data-formie-field-error]').forEach((errorNode) => {
|
|
285
|
+
const errorMessageId = (errorNode as HTMLElement).id;
|
|
286
|
+
|
|
287
|
+
if (errorMessageId) {
|
|
288
|
+
clearErrorMessageReference(element, errorMessageId);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// Nested field wrappers inherit error state so repeaters/groups can reflect
|
|
294
|
+
// child validation failures without each feature reimplementing traversal.
|
|
295
|
+
for (let element = fieldContainer as HTMLElement | null; element; element = element.parentElement?.closest('[data-formie-field-handle]') as HTMLElement | null) {
|
|
296
|
+
if (this.config.fieldContainerErrorClass.length) {
|
|
297
|
+
element.classList.remove(...this.config.fieldContainerErrorClass);
|
|
298
|
+
}
|
|
299
|
+
element.removeAttribute('data-formie-field-has-error');
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
this.emitEvent(input, getValidatorEventName('clear-error'), {
|
|
303
|
+
validator: this,
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
syncPageTabErrors(this.form);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
showError(input: ValidationInput, validatorName: string, errorMessage: string): void {
|
|
310
|
+
const fieldContainer = input.closest('[data-formie-field-handle]') as HTMLElement | null;
|
|
311
|
+
|
|
312
|
+
if (!fieldContainer) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
let errorMessages = fieldContainer.querySelector('[data-formie-field-errors]') as HTMLElement | null;
|
|
317
|
+
|
|
318
|
+
if (!errorMessages) {
|
|
319
|
+
errorMessages = document.createElement('div');
|
|
320
|
+
errorMessages.setAttribute('data-formie-field-errors', 'true');
|
|
321
|
+
if (this.config.messagesClass.length) {
|
|
322
|
+
errorMessages.classList.add(...this.config.messagesClass);
|
|
323
|
+
}
|
|
324
|
+
fieldContainer.appendChild(errorMessages);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (this.config.messagesClass.length) {
|
|
328
|
+
errorMessages.classList.add(...this.config.messagesClass);
|
|
329
|
+
}
|
|
330
|
+
errorMessages.innerHTML = '';
|
|
331
|
+
|
|
332
|
+
const handle = fieldContainer.getAttribute('data-formie-field-handle') || 'field';
|
|
333
|
+
const errorId = `${handle}-error`;
|
|
334
|
+
errorMessages.id = errorMessages.id || `${handle}-errors`;
|
|
335
|
+
errorMessages.setAttribute('aria-live', 'polite');
|
|
336
|
+
errorMessages.setAttribute('aria-atomic', 'true');
|
|
337
|
+
|
|
338
|
+
const errorElement = document.createElement('div');
|
|
339
|
+
errorElement.setAttribute('data-formie-field-error', 'true');
|
|
340
|
+
errorElement.setAttribute(`data-formie-field-error-${validatorName}`, 'true');
|
|
341
|
+
errorElement.setAttribute('id', errorId);
|
|
342
|
+
errorElement.setAttribute('role', 'alert');
|
|
343
|
+
if (this.config.messageClass.length) {
|
|
344
|
+
errorElement.classList.add(...this.config.messageClass);
|
|
345
|
+
}
|
|
346
|
+
errorElement.textContent = errorMessage;
|
|
347
|
+
errorMessages.appendChild(errorElement);
|
|
348
|
+
|
|
349
|
+
fieldContainer.setAttribute('data-formie-field-has-error', 'true');
|
|
350
|
+
|
|
351
|
+
fieldContainer.querySelectorAll('input, select, textarea').forEach((fieldInput) => {
|
|
352
|
+
const element = fieldInput as HTMLElement;
|
|
353
|
+
element.setAttribute('aria-invalid', 'true');
|
|
354
|
+
if (this.config.inputErrorClass.length) {
|
|
355
|
+
element.classList.add(...this.config.inputErrorClass);
|
|
356
|
+
}
|
|
357
|
+
element.setAttribute('data-formie-input-has-error', 'true');
|
|
358
|
+
appendDescribedBy(element, errorMessages.id);
|
|
359
|
+
setErrorMessageReference(element, errorId);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// Mirror the same nested traversal on add so parent wrappers stay visually
|
|
363
|
+
// in sync with the actual field that failed validation.
|
|
364
|
+
for (let element = fieldContainer as HTMLElement | null; element; element = element.parentElement?.closest('[data-formie-field-handle]') as HTMLElement | null) {
|
|
365
|
+
if (this.config.fieldContainerErrorClass.length) {
|
|
366
|
+
element.classList.add(...this.config.fieldContainerErrorClass);
|
|
367
|
+
}
|
|
368
|
+
element.setAttribute('data-formie-field-has-error', 'true');
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
this.emitEvent(input, getValidatorEventName('show-error'), {
|
|
372
|
+
validator: this,
|
|
373
|
+
validatorName,
|
|
374
|
+
errorMessage,
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
syncPageTabErrors(this.form);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
getValidatorCallbackOptions(input: ValidationInput): ValidationContext {
|
|
381
|
+
const fieldContainer = input.closest('[data-formie-field-handle]') as HTMLElement | null;
|
|
382
|
+
const label = fieldContainer?.querySelector('[data-formie-field-label]')?.childNodes[0]?.textContent?.trim() ?? '';
|
|
383
|
+
const rules = this.parseValidationRules(fieldContainer?.getAttribute('data-formie-validation'));
|
|
384
|
+
|
|
385
|
+
return {
|
|
386
|
+
t,
|
|
387
|
+
input,
|
|
388
|
+
label,
|
|
389
|
+
field: fieldContainer,
|
|
390
|
+
form: this.form,
|
|
391
|
+
config: this.config,
|
|
392
|
+
rules,
|
|
393
|
+
getRule: (rule) => {
|
|
394
|
+
return this.getRule(fieldContainer, rule);
|
|
395
|
+
},
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
getErrorMessage(input: ValidationInput, validatorName: string, validator: ValidatorDefinition, opts: ValidationContext): string {
|
|
400
|
+
const errorMessage = typeof validator.errorMessage === 'function' ? validator.errorMessage(opts) : validator.errorMessage;
|
|
401
|
+
return errorMessage ?? t('{attribute} is invalid.', { attribute: opts.label });
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
getErrors(): ValidationError[] {
|
|
405
|
+
return this.errors;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
getFieldErrors(errors: ValidationError[] = this.errors): Record<string, string[]> {
|
|
409
|
+
const fieldErrors: Record<string, string[]> = {};
|
|
410
|
+
|
|
411
|
+
errors.forEach((error) => {
|
|
412
|
+
if (!error.handle || fieldErrors[error.handle]?.length) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
fieldErrors[error.handle] = [error.message];
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
return fieldErrors;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
getRule(field: HTMLElement | null, rule: string): ValidationRules[string] | false {
|
|
423
|
+
if (!field) {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const rules = this.parseValidationRules(field.getAttribute('data-formie-validation'));
|
|
428
|
+
|
|
429
|
+
if (Object.prototype.hasOwnProperty.call(rules, rule)) {
|
|
430
|
+
return rules[rule];
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
parseValidationRules(ruleString: string | null | undefined): ValidationRules {
|
|
437
|
+
const rules: ValidationRules = {};
|
|
438
|
+
|
|
439
|
+
if (!ruleString) {
|
|
440
|
+
return rules;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
let parsedRules: unknown = null;
|
|
444
|
+
|
|
445
|
+
try {
|
|
446
|
+
parsedRules = JSON.parse(ruleString);
|
|
447
|
+
} catch {
|
|
448
|
+
debug.warn('Invalid validation rules payload.', {
|
|
449
|
+
formId: this.form.id || null,
|
|
450
|
+
});
|
|
451
|
+
return rules;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
if (!Array.isArray(parsedRules)) {
|
|
455
|
+
return rules;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
parsedRules.forEach((part) => {
|
|
459
|
+
if (!part || typeof part !== 'object' || Array.isArray(part)) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
const candidate = part as Record<string, unknown>;
|
|
464
|
+
const type = typeof candidate.type === 'string' ? candidate.type.trim() : '';
|
|
465
|
+
|
|
466
|
+
if (!type) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
rules[type] = candidate as ValidationRules[string];
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
return rules;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
destroy(): void {
|
|
477
|
+
debug.log('Destroying validator.', {
|
|
478
|
+
formId: this.form.id || null,
|
|
479
|
+
});
|
|
480
|
+
this.removeEventListeners();
|
|
481
|
+
this.form.removeAttribute('novalidate');
|
|
482
|
+
|
|
483
|
+
this.emitEvent(document, getValidatorEventName('destroy'), {
|
|
484
|
+
validator: this,
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
isVisible(element: ValidationInput, options: ValidateOptions = {}): boolean {
|
|
489
|
+
// Conditionally hidden fields are treated as inactive inputs, and hidden
|
|
490
|
+
// pages are only re-included on the final page submit pass.
|
|
491
|
+
if (element.closest('[data-formie-conditionally-hidden]')) {
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (element.closest('[data-formie-page-hidden]')) {
|
|
496
|
+
return !!options.includeHiddenPages;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
blurHandler(event: Event): void {
|
|
503
|
+
if (!(event.target instanceof HTMLElement) || !isValidationInput(event.target) || !event.target.form?.isSameNode(this.form)) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (event instanceof CustomEvent) {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (event.target instanceof HTMLInputElement && event.target.type === 'file') {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if (event.target instanceof HTMLInputElement && (event.target.type === 'checkbox' || event.target.type === 'radio')) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if (this.isDirty(event.target)) {
|
|
520
|
+
this.activated.add(event.target);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (this.shouldShowError(event.target)) {
|
|
524
|
+
this.validate(event.target);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
changeHandler(event: Event): void {
|
|
529
|
+
if (!(event.target instanceof HTMLElement) || !isValidationInput(event.target) || !event.target.form?.isSameNode(this.form)) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (event instanceof CustomEvent) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
if (event.target instanceof HTMLSelectElement) {
|
|
538
|
+
this.activated.add(event.target);
|
|
539
|
+
this.validate(event.target);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
if (!(event.target instanceof HTMLInputElement)) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (
|
|
548
|
+
event.target.type !== 'file' &&
|
|
549
|
+
event.target.type !== 'checkbox' &&
|
|
550
|
+
event.target.type !== 'radio'
|
|
551
|
+
) {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
this.activated.add(event.target);
|
|
556
|
+
this.validate(event.target);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
inputHandler(event: Event): void {
|
|
560
|
+
if (!(event.target instanceof HTMLElement) || !isValidationInput(event.target) || !event.target.form?.isSameNode(this.form)) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (event instanceof CustomEvent) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (event.target instanceof HTMLInputElement && (event.target.type === 'checkbox' || event.target.type === 'radio')) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
if (this.shouldShowError(event.target)) {
|
|
573
|
+
this.validate(event.target);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
submit(inputOrSelector: Element | null = null, { final = false }: { final?: boolean } = {}): ValidationError[] {
|
|
578
|
+
this.submitted = true;
|
|
579
|
+
debug.log('Submit validation requested.', {
|
|
580
|
+
final,
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
// After the first submit attempt, validation should respond live while the user corrects errors.
|
|
584
|
+
if (!this.boundListeners) {
|
|
585
|
+
this.addEventListeners();
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
this.removeAllErrors();
|
|
589
|
+
|
|
590
|
+
return this.validate(inputOrSelector, {
|
|
591
|
+
includeHiddenPages: final,
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
resetLiveState(): void {
|
|
596
|
+
this.submitted = false;
|
|
597
|
+
this.activated = new WeakSet<ValidationInput>();
|
|
598
|
+
this.errors = [];
|
|
599
|
+
this.removeAllErrors();
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
addEventListeners(): void {
|
|
603
|
+
if (this.boundListeners) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
this.form.addEventListener('blur', this.onBlur, true);
|
|
608
|
+
this.form.addEventListener('change', this.onChange, false);
|
|
609
|
+
this.form.addEventListener('input', this.onInput, false);
|
|
610
|
+
this.boundListeners = true;
|
|
611
|
+
debug.log('Event listeners attached.');
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
removeEventListeners(): void {
|
|
615
|
+
this.form.removeEventListener('blur', this.onBlur, true);
|
|
616
|
+
this.form.removeEventListener('change', this.onChange, false);
|
|
617
|
+
this.form.removeEventListener('input', this.onInput, false);
|
|
618
|
+
this.boundListeners = false;
|
|
619
|
+
debug.log('Event listeners removed.');
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
emitEvent(target: Document | Element, type: string, detail: Record<string, unknown> = {}): void {
|
|
623
|
+
target.dispatchEvent(new CustomEvent(type, {
|
|
624
|
+
bubbles: true,
|
|
625
|
+
detail,
|
|
626
|
+
}));
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
addValidator(
|
|
630
|
+
name: string,
|
|
631
|
+
validatorFunction: (ctx: ValidationContext) => boolean,
|
|
632
|
+
errorMessage?: (ctx: ValidationContext) => string,
|
|
633
|
+
): void {
|
|
634
|
+
this.validators[name] = {
|
|
635
|
+
validate: validatorFunction,
|
|
636
|
+
errorMessage,
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
removeValidator(name: string): void {
|
|
641
|
+
delete this.validators[name];
|
|
642
|
+
}
|
|
643
|
+
}
|