@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,203 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FormieModuleDefinition,
|
|
3
|
+
FormieModuleInstance,
|
|
4
|
+
ModuleSetupContext,
|
|
5
|
+
} from '#contracts/modules';
|
|
6
|
+
import {
|
|
7
|
+
createAddressHostServices,
|
|
8
|
+
type AddressHostServices,
|
|
9
|
+
type NormalizedAddressModuleOptions,
|
|
10
|
+
normalizeAddressModuleOptions,
|
|
11
|
+
} from '#modules/address/host';
|
|
12
|
+
import { createDebug } from '#utils/debug';
|
|
13
|
+
|
|
14
|
+
type Cleanup = () => void;
|
|
15
|
+
const debug = createDebug('address');
|
|
16
|
+
|
|
17
|
+
function isTargetVisible(element: Element): boolean {
|
|
18
|
+
const node = element as HTMLElement;
|
|
19
|
+
|
|
20
|
+
return !node.closest('[data-formie-page-hidden]') && !node.closest('[hidden]');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type AddressModuleSetupContext<TProvider extends Record<string, unknown>> = Omit<ModuleSetupContext, 'options'> & {
|
|
24
|
+
options: NormalizedAddressModuleOptions<TProvider>;
|
|
25
|
+
services: AddressHostServices;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type ManagedAddressModuleAdapter<
|
|
29
|
+
TProvider extends Record<string, unknown>,
|
|
30
|
+
TApi,
|
|
31
|
+
TWidget,
|
|
32
|
+
> = {
|
|
33
|
+
id: string;
|
|
34
|
+
load: (ctx: AddressModuleSetupContext<TProvider>) => Promise<TApi>;
|
|
35
|
+
mount: (args: {
|
|
36
|
+
api: TApi;
|
|
37
|
+
field: Element;
|
|
38
|
+
services: AddressHostServices;
|
|
39
|
+
options: NormalizedAddressModuleOptions<TProvider>;
|
|
40
|
+
provider: TProvider;
|
|
41
|
+
}) => Promise<TWidget | null> | TWidget | null;
|
|
42
|
+
unmount?: (args: {
|
|
43
|
+
api: TApi;
|
|
44
|
+
widget: TWidget;
|
|
45
|
+
field: Element;
|
|
46
|
+
services: AddressHostServices;
|
|
47
|
+
options: NormalizedAddressModuleOptions<TProvider>;
|
|
48
|
+
provider: TProvider;
|
|
49
|
+
}) => Promise<void> | void;
|
|
50
|
+
onCurrentLocation?: (position: GeolocationPosition, args: {
|
|
51
|
+
api: TApi;
|
|
52
|
+
widget: TWidget;
|
|
53
|
+
field: Element;
|
|
54
|
+
services: AddressHostServices;
|
|
55
|
+
options: NormalizedAddressModuleOptions<TProvider>;
|
|
56
|
+
provider: TProvider;
|
|
57
|
+
}) => void | Promise<void>;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export function createManagedAddressModule<
|
|
61
|
+
TProvider extends Record<string, unknown>,
|
|
62
|
+
TApi,
|
|
63
|
+
TWidget,
|
|
64
|
+
>(adapter: ManagedAddressModuleAdapter<TProvider, TApi, TWidget>): FormieModuleDefinition {
|
|
65
|
+
return {
|
|
66
|
+
id: adapter.id,
|
|
67
|
+
kind: 'address',
|
|
68
|
+
match: (ctx) => {
|
|
69
|
+
const input = ctx.target.querySelector('[data-formie-address-autocomplete-input]');
|
|
70
|
+
|
|
71
|
+
return !!input;
|
|
72
|
+
},
|
|
73
|
+
setup: async (ctx) => {
|
|
74
|
+
const options = normalizeAddressModuleOptions<TProvider>(adapter.id, ctx.options || {});
|
|
75
|
+
const services = createAddressHostServices(ctx);
|
|
76
|
+
debug.log('Setup module.', {
|
|
77
|
+
moduleId: adapter.id,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const setupCtx: AddressModuleSetupContext<TProvider> = {
|
|
81
|
+
...ctx,
|
|
82
|
+
options,
|
|
83
|
+
services,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const cleanups: Cleanup[] = [];
|
|
87
|
+
let apiPromise: Promise<TApi> | null = null;
|
|
88
|
+
let widget: TWidget | null = null;
|
|
89
|
+
const input = services.input.getAutocomplete();
|
|
90
|
+
|
|
91
|
+
if (!input) {
|
|
92
|
+
console.warn(
|
|
93
|
+
`[formie] Address module "${adapter.id}" skipped: no autocomplete input found in target. ` +
|
|
94
|
+
'Ensure the Address field has the Auto-Complete subfield enabled.',
|
|
95
|
+
);
|
|
96
|
+
debug.warn('Autocomplete input missing; skipping module.', {
|
|
97
|
+
moduleId: adapter.id,
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
destroy: () => { },
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const getApi = async(): Promise<TApi> => {
|
|
105
|
+
if (!apiPromise) {
|
|
106
|
+
debug.log('Loading provider API.', {
|
|
107
|
+
moduleId: adapter.id,
|
|
108
|
+
});
|
|
109
|
+
apiPromise = adapter.load(setupCtx);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return apiPromise;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const ensureMounted = async() => {
|
|
116
|
+
if (widget || !isTargetVisible(ctx.target)) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const api = await getApi();
|
|
121
|
+
widget = await adapter.mount({
|
|
122
|
+
api,
|
|
123
|
+
field: ctx.target,
|
|
124
|
+
services,
|
|
125
|
+
options,
|
|
126
|
+
provider: options.provider,
|
|
127
|
+
});
|
|
128
|
+
debug.log('Widget mounted.', {
|
|
129
|
+
moduleId: adapter.id,
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
if (isTargetVisible(ctx.target)) {
|
|
134
|
+
await ensureMounted();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const visibilityEvents = ['formie:page:navigate:after', 'formie:submit:result'];
|
|
138
|
+
visibilityEvents.forEach((eventName) => {
|
|
139
|
+
const handleVisibility = () => {
|
|
140
|
+
void ensureMounted();
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
ctx.root.addEventListener(eventName, handleVisibility as EventListener);
|
|
144
|
+
cleanups.push(() => {
|
|
145
|
+
ctx.root.removeEventListener(eventName, handleVisibility as EventListener);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const locationCleanup = services.location.onUseLocation((position) => {
|
|
150
|
+
if (!adapter.onCurrentLocation) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
void (async() => {
|
|
155
|
+
await ensureMounted();
|
|
156
|
+
|
|
157
|
+
if (!widget) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const api = await getApi();
|
|
162
|
+
|
|
163
|
+
await adapter.onCurrentLocation?.(position, {
|
|
164
|
+
api,
|
|
165
|
+
widget,
|
|
166
|
+
field: ctx.target,
|
|
167
|
+
services,
|
|
168
|
+
options,
|
|
169
|
+
provider: options.provider,
|
|
170
|
+
});
|
|
171
|
+
})();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
if (locationCleanup) {
|
|
175
|
+
cleanups.push(locationCleanup);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
destroy: async () => {
|
|
180
|
+
debug.log('Destroying module.', {
|
|
181
|
+
moduleId: adapter.id,
|
|
182
|
+
});
|
|
183
|
+
cleanups.forEach((c) => c());
|
|
184
|
+
|
|
185
|
+
if (widget && adapter.unmount) {
|
|
186
|
+
const api = await getApi();
|
|
187
|
+
await adapter.unmount({
|
|
188
|
+
api,
|
|
189
|
+
widget,
|
|
190
|
+
field: ctx.target,
|
|
191
|
+
services,
|
|
192
|
+
options,
|
|
193
|
+
provider: options.provider,
|
|
194
|
+
});
|
|
195
|
+
debug.log('Widget unmounted.', {
|
|
196
|
+
moduleId: adapter.id,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { defineAddressModule } from '#modules/address/api';
|
|
2
|
+
import type { AddressHostServices } from '#modules/address/host';
|
|
3
|
+
import { getAddressProviderEventName } from '#utils/event-names';
|
|
4
|
+
import { ensureGlobal, loadExternalScript } from '#utils/scripts';
|
|
5
|
+
|
|
6
|
+
type GoogleMaps = typeof google;
|
|
7
|
+
|
|
8
|
+
type GoogleAddressProviderOptions = {
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
options?: Record<string, unknown>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const SCRIPT_ID = 'FORMIE_GOOGLE_ADDRESS_SCRIPT';
|
|
14
|
+
const CALLBACK_NAME = 'formieGoogleMapsReady';
|
|
15
|
+
|
|
16
|
+
let loadPromise: Promise<GoogleMaps> | null = null;
|
|
17
|
+
|
|
18
|
+
/** Load Google Maps with callback; required when using loading=async. */
|
|
19
|
+
async function loadGoogleMapsScript(apiKey: string): Promise<GoogleMaps> {
|
|
20
|
+
const w = window as unknown as Record<string, unknown>;
|
|
21
|
+
const existing = w.google;
|
|
22
|
+
|
|
23
|
+
if (typeof existing !== 'undefined' && existing !== null) {
|
|
24
|
+
const maps = (existing as GoogleMaps).maps;
|
|
25
|
+
if (maps?.places?.PlaceAutocompleteElement) {
|
|
26
|
+
return existing as GoogleMaps;
|
|
27
|
+
}
|
|
28
|
+
const imp = maps as { importLibrary?: (name: string) => Promise<unknown> } | undefined;
|
|
29
|
+
if (typeof imp?.importLibrary === 'function') {
|
|
30
|
+
await imp.importLibrary('places');
|
|
31
|
+
}
|
|
32
|
+
return existing as GoogleMaps;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (loadPromise) {
|
|
36
|
+
return loadPromise;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const existingScript = document.getElementById(SCRIPT_ID);
|
|
40
|
+
if (existingScript) {
|
|
41
|
+
const google = await ensureGlobal<GoogleMaps>('google', 10000);
|
|
42
|
+
const maps = google?.maps as { importLibrary?: (name: string) => Promise<unknown> } | undefined;
|
|
43
|
+
if (typeof maps?.importLibrary === 'function') {
|
|
44
|
+
await maps.importLibrary('places');
|
|
45
|
+
}
|
|
46
|
+
return google;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const url = new URL('https://maps.googleapis.com/maps/api/js');
|
|
50
|
+
url.searchParams.set('key', apiKey);
|
|
51
|
+
url.searchParams.set('loading', 'async');
|
|
52
|
+
url.searchParams.set('libraries', 'places');
|
|
53
|
+
url.searchParams.set('callback', CALLBACK_NAME);
|
|
54
|
+
|
|
55
|
+
loadPromise = (async () => {
|
|
56
|
+
const ready = new Promise<GoogleMaps>((resolve, reject) => {
|
|
57
|
+
const t = setTimeout(() => {
|
|
58
|
+
if (w[CALLBACK_NAME]) {
|
|
59
|
+
delete w[CALLBACK_NAME];
|
|
60
|
+
reject(new Error('Google Maps API load timeout'));
|
|
61
|
+
}
|
|
62
|
+
}, 15000);
|
|
63
|
+
w[CALLBACK_NAME] = () => {
|
|
64
|
+
clearTimeout(t);
|
|
65
|
+
delete w[CALLBACK_NAME];
|
|
66
|
+
resolve(w.google as GoogleMaps);
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
await loadExternalScript({
|
|
71
|
+
id: SCRIPT_ID,
|
|
72
|
+
src: url.toString(),
|
|
73
|
+
async: true,
|
|
74
|
+
defer: true,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const google = await ready;
|
|
78
|
+
const maps = google?.maps as { importLibrary?: (name: string) => Promise<unknown> } | undefined;
|
|
79
|
+
if (typeof maps?.importLibrary === 'function') {
|
|
80
|
+
await maps.importLibrary('places');
|
|
81
|
+
}
|
|
82
|
+
return google;
|
|
83
|
+
})();
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
return await loadPromise;
|
|
87
|
+
} catch (e) {
|
|
88
|
+
loadPromise = null;
|
|
89
|
+
throw e;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function setFieldValues(
|
|
94
|
+
services: AddressHostServices,
|
|
95
|
+
data: {
|
|
96
|
+
address1?: string;
|
|
97
|
+
city?: string;
|
|
98
|
+
state?: string;
|
|
99
|
+
zip?: string;
|
|
100
|
+
country?: string;
|
|
101
|
+
formattedAddress?: string;
|
|
102
|
+
},
|
|
103
|
+
): void {
|
|
104
|
+
if (data.formattedAddress) {
|
|
105
|
+
services.input.setValue('autoComplete', data.formattedAddress);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (data.address1) {
|
|
109
|
+
services.input.setValue('address1', data.address1);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (data.city !== undefined) {
|
|
113
|
+
services.input.setValue('city', data.city);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (data.state !== undefined) {
|
|
117
|
+
services.input.setValue('state', data.state);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (data.zip !== undefined) {
|
|
121
|
+
services.input.setValue('zip', data.zip);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (data.country !== undefined) {
|
|
125
|
+
services.input.setValue('country', data.country);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function componentMap(): Record<string, 'shortText' | 'longText'> {
|
|
130
|
+
return {
|
|
131
|
+
subpremise: 'shortText',
|
|
132
|
+
street_number: 'shortText',
|
|
133
|
+
route: 'longText',
|
|
134
|
+
postal_town: 'longText',
|
|
135
|
+
locality: 'longText',
|
|
136
|
+
administrative_area_level_1: 'shortText',
|
|
137
|
+
country: 'shortText',
|
|
138
|
+
postal_code: 'shortText',
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
type AddressComponent = {
|
|
143
|
+
types: string[];
|
|
144
|
+
shortText?: string;
|
|
145
|
+
longText?: string;
|
|
146
|
+
short_text?: string;
|
|
147
|
+
long_text?: string;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
function parseAddressComponents(components: AddressComponent[]): Record<string, string> {
|
|
151
|
+
const map = componentMap();
|
|
152
|
+
const out: Record<string, string> = {};
|
|
153
|
+
|
|
154
|
+
for (const comp of components) {
|
|
155
|
+
const type = comp.types?.[0];
|
|
156
|
+
|
|
157
|
+
if (!type || !map[type as keyof typeof map]) continue;
|
|
158
|
+
|
|
159
|
+
const fieldKey = map[type as keyof typeof map];
|
|
160
|
+
const val = (comp as unknown as Record<string, string>)[fieldKey]
|
|
161
|
+
?? comp.short_text
|
|
162
|
+
?? comp.long_text
|
|
163
|
+
?? '';
|
|
164
|
+
|
|
165
|
+
out[type] = val;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function buildAddressFromComponents(formData: Record<string, string>): {
|
|
172
|
+
address1: string;
|
|
173
|
+
city: string;
|
|
174
|
+
state: string;
|
|
175
|
+
zip: string;
|
|
176
|
+
country: string;
|
|
177
|
+
} {
|
|
178
|
+
let address1 = '';
|
|
179
|
+
|
|
180
|
+
if (formData.street_number || formData.route) {
|
|
181
|
+
address1 = [formData.street_number, formData.route].filter(Boolean).join(' ');
|
|
182
|
+
|
|
183
|
+
if (formData.subpremise) {
|
|
184
|
+
address1 = `${formData.subpremise}/${address1}`;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
address1,
|
|
190
|
+
city: formData.locality || formData.postal_town || '',
|
|
191
|
+
state: formData.administrative_area_level_1 || '',
|
|
192
|
+
zip: formData.postal_code || '',
|
|
193
|
+
country: formData.country || '',
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export const googleAddressModule = defineAddressModule<
|
|
198
|
+
GoogleAddressProviderOptions,
|
|
199
|
+
GoogleMaps,
|
|
200
|
+
google.maps.places.PlaceAutocompleteElement
|
|
201
|
+
>({
|
|
202
|
+
id: 'google-address',
|
|
203
|
+
load: async ({ options }) => {
|
|
204
|
+
const apiKey = options.provider.apiKey;
|
|
205
|
+
|
|
206
|
+
if (!apiKey) {
|
|
207
|
+
throw new Error('Google Places API key is required');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return loadGoogleMapsScript(apiKey);
|
|
211
|
+
},
|
|
212
|
+
mount: async ({ api, field, services, provider }) => {
|
|
213
|
+
const input = services.input.getAutocomplete();
|
|
214
|
+
const PlaceAutocompleteElement = api?.maps?.places?.PlaceAutocompleteElement;
|
|
215
|
+
|
|
216
|
+
if (!input || typeof PlaceAutocompleteElement !== 'function') {
|
|
217
|
+
console.warn('[formie] Google Places API not ready; address autocomplete skipped.');
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const options = { types: ['geocode'], ...(provider.options || {}) };
|
|
222
|
+
const autocomplete = new PlaceAutocompleteElement(options);
|
|
223
|
+
const inputHeight = window.getComputedStyle(input).height;
|
|
224
|
+
|
|
225
|
+
autocomplete.style.height = inputHeight;
|
|
226
|
+
autocomplete.style.boxSizing = 'border-box';
|
|
227
|
+
|
|
228
|
+
let wrapper = input.parentElement;
|
|
229
|
+
|
|
230
|
+
if (!wrapper?.classList.contains('formie-autocomplete-wrapper')) {
|
|
231
|
+
wrapper = document.createElement('div');
|
|
232
|
+
wrapper.classList.add('formie-autocomplete-wrapper');
|
|
233
|
+
input.parentNode?.insertBefore(wrapper, input);
|
|
234
|
+
wrapper.appendChild(input);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const savedValue = input.value;
|
|
238
|
+
|
|
239
|
+
if (savedValue) {
|
|
240
|
+
const overlay = document.createElement('div');
|
|
241
|
+
overlay.classList.add('formie-autocomplete-placeholder');
|
|
242
|
+
overlay.textContent = savedValue;
|
|
243
|
+
|
|
244
|
+
(wrapper as HTMLElement).style.position = 'relative';
|
|
245
|
+
overlay.style.cssText = `
|
|
246
|
+
position: absolute; left: 0; top: 0; height: ${inputHeight};
|
|
247
|
+
line-height: ${inputHeight}; width: 100%; padding: 0 2.5rem;
|
|
248
|
+
pointer-events: none; color: #6B7280; font-size: 14px; z-index: 1;
|
|
249
|
+
`;
|
|
250
|
+
|
|
251
|
+
wrapper.appendChild(overlay);
|
|
252
|
+
|
|
253
|
+
autocomplete.addEventListener('focusin', () => {
|
|
254
|
+
overlay.style.display = 'none';
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
autocomplete.addEventListener('focusout', () => {
|
|
258
|
+
if ((input as HTMLInputElement).value) {
|
|
259
|
+
overlay.style.display = '';
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
wrapper.replaceChild(autocomplete, input);
|
|
265
|
+
input.type = 'hidden';
|
|
266
|
+
input.name = (input as HTMLInputElement).getAttribute('name') || '';
|
|
267
|
+
wrapper.appendChild(input);
|
|
268
|
+
|
|
269
|
+
const onSelect = async (ev: Event): Promise<void> => {
|
|
270
|
+
const e = ev as unknown as { placePrediction?: { toPlace: () => Promise<{ addressComponents?: unknown[]; formattedAddress?: string; fetchFields: (opts: { fields: string[] }) => Promise<void> }> } };
|
|
271
|
+
const pred = e.placePrediction;
|
|
272
|
+
|
|
273
|
+
if (!pred) return;
|
|
274
|
+
|
|
275
|
+
const place = await pred.toPlace();
|
|
276
|
+
await place.fetchFields({ fields: ['addressComponents', 'formattedAddress'] });
|
|
277
|
+
|
|
278
|
+
if (!place.addressComponents) return;
|
|
279
|
+
|
|
280
|
+
const formData = parseAddressComponents(
|
|
281
|
+
place.addressComponents as AddressComponent[],
|
|
282
|
+
);
|
|
283
|
+
const address = buildAddressFromComponents(formData);
|
|
284
|
+
|
|
285
|
+
setFieldValues(services, {
|
|
286
|
+
...address,
|
|
287
|
+
formattedAddress: place.formattedAddress,
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
field.dispatchEvent(
|
|
291
|
+
new CustomEvent(getAddressProviderEventName('google', 'populate'), {
|
|
292
|
+
bubbles: true,
|
|
293
|
+
detail: {
|
|
294
|
+
addressProvider: 'google',
|
|
295
|
+
place,
|
|
296
|
+
formattedAddress: place.formattedAddress,
|
|
297
|
+
addressComponents: place.addressComponents,
|
|
298
|
+
},
|
|
299
|
+
}),
|
|
300
|
+
);
|
|
301
|
+
};
|
|
302
|
+
autocomplete.addEventListener('gmp-select', onSelect as EventListener);
|
|
303
|
+
|
|
304
|
+
return autocomplete;
|
|
305
|
+
},
|
|
306
|
+
onCurrentLocation: async (position, { field, services }) => {
|
|
307
|
+
const { latitude, longitude } = position.coords;
|
|
308
|
+
const form = services.form;
|
|
309
|
+
const actionUrl = form?.action || window.location.href;
|
|
310
|
+
const fieldHandle = field.getAttribute('data-formie-field-handle')?.trim();
|
|
311
|
+
const formHandle = (form?.querySelector('[name="handle"]') as HTMLInputElement | null)?.value?.trim();
|
|
312
|
+
|
|
313
|
+
if (!formHandle || !fieldHandle) return;
|
|
314
|
+
|
|
315
|
+
try {
|
|
316
|
+
const formData = new FormData();
|
|
317
|
+
formData.append('action', 'formie/address/google-places-geocode');
|
|
318
|
+
formData.append('latlng', `${latitude},${longitude}`);
|
|
319
|
+
formData.append('handle', formHandle);
|
|
320
|
+
formData.append('fieldHandle', fieldHandle);
|
|
321
|
+
|
|
322
|
+
const response = await fetch(actionUrl, {
|
|
323
|
+
method: 'POST',
|
|
324
|
+
body: formData,
|
|
325
|
+
credentials: 'include',
|
|
326
|
+
headers: {
|
|
327
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
328
|
+
Accept: 'application/json',
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
const data = await response.json();
|
|
333
|
+
|
|
334
|
+
if (data?.results?.[0]?.address_components) {
|
|
335
|
+
const formDataParsed = parseAddressComponents(
|
|
336
|
+
data.results[0].address_components as AddressComponent[],
|
|
337
|
+
);
|
|
338
|
+
const address = buildAddressFromComponents(formDataParsed);
|
|
339
|
+
setFieldValues(services, address);
|
|
340
|
+
}
|
|
341
|
+
} catch {
|
|
342
|
+
// Silently fail geocode
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
});
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { ModuleSetupContext } from '#contracts/modules';
|
|
2
|
+
import {
|
|
3
|
+
ADDRESS_LOCATION_SELECTOR,
|
|
4
|
+
ADDRESS_SELECTORS,
|
|
5
|
+
DEFAULT_AUTOCOMPLETE_SELECTOR,
|
|
6
|
+
} from '#modules/address/constants';
|
|
7
|
+
|
|
8
|
+
type Cleanup = () => void;
|
|
9
|
+
|
|
10
|
+
export type AddressModuleOptions<TProvider extends Record<string, unknown> = Record<string, unknown>> = {
|
|
11
|
+
handle?: string;
|
|
12
|
+
} & TProvider;
|
|
13
|
+
|
|
14
|
+
export type NormalizedAddressModuleOptions<TProvider extends Record<string, unknown>> = {
|
|
15
|
+
handle: string;
|
|
16
|
+
provider: TProvider;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const ADDRESS_OPTION_KEYS = new Set(['handle']);
|
|
20
|
+
|
|
21
|
+
export type AddressHostServices = {
|
|
22
|
+
root: Element;
|
|
23
|
+
field: Element;
|
|
24
|
+
form: HTMLFormElement | null;
|
|
25
|
+
input: {
|
|
26
|
+
getAutocomplete: () => HTMLInputElement | null;
|
|
27
|
+
setValue: (selector: keyof typeof ADDRESS_SELECTORS, value: string, fallback?: string) => void;
|
|
28
|
+
};
|
|
29
|
+
location: {
|
|
30
|
+
getButton: () => HTMLElement | null;
|
|
31
|
+
onUseLocation: (callback: (position: GeolocationPosition) => void) => Cleanup;
|
|
32
|
+
};
|
|
33
|
+
events: {
|
|
34
|
+
onField: (eventName: string, callback: EventListener) => Cleanup;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function getAddressProviderHandle(id: string, options: Record<string, unknown>): string {
|
|
39
|
+
const handle = typeof options.handle === 'string' && options.handle.trim() !== ''
|
|
40
|
+
? options.handle.trim()
|
|
41
|
+
: '';
|
|
42
|
+
|
|
43
|
+
return handle || id;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function normalizeAddressModuleOptions<TProvider extends Record<string, unknown>>(
|
|
47
|
+
id: string,
|
|
48
|
+
rawOptions: Record<string, unknown> | undefined,
|
|
49
|
+
): NormalizedAddressModuleOptions<TProvider> {
|
|
50
|
+
const options = rawOptions || {};
|
|
51
|
+
const provider = Object.entries(options).reduce((carry, [key, value]) => {
|
|
52
|
+
if (ADDRESS_OPTION_KEYS.has(key)) {
|
|
53
|
+
return carry;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
carry[key] = value;
|
|
57
|
+
|
|
58
|
+
return carry;
|
|
59
|
+
}, {} as Record<string, unknown>) as TProvider;
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
handle: getAddressProviderHandle(id, options),
|
|
63
|
+
provider,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function bindDomEvent(target: EventTarget, eventName: string, callback: EventListener): Cleanup {
|
|
68
|
+
target.addEventListener(eventName, callback);
|
|
69
|
+
|
|
70
|
+
return () => {
|
|
71
|
+
target.removeEventListener(eventName, callback);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function createAddressHostServices(
|
|
76
|
+
ctx: ModuleSetupContext,
|
|
77
|
+
): AddressHostServices {
|
|
78
|
+
const field = ctx.target;
|
|
79
|
+
const form = ctx.form;
|
|
80
|
+
const root = ctx.root;
|
|
81
|
+
|
|
82
|
+
const autocompleteSelector = DEFAULT_AUTOCOMPLETE_SELECTOR;
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
root,
|
|
86
|
+
field,
|
|
87
|
+
form,
|
|
88
|
+
input: {
|
|
89
|
+
getAutocomplete: () => {
|
|
90
|
+
return field.querySelector(autocompleteSelector) as HTMLInputElement | null;
|
|
91
|
+
},
|
|
92
|
+
setValue: (selectorKey, value, fallback) => {
|
|
93
|
+
const selector = ADDRESS_SELECTORS[selectorKey];
|
|
94
|
+
const el = field.querySelector(selector) as HTMLInputElement | null;
|
|
95
|
+
|
|
96
|
+
if (el) {
|
|
97
|
+
el.value = value || fallback || '';
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
location: {
|
|
102
|
+
getButton: () => {
|
|
103
|
+
return field.querySelector(ADDRESS_LOCATION_SELECTOR) as HTMLElement | null;
|
|
104
|
+
},
|
|
105
|
+
onUseLocation: (callback) => {
|
|
106
|
+
const btn = field.querySelector(ADDRESS_LOCATION_SELECTOR);
|
|
107
|
+
|
|
108
|
+
if (!btn) {
|
|
109
|
+
return () => {};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const handler = (e: Event) => {
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
|
|
115
|
+
if (!navigator.geolocation) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
navigator.geolocation.getCurrentPosition(
|
|
120
|
+
callback,
|
|
121
|
+
() => {},
|
|
122
|
+
{ enableHighAccuracy: true },
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
btn.addEventListener('click', handler);
|
|
127
|
+
|
|
128
|
+
return () => {
|
|
129
|
+
btn.removeEventListener('click', handler);
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
events: {
|
|
134
|
+
onField: (eventName, callback) => bindDomEvent(field, eventName, callback),
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FormieModuleDefinition } from '#contracts/modules';
|
|
2
|
+
|
|
3
|
+
export const builtinAddressModuleLoaders: Record<string, () => Promise<FormieModuleDefinition>> = {
|
|
4
|
+
// Address providers stay behind lazy importer entries because their SDKs are
|
|
5
|
+
// optional and often much heavier than the base form client.
|
|
6
|
+
'address-finder': () => import('#modules/address/address-finder').then((m) => m.addressFinderModule),
|
|
7
|
+
'google-address': () => import('#modules/address/google-address').then((m) => m.googleAddressModule),
|
|
8
|
+
'loqate': () => import('#modules/address/loqate').then((m) => m.loqateModule),
|
|
9
|
+
'place-kit': () => import('#modules/address/place-kit').then((m) => m.placeKitModule),
|
|
10
|
+
};
|