@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,273 @@
|
|
|
1
|
+
import {
|
|
2
|
+
coerceCalculationVariables,
|
|
3
|
+
evaluateCalculationExpression,
|
|
4
|
+
getCalculationFormula,
|
|
5
|
+
getCalculationVariableEntries,
|
|
6
|
+
readCalculationVariableValue,
|
|
7
|
+
type CalculationOptions,
|
|
8
|
+
type CalculationVariable,
|
|
9
|
+
type CalculationVariableEntry,
|
|
10
|
+
} from '@verbb/formie-core';
|
|
11
|
+
|
|
12
|
+
import type { FormieModuleDefinition } from '#contracts/modules';
|
|
13
|
+
import { dispatchFieldEvent, getModuleFieldContainers } from '#modules/fields/shared';
|
|
14
|
+
import { buildFieldValueRegistry, fieldKeyToInputName, normalizeFieldKey, resolveFieldReferenceLive } from '#utils/field-references';
|
|
15
|
+
import { createDebug } from '#utils/debug';
|
|
16
|
+
|
|
17
|
+
const INPUT_SELECTOR = 'input[data-formie-calculation-input]';
|
|
18
|
+
const MODULE_ID = 'calculations';
|
|
19
|
+
const debug = createDebug('fields', 'calculations');
|
|
20
|
+
|
|
21
|
+
function resolveVariables(
|
|
22
|
+
root: Element,
|
|
23
|
+
variableEntries: CalculationVariableEntry[],
|
|
24
|
+
options: CalculationOptions,
|
|
25
|
+
): Record<string, unknown> {
|
|
26
|
+
const registry = buildFieldValueRegistry(root);
|
|
27
|
+
const variables: Record<string, unknown> = {};
|
|
28
|
+
|
|
29
|
+
variableEntries.forEach(([variableKey, variable]) => {
|
|
30
|
+
const resolved = resolveFieldReferenceLive(variable.sourceKey || '', registry);
|
|
31
|
+
variables[variableKey] = readCalculationVariableValue(variable, resolved.value);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return coerceCalculationVariables(variables, options.formatting);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getWatchNames(root: Element, variableEntries: CalculationVariableEntry[]): Set<string> {
|
|
38
|
+
const registry = buildFieldValueRegistry(root);
|
|
39
|
+
const watchNames = new Set<string>();
|
|
40
|
+
|
|
41
|
+
variableEntries.forEach(([, variable]) => {
|
|
42
|
+
const key = normalizeFieldKey(variable.sourceKey || '');
|
|
43
|
+
const entry = registry.get(key);
|
|
44
|
+
|
|
45
|
+
if (entry?.names?.length) {
|
|
46
|
+
entry.names.forEach((name) => {
|
|
47
|
+
watchNames.add(name);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const fallback = fieldKeyToInputName(key);
|
|
54
|
+
if (fallback) {
|
|
55
|
+
watchNames.add(fallback);
|
|
56
|
+
watchNames.add(`${fallback}[]`);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return watchNames;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function bindCalculationsField(root: Element, field: HTMLElement, input: HTMLInputElement, options: CalculationOptions): () => void {
|
|
64
|
+
const formula = getCalculationFormula(options);
|
|
65
|
+
const variableEntries = getCalculationVariableEntries(options);
|
|
66
|
+
const sourceBindings = new Map<EventTarget, Map<string, EventListener>>();
|
|
67
|
+
let observer: MutationObserver | null = null;
|
|
68
|
+
let destroyed = false;
|
|
69
|
+
let evaluateQueued = false;
|
|
70
|
+
let rebindQueued = false;
|
|
71
|
+
|
|
72
|
+
const cleanupBindings = () => {
|
|
73
|
+
sourceBindings.forEach((listeners, target: EventTarget) => {
|
|
74
|
+
listeners.forEach((listener, eventName) => {
|
|
75
|
+
(target as Element).removeEventListener(eventName, listener);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
sourceBindings.clear();
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const dispatchCalculatedValueChanged = (valueChanged: boolean) => {
|
|
83
|
+
if (!valueChanged || destroyed) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
queueMicrotask(() => {
|
|
88
|
+
if (destroyed) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
93
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const evaluate = (isInit = false) => {
|
|
98
|
+
const variables = resolveVariables(root, variableEntries, options);
|
|
99
|
+
debug.log('Evaluate requested.', {
|
|
100
|
+
fieldHandle: field.getAttribute('data-formie-field-handle') || null,
|
|
101
|
+
isInit,
|
|
102
|
+
});
|
|
103
|
+
const beforeDetail = {
|
|
104
|
+
calculations: input,
|
|
105
|
+
init: isInit,
|
|
106
|
+
formula,
|
|
107
|
+
variables,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
dispatchFieldEvent(field, MODULE_ID, 'before-evaluate', beforeDetail);
|
|
111
|
+
|
|
112
|
+
if (!beforeDetail.formula) {
|
|
113
|
+
const valueChanged = input.value !== '';
|
|
114
|
+
input.value = '';
|
|
115
|
+
dispatchCalculatedValueChanged(valueChanged);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
const result = evaluateCalculationExpression(beforeDetail.formula, beforeDetail.variables, options);
|
|
121
|
+
|
|
122
|
+
const afterDetail = {
|
|
123
|
+
calculations: input,
|
|
124
|
+
init: isInit,
|
|
125
|
+
formula: beforeDetail.formula,
|
|
126
|
+
variables: beforeDetail.variables,
|
|
127
|
+
result,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
dispatchFieldEvent(field, MODULE_ID, 'after-evaluate', afterDetail);
|
|
131
|
+
const nextValue = typeof afterDetail.result === 'string' || typeof afterDetail.result === 'number'
|
|
132
|
+
? String(afterDetail.result)
|
|
133
|
+
: '';
|
|
134
|
+
const valueChanged = input.value !== nextValue;
|
|
135
|
+
input.value = nextValue;
|
|
136
|
+
debug.log('Evaluate complete.', {
|
|
137
|
+
fieldHandle: field.getAttribute('data-formie-field-handle') || null,
|
|
138
|
+
valueChanged,
|
|
139
|
+
nextValue,
|
|
140
|
+
});
|
|
141
|
+
dispatchCalculatedValueChanged(valueChanged);
|
|
142
|
+
} catch (error) {
|
|
143
|
+
const valueChanged = input.value !== '';
|
|
144
|
+
console.error('[formie] Failed to evaluate calculation.', error);
|
|
145
|
+
debug.warn('Evaluate failed.', {
|
|
146
|
+
fieldHandle: field.getAttribute('data-formie-field-handle') || null,
|
|
147
|
+
error: error instanceof Error ? error.message : error,
|
|
148
|
+
});
|
|
149
|
+
input.value = '';
|
|
150
|
+
dispatchCalculatedValueChanged(valueChanged);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const scheduleEvaluate = (isInit = false) => {
|
|
155
|
+
if (evaluateQueued || destroyed) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
evaluateQueued = true;
|
|
160
|
+
|
|
161
|
+
queueMicrotask(() => {
|
|
162
|
+
evaluateQueued = false;
|
|
163
|
+
evaluate(isInit);
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const bindSources = () => {
|
|
168
|
+
cleanupBindings();
|
|
169
|
+
const watchNames = getWatchNames(root, variableEntries);
|
|
170
|
+
debug.log('Binding variable watchers.', {
|
|
171
|
+
fieldHandle: field.getAttribute('data-formie-field-handle') || null,
|
|
172
|
+
watchCount: watchNames.size,
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
if (!watchNames.size) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const listener: EventListener = (event) => {
|
|
180
|
+
const target = event.target as HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null;
|
|
181
|
+
const name = target?.name || '';
|
|
182
|
+
|
|
183
|
+
if (!name || !watchNames.has(name)) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
debug.log('Source change detected.', {
|
|
188
|
+
fieldHandle: field.getAttribute('data-formie-field-handle') || null,
|
|
189
|
+
sourceName: name,
|
|
190
|
+
eventType: event.type,
|
|
191
|
+
});
|
|
192
|
+
scheduleEvaluate(false);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
['input', 'change'].forEach((eventName) => {
|
|
196
|
+
root.addEventListener(eventName, listener);
|
|
197
|
+
const listeners = sourceBindings.get(root) || new Map<string, EventListener>();
|
|
198
|
+
listeners.set(eventName, listener);
|
|
199
|
+
sourceBindings.set(root, listeners);
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const scheduleRebind = () => {
|
|
204
|
+
if (rebindQueued || destroyed) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
rebindQueued = true;
|
|
209
|
+
|
|
210
|
+
queueMicrotask(() => {
|
|
211
|
+
rebindQueued = false;
|
|
212
|
+
bindSources();
|
|
213
|
+
scheduleEvaluate(false);
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
bindSources();
|
|
218
|
+
observer = new MutationObserver(() => {
|
|
219
|
+
scheduleRebind();
|
|
220
|
+
});
|
|
221
|
+
observer.observe(root, {
|
|
222
|
+
childList: true,
|
|
223
|
+
subtree: true,
|
|
224
|
+
});
|
|
225
|
+
evaluate(true);
|
|
226
|
+
|
|
227
|
+
return () => {
|
|
228
|
+
destroyed = true;
|
|
229
|
+
observer?.disconnect();
|
|
230
|
+
cleanupBindings();
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export const calculationsModule: FormieModuleDefinition = {
|
|
235
|
+
id: MODULE_ID,
|
|
236
|
+
kind: 'field',
|
|
237
|
+
match: (ctx) => {
|
|
238
|
+
return !!ctx.target.querySelector(INPUT_SELECTOR);
|
|
239
|
+
},
|
|
240
|
+
setup: async(ctx) => {
|
|
241
|
+
const options = (ctx.options || {}) as CalculationOptions;
|
|
242
|
+
const fields = getModuleFieldContainers(ctx);
|
|
243
|
+
debug.log('Module setup.', {
|
|
244
|
+
fieldCount: fields.length,
|
|
245
|
+
formatting: options.formatting || null,
|
|
246
|
+
});
|
|
247
|
+
const cleanups = fields.map((field) => {
|
|
248
|
+
const input = field.querySelector(INPUT_SELECTOR);
|
|
249
|
+
if (!(input instanceof HTMLInputElement)) {
|
|
250
|
+
return () => {};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return bindCalculationsField(ctx.root, field, input, options);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
await ctx.emit('formie:module:calculations:init', {
|
|
257
|
+
count: cleanups.length,
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
return {
|
|
261
|
+
destroy: () => {
|
|
262
|
+
debug.log('Module destroy.', {
|
|
263
|
+
fieldCount: cleanups.length,
|
|
264
|
+
});
|
|
265
|
+
cleanups.forEach((cleanup) => {
|
|
266
|
+
cleanup();
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
void ctx.emit('formie:module:calculations:destroy', {});
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
},
|
|
273
|
+
};
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import type { FormieModuleDefinition } from '#contracts/modules';
|
|
2
|
+
import { dispatchFieldEvent, escapeSelectorValue, releaseFormValidators, retainFormValidators } from '#modules/fields/shared';
|
|
3
|
+
import { createDebug } from '#utils/debug';
|
|
4
|
+
|
|
5
|
+
const FIELD_SELECTOR = '[data-formie-checkboxes-field-layout], [data-formie-radio-field-layout]';
|
|
6
|
+
const CHECKBOX_MINMAX_VALIDATOR = 'minmaxOptions';
|
|
7
|
+
const MAX_DISABLED_ATTR = 'data-formie-checkbox-radio-max-disabled';
|
|
8
|
+
const MODULE_ID = 'checkbox-radio';
|
|
9
|
+
const VALIDATOR_SCOPE = 'checkbox-radio';
|
|
10
|
+
const debug = createDebug('fields', 'checkbox-radio');
|
|
11
|
+
|
|
12
|
+
function isToggleCheckbox(input: HTMLInputElement): boolean {
|
|
13
|
+
return input.hasAttribute('data-checkbox-toggle') || input.hasAttribute('data-formie-checkbox-toggle');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getMinMaxRule(getRule: (rule: string) => unknown): { min: number | null; max: number | null } {
|
|
17
|
+
const rule = getRule(CHECKBOX_MINMAX_VALIDATOR);
|
|
18
|
+
|
|
19
|
+
if (!rule || rule === true || typeof rule !== 'object') {
|
|
20
|
+
return {
|
|
21
|
+
min: null,
|
|
22
|
+
max: null,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const candidate = rule as Record<string, unknown>;
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
min: typeof candidate.min === 'number' ? candidate.min : null,
|
|
30
|
+
max: typeof candidate.max === 'number' ? candidate.max : null,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function registerValidators(form: HTMLFormElement | null): void {
|
|
35
|
+
// Several checkbox/radio module instances can exist in one form, but the
|
|
36
|
+
// custom validator should only be registered once per form lifecycle.
|
|
37
|
+
retainFormValidators(form, VALIDATOR_SCOPE, (validator) => {
|
|
38
|
+
validator.addValidator(
|
|
39
|
+
CHECKBOX_MINMAX_VALIDATOR,
|
|
40
|
+
({ field, getRule }) => {
|
|
41
|
+
if (!field || !getRule(CHECKBOX_MINMAX_VALIDATOR)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const inputs = Array.from(field.querySelectorAll('input[type="checkbox"]')).filter((input): input is HTMLInputElement => {
|
|
46
|
+
return input instanceof HTMLInputElement && !isToggleCheckbox(input);
|
|
47
|
+
});
|
|
48
|
+
const selected = inputs.filter((input) => {
|
|
49
|
+
return input.checked;
|
|
50
|
+
}).length;
|
|
51
|
+
const { min, max } = getMinMaxRule(getRule);
|
|
52
|
+
|
|
53
|
+
if (min !== null && selected < min) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (max !== null && selected > max) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return true;
|
|
62
|
+
},
|
|
63
|
+
({ field, label, t, getRule }) => {
|
|
64
|
+
const { min, max } = field ? getMinMaxRule(getRule) : { min: null, max: null };
|
|
65
|
+
|
|
66
|
+
if (min !== null && max !== null) {
|
|
67
|
+
return t('{attribute} must select between {min} and {max}.', { attribute: label, min, max });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (min !== null) {
|
|
71
|
+
return t('{attribute} must select no less than {min}.', { attribute: label, min });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (max !== null) {
|
|
75
|
+
return t('{attribute} must select no greater than {max}.', { attribute: label, max });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return t('{attribute} has an invalid value.', { attribute: label });
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function unregisterValidators(form: HTMLFormElement | null): void {
|
|
85
|
+
releaseFormValidators(form, VALIDATOR_SCOPE, [CHECKBOX_MINMAX_VALIDATOR]);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function syncCheckedAttribute(input: HTMLInputElement): void {
|
|
89
|
+
if (input.checked) {
|
|
90
|
+
input.setAttribute('checked', '');
|
|
91
|
+
} else {
|
|
92
|
+
input.removeAttribute('checked');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function syncRequiredCheckboxes(field: HTMLElement): void {
|
|
97
|
+
const requiredCheckboxes = Array.from(field.querySelectorAll('input[type="checkbox"][required][data-formie-checkbox-input]')).filter((input): input is HTMLInputElement => {
|
|
98
|
+
return input instanceof HTMLInputElement;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
if (!requiredCheckboxes.length) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const hasCheckedValue = requiredCheckboxes.some((input) => {
|
|
106
|
+
return input.checked;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Native required checkbox behavior is per-input, while Formie treats the
|
|
110
|
+
// field as one logical group. Toggle `required` to preserve that contract.
|
|
111
|
+
requiredCheckboxes.forEach((input) => {
|
|
112
|
+
if (hasCheckedValue) {
|
|
113
|
+
input.removeAttribute('required');
|
|
114
|
+
input.setAttribute('aria-required', 'false');
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
input.setAttribute('required', 'true');
|
|
119
|
+
input.setAttribute('aria-required', 'true');
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function enforceMaxOptions(field: HTMLElement): void {
|
|
124
|
+
const maxOptions = parseInt(field.closest('[data-formie-field-handle]')?.getAttribute('data-formie-max-options') || '', 10);
|
|
125
|
+
|
|
126
|
+
if (!(maxOptions > 0)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const checkboxes = Array.from(field.querySelectorAll('input[type="checkbox"]')).filter((input): input is HTMLInputElement => {
|
|
131
|
+
return input instanceof HTMLInputElement && !isToggleCheckbox(input);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const checked = checkboxes.filter((input) => {
|
|
135
|
+
return input.checked;
|
|
136
|
+
});
|
|
137
|
+
const disableUnchecked = checked.length >= maxOptions;
|
|
138
|
+
|
|
139
|
+
// Disable only the unchecked options once the max is reached so the user can
|
|
140
|
+
// still back out of a choice without getting trapped in a disabled state.
|
|
141
|
+
checkboxes.forEach((input) => {
|
|
142
|
+
const shouldDisableForMax = disableUnchecked && !input.checked;
|
|
143
|
+
const wasDisabledForMax = input.hasAttribute(MAX_DISABLED_ATTR);
|
|
144
|
+
|
|
145
|
+
if (shouldDisableForMax) {
|
|
146
|
+
if (!input.disabled) {
|
|
147
|
+
input.disabled = true;
|
|
148
|
+
input.setAttribute(MAX_DISABLED_ATTR, 'true');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (wasDisabledForMax) {
|
|
155
|
+
input.disabled = false;
|
|
156
|
+
input.removeAttribute(MAX_DISABLED_ATTR);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function toggleCheckboxGroup(field: HTMLElement, toggle: HTMLInputElement): void {
|
|
162
|
+
const checkboxes = Array.from(field.querySelectorAll('input[type="checkbox"]')).filter((input): input is HTMLInputElement => {
|
|
163
|
+
return input instanceof HTMLInputElement && input !== toggle && !isToggleCheckbox(input);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
checkboxes.forEach((input) => {
|
|
167
|
+
if (input.disabled && !input.checked) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Re-emit change/input so downstream modules (conditions, calculations,
|
|
172
|
+
// validation) react exactly as if the user toggled each box manually.
|
|
173
|
+
input.checked = toggle.checked;
|
|
174
|
+
syncCheckedAttribute(input);
|
|
175
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
176
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function syncRadioGroup(input: HTMLInputElement, field: HTMLElement): void {
|
|
181
|
+
if (!input.checked || !input.name) {
|
|
182
|
+
syncCheckedAttribute(input);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const group = Array.from(field.querySelectorAll(`input[type="radio"][name="${escapeSelectorValue(input.name)}"]`)).filter((radio): radio is HTMLInputElement => {
|
|
187
|
+
return radio instanceof HTMLInputElement;
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
group.forEach((radio) => {
|
|
191
|
+
syncCheckedAttribute(radio);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function bindField(field: HTMLElement): () => void {
|
|
196
|
+
const inputs = Array.from(field.querySelectorAll('input[type="checkbox"], input[type="radio"]')).filter((input): input is HTMLInputElement => {
|
|
197
|
+
return input instanceof HTMLInputElement;
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
if (!inputs.length) {
|
|
201
|
+
debug.log('No checkbox/radio inputs found for field.');
|
|
202
|
+
return () => {};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const listeners = inputs.map((input) => {
|
|
206
|
+
const eventName = input.type === 'radio' ? 'change' : 'click';
|
|
207
|
+
const handler = () => {
|
|
208
|
+
syncCheckedAttribute(input);
|
|
209
|
+
|
|
210
|
+
if (input.type === 'checkbox' && isToggleCheckbox(input)) {
|
|
211
|
+
toggleCheckboxGroup(field, input);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (input.type === 'radio') {
|
|
215
|
+
syncRadioGroup(input, field);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
syncRequiredCheckboxes(field);
|
|
219
|
+
enforceMaxOptions(field);
|
|
220
|
+
debug.log('Input interaction processed.', {
|
|
221
|
+
inputName: input.name,
|
|
222
|
+
inputType: input.type,
|
|
223
|
+
checked: input.checked,
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
input.addEventListener(eventName, handler);
|
|
228
|
+
syncCheckedAttribute(input);
|
|
229
|
+
|
|
230
|
+
return () => {
|
|
231
|
+
input.removeEventListener(eventName, handler);
|
|
232
|
+
};
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
syncRequiredCheckboxes(field);
|
|
236
|
+
enforceMaxOptions(field);
|
|
237
|
+
dispatchFieldEvent(field, MODULE_ID, 'init', {
|
|
238
|
+
checkboxRadio: field,
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
return () => {
|
|
242
|
+
listeners.forEach((unbind) => {
|
|
243
|
+
unbind();
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export const checkboxRadioModule: FormieModuleDefinition = {
|
|
249
|
+
id: MODULE_ID,
|
|
250
|
+
kind: 'field',
|
|
251
|
+
match: (ctx) => {
|
|
252
|
+
return ctx.target instanceof HTMLElement && (
|
|
253
|
+
ctx.target.matches(FIELD_SELECTOR) ||
|
|
254
|
+
!!ctx.target.querySelector(FIELD_SELECTOR)
|
|
255
|
+
);
|
|
256
|
+
},
|
|
257
|
+
setup: async(ctx) => {
|
|
258
|
+
if (!(ctx.target instanceof HTMLElement)) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const fields = ctx.target.matches(FIELD_SELECTOR)
|
|
263
|
+
? [ctx.target]
|
|
264
|
+
: Array.from(ctx.target.querySelectorAll(FIELD_SELECTOR)).filter((field): field is HTMLElement => {
|
|
265
|
+
return field instanceof HTMLElement;
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
registerValidators(ctx.form);
|
|
269
|
+
debug.log('Module setup.', {
|
|
270
|
+
fieldCount: fields.length,
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const destroyBindings = fields.map((field) => {
|
|
274
|
+
return bindField(field);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
await ctx.emit('formie:module:checkbox-radio:init', {
|
|
278
|
+
count: fields.length,
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
destroy: () => {
|
|
283
|
+
destroyBindings.forEach((destroyBinding) => {
|
|
284
|
+
destroyBinding();
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
unregisterValidators(ctx.form);
|
|
288
|
+
debug.log('Module destroy.', {
|
|
289
|
+
fieldCount: fields.length,
|
|
290
|
+
});
|
|
291
|
+
void ctx.emit('formie:module:checkbox-radio:destroy', {});
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
},
|
|
295
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ParsedConditionSettings, ConditionDefinition, ConditionSource } from '#modules/fields/conditions/types';
|
|
2
|
+
|
|
3
|
+
export const CONDITION_SELECTOR = '[data-formie-conditions]';
|
|
4
|
+
|
|
5
|
+
function parseConditionSource(value: unknown): ConditionSource | null {
|
|
6
|
+
if (!value || typeof value !== 'object') {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const candidate = value as Record<string, unknown>;
|
|
11
|
+
const transformerParams = candidate.transformerParams;
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
raw: typeof candidate.raw === 'string' ? candidate.raw : '',
|
|
15
|
+
target: typeof candidate.target === 'string' ? candidate.target : '',
|
|
16
|
+
handle: typeof candidate.handle === 'string' ? candidate.handle : '',
|
|
17
|
+
selector: typeof candidate.selector === 'string' ? candidate.selector : '',
|
|
18
|
+
defaultValue: typeof candidate.defaultValue === 'string' ? candidate.defaultValue : '',
|
|
19
|
+
transformerId: typeof candidate.transformerId === 'string' ? candidate.transformerId : '',
|
|
20
|
+
transformerParams: transformerParams && typeof transformerParams === 'object'
|
|
21
|
+
? Object.fromEntries(Object.entries(transformerParams as Record<string, unknown>).map(([key, item]) => {
|
|
22
|
+
return [key, String(item ?? '')];
|
|
23
|
+
}))
|
|
24
|
+
: {},
|
|
25
|
+
isValid: candidate.isValid !== false,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getConditionNodes(root: Element): Element[] {
|
|
30
|
+
const nodes = Array.from(root.querySelectorAll(CONDITION_SELECTOR));
|
|
31
|
+
|
|
32
|
+
if (root.matches(CONDITION_SELECTOR)) {
|
|
33
|
+
return [root, ...nodes];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return nodes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function parseConditionSettings(node: Element): ParsedConditionSettings | null {
|
|
40
|
+
const raw = node.getAttribute('data-formie-conditions');
|
|
41
|
+
|
|
42
|
+
if (!raw) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const parsed = JSON.parse(raw) as Record<string, unknown>;
|
|
48
|
+
const conditions = Array.isArray(parsed.conditions)
|
|
49
|
+
? parsed.conditions.filter((condition): condition is ConditionDefinition => {
|
|
50
|
+
if (!condition || typeof condition !== 'object') {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const candidate = condition as Record<string, unknown>;
|
|
55
|
+
return typeof candidate.field === 'string' && typeof candidate.condition === 'string';
|
|
56
|
+
}).map((condition) => {
|
|
57
|
+
const candidate = condition as Record<string, unknown>;
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
field: condition.field,
|
|
61
|
+
source: parseConditionSource(candidate.source),
|
|
62
|
+
condition: condition.condition,
|
|
63
|
+
value: condition.value,
|
|
64
|
+
};
|
|
65
|
+
})
|
|
66
|
+
: [];
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
showRule: parsed.showRule === 'hide' ? 'hide' : 'show',
|
|
70
|
+
conditionRule: parsed.conditionRule === 'any' ? 'any' : 'all',
|
|
71
|
+
clearOnHide: parsed.clearOnHide !== false,
|
|
72
|
+
isNested: Boolean(parsed.isNested),
|
|
73
|
+
conditions,
|
|
74
|
+
};
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error('[formie] Invalid condition JSON.', error);
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|