@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,609 @@
|
|
|
1
|
+
import { t as createDebug } from "./debug-KnZeKYBI.js";
|
|
2
|
+
import { t as fieldKeyToInputName } from "./field-references.keys-BpBZ_quS.js";
|
|
3
|
+
import { a as g, o as h } from "./dist-D09GnXMW.js";
|
|
4
|
+
import { n as escapeSelectorValue } from "./shared-DC6_1u8X.js";
|
|
5
|
+
//#region src/js/modules/fields/conditions/config.ts
|
|
6
|
+
var CONDITION_SELECTOR = "[data-formie-conditions]";
|
|
7
|
+
function parseConditionSource(value) {
|
|
8
|
+
if (!value || typeof value !== "object") return null;
|
|
9
|
+
const candidate = value;
|
|
10
|
+
const transformerParams = candidate.transformerParams;
|
|
11
|
+
return {
|
|
12
|
+
raw: typeof candidate.raw === "string" ? candidate.raw : "",
|
|
13
|
+
target: typeof candidate.target === "string" ? candidate.target : "",
|
|
14
|
+
handle: typeof candidate.handle === "string" ? candidate.handle : "",
|
|
15
|
+
selector: typeof candidate.selector === "string" ? candidate.selector : "",
|
|
16
|
+
defaultValue: typeof candidate.defaultValue === "string" ? candidate.defaultValue : "",
|
|
17
|
+
transformerId: typeof candidate.transformerId === "string" ? candidate.transformerId : "",
|
|
18
|
+
transformerParams: transformerParams && typeof transformerParams === "object" ? Object.fromEntries(Object.entries(transformerParams).map(([key, item]) => {
|
|
19
|
+
return [key, String(item ?? "")];
|
|
20
|
+
})) : {},
|
|
21
|
+
isValid: candidate.isValid !== false
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function getConditionNodes(root) {
|
|
25
|
+
const nodes = Array.from(root.querySelectorAll(CONDITION_SELECTOR));
|
|
26
|
+
if (root.matches("[data-formie-conditions]")) return [root, ...nodes];
|
|
27
|
+
return nodes;
|
|
28
|
+
}
|
|
29
|
+
function parseConditionSettings(node) {
|
|
30
|
+
const raw = node.getAttribute("data-formie-conditions");
|
|
31
|
+
if (!raw) return null;
|
|
32
|
+
try {
|
|
33
|
+
const parsed = JSON.parse(raw);
|
|
34
|
+
const conditions = Array.isArray(parsed.conditions) ? parsed.conditions.filter((condition) => {
|
|
35
|
+
if (!condition || typeof condition !== "object") return false;
|
|
36
|
+
const candidate = condition;
|
|
37
|
+
return typeof candidate.field === "string" && typeof candidate.condition === "string";
|
|
38
|
+
}).map((condition) => {
|
|
39
|
+
const candidate = condition;
|
|
40
|
+
return {
|
|
41
|
+
field: condition.field,
|
|
42
|
+
source: parseConditionSource(candidate.source),
|
|
43
|
+
condition: condition.condition,
|
|
44
|
+
value: condition.value
|
|
45
|
+
};
|
|
46
|
+
}) : [];
|
|
47
|
+
return {
|
|
48
|
+
showRule: parsed.showRule === "hide" ? "hide" : "show",
|
|
49
|
+
conditionRule: parsed.conditionRule === "any" ? "any" : "all",
|
|
50
|
+
clearOnHide: parsed.clearOnHide !== false,
|
|
51
|
+
isNested: Boolean(parsed.isNested),
|
|
52
|
+
conditions
|
|
53
|
+
};
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error("[formie] Invalid condition JSON.", error);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/js/modules/fields/conditions/effects.ts
|
|
61
|
+
var CONDITION_DISABLED_ATTR = "data-formie-conditions-disabled";
|
|
62
|
+
var PRESERVED_DISABLED_ATTR = "data-formie-preserve-disabled";
|
|
63
|
+
var CONDITIONAL_HIDDEN_ATTR = "data-formie-conditionally-hidden";
|
|
64
|
+
var PAGE_HIDDEN_ATTR = "data-formie-page-hidden";
|
|
65
|
+
var CONDITIONAL_HIDDEN_CLASS = "formie-conditionally-hidden";
|
|
66
|
+
var PAGE_HIDDEN_CLASS = "formie-page-hidden";
|
|
67
|
+
var ROW_HIDDEN_ATTR = "data-formie-row-hidden";
|
|
68
|
+
var ROW_HIDDEN_CLASS = "formie-row-hidden";
|
|
69
|
+
var FIELD_COUNT_ATTR = "data-formie-field-count";
|
|
70
|
+
var ROW_SELECTOR = "[data-formie-row], [data-formie-subfield-row], [data-formie-nested-field-row]";
|
|
71
|
+
var FIELD_SELECTOR = ":scope > [data-formie-field]";
|
|
72
|
+
function clearConditionNodeValues(node) {
|
|
73
|
+
node.querySelectorAll("input, select, textarea").forEach((element) => {
|
|
74
|
+
if (!(element instanceof HTMLInputElement) && !(element instanceof HTMLSelectElement) && !(element instanceof HTMLTextAreaElement)) return;
|
|
75
|
+
if (element instanceof HTMLInputElement) {
|
|
76
|
+
if (element.type === "checkbox" || element.type === "radio") element.checked = false;
|
|
77
|
+
else if (element.type !== "hidden") element.value = "";
|
|
78
|
+
}
|
|
79
|
+
if (element instanceof HTMLSelectElement) if (element.multiple) Array.from(element.options).forEach((option) => {
|
|
80
|
+
option.selected = false;
|
|
81
|
+
});
|
|
82
|
+
else element.selectedIndex = 0;
|
|
83
|
+
if (element instanceof HTMLTextAreaElement) element.value = "";
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function setVisibilityState(node, hidden) {
|
|
87
|
+
const isPage = node.hasAttribute("data-formie-page");
|
|
88
|
+
const hiddenAttr = isPage ? PAGE_HIDDEN_ATTR : CONDITIONAL_HIDDEN_ATTR;
|
|
89
|
+
const hiddenClass = isPage ? PAGE_HIDDEN_CLASS : CONDITIONAL_HIDDEN_CLASS;
|
|
90
|
+
const wasHidden = node.hasAttribute(hiddenAttr);
|
|
91
|
+
if (hidden) {
|
|
92
|
+
if (!wasHidden) node.setAttribute(hiddenAttr, "true");
|
|
93
|
+
if (!node.classList.contains(hiddenClass)) node.classList.add(hiddenClass);
|
|
94
|
+
} else {
|
|
95
|
+
if (wasHidden) node.removeAttribute(hiddenAttr);
|
|
96
|
+
if (node.classList.contains(hiddenClass)) node.classList.remove(hiddenClass);
|
|
97
|
+
}
|
|
98
|
+
return wasHidden !== hidden;
|
|
99
|
+
}
|
|
100
|
+
function syncDisabledState(node, hidden) {
|
|
101
|
+
node.querySelectorAll("input, textarea, select").forEach((input) => {
|
|
102
|
+
if (hidden) {
|
|
103
|
+
if (!input.hasAttribute(CONDITION_DISABLED_ATTR)) {
|
|
104
|
+
if (input.hasAttribute("disabled")) input.setAttribute(PRESERVED_DISABLED_ATTR, "true");
|
|
105
|
+
input.setAttribute(CONDITION_DISABLED_ATTR, "true");
|
|
106
|
+
}
|
|
107
|
+
input.setAttribute("disabled", "true");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (!input.hasAttribute(CONDITION_DISABLED_ATTR)) return;
|
|
111
|
+
if (input.hasAttribute(PRESERVED_DISABLED_ATTR)) {
|
|
112
|
+
input.setAttribute("disabled", "true");
|
|
113
|
+
input.removeAttribute(PRESERVED_DISABLED_ATTR);
|
|
114
|
+
} else input.removeAttribute("disabled");
|
|
115
|
+
input.removeAttribute(CONDITION_DISABLED_ATTR);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function isFieldVisible(field) {
|
|
119
|
+
return !field.hasAttribute(CONDITIONAL_HIDDEN_ATTR) && !field.hasAttribute(PAGE_HIDDEN_ATTR) && !field.hasAttribute(ROW_HIDDEN_ATTR) && !field.hasAttribute("hidden");
|
|
120
|
+
}
|
|
121
|
+
function syncRowState(row) {
|
|
122
|
+
const visibleFieldCount = Array.from(row.querySelectorAll(FIELD_SELECTOR)).filter((field) => {
|
|
123
|
+
return isFieldVisible(field);
|
|
124
|
+
}).length;
|
|
125
|
+
if (visibleFieldCount > 0) {
|
|
126
|
+
const visibleCount = String(visibleFieldCount);
|
|
127
|
+
if (row.getAttribute(FIELD_COUNT_ATTR) !== visibleCount) row.setAttribute(FIELD_COUNT_ATTR, visibleCount);
|
|
128
|
+
if (row.hasAttribute(ROW_HIDDEN_ATTR)) row.removeAttribute(ROW_HIDDEN_ATTR);
|
|
129
|
+
if (row.classList.contains(ROW_HIDDEN_CLASS)) row.classList.remove(ROW_HIDDEN_CLASS);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (row.hasAttribute(FIELD_COUNT_ATTR)) row.removeAttribute(FIELD_COUNT_ATTR);
|
|
133
|
+
if (!row.hasAttribute(ROW_HIDDEN_ATTR)) row.setAttribute(ROW_HIDDEN_ATTR, "true");
|
|
134
|
+
if (!row.classList.contains(ROW_HIDDEN_CLASS)) row.classList.add(ROW_HIDDEN_CLASS);
|
|
135
|
+
}
|
|
136
|
+
function syncAncestorRows(node) {
|
|
137
|
+
let currentRow = node.closest(ROW_SELECTOR);
|
|
138
|
+
while (currentRow) {
|
|
139
|
+
syncRowState(currentRow);
|
|
140
|
+
currentRow = currentRow.parentElement?.closest(ROW_SELECTOR) || null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function applyConditionVisibility(node, hidden, clearOnHide) {
|
|
144
|
+
const stateChanged = setVisibilityState(node, hidden);
|
|
145
|
+
syncDisabledState(node, hidden);
|
|
146
|
+
syncAncestorRows(node);
|
|
147
|
+
if (hidden && clearOnHide && stateChanged) clearConditionNodeValues(node);
|
|
148
|
+
return stateChanged;
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/js/modules/fields/conditions/references.ts
|
|
152
|
+
var CONDITION_INPUT_SELECTOR = "input, select, textarea";
|
|
153
|
+
var ROW_SCOPE_SELECTOR = "[data-formie-repeater-item], [data-formie-table-row]";
|
|
154
|
+
function isConditionInput(element) {
|
|
155
|
+
return element instanceof HTMLInputElement || element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement;
|
|
156
|
+
}
|
|
157
|
+
function getNodeRowToken(node) {
|
|
158
|
+
const nodeInput = node.querySelector(CONDITION_INPUT_SELECTOR);
|
|
159
|
+
if (!nodeInput) return null;
|
|
160
|
+
const name = nodeInput.getAttribute("name") || "";
|
|
161
|
+
const tokens = Array.from(name.matchAll(/\[(\d+)\]/g));
|
|
162
|
+
if (!tokens.length) return null;
|
|
163
|
+
return tokens[tokens.length - 1]?.[1] || null;
|
|
164
|
+
}
|
|
165
|
+
function getRowScope(node) {
|
|
166
|
+
return node.closest(ROW_SCOPE_SELECTOR);
|
|
167
|
+
}
|
|
168
|
+
function getFieldInputs(fieldNode) {
|
|
169
|
+
return Array.from(fieldNode.querySelectorAll(CONDITION_INPUT_SELECTOR)).filter((element) => {
|
|
170
|
+
return isConditionInput(element);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function getInputNameTokens(input) {
|
|
174
|
+
const name = input.getAttribute("name") || "";
|
|
175
|
+
return Array.from(name.matchAll(/\[([^\]]+)\]/g)).map((match) => {
|
|
176
|
+
return match[1] || "";
|
|
177
|
+
}).filter(Boolean);
|
|
178
|
+
}
|
|
179
|
+
function matchesSelectorPath(input, selector) {
|
|
180
|
+
if (!selector) return true;
|
|
181
|
+
const selectorTokens = selector.split(/[.:]/).filter(Boolean);
|
|
182
|
+
if (!selectorTokens.length) return true;
|
|
183
|
+
const inputTokens = getInputNameTokens(input);
|
|
184
|
+
if (inputTokens.length < selectorTokens.length) return false;
|
|
185
|
+
return selectorTokens.every((token, index) => {
|
|
186
|
+
return inputTokens[inputTokens.length - selectorTokens.length + index] === token;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function filterInputsBySelector(inputs, selector) {
|
|
190
|
+
if (!selector) return inputs;
|
|
191
|
+
const matchedInputs = inputs.filter((input) => {
|
|
192
|
+
return matchesSelectorPath(input, selector);
|
|
193
|
+
});
|
|
194
|
+
return matchedInputs.length ? matchedInputs : inputs;
|
|
195
|
+
}
|
|
196
|
+
function preferSameRow(targetNode, candidates) {
|
|
197
|
+
const targetRow = getRowScope(targetNode);
|
|
198
|
+
if (!targetRow) return candidates;
|
|
199
|
+
const sameRowCandidates = candidates.filter((candidate) => {
|
|
200
|
+
return getRowScope(candidate) === targetRow;
|
|
201
|
+
});
|
|
202
|
+
return sameRowCandidates.length ? sameRowCandidates : candidates;
|
|
203
|
+
}
|
|
204
|
+
function resolveConditionSource(condition) {
|
|
205
|
+
if (condition.source?.target === "field" && condition.source.handle) return condition.source;
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
function queryConditionInputs(root, targetNode, condition) {
|
|
209
|
+
const source = resolveConditionSource(condition);
|
|
210
|
+
if (!source || source.target !== "field" || !source.handle) return [];
|
|
211
|
+
const escapedFieldHandle = escapeSelectorValue(source.handle);
|
|
212
|
+
const fieldMatches = Array.from(root.querySelectorAll(`[data-formie-field-handle="${escapedFieldHandle}"]`));
|
|
213
|
+
if (fieldMatches.length) return preferSameRow(targetNode, fieldMatches).flatMap((fieldNode) => {
|
|
214
|
+
return filterInputsBySelector(getFieldInputs(fieldNode), source.selector);
|
|
215
|
+
});
|
|
216
|
+
const exactName = escapeSelectorValue(fieldKeyToInputName(source.handle));
|
|
217
|
+
const direct = Array.from(root.querySelectorAll(`[name="${exactName}"]`)).filter((element) => {
|
|
218
|
+
return isConditionInput(element);
|
|
219
|
+
});
|
|
220
|
+
const multi = Array.from(root.querySelectorAll(`[name="${exactName}[]"]`)).filter((element) => {
|
|
221
|
+
return isConditionInput(element);
|
|
222
|
+
});
|
|
223
|
+
if (direct.length || multi.length) return preferSameRow(targetNode, [...direct, ...multi]);
|
|
224
|
+
if (!source.handle.includes("__ROW__")) return [];
|
|
225
|
+
const rowToken = getNodeRowToken(targetNode);
|
|
226
|
+
if (rowToken) {
|
|
227
|
+
const escapedRowFieldName = escapeSelectorValue(fieldKeyToInputName(source.handle.replace(/__ROW__/g, rowToken)));
|
|
228
|
+
const rowDirect = Array.from(root.querySelectorAll(`[name="${escapedRowFieldName}"]`)).filter((element) => {
|
|
229
|
+
return isConditionInput(element);
|
|
230
|
+
});
|
|
231
|
+
const rowMulti = Array.from(root.querySelectorAll(`[name="${escapedRowFieldName}[]"]`)).filter((element) => {
|
|
232
|
+
return isConditionInput(element);
|
|
233
|
+
});
|
|
234
|
+
if (rowDirect.length || rowMulti.length) return [...rowDirect, ...rowMulti];
|
|
235
|
+
}
|
|
236
|
+
const regexString = fieldKeyToInputName(source.handle).replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/__ROW__/g, "\\d+");
|
|
237
|
+
const regex = new RegExp(regexString);
|
|
238
|
+
return Array.from(root.querySelectorAll("[name]")).filter((element) => {
|
|
239
|
+
return isConditionInput(element) && regex.test(element.getAttribute("name") || "");
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/js/modules/fields/conditions/transforms.ts
|
|
244
|
+
function stringifyValue(value) {
|
|
245
|
+
if (value == null) return "";
|
|
246
|
+
return String(value);
|
|
247
|
+
}
|
|
248
|
+
function toBoolean(value) {
|
|
249
|
+
if (typeof value === "boolean") return value;
|
|
250
|
+
if (typeof value === "number") return value !== 0;
|
|
251
|
+
const normalized = stringifyValue(value).trim().toLowerCase();
|
|
252
|
+
if (!normalized || [
|
|
253
|
+
"0",
|
|
254
|
+
"false",
|
|
255
|
+
"no",
|
|
256
|
+
"off"
|
|
257
|
+
].includes(normalized)) return false;
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
function toTitleCase(value) {
|
|
261
|
+
return value.toLowerCase().replace(/\b\w/g, (match) => {
|
|
262
|
+
return match.toUpperCase();
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
function formatNumber(value, params) {
|
|
266
|
+
const decimals = Number.isFinite(Number(params.decimals)) ? Number(params.decimals) : 0;
|
|
267
|
+
const decimalPoint = params.decimalPoint ?? ".";
|
|
268
|
+
const thousandsSeparator = params.thousandsSeparator ?? ",";
|
|
269
|
+
const [integerPart, decimalPart = ""] = value.toFixed(decimals).split(".");
|
|
270
|
+
const groupedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSeparator);
|
|
271
|
+
if (decimals === 0) return groupedInteger;
|
|
272
|
+
return `${groupedInteger}${decimalPoint}${decimalPart}`;
|
|
273
|
+
}
|
|
274
|
+
function pad(value) {
|
|
275
|
+
return String(value).padStart(2, "0");
|
|
276
|
+
}
|
|
277
|
+
function formatDate(value, pattern) {
|
|
278
|
+
return [
|
|
279
|
+
["Y", String(value.getFullYear())],
|
|
280
|
+
["m", pad(value.getMonth() + 1)],
|
|
281
|
+
["d", pad(value.getDate())],
|
|
282
|
+
["j", String(value.getDate())],
|
|
283
|
+
["H", pad(value.getHours())],
|
|
284
|
+
["h", pad((value.getHours() + 11) % 12 + 1)],
|
|
285
|
+
["i", pad(value.getMinutes())],
|
|
286
|
+
["A", value.getHours() >= 12 ? "PM" : "AM"],
|
|
287
|
+
["F", value.toLocaleString(void 0, { month: "long" })]
|
|
288
|
+
].reduce((formatted, [token, replacement]) => {
|
|
289
|
+
return formatted.replaceAll(token, replacement);
|
|
290
|
+
}, pattern);
|
|
291
|
+
}
|
|
292
|
+
function resolveDateFormatPattern(preset) {
|
|
293
|
+
switch (preset) {
|
|
294
|
+
case "datetimeUs12": return "m/d/Y h:i A";
|
|
295
|
+
case "datetimeEu12": return "d/m/Y h:i A";
|
|
296
|
+
case "datetimeEu24": return "d/m/Y H:i";
|
|
297
|
+
case "datetimeIso24": return "Y-m-d H:i";
|
|
298
|
+
case "dateUs": return "m/d/Y";
|
|
299
|
+
case "dateEu": return "d/m/Y";
|
|
300
|
+
case "isoDate": return "Y-m-d";
|
|
301
|
+
case "dateLong": return "F j, Y";
|
|
302
|
+
case "time12": return "h:i A";
|
|
303
|
+
case "time24": return "H:i";
|
|
304
|
+
default: return "";
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function applyTransformer(value, source) {
|
|
308
|
+
const transformerId = source.transformerId;
|
|
309
|
+
const params = source.transformerParams;
|
|
310
|
+
switch (transformerId) {
|
|
311
|
+
case "round":
|
|
312
|
+
case "floor":
|
|
313
|
+
case "ceil": {
|
|
314
|
+
const number = Number(value);
|
|
315
|
+
if (!Number.isFinite(number)) return value;
|
|
316
|
+
if (transformerId === "round") return String(Math.round(number));
|
|
317
|
+
if (transformerId === "floor") return String(Math.floor(number));
|
|
318
|
+
return String(Math.ceil(number));
|
|
319
|
+
}
|
|
320
|
+
case "format": {
|
|
321
|
+
const number = Number(value);
|
|
322
|
+
if (Number.isFinite(number) && value.trim() !== "") return formatNumber(number, params);
|
|
323
|
+
const preset = params.preset || "";
|
|
324
|
+
const pattern = preset === "custom" ? params.pattern || "" : resolveDateFormatPattern(preset);
|
|
325
|
+
if (!pattern) return value;
|
|
326
|
+
const date = new Date(value);
|
|
327
|
+
if (Number.isNaN(date.getTime())) return value;
|
|
328
|
+
return formatDate(date, pattern);
|
|
329
|
+
}
|
|
330
|
+
case "lower": return value.toLowerCase();
|
|
331
|
+
case "upper": return value.toUpperCase();
|
|
332
|
+
case "title": return toTitleCase(value);
|
|
333
|
+
case "capitalize": return value ? value.charAt(0).toUpperCase() + value.slice(1) : value;
|
|
334
|
+
case "replace": {
|
|
335
|
+
const search = params.search || "";
|
|
336
|
+
if (!search) return value;
|
|
337
|
+
return value.split(search).join(params.replace || "");
|
|
338
|
+
}
|
|
339
|
+
case "truncate": {
|
|
340
|
+
const length = Math.max(1, Number.parseInt(params.length || "50", 10) || 50);
|
|
341
|
+
const suffix = params.suffix || "...";
|
|
342
|
+
if (value.length <= length) return value;
|
|
343
|
+
return `${value.slice(0, Math.max(0, length - suffix.length))}${suffix}`;
|
|
344
|
+
}
|
|
345
|
+
case "map": return toBoolean(value) ? params.trueLabel || "Yes" : params.falseLabel || "No";
|
|
346
|
+
default: return value;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
function applyConditionSource(values, source) {
|
|
350
|
+
if (!source) return values;
|
|
351
|
+
const transformedValues = source.transformerId ? values.map((value) => {
|
|
352
|
+
return applyTransformer(value, source);
|
|
353
|
+
}) : values;
|
|
354
|
+
if ((transformedValues.length === 0 || transformedValues.every((value) => {
|
|
355
|
+
return value.trim() === "";
|
|
356
|
+
})) && source.defaultValue) return [source.defaultValue];
|
|
357
|
+
return transformedValues;
|
|
358
|
+
}
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/js/modules/fields/conditions/values.ts
|
|
361
|
+
function getInputKey(input, index) {
|
|
362
|
+
return input.name || `__condition_input_${index}`;
|
|
363
|
+
}
|
|
364
|
+
function getInputLabel(input) {
|
|
365
|
+
const explicitLabel = input.id ? input.ownerDocument.querySelector(`label[for="${input.id}"]`)?.textContent?.trim() : "";
|
|
366
|
+
if (explicitLabel) return explicitLabel;
|
|
367
|
+
return input.closest("label")?.textContent?.trim() || "";
|
|
368
|
+
}
|
|
369
|
+
function readInputGroupValues(inputs, selector = "") {
|
|
370
|
+
const firstInput = inputs[0];
|
|
371
|
+
if (!firstInput) return [];
|
|
372
|
+
if (firstInput instanceof HTMLInputElement) {
|
|
373
|
+
if (firstInput.type === "checkbox") {
|
|
374
|
+
const checkedInputs = inputs.filter((input) => {
|
|
375
|
+
return input instanceof HTMLInputElement && input.checked;
|
|
376
|
+
});
|
|
377
|
+
if (selector === "label") return checkedInputs.map((input) => {
|
|
378
|
+
return getInputLabel(input);
|
|
379
|
+
}).filter(Boolean);
|
|
380
|
+
return checkedInputs.map((input) => {
|
|
381
|
+
return input.value;
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
if (firstInput.type === "radio") {
|
|
385
|
+
const checkedInputs = inputs.filter((input) => {
|
|
386
|
+
return input instanceof HTMLInputElement && input.checked;
|
|
387
|
+
});
|
|
388
|
+
if (selector === "label") return checkedInputs.map((input) => {
|
|
389
|
+
return getInputLabel(input);
|
|
390
|
+
}).filter(Boolean);
|
|
391
|
+
return checkedInputs.map((input) => {
|
|
392
|
+
return input.value;
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
if (firstInput.type === "file") return Array.from(firstInput.files || []).map((file) => {
|
|
396
|
+
return file.name;
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
if (firstInput instanceof HTMLSelectElement && firstInput.multiple) {
|
|
400
|
+
if (selector === "label") return Array.from(firstInput.selectedOptions).map((option) => {
|
|
401
|
+
return option.label || option.text;
|
|
402
|
+
});
|
|
403
|
+
return Array.from(firstInput.selectedOptions).map((option) => {
|
|
404
|
+
return option.value;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
if (firstInput instanceof HTMLSelectElement && selector === "label") return Array.from(firstInput.selectedOptions).map((option) => {
|
|
408
|
+
return option.label || option.text;
|
|
409
|
+
});
|
|
410
|
+
return inputs.map((input) => {
|
|
411
|
+
return input.value;
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
function getConditionInputEventNames(_input) {
|
|
415
|
+
return ["input", "change"];
|
|
416
|
+
}
|
|
417
|
+
function readConditionValues(inputs, source = null) {
|
|
418
|
+
const groupedInputs = /* @__PURE__ */ new Map();
|
|
419
|
+
inputs.forEach((input, index) => {
|
|
420
|
+
const key = getInputKey(input, index);
|
|
421
|
+
const existing = groupedInputs.get(key) || [];
|
|
422
|
+
existing.push(input);
|
|
423
|
+
groupedInputs.set(key, existing);
|
|
424
|
+
});
|
|
425
|
+
return applyConditionSource(Array.from(groupedInputs.values()).flatMap((group) => {
|
|
426
|
+
return readInputGroupValues(group, source?.selector || "");
|
|
427
|
+
}), source);
|
|
428
|
+
}
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/js/modules/fields/conditions/evaluator.ts
|
|
431
|
+
function isInputVisible(input) {
|
|
432
|
+
if (input.closest("[data-formie-conditionally-hidden]") || input.closest("[data-formie-page-hidden]") || input.closest("[hidden]") || input.closest("[aria-hidden=\"true\"]")) return false;
|
|
433
|
+
return !!(input.offsetWidth || input.offsetHeight || input.getClientRects().length);
|
|
434
|
+
}
|
|
435
|
+
function getConditionVisibility(inputs) {
|
|
436
|
+
if (!inputs.length) return null;
|
|
437
|
+
return inputs.some((input) => {
|
|
438
|
+
return isInputVisible(input);
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
function evaluateConditionSettings(settings, getConditionInputs) {
|
|
442
|
+
return g(settings, settings.conditions.map((condition) => {
|
|
443
|
+
const inputs = getConditionInputs(condition);
|
|
444
|
+
return h(condition, readConditionValues(inputs, resolveConditionSource(condition)), { visibility: getConditionVisibility(inputs) });
|
|
445
|
+
}));
|
|
446
|
+
}
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/js/modules/fields/conditions.ts
|
|
449
|
+
var MAX_EVALUATION_PASSES = 4;
|
|
450
|
+
var debug = createDebug("conditions");
|
|
451
|
+
function uniqueConditionInputs(inputs) {
|
|
452
|
+
const seenInputs = /* @__PURE__ */ new Set();
|
|
453
|
+
return inputs.filter((input) => {
|
|
454
|
+
if (seenInputs.has(input)) return false;
|
|
455
|
+
seenInputs.add(input);
|
|
456
|
+
return true;
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
var conditionsModule = {
|
|
460
|
+
id: "conditions",
|
|
461
|
+
kind: "field",
|
|
462
|
+
match: (ctx) => {
|
|
463
|
+
return ctx.target instanceof HTMLElement && (ctx.target.matches("[data-formie-conditions]") || !!ctx.target.querySelector("[data-formie-conditions]"));
|
|
464
|
+
},
|
|
465
|
+
setup: async (ctx) => {
|
|
466
|
+
const scopeRoot = ctx.target instanceof HTMLElement ? ctx.target : ctx.root;
|
|
467
|
+
if (!getConditionNodes(scopeRoot).length) {
|
|
468
|
+
debug.log("No condition nodes in scope.");
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
const sourceUnbinds = [];
|
|
472
|
+
let entries = [];
|
|
473
|
+
let evaluationQueued = false;
|
|
474
|
+
let rebuildQueued = false;
|
|
475
|
+
const cleanupSourceBindings = () => {
|
|
476
|
+
sourceUnbinds.forEach((unbind) => {
|
|
477
|
+
unbind();
|
|
478
|
+
});
|
|
479
|
+
sourceUnbinds.length = 0;
|
|
480
|
+
};
|
|
481
|
+
const buildEntries = () => {
|
|
482
|
+
return getConditionNodes(scopeRoot).flatMap((node) => {
|
|
483
|
+
const settings = parseConditionSettings(node);
|
|
484
|
+
if (!settings || !settings.conditions.length) return [];
|
|
485
|
+
return [{
|
|
486
|
+
node,
|
|
487
|
+
settings,
|
|
488
|
+
sourceInputs: uniqueConditionInputs(settings.conditions.flatMap((condition) => {
|
|
489
|
+
return queryConditionInputs(scopeRoot, node, condition);
|
|
490
|
+
}))
|
|
491
|
+
}];
|
|
492
|
+
});
|
|
493
|
+
};
|
|
494
|
+
const runEvaluationPass = () => {
|
|
495
|
+
let hasStateChanges = false;
|
|
496
|
+
entries.forEach((entry) => {
|
|
497
|
+
const result = evaluateConditionSettings(entry.settings, (condition) => {
|
|
498
|
+
return queryConditionInputs(scopeRoot, entry.node, condition);
|
|
499
|
+
});
|
|
500
|
+
const stateChanged = applyConditionVisibility(entry.node, result.shouldHide, entry.settings.clearOnHide);
|
|
501
|
+
hasStateChanges = hasStateChanges || stateChanged;
|
|
502
|
+
debug.log("Condition evaluated.", {
|
|
503
|
+
shouldHide: result.shouldHide,
|
|
504
|
+
finalResult: result.finalResult,
|
|
505
|
+
stateChanged
|
|
506
|
+
});
|
|
507
|
+
ctx.emit("formie:conditions:evaluated", {
|
|
508
|
+
node: entry.node,
|
|
509
|
+
shouldHide: result.shouldHide,
|
|
510
|
+
finalResult: result.finalResult,
|
|
511
|
+
clearOnHide: entry.settings.clearOnHide
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
return hasStateChanges;
|
|
515
|
+
};
|
|
516
|
+
const evaluateAll = () => {
|
|
517
|
+
for (let pass = 0; pass < MAX_EVALUATION_PASSES; pass += 1) {
|
|
518
|
+
if (!runEvaluationPass()) break;
|
|
519
|
+
if (pass === MAX_EVALUATION_PASSES - 1) debug.warn("Reached max evaluation passes.", { maxPasses: MAX_EVALUATION_PASSES });
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
const scheduleEvaluateAll = () => {
|
|
523
|
+
if (evaluationQueued) return;
|
|
524
|
+
evaluationQueued = true;
|
|
525
|
+
queueMicrotask(() => {
|
|
526
|
+
evaluationQueued = false;
|
|
527
|
+
evaluateAll();
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
const bindSourceInputs = () => {
|
|
531
|
+
uniqueConditionInputs(entries.flatMap((entry) => {
|
|
532
|
+
return entry.sourceInputs;
|
|
533
|
+
})).forEach((input) => {
|
|
534
|
+
const handler = () => {
|
|
535
|
+
scheduleEvaluateAll();
|
|
536
|
+
};
|
|
537
|
+
getConditionInputEventNames(input).forEach((eventName) => {
|
|
538
|
+
input.addEventListener(eventName, handler);
|
|
539
|
+
});
|
|
540
|
+
sourceUnbinds.push(() => {
|
|
541
|
+
getConditionInputEventNames(input).forEach((eventName) => {
|
|
542
|
+
input.removeEventListener(eventName, handler);
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
});
|
|
546
|
+
if (ctx.form) {
|
|
547
|
+
const resetHandler = () => {
|
|
548
|
+
window.setTimeout(() => {
|
|
549
|
+
scheduleEvaluateAll();
|
|
550
|
+
}, 0);
|
|
551
|
+
};
|
|
552
|
+
ctx.form.addEventListener("reset", resetHandler);
|
|
553
|
+
sourceUnbinds.push(() => {
|
|
554
|
+
ctx.form?.removeEventListener("reset", resetHandler);
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
const rebuild = () => {
|
|
559
|
+
cleanupSourceBindings();
|
|
560
|
+
entries = buildEntries();
|
|
561
|
+
bindSourceInputs();
|
|
562
|
+
debug.log("Rebuilt condition graph.", { entryCount: entries.length });
|
|
563
|
+
scheduleEvaluateAll();
|
|
564
|
+
};
|
|
565
|
+
const scheduleRebuild = () => {
|
|
566
|
+
if (rebuildQueued) return;
|
|
567
|
+
rebuildQueued = true;
|
|
568
|
+
queueMicrotask(() => {
|
|
569
|
+
rebuildQueued = false;
|
|
570
|
+
rebuild();
|
|
571
|
+
});
|
|
572
|
+
};
|
|
573
|
+
const observer = new MutationObserver((mutations) => {
|
|
574
|
+
const shouldRebuild = mutations.some((mutation) => {
|
|
575
|
+
return mutation.type === "childList" && (mutation.addedNodes.length > 0 || mutation.removedNodes.length > 0);
|
|
576
|
+
});
|
|
577
|
+
const shouldEvaluate = mutations.some((mutation) => {
|
|
578
|
+
return mutation.type === "attributes";
|
|
579
|
+
});
|
|
580
|
+
if (shouldRebuild) scheduleRebuild();
|
|
581
|
+
else if (shouldEvaluate) scheduleEvaluateAll();
|
|
582
|
+
});
|
|
583
|
+
observer.observe(scopeRoot, {
|
|
584
|
+
childList: true,
|
|
585
|
+
subtree: true,
|
|
586
|
+
attributes: true,
|
|
587
|
+
attributeFilter: [
|
|
588
|
+
"class",
|
|
589
|
+
"style",
|
|
590
|
+
"hidden",
|
|
591
|
+
"aria-hidden",
|
|
592
|
+
"data-formie-conditionally-hidden",
|
|
593
|
+
"data-formie-page-hidden",
|
|
594
|
+
"data-formie-row-hidden"
|
|
595
|
+
]
|
|
596
|
+
});
|
|
597
|
+
rebuild();
|
|
598
|
+
await ctx.emit("formie:module:conditions:init", { count: entries.length });
|
|
599
|
+
debug.log("Module setup complete.", { entryCount: entries.length });
|
|
600
|
+
return { destroy: () => {
|
|
601
|
+
cleanupSourceBindings();
|
|
602
|
+
observer.disconnect();
|
|
603
|
+
debug.log("Module destroy.");
|
|
604
|
+
ctx.emit("formie:module:conditions:destroy", {});
|
|
605
|
+
} };
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
//#endregion
|
|
609
|
+
export { conditionsModule };
|