@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,121 @@
|
|
|
1
|
+
import type { FieldReferenceTransform, ParsedFieldReference } from '#utils/field-references.types';
|
|
2
|
+
import { normalizeFieldKey } from '#utils/field-references.keys';
|
|
3
|
+
|
|
4
|
+
function parseTransforms(body: string): { source: string; transforms: FieldReferenceTransform[] } {
|
|
5
|
+
const parts = body.split(';').map((part) => {
|
|
6
|
+
return part.trim();
|
|
7
|
+
}).filter(Boolean);
|
|
8
|
+
|
|
9
|
+
if (!parts.length) {
|
|
10
|
+
return {
|
|
11
|
+
source: '',
|
|
12
|
+
transforms: [],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const [source, ...metadata] = parts;
|
|
17
|
+
const transforms: FieldReferenceTransform[] = [];
|
|
18
|
+
let current: FieldReferenceTransform | null = null;
|
|
19
|
+
|
|
20
|
+
metadata.forEach((entry) => {
|
|
21
|
+
if (entry.startsWith('transform=')) {
|
|
22
|
+
if (current) {
|
|
23
|
+
transforms.push(current);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
current = {
|
|
27
|
+
id: decodeURIComponent(entry.slice('transform='.length) || '').trim(),
|
|
28
|
+
params: {},
|
|
29
|
+
};
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!current || !entry.includes('=')) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const [rawKey, rawValue] = entry.split('=', 2);
|
|
38
|
+
const key = (rawKey || '').trim();
|
|
39
|
+
|
|
40
|
+
if (!key || key === 'transform') {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
current.params[key] = decodeURIComponent(rawValue || '').trim();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (current) {
|
|
48
|
+
transforms.push(current);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
source: source || '',
|
|
53
|
+
transforms,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function parseFieldReference(rawValue: string): ParsedFieldReference {
|
|
58
|
+
const raw = String(rawValue || '').trim();
|
|
59
|
+
|
|
60
|
+
if (!raw) {
|
|
61
|
+
return {
|
|
62
|
+
raw,
|
|
63
|
+
target: '',
|
|
64
|
+
key: '',
|
|
65
|
+
selector: '',
|
|
66
|
+
defaultValue: '',
|
|
67
|
+
transforms: [],
|
|
68
|
+
isToken: false,
|
|
69
|
+
isValid: false,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const tokenMatch = raw.match(/^\{([a-zA-Z]+)(?::(.*))?\}$/);
|
|
74
|
+
|
|
75
|
+
if (!tokenMatch) {
|
|
76
|
+
return {
|
|
77
|
+
raw,
|
|
78
|
+
target: '',
|
|
79
|
+
key: normalizeFieldKey(raw),
|
|
80
|
+
selector: '',
|
|
81
|
+
defaultValue: '',
|
|
82
|
+
transforms: [],
|
|
83
|
+
isToken: false,
|
|
84
|
+
isValid: true,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const targetRaw = (tokenMatch[1] || '').trim().toLowerCase();
|
|
89
|
+
const bodyRaw = (tokenMatch[2] || '').trim();
|
|
90
|
+
const [beforeDefault, defaultRaw = ''] = bodyRaw.split('|', 2);
|
|
91
|
+
const { source, transforms } = parseTransforms(beforeDefault || '');
|
|
92
|
+
|
|
93
|
+
if (targetRaw !== 'field') {
|
|
94
|
+
return {
|
|
95
|
+
raw,
|
|
96
|
+
target: '',
|
|
97
|
+
key: '',
|
|
98
|
+
selector: '',
|
|
99
|
+
defaultValue: defaultRaw.trim(),
|
|
100
|
+
transforms,
|
|
101
|
+
isToken: true,
|
|
102
|
+
isValid: false,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const separatorIndex = source.indexOf(':');
|
|
107
|
+
const keyRaw = separatorIndex === -1 ? source : source.slice(0, separatorIndex);
|
|
108
|
+
const selectorRaw = separatorIndex === -1 ? '' : source.slice(separatorIndex + 1);
|
|
109
|
+
const key = normalizeFieldKey(keyRaw);
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
raw,
|
|
113
|
+
target: 'field',
|
|
114
|
+
key,
|
|
115
|
+
selector: selectorRaw.trim(),
|
|
116
|
+
defaultValue: defaultRaw.trim(),
|
|
117
|
+
transforms,
|
|
118
|
+
isToken: true,
|
|
119
|
+
isValid: key !== '',
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { inputNameToFieldKey } from '#utils/field-references.keys';
|
|
2
|
+
import type { FieldValueInput, FieldValueRegistry, FieldValueRegistryEntry } from '#utils/field-references.types';
|
|
3
|
+
|
|
4
|
+
function isFieldValueInput(node: Element): node is FieldValueInput {
|
|
5
|
+
return node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement || node instanceof HTMLSelectElement;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function addInputEntry(registry: FieldValueRegistry, key: string, input: FieldValueInput): void {
|
|
9
|
+
const normalizedKey = key.trim();
|
|
10
|
+
const name = String(input.name || '').trim();
|
|
11
|
+
|
|
12
|
+
if (!normalizedKey || !name) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const entry = registry.get(normalizedKey) || {
|
|
17
|
+
key: normalizedKey,
|
|
18
|
+
names: [],
|
|
19
|
+
inputs: [],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
if (!entry.names.includes(name)) {
|
|
23
|
+
entry.names.push(name);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!entry.inputs.includes(input)) {
|
|
27
|
+
entry.inputs.push(input);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
registry.set(normalizedKey, entry);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function buildFieldValueRegistry(root: ParentNode): FieldValueRegistry {
|
|
34
|
+
const registry: FieldValueRegistry = new Map<string, FieldValueRegistryEntry>();
|
|
35
|
+
const inputs = Array.from(root.querySelectorAll('[name]')).filter((node): node is FieldValueInput => {
|
|
36
|
+
return isFieldValueInput(node);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
inputs.forEach((input) => {
|
|
40
|
+
const key = inputNameToFieldKey(input.name);
|
|
41
|
+
|
|
42
|
+
if (!key) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
addInputEntry(registry, key, input);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return registry;
|
|
50
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { fieldKeyToInputName, normalizeFieldKey } from '#utils/field-references.keys';
|
|
2
|
+
import { parseFieldReference } from '#utils/field-references.parser';
|
|
3
|
+
import type {
|
|
4
|
+
FieldValueInput,
|
|
5
|
+
FieldValueRegistry,
|
|
6
|
+
ResolveFieldValueResult,
|
|
7
|
+
} from '#utils/field-references.types';
|
|
8
|
+
|
|
9
|
+
function readInputsValue(inputs: FieldValueInput[]): string | string[] {
|
|
10
|
+
if (!inputs.length) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const first = inputs[0];
|
|
15
|
+
|
|
16
|
+
if (first instanceof HTMLSelectElement && first.multiple) {
|
|
17
|
+
return Array.from(first.selectedOptions).map((option) => {
|
|
18
|
+
return option.value;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const hasCheckboxOrRadio = inputs.some((input) => {
|
|
23
|
+
return input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (hasCheckboxOrRadio) {
|
|
27
|
+
const selected = inputs.flatMap((input) => {
|
|
28
|
+
if (!(input instanceof HTMLInputElement) || !input.checked) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return [input.value];
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return selected.length > 1 ? selected : (selected[0] || '');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return first.value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getEntry(registry: FieldValueRegistry, key: string) {
|
|
42
|
+
return registry.get(normalizeFieldKey(key)) || null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function resolveFieldReferenceLive(
|
|
46
|
+
reference: string,
|
|
47
|
+
registry: FieldValueRegistry,
|
|
48
|
+
): ResolveFieldValueResult {
|
|
49
|
+
const parsed = parseFieldReference(reference);
|
|
50
|
+
const key = parsed.key;
|
|
51
|
+
const entry = getEntry(registry, key);
|
|
52
|
+
|
|
53
|
+
if (!entry) {
|
|
54
|
+
return {
|
|
55
|
+
key,
|
|
56
|
+
value: parsed.defaultValue,
|
|
57
|
+
found: false,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const value = readInputsValue(entry.inputs);
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
key,
|
|
65
|
+
value: value === '' && parsed.defaultValue !== '' ? parsed.defaultValue : value,
|
|
66
|
+
found: true,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function resolveFieldReferenceFromFormData(
|
|
71
|
+
reference: string,
|
|
72
|
+
formData: FormData,
|
|
73
|
+
registry?: FieldValueRegistry,
|
|
74
|
+
): ResolveFieldValueResult {
|
|
75
|
+
const parsed = parseFieldReference(reference);
|
|
76
|
+
const key = parsed.key;
|
|
77
|
+
|
|
78
|
+
if (!key) {
|
|
79
|
+
return {
|
|
80
|
+
key,
|
|
81
|
+
value: parsed.defaultValue,
|
|
82
|
+
found: false,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const entry = registry ? getEntry(registry, key) : null;
|
|
87
|
+
const names = entry?.names?.length ? entry.names : [fieldKeyToInputName(key)];
|
|
88
|
+
const values = names.flatMap((name) => {
|
|
89
|
+
const collected = formData.getAll(name).map((value) => {
|
|
90
|
+
return String(value ?? '');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (collected.length) {
|
|
94
|
+
return collected;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return formData.getAll(`${name}[]`).map((value) => {
|
|
98
|
+
return String(value ?? '');
|
|
99
|
+
});
|
|
100
|
+
}).filter((value) => value !== '');
|
|
101
|
+
|
|
102
|
+
if (!values.length) {
|
|
103
|
+
return {
|
|
104
|
+
key,
|
|
105
|
+
value: parsed.defaultValue,
|
|
106
|
+
found: false,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
key,
|
|
112
|
+
value: values.length > 1 ? values : values[0],
|
|
113
|
+
found: true,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { normalizeFieldKey, fieldKeyToInputName, inputNameToFieldKey } from '#utils/field-references.keys';
|
|
2
|
+
export { parseFieldReference } from '#utils/field-references.parser';
|
|
3
|
+
export { buildFieldValueRegistry } from '#utils/field-references.registry';
|
|
4
|
+
export { resolveFieldReferenceLive, resolveFieldReferenceFromFormData } from '#utils/field-references.resolver';
|
|
5
|
+
export type {
|
|
6
|
+
FieldReferenceTransform,
|
|
7
|
+
FieldValueRegistry,
|
|
8
|
+
FieldValueRegistryEntry,
|
|
9
|
+
ParsedFieldReference,
|
|
10
|
+
ResolveFieldValueResult,
|
|
11
|
+
} from '#utils/field-references.types';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type FieldReferenceTransform = {
|
|
2
|
+
id: string;
|
|
3
|
+
params: Record<string, string>;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type ParsedFieldReference = {
|
|
7
|
+
raw: string;
|
|
8
|
+
target: 'field' | '';
|
|
9
|
+
key: string;
|
|
10
|
+
selector: string;
|
|
11
|
+
defaultValue: string;
|
|
12
|
+
transforms: FieldReferenceTransform[];
|
|
13
|
+
isToken: boolean;
|
|
14
|
+
isValid: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type FieldValueInput = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
|
|
18
|
+
|
|
19
|
+
export type FieldValueRegistryEntry = {
|
|
20
|
+
key: string;
|
|
21
|
+
names: string[];
|
|
22
|
+
inputs: FieldValueInput[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type FieldValueRegistry = Map<string, FieldValueRegistryEntry>;
|
|
26
|
+
|
|
27
|
+
export type ResolveFieldValueResult = {
|
|
28
|
+
key: string;
|
|
29
|
+
value: string | string[];
|
|
30
|
+
found: boolean;
|
|
31
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function normalizeHandle(handle: string): string {
|
|
2
|
+
// Handles can come from token-like references or nested names. Normalize them
|
|
3
|
+
// once so DOM lookups keep using the field name syntax the form actually renders.
|
|
4
|
+
return handle
|
|
5
|
+
.replace('{field:', '')
|
|
6
|
+
.replace('{', '')
|
|
7
|
+
.replace('}', '')
|
|
8
|
+
.replace(']', '')
|
|
9
|
+
.split('[')
|
|
10
|
+
.join('][');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getFieldName(handle: string): string {
|
|
14
|
+
return `fields[${normalizeHandle(handle)}]`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getFormFields(form: ParentNode, handle: string): HTMLElement[] {
|
|
18
|
+
const fieldName = getFieldName(handle);
|
|
19
|
+
const direct = Array.from(form.querySelectorAll(`[name="${fieldName}"]`));
|
|
20
|
+
const multi = Array.from(form.querySelectorAll(`[name="${fieldName}[]"]`));
|
|
21
|
+
|
|
22
|
+
return (multi.length ? multi : direct).filter((element): element is HTMLElement => {
|
|
23
|
+
return element instanceof HTMLElement;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getFieldLabel(form: ParentNode, handle: string): string {
|
|
28
|
+
const fields = getFormFields(form, handle);
|
|
29
|
+
|
|
30
|
+
for (const field of fields) {
|
|
31
|
+
const fieldContainer = field.closest('[data-formie-field-handle]') as HTMLElement | null;
|
|
32
|
+
const label = fieldContainer?.querySelector('[data-formie-field-label]')?.childNodes[0]?.textContent?.trim();
|
|
33
|
+
|
|
34
|
+
if (label) {
|
|
35
|
+
return label;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function currencyToFloat(currencyString: string): number {
|
|
43
|
+
let sanitized = currencyString.replace(/[^\d.,-]/g, '');
|
|
44
|
+
const hasComma = sanitized.includes(',');
|
|
45
|
+
const hasDot = sanitized.includes('.');
|
|
46
|
+
|
|
47
|
+
// Accept both "1,234.56" and "1.234,56" style inputs so calculations can
|
|
48
|
+
// operate on locale-formatted values emitted by other field modules.
|
|
49
|
+
if (hasComma && hasDot) {
|
|
50
|
+
sanitized = sanitized.replace(/\./g, '').replace(/,/, '.');
|
|
51
|
+
} else if (hasComma && !hasDot) {
|
|
52
|
+
sanitized = sanitized.replace(/,/, '.');
|
|
53
|
+
} else {
|
|
54
|
+
sanitized = sanitized.replace(/,/g, '');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return parseFloat(sanitized);
|
|
58
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type RequestJsonOptions = {
|
|
2
|
+
method?: string;
|
|
3
|
+
body?: BodyInit | null;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
async function request(url: string | URL, options: RequestJsonOptions = {}): Promise<Response> {
|
|
9
|
+
// Do not send `X-Requested-With` here: it is not CORS-safelisted, and Craft GraphQL CORS
|
|
10
|
+
// often omits it from `Access-Control-Allow-Headers` (breaks localhost → ddev, starters, etc.).
|
|
11
|
+
// `Accept` + JSON `Content-Type` are enough for Formie/Craft JSON endpoints.
|
|
12
|
+
const headers: Record<string, string> = {
|
|
13
|
+
Accept: 'application/json',
|
|
14
|
+
...(options.headers || {}),
|
|
15
|
+
};
|
|
16
|
+
delete headers['X-Requested-With'];
|
|
17
|
+
delete headers['x-requested-with'];
|
|
18
|
+
|
|
19
|
+
return fetch(String(url), {
|
|
20
|
+
method: options.method || 'GET',
|
|
21
|
+
body: options.body ?? null,
|
|
22
|
+
signal: options.signal,
|
|
23
|
+
// Avoid sending `Cache-Control`: not CORS-safelisted; use fetch cache mode instead.
|
|
24
|
+
cache: 'no-store',
|
|
25
|
+
headers,
|
|
26
|
+
// `include` + `Access-Control-Allow-Origin: *` is invalid; many Craft GraphQL setups use `*`.
|
|
27
|
+
// `same-origin` keeps cookies for same-host deployments and avoids credentialed cross-origin
|
|
28
|
+
// fetches (e.g. Vite on localhost → ddev HTTPS) so wildcard CORS can succeed.
|
|
29
|
+
credentials: 'same-origin',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function requestJson<T>(url: string | URL, options: RequestJsonOptions = {}): Promise<T> {
|
|
34
|
+
const response = await request(url, options);
|
|
35
|
+
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
throw new Error(`Request failed (${response.status}) for ${String(url)}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return response.json() as Promise<T>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function requestText(url: string | URL, options: RequestJsonOptions = {}): Promise<string> {
|
|
44
|
+
const response = await request(url, options);
|
|
45
|
+
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
throw new Error(`Request failed (${response.status}) for ${String(url)}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return response.text();
|
|
51
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export type TranslationReplacements = Record<string, string | number>;
|
|
2
|
+
|
|
3
|
+
type FormieWindow = Window & {
|
|
4
|
+
FormieTranslations?: Record<string, string>;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
function getWindowTranslationStore(): Record<string, string> {
|
|
8
|
+
return (window as FormieWindow).FormieTranslations || {};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function hydrateTranslationsFromDom(): void {
|
|
12
|
+
if (typeof document === 'undefined') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const scripts = Array.from(document.querySelectorAll<HTMLScriptElement>('script[type="application/json"][data-formie-translations]:not([data-formie-translations-loaded="true"])'));
|
|
17
|
+
|
|
18
|
+
if (scripts.length === 0) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let nextStore: Record<string, string> | null = null;
|
|
23
|
+
|
|
24
|
+
for (const script of scripts) {
|
|
25
|
+
// Mark each seed as consumed so repeated reads stay cheap and predictable.
|
|
26
|
+
script.dataset.formieTranslationsLoaded = 'true';
|
|
27
|
+
|
|
28
|
+
const payload = script.textContent?.trim();
|
|
29
|
+
|
|
30
|
+
if (!payload) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const translations = JSON.parse(payload);
|
|
36
|
+
|
|
37
|
+
if (!translations || Array.isArray(translations) || typeof translations !== 'object') {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
nextStore = {
|
|
42
|
+
...(nextStore ?? getWindowTranslationStore()),
|
|
43
|
+
...(translations as Record<string, string>),
|
|
44
|
+
};
|
|
45
|
+
} catch {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (nextStore) {
|
|
51
|
+
(window as FormieWindow).FormieTranslations = nextStore;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getTranslationStore(): Record<string, string> {
|
|
56
|
+
hydrateTranslationsFromDom();
|
|
57
|
+
|
|
58
|
+
return getWindowTranslationStore();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function getFormieTranslations(): Record<string, string> {
|
|
62
|
+
return { ...getTranslationStore() };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function setFormieTranslations(translations: Record<string, string>): Record<string, string> {
|
|
66
|
+
(window as FormieWindow).FormieTranslations = { ...translations };
|
|
67
|
+
|
|
68
|
+
return getFormieTranslations();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function mergeFormieTranslations(translations: Record<string, string>): Record<string, string> {
|
|
72
|
+
// Merge lets SSR/server-rendered code seed defaults while later consumers layer in
|
|
73
|
+
// feature- or locale-specific strings without wiping the existing store.
|
|
74
|
+
(window as FormieWindow).FormieTranslations = {
|
|
75
|
+
...getTranslationStore(),
|
|
76
|
+
...translations,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return getFormieTranslations();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function t(message: string, replacements: TranslationReplacements = {}): string {
|
|
83
|
+
let output = getTranslationStore()[message] || message;
|
|
84
|
+
|
|
85
|
+
// Keep replacement syntax intentionally small and predictable because these
|
|
86
|
+
// messages are often shared across PHP-rendered and JS-rendered validation UI.
|
|
87
|
+
output = output.replace(/{([a-zA-Z0-9]+)}/g, (match, key) => {
|
|
88
|
+
if (Object.prototype.hasOwnProperty.call(replacements, key)) {
|
|
89
|
+
return String(replacements[key]);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return match;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return output;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const translate = t;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { waitFor } from '#utils/async';
|
|
2
|
+
|
|
3
|
+
type GlobalWindow = Window & Record<string, unknown>;
|
|
4
|
+
|
|
5
|
+
type LoadExternalScriptOptions = {
|
|
6
|
+
id: string;
|
|
7
|
+
src: string;
|
|
8
|
+
async?: boolean;
|
|
9
|
+
defer?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const scriptLoadCache = new Map<string, Promise<HTMLScriptElement>>();
|
|
13
|
+
|
|
14
|
+
export async function ensureGlobal<T = unknown>(globalName: string, timeoutMs = 5000): Promise<T> {
|
|
15
|
+
// Third-party SDKs often attach themselves to `window` after their script tag
|
|
16
|
+
// loads, so callers wait on the global rather than assuming load == ready.
|
|
17
|
+
return waitFor(() => {
|
|
18
|
+
const value = (window as unknown as GlobalWindow)[globalName];
|
|
19
|
+
|
|
20
|
+
if (typeof value === 'undefined' || value === null) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return value as T;
|
|
25
|
+
}, {
|
|
26
|
+
timeoutMs,
|
|
27
|
+
intervalMs: 30,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function loadExternalScript({
|
|
32
|
+
id,
|
|
33
|
+
src,
|
|
34
|
+
async = true,
|
|
35
|
+
defer = true,
|
|
36
|
+
}: LoadExternalScriptOptions): Promise<HTMLScriptElement> {
|
|
37
|
+
const existing = document.getElementById(id) as HTMLScriptElement | null;
|
|
38
|
+
|
|
39
|
+
if (existing) {
|
|
40
|
+
return existing;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Cache by id so multiple forms/providers can safely request the same SDK
|
|
44
|
+
// without racing duplicate script tags into the page.
|
|
45
|
+
if (!scriptLoadCache.has(id)) {
|
|
46
|
+
scriptLoadCache.set(id, new Promise((resolve, reject) => {
|
|
47
|
+
const script = document.createElement('script');
|
|
48
|
+
script.id = id;
|
|
49
|
+
script.src = src;
|
|
50
|
+
script.async = async;
|
|
51
|
+
script.defer = defer;
|
|
52
|
+
script.onload = () => {
|
|
53
|
+
resolve(script);
|
|
54
|
+
};
|
|
55
|
+
script.onerror = () => {
|
|
56
|
+
scriptLoadCache.delete(id);
|
|
57
|
+
reject(new Error(`Failed to load external script: ${src}`));
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
document.body.appendChild(script);
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return scriptLoadCache.get(id) as Promise<HTMLScriptElement>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function loadScriptAndEnsureGlobal<T = unknown>(
|
|
68
|
+
globalName: string,
|
|
69
|
+
options: LoadExternalScriptOptions & {
|
|
70
|
+
timeoutMs?: number;
|
|
71
|
+
},
|
|
72
|
+
): Promise<T> {
|
|
73
|
+
const existing = (window as unknown as GlobalWindow)[globalName];
|
|
74
|
+
|
|
75
|
+
if (typeof existing !== 'undefined' && existing !== null) {
|
|
76
|
+
return existing as T;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Some providers expose one stable global no matter how many forms use them,
|
|
80
|
+
// so load once and then gate on that final ready signal.
|
|
81
|
+
await loadExternalScript(options);
|
|
82
|
+
|
|
83
|
+
return ensureGlobal<T>(globalName, options.timeoutMs);
|
|
84
|
+
}
|