@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,183 @@
|
|
|
1
|
+
import type { FormieModuleDefinition } from '#contracts/modules';
|
|
2
|
+
|
|
3
|
+
type PaymentProviderConfig = {
|
|
4
|
+
handle: string;
|
|
5
|
+
requiredInputSuffixes: string[];
|
|
6
|
+
waitForValueMs: number;
|
|
7
|
+
errorMessage?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const DEFAULT_WAIT_FOR_VALUE_MS = 2500;
|
|
11
|
+
|
|
12
|
+
const DEFAULT_PROVIDER_SUFFIXES: Record<string, string[]> = {
|
|
13
|
+
stripe: ['stripePaymentIntentId'],
|
|
14
|
+
paypal: ['paypalOrderId'],
|
|
15
|
+
payway: ['paywayTokenId'],
|
|
16
|
+
opayo: ['opayoTokenId'],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function normalizeProviders(rawProviders: unknown, fallbackSuffixes: string[]): PaymentProviderConfig[] {
|
|
20
|
+
if (!Array.isArray(rawProviders) || rawProviders.length === 0) {
|
|
21
|
+
return [{
|
|
22
|
+
handle: 'generic',
|
|
23
|
+
requiredInputSuffixes: fallbackSuffixes,
|
|
24
|
+
waitForValueMs: DEFAULT_WAIT_FOR_VALUE_MS,
|
|
25
|
+
}];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return rawProviders.map((item) => {
|
|
29
|
+
if (typeof item === 'string') {
|
|
30
|
+
const normalizedHandle = item.trim();
|
|
31
|
+
return {
|
|
32
|
+
handle: normalizedHandle || 'unknown',
|
|
33
|
+
requiredInputSuffixes: DEFAULT_PROVIDER_SUFFIXES[normalizedHandle] || fallbackSuffixes,
|
|
34
|
+
waitForValueMs: DEFAULT_WAIT_FOR_VALUE_MS,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const raw = (item && typeof item === 'object' ? item : {}) as Record<string, unknown>;
|
|
39
|
+
const handle = String(raw.handle || '').trim();
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
handle: handle || 'unknown',
|
|
43
|
+
requiredInputSuffixes: Array.isArray(raw.requiredInputSuffixes)
|
|
44
|
+
? raw.requiredInputSuffixes.map(String)
|
|
45
|
+
: (DEFAULT_PROVIDER_SUFFIXES[handle] || fallbackSuffixes),
|
|
46
|
+
waitForValueMs: Number(raw.waitForValueMs || DEFAULT_WAIT_FOR_VALUE_MS),
|
|
47
|
+
errorMessage: typeof raw.errorMessage === 'string' ? raw.errorMessage : undefined,
|
|
48
|
+
};
|
|
49
|
+
}).filter((provider) => {
|
|
50
|
+
return provider.requiredInputSuffixes.length > 0;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function findInputBySuffix(root: Element, suffix: string): HTMLInputElement | null {
|
|
55
|
+
const escapedSuffix = suffix.replace(/"/g, '\\"');
|
|
56
|
+
return (root.querySelector(`input[name$="[${escapedSuffix}]"]`) ||
|
|
57
|
+
root.querySelector(`input[name$="${escapedSuffix}"]`)) as HTMLInputElement | null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function hasAllRequiredInputs(root: Element, requiredInputSuffixes: string[]): { ok: boolean; missingSuffix?: string } {
|
|
61
|
+
const missingSuffix = requiredInputSuffixes.find((suffix) => {
|
|
62
|
+
const input = findInputBySuffix(root, suffix);
|
|
63
|
+
return !input || String(input.value || '').trim() === '';
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
ok: !missingSuffix,
|
|
68
|
+
missingSuffix,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function waitForRequiredInputs(root: Element, requiredInputSuffixes: string[], waitForValueMs: number): Promise<{ ok: boolean; missingSuffix?: string }> {
|
|
73
|
+
const initial = hasAllRequiredInputs(root, requiredInputSuffixes);
|
|
74
|
+
if (initial.ok) {
|
|
75
|
+
return initial;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const deadline = Date.now() + Math.max(waitForValueMs, 0);
|
|
79
|
+
|
|
80
|
+
// Payment SDKs often populate hidden tokens asynchronously after the user
|
|
81
|
+
// clicks submit, so authorize waits briefly for those inputs to settle.
|
|
82
|
+
while (Date.now() < deadline) {
|
|
83
|
+
await new Promise((resolve) => {
|
|
84
|
+
window.setTimeout(resolve, 120);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const current = hasAllRequiredInputs(root, requiredInputSuffixes);
|
|
88
|
+
if (current.ok) {
|
|
89
|
+
return current;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return hasAllRequiredInputs(root, requiredInputSuffixes);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const paymentModule: FormieModuleDefinition = {
|
|
97
|
+
id: 'payment',
|
|
98
|
+
kind: 'payment',
|
|
99
|
+
match: () => true,
|
|
100
|
+
setup: async(ctx) => {
|
|
101
|
+
const targetRoot = ctx.scope === 'field' ? ctx.target : ctx.root;
|
|
102
|
+
const requiredInputSuffixes = Array.isArray(ctx.options?.requiredInputSuffixes)
|
|
103
|
+
? (ctx.options?.requiredInputSuffixes as string[])
|
|
104
|
+
: [];
|
|
105
|
+
const providers = normalizeProviders(ctx.options?.providers, requiredInputSuffixes);
|
|
106
|
+
|
|
107
|
+
const hasPaymentField = !!targetRoot.querySelector('[data-formie-field-type="payment"]');
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
destroy: () => {
|
|
111
|
+
void ctx.emit('formie:module:payment:destroy', {});
|
|
112
|
+
},
|
|
113
|
+
onBeforeStage: async(stageCtx) => {
|
|
114
|
+
if (stageCtx.stage !== 'authorize') {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (stageCtx.action !== 'submit') {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!hasPaymentField) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
await ctx.emit('formie:payment:authorize:before', {
|
|
127
|
+
action: stageCtx.action,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
for (const provider of providers) {
|
|
131
|
+
await ctx.emit('formie:payment:provider:authorize:before', {
|
|
132
|
+
provider,
|
|
133
|
+
action: stageCtx.action,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const result = await waitForRequiredInputs(
|
|
137
|
+
targetRoot,
|
|
138
|
+
provider.requiredInputSuffixes,
|
|
139
|
+
provider.waitForValueMs
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
if (!result.ok) {
|
|
143
|
+
// Abort before dispatch so the form never posts without the
|
|
144
|
+
// provider-specific token the backend expects to finalize payment.
|
|
145
|
+
const message = provider.errorMessage || 'Payment authorization is incomplete.';
|
|
146
|
+
stageCtx.abort(message);
|
|
147
|
+
|
|
148
|
+
await ctx.emit('formie:payment:provider:authorize:error', {
|
|
149
|
+
reason: 'missing-payment-token',
|
|
150
|
+
provider,
|
|
151
|
+
action: stageCtx.action,
|
|
152
|
+
missingSuffix: result.missingSuffix,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
await ctx.emit('formie:payment:authorize:error', {
|
|
156
|
+
reason: 'missing-payment-token',
|
|
157
|
+
providerHandle: provider.handle,
|
|
158
|
+
missingSuffix: result.missingSuffix,
|
|
159
|
+
action: stageCtx.action,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
await ctx.emit('formie:payment:provider:authorize:after', {
|
|
166
|
+
provider,
|
|
167
|
+
action: stageCtx.action,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
onAfterStage: async(stageCtx, result) => {
|
|
172
|
+
if (stageCtx.stage !== 'authorize') {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
await ctx.emit('formie:payment:authorize:after', {
|
|
177
|
+
action: stageCtx.action,
|
|
178
|
+
result,
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import paypalCss from '#theme/integrations/_paypal.css?inline';
|
|
2
|
+
|
|
3
|
+
import { definePaymentModule } from '#modules/payments/api';
|
|
4
|
+
import { ensureModuleStyles } from '#modules/styles';
|
|
5
|
+
import { loadScriptAndEnsureGlobal } from '#utils/scripts';
|
|
6
|
+
|
|
7
|
+
ensureModuleStyles('paypal', [paypalCss]);
|
|
8
|
+
|
|
9
|
+
type PayPalButtonsInstance = {
|
|
10
|
+
close: () => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type PayPalActions = {
|
|
14
|
+
order: {
|
|
15
|
+
create: (config: Record<string, unknown>) => Promise<string>;
|
|
16
|
+
authorize: () => Promise<Record<string, unknown>>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type PayPalButtonsOptions = {
|
|
21
|
+
env: string;
|
|
22
|
+
style: Record<string, unknown>;
|
|
23
|
+
createOrder: (data: unknown, actions: PayPalActions) => Promise<string>;
|
|
24
|
+
onCancel?: () => void;
|
|
25
|
+
onError: (err: Error) => void;
|
|
26
|
+
onApprove: (data: { orderID: string }, actions: PayPalActions) => Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type PayPalGlobal = {
|
|
30
|
+
Buttons: (options: PayPalButtonsOptions) => { render: (el: HTMLElement) => PayPalButtonsInstance };
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type PayPalProviderOptions = {
|
|
34
|
+
clientId?: string;
|
|
35
|
+
useSandbox?: boolean;
|
|
36
|
+
currency?: string;
|
|
37
|
+
amountType?: string;
|
|
38
|
+
amountFixed?: number;
|
|
39
|
+
amountVariable?: string;
|
|
40
|
+
buttonLayout?: string;
|
|
41
|
+
buttonColor?: string;
|
|
42
|
+
buttonShape?: string;
|
|
43
|
+
buttonLabel?: string;
|
|
44
|
+
buttonTagline?: boolean;
|
|
45
|
+
buttonWidth?: number;
|
|
46
|
+
buttonHeight?: number;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const SCRIPT_ID = 'FORMIE_PAYPAL_SCRIPT';
|
|
50
|
+
|
|
51
|
+
function extractAuthIdFromAuthorization(result: Record<string, unknown> | null): string {
|
|
52
|
+
if (!result) {
|
|
53
|
+
return '';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const purchaseUnits = (result.purchase_units || []) as Array<Record<string, unknown>>;
|
|
57
|
+
const payments = (purchaseUnits[0]?.payments || {}) as Record<string, unknown>;
|
|
58
|
+
|
|
59
|
+
const authorizations = (payments.authorizations || []) as Array<Record<string, unknown>>;
|
|
60
|
+
const captures = (payments.captures || []) as Array<Record<string, unknown>>;
|
|
61
|
+
|
|
62
|
+
const authId = String(authorizations[0]?.id || captures[0]?.id || '');
|
|
63
|
+
|
|
64
|
+
return authId.trim();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function getScriptUrl(clientId: string, currency: string): string {
|
|
68
|
+
const params = [
|
|
69
|
+
'intent=authorize',
|
|
70
|
+
`currency=${encodeURIComponent(currency)}`,
|
|
71
|
+
`client-id=${encodeURIComponent(clientId)}`,
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
return `https://www.paypal.com/sdk/js?${params.join('&')}`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const paypalModule = definePaymentModule<PayPalProviderOptions, PayPalGlobal | null, PayPalButtonsInstance | null>({
|
|
78
|
+
id: 'paypal',
|
|
79
|
+
defaultRequiredInputSuffixes: ['paypalOrderId', 'paypalAuthId'],
|
|
80
|
+
load: async (ctx) => {
|
|
81
|
+
const { provider } = ctx.options;
|
|
82
|
+
const clientId = provider.clientId as string | undefined;
|
|
83
|
+
|
|
84
|
+
if (!clientId?.trim()) {
|
|
85
|
+
console.error('[formie] Missing clientId for PayPal.');
|
|
86
|
+
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const currency = (provider.currency as string) || 'AUD';
|
|
91
|
+
const scriptUrl = getScriptUrl(clientId, currency);
|
|
92
|
+
|
|
93
|
+
await loadScriptAndEnsureGlobal<PayPalGlobal>('paypal', {
|
|
94
|
+
id: SCRIPT_ID,
|
|
95
|
+
src: scriptUrl,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return (window as unknown as { paypal: PayPalGlobal }).paypal;
|
|
99
|
+
},
|
|
100
|
+
mount: async (args) => {
|
|
101
|
+
const { api, field, services, options, provider } = args;
|
|
102
|
+
const placeholder = field.querySelector<HTMLElement>('[data-formie-paypal-button]');
|
|
103
|
+
|
|
104
|
+
if (!placeholder || !api) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Guard against duplicate mounts on the same placeholder.
|
|
109
|
+
if (placeholder.getAttribute('data-formie-paypal-rendered') === 'true') {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Ensure a clean mount surface before rendering PayPal buttons.
|
|
114
|
+
placeholder.innerHTML = '';
|
|
115
|
+
|
|
116
|
+
const useSandbox = Boolean(provider.useSandbox);
|
|
117
|
+
const currencyResult = services.resolveCurrency({ value: provider.currency, defaultCurrency: 'AUD' });
|
|
118
|
+
|
|
119
|
+
if (!currencyResult.ok) {
|
|
120
|
+
services.addError(('error' in currencyResult) ? currencyResult.error : 'Invalid PayPal currency.');
|
|
121
|
+
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const currency = currencyResult.value;
|
|
126
|
+
|
|
127
|
+
const style: Record<string, unknown> = {
|
|
128
|
+
layout: provider.buttonLayout || 'vertical',
|
|
129
|
+
color: provider.buttonColor || 'gold',
|
|
130
|
+
shape: provider.buttonShape || 'rect',
|
|
131
|
+
label: provider.buttonLabel || 'paypal',
|
|
132
|
+
width: provider.buttonWidth || 250,
|
|
133
|
+
height: provider.buttonHeight || 35,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
if (style.layout === 'horizontal') {
|
|
137
|
+
style.tagline = provider.buttonTagline ?? true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const paypalOptions: PayPalButtonsOptions = {
|
|
141
|
+
env: useSandbox ? 'sandbox' : 'production',
|
|
142
|
+
style,
|
|
143
|
+
createOrder: (_data, actions) => {
|
|
144
|
+
services.removeError();
|
|
145
|
+
const amountResult = services.resolveAmount({
|
|
146
|
+
type: provider.amountType as string,
|
|
147
|
+
fixed: provider.amountFixed,
|
|
148
|
+
variable: provider.amountVariable as string,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
if (!amountResult.ok) {
|
|
152
|
+
const errorMessage = ('error' in amountResult) ? amountResult.error : 'Invalid PayPal amount.';
|
|
153
|
+
services.addError(errorMessage);
|
|
154
|
+
|
|
155
|
+
throw new Error(errorMessage);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return actions.order.create({
|
|
159
|
+
intent: 'AUTHORIZE',
|
|
160
|
+
application_context: { user_action: 'CONTINUE' },
|
|
161
|
+
purchase_units: [{
|
|
162
|
+
amount: {
|
|
163
|
+
currency_code: currency,
|
|
164
|
+
value: String(amountResult.value),
|
|
165
|
+
},
|
|
166
|
+
}],
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
onError: (err) => {
|
|
170
|
+
services.addError(err?.message || 'PayPal error.');
|
|
171
|
+
},
|
|
172
|
+
onApprove: async (data, actions) => {
|
|
173
|
+
try {
|
|
174
|
+
const authorization = await actions.order.authorize();
|
|
175
|
+
const authId = extractAuthIdFromAuthorization(authorization);
|
|
176
|
+
|
|
177
|
+
services.updateInputs('paypalOrderId', data.orderID);
|
|
178
|
+
services.updateInputs('paypalAuthId', authId || '');
|
|
179
|
+
|
|
180
|
+
if (authId) {
|
|
181
|
+
services.addSuccess('Payment authorized. Finalize the form to complete payment.');
|
|
182
|
+
} else {
|
|
183
|
+
// Allow submit to continue using order ID fallback on the backend.
|
|
184
|
+
services.addSuccess('PayPal approval received. Finalizing payment on submit.');
|
|
185
|
+
}
|
|
186
|
+
} catch {
|
|
187
|
+
services.addError('Unable to authorize payment. Please try again.');
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const buttons = api.Buttons(paypalOptions);
|
|
193
|
+
placeholder.setAttribute('data-formie-paypal-rendered', 'true');
|
|
194
|
+
const instance = buttons.render(placeholder);
|
|
195
|
+
|
|
196
|
+
return instance;
|
|
197
|
+
},
|
|
198
|
+
unmount: async (args) => {
|
|
199
|
+
if (args.widget?.close) {
|
|
200
|
+
args.widget.close();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const placeholder = args.field.querySelector<HTMLElement>('[data-formie-paypal-button]');
|
|
204
|
+
if (placeholder) {
|
|
205
|
+
placeholder.removeAttribute('data-formie-paypal-rendered');
|
|
206
|
+
placeholder.innerHTML = '';
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
onAfterSubmit: async ({ services }) => {
|
|
210
|
+
services.updateInputs(['paypalOrderId', 'paypalAuthId'], '');
|
|
211
|
+
services.removeSuccess();
|
|
212
|
+
services.removeError();
|
|
213
|
+
},
|
|
214
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import paywayCss from '#theme/integrations/_payway.css?inline';
|
|
2
|
+
|
|
3
|
+
import { definePaymentModule } from '#modules/payments/api';
|
|
4
|
+
import { ensureModuleStyles } from '#modules/styles';
|
|
5
|
+
import { loadScriptAndEnsureGlobal } from '#utils/scripts';
|
|
6
|
+
|
|
7
|
+
ensureModuleStyles('payway', [paywayCss]);
|
|
8
|
+
|
|
9
|
+
type PayWayFrame = {
|
|
10
|
+
getToken: (callback: (err: Error | null, data?: { singleUseTokenId: string }) => void) => void;
|
|
11
|
+
destroy: () => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type PayWayGlobal = {
|
|
15
|
+
createCreditCardFrame: (
|
|
16
|
+
opts: { layout: string; publishableApiKey: string; tokenMode: string },
|
|
17
|
+
callback: (err: Error | null, frame?: PayWayFrame) => void
|
|
18
|
+
) => void;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type PayWayProviderOptions = {
|
|
22
|
+
publishableKey?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const SCRIPT_ID = 'FORMIE_PAYWAY_SCRIPT';
|
|
26
|
+
|
|
27
|
+
export const paywayModule = definePaymentModule<PayWayProviderOptions, null, PayWayFrame | null>({
|
|
28
|
+
id: 'payway',
|
|
29
|
+
defaultRequiredInputSuffixes: ['paywayTokenId'],
|
|
30
|
+
load: async (ctx) => {
|
|
31
|
+
const { provider } = ctx.options;
|
|
32
|
+
const publishableKey = provider.publishableKey as string | undefined;
|
|
33
|
+
|
|
34
|
+
if (!publishableKey?.trim()) {
|
|
35
|
+
console.error('[formie] Missing publishableKey for PayWay.');
|
|
36
|
+
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
await loadScriptAndEnsureGlobal<PayWayGlobal>('payway', {
|
|
41
|
+
id: SCRIPT_ID,
|
|
42
|
+
src: 'https://api.payway.com.au/rest/v1/payway.js',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return null;
|
|
46
|
+
},
|
|
47
|
+
mount: async (args) => {
|
|
48
|
+
const { field, services, options } = args;
|
|
49
|
+
const provider = options.provider as PayWayProviderOptions;
|
|
50
|
+
const placeholder = field.querySelector<HTMLElement>('[data-formie-payway-button]');
|
|
51
|
+
|
|
52
|
+
if (!placeholder) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const payway = (window as unknown as { payway: PayWayGlobal }).payway;
|
|
57
|
+
|
|
58
|
+
if (!payway) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return new Promise<PayWayFrame | null>((resolve) => {
|
|
63
|
+
payway.createCreditCardFrame({
|
|
64
|
+
layout: 'wide',
|
|
65
|
+
publishableApiKey: provider.publishableKey || '',
|
|
66
|
+
tokenMode: 'callback',
|
|
67
|
+
}, (err, frame) => {
|
|
68
|
+
if (err || !frame) {
|
|
69
|
+
services.addError(err?.message || 'PayWay frame failed to load.');
|
|
70
|
+
resolve(null);
|
|
71
|
+
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
resolve(frame);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
unmount: async (args) => {
|
|
80
|
+
args.widget?.destroy();
|
|
81
|
+
},
|
|
82
|
+
onBeforeAuthorize: async (args) => {
|
|
83
|
+
const { widget, services } = args;
|
|
84
|
+
|
|
85
|
+
if (!widget) {
|
|
86
|
+
services.addError('PayWay card frame is not ready.');
|
|
87
|
+
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return new Promise<boolean>((resolve) => {
|
|
92
|
+
widget.getToken((err, data) => {
|
|
93
|
+
if (err) {
|
|
94
|
+
services.addError(err.message);
|
|
95
|
+
resolve(false);
|
|
96
|
+
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (data?.singleUseTokenId) {
|
|
101
|
+
services.updateInputs('paywayTokenId', data.singleUseTokenId);
|
|
102
|
+
|
|
103
|
+
resolve(true);
|
|
104
|
+
} else {
|
|
105
|
+
services.addError('Tokenization failed.');
|
|
106
|
+
resolve(false);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
onAfterSubmit: async ({ services }) => {
|
|
112
|
+
services.updateInputs('paywayTokenId', '');
|
|
113
|
+
},
|
|
114
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { definePaymentModule } from '#modules/payments/api';
|
|
2
|
+
import { loadScriptAndEnsureGlobal } from '#utils/scripts';
|
|
3
|
+
|
|
4
|
+
type SquareCard = {
|
|
5
|
+
tokenize: () => Promise<{ status: string; token?: string; errors?: Array<{ message: string }> }>;
|
|
6
|
+
attach: (element: HTMLElement) => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type SquarePayments = {
|
|
10
|
+
card: () => Promise<SquareCard>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type SquareGlobal = {
|
|
14
|
+
payments: (applicationId: string, locationId: string) => SquarePayments;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type SquareProviderOptions = {
|
|
18
|
+
applicationId?: string;
|
|
19
|
+
locationId?: string;
|
|
20
|
+
environment?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const SCRIPT_ID = 'FORMIE_SQUARE_SCRIPT';
|
|
24
|
+
|
|
25
|
+
export const squareModule = definePaymentModule<SquareProviderOptions, SquareGlobal | null, SquareCard | null>({
|
|
26
|
+
id: 'square',
|
|
27
|
+
defaultRequiredInputSuffixes: ['squarePaymentId'],
|
|
28
|
+
load: async(ctx) => {
|
|
29
|
+
const { provider } = ctx.options;
|
|
30
|
+
const applicationId = provider.applicationId as string | undefined;
|
|
31
|
+
const locationId = provider.locationId as string | undefined;
|
|
32
|
+
|
|
33
|
+
if (!applicationId?.trim() || !locationId?.trim()) {
|
|
34
|
+
console.error('[formie] Missing applicationId or locationId for Square.');
|
|
35
|
+
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const environment = provider.environment as string;
|
|
40
|
+
const src = environment === 'sandbox'
|
|
41
|
+
? 'https://sandbox.web.squarecdn.com/v1/square.js'
|
|
42
|
+
: 'https://web.squarecdn.com/v1/square.js';
|
|
43
|
+
|
|
44
|
+
await loadScriptAndEnsureGlobal<SquareGlobal>('Square', {
|
|
45
|
+
id: SCRIPT_ID,
|
|
46
|
+
src,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return (window as unknown as { Square: SquareGlobal }).Square;
|
|
50
|
+
},
|
|
51
|
+
mount: async(args) => {
|
|
52
|
+
const { api, field, services, options } = args;
|
|
53
|
+
const provider = options.provider as SquareProviderOptions;
|
|
54
|
+
const placeholder = field.querySelector<HTMLElement>('[data-formie-square-button]');
|
|
55
|
+
|
|
56
|
+
if (!placeholder || !api) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
const payments = api.payments(provider.applicationId || '', provider.locationId || '');
|
|
62
|
+
const card = await payments.card();
|
|
63
|
+
|
|
64
|
+
await card.attach(placeholder);
|
|
65
|
+
|
|
66
|
+
return card;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
services.addError(error instanceof Error ? error.message : 'Unable to initialize payment.');
|
|
69
|
+
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
unmount: async() => {
|
|
74
|
+
// Square card doesn't expose destroy, detach handled by removing element
|
|
75
|
+
},
|
|
76
|
+
onBeforeAuthorize: async(args) => {
|
|
77
|
+
const { widget, services } = args;
|
|
78
|
+
|
|
79
|
+
if (!widget) {
|
|
80
|
+
services.addError('Square card is not ready.');
|
|
81
|
+
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
const result = await widget.tokenize();
|
|
87
|
+
|
|
88
|
+
if (result.status === 'OK' && result.token) {
|
|
89
|
+
services.updateInputs('squarePaymentId', result.token);
|
|
90
|
+
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
services.addError(result.errors?.[0]?.message || 'Tokenization failed.');
|
|
95
|
+
|
|
96
|
+
return false;
|
|
97
|
+
} catch {
|
|
98
|
+
services.addError('Payment tokenization failed. Please try again.');
|
|
99
|
+
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
onAfterSubmit: async({ services }) => {
|
|
104
|
+
services.updateInputs('squarePaymentId', '');
|
|
105
|
+
},
|
|
106
|
+
});
|