@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,426 @@
|
|
|
1
|
+
import stripeCss from '#theme/integrations/_stripe.css?inline';
|
|
2
|
+
|
|
3
|
+
import { definePaymentModule } from '#modules/payments/api';
|
|
4
|
+
import { ensureModuleStyles } from '#modules/styles';
|
|
5
|
+
import { addThemeClasses, removeThemeClasses } from '#theme/theme-classes';
|
|
6
|
+
import { getPaymentProviderActionEventName } from '#utils/event-names';
|
|
7
|
+
import { loadScriptAndEnsureGlobal } from '#utils/scripts';
|
|
8
|
+
|
|
9
|
+
ensureModuleStyles('stripe', [stripeCss]);
|
|
10
|
+
|
|
11
|
+
type StripeConstructor = (publishableKey: string) => StripeInstance;
|
|
12
|
+
|
|
13
|
+
type StripeInstance = {
|
|
14
|
+
elements: (options: Record<string, unknown>) => StripeElements;
|
|
15
|
+
confirmPayment: (opts: {
|
|
16
|
+
elements: StripeElements;
|
|
17
|
+
clientSecret: string;
|
|
18
|
+
redirect?: string;
|
|
19
|
+
confirmParams?: { return_url: string };
|
|
20
|
+
}) => Promise<{ paymentIntent?: { id: string }; error?: { message: string } }>;
|
|
21
|
+
confirmSetup: (opts: {
|
|
22
|
+
elements: StripeElements;
|
|
23
|
+
clientSecret: string;
|
|
24
|
+
redirect?: string;
|
|
25
|
+
confirmParams?: { return_url: string };
|
|
26
|
+
}) => Promise<{ setupIntent?: { id: string }; error?: { message: string } }>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type StripeElements = {
|
|
30
|
+
create: (type: string, options?: Record<string, unknown>) => StripePaymentElement;
|
|
31
|
+
update: (params: Record<string, unknown>) => void;
|
|
32
|
+
submit: () => Promise<{ error?: { message: string } }>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type StripePaymentElement = {
|
|
36
|
+
mount: (el: HTMLElement) => void;
|
|
37
|
+
clear: () => void;
|
|
38
|
+
destroy: () => void;
|
|
39
|
+
on?: (event: 'ready' | 'loaderror', callback: (event?: { error?: { message?: string } }) => void) => void;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type StripeProviderOptions = {
|
|
43
|
+
publishableKey?: string;
|
|
44
|
+
paymentType?: string;
|
|
45
|
+
amountType?: string;
|
|
46
|
+
currencyType?: string;
|
|
47
|
+
billingDetails?: Record<string, string> | null;
|
|
48
|
+
initialPaymentInformation?: Record<string, unknown>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const SCRIPT_ID = 'FORMIE_STRIPE_SCRIPT';
|
|
52
|
+
const CONFIRM_EVENT = getPaymentProviderActionEventName('stripe', 'confirm');
|
|
53
|
+
const PLACEHOLDER_SELECTOR = '[data-formie-stripe-elements-placeholder]';
|
|
54
|
+
|
|
55
|
+
type StripeWidget = { elements: StripeElements; paymentElement: StripePaymentElement };
|
|
56
|
+
type StripeFieldState = Element & {
|
|
57
|
+
__formieStripeElements?: StripeElements;
|
|
58
|
+
__formieStripeInstance?: StripeInstance | null;
|
|
59
|
+
__formieStripeWidget?: StripeWidget | null;
|
|
60
|
+
__formieStripeDynamicUnbind?: (() => void) | null;
|
|
61
|
+
__formieStripeConfirmUnbind?: (() => void) | null;
|
|
62
|
+
__formieStripeConfirming?: boolean;
|
|
63
|
+
__formieStripeLastClientSecret?: string;
|
|
64
|
+
__formieStripeEvaluateAndRender?: (() => void) | null;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const ZERO_DECIMAL_CURRENCIES = new Set([
|
|
68
|
+
'BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG',
|
|
69
|
+
'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF',
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
function toStripeSubunitAmount(amount: number, currency: string): number {
|
|
73
|
+
if (ZERO_DECIMAL_CURRENCIES.has(currency.toUpperCase())) {
|
|
74
|
+
return Math.ceil(amount);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return Math.ceil(amount * 100);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function clearPlaceholderError(placeholder: HTMLElement | null, themeSource: Element | null): void {
|
|
81
|
+
if (!placeholder) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
removeThemeClasses(placeholder, themeSource, 'fieldErrors', 'fieldError');
|
|
86
|
+
placeholder.querySelectorAll('[data-payment-placeholder-error]').forEach((el) => {
|
|
87
|
+
removeThemeClasses(el as Element, themeSource, 'fieldError');
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function renderPlaceholderLoading(placeholder: HTMLElement | null, themeSource: Element | null, message = 'Loading payment options...'): void {
|
|
92
|
+
if (!placeholder) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
clearPlaceholderError(placeholder, themeSource);
|
|
97
|
+
placeholder.removeAttribute('hidden');
|
|
98
|
+
placeholder.innerHTML = '';
|
|
99
|
+
const spinner = document.createElement('div');
|
|
100
|
+
spinner.className = 'formie-loading';
|
|
101
|
+
const text = document.createElement('div');
|
|
102
|
+
text.textContent = message;
|
|
103
|
+
placeholder.append(spinner, text);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function showPlaceholderMessage(placeholder: HTMLElement | null, themeSource: Element | null, message: string): void {
|
|
107
|
+
if (!placeholder) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
clearPlaceholderError(placeholder, themeSource);
|
|
112
|
+
placeholder.removeAttribute('hidden');
|
|
113
|
+
addThemeClasses(placeholder, themeSource, 'fieldErrors');
|
|
114
|
+
placeholder.innerHTML = '';
|
|
115
|
+
const error = document.createElement('div');
|
|
116
|
+
error.setAttribute('data-payment-placeholder-error', '');
|
|
117
|
+
error.textContent = message;
|
|
118
|
+
addThemeClasses(error, themeSource, 'fieldError');
|
|
119
|
+
placeholder.appendChild(error);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const stripeModule = definePaymentModule<StripeProviderOptions, StripeInstance | null, StripeWidget | null>({
|
|
123
|
+
id: 'stripe',
|
|
124
|
+
defaultRequiredInputSuffixes: ['stripePaymentIntentId'],
|
|
125
|
+
load: async (ctx) => {
|
|
126
|
+
const { provider } = ctx.options;
|
|
127
|
+
const publishableKey = provider.publishableKey as string | undefined;
|
|
128
|
+
|
|
129
|
+
if (!publishableKey?.trim()) {
|
|
130
|
+
console.error('[formie] Missing publishableKey for Stripe.');
|
|
131
|
+
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const StripeGlobal = await loadScriptAndEnsureGlobal<StripeConstructor>('Stripe', {
|
|
136
|
+
id: SCRIPT_ID,
|
|
137
|
+
src: 'https://js.stripe.com/v3',
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const stripe = (StripeGlobal as (key: string) => StripeInstance)(publishableKey);
|
|
141
|
+
|
|
142
|
+
return stripe;
|
|
143
|
+
},
|
|
144
|
+
mount: async (args) => {
|
|
145
|
+
const { api, field, services, provider } = args;
|
|
146
|
+
const placeholder = field.querySelector<HTMLElement>('[data-formie-stripe-elements]');
|
|
147
|
+
const loadingPlaceholder = field.querySelector<HTMLElement>(PLACEHOLDER_SELECTOR);
|
|
148
|
+
const stripeField = field as StripeFieldState;
|
|
149
|
+
const themeSource = services.form || services.root;
|
|
150
|
+
|
|
151
|
+
if (!placeholder || !api) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const initial = (provider.initialPaymentInformation as Record<string, unknown>) || {};
|
|
156
|
+
const dynamicHandles = [initial.amount, initial.currency]
|
|
157
|
+
.map((value) => String(value ?? '').trim())
|
|
158
|
+
.filter((value, index) => {
|
|
159
|
+
const isAmount = index === 0;
|
|
160
|
+
const type = isAmount ? provider.amountType : provider.currencyType;
|
|
161
|
+
|
|
162
|
+
return type === 'dynamic' && value !== '';
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const getResolvedPaymentInfo = (): { ok: true; value: Record<string, unknown> } | { ok: false; error: string } => {
|
|
166
|
+
const amountResult = services.resolveAmount({ value: initial.amount });
|
|
167
|
+
if (!amountResult.ok) {
|
|
168
|
+
return {
|
|
169
|
+
ok: false,
|
|
170
|
+
error: 'error' in amountResult ? amountResult.error : 'Provide a payment amount to proceed.',
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const currencyResult = services.resolveCurrency({ value: initial.currency });
|
|
175
|
+
if (!currencyResult.ok) {
|
|
176
|
+
return {
|
|
177
|
+
ok: false,
|
|
178
|
+
error: 'error' in currencyResult ? currencyResult.error : 'Provide a payment currency to proceed.',
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const currencyCode = currencyResult.value.toLowerCase();
|
|
183
|
+
const amountValue = provider.amountType === 'dynamic'
|
|
184
|
+
? toStripeSubunitAmount(amountResult.value, currencyCode)
|
|
185
|
+
: amountResult.value;
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
ok: true,
|
|
189
|
+
value: {
|
|
190
|
+
...initial,
|
|
191
|
+
capture_method: 'automatic',
|
|
192
|
+
mode: provider.paymentType === 'subscription' ? 'subscription' : 'payment',
|
|
193
|
+
appearance: {},
|
|
194
|
+
amount: amountValue,
|
|
195
|
+
currency: currencyCode,
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const destroyWidget = () => {
|
|
201
|
+
try {
|
|
202
|
+
stripeField.__formieStripeWidget?.paymentElement?.destroy?.();
|
|
203
|
+
} catch (error) {
|
|
204
|
+
// Best-effort cleanup only. We'll still reset local state below.
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
stripeField.__formieStripeWidget = null;
|
|
208
|
+
stripeField.__formieStripeElements = undefined;
|
|
209
|
+
|
|
210
|
+
// Ensure the container is empty after teardown to avoid stale Stripe UI.
|
|
211
|
+
placeholder.innerHTML = '';
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const evaluateAndRender = () => {
|
|
215
|
+
const resolved = getResolvedPaymentInfo();
|
|
216
|
+
if (!resolved.ok) {
|
|
217
|
+
destroyWidget();
|
|
218
|
+
showPlaceholderMessage(
|
|
219
|
+
loadingPlaceholder,
|
|
220
|
+
themeSource,
|
|
221
|
+
'error' in resolved ? resolved.error : 'Unable to resolve payment details.',
|
|
222
|
+
);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
try {
|
|
227
|
+
if (stripeField.__formieStripeWidget && stripeField.__formieStripeElements) {
|
|
228
|
+
stripeField.__formieStripeElements.update(resolved.value);
|
|
229
|
+
clearPlaceholderError(loadingPlaceholder, themeSource);
|
|
230
|
+
loadingPlaceholder?.setAttribute('hidden', 'hidden');
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
renderPlaceholderLoading(loadingPlaceholder, themeSource);
|
|
235
|
+
const elements = api.elements(resolved.value);
|
|
236
|
+
const paymentElement = elements.create('payment', {});
|
|
237
|
+
paymentElement.mount(placeholder);
|
|
238
|
+
|
|
239
|
+
paymentElement.on?.('loaderror', (event) => {
|
|
240
|
+
const message = event?.error?.message || 'Unable to load payment options.';
|
|
241
|
+
destroyWidget();
|
|
242
|
+
showPlaceholderMessage(loadingPlaceholder, themeSource, message);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
paymentElement.on?.('ready', () => {
|
|
246
|
+
clearPlaceholderError(loadingPlaceholder, themeSource);
|
|
247
|
+
loadingPlaceholder?.setAttribute('hidden', 'hidden');
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
stripeField.__formieStripeElements = elements;
|
|
251
|
+
stripeField.__formieStripeInstance = api;
|
|
252
|
+
stripeField.__formieStripeWidget = { elements, paymentElement };
|
|
253
|
+
if (!paymentElement.on) {
|
|
254
|
+
clearPlaceholderError(loadingPlaceholder, themeSource);
|
|
255
|
+
loadingPlaceholder?.setAttribute('hidden', 'hidden');
|
|
256
|
+
}
|
|
257
|
+
} catch (error) {
|
|
258
|
+
destroyWidget();
|
|
259
|
+
showPlaceholderMessage(
|
|
260
|
+
loadingPlaceholder,
|
|
261
|
+
themeSource,
|
|
262
|
+
error instanceof Error ? error.message : 'Unable to initialize Stripe payment element.',
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
stripeField.__formieStripeEvaluateAndRender = evaluateAndRender;
|
|
268
|
+
|
|
269
|
+
stripeField.__formieStripeDynamicUnbind?.();
|
|
270
|
+
if (dynamicHandles.length > 0) {
|
|
271
|
+
stripeField.__formieStripeDynamicUnbind = services.watchFieldValueChanges(dynamicHandles, () => {
|
|
272
|
+
evaluateAndRender();
|
|
273
|
+
}, 600);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
evaluateAndRender();
|
|
277
|
+
|
|
278
|
+
return stripeField.__formieStripeWidget || null;
|
|
279
|
+
},
|
|
280
|
+
unmount: async (args) => {
|
|
281
|
+
args.widget?.paymentElement?.destroy();
|
|
282
|
+
const stripeField = args.field as StripeFieldState;
|
|
283
|
+
stripeField.__formieStripeWidget = null;
|
|
284
|
+
stripeField.__formieStripeElements = undefined;
|
|
285
|
+
stripeField.__formieStripeInstance = null;
|
|
286
|
+
stripeField.__formieStripeLastClientSecret = undefined;
|
|
287
|
+
stripeField.__formieStripeEvaluateAndRender = null;
|
|
288
|
+
stripeField.__formieStripeDynamicUnbind?.();
|
|
289
|
+
stripeField.__formieStripeDynamicUnbind = null;
|
|
290
|
+
},
|
|
291
|
+
onBeforeAuthorize: async (args) => {
|
|
292
|
+
const { widget, services, field } = args;
|
|
293
|
+
const stripeField = field as StripeFieldState;
|
|
294
|
+
let activeWidget = widget;
|
|
295
|
+
|
|
296
|
+
// Multi-page dynamic flows can temporarily destroy the payment element when
|
|
297
|
+
// amount/currency becomes invalid. Re-evaluate right before authorize so a
|
|
298
|
+
// now-valid value can remount without requiring another input/change event.
|
|
299
|
+
if (!activeWidget?.elements) {
|
|
300
|
+
stripeField.__formieStripeEvaluateAndRender?.();
|
|
301
|
+
activeWidget = stripeField.__formieStripeWidget || null;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (!activeWidget?.elements) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const result = await activeWidget.elements.submit();
|
|
309
|
+
|
|
310
|
+
if (result?.error) {
|
|
311
|
+
services.addError(result.error.message);
|
|
312
|
+
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return true;
|
|
317
|
+
},
|
|
318
|
+
setup: async (ctx) => {
|
|
319
|
+
const { services, options } = ctx;
|
|
320
|
+
const provider = options.provider as StripeProviderOptions;
|
|
321
|
+
const field = ctx.target as StripeFieldState;
|
|
322
|
+
|
|
323
|
+
const handler = async (event: Event) => {
|
|
324
|
+
try {
|
|
325
|
+
const e = event as CustomEvent<{ data?: { clientSecret?: string; returnUrl?: string; type?: string; subscriptionId?: string } }>;
|
|
326
|
+
const data = e.detail?.data;
|
|
327
|
+
|
|
328
|
+
if (!data?.clientSecret) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Prevent duplicate/looped confirms for the same server response.
|
|
333
|
+
if (field.__formieStripeConfirming) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (field.__formieStripeLastClientSecret === data.clientSecret) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const elements = field.__formieStripeElements;
|
|
342
|
+
if (!elements) {
|
|
343
|
+
services.addError('Stripe elements not ready for 3DS.');
|
|
344
|
+
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const instance = field.__formieStripeInstance;
|
|
349
|
+
const publishableKey = provider.publishableKey as string;
|
|
350
|
+
|
|
351
|
+
if (!instance || !publishableKey) {
|
|
352
|
+
services.addError('Stripe is not initialized.');
|
|
353
|
+
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
field.__formieStripeConfirming = true;
|
|
358
|
+
const returnUrl = new URL(data.returnUrl || window.location.href);
|
|
359
|
+
returnUrl.searchParams.set('origin', window.location.href);
|
|
360
|
+
|
|
361
|
+
const confirmFn = data.type === 'setup' ? instance.confirmSetup : instance.confirmPayment;
|
|
362
|
+
const result = await confirmFn({
|
|
363
|
+
elements,
|
|
364
|
+
clientSecret: data.clientSecret,
|
|
365
|
+
redirect: 'if_required',
|
|
366
|
+
confirmParams: { return_url: returnUrl.toString() },
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
if (result?.error) {
|
|
370
|
+
services.releaseSubmitLoading();
|
|
371
|
+
services.addError(result.error.message);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (data.subscriptionId) {
|
|
376
|
+
services.updateInputs('stripeSubscriptionId', data.subscriptionId);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const pi = result && 'paymentIntent' in result ? result.paymentIntent : null;
|
|
380
|
+
const si = result && 'setupIntent' in result ? result.setupIntent : null;
|
|
381
|
+
|
|
382
|
+
if (pi?.id) {
|
|
383
|
+
services.updateInputs('stripePaymentIntentId', pi.id);
|
|
384
|
+
} else if (si?.id) {
|
|
385
|
+
services.updateInputs('stripePaymentIntentId', si.id);
|
|
386
|
+
} else {
|
|
387
|
+
services.releaseSubmitLoading();
|
|
388
|
+
services.addError('Stripe confirmation did not return an intent ID.');
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
field.__formieStripeLastClientSecret = data.clientSecret;
|
|
393
|
+
services.triggerSubmit();
|
|
394
|
+
} catch (error) {
|
|
395
|
+
services.releaseSubmitLoading();
|
|
396
|
+
services.addError(error instanceof Error ? error.message : 'Unable to confirm Stripe payment.');
|
|
397
|
+
} finally {
|
|
398
|
+
field.__formieStripeConfirming = false;
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
field.__formieStripeConfirmUnbind?.();
|
|
403
|
+
const unbind = services.events.onForm(CONFIRM_EVENT, handler as EventListener);
|
|
404
|
+
field.__formieStripeConfirmUnbind = unbind;
|
|
405
|
+
|
|
406
|
+
return {
|
|
407
|
+
destroy: () => {
|
|
408
|
+
field.__formieStripeConfirmUnbind?.();
|
|
409
|
+
field.__formieStripeConfirmUnbind = null;
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
},
|
|
413
|
+
onAfterSubmit: async (args) => {
|
|
414
|
+
const stripeField = args.field as StripeFieldState;
|
|
415
|
+
|
|
416
|
+
// After a completed final submit, clear the Stripe element + hidden IDs
|
|
417
|
+
// so stale intents cannot be replayed.
|
|
418
|
+
if (args.result?.ok && !args.result?.nextPage) {
|
|
419
|
+
stripeField.__formieStripeWidget?.paymentElement?.destroy?.();
|
|
420
|
+
stripeField.__formieStripeWidget = null;
|
|
421
|
+
stripeField.__formieStripeElements = undefined;
|
|
422
|
+
args.services.updateInputs(['stripePaymentIntentId', 'stripeSubscriptionId'], '');
|
|
423
|
+
stripeField.__formieStripeLastClientSecret = undefined;
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { FormieModuleDefinition } from '#contracts/modules';
|
|
2
|
+
import {
|
|
3
|
+
getPaymentProviderHandle,
|
|
4
|
+
waitForRequiredPaymentInputs,
|
|
5
|
+
type PaymentProviderOptions,
|
|
6
|
+
} from '#modules/payments/utils';
|
|
7
|
+
|
|
8
|
+
type StubPaymentModuleConfig = {
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const DEFAULT_WAIT_FOR_VALUE_MS = 2500;
|
|
13
|
+
|
|
14
|
+
export function createStubPaymentModule({ id }: StubPaymentModuleConfig): FormieModuleDefinition {
|
|
15
|
+
return {
|
|
16
|
+
id,
|
|
17
|
+
kind: 'payment',
|
|
18
|
+
match: () => true,
|
|
19
|
+
setup: async(ctx) => {
|
|
20
|
+
const options = (ctx.options || {}) as PaymentProviderOptions;
|
|
21
|
+
const targetRoot = ctx.scope === 'field' ? ctx.target : ctx.root;
|
|
22
|
+
const requiredInputSuffixes = Array.isArray(options.requiredInputSuffixes)
|
|
23
|
+
? options.requiredInputSuffixes.map(String)
|
|
24
|
+
: [];
|
|
25
|
+
const waitForValueMs = Number(options.waitForValueMs || DEFAULT_WAIT_FOR_VALUE_MS);
|
|
26
|
+
const providerHandle = getPaymentProviderHandle(id, options);
|
|
27
|
+
|
|
28
|
+
await ctx.emit(`formie:module:${id}:init`, {
|
|
29
|
+
options,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
destroy: () => {
|
|
34
|
+
void ctx.emit(`formie:module:${id}:destroy`, {});
|
|
35
|
+
},
|
|
36
|
+
onBeforeStage: async(stageCtx) => {
|
|
37
|
+
if (stageCtx.stage !== 'authorize' || stageCtx.action !== 'submit') {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (requiredInputSuffixes.length === 0) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
await ctx.emit('formie:payment:provider:authorize:before', {
|
|
46
|
+
provider: {
|
|
47
|
+
handle: providerHandle,
|
|
48
|
+
...options,
|
|
49
|
+
},
|
|
50
|
+
action: stageCtx.action,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const result = await waitForRequiredPaymentInputs(
|
|
54
|
+
targetRoot,
|
|
55
|
+
requiredInputSuffixes,
|
|
56
|
+
waitForValueMs
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
if (!result.ok) {
|
|
60
|
+
const message = options.errorMessage || 'Payment authorization is incomplete.';
|
|
61
|
+
stageCtx.abort(message);
|
|
62
|
+
|
|
63
|
+
await ctx.emit('formie:payment:provider:authorize:error', {
|
|
64
|
+
reason: 'missing-payment-token',
|
|
65
|
+
provider: {
|
|
66
|
+
handle: providerHandle,
|
|
67
|
+
...options,
|
|
68
|
+
},
|
|
69
|
+
action: stageCtx.action,
|
|
70
|
+
missingSuffix: result.missingSuffix,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
await ctx.emit('formie:payment:provider:authorize:after', {
|
|
77
|
+
provider: {
|
|
78
|
+
handle: providerHandle,
|
|
79
|
+
...options,
|
|
80
|
+
},
|
|
81
|
+
action: stageCtx.action,
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { sleep } from '#utils/async';
|
|
2
|
+
|
|
3
|
+
export type PaymentProviderOptions = {
|
|
4
|
+
handle?: string;
|
|
5
|
+
requiredInputSuffixes?: string[];
|
|
6
|
+
waitForValueMs?: number;
|
|
7
|
+
errorMessage?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function getPaymentProviderHandle(id: string, options: PaymentProviderOptions): string {
|
|
11
|
+
if (typeof options.handle === 'string' && options.handle.trim() !== '') {
|
|
12
|
+
return options.handle.trim();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return id;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function findPaymentInputBySuffix(root: Element, suffix: string): HTMLInputElement | null {
|
|
19
|
+
const escapedSuffix = suffix.replace(/"/g, '\\"');
|
|
20
|
+
return (root.querySelector(`input[name$="[${escapedSuffix}]"]`) ||
|
|
21
|
+
root.querySelector(`input[name$="${escapedSuffix}"]`)) as HTMLInputElement | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function hasRequiredPaymentInputs(root: Element, requiredInputSuffixes: string[]): { ok: boolean; missingSuffix?: string } {
|
|
25
|
+
const missingSuffix = requiredInputSuffixes.find((suffix) => {
|
|
26
|
+
const input = findPaymentInputBySuffix(root, suffix);
|
|
27
|
+
return !input || String(input.value || '').trim() === '';
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
ok: !missingSuffix,
|
|
32
|
+
missingSuffix,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function waitForRequiredPaymentInputs(
|
|
37
|
+
root: Element,
|
|
38
|
+
requiredInputSuffixes: string[],
|
|
39
|
+
waitForValueMs: number,
|
|
40
|
+
): Promise<{ ok: boolean; missingSuffix?: string }> {
|
|
41
|
+
const initial = hasRequiredPaymentInputs(root, requiredInputSuffixes);
|
|
42
|
+
|
|
43
|
+
if (initial.ok) {
|
|
44
|
+
return initial;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const deadline = Date.now() + Math.max(waitForValueMs, 0);
|
|
48
|
+
|
|
49
|
+
while (Date.now() < deadline) {
|
|
50
|
+
await sleep(120);
|
|
51
|
+
|
|
52
|
+
const current = hasRequiredPaymentInputs(root, requiredInputSuffixes);
|
|
53
|
+
|
|
54
|
+
if (current.ok) {
|
|
55
|
+
return current;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return hasRequiredPaymentInputs(root, requiredInputSuffixes);
|
|
60
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { FormieModuleDefinition, ModuleRegistrationOptions } from '#contracts/modules';
|
|
2
|
+
|
|
3
|
+
export class ModuleRegistry {
|
|
4
|
+
private modules = new Map<string, FormieModuleDefinition>();
|
|
5
|
+
|
|
6
|
+
register(moduleDefinition: FormieModuleDefinition, options: ModuleRegistrationOptions = {}): boolean {
|
|
7
|
+
// The registry is intentionally lightweight: the loader handles lazy
|
|
8
|
+
// resolution, while this class only tracks already-available definitions.
|
|
9
|
+
const existing = this.modules.get(moduleDefinition.id);
|
|
10
|
+
|
|
11
|
+
if (existing === moduleDefinition) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (existing && !options.replace) {
|
|
16
|
+
console.warn(
|
|
17
|
+
`[formie] Module "${moduleDefinition.id}" is already registered. `
|
|
18
|
+
+ 'Pass { replace: true } to override the existing definition.',
|
|
19
|
+
);
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
this.modules.set(moduleDefinition.id, moduleDefinition);
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
unregister(moduleId: string): void {
|
|
28
|
+
this.modules.delete(moduleId);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get(moduleId: string): FormieModuleDefinition | null {
|
|
32
|
+
return this.modules.get(moduleId) || null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getAll(): FormieModuleDefinition[] {
|
|
36
|
+
return Array.from(this.modules.values());
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const injectedModuleStyles = new Set<string>();
|
|
2
|
+
|
|
3
|
+
export function ensureModuleStyles(moduleId: string, styles: Array<string | null | undefined>): void {
|
|
4
|
+
if (typeof document === 'undefined') {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const styleId = `formie-module-style:${moduleId}`;
|
|
9
|
+
|
|
10
|
+
if (injectedModuleStyles.has(styleId) || document.querySelector(`style[data-formie-module-style="${moduleId}"]`)) {
|
|
11
|
+
injectedModuleStyles.add(styleId);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const cssText = styles
|
|
16
|
+
.filter((style): style is string => typeof style === 'string' && style.trim().length > 0)
|
|
17
|
+
.join('\n');
|
|
18
|
+
|
|
19
|
+
if (!cssText) {
|
|
20
|
+
injectedModuleStyles.add(styleId);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const style = document.createElement('style');
|
|
25
|
+
style.setAttribute('data-formie-module-style', moduleId);
|
|
26
|
+
style.textContent = cssText;
|
|
27
|
+
document.head.appendChild(style);
|
|
28
|
+
injectedModuleStyles.add(styleId);
|
|
29
|
+
}
|