@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,448 @@
|
|
|
1
|
+
import type { FormSubmitResult } from '#contracts/schema';
|
|
2
|
+
import { syncPageTabErrors } from '#core/page-tab-errors';
|
|
3
|
+
import { setFormHiddenState } from '#core/submit-result-state';
|
|
4
|
+
import { addThemeClasses, removeThemeClasses } from '#theme/theme-classes';
|
|
5
|
+
|
|
6
|
+
const successHideTimers = new WeakMap<HTMLFormElement, number>();
|
|
7
|
+
|
|
8
|
+
function getConfiguredSubmitAction(form: HTMLFormElement): string {
|
|
9
|
+
return (form.dataset.formieSubmitAction || '').trim();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getErrorMessagePosition(form: HTMLFormElement): string {
|
|
13
|
+
return (form.dataset.formieErrorMessagePosition || 'top-form').trim() || 'top-form';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getSuccessMessagePosition(form: HTMLFormElement): string {
|
|
17
|
+
return (form.dataset.formieSubmitActionMessagePosition || '').trim();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getSuccessMessageTimeoutMs(form: HTMLFormElement): number | null {
|
|
21
|
+
const rawValue = (form.dataset.formieSubmitActionMessageTimeout || '').trim();
|
|
22
|
+
|
|
23
|
+
if (!rawValue) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const seconds = Number.parseFloat(rawValue);
|
|
28
|
+
|
|
29
|
+
if (!Number.isFinite(seconds) || seconds < 0) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return Math.round(seconds * 1000);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function shouldHideFormOnSuccess(form: HTMLFormElement): boolean {
|
|
37
|
+
const rawValue = form.dataset.formieSubmitActionFormHide;
|
|
38
|
+
|
|
39
|
+
if (rawValue === undefined) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const normalized = rawValue.trim().toLowerCase();
|
|
44
|
+
return normalized === 'true' || normalized === '1' || normalized === '';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function clearPendingSuccessHide(form: HTMLFormElement): void {
|
|
48
|
+
const timerId = successHideTimers.get(form);
|
|
49
|
+
|
|
50
|
+
if (typeof timerId === 'number') {
|
|
51
|
+
window.clearTimeout(timerId);
|
|
52
|
+
successHideTimers.delete(form);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getTopMessageHost(form: HTMLFormElement): HTMLElement {
|
|
57
|
+
return form.querySelector('[data-formie-form-messages-top]') as HTMLElement || form;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getBottomMessageHost(form: HTMLFormElement): HTMLElement {
|
|
61
|
+
return form.querySelector('[data-formie-form-messages-bottom]') as HTMLElement || form;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getErrorMessageHost(form: HTMLFormElement, position: string): HTMLElement {
|
|
65
|
+
if (position === 'bottom-form') {
|
|
66
|
+
return getBottomMessageHost(form);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return getTopMessageHost(form);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getSuccessMessageHost(form: HTMLFormElement, position: string): HTMLElement {
|
|
73
|
+
if (position === 'top-form') {
|
|
74
|
+
return getTopMessageHost(form);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Hidden-on-success forms cannot rely on a bottom host that will disappear,
|
|
78
|
+
// so their success message stays attached to the root form container.
|
|
79
|
+
if (position === 'bottom-form' && !shouldHideFormOnSuccess(form)) {
|
|
80
|
+
return getBottomMessageHost(form);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return form;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function ensureFormErrorContainer(form: HTMLFormElement): HTMLElement {
|
|
87
|
+
const position = getErrorMessagePosition(form);
|
|
88
|
+
const host = getErrorMessageHost(form, position);
|
|
89
|
+
let container = host.querySelector('[data-formie-error-container], [data-formie-errors]') as HTMLElement | null;
|
|
90
|
+
|
|
91
|
+
if (!container) {
|
|
92
|
+
container = document.createElement('div');
|
|
93
|
+
container.setAttribute('data-formie-errors', 'true');
|
|
94
|
+
addThemeClasses(container, form, 'errors');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Reuse one form-level container so repeated submits replace the current
|
|
98
|
+
// message state instead of stacking duplicate wrappers in the DOM.
|
|
99
|
+
container.setAttribute('data-formie-error-container', 'true');
|
|
100
|
+
|
|
101
|
+
if (position === 'bottom-form') {
|
|
102
|
+
host.append(container);
|
|
103
|
+
} else {
|
|
104
|
+
host.prepend(container);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return container;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function ensureFormErrorMessageContainer(form: HTMLFormElement, container: HTMLElement): HTMLElement {
|
|
111
|
+
let messageContainer = container.querySelector('[data-formie-error-message-container], [data-formie-message][data-formie-message-error]') as HTMLElement | null;
|
|
112
|
+
|
|
113
|
+
if (!messageContainer) {
|
|
114
|
+
messageContainer = document.createElement('div');
|
|
115
|
+
messageContainer.setAttribute('data-formie-error-message-container', 'true');
|
|
116
|
+
container.appendChild(messageContainer);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
messageContainer.setAttribute('data-formie-message', 'true');
|
|
120
|
+
messageContainer.setAttribute('data-formie-message-error', 'true');
|
|
121
|
+
addThemeClasses(messageContainer, form, 'message', 'messageError');
|
|
122
|
+
// Form-level errors use a live region because they are often the only output
|
|
123
|
+
// for submit-stage failures such as provider or transport errors.
|
|
124
|
+
messageContainer.setAttribute('role', 'alert');
|
|
125
|
+
messageContainer.setAttribute('aria-live', 'polite');
|
|
126
|
+
messageContainer.setAttribute('aria-atomic', 'true');
|
|
127
|
+
|
|
128
|
+
return messageContainer;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function ensureFormSuccessContainer(form: HTMLFormElement, position: string): HTMLElement {
|
|
132
|
+
let container = form.querySelector('[data-formie-success-container]') as HTMLElement | null;
|
|
133
|
+
const host = getSuccessMessageHost(form, position);
|
|
134
|
+
|
|
135
|
+
if (!container) {
|
|
136
|
+
container = document.createElement('div');
|
|
137
|
+
container.setAttribute('data-formie-success-container', 'true');
|
|
138
|
+
addThemeClasses(container, form, 'successes');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (position === 'bottom-form') {
|
|
142
|
+
host.append(container);
|
|
143
|
+
} else if (host === form) {
|
|
144
|
+
host.prepend(container);
|
|
145
|
+
} else {
|
|
146
|
+
host.prepend(container);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return container;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function ensureFieldErrorContainer(fieldNode: Element): HTMLElement {
|
|
153
|
+
let container = fieldNode.querySelector('[data-formie-field-errors]') as HTMLElement | null;
|
|
154
|
+
|
|
155
|
+
if (!container) {
|
|
156
|
+
container = document.createElement('div');
|
|
157
|
+
container.setAttribute('data-formie-field-errors', 'true');
|
|
158
|
+
addThemeClasses(container, fieldNode, 'fieldErrors');
|
|
159
|
+
fieldNode.appendChild(container);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return container;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function removeDescribedBy(input: HTMLElement, describedById: string): void {
|
|
166
|
+
const current = (input.getAttribute('aria-describedby') || '').trim();
|
|
167
|
+
|
|
168
|
+
if (!current) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const nextValue = current.split(/\s+/).filter((item) => {
|
|
173
|
+
return item !== describedById;
|
|
174
|
+
}).join(' ').trim();
|
|
175
|
+
|
|
176
|
+
if (nextValue) {
|
|
177
|
+
input.setAttribute('aria-describedby', nextValue);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
input.removeAttribute('aria-describedby');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function setErrorMessageReference(input: HTMLElement, errorMessageId: string): void {
|
|
185
|
+
input.setAttribute('aria-errormessage', errorMessageId);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function clearErrorMessageReference(input: HTMLElement, errorMessageId: string): void {
|
|
189
|
+
if (input.getAttribute('aria-errormessage') === errorMessageId) {
|
|
190
|
+
input.removeAttribute('aria-errormessage');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function clearFieldErrors(form: HTMLFormElement): void {
|
|
195
|
+
form.querySelectorAll('[data-formie-field-handle]').forEach((fieldNode) => {
|
|
196
|
+
const fieldElement = fieldNode as HTMLElement;
|
|
197
|
+
const container = fieldElement.querySelector('[data-formie-field-errors]') as HTMLElement | null;
|
|
198
|
+
const containerId = container?.id || '';
|
|
199
|
+
const errorMessageIds = Array.from(fieldElement.querySelectorAll('[data-formie-field-error]')).map((node) => {
|
|
200
|
+
return (node as HTMLElement).id;
|
|
201
|
+
}).filter(Boolean);
|
|
202
|
+
|
|
203
|
+
removeThemeClasses(fieldElement, form, 'fieldLayoutError');
|
|
204
|
+
fieldElement.removeAttribute('data-formie-field-has-error');
|
|
205
|
+
|
|
206
|
+
fieldElement.querySelectorAll('[data-formie-field-error]').forEach((node) => {
|
|
207
|
+
node.remove();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
if (container && !container.querySelector('[data-formie-field-error]')) {
|
|
211
|
+
container.innerHTML = '';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
fieldElement.querySelectorAll('input, select, textarea').forEach((input) => {
|
|
215
|
+
const element = input as HTMLElement;
|
|
216
|
+
element.removeAttribute('aria-invalid');
|
|
217
|
+
removeThemeClasses(element, form, 'fieldControlError');
|
|
218
|
+
element.removeAttribute('data-formie-input-has-error');
|
|
219
|
+
|
|
220
|
+
if (containerId) {
|
|
221
|
+
removeDescribedBy(element, containerId);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
errorMessageIds.forEach((errorMessageId) => {
|
|
225
|
+
clearErrorMessageReference(element, errorMessageId);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
syncPageTabErrors(form);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function clearFormErrors(form: HTMLFormElement): void {
|
|
234
|
+
form.querySelectorAll('[data-formie-error-container], [data-formie-errors]').forEach((node) => {
|
|
235
|
+
const container = node as HTMLElement;
|
|
236
|
+
|
|
237
|
+
container.querySelectorAll('[data-formie-error]').forEach((errorNode) => {
|
|
238
|
+
errorNode.remove();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
removeThemeClasses(container, form, 'message', 'messageError');
|
|
242
|
+
container.removeAttribute('data-formie-message');
|
|
243
|
+
container.removeAttribute('data-formie-message-error');
|
|
244
|
+
container.removeAttribute('role');
|
|
245
|
+
container.removeAttribute('aria-live');
|
|
246
|
+
container.removeAttribute('aria-atomic');
|
|
247
|
+
|
|
248
|
+
if (!container.querySelector('[data-formie-error]')) {
|
|
249
|
+
container.innerHTML = '';
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function clearFormSuccess(form: HTMLFormElement): void {
|
|
255
|
+
clearPendingSuccessHide(form);
|
|
256
|
+
|
|
257
|
+
form.querySelectorAll('[data-formie-message-success]:not([data-formie-success-container])').forEach((node) => {
|
|
258
|
+
node.remove();
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
form.querySelectorAll('[data-formie-success-container]').forEach((node) => {
|
|
262
|
+
const container = node as HTMLElement;
|
|
263
|
+
|
|
264
|
+
container.querySelectorAll('[data-formie-success]').forEach((successNode) => {
|
|
265
|
+
successNode.remove();
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
removeThemeClasses(container, form, 'message', 'messageSuccess');
|
|
269
|
+
container.removeAttribute('data-formie-message');
|
|
270
|
+
container.removeAttribute('data-formie-message-success');
|
|
271
|
+
container.removeAttribute('role');
|
|
272
|
+
container.removeAttribute('aria-live');
|
|
273
|
+
container.removeAttribute('aria-atomic');
|
|
274
|
+
|
|
275
|
+
if (!container.querySelector('[data-formie-success]')) {
|
|
276
|
+
container.innerHTML = '';
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
if (!(getConfiguredSubmitAction(form) === 'message' && shouldHideFormOnSuccess(form))) {
|
|
281
|
+
setFormHiddenState(form, false);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export function clearAriaInvalid(form: HTMLFormElement): void {
|
|
286
|
+
form.querySelectorAll('[aria-invalid="true"]').forEach((node) => {
|
|
287
|
+
node.removeAttribute('aria-invalid');
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function appendDescribedBy(input: HTMLElement, describedById: string): void {
|
|
292
|
+
const current = (input.getAttribute('aria-describedby') || '').trim();
|
|
293
|
+
const items = current ? current.split(/\s+/) : [];
|
|
294
|
+
|
|
295
|
+
if (!items.includes(describedById)) {
|
|
296
|
+
items.push(describedById);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
input.setAttribute('aria-describedby', items.join(' ').trim());
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export function renderFieldErrors(form: HTMLFormElement, fieldErrors: Record<string, string[]>): void {
|
|
303
|
+
Object.entries(fieldErrors).forEach(([handle, messages]) => {
|
|
304
|
+
const fieldNode = form.querySelector(`[data-formie-field-handle="${handle}"]`);
|
|
305
|
+
|
|
306
|
+
if (!fieldNode) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const container = ensureFieldErrorContainer(fieldNode);
|
|
311
|
+
const containerId = (container.id && container.id.trim())
|
|
312
|
+
? container.id
|
|
313
|
+
: `${handle}-errors`;
|
|
314
|
+
container.id = containerId;
|
|
315
|
+
container.setAttribute('aria-live', 'polite');
|
|
316
|
+
container.setAttribute('aria-atomic', 'true');
|
|
317
|
+
addThemeClasses(fieldNode as HTMLElement, form, 'fieldLayoutError');
|
|
318
|
+
(fieldNode as HTMLElement).setAttribute('data-formie-field-has-error', 'true');
|
|
319
|
+
|
|
320
|
+
messages.forEach((message, index) => {
|
|
321
|
+
const errorNode = document.createElement('div');
|
|
322
|
+
errorNode.setAttribute('data-formie-field-error', 'true');
|
|
323
|
+
errorNode.setAttribute('role', 'alert');
|
|
324
|
+
errorNode.id = `${containerId}-${index + 1}`;
|
|
325
|
+
addThemeClasses(errorNode, form, 'fieldError');
|
|
326
|
+
errorNode.textContent = message;
|
|
327
|
+
container.appendChild(errorNode);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
// Point every control in the field at the first rendered message while
|
|
331
|
+
// still rendering the full list for visual output.
|
|
332
|
+
const primaryErrorId = (container.querySelector('[data-formie-field-error]') as HTMLElement | null)?.id;
|
|
333
|
+
|
|
334
|
+
fieldNode.querySelectorAll('input, select, textarea').forEach((input) => {
|
|
335
|
+
const element = input as HTMLElement;
|
|
336
|
+
element.setAttribute('aria-invalid', 'true');
|
|
337
|
+
addThemeClasses(element, form, 'fieldControlError');
|
|
338
|
+
element.setAttribute('data-formie-input-has-error', 'true');
|
|
339
|
+
appendDescribedBy(element, containerId);
|
|
340
|
+
|
|
341
|
+
if (primaryErrorId) {
|
|
342
|
+
setErrorMessageReference(element, primaryErrorId);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const instructions = fieldNode.querySelector('[data-formie-instructions]') as HTMLElement | null;
|
|
346
|
+
if (instructions?.id) {
|
|
347
|
+
appendDescribedBy(element, instructions.id);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
syncPageTabErrors(form);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export function renderFormErrors(form: HTMLFormElement, formErrors: string[]): void {
|
|
356
|
+
const container = ensureFormErrorContainer(form);
|
|
357
|
+
const messageContainer = ensureFormErrorMessageContainer(form, container);
|
|
358
|
+
|
|
359
|
+
addThemeClasses(container, form, 'errors');
|
|
360
|
+
|
|
361
|
+
formErrors.forEach((error) => {
|
|
362
|
+
const errorNode = document.createElement('div');
|
|
363
|
+
errorNode.setAttribute('data-formie-error', 'true');
|
|
364
|
+
errorNode.setAttribute('role', 'alert');
|
|
365
|
+
addThemeClasses(errorNode, form, 'error');
|
|
366
|
+
errorNode.innerHTML = error;
|
|
367
|
+
messageContainer.appendChild(errorNode);
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function shouldRenderSuccessMessage(form: HTMLFormElement, result: FormSubmitResult): boolean {
|
|
372
|
+
if (!result.message || result.nextPage || result.redirect) {
|
|
373
|
+
// Page changes and redirects are transitional outcomes, not terminal
|
|
374
|
+
// success states that should leave an in-form success message behind.
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (result.action === 'save') {
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return getConfiguredSubmitAction(form) === 'message' && getSuccessMessagePosition(form) !== '';
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export function renderFormSuccess(form: HTMLFormElement, message: string): void {
|
|
386
|
+
const position = getSuccessMessagePosition(form);
|
|
387
|
+
|
|
388
|
+
if (!position) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const container = ensureFormSuccessContainer(form, position);
|
|
393
|
+
|
|
394
|
+
addThemeClasses(container, form, 'message', 'messageSuccess');
|
|
395
|
+
container.setAttribute('data-formie-message', 'true');
|
|
396
|
+
container.setAttribute('data-formie-message-success', 'true');
|
|
397
|
+
container.setAttribute('role', 'status');
|
|
398
|
+
container.setAttribute('aria-live', 'polite');
|
|
399
|
+
container.setAttribute('aria-atomic', 'true');
|
|
400
|
+
const successNode = document.createElement('div');
|
|
401
|
+
successNode.setAttribute('data-formie-success', 'true');
|
|
402
|
+
addThemeClasses(successNode, form, 'success');
|
|
403
|
+
successNode.innerHTML = message;
|
|
404
|
+
container.appendChild(successNode);
|
|
405
|
+
|
|
406
|
+
if (shouldHideFormOnSuccess(form)) {
|
|
407
|
+
setFormHiddenState(form, true);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const timeoutMs = getSuccessMessageTimeoutMs(form);
|
|
411
|
+
|
|
412
|
+
if (timeoutMs !== null) {
|
|
413
|
+
const timerId = window.setTimeout(() => {
|
|
414
|
+
successHideTimers.delete(form);
|
|
415
|
+
clearFormSuccess(form);
|
|
416
|
+
}, timeoutMs);
|
|
417
|
+
|
|
418
|
+
successHideTimers.set(form, timerId);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export function applySubmitResultUi(form: HTMLFormElement, result: FormSubmitResult): void {
|
|
423
|
+
clearFieldErrors(form);
|
|
424
|
+
clearFormErrors(form);
|
|
425
|
+
clearFormSuccess(form);
|
|
426
|
+
clearAriaInvalid(form);
|
|
427
|
+
|
|
428
|
+
if (result.ok) {
|
|
429
|
+
if (shouldRenderSuccessMessage(form, result)) {
|
|
430
|
+
renderFormSuccess(form, result.message || '');
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
if (result.fieldErrors) {
|
|
437
|
+
renderFieldErrors(form, result.fieldErrors);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
if (result.formErrors?.length) {
|
|
441
|
+
renderFormErrors(form, result.formErrors);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
if (!result.fieldErrors && result.message) {
|
|
446
|
+
renderFormErrors(form, [result.message]);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
type EventCallback<T = unknown> = (payload: T) => void | Promise<void>;
|
|
2
|
+
|
|
3
|
+
export type EventEmitFailure = {
|
|
4
|
+
index: number;
|
|
5
|
+
error: unknown;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type EventEmitReport = {
|
|
9
|
+
eventName: string;
|
|
10
|
+
total: number;
|
|
11
|
+
succeeded: number;
|
|
12
|
+
failed: EventEmitFailure[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export class EventBus {
|
|
16
|
+
private listeners = new Map<string, Set<EventCallback>>();
|
|
17
|
+
|
|
18
|
+
on<T = unknown>(eventName: string, callback: EventCallback<T>): () => void {
|
|
19
|
+
if (!this.listeners.has(eventName)) {
|
|
20
|
+
this.listeners.set(eventName, new Set());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
this.listeners.get(eventName)?.add(callback as EventCallback);
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
this.listeners.get(eventName)?.delete(callback as EventCallback);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async emit<T = unknown>(eventName: string, payload: T): Promise<void> {
|
|
31
|
+
const callbacks = this.listeners.get(eventName);
|
|
32
|
+
|
|
33
|
+
if (!callbacks || callbacks.size === 0) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const callback of callbacks) {
|
|
38
|
+
await callback(payload);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async emitSafe<T = unknown>(eventName: string, payload: T): Promise<EventEmitReport> {
|
|
43
|
+
const callbacks = this.listeners.get(eventName);
|
|
44
|
+
const report: EventEmitReport = {
|
|
45
|
+
eventName,
|
|
46
|
+
total: callbacks?.size || 0,
|
|
47
|
+
succeeded: 0,
|
|
48
|
+
failed: [],
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
if (!callbacks || callbacks.size === 0) {
|
|
52
|
+
return report;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let index = 0;
|
|
56
|
+
|
|
57
|
+
for (const callback of callbacks) {
|
|
58
|
+
try {
|
|
59
|
+
await callback(payload);
|
|
60
|
+
report.succeeded += 1;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
report.failed.push({
|
|
63
|
+
index,
|
|
64
|
+
error,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
index += 1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return report;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async emitParallelSafe<T = unknown>(eventName: string, payload: T): Promise<EventEmitReport> {
|
|
75
|
+
const callbacks = this.listeners.get(eventName);
|
|
76
|
+
const report: EventEmitReport = {
|
|
77
|
+
eventName,
|
|
78
|
+
total: callbacks?.size || 0,
|
|
79
|
+
succeeded: 0,
|
|
80
|
+
failed: [],
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if (!callbacks || callbacks.size === 0) {
|
|
84
|
+
return report;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const results = await Promise.allSettled(Array.from(callbacks).map(async(callback) => {
|
|
88
|
+
return callback(payload);
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
results.forEach((result, index) => {
|
|
92
|
+
if (result.status === 'fulfilled') {
|
|
93
|
+
report.succeeded += 1;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
report.failed.push({
|
|
98
|
+
index,
|
|
99
|
+
error: result.reason,
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return report;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
clear(): void {
|
|
107
|
+
this.listeners.clear();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { defineAddressModule } from '#modules/address/api';
|
|
2
|
+
import { getAddressProviderEventName } from '#utils/event-names';
|
|
3
|
+
import { loadScriptAndEnsureGlobal } from '#utils/scripts';
|
|
4
|
+
|
|
5
|
+
type AddressFinderWidget = {
|
|
6
|
+
on: (event: string, callback: (fullAddress: string, metaData: Record<string, string>) => void) => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type AddressFinderGlobal = {
|
|
10
|
+
Widget: new (
|
|
11
|
+
element: HTMLInputElement,
|
|
12
|
+
apiKey: string,
|
|
13
|
+
countryCode: string,
|
|
14
|
+
widgetOptions?: Record<string, unknown>,
|
|
15
|
+
) => AddressFinderWidget;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type AddressFinderProviderOptions = {
|
|
19
|
+
apiKey?: string;
|
|
20
|
+
countryCode?: string;
|
|
21
|
+
widgetOptions?: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const SCRIPT_ID = 'FORMIE_ADDRESS_FINDER_SCRIPT';
|
|
25
|
+
|
|
26
|
+
export const addressFinderModule = defineAddressModule<
|
|
27
|
+
AddressFinderProviderOptions,
|
|
28
|
+
AddressFinderGlobal,
|
|
29
|
+
AddressFinderWidget
|
|
30
|
+
>({
|
|
31
|
+
id: 'address-finder',
|
|
32
|
+
load: async () => {
|
|
33
|
+
return loadScriptAndEnsureGlobal<AddressFinderGlobal>('AddressFinder', {
|
|
34
|
+
id: SCRIPT_ID,
|
|
35
|
+
src: 'https://api.addressfinder.io/assets/v3/widget.js',
|
|
36
|
+
async: true,
|
|
37
|
+
defer: true,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
mount: ({ api, field, services, provider }) => {
|
|
41
|
+
const input = services.input.getAutocomplete();
|
|
42
|
+
|
|
43
|
+
if (!input || typeof api === 'undefined' || !api.Widget) {
|
|
44
|
+
throw new Error('AddressFinder API not ready');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const apiKey = provider.apiKey || '';
|
|
48
|
+
const countryCode = provider.countryCode || 'au';
|
|
49
|
+
|
|
50
|
+
const widget = new api.Widget(
|
|
51
|
+
input as HTMLInputElement,
|
|
52
|
+
apiKey,
|
|
53
|
+
countryCode,
|
|
54
|
+
provider.widgetOptions,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
widget.on('result:select', (fullAddress, metaData: Record<string, string>) => {
|
|
58
|
+
if (metaData.address_line_2) {
|
|
59
|
+
services.input.setValue('address1', metaData.address_line_2);
|
|
60
|
+
services.input.setValue('address2', metaData.address_line_1);
|
|
61
|
+
} else {
|
|
62
|
+
services.input.setValue('address1', metaData.address_line_1 || '');
|
|
63
|
+
services.input.setValue('address2', '');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
services.input.setValue('city', metaData.locality_name || '');
|
|
67
|
+
services.input.setValue('zip', metaData.postcode || '');
|
|
68
|
+
services.input.setValue('state', metaData.state_territory || '');
|
|
69
|
+
services.input.setValue('country', countryCode);
|
|
70
|
+
|
|
71
|
+
field.dispatchEvent(
|
|
72
|
+
new CustomEvent(getAddressProviderEventName('address-finder', 'populate'), {
|
|
73
|
+
bubbles: true,
|
|
74
|
+
detail: {
|
|
75
|
+
addressProvider: 'address-finder',
|
|
76
|
+
fullAddress,
|
|
77
|
+
metaData,
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return widget;
|
|
84
|
+
},
|
|
85
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createManagedAddressModule,
|
|
3
|
+
type AddressModuleSetupContext,
|
|
4
|
+
type ManagedAddressModuleAdapter,
|
|
5
|
+
} from '#modules/address/factories';
|
|
6
|
+
import type {
|
|
7
|
+
AddressHostServices,
|
|
8
|
+
AddressModuleOptions as AddressModuleManifestOptions,
|
|
9
|
+
} from '#modules/address/host';
|
|
10
|
+
|
|
11
|
+
// This file is the intended authoring surface for address providers.
|
|
12
|
+
// Built-in providers import from here so third-party authors can follow the same patterns.
|
|
13
|
+
export const defineAddressModule = createManagedAddressModule;
|
|
14
|
+
|
|
15
|
+
export type AddressServices = AddressHostServices;
|
|
16
|
+
export type AddressModuleContext<TProvider extends Record<string, unknown>> = AddressModuleSetupContext<TProvider>;
|
|
17
|
+
export type AddressModuleOptions<TProvider extends Record<string, unknown>> = AddressModuleManifestOptions<TProvider>;
|
|
18
|
+
export type AddressProviderModule<
|
|
19
|
+
TProvider extends Record<string, unknown>,
|
|
20
|
+
TApi,
|
|
21
|
+
TWidget,
|
|
22
|
+
> = ManagedAddressModuleAdapter<TProvider, TApi, TWidget>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Default selector for the autocomplete input within an address field. */
|
|
2
|
+
export const DEFAULT_AUTOCOMPLETE_SELECTOR = '[data-formie-address-autocomplete-input]';
|
|
3
|
+
export const ADDRESS_LOCATION_SELECTOR = '[data-formie-address-location]';
|
|
4
|
+
|
|
5
|
+
/** Selector for address sub-field inputs used when populating from provider. */
|
|
6
|
+
export const ADDRESS_SELECTORS = {
|
|
7
|
+
autoComplete: '[data-formie-address-autocomplete-input]',
|
|
8
|
+
address1: '[data-formie-address-line1-input]',
|
|
9
|
+
address2: '[data-formie-address-line2-input]',
|
|
10
|
+
address3: '[data-formie-address-line3-input]',
|
|
11
|
+
city: '[data-formie-address-city-input]',
|
|
12
|
+
state: '[data-formie-address-state-input]',
|
|
13
|
+
zip: '[data-formie-address-zip-input]',
|
|
14
|
+
country: '[data-formie-address-country-input]',
|
|
15
|
+
} as const;
|