@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,597 @@
|
|
|
1
|
+
import type { FormAction } from '#contracts/common';
|
|
2
|
+
import type { FormSubmitResult } from '#contracts/schema';
|
|
3
|
+
import { dispatchPageClientEventForSubmit } from '#core/page-client-event';
|
|
4
|
+
import { syncPageTabErrors } from '#core/page-tab-errors';
|
|
5
|
+
import { addThemeClasses, removeThemeClasses, toggleThemeClasses } from '#theme/theme-classes';
|
|
6
|
+
import { createDebug } from '#utils/debug';
|
|
7
|
+
import { getFormStateEventName, normalizeFormieEventName } from '#utils/event-names';
|
|
8
|
+
import type { FormieValidator } from '#validation/validator';
|
|
9
|
+
|
|
10
|
+
type FormWithValidationApi = HTMLFormElement & {
|
|
11
|
+
formieValidation?: FormieValidator;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const STALE_SUBMISSION_STATE_CODE = 'STALE_SUBMISSION_STATE';
|
|
15
|
+
const DEFAULT_FINAL_SUBMIT_RESET_DELAY_MS = 1500;
|
|
16
|
+
const finalSubmitResetTimers = new WeakMap<HTMLFormElement, number>();
|
|
17
|
+
const originalSubmitterMarkup = new WeakMap<HTMLElement, string>();
|
|
18
|
+
const debug = createDebug('general', 'submit-result');
|
|
19
|
+
|
|
20
|
+
type ResetSubmissionStateOptions = {
|
|
21
|
+
preserveHiddenState?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function setHiddenInputValue(form: HTMLFormElement, name: string, value: string): void {
|
|
25
|
+
let input = form.querySelector(`input[name="${name}"]`) as HTMLInputElement | null;
|
|
26
|
+
|
|
27
|
+
if (!input) {
|
|
28
|
+
input = document.createElement('input');
|
|
29
|
+
input.type = 'hidden';
|
|
30
|
+
input.name = name;
|
|
31
|
+
form.appendChild(input);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
input.value = value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function markInternalNavigation(form: HTMLFormElement, reason: string): void {
|
|
38
|
+
form.setAttribute('data-formie-internal-navigation', reason);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function removeHiddenInput(form: HTMLFormElement, name: string): void {
|
|
42
|
+
const input = form.querySelector(`input[name="${name}"]`) as HTMLInputElement | null;
|
|
43
|
+
input?.remove();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function stripQueryParam(urlValue: string, paramName: string): string {
|
|
47
|
+
try {
|
|
48
|
+
const url = new URL(urlValue, window.location.href);
|
|
49
|
+
url.searchParams.delete(paramName);
|
|
50
|
+
|
|
51
|
+
return url.toString();
|
|
52
|
+
} catch {
|
|
53
|
+
return urlValue;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isSameOriginUrl(urlValue: string): boolean {
|
|
58
|
+
try {
|
|
59
|
+
const url = new URL(urlValue, window.location.href);
|
|
60
|
+
return url.origin === window.location.origin;
|
|
61
|
+
} catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function getPageElements(form: HTMLFormElement): HTMLElement[] {
|
|
67
|
+
return Array.from(form.querySelectorAll('[data-formie-page]')) as HTMLElement[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function getTabElements(form: HTMLFormElement): HTMLElement[] {
|
|
71
|
+
return Array.from(form.querySelectorAll('[data-formie-tab]')) as HTMLElement[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getProgressPercent(form: HTMLFormElement, currentPageIndex: number, totalPages: number): number {
|
|
75
|
+
if (currentPageIndex < 0 || totalPages < 1) {
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const mode = form.dataset.formieProgressCalculation === 'page-position' ? 'page-position' : 'completion';
|
|
80
|
+
|
|
81
|
+
if (mode === 'page-position') {
|
|
82
|
+
return Math.round(((currentPageIndex + 1) / totalPages) * 100);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return Math.round((currentPageIndex / totalPages) * 100);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function getProgressState(progress: number): 'start' | 'middle' | 'end' {
|
|
89
|
+
if (progress <= 0) {
|
|
90
|
+
return 'start';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (progress >= 100) {
|
|
94
|
+
return 'end';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return 'middle';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function getConfiguredSubmitAction(form: HTMLFormElement): string {
|
|
101
|
+
return (form.dataset.formieSubmitAction || '').trim();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function shouldHideFormOnSuccess(form: HTMLFormElement): boolean {
|
|
105
|
+
const rawValue = form.dataset.formieSubmitActionFormHide;
|
|
106
|
+
|
|
107
|
+
if (rawValue === undefined) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const normalized = rawValue.trim().toLowerCase();
|
|
112
|
+
return normalized === 'true' || normalized === '1' || normalized === '';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function setFormHiddenState(form: HTMLFormElement, hidden: boolean): void {
|
|
116
|
+
const sections = [
|
|
117
|
+
'[data-formie-form-header]',
|
|
118
|
+
'[data-formie-form-navigation]',
|
|
119
|
+
'[data-formie-form-body]',
|
|
120
|
+
'[data-formie-form-footer]',
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
form.toggleAttribute('data-formie-form-hidden', hidden);
|
|
124
|
+
|
|
125
|
+
sections.forEach((selector) => {
|
|
126
|
+
form.querySelectorAll(selector).forEach((node) => {
|
|
127
|
+
const element = node as HTMLElement;
|
|
128
|
+
|
|
129
|
+
if (hidden) {
|
|
130
|
+
element.hidden = true;
|
|
131
|
+
} else {
|
|
132
|
+
element.hidden = false;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function clearPendingFinalSubmitReset(form: HTMLFormElement): void {
|
|
139
|
+
const timerId = finalSubmitResetTimers.get(form);
|
|
140
|
+
|
|
141
|
+
if (typeof timerId === 'number') {
|
|
142
|
+
window.clearTimeout(timerId);
|
|
143
|
+
finalSubmitResetTimers.delete(form);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function setSubmitterLoadingText(submitter: HTMLElement, loadingText: string): void {
|
|
148
|
+
if (!originalSubmitterMarkup.has(submitter)) {
|
|
149
|
+
originalSubmitterMarkup.set(submitter, submitter.innerHTML);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
submitter.textContent = loadingText;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function restoreSubmitterLoadingText(submitter: HTMLElement): void {
|
|
156
|
+
const originalMarkup = originalSubmitterMarkup.get(submitter);
|
|
157
|
+
|
|
158
|
+
if (originalMarkup === undefined) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
submitter.innerHTML = originalMarkup;
|
|
163
|
+
originalSubmitterMarkup.delete(submitter);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function updateProgressUi(form: HTMLFormElement, progress: number): void {
|
|
167
|
+
const progressBar = form.querySelector('[data-formie-progress-bar]') as HTMLElement | null;
|
|
168
|
+
const progressValue = form.querySelector('[data-formie-progress-value]') as HTMLElement | null;
|
|
169
|
+
|
|
170
|
+
if (!progressBar) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
progressBar.style.width = `${progress}%`;
|
|
175
|
+
progressBar.setAttribute('aria-valuenow', `${progress}`);
|
|
176
|
+
progressBar.setAttribute('data-formie-progress-state', getProgressState(progress));
|
|
177
|
+
|
|
178
|
+
if (progressValue) {
|
|
179
|
+
progressValue.textContent = `${progress}%`;
|
|
180
|
+
progressValue.setAttribute('data-formie-progress-value', `${progress}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function applyCompletedProgressState(form: HTMLFormElement): void {
|
|
185
|
+
updateProgressUi(form, 100);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function scheduleFinalSubmitReset(form: HTMLFormElement): void {
|
|
189
|
+
clearPendingFinalSubmitReset(form);
|
|
190
|
+
const preserveHiddenState = getConfiguredSubmitAction(form) === 'message' && shouldHideFormOnSuccess(form);
|
|
191
|
+
|
|
192
|
+
if (DEFAULT_FINAL_SUBMIT_RESET_DELAY_MS < 1) {
|
|
193
|
+
resetSubmissionState(form, { preserveHiddenState });
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Successful final submits often leave a transient success state visible.
|
|
198
|
+
// Delay the reset so success messaging/progress can remain on screen briefly.
|
|
199
|
+
const timerId = window.setTimeout(() => {
|
|
200
|
+
finalSubmitResetTimers.delete(form);
|
|
201
|
+
resetSubmissionState(form, { preserveHiddenState });
|
|
202
|
+
}, DEFAULT_FINAL_SUBMIT_RESET_DELAY_MS);
|
|
203
|
+
|
|
204
|
+
finalSubmitResetTimers.set(form, timerId);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function applySubmitterLoadingState(form: HTMLFormElement, submitter?: HTMLElement | null): void {
|
|
208
|
+
if (!submitter) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const indicator = (form.dataset.formieLoadingIndicator || '').trim();
|
|
213
|
+
if (!indicator) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
submitter.setAttribute('data-formie-loading-indicator', indicator);
|
|
218
|
+
|
|
219
|
+
if (indicator === 'spinner') {
|
|
220
|
+
toggleThemeClasses(submitter, form, 'loading', true);
|
|
221
|
+
restoreSubmitterLoadingText(submitter);
|
|
222
|
+
submitter.removeAttribute('data-formie-loading-text');
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (indicator === 'text') {
|
|
227
|
+
const configuredText = (form.dataset.formieLoadingIndicatorText || '').trim();
|
|
228
|
+
const fallbackText = submitter.textContent?.trim() || '';
|
|
229
|
+
const loadingText = configuredText || fallbackText;
|
|
230
|
+
|
|
231
|
+
submitter.setAttribute('data-formie-loading-text', loadingText);
|
|
232
|
+
setSubmitterLoadingText(submitter, loadingText);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
restoreSubmitterLoadingText(submitter);
|
|
237
|
+
submitter.removeAttribute('data-formie-loading-text');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function getActionButtons(form: HTMLFormElement): HTMLElement[] {
|
|
241
|
+
return Array.from(form.querySelectorAll('[data-formie-action]')) as HTMLElement[];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function setSubmitLoading(form: HTMLFormElement, submitter?: HTMLElement | null): void {
|
|
245
|
+
if (form.getAttribute('data-formie-loading') === 'true') {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
form.setAttribute('data-formie-loading', 'true');
|
|
250
|
+
|
|
251
|
+
const buttons = getActionButtons(form);
|
|
252
|
+
buttons.forEach((button) => {
|
|
253
|
+
if ('disabled' in button) {
|
|
254
|
+
// Remember pre-existing disabled buttons so clearSubmitLoading only
|
|
255
|
+
// restores buttons that the browser client disabled for this submit cycle.
|
|
256
|
+
if ((button as HTMLButtonElement).disabled) {
|
|
257
|
+
button.setAttribute('data-formie-was-disabled', 'true');
|
|
258
|
+
} else {
|
|
259
|
+
button.removeAttribute('data-formie-was-disabled');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
(button as HTMLButtonElement).disabled = true;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
if (submitter) {
|
|
267
|
+
submitter.setAttribute('data-formie-loading', 'true');
|
|
268
|
+
applySubmitterLoadingState(form, submitter);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export function clearSubmitLoading(form: HTMLFormElement): void {
|
|
273
|
+
form.removeAttribute('data-formie-loading');
|
|
274
|
+
|
|
275
|
+
const buttons = getActionButtons(form);
|
|
276
|
+
buttons.forEach((button) => {
|
|
277
|
+
if ('disabled' in button) {
|
|
278
|
+
const element = button as HTMLButtonElement;
|
|
279
|
+
const wasDisabled = element.getAttribute('data-formie-was-disabled') === 'true';
|
|
280
|
+
element.disabled = wasDisabled;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
restoreSubmitterLoadingText(button);
|
|
284
|
+
button.removeAttribute('data-formie-was-disabled');
|
|
285
|
+
button.removeAttribute('data-formie-loading');
|
|
286
|
+
toggleThemeClasses(button, form, 'loading', false);
|
|
287
|
+
button.removeAttribute('data-formie-loading-indicator');
|
|
288
|
+
button.removeAttribute('data-formie-loading-text');
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export function applyPageState(form: HTMLFormElement, nextPageId: string): void {
|
|
293
|
+
const pages = getPageElements(form);
|
|
294
|
+
const tabs = getTabElements(form);
|
|
295
|
+
const currentPageIndex = pages.findIndex((page) => {
|
|
296
|
+
return page.getAttribute('data-formie-page-id') === nextPageId;
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
pages.forEach((page) => {
|
|
300
|
+
const pageId = page.getAttribute('data-formie-page-id');
|
|
301
|
+
|
|
302
|
+
if (pageId === nextPageId) {
|
|
303
|
+
page.removeAttribute('data-formie-page-hidden');
|
|
304
|
+
removeThemeClasses(page, form, 'pageHidden');
|
|
305
|
+
} else {
|
|
306
|
+
page.setAttribute('data-formie-page-hidden', 'true');
|
|
307
|
+
addThemeClasses(page, form, 'pageHidden');
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
tabs.forEach((tab, index) => {
|
|
312
|
+
const isCurrent = tab.getAttribute('data-formie-page-id') === nextPageId;
|
|
313
|
+
const isComplete = currentPageIndex > -1 && index < currentPageIndex;
|
|
314
|
+
|
|
315
|
+
toggleThemeClasses(tab, form, 'tabCurrent', isCurrent);
|
|
316
|
+
toggleThemeClasses(tab, form, 'tabComplete', isComplete);
|
|
317
|
+
|
|
318
|
+
if (isCurrent) {
|
|
319
|
+
tab.setAttribute('aria-current', 'page');
|
|
320
|
+
} else {
|
|
321
|
+
tab.removeAttribute('aria-current');
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (isComplete) {
|
|
325
|
+
tab.setAttribute('data-formie-tab-complete', 'true');
|
|
326
|
+
} else {
|
|
327
|
+
tab.removeAttribute('data-formie-tab-complete');
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
if (currentPageIndex > -1 && pages.length > 0) {
|
|
332
|
+
const progress = getProgressPercent(form, currentPageIndex, pages.length);
|
|
333
|
+
updateProgressUi(form, progress);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Keep the hidden continuity input in sync with the visible page so refreshes,
|
|
337
|
+
// follow-up submits, and server recovery land on the same page.
|
|
338
|
+
setHiddenInputValue(form, 'pageId', nextPageId);
|
|
339
|
+
syncPageTabErrors(form);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function syncSubmissionIdentity(form: HTMLFormElement, result: FormSubmitResult): void {
|
|
343
|
+
const submissionUid = result.meta?.submissionUid;
|
|
344
|
+
if (typeof submissionUid === 'string' && submissionUid.trim() !== '') {
|
|
345
|
+
setHiddenInputValue(form, 'submissionUid', submissionUid);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const continuationToken = (result.meta?.session as { continuation?: { continuationToken?: unknown } } | undefined)
|
|
349
|
+
?.continuation?.continuationToken;
|
|
350
|
+
if (typeof continuationToken === 'string' && continuationToken.trim() !== '') {
|
|
351
|
+
setHiddenInputValue(form, 'continuationToken', continuationToken);
|
|
352
|
+
} else {
|
|
353
|
+
removeHiddenInput(form, 'continuationToken');
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function clearResumeTokenState(form: HTMLFormElement): void {
|
|
358
|
+
const action = form.getAttribute('action');
|
|
359
|
+
|
|
360
|
+
if (action) {
|
|
361
|
+
form.setAttribute('action', stripQueryParam(action, 'resumeToken'));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
try {
|
|
365
|
+
const url = new URL(window.location.href);
|
|
366
|
+
|
|
367
|
+
if (!url.searchParams.has('resumeToken')) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
url.searchParams.delete('resumeToken');
|
|
372
|
+
window.history.replaceState({}, document.title, `${url.pathname}${url.search}${url.hash}`);
|
|
373
|
+
} catch {
|
|
374
|
+
// Ignore malformed URLs and keep the user on the recovery path.
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function applyResumeTokenState(form: HTMLFormElement, result: FormSubmitResult): void {
|
|
379
|
+
const resumeUrl = result.meta?.resumeUrl;
|
|
380
|
+
|
|
381
|
+
if (typeof resumeUrl !== 'string' || resumeUrl.trim() === '') {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const normalizedResumeUrl = resumeUrl.trim();
|
|
386
|
+
|
|
387
|
+
if (!isSameOriginUrl(normalizedResumeUrl)) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const action = form.getAttribute('action');
|
|
392
|
+
|
|
393
|
+
if (action) {
|
|
394
|
+
form.setAttribute('action', normalizedResumeUrl);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Save/resume updates both the form action and the browser URL so retries and
|
|
398
|
+
// reloads continue through the newly-issued resume token.
|
|
399
|
+
try {
|
|
400
|
+
const url = new URL(normalizedResumeUrl, window.location.href);
|
|
401
|
+
window.history.replaceState({}, document.title, `${url.pathname}${url.search}${url.hash}`);
|
|
402
|
+
} catch {
|
|
403
|
+
// Ignore malformed URLs and preserve the current state.
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function resetSubmissionState(form: HTMLFormElement, options: ResetSubmissionStateOptions = {}): void {
|
|
408
|
+
const formWithValidationApi = form as FormWithValidationApi;
|
|
409
|
+
const validator = formWithValidationApi.formieValidation;
|
|
410
|
+
const firstPageId = getPageElements(form)[0]?.getAttribute('data-formie-page-id');
|
|
411
|
+
|
|
412
|
+
clearPendingFinalSubmitReset(form);
|
|
413
|
+
// A full state reset is broader than the native form reset: it also clears
|
|
414
|
+
// hidden continuity inputs, resume-token state, page UI, and live validation.
|
|
415
|
+
form.reset();
|
|
416
|
+
if (!options.preserveHiddenState) {
|
|
417
|
+
setFormHiddenState(form, false);
|
|
418
|
+
}
|
|
419
|
+
removeHiddenInput(form, 'submissionId');
|
|
420
|
+
removeHiddenInput(form, 'submissionUid');
|
|
421
|
+
removeHiddenInput(form, 'continuationToken');
|
|
422
|
+
removeHiddenInput(form, 'pageId');
|
|
423
|
+
clearResumeTokenState(form);
|
|
424
|
+
validator?.resetLiveState();
|
|
425
|
+
|
|
426
|
+
if (firstPageId) {
|
|
427
|
+
applyPageState(form, firstPageId);
|
|
428
|
+
form.dispatchEvent(new CustomEvent(getFormStateEventName('reset'), { bubbles: true }));
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
syncPageTabErrors(form);
|
|
433
|
+
form.dispatchEvent(new CustomEvent(getFormStateEventName('reset'), { bubbles: true }));
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function shouldResetSubmissionState(result: FormSubmitResult): boolean {
|
|
437
|
+
return result.code === STALE_SUBMISSION_STATE_CODE || result.meta?.resetState === true;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function dispatchSubmitDataEvents(form: HTMLFormElement, result: FormSubmitResult): { hasPaymentFollowUpEvent: boolean } {
|
|
441
|
+
const submitData = result.submitData;
|
|
442
|
+
const dispatchedEvents = new Set<string>();
|
|
443
|
+
let hasPaymentFollowUpEvent = false;
|
|
444
|
+
|
|
445
|
+
if (Array.isArray(submitData) && submitData.length > 0) {
|
|
446
|
+
const events = submitData.filter((item): item is { event: string; data?: unknown } =>
|
|
447
|
+
typeof item === 'object' && item !== null && 'event' in item && typeof (item as { event?: unknown }).event === 'string'
|
|
448
|
+
);
|
|
449
|
+
|
|
450
|
+
for (const eventData of events) {
|
|
451
|
+
const eventName = normalizeFormieEventName(eventData.event);
|
|
452
|
+
dispatchedEvents.add(eventName);
|
|
453
|
+
debug.log('Dispatching submitData event.', {
|
|
454
|
+
eventName,
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
// Payment follow-up flows (3DS challenge, provider redirects, etc.)
|
|
458
|
+
// should be handled by provider event listeners rather than the generic
|
|
459
|
+
// redirect fallback in submit result handling.
|
|
460
|
+
if (eventName.startsWith('formie:payment:')) {
|
|
461
|
+
hasPaymentFollowUpEvent = true;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
form.dispatchEvent(new CustomEvent(eventName, {
|
|
465
|
+
bubbles: true,
|
|
466
|
+
detail: { data: eventData.data },
|
|
467
|
+
}));
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Fallback: some payment action-required responses can carry action payloads
|
|
472
|
+
// as `paymentAction`/`paymentDecision` metadata without submitData entries.
|
|
473
|
+
const meta = (result.meta || {}) as Record<string, unknown>;
|
|
474
|
+
const paymentAction = (
|
|
475
|
+
(meta.paymentAction && typeof meta.paymentAction === 'object' ? meta.paymentAction : null)
|
|
476
|
+
|| (meta.paymentDecision && typeof meta.paymentDecision === 'object'
|
|
477
|
+
? ((meta.paymentDecision as Record<string, unknown>).action as Record<string, unknown> | null)
|
|
478
|
+
: null)
|
|
479
|
+
) as Record<string, unknown> | null;
|
|
480
|
+
|
|
481
|
+
const actionEvent = paymentAction ? String(paymentAction.event || '') : '';
|
|
482
|
+
const actionPayload = paymentAction ? paymentAction.payload : undefined;
|
|
483
|
+
const normalizedActionEvent = normalizeFormieEventName(actionEvent);
|
|
484
|
+
|
|
485
|
+
if (normalizedActionEvent && !dispatchedEvents.has(normalizedActionEvent)) {
|
|
486
|
+
if (normalizedActionEvent.startsWith('formie:payment:')) {
|
|
487
|
+
hasPaymentFollowUpEvent = true;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
form.dispatchEvent(new CustomEvent(normalizedActionEvent, {
|
|
491
|
+
bubbles: true,
|
|
492
|
+
detail: { data: actionPayload },
|
|
493
|
+
}));
|
|
494
|
+
debug.log('Dispatching fallback payment action event.', {
|
|
495
|
+
eventName: normalizedActionEvent,
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
return { hasPaymentFollowUpEvent };
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export function applySubmitResultState(form: HTMLFormElement, result: FormSubmitResult, action: FormAction): void {
|
|
503
|
+
debug.log('Applying submit result state.', {
|
|
504
|
+
ok: result.ok,
|
|
505
|
+
action,
|
|
506
|
+
code: result.code,
|
|
507
|
+
hasRedirect: !!result.redirect?.url,
|
|
508
|
+
hasSubmitData: Array.isArray(result.submitData) && result.submitData.length > 0,
|
|
509
|
+
});
|
|
510
|
+
if (shouldResetSubmissionState(result)) {
|
|
511
|
+
resetSubmissionState(form);
|
|
512
|
+
debug.log('Resetting state due to stale/reset marker.');
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// Dispatch payment/redirect events from submitData (e.g. formie:payment:mollie:redirect)
|
|
517
|
+
const eventDispatchResult = dispatchSubmitDataEvents(form, result);
|
|
518
|
+
|
|
519
|
+
// Fallback: redirect when backend returns redirectUrl for payment (e.g. Mollie, GoCardless)
|
|
520
|
+
if (!result.ok && result.redirect?.url && !eventDispatchResult.hasPaymentFollowUpEvent) {
|
|
521
|
+
debug.log('Applying redirect fallback for failed result.', {
|
|
522
|
+
url: result.redirect.url,
|
|
523
|
+
target: result.redirect.target,
|
|
524
|
+
});
|
|
525
|
+
clearPendingFinalSubmitReset(form);
|
|
526
|
+
if (result.redirect.target === 'new-tab') {
|
|
527
|
+
window.open(result.redirect.url, '_blank');
|
|
528
|
+
} else {
|
|
529
|
+
markInternalNavigation(form, 'redirect');
|
|
530
|
+
window.location.href = result.redirect.url;
|
|
531
|
+
}
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
syncSubmissionIdentity(form, result);
|
|
536
|
+
|
|
537
|
+
if (!result.ok) {
|
|
538
|
+
debug.log('Non-redirect failure; keeping current form state.');
|
|
539
|
+
clearPendingFinalSubmitReset(form);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
dispatchPageClientEventForSubmit(form, action);
|
|
544
|
+
|
|
545
|
+
if (result.nextPage?.id) {
|
|
546
|
+
// Advancing pages is treated as a fresh validation cycle for the next page.
|
|
547
|
+
clearPendingFinalSubmitReset(form);
|
|
548
|
+
const formWithValidationApi = form as FormWithValidationApi;
|
|
549
|
+
const validator = formWithValidationApi.formieValidation;
|
|
550
|
+
validator?.resetLiveState();
|
|
551
|
+
applyPageState(form, result.nextPage.id);
|
|
552
|
+
debug.log('Advanced to next page.', {
|
|
553
|
+
nextPageId: result.nextPage.id,
|
|
554
|
+
});
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
if (action === 'save') {
|
|
559
|
+
clearPendingFinalSubmitReset(form);
|
|
560
|
+
applyResumeTokenState(form, result);
|
|
561
|
+
debug.log('Applied save/resume token state.');
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
if (action === 'submit' && !result.redirect?.url) {
|
|
566
|
+
const configuredSubmitAction = getConfiguredSubmitAction(form);
|
|
567
|
+
const preserveHiddenState = configuredSubmitAction === 'message' && shouldHideFormOnSuccess(form);
|
|
568
|
+
|
|
569
|
+
if (configuredSubmitAction === 'reload') {
|
|
570
|
+
clearPendingFinalSubmitReset(form);
|
|
571
|
+
markInternalNavigation(form, 'reload');
|
|
572
|
+
window.location.reload();
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
if (configuredSubmitAction === 'reset') {
|
|
577
|
+
resetSubmissionState(form);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// Always reset values/state after a successful terminal AJAX submit so a
|
|
582
|
+
// fresh interaction starts from canonical empty state.
|
|
583
|
+
clearPendingFinalSubmitReset(form);
|
|
584
|
+
resetSubmissionState(form, { preserveHiddenState });
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
if (action === 'submit' && result.redirect?.url && result.redirect.target === 'new-tab') {
|
|
589
|
+
const configuredSubmitAction = getConfiguredSubmitAction(form);
|
|
590
|
+
const preserveHiddenState = configuredSubmitAction === 'message' && shouldHideFormOnSuccess(form);
|
|
591
|
+
clearPendingFinalSubmitReset(form);
|
|
592
|
+
resetSubmissionState(form, { preserveHiddenState });
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
clearPendingFinalSubmitReset(form);
|
|
597
|
+
}
|