@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,190 @@
|
|
|
1
|
+
const DIRTY_TRACKING_IGNORED_FIELD_NAMES = new Set([
|
|
2
|
+
'CRAFT_CSRF_TOKEN',
|
|
3
|
+
'action',
|
|
4
|
+
'redirect',
|
|
5
|
+
'requestToken',
|
|
6
|
+
'renderId',
|
|
7
|
+
'submitAction',
|
|
8
|
+
'pageId',
|
|
9
|
+
'draftContextToken',
|
|
10
|
+
'draftContext',
|
|
11
|
+
'continuationToken',
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
function serializeStableValue(value: unknown, seen: WeakSet<object>): string {
|
|
15
|
+
if (value == null) {
|
|
16
|
+
return String(value);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (typeof value === 'string') {
|
|
20
|
+
return JSON.stringify(value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
24
|
+
return String(value);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (typeof value === 'function') {
|
|
28
|
+
return '[function]';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (typeof File !== 'undefined' && value instanceof File) {
|
|
32
|
+
return `[file:${value.name}:${value.size}:${value.type}]`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (typeof Blob !== 'undefined' && value instanceof Blob) {
|
|
36
|
+
return `[blob:${value.size}:${value.type}]`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
return `[${value.map((item) => serializeStableValue(item, seen)).join(',')}]`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (typeof value === 'object') {
|
|
44
|
+
if (seen.has(value as object)) {
|
|
45
|
+
return '[circular]';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
seen.add(value as object);
|
|
49
|
+
const entries = Object.entries(value as Record<string, unknown>)
|
|
50
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
51
|
+
.map(([key, item]) => {
|
|
52
|
+
return `${JSON.stringify(key)}:${serializeStableValue(item, seen)}`;
|
|
53
|
+
});
|
|
54
|
+
seen.delete(value as object);
|
|
55
|
+
|
|
56
|
+
return `{${entries.join(',')}}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return JSON.stringify(String(value));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function stableSerialize(value: unknown): string {
|
|
63
|
+
return serializeStableValue(value, new WeakSet<object>());
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function shouldTrackFieldName(name: string): boolean {
|
|
67
|
+
if (!name) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const normalizedName = name.endsWith('[]') ? name.slice(0, -2) : name;
|
|
72
|
+
|
|
73
|
+
return !DIRTY_TRACKING_IGNORED_FIELD_NAMES.has(normalizedName);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function buildTrackedSnapshot(form: HTMLFormElement): string {
|
|
77
|
+
const entries = Array.from(new FormData(form).entries()).filter(([name]) => {
|
|
78
|
+
return shouldTrackFieldName(String(name || ''));
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return stableSerialize(entries);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type FormUnloadWarningGuard = {
|
|
85
|
+
captureBaseline: () => void;
|
|
86
|
+
scheduleBaselineCapture: () => void;
|
|
87
|
+
refreshDirtyState: () => boolean;
|
|
88
|
+
destroy: () => void;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export function createFormUnloadWarningGuard(
|
|
92
|
+
form: HTMLFormElement,
|
|
93
|
+
options: {
|
|
94
|
+
shouldWarn?: () => boolean;
|
|
95
|
+
} = {},
|
|
96
|
+
): FormUnloadWarningGuard {
|
|
97
|
+
let baselineSnapshot: string | null = null;
|
|
98
|
+
let isReady = false;
|
|
99
|
+
let isDirty = false;
|
|
100
|
+
let animationFrameId: number | null = null;
|
|
101
|
+
let dirtyTimerId: number | null = null;
|
|
102
|
+
let baselineTimerId: number | null = null;
|
|
103
|
+
|
|
104
|
+
const clearScheduledWork = (): void => {
|
|
105
|
+
if (animationFrameId !== null) {
|
|
106
|
+
window.cancelAnimationFrame(animationFrameId);
|
|
107
|
+
animationFrameId = null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (dirtyTimerId !== null) {
|
|
111
|
+
window.clearTimeout(dirtyTimerId);
|
|
112
|
+
dirtyTimerId = null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (baselineTimerId !== null) {
|
|
116
|
+
window.clearTimeout(baselineTimerId);
|
|
117
|
+
baselineTimerId = null;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const refreshDirtyState = (): boolean => {
|
|
122
|
+
if (!isReady) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
isDirty = buildTrackedSnapshot(form) !== baselineSnapshot;
|
|
127
|
+
|
|
128
|
+
return isDirty;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const captureBaseline = (): void => {
|
|
132
|
+
baselineSnapshot = buildTrackedSnapshot(form);
|
|
133
|
+
isReady = true;
|
|
134
|
+
isDirty = false;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const scheduleBaselineCapture = (): void => {
|
|
138
|
+
clearScheduledWork();
|
|
139
|
+
isReady = false;
|
|
140
|
+
|
|
141
|
+
animationFrameId = window.requestAnimationFrame(() => {
|
|
142
|
+
animationFrameId = null;
|
|
143
|
+
baselineTimerId = window.setTimeout(() => {
|
|
144
|
+
baselineTimerId = null;
|
|
145
|
+
captureBaseline();
|
|
146
|
+
}, 0);
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const scheduleDirtyRefresh = (): void => {
|
|
151
|
+
if (dirtyTimerId !== null) {
|
|
152
|
+
window.clearTimeout(dirtyTimerId);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
dirtyTimerId = window.setTimeout(() => {
|
|
156
|
+
dirtyTimerId = null;
|
|
157
|
+
refreshDirtyState();
|
|
158
|
+
}, 120);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const handleBeforeUnload = (event: BeforeUnloadEvent): void => {
|
|
162
|
+
if (options.shouldWarn && !options.shouldWarn()) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (!refreshDirtyState()) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
event.returnValue = '';
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
form.addEventListener('input', scheduleDirtyRefresh);
|
|
175
|
+
form.addEventListener('change', scheduleDirtyRefresh);
|
|
176
|
+
window.addEventListener('beforeunload', handleBeforeUnload);
|
|
177
|
+
scheduleBaselineCapture();
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
captureBaseline,
|
|
181
|
+
scheduleBaselineCapture,
|
|
182
|
+
refreshDirtyState,
|
|
183
|
+
destroy: () => {
|
|
184
|
+
clearScheduledWork();
|
|
185
|
+
form.removeEventListener('input', scheduleDirtyRefresh);
|
|
186
|
+
form.removeEventListener('change', scheduleDirtyRefresh);
|
|
187
|
+
window.removeEventListener('beforeunload', handleBeforeUnload);
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ValidationRuleDefinition } from '#validation/types';
|
|
2
|
+
|
|
3
|
+
const email: ValidationRuleDefinition = {
|
|
4
|
+
rule: ({ input, getRule }) => {
|
|
5
|
+
if (!getRule('email') || !input.value || input.value.length < 1) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(input.value);
|
|
10
|
+
},
|
|
11
|
+
message: ({ input, label, t }) => {
|
|
12
|
+
return input.getAttribute('data-formie-pattern-email-message')
|
|
13
|
+
?? input.getAttribute('data-pattern-email-message')
|
|
14
|
+
?? t('{attribute} is not a valid email address.', { attribute: label });
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default email;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ValidationRuleDefinition } from '#validation/types';
|
|
2
|
+
import { getComparableInput, getLabelText } from '#validation/rules/shared';
|
|
3
|
+
|
|
4
|
+
const match: ValidationRuleDefinition = {
|
|
5
|
+
rule: (ctx) => {
|
|
6
|
+
const sourceInput = getComparableInput(ctx);
|
|
7
|
+
|
|
8
|
+
if (!sourceInput) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return sourceInput.value === ctx.input.value;
|
|
13
|
+
},
|
|
14
|
+
message: (ctx) => {
|
|
15
|
+
const sourceInput = getComparableInput(ctx);
|
|
16
|
+
const sourceField = sourceInput?.closest('[data-formie-field-handle]') as HTMLElement | null;
|
|
17
|
+
const sourceLabel = getLabelText(sourceField);
|
|
18
|
+
|
|
19
|
+
return ctx.t('{name} must match {value}.', {
|
|
20
|
+
name: ctx.label,
|
|
21
|
+
value: sourceLabel,
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default match;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ValidationRuleDefinition } from '#validation/types';
|
|
2
|
+
|
|
3
|
+
const minmax: ValidationRuleDefinition = {
|
|
4
|
+
rule: ({ input }) => {
|
|
5
|
+
if (input.type !== 'number' || input.value.trim() === '') {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const value = parseFloat(input.value);
|
|
10
|
+
const min = input.hasAttribute('min') ? parseFloat(input.getAttribute('min') || '') : null;
|
|
11
|
+
const max = input.hasAttribute('max') ? parseFloat(input.getAttribute('max') || '') : null;
|
|
12
|
+
|
|
13
|
+
if (Number.isNaN(value)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (min !== null && value < min) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (max !== null && value > max) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return true;
|
|
26
|
+
},
|
|
27
|
+
message: ({ input, label, t }) => {
|
|
28
|
+
const min = input.hasAttribute('min') ? parseFloat(input.getAttribute('min') || '') : null;
|
|
29
|
+
const max = input.hasAttribute('max') ? parseFloat(input.getAttribute('max') || '') : null;
|
|
30
|
+
|
|
31
|
+
if (min !== null && max !== null) {
|
|
32
|
+
return t('{attribute} must be between {min} and {max}.', { attribute: label, min, max });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (min !== null) {
|
|
36
|
+
return t('{attribute} must be no less than {min}.', { attribute: label, min });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (max !== null) {
|
|
40
|
+
return t('{attribute} must be no greater than {max}.', { attribute: label, max });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return t('{attribute} has an invalid value.', { attribute: label });
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default minmax;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ValidationRuleDefinition } from '#validation/types';
|
|
2
|
+
|
|
3
|
+
const number: ValidationRuleDefinition = {
|
|
4
|
+
rule: ({ input, getRule }) => {
|
|
5
|
+
const rule = getRule('number');
|
|
6
|
+
|
|
7
|
+
if (!rule || !input.value || input.value.trim() === '') {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const value = parseFloat(input.value);
|
|
12
|
+
|
|
13
|
+
if (Number.isNaN(value)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (rule !== true && typeof rule === 'object') {
|
|
18
|
+
const min = typeof rule.min === 'number' ? rule.min : null;
|
|
19
|
+
const max = typeof rule.max === 'number' ? rule.max : null;
|
|
20
|
+
|
|
21
|
+
if (min !== null && value < min) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (max !== null && value > max) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return true;
|
|
31
|
+
},
|
|
32
|
+
message: ({ input, label, getRule, t }) => {
|
|
33
|
+
const rule = getRule('number');
|
|
34
|
+
const min = rule !== true && rule && typeof rule === 'object' && typeof rule.min === 'number' ? rule.min : null;
|
|
35
|
+
const max = rule !== true && rule && typeof rule === 'object' && typeof rule.max === 'number' ? rule.max : null;
|
|
36
|
+
|
|
37
|
+
if (min !== null && max !== null) {
|
|
38
|
+
return t('{attribute} must be between {min} and {max}.', { attribute: label, min, max });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (min !== null) {
|
|
42
|
+
return t('{attribute} must be no less than {min}.', { attribute: label, min });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (max !== null) {
|
|
46
|
+
return t('{attribute} must be no greater than {max}.', { attribute: label, max });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return input.getAttribute('data-formie-pattern-number-message')
|
|
50
|
+
?? input.getAttribute('data-pattern-number-message')
|
|
51
|
+
?? t('{attribute} is not a valid number.', { attribute: label });
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default number;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ValidationRuleDefinition } from '#validation/types';
|
|
2
|
+
|
|
3
|
+
const pattern: ValidationRuleDefinition = {
|
|
4
|
+
rule: ({ input, config }) => {
|
|
5
|
+
const rawPattern = input.getAttribute('pattern');
|
|
6
|
+
const patternToMatch = rawPattern ? new RegExp(`^(?:${rawPattern})$`) : config.patterns[input.type];
|
|
7
|
+
|
|
8
|
+
if (!patternToMatch || !input.value || input.value.length < 1) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return patternToMatch.test(input.value);
|
|
13
|
+
},
|
|
14
|
+
message: ({ input, label, t }) => {
|
|
15
|
+
const messages = {
|
|
16
|
+
email: t('{attribute} is not a valid email address.', { attribute: label }),
|
|
17
|
+
url: t('{attribute} is not a valid URL.', { attribute: label }),
|
|
18
|
+
number: t('{attribute} is not a valid number.', { attribute: label }),
|
|
19
|
+
default: t('{attribute} is not a valid format.', { attribute: label }),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return input.getAttribute(`data-formie-pattern-${input.type}-message`)
|
|
23
|
+
?? input.getAttribute(`data-pattern-${input.type}-message`)
|
|
24
|
+
?? messages[input.type as keyof typeof messages]
|
|
25
|
+
?? messages.default;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default pattern;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ValidationRuleDefinition } from '#validation/types';
|
|
2
|
+
|
|
3
|
+
const required: ValidationRuleDefinition = {
|
|
4
|
+
rule: ({ input, getRule }) => {
|
|
5
|
+
if (!getRule('required') || input.type === 'hidden') {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
10
|
+
const checkboxInputs = input.form?.querySelectorAll(`[name="${input.name}"]:not([type="hidden"]):not([disabled])`) || [];
|
|
11
|
+
|
|
12
|
+
if (checkboxInputs.length) {
|
|
13
|
+
return Array.from(checkboxInputs).some((button) => {
|
|
14
|
+
return button instanceof HTMLInputElement && button.checked;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return input instanceof HTMLInputElement ? input.checked : true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return input.value.trim() !== '';
|
|
22
|
+
},
|
|
23
|
+
message: ({ input, label, t }) => {
|
|
24
|
+
return input.getAttribute('data-formie-required-message')
|
|
25
|
+
?? input.getAttribute('data-required-message')
|
|
26
|
+
?? t('{attribute} cannot be blank.', { attribute: label });
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default required;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ValidationContext, ValidationInput } from '#validation/types';
|
|
2
|
+
|
|
3
|
+
export function stripTags(value: string): string {
|
|
4
|
+
const doc = new DOMParser().parseFromString(value, 'text/html');
|
|
5
|
+
return doc.body.textContent || '';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function countGraphemes(value: string): number {
|
|
9
|
+
// Validation rules share grapheme counting with the field module path so
|
|
10
|
+
// visible counters and submit-time validation agree on what "1 character" means.
|
|
11
|
+
const unicodeRegExp = /(?:\p{Extended_Pictographic}[\p{Emoji_Modifier}\p{M}]*(?:\p{Join_Control}\p{Extended_Pictographic}[\p{Emoji_Modifier}\p{M}]*)*|\s|.)\p{M}*/gu;
|
|
12
|
+
const graphemes = value.match(unicodeRegExp) || [];
|
|
13
|
+
|
|
14
|
+
return graphemes.length;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getWordCount(value: string): number {
|
|
18
|
+
return stripTags(value).split(/\S+/).length - 1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getLabelText(field: HTMLElement | null): string {
|
|
22
|
+
return field?.querySelector('[data-formie-field-label]')?.childNodes[0]?.textContent?.trim() || '';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getComparableInput(ctx: ValidationContext): ValidationInput | null {
|
|
26
|
+
const match = ctx.getRule('match');
|
|
27
|
+
|
|
28
|
+
if (!match || match === true || typeof match !== 'object' || !ctx.field) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const fieldHandle = typeof match.fieldHandle === 'string' ? match.fieldHandle.trim() : '';
|
|
33
|
+
|
|
34
|
+
if (!fieldHandle) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Match validation resolves by field handle, not raw input name, so it stays
|
|
39
|
+
// aligned with the DOM contract used throughout the rest of the browser client.
|
|
40
|
+
const sourceField = ctx.form.querySelector(`[data-formie-field-handle="${fieldHandle}"]`) as HTMLElement | null;
|
|
41
|
+
|
|
42
|
+
if (!sourceField) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return sourceField.querySelector(ctx.config.fieldsSelector) as ValidationInput | null;
|
|
47
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ValidationRuleDefinition } from '#validation/types';
|
|
2
|
+
|
|
3
|
+
const url: ValidationRuleDefinition = {
|
|
4
|
+
rule: ({ input, getRule }) => {
|
|
5
|
+
if (!getRule('url') || !input.value || input.value.length < 1) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
new URL(input.value);
|
|
11
|
+
return true;
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
message: ({ input, label, t }) => {
|
|
17
|
+
return input.getAttribute('data-formie-pattern-url-message')
|
|
18
|
+
?? input.getAttribute('data-pattern-url-message')
|
|
19
|
+
?? t('{attribute} is not a valid URL.', { attribute: label });
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default url;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ValidationRuleDefinition } from '#validation/types';
|
|
2
|
+
import email from '#validation/rules/email';
|
|
3
|
+
import match from '#validation/rules/match';
|
|
4
|
+
import number from '#validation/rules/number';
|
|
5
|
+
import required from '#validation/rules/required';
|
|
6
|
+
import url from '#validation/rules/url';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
// Keep the core validator registry centralized so FormieValidator can extend
|
|
10
|
+
// it at runtime while still shipping one predictable builtin rule surface.
|
|
11
|
+
required,
|
|
12
|
+
email,
|
|
13
|
+
url,
|
|
14
|
+
number,
|
|
15
|
+
match,
|
|
16
|
+
} satisfies Record<string, ValidationRuleDefinition>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type ValidationInput = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
2
|
+
|
|
3
|
+
export type ValidationRule = {
|
|
4
|
+
type: string;
|
|
5
|
+
fieldId?: string | null;
|
|
6
|
+
fieldHandle?: string | null;
|
|
7
|
+
min?: number | null;
|
|
8
|
+
max?: number | null;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type ValidationRuleValue = ValidationRule | boolean;
|
|
13
|
+
|
|
14
|
+
export type ValidationRules = Record<string, ValidationRuleValue>;
|
|
15
|
+
|
|
16
|
+
export type ValidationConfig = {
|
|
17
|
+
live: boolean;
|
|
18
|
+
errorMessage?: string;
|
|
19
|
+
fieldContainerErrorClass: string[];
|
|
20
|
+
inputErrorClass: string[];
|
|
21
|
+
messagesClass: string[];
|
|
22
|
+
messageClass: string[];
|
|
23
|
+
fieldsSelector: string;
|
|
24
|
+
patterns: Record<string, RegExp>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type ValidationContext = {
|
|
28
|
+
t: (message: string, replacements?: Record<string, string | number>) => string;
|
|
29
|
+
input: ValidationInput;
|
|
30
|
+
label: string;
|
|
31
|
+
field: HTMLElement | null;
|
|
32
|
+
form: HTMLFormElement;
|
|
33
|
+
config: ValidationConfig;
|
|
34
|
+
rules: ValidationRules;
|
|
35
|
+
getRule: (rule: string) => ValidationRuleValue | false;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type ValidationRuleDefinition = {
|
|
39
|
+
rule: (ctx: ValidationContext) => boolean;
|
|
40
|
+
message?: (ctx: ValidationContext) => string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type ValidationError = {
|
|
44
|
+
input: ValidationInput;
|
|
45
|
+
field: HTMLElement | null;
|
|
46
|
+
validator: string;
|
|
47
|
+
message: string;
|
|
48
|
+
handle: string | null;
|
|
49
|
+
result: boolean;
|
|
50
|
+
};
|