@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,8 @@
|
|
|
1
|
+
import { n as definePassiveCaptchaModule } from "./api-DOfDzYC_.js";
|
|
2
|
+
//#region src/js/modules/captchas/snaptcha.ts
|
|
3
|
+
var snaptchaModule = definePassiveCaptchaModule({
|
|
4
|
+
id: "snaptcha",
|
|
5
|
+
defaultPlaceholderSelector: "[data-snaptcha-captcha-placeholder]"
|
|
6
|
+
});
|
|
7
|
+
//#endregion
|
|
8
|
+
export { snaptchaModule };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { t as definePaymentModule } from "./api-DE7LfK-R.js";
|
|
2
|
+
import { r as loadScriptAndEnsureGlobal } from "./scripts-BGD_iU_6.js";
|
|
3
|
+
//#region src/js/modules/payments/square.ts
|
|
4
|
+
var SCRIPT_ID = "FORMIE_SQUARE_SCRIPT";
|
|
5
|
+
var squareModule = definePaymentModule({
|
|
6
|
+
id: "square",
|
|
7
|
+
defaultRequiredInputSuffixes: ["squarePaymentId"],
|
|
8
|
+
load: async (ctx) => {
|
|
9
|
+
const { provider } = ctx.options;
|
|
10
|
+
const applicationId = provider.applicationId;
|
|
11
|
+
const locationId = provider.locationId;
|
|
12
|
+
if (!applicationId?.trim() || !locationId?.trim()) {
|
|
13
|
+
console.error("[formie] Missing applicationId or locationId for Square.");
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
await loadScriptAndEnsureGlobal("Square", {
|
|
17
|
+
id: SCRIPT_ID,
|
|
18
|
+
src: provider.environment === "sandbox" ? "https://sandbox.web.squarecdn.com/v1/square.js" : "https://web.squarecdn.com/v1/square.js"
|
|
19
|
+
});
|
|
20
|
+
return window.Square;
|
|
21
|
+
},
|
|
22
|
+
mount: async (args) => {
|
|
23
|
+
const { api, field, services, options } = args;
|
|
24
|
+
const provider = options.provider;
|
|
25
|
+
const placeholder = field.querySelector("[data-formie-square-button]");
|
|
26
|
+
if (!placeholder || !api) return null;
|
|
27
|
+
try {
|
|
28
|
+
const card = await api.payments(provider.applicationId || "", provider.locationId || "").card();
|
|
29
|
+
await card.attach(placeholder);
|
|
30
|
+
return card;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
services.addError(error instanceof Error ? error.message : "Unable to initialize payment.");
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
unmount: async () => {},
|
|
37
|
+
onBeforeAuthorize: async (args) => {
|
|
38
|
+
const { widget, services } = args;
|
|
39
|
+
if (!widget) {
|
|
40
|
+
services.addError("Square card is not ready.");
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const result = await widget.tokenize();
|
|
45
|
+
if (result.status === "OK" && result.token) {
|
|
46
|
+
services.updateInputs("squarePaymentId", result.token);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
services.addError(result.errors?.[0]?.message || "Tokenization failed.");
|
|
50
|
+
return false;
|
|
51
|
+
} catch {
|
|
52
|
+
services.addError("Payment tokenization failed. Please try again.");
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
onAfterSubmit: async ({ services }) => {
|
|
57
|
+
services.updateInputs("squarePaymentId", "");
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
//#endregion
|
|
61
|
+
export { squareModule };
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { s as getPaymentProviderActionEventName } from "./event-names-DamGPtXR.js";
|
|
2
|
+
import { t as definePaymentModule } from "./api-DE7LfK-R.js";
|
|
3
|
+
import { r as removeThemeClasses, t as addThemeClasses } from "./theme-classes-vSHpdCUO.js";
|
|
4
|
+
import { r as loadScriptAndEnsureGlobal } from "./scripts-BGD_iU_6.js";
|
|
5
|
+
import { t as ensureModuleStyles } from "./styles-BIh6g7V_.js";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/js/modules/payments/stripe.ts
|
|
8
|
+
ensureModuleStyles("stripe", ["@layer formie-theme{.formie-stripe-placeholder{justify-content:center;align-items:center;gap:var(--formie-space-2);width:100%;min-height:12rem;padding:var(--formie-space-4);border:var(--formie-border-width) solid var(--formie-color-border);border-radius:var(--formie-radius-sm);background:var(--formie-color-surface);color:var(--formie-color-text-muted);text-align:center;box-sizing:border-box;flex-direction:column;display:flex}.formie-stripe-placeholder[hidden]{display:none}}"]);
|
|
9
|
+
var SCRIPT_ID = "FORMIE_STRIPE_SCRIPT";
|
|
10
|
+
var CONFIRM_EVENT = getPaymentProviderActionEventName("stripe", "confirm");
|
|
11
|
+
var PLACEHOLDER_SELECTOR = "[data-formie-stripe-elements-placeholder]";
|
|
12
|
+
var ZERO_DECIMAL_CURRENCIES = new Set([
|
|
13
|
+
"BIF",
|
|
14
|
+
"CLP",
|
|
15
|
+
"DJF",
|
|
16
|
+
"GNF",
|
|
17
|
+
"JPY",
|
|
18
|
+
"KMF",
|
|
19
|
+
"KRW",
|
|
20
|
+
"MGA",
|
|
21
|
+
"PYG",
|
|
22
|
+
"RWF",
|
|
23
|
+
"UGX",
|
|
24
|
+
"VND",
|
|
25
|
+
"VUV",
|
|
26
|
+
"XAF",
|
|
27
|
+
"XOF",
|
|
28
|
+
"XPF"
|
|
29
|
+
]);
|
|
30
|
+
function toStripeSubunitAmount(amount, currency) {
|
|
31
|
+
if (ZERO_DECIMAL_CURRENCIES.has(currency.toUpperCase())) return Math.ceil(amount);
|
|
32
|
+
return Math.ceil(amount * 100);
|
|
33
|
+
}
|
|
34
|
+
function clearPlaceholderError(placeholder, themeSource) {
|
|
35
|
+
if (!placeholder) return;
|
|
36
|
+
removeThemeClasses(placeholder, themeSource, "fieldErrors", "fieldError");
|
|
37
|
+
placeholder.querySelectorAll("[data-payment-placeholder-error]").forEach((el) => {
|
|
38
|
+
removeThemeClasses(el, themeSource, "fieldError");
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function renderPlaceholderLoading(placeholder, themeSource, message = "Loading payment options...") {
|
|
42
|
+
if (!placeholder) return;
|
|
43
|
+
clearPlaceholderError(placeholder, themeSource);
|
|
44
|
+
placeholder.removeAttribute("hidden");
|
|
45
|
+
placeholder.innerHTML = "";
|
|
46
|
+
const spinner = document.createElement("div");
|
|
47
|
+
spinner.className = "formie-loading";
|
|
48
|
+
const text = document.createElement("div");
|
|
49
|
+
text.textContent = message;
|
|
50
|
+
placeholder.append(spinner, text);
|
|
51
|
+
}
|
|
52
|
+
function showPlaceholderMessage(placeholder, themeSource, message) {
|
|
53
|
+
if (!placeholder) return;
|
|
54
|
+
clearPlaceholderError(placeholder, themeSource);
|
|
55
|
+
placeholder.removeAttribute("hidden");
|
|
56
|
+
addThemeClasses(placeholder, themeSource, "fieldErrors");
|
|
57
|
+
placeholder.innerHTML = "";
|
|
58
|
+
const error = document.createElement("div");
|
|
59
|
+
error.setAttribute("data-payment-placeholder-error", "");
|
|
60
|
+
error.textContent = message;
|
|
61
|
+
addThemeClasses(error, themeSource, "fieldError");
|
|
62
|
+
placeholder.appendChild(error);
|
|
63
|
+
}
|
|
64
|
+
var stripeModule = definePaymentModule({
|
|
65
|
+
id: "stripe",
|
|
66
|
+
defaultRequiredInputSuffixes: ["stripePaymentIntentId"],
|
|
67
|
+
load: async (ctx) => {
|
|
68
|
+
const { provider } = ctx.options;
|
|
69
|
+
const publishableKey = provider.publishableKey;
|
|
70
|
+
if (!publishableKey?.trim()) {
|
|
71
|
+
console.error("[formie] Missing publishableKey for Stripe.");
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return (await loadScriptAndEnsureGlobal("Stripe", {
|
|
75
|
+
id: SCRIPT_ID,
|
|
76
|
+
src: "https://js.stripe.com/v3"
|
|
77
|
+
}))(publishableKey);
|
|
78
|
+
},
|
|
79
|
+
mount: async (args) => {
|
|
80
|
+
const { api, field, services, provider } = args;
|
|
81
|
+
const placeholder = field.querySelector("[data-formie-stripe-elements]");
|
|
82
|
+
const loadingPlaceholder = field.querySelector(PLACEHOLDER_SELECTOR);
|
|
83
|
+
const stripeField = field;
|
|
84
|
+
const themeSource = services.form || services.root;
|
|
85
|
+
if (!placeholder || !api) return null;
|
|
86
|
+
const initial = provider.initialPaymentInformation || {};
|
|
87
|
+
const dynamicHandles = [initial.amount, initial.currency].map((value) => String(value ?? "").trim()).filter((value, index) => {
|
|
88
|
+
return (index === 0 ? provider.amountType : provider.currencyType) === "dynamic" && value !== "";
|
|
89
|
+
});
|
|
90
|
+
const getResolvedPaymentInfo = () => {
|
|
91
|
+
const amountResult = services.resolveAmount({ value: initial.amount });
|
|
92
|
+
if (!amountResult.ok) return {
|
|
93
|
+
ok: false,
|
|
94
|
+
error: "error" in amountResult ? amountResult.error : "Provide a payment amount to proceed."
|
|
95
|
+
};
|
|
96
|
+
const currencyResult = services.resolveCurrency({ value: initial.currency });
|
|
97
|
+
if (!currencyResult.ok) return {
|
|
98
|
+
ok: false,
|
|
99
|
+
error: "error" in currencyResult ? currencyResult.error : "Provide a payment currency to proceed."
|
|
100
|
+
};
|
|
101
|
+
const currencyCode = currencyResult.value.toLowerCase();
|
|
102
|
+
const amountValue = provider.amountType === "dynamic" ? toStripeSubunitAmount(amountResult.value, currencyCode) : amountResult.value;
|
|
103
|
+
return {
|
|
104
|
+
ok: true,
|
|
105
|
+
value: {
|
|
106
|
+
...initial,
|
|
107
|
+
capture_method: "automatic",
|
|
108
|
+
mode: provider.paymentType === "subscription" ? "subscription" : "payment",
|
|
109
|
+
appearance: {},
|
|
110
|
+
amount: amountValue,
|
|
111
|
+
currency: currencyCode
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
const destroyWidget = () => {
|
|
116
|
+
try {
|
|
117
|
+
stripeField.__formieStripeWidget?.paymentElement?.destroy?.();
|
|
118
|
+
} catch (error) {}
|
|
119
|
+
stripeField.__formieStripeWidget = null;
|
|
120
|
+
stripeField.__formieStripeElements = void 0;
|
|
121
|
+
placeholder.innerHTML = "";
|
|
122
|
+
};
|
|
123
|
+
const evaluateAndRender = () => {
|
|
124
|
+
const resolved = getResolvedPaymentInfo();
|
|
125
|
+
if (!resolved.ok) {
|
|
126
|
+
destroyWidget();
|
|
127
|
+
showPlaceholderMessage(loadingPlaceholder, themeSource, "error" in resolved ? resolved.error : "Unable to resolve payment details.");
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
if (stripeField.__formieStripeWidget && stripeField.__formieStripeElements) {
|
|
132
|
+
stripeField.__formieStripeElements.update(resolved.value);
|
|
133
|
+
clearPlaceholderError(loadingPlaceholder, themeSource);
|
|
134
|
+
loadingPlaceholder?.setAttribute("hidden", "hidden");
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
renderPlaceholderLoading(loadingPlaceholder, themeSource);
|
|
138
|
+
const elements = api.elements(resolved.value);
|
|
139
|
+
const paymentElement = elements.create("payment", {});
|
|
140
|
+
paymentElement.mount(placeholder);
|
|
141
|
+
paymentElement.on?.("loaderror", (event) => {
|
|
142
|
+
const message = event?.error?.message || "Unable to load payment options.";
|
|
143
|
+
destroyWidget();
|
|
144
|
+
showPlaceholderMessage(loadingPlaceholder, themeSource, message);
|
|
145
|
+
});
|
|
146
|
+
paymentElement.on?.("ready", () => {
|
|
147
|
+
clearPlaceholderError(loadingPlaceholder, themeSource);
|
|
148
|
+
loadingPlaceholder?.setAttribute("hidden", "hidden");
|
|
149
|
+
});
|
|
150
|
+
stripeField.__formieStripeElements = elements;
|
|
151
|
+
stripeField.__formieStripeInstance = api;
|
|
152
|
+
stripeField.__formieStripeWidget = {
|
|
153
|
+
elements,
|
|
154
|
+
paymentElement
|
|
155
|
+
};
|
|
156
|
+
if (!paymentElement.on) {
|
|
157
|
+
clearPlaceholderError(loadingPlaceholder, themeSource);
|
|
158
|
+
loadingPlaceholder?.setAttribute("hidden", "hidden");
|
|
159
|
+
}
|
|
160
|
+
} catch (error) {
|
|
161
|
+
destroyWidget();
|
|
162
|
+
showPlaceholderMessage(loadingPlaceholder, themeSource, error instanceof Error ? error.message : "Unable to initialize Stripe payment element.");
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
stripeField.__formieStripeEvaluateAndRender = evaluateAndRender;
|
|
166
|
+
stripeField.__formieStripeDynamicUnbind?.();
|
|
167
|
+
if (dynamicHandles.length > 0) stripeField.__formieStripeDynamicUnbind = services.watchFieldValueChanges(dynamicHandles, () => {
|
|
168
|
+
evaluateAndRender();
|
|
169
|
+
}, 600);
|
|
170
|
+
evaluateAndRender();
|
|
171
|
+
return stripeField.__formieStripeWidget || null;
|
|
172
|
+
},
|
|
173
|
+
unmount: async (args) => {
|
|
174
|
+
args.widget?.paymentElement?.destroy();
|
|
175
|
+
const stripeField = args.field;
|
|
176
|
+
stripeField.__formieStripeWidget = null;
|
|
177
|
+
stripeField.__formieStripeElements = void 0;
|
|
178
|
+
stripeField.__formieStripeInstance = null;
|
|
179
|
+
stripeField.__formieStripeLastClientSecret = void 0;
|
|
180
|
+
stripeField.__formieStripeEvaluateAndRender = null;
|
|
181
|
+
stripeField.__formieStripeDynamicUnbind?.();
|
|
182
|
+
stripeField.__formieStripeDynamicUnbind = null;
|
|
183
|
+
},
|
|
184
|
+
onBeforeAuthorize: async (args) => {
|
|
185
|
+
const { widget, services, field } = args;
|
|
186
|
+
const stripeField = field;
|
|
187
|
+
let activeWidget = widget;
|
|
188
|
+
if (!activeWidget?.elements) {
|
|
189
|
+
stripeField.__formieStripeEvaluateAndRender?.();
|
|
190
|
+
activeWidget = stripeField.__formieStripeWidget || null;
|
|
191
|
+
}
|
|
192
|
+
if (!activeWidget?.elements) return false;
|
|
193
|
+
const result = await activeWidget.elements.submit();
|
|
194
|
+
if (result?.error) {
|
|
195
|
+
services.addError(result.error.message);
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
return true;
|
|
199
|
+
},
|
|
200
|
+
setup: async (ctx) => {
|
|
201
|
+
const { services, options } = ctx;
|
|
202
|
+
const provider = options.provider;
|
|
203
|
+
const field = ctx.target;
|
|
204
|
+
const handler = async (event) => {
|
|
205
|
+
try {
|
|
206
|
+
const data = event.detail?.data;
|
|
207
|
+
if (!data?.clientSecret) return;
|
|
208
|
+
if (field.__formieStripeConfirming) return;
|
|
209
|
+
if (field.__formieStripeLastClientSecret === data.clientSecret) return;
|
|
210
|
+
const elements = field.__formieStripeElements;
|
|
211
|
+
if (!elements) {
|
|
212
|
+
services.addError("Stripe elements not ready for 3DS.");
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const instance = field.__formieStripeInstance;
|
|
216
|
+
const publishableKey = provider.publishableKey;
|
|
217
|
+
if (!instance || !publishableKey) {
|
|
218
|
+
services.addError("Stripe is not initialized.");
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
field.__formieStripeConfirming = true;
|
|
222
|
+
const returnUrl = new URL(data.returnUrl || window.location.href);
|
|
223
|
+
returnUrl.searchParams.set("origin", window.location.href);
|
|
224
|
+
const result = await (data.type === "setup" ? instance.confirmSetup : instance.confirmPayment)({
|
|
225
|
+
elements,
|
|
226
|
+
clientSecret: data.clientSecret,
|
|
227
|
+
redirect: "if_required",
|
|
228
|
+
confirmParams: { return_url: returnUrl.toString() }
|
|
229
|
+
});
|
|
230
|
+
if (result?.error) {
|
|
231
|
+
services.releaseSubmitLoading();
|
|
232
|
+
services.addError(result.error.message);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (data.subscriptionId) services.updateInputs("stripeSubscriptionId", data.subscriptionId);
|
|
236
|
+
const pi = result && "paymentIntent" in result ? result.paymentIntent : null;
|
|
237
|
+
const si = result && "setupIntent" in result ? result.setupIntent : null;
|
|
238
|
+
if (pi?.id) services.updateInputs("stripePaymentIntentId", pi.id);
|
|
239
|
+
else if (si?.id) services.updateInputs("stripePaymentIntentId", si.id);
|
|
240
|
+
else {
|
|
241
|
+
services.releaseSubmitLoading();
|
|
242
|
+
services.addError("Stripe confirmation did not return an intent ID.");
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
field.__formieStripeLastClientSecret = data.clientSecret;
|
|
246
|
+
services.triggerSubmit();
|
|
247
|
+
} catch (error) {
|
|
248
|
+
services.releaseSubmitLoading();
|
|
249
|
+
services.addError(error instanceof Error ? error.message : "Unable to confirm Stripe payment.");
|
|
250
|
+
} finally {
|
|
251
|
+
field.__formieStripeConfirming = false;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
field.__formieStripeConfirmUnbind?.();
|
|
255
|
+
field.__formieStripeConfirmUnbind = services.events.onForm(CONFIRM_EVENT, handler);
|
|
256
|
+
return { destroy: () => {
|
|
257
|
+
field.__formieStripeConfirmUnbind?.();
|
|
258
|
+
field.__formieStripeConfirmUnbind = null;
|
|
259
|
+
} };
|
|
260
|
+
},
|
|
261
|
+
onAfterSubmit: async (args) => {
|
|
262
|
+
const stripeField = args.field;
|
|
263
|
+
if (args.result?.ok && !args.result?.nextPage) {
|
|
264
|
+
stripeField.__formieStripeWidget?.paymentElement?.destroy?.();
|
|
265
|
+
stripeField.__formieStripeWidget = null;
|
|
266
|
+
stripeField.__formieStripeElements = void 0;
|
|
267
|
+
args.services.updateInputs(["stripePaymentIntentId", "stripeSubscriptionId"], "");
|
|
268
|
+
stripeField.__formieStripeLastClientSecret = void 0;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
//#endregion
|
|
273
|
+
export { stripeModule };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/js/modules/styles.ts
|
|
2
|
+
var injectedModuleStyles = /* @__PURE__ */ new Set();
|
|
3
|
+
function ensureModuleStyles(moduleId, styles) {
|
|
4
|
+
if (typeof document === "undefined") return;
|
|
5
|
+
const styleId = `formie-module-style:${moduleId}`;
|
|
6
|
+
if (injectedModuleStyles.has(styleId) || document.querySelector(`style[data-formie-module-style="${moduleId}"]`)) {
|
|
7
|
+
injectedModuleStyles.add(styleId);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const cssText = styles.filter((style) => typeof style === "string" && style.trim().length > 0).join("\n");
|
|
11
|
+
if (!cssText) {
|
|
12
|
+
injectedModuleStyles.add(styleId);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const style = document.createElement("style");
|
|
16
|
+
style.setAttribute("data-formie-module-style", moduleId);
|
|
17
|
+
style.textContent = cssText;
|
|
18
|
+
document.head.appendChild(style);
|
|
19
|
+
injectedModuleStyles.add(styleId);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ensureModuleStyles as t };
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { t as createDebug } from "./debug-KnZeKYBI.js";
|
|
2
|
+
import { i as toggleThemeClasses } from "./theme-classes-vSHpdCUO.js";
|
|
3
|
+
import { n as requestText } from "./http-18nn97DZ.js";
|
|
4
|
+
import { t as debounce } from "./async-B3DUf1GZ.js";
|
|
5
|
+
import { t as ensureModuleStyles } from "./styles-BIh6g7V_.js";
|
|
6
|
+
import { r as getModuleFieldContainers, t as dispatchFieldEvent } from "./shared-DC6_1u8X.js";
|
|
7
|
+
//#region src/css/theme/fields/_summary.css?inline
|
|
8
|
+
var _summary_default = "@layer formie-theme{.formie-summary-container{padding:var(--formie-summary-padding);border:var(--formie-border-width) solid var(--formie-color-border);border-radius:var(--formie-radius-sm)}.formie-summary-heading{color:var(--formie-color-heading)}.formie-summary-blocks{gap:var(--formie-gap-summary);display:grid}.formie-summary-blocks[data-formie-loading=true]{min-height:calc(var(--formie-loading-size) + var(--formie-space-4));position:relative}.formie-summary-blocks[data-formie-loading=true]>*{opacity:0;pointer-events:none}.formie-summary-blocks[data-formie-loading=true]:before{content:\"\";background:var(--formie-color-bg);border-radius:inherit;z-index:1;display:block;position:absolute;inset:0}.formie-summary-blocks[data-formie-loading=true]:after{width:var(--formie-loading-size);height:var(--formie-loading-size);content:\"\";border:var(--formie-loading-border-width) solid var(--formie-loading-color);border-radius:var(--formie-radius-full);z-index:2;animation:formie-loading-spin var(--formie-loading-speed) linear infinite;border-top-color:#0000;border-right-color:#0000;display:block;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}}";
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/js/modules/fields/summary.ts
|
|
11
|
+
var BLOCKS_SELECTOR = "[data-formie-summary-blocks]";
|
|
12
|
+
var CONTAINER_SELECTOR = "[data-formie-summary-container]";
|
|
13
|
+
var SUMMARY_ACTION = "formie/fields/get-summary-html";
|
|
14
|
+
var MODULE_ID = "summary";
|
|
15
|
+
var debug = createDebug("fields", "summary");
|
|
16
|
+
ensureModuleStyles(MODULE_ID, [_summary_default]);
|
|
17
|
+
function getSummaryRequestUrl() {
|
|
18
|
+
const url = new URL(window.location.href);
|
|
19
|
+
url.hash = "";
|
|
20
|
+
return url.toString();
|
|
21
|
+
}
|
|
22
|
+
function getSummaryRequestState(field) {
|
|
23
|
+
return { accessToken: field.querySelector("[data-formie-summary-token]")?.value?.trim() || null };
|
|
24
|
+
}
|
|
25
|
+
async function requestSummaryHtml(form, state, signal) {
|
|
26
|
+
if (!state.accessToken) throw new Error("Summary field requires an access token.");
|
|
27
|
+
const formData = new FormData(form);
|
|
28
|
+
formData.set("action", SUMMARY_ACTION);
|
|
29
|
+
formData.set("accessToken", state.accessToken);
|
|
30
|
+
return requestText(getSummaryRequestUrl(), {
|
|
31
|
+
method: "POST",
|
|
32
|
+
body: formData,
|
|
33
|
+
signal,
|
|
34
|
+
headers: { Accept: "text/html" }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function initSummaryField(field, root) {
|
|
38
|
+
const form = field.closest("form");
|
|
39
|
+
if (!(form instanceof HTMLFormElement)) {
|
|
40
|
+
debug.warn("Missing form ancestor; skipping field.");
|
|
41
|
+
return () => {};
|
|
42
|
+
}
|
|
43
|
+
let hasFetched = false;
|
|
44
|
+
let isDirty = true;
|
|
45
|
+
let isVisible = false;
|
|
46
|
+
let dirtyVersion = 0;
|
|
47
|
+
let requestVersion = 0;
|
|
48
|
+
let activeRequest = null;
|
|
49
|
+
const getBlocks = () => {
|
|
50
|
+
const blocks = field.querySelector(BLOCKS_SELECTOR);
|
|
51
|
+
return blocks instanceof HTMLElement ? blocks : null;
|
|
52
|
+
};
|
|
53
|
+
const getContainer = () => {
|
|
54
|
+
const container = field.querySelector(CONTAINER_SELECTOR);
|
|
55
|
+
return container instanceof HTMLElement ? container : null;
|
|
56
|
+
};
|
|
57
|
+
const setLoadingState = (isLoading) => {
|
|
58
|
+
const blocks = getBlocks();
|
|
59
|
+
if (!blocks) return;
|
|
60
|
+
if (isLoading) {
|
|
61
|
+
blocks.setAttribute("data-formie-loading", "true");
|
|
62
|
+
blocks.setAttribute("aria-busy", "true");
|
|
63
|
+
toggleThemeClasses(blocks, form, "loading", true);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
blocks.removeAttribute("data-formie-loading");
|
|
67
|
+
blocks.removeAttribute("aria-busy");
|
|
68
|
+
toggleThemeClasses(blocks, form, "loading", false);
|
|
69
|
+
};
|
|
70
|
+
setLoadingState(!!getSummaryRequestState(field).accessToken);
|
|
71
|
+
const queueFetch = () => {
|
|
72
|
+
if (!isVisible || hasFetched && !isDirty) return;
|
|
73
|
+
debug.log("Queueing fetch.");
|
|
74
|
+
fetchSummary();
|
|
75
|
+
};
|
|
76
|
+
const fetchSummary = debounce(async () => {
|
|
77
|
+
const state = getSummaryRequestState(field);
|
|
78
|
+
if (!getBlocks() || !state.accessToken) {
|
|
79
|
+
debug.warn("Missing state for fetch.", state);
|
|
80
|
+
setLoadingState(false);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
requestVersion += 1;
|
|
84
|
+
const currentRequestVersion = requestVersion;
|
|
85
|
+
const requestDirtyVersion = dirtyVersion;
|
|
86
|
+
activeRequest?.abort();
|
|
87
|
+
activeRequest = new AbortController();
|
|
88
|
+
setLoadingState(true);
|
|
89
|
+
try {
|
|
90
|
+
const html = await requestSummaryHtml(form, state, activeRequest.signal);
|
|
91
|
+
if (currentRequestVersion !== requestVersion) return;
|
|
92
|
+
const container = getContainer();
|
|
93
|
+
const nextMarkup = document.createElement("template");
|
|
94
|
+
nextMarkup.innerHTML = html.trim();
|
|
95
|
+
const nextContainer = nextMarkup.content.querySelector(CONTAINER_SELECTOR);
|
|
96
|
+
if (container && nextContainer instanceof HTMLElement) container.replaceWith(nextContainer);
|
|
97
|
+
else if (container) container.innerHTML = html;
|
|
98
|
+
hasFetched = true;
|
|
99
|
+
isDirty = dirtyVersion !== requestDirtyVersion;
|
|
100
|
+
debug.log("Fetch complete.", {
|
|
101
|
+
isDirty,
|
|
102
|
+
dirtyVersion,
|
|
103
|
+
requestVersion: currentRequestVersion
|
|
104
|
+
});
|
|
105
|
+
dispatchFieldEvent(field, MODULE_ID, "fetch-summary", {
|
|
106
|
+
summary: field,
|
|
107
|
+
html
|
|
108
|
+
});
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
111
|
+
debug.log("Fetch aborted.");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
console.error("[formie] Failed to load summary field HTML.", error);
|
|
115
|
+
} finally {
|
|
116
|
+
if (currentRequestVersion === requestVersion) {
|
|
117
|
+
setLoadingState(false);
|
|
118
|
+
activeRequest = null;
|
|
119
|
+
if (isDirty) queueFetch();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}, 300);
|
|
123
|
+
const markDirty = (event) => {
|
|
124
|
+
const target = event?.target;
|
|
125
|
+
if (target instanceof Node && field.contains(target)) return;
|
|
126
|
+
isDirty = true;
|
|
127
|
+
dirtyVersion += 1;
|
|
128
|
+
debug.log("Marked dirty.", { dirtyVersion });
|
|
129
|
+
};
|
|
130
|
+
const handleFieldMutation = (event) => {
|
|
131
|
+
markDirty(event);
|
|
132
|
+
queueFetch();
|
|
133
|
+
};
|
|
134
|
+
const handleSubmitResult = () => {
|
|
135
|
+
isDirty = true;
|
|
136
|
+
debug.log("Submit result received; refreshing.");
|
|
137
|
+
queueFetch();
|
|
138
|
+
};
|
|
139
|
+
const handlePageNavigate = () => {
|
|
140
|
+
isDirty = true;
|
|
141
|
+
debug.log("Page navigation received; refreshing.");
|
|
142
|
+
queueFetch();
|
|
143
|
+
};
|
|
144
|
+
const observer = new IntersectionObserver((entries) => {
|
|
145
|
+
isVisible = !!entries[0]?.isIntersecting;
|
|
146
|
+
if (!isVisible) return;
|
|
147
|
+
debug.log("Field became visible.");
|
|
148
|
+
dispatchFieldEvent(field, MODULE_ID, "field-visible", { summary: field });
|
|
149
|
+
queueFetch();
|
|
150
|
+
}, {
|
|
151
|
+
root: form,
|
|
152
|
+
rootMargin: "50px"
|
|
153
|
+
});
|
|
154
|
+
observer.observe(field);
|
|
155
|
+
form.addEventListener("input", handleFieldMutation);
|
|
156
|
+
form.addEventListener("change", handleFieldMutation);
|
|
157
|
+
root.addEventListener("formie:page:navigate:after", handlePageNavigate);
|
|
158
|
+
root.addEventListener("formie:submit:result", handleSubmitResult);
|
|
159
|
+
return () => {
|
|
160
|
+
activeRequest?.abort();
|
|
161
|
+
observer.disconnect();
|
|
162
|
+
form.removeEventListener("input", handleFieldMutation);
|
|
163
|
+
form.removeEventListener("change", handleFieldMutation);
|
|
164
|
+
root.removeEventListener("formie:page:navigate:after", handlePageNavigate);
|
|
165
|
+
root.removeEventListener("formie:submit:result", handleSubmitResult);
|
|
166
|
+
debug.log("Field destroyed.");
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
var summaryModule = {
|
|
170
|
+
id: MODULE_ID,
|
|
171
|
+
kind: "field",
|
|
172
|
+
match: (ctx) => {
|
|
173
|
+
return !!ctx.target.querySelector(BLOCKS_SELECTOR);
|
|
174
|
+
},
|
|
175
|
+
setup: async (ctx) => {
|
|
176
|
+
const cleanups = getModuleFieldContainers(ctx).map((field) => {
|
|
177
|
+
return initSummaryField(field, ctx.root);
|
|
178
|
+
});
|
|
179
|
+
debug.log("Module setup.", { fieldCount: cleanups.length });
|
|
180
|
+
await ctx.emit("formie:module:summary:init", { count: cleanups.length });
|
|
181
|
+
return { destroy: () => {
|
|
182
|
+
cleanups.forEach((cleanup) => {
|
|
183
|
+
cleanup();
|
|
184
|
+
});
|
|
185
|
+
debug.log("Module destroy.", { fieldCount: cleanups.length });
|
|
186
|
+
ctx.emit("formie:module:summary:destroy", {});
|
|
187
|
+
} };
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
//#endregion
|
|
191
|
+
export { summaryModule };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { n as sleep } from "./async-B3DUf1GZ.js";
|
|
2
|
+
import { t as ensureModuleStyles } from "./styles-BIh6g7V_.js";
|
|
3
|
+
import { a as getTemplateSource, o as getTemplateSourceHtml, t as dispatchFieldEvent } from "./shared-DC6_1u8X.js";
|
|
4
|
+
//#region src/css/theme/fields/_table.css?inline
|
|
5
|
+
var _table_default = "@layer formie-theme{.formie-table-wrapper{-webkit-overflow-scrolling:touch;max-width:100%;overflow:auto hidden}.formie-table{width:var(--formie-table-width);margin-bottom:var(--formie-table-margin-bottom);border-collapse:var(--formie-table-border-collapse)}.formie-table th{text-align:var(--formie-table-th-text-align);font-size:var(--formie-table-th-font-size);font-weight:var(--formie-table-th-font-weight);color:var(--formie-table-th-color,var(--formie-gray-500))}.formie-table th,.formie-table td{padding:var(--formie-table-row-padding);vertical-align:top}.formie-table th:first-child,.formie-table td:first-child{padding-left:0}.formie-table th:last-child,.formie-table td:last-child{padding-right:0}.formie-table [data-col-remove]{width:calc(var(--formie-button-icon-button-size) + (var(--formie-table-row-padding) * 2));min-width:calc(var(--formie-button-icon-button-size) + (var(--formie-table-row-padding) * 2));white-space:nowrap;text-align:center;vertical-align:middle}.formie-table [data-formie-table-column-type=checkbox]{text-align:center;vertical-align:middle}.formie-table [data-formie-table-column-type=checkbox] .formie-checkbox-option{width:100%;min-height:var(--formie-check-size);justify-content:center;align-items:center;margin:0;display:flex}.formie-table [data-formie-table-column-type=checkbox] .formie-checkbox-option-label{width:var(--formie-check-size);min-width:var(--formie-check-size);height:var(--formie-check-size);margin:0 auto;padding-left:0;font-size:0;line-height:0;display:block}.formie-table [data-formie-table-column-type=checkbox] .formie-checkbox-option-label:before{position:static}.formie-table-color-input{min-width:4rem;padding:var(--formie-space-1)}.formie-table-multiline-input{min-height:calc(var(--formie-control-height) + var(--formie-space-2))}.formie-table-remove-button{vertical-align:middle;display:inline-flex}.formie-button.formie-table-add-button{width:auto;max-width:100%;padding-left:var(--formie-table-add-button-padding-left);justify-content:center;justify-self:start;align-items:center;display:inline-flex;position:relative}.formie-button.formie-table-add-button:before{content:\"\";width:var(--formie-table-add-button-width);height:var(--formie-table-add-button-height);left:var(--formie-table-add-button-left);-webkit-mask-image:var(--formie-table-add-button-icon-mask);-webkit-mask-image:var(--formie-table-add-button-icon-mask);mask-image:var(--formie-table-add-button-icon-mask);background-color:currentColor;display:block;position:absolute;top:50%;transform:translateY(-50%);-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}}";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/js/modules/fields/table.ts
|
|
8
|
+
var FIELD_SELECTOR = "[data-formie-table-field-layout]";
|
|
9
|
+
var TABLE_SELECTOR = "[data-formie-table]";
|
|
10
|
+
var TABLE_BODY_SELECTOR = "[data-formie-table-body]";
|
|
11
|
+
var ROW_SELECTOR = "[data-formie-table-row]";
|
|
12
|
+
var ADD_SELECTOR = "[data-formie-table-add]";
|
|
13
|
+
var REMOVE_SELECTOR = "[data-formie-table-remove]";
|
|
14
|
+
var TEMPLATE_ID_ATTR = "data-formie-template-id";
|
|
15
|
+
var ROW_ID_ATTR = "data-formie-table-row-id";
|
|
16
|
+
var MODULE_ID = "table";
|
|
17
|
+
ensureModuleStyles(MODULE_ID, [_table_default]);
|
|
18
|
+
function getTemplate(field, templateId) {
|
|
19
|
+
return getTemplateSource(field, templateId);
|
|
20
|
+
}
|
|
21
|
+
function getRowCount(field) {
|
|
22
|
+
return field.querySelectorAll(ROW_SELECTOR).length;
|
|
23
|
+
}
|
|
24
|
+
function getNextRowId(field) {
|
|
25
|
+
return Array.from(field.querySelectorAll(ROW_SELECTOR)).reduce((max, row) => {
|
|
26
|
+
const current = parseInt(row.getAttribute(ROW_ID_ATTR) || "", 10);
|
|
27
|
+
return Number.isNaN(current) ? max : Math.max(max, current + 1);
|
|
28
|
+
}, 0);
|
|
29
|
+
}
|
|
30
|
+
function syncAddButton(addButton, rowCount) {
|
|
31
|
+
if (!addButton) return;
|
|
32
|
+
const maxRows = parseInt(addButton.getAttribute("data-formie-max-rows") || "", 10);
|
|
33
|
+
addButton.disabled = maxRows > 0 && rowCount >= maxRows;
|
|
34
|
+
}
|
|
35
|
+
function bindTableField(field, options) {
|
|
36
|
+
const table = field.querySelector(TABLE_SELECTOR);
|
|
37
|
+
const tbody = field.querySelector(TABLE_BODY_SELECTOR);
|
|
38
|
+
const addButton = field.querySelector(ADD_SELECTOR);
|
|
39
|
+
if (!(table instanceof HTMLElement) || !(tbody instanceof HTMLElement)) return () => {};
|
|
40
|
+
const removeHandlers = /* @__PURE__ */ new Map();
|
|
41
|
+
let rowCounter = getNextRowId(field);
|
|
42
|
+
const bindRemoveButtons = () => {
|
|
43
|
+
field.querySelectorAll(REMOVE_SELECTOR).forEach((button) => {
|
|
44
|
+
if (!(button instanceof HTMLElement) || removeHandlers.has(button)) return;
|
|
45
|
+
const handler = (event) => {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
const row = button.closest(ROW_SELECTOR);
|
|
48
|
+
if (!(row instanceof HTMLElement)) return;
|
|
49
|
+
const minRows = parseInt((addButton instanceof HTMLButtonElement ? addButton.getAttribute("data-formie-min-rows") : "") || "", 10);
|
|
50
|
+
if (minRows > 0 && getRowCount(field) <= minRows) return;
|
|
51
|
+
row.remove();
|
|
52
|
+
syncAddButton(addButton instanceof HTMLButtonElement ? addButton : null, getRowCount(field));
|
|
53
|
+
dispatchFieldEvent(field, MODULE_ID, "remove", {
|
|
54
|
+
table: field,
|
|
55
|
+
row
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
button.addEventListener("click", handler);
|
|
59
|
+
removeHandlers.set(button, handler);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const addRow = async () => {
|
|
63
|
+
if (options.static || !(addButton instanceof HTMLButtonElement)) return;
|
|
64
|
+
if (!addButton.getAttribute("data-formie-table-add")) return;
|
|
65
|
+
const templateId = addButton.getAttribute(TEMPLATE_ID_ATTR) || field.getAttribute(TEMPLATE_ID_ATTR);
|
|
66
|
+
const maxRows = parseInt(addButton.getAttribute("data-formie-max-rows") || "", 10);
|
|
67
|
+
if (maxRows > 0 && getRowCount(field) >= maxRows) return;
|
|
68
|
+
const template = getTemplate(field, templateId);
|
|
69
|
+
if (!template) return;
|
|
70
|
+
const html = getTemplateSourceHtml(template).replaceAll("__ROW__", String(rowCounter++));
|
|
71
|
+
const row = document.createElement("tr");
|
|
72
|
+
row.setAttribute("data-formie-table-row", "true");
|
|
73
|
+
row.setAttribute(ROW_ID_ATTR, String(rowCounter - 1));
|
|
74
|
+
row.innerHTML = html;
|
|
75
|
+
tbody.appendChild(row);
|
|
76
|
+
await sleep(50);
|
|
77
|
+
bindRemoveButtons();
|
|
78
|
+
syncAddButton(addButton, getRowCount(field));
|
|
79
|
+
dispatchFieldEvent(field, MODULE_ID, "append", {
|
|
80
|
+
table: field,
|
|
81
|
+
row
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const addHandler = (event) => {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
addRow();
|
|
87
|
+
};
|
|
88
|
+
if (addButton instanceof HTMLButtonElement && !options.static) addButton.addEventListener("click", addHandler);
|
|
89
|
+
bindRemoveButtons();
|
|
90
|
+
syncAddButton(addButton instanceof HTMLButtonElement ? addButton : null, getRowCount(field));
|
|
91
|
+
dispatchFieldEvent(field, MODULE_ID, "init", { table: field });
|
|
92
|
+
return () => {
|
|
93
|
+
if (addButton instanceof HTMLButtonElement) addButton.removeEventListener("click", addHandler);
|
|
94
|
+
removeHandlers.forEach((handler, button) => {
|
|
95
|
+
button.removeEventListener("click", handler);
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
var tableModule = {
|
|
100
|
+
id: MODULE_ID,
|
|
101
|
+
kind: "field",
|
|
102
|
+
match: (ctx) => {
|
|
103
|
+
return ctx.target instanceof HTMLElement && (ctx.target.matches(FIELD_SELECTOR) || !!ctx.target.querySelector(FIELD_SELECTOR));
|
|
104
|
+
},
|
|
105
|
+
setup: async (ctx) => {
|
|
106
|
+
const options = ctx.options || {};
|
|
107
|
+
if (!(ctx.target instanceof HTMLElement)) return;
|
|
108
|
+
const fields = ctx.target.matches(FIELD_SELECTOR) ? [ctx.target] : Array.from(ctx.target.querySelectorAll(FIELD_SELECTOR)).filter((field) => {
|
|
109
|
+
return field instanceof HTMLElement;
|
|
110
|
+
});
|
|
111
|
+
const destroyBindings = fields.map((field) => {
|
|
112
|
+
return bindTableField(field, options);
|
|
113
|
+
});
|
|
114
|
+
await ctx.emit("formie:module:table:init", { count: fields.length });
|
|
115
|
+
return { destroy: () => {
|
|
116
|
+
destroyBindings.forEach((destroyBinding) => {
|
|
117
|
+
destroyBinding();
|
|
118
|
+
});
|
|
119
|
+
ctx.emit("formie:module:table:destroy", {});
|
|
120
|
+
} };
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
//#endregion
|
|
124
|
+
export { tableModule };
|