@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,345 @@
|
|
|
1
|
+
import type { FormEndpointPayload, FormSubmitResult } from '#contracts/schema';
|
|
2
|
+
import { createDebug } from '#utils/debug';
|
|
3
|
+
import { requestJson } from '#utils/http';
|
|
4
|
+
|
|
5
|
+
const debug = createDebug('general', 'transport');
|
|
6
|
+
|
|
7
|
+
type GraphqlResponse<T> = {
|
|
8
|
+
data?: T;
|
|
9
|
+
errors?: Array<{ message?: string }>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type GraphqlFormQueryResult = {
|
|
13
|
+
formieHtmlForm?: FormEndpointPayload | null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function toServerRenderPayloadInput(renderOptions: Record<string, unknown>): Record<string, unknown> {
|
|
17
|
+
const input: Record<string, unknown> = {};
|
|
18
|
+
|
|
19
|
+
['theme', 'themeConfig', 'locale', 'siteId'].forEach((key) => {
|
|
20
|
+
if (renderOptions[key] !== undefined) {
|
|
21
|
+
input[key] = renderOptions[key];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return input;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function flattenErrors(errors: unknown, path = '', output: Record<string, string[]> = {}): Record<string, string[]> {
|
|
29
|
+
if (Array.isArray(errors)) {
|
|
30
|
+
const messages = errors
|
|
31
|
+
.map((value) => {
|
|
32
|
+
return typeof value === 'string' ? value : String(value ?? '');
|
|
33
|
+
})
|
|
34
|
+
.filter((value) => {
|
|
35
|
+
return value.trim() !== '';
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (path && messages.length) {
|
|
39
|
+
output[path] = (output[path] || []).concat(messages);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return output;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Craft/Formie error payloads can be nested by page/field/path. Flatten first
|
|
46
|
+
// so the browser client can map them back onto field handles consistently.
|
|
47
|
+
if (errors && typeof errors === 'object') {
|
|
48
|
+
Object.entries(errors as Record<string, unknown>).forEach(([key, value]) => {
|
|
49
|
+
const nextPath = path ? `${path}.${key}` : key;
|
|
50
|
+
flattenErrors(value, nextPath, output);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return output;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function normalizePayload(payload: Record<string, unknown>, fallbackFormError?: string): FormSubmitResult {
|
|
58
|
+
const success = payload.success === true;
|
|
59
|
+
const keepSubmitLoading = payload.keepSubmitLoading === true;
|
|
60
|
+
const errors = payload.errors;
|
|
61
|
+
const fieldErrorsFlat = flattenErrors(errors || {});
|
|
62
|
+
const formErrors = fieldErrorsFlat.form || [];
|
|
63
|
+
const fieldErrors: Record<string, string[]> = {};
|
|
64
|
+
|
|
65
|
+
Object.entries(fieldErrorsFlat).forEach(([key, value]) => {
|
|
66
|
+
if (key === 'form') {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// The client renders field errors against top-level field handles even when
|
|
71
|
+
// the backend returns deeper nested keys for subfields or row paths.
|
|
72
|
+
const topKey = key.split('.')[0];
|
|
73
|
+
fieldErrors[topKey] = (fieldErrors[topKey] || []).concat(value);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const resolvedFormErrors = !success && formErrors.length === 0 && Object.keys(fieldErrors).length > 0
|
|
77
|
+
? [fallbackFormError || 'Submission failed.']
|
|
78
|
+
: formErrors;
|
|
79
|
+
|
|
80
|
+
const isTransientPendingResult = !success
|
|
81
|
+
&& keepSubmitLoading
|
|
82
|
+
&& resolvedFormErrors.length === 0
|
|
83
|
+
&& Object.keys(fieldErrors).length === 0;
|
|
84
|
+
|
|
85
|
+
const result: FormSubmitResult = {
|
|
86
|
+
ok: success,
|
|
87
|
+
action: (payload.submitAction === 'back' || payload.submitAction === 'save' || payload.submitAction === 'submit')
|
|
88
|
+
? payload.submitAction
|
|
89
|
+
: undefined,
|
|
90
|
+
message: (
|
|
91
|
+
payload.submitActionMessage
|
|
92
|
+
|| (success ? 'Submission completed.' : (isTransientPendingResult ? '' : (resolvedFormErrors[0] || 'Submission failed.')))
|
|
93
|
+
) as string,
|
|
94
|
+
code: success ? undefined : String(payload.code || 'SUBMIT_ERROR'),
|
|
95
|
+
keepSubmitLoading,
|
|
96
|
+
fieldErrors: Object.keys(fieldErrors).length ? fieldErrors : undefined,
|
|
97
|
+
formErrors: resolvedFormErrors.length ? resolvedFormErrors : undefined,
|
|
98
|
+
nextPage: payload.nextPageId
|
|
99
|
+
? {
|
|
100
|
+
id: String(payload.nextPageId),
|
|
101
|
+
}
|
|
102
|
+
: null,
|
|
103
|
+
redirect: payload.redirectUrl
|
|
104
|
+
? {
|
|
105
|
+
url: String(payload.redirectUrl),
|
|
106
|
+
target: payload.submitActionTab === 'new-tab' ? 'new-tab' : 'same-tab',
|
|
107
|
+
}
|
|
108
|
+
: null,
|
|
109
|
+
submitData: Array.isArray(payload.submitData) ? payload.submitData : undefined,
|
|
110
|
+
meta: payload,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export async function requestRender(endpoint: string, handle: string, renderOptions: Record<string, unknown> = {}): Promise<FormEndpointPayload> {
|
|
117
|
+
const body = JSON.stringify({
|
|
118
|
+
handle,
|
|
119
|
+
renderOptions,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
debug.log('requestRender start.', { endpoint, handle });
|
|
123
|
+
const result = await requestJson<FormEndpointPayload>(endpoint, {
|
|
124
|
+
method: 'POST',
|
|
125
|
+
body,
|
|
126
|
+
headers: {
|
|
127
|
+
'Content-Type': 'application/json',
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
debug.log('requestRender complete.', {
|
|
131
|
+
hasHtml: !!result.html,
|
|
132
|
+
});
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export async function requestGraphqlRender(endpoint: string, handle: string, renderOptions: Record<string, unknown> = {}): Promise<FormEndpointPayload> {
|
|
137
|
+
const query = `
|
|
138
|
+
query FormieHtmlForm($handle: String!, $input: ServerRenderPayloadInput) {
|
|
139
|
+
formieHtmlForm(handle: $handle, input: $input) {
|
|
140
|
+
html
|
|
141
|
+
}
|
|
142
|
+
}`;
|
|
143
|
+
const body = JSON.stringify({
|
|
144
|
+
query,
|
|
145
|
+
variables: {
|
|
146
|
+
handle,
|
|
147
|
+
input: toServerRenderPayloadInput(renderOptions),
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
debug.log('requestGraphqlRender start.', { endpoint, handle });
|
|
152
|
+
const result = await requestJson<GraphqlResponse<GraphqlFormQueryResult>>(endpoint, {
|
|
153
|
+
method: 'POST',
|
|
154
|
+
body,
|
|
155
|
+
headers: {
|
|
156
|
+
'Content-Type': 'application/json',
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
if (Array.isArray(result.errors) && result.errors.length > 0) {
|
|
161
|
+
throw new Error(result.errors.map((error) => error.message || 'Unknown GraphQL error').join('; '));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (!result.data?.formieHtmlForm) {
|
|
165
|
+
throw new Error(`Form not found for handle "${handle}".`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const payload = result.data.formieHtmlForm;
|
|
169
|
+
debug.log('requestGraphqlRender complete.', {
|
|
170
|
+
hasHtml: !!payload.html,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
return payload;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export async function requestRefreshTokens(endpoint: string, handle: string, renderId?: string): Promise<FormEndpointPayload['refreshTokens']> {
|
|
177
|
+
const url = new URL(endpoint, window.location.origin);
|
|
178
|
+
url.searchParams.set('handle', handle);
|
|
179
|
+
|
|
180
|
+
if (renderId) {
|
|
181
|
+
url.searchParams.set('renderId', renderId);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
debug.log('requestRefreshTokens start.', {
|
|
185
|
+
endpoint: url.toString(),
|
|
186
|
+
handle,
|
|
187
|
+
hasRenderId: !!renderId,
|
|
188
|
+
});
|
|
189
|
+
const response = await requestJson<FormEndpointPayload>(url.toString());
|
|
190
|
+
debug.log('requestRefreshTokens complete.', {
|
|
191
|
+
hasRefreshTokens: !!response.refreshTokens,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return response.refreshTokens || response as FormEndpointPayload['refreshTokens'];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export async function requestSetPage(url: string, form?: HTMLFormElement, pageId?: string): Promise<{
|
|
198
|
+
success?: boolean;
|
|
199
|
+
pageId?: string | number;
|
|
200
|
+
}> {
|
|
201
|
+
const requestUrl = new URL(url, window.location.origin);
|
|
202
|
+
const body = new FormData();
|
|
203
|
+
|
|
204
|
+
if (pageId) {
|
|
205
|
+
body.append('pageId', pageId);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (form) {
|
|
209
|
+
// Page changes must carry the same continuity identifiers the submit flow
|
|
210
|
+
// uses so the backend can persist draft/session state for multipage forms.
|
|
211
|
+
const inputNames = ['handle', 'renderId', 'draftContextToken', 'draftContext', 'continuationToken'];
|
|
212
|
+
|
|
213
|
+
inputNames.forEach((name) => {
|
|
214
|
+
const input = form.querySelector(`input[name="${name}"]`) as HTMLInputElement | null;
|
|
215
|
+
const value = input?.value?.trim();
|
|
216
|
+
|
|
217
|
+
if (value) {
|
|
218
|
+
body.append(name, value);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
const csrfInput = form.querySelector('input[name="CRAFT_CSRF_TOKEN"]') as HTMLInputElement | null;
|
|
223
|
+
const csrfValue = csrfInput?.value?.trim();
|
|
224
|
+
|
|
225
|
+
if (csrfValue) {
|
|
226
|
+
body.append('CRAFT_CSRF_TOKEN', csrfValue);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
debug.log('requestSetPage start.', {
|
|
231
|
+
requestUrl: requestUrl.toString(),
|
|
232
|
+
pageId: pageId || null,
|
|
233
|
+
});
|
|
234
|
+
const result = await requestJson<{
|
|
235
|
+
success?: boolean;
|
|
236
|
+
pageId?: string | number;
|
|
237
|
+
}>(requestUrl.toString(), {
|
|
238
|
+
method: 'POST',
|
|
239
|
+
body,
|
|
240
|
+
});
|
|
241
|
+
debug.log('requestSetPage complete.', result);
|
|
242
|
+
return result;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function clearSubmissionOnUnload(endpoint: string, form: HTMLFormElement): void {
|
|
246
|
+
const requestUrl = new URL(endpoint, window.location.origin);
|
|
247
|
+
const body = new FormData();
|
|
248
|
+
const inputNames = ['handle', 'renderId', 'draftContextToken', 'draftContext'];
|
|
249
|
+
|
|
250
|
+
inputNames.forEach((name) => {
|
|
251
|
+
const input = form.querySelector(`input[name="${name}"]`) as HTMLInputElement | null;
|
|
252
|
+
const value = input?.value?.trim();
|
|
253
|
+
|
|
254
|
+
if (value) {
|
|
255
|
+
body.append(name, value);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
const csrfInput = form.querySelector('input[name="CRAFT_CSRF_TOKEN"]') as HTMLInputElement | null;
|
|
260
|
+
const csrfValue = csrfInput?.value?.trim();
|
|
261
|
+
|
|
262
|
+
if (csrfValue) {
|
|
263
|
+
body.append('CRAFT_CSRF_TOKEN', csrfValue);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
debug.log('clearSubmissionOnUnload start.', {
|
|
267
|
+
requestUrl: requestUrl.toString(),
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
try {
|
|
271
|
+
if (typeof navigator.sendBeacon === 'function' && navigator.sendBeacon(requestUrl.toString(), body)) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
} catch (_error) {
|
|
275
|
+
// Fall back to keepalive fetch below when Beacon is unavailable or rejects the payload.
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
void fetch(requestUrl.toString(), {
|
|
279
|
+
method: 'POST',
|
|
280
|
+
body,
|
|
281
|
+
credentials: 'include',
|
|
282
|
+
keepalive: true,
|
|
283
|
+
headers: {
|
|
284
|
+
Accept: 'application/json',
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export async function submitForm(form: HTMLFormElement, formData: FormData): Promise<FormSubmitResult> {
|
|
290
|
+
const method = (form.getAttribute('method') || 'POST').toUpperCase();
|
|
291
|
+
const action = form.getAttribute('action') || window.location.href;
|
|
292
|
+
const fallbackFormError = form.dataset.formieErrorMessage?.trim() || 'Submission failed.';
|
|
293
|
+
|
|
294
|
+
debug.log('submitForm start.', {
|
|
295
|
+
method,
|
|
296
|
+
action,
|
|
297
|
+
submitAction: formData.get('submitAction'),
|
|
298
|
+
});
|
|
299
|
+
const response = await fetch(action, {
|
|
300
|
+
method,
|
|
301
|
+
body: formData,
|
|
302
|
+
credentials: 'include',
|
|
303
|
+
headers: {
|
|
304
|
+
Accept: 'application/json',
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
const contentType = response.headers.get('content-type') || '';
|
|
309
|
+
|
|
310
|
+
// Non-JSON responses still count as successful submits in traditional redirect
|
|
311
|
+
// flows; only non-OK responses are treated as transport errors here.
|
|
312
|
+
if (!contentType.includes('application/json')) {
|
|
313
|
+
if (!response.ok) {
|
|
314
|
+
debug.warn('submitForm non-JSON HTTP error.', {
|
|
315
|
+
status: response.status,
|
|
316
|
+
contentType,
|
|
317
|
+
});
|
|
318
|
+
return {
|
|
319
|
+
ok: false,
|
|
320
|
+
code: 'HTTP_ERROR',
|
|
321
|
+
message: `Request failed (${response.status}).`,
|
|
322
|
+
formErrors: [`Request failed (${response.status}).`],
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
debug.log('submitForm non-JSON success response.', {
|
|
327
|
+
status: response.status,
|
|
328
|
+
contentType,
|
|
329
|
+
});
|
|
330
|
+
return {
|
|
331
|
+
ok: true,
|
|
332
|
+
message: 'Submission completed.',
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const payload = await response.json() as Record<string, unknown>;
|
|
337
|
+
const normalized = normalizePayload(payload, fallbackFormError);
|
|
338
|
+
debug.log('submitForm JSON response normalized.', {
|
|
339
|
+
ok: normalized.ok,
|
|
340
|
+
code: normalized.code,
|
|
341
|
+
hasRedirect: !!normalized.redirect?.url,
|
|
342
|
+
hasSubmitData: Array.isArray(normalized.submitData) && normalized.submitData.length > 0,
|
|
343
|
+
});
|
|
344
|
+
return normalized;
|
|
345
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export async function sleep(ms: number): Promise<void> {
|
|
2
|
+
await new Promise((resolve) => {
|
|
3
|
+
window.setTimeout(resolve, Math.max(ms, 0));
|
|
4
|
+
});
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export async function waitFor<T>(
|
|
8
|
+
callback: () => T | null | undefined | false,
|
|
9
|
+
{
|
|
10
|
+
timeoutMs = 5000,
|
|
11
|
+
intervalMs = 30,
|
|
12
|
+
}: {
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
intervalMs?: number;
|
|
15
|
+
} = {},
|
|
16
|
+
): Promise<T> {
|
|
17
|
+
const startedAt = Date.now();
|
|
18
|
+
|
|
19
|
+
// Polling is sufficient here because these waits are short-lived bridges to
|
|
20
|
+
// third-party SDK readiness or DOM insertion, not long-running job orchestration.
|
|
21
|
+
while ((Date.now() - startedAt) < timeoutMs) {
|
|
22
|
+
const value = callback();
|
|
23
|
+
|
|
24
|
+
if (value) {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await sleep(intervalMs);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
throw new Error('Timed out waiting for async condition.');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function debounce<TArgs extends unknown[]>(
|
|
35
|
+
callback: (...args: TArgs) => void,
|
|
36
|
+
delayMs: number,
|
|
37
|
+
): (...args: TArgs) => void {
|
|
38
|
+
let timeoutId: number | null = null;
|
|
39
|
+
|
|
40
|
+
return (...args: TArgs) => {
|
|
41
|
+
if (timeoutId !== null) {
|
|
42
|
+
window.clearTimeout(timeoutId);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
timeoutId = window.setTimeout(() => {
|
|
46
|
+
callback(...args);
|
|
47
|
+
}, Math.max(delayMs, 0));
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function waitForElement(
|
|
52
|
+
selector: string,
|
|
53
|
+
root: ParentNode = document,
|
|
54
|
+
): Promise<Element> {
|
|
55
|
+
return new Promise((resolve) => {
|
|
56
|
+
const existing = root.querySelector(selector);
|
|
57
|
+
|
|
58
|
+
if (existing) {
|
|
59
|
+
resolve(existing);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Use DOM observation instead of polling when the dependency is structural,
|
|
64
|
+
// such as late-rendered provider placeholders or dynamically added rows.
|
|
65
|
+
const observer = new MutationObserver(() => {
|
|
66
|
+
const match = root.querySelector(selector);
|
|
67
|
+
|
|
68
|
+
if (!match) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
observer.disconnect();
|
|
73
|
+
resolve(match);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
observer.observe(root, {
|
|
77
|
+
childList: true,
|
|
78
|
+
subtree: true,
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
type FormieDebugGlobal = {
|
|
2
|
+
__FORMIE_DEBUG__?: boolean;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export type FormieDebugCategory = 'general' | 'fields' | 'conditions' | 'address' | 'captchas' | 'payments';
|
|
6
|
+
|
|
7
|
+
function getDebugGlobal(): FormieDebugGlobal {
|
|
8
|
+
return globalThis as FormieDebugGlobal;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isFormieDebugEnabled(): boolean {
|
|
12
|
+
return getDebugGlobal().__FORMIE_DEBUG__ === true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function setFormieDebugEnabled(enabled: boolean): void {
|
|
16
|
+
getDebugGlobal().__FORMIE_DEBUG__ = enabled;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function debugLog(scope: string, message: string, meta?: unknown): void {
|
|
20
|
+
if (!isFormieDebugEnabled()) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (typeof meta === 'undefined') {
|
|
25
|
+
console.log(`[formie:${scope}] ${message}`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
console.log(`[formie:${scope}] ${message}`, meta);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function debugWarn(scope: string, message: string, meta?: unknown): void {
|
|
33
|
+
if (!isFormieDebugEnabled()) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (typeof meta === 'undefined') {
|
|
38
|
+
console.warn(`[formie:${scope}] ${message}`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.warn(`[formie:${scope}] ${message}`, meta);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function createDebug(category: FormieDebugCategory, module?: string): {
|
|
46
|
+
log: (message: string, meta?: unknown) => void;
|
|
47
|
+
warn: (message: string, meta?: unknown) => void;
|
|
48
|
+
} {
|
|
49
|
+
const scope = module ? `${category}:${module}` : category;
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
log: (message, meta) => {
|
|
53
|
+
debugLog(scope, message, meta);
|
|
54
|
+
},
|
|
55
|
+
warn: (message, meta) => {
|
|
56
|
+
debugWarn(scope, message, meta);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export const FORMIE_HTML_EVENT_NAMES = [
|
|
2
|
+
'formie:mount:after',
|
|
3
|
+
'formie:unmount:before',
|
|
4
|
+
'formie:unmount:after',
|
|
5
|
+
'formie:validator:ready',
|
|
6
|
+
'formie:theme:applied',
|
|
7
|
+
'formie:page:navigate',
|
|
8
|
+
'formie:page:navigate:after',
|
|
9
|
+
'formie:page:navigate:error',
|
|
10
|
+
'formie:submit:before',
|
|
11
|
+
'formie:submit:after',
|
|
12
|
+
'formie:submit:final:before',
|
|
13
|
+
'formie:submit:final:after',
|
|
14
|
+
'formie:submit:result',
|
|
15
|
+
'formie:client-event',
|
|
16
|
+
'formie:refresh-tokens:after',
|
|
17
|
+
'formie:refresh-tokens:refreshed',
|
|
18
|
+
] as const;
|
|
19
|
+
|
|
20
|
+
export function toDomEventName(eventName: string): string {
|
|
21
|
+
return normalizeFormieEventName(eventName);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function normalizeFormieEventName(eventName: string): string {
|
|
25
|
+
return eventName;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type ModuleLifecycleEventPhase = 'before-setup' | 'after-setup' | 'before-destroy' | 'after-destroy';
|
|
29
|
+
|
|
30
|
+
export function getFieldModuleEventName(moduleId: string, name: string): string {
|
|
31
|
+
return `formie:field:${moduleId}:${name}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getValidatorEventName(name: string): string {
|
|
35
|
+
return `formie:validator:${name}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function getAddressProviderEventName(providerId: string, name: string): string {
|
|
39
|
+
return `formie:address:${providerId}:${name}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getFileUploadEventName(name: string): string {
|
|
43
|
+
return `formie:file-upload:${name}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function getPaymentProviderActionEventName(providerId: string, action: string): string {
|
|
47
|
+
return `formie:payment:${providerId}:${action}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function getFormStateEventName(name: string): string {
|
|
51
|
+
return `formie:state:${name}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function getScopedModuleLifecycleEventName(moduleId: string, phase: ModuleLifecycleEventPhase): string {
|
|
55
|
+
return `formie:module:${moduleId}:${phase}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getGlobalModuleLifecycleEventName(phase: ModuleLifecycleEventPhase): string {
|
|
59
|
+
return `formie:module:${phase}`;
|
|
60
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function stripFieldPrefix(value: string): string {
|
|
2
|
+
return value
|
|
3
|
+
.replace(/^\{field:/, '')
|
|
4
|
+
.replace(/^\{/, '')
|
|
5
|
+
.replace(/\}$/, '')
|
|
6
|
+
.trim();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function normalizeFieldKey(value: string): string {
|
|
10
|
+
return stripFieldPrefix(value)
|
|
11
|
+
.replace(/\]/g, '')
|
|
12
|
+
.split('[')
|
|
13
|
+
.join('.')
|
|
14
|
+
.replace(/\.+/g, '.')
|
|
15
|
+
.replace(/^\./, '')
|
|
16
|
+
.replace(/\.$/, '');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function fieldKeyToInputName(key: string): string {
|
|
20
|
+
const normalized = normalizeFieldKey(key);
|
|
21
|
+
const parts = normalized.split('.').filter(Boolean);
|
|
22
|
+
|
|
23
|
+
if (!parts.length) {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const [head, ...rest] = parts;
|
|
28
|
+
|
|
29
|
+
return `fields[${head}]${rest.map((part) => `[${part}]`).join('')}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function inputNameToFieldKey(name: string): string {
|
|
33
|
+
const trimmedName = String(name || '').trim();
|
|
34
|
+
const match = trimmedName.match(/^fields\[([^\]]+)\](.*)$/);
|
|
35
|
+
|
|
36
|
+
if (!match) {
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const first = match[1] || '';
|
|
41
|
+
const tail = match[2] || '';
|
|
42
|
+
const suffix = Array.from(tail.matchAll(/\[([^\]]+)\]/g)).map((part) => {
|
|
43
|
+
return part[1] || '';
|
|
44
|
+
}).filter(Boolean);
|
|
45
|
+
|
|
46
|
+
return [first, ...suffix].join('.');
|
|
47
|
+
}
|