@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,765 @@
|
|
|
1
|
+
import { t as ensureModuleStyles } from "./styles-BIh6g7V_.js";
|
|
2
|
+
import { r as getModuleFieldContainers, t as dispatchFieldEvent } from "./shared-DC6_1u8X.js";
|
|
3
|
+
//#region ../../node_modules/signature_pad/dist/signature_pad.js
|
|
4
|
+
/*!
|
|
5
|
+
* Signature Pad v5.1.3 | https://github.com/szimek/signature_pad
|
|
6
|
+
* (c) 2025 Szymon Nowak | Released under the MIT license
|
|
7
|
+
*/
|
|
8
|
+
var Point = class {
|
|
9
|
+
x;
|
|
10
|
+
y;
|
|
11
|
+
pressure;
|
|
12
|
+
time;
|
|
13
|
+
constructor(x, y, pressure, time) {
|
|
14
|
+
if (isNaN(x) || isNaN(y)) throw new Error(`Point is invalid: (${x}, ${y})`);
|
|
15
|
+
this.x = +x;
|
|
16
|
+
this.y = +y;
|
|
17
|
+
this.pressure = pressure || 0;
|
|
18
|
+
this.time = time || Date.now();
|
|
19
|
+
}
|
|
20
|
+
distanceTo(start) {
|
|
21
|
+
return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
|
|
22
|
+
}
|
|
23
|
+
equals(other) {
|
|
24
|
+
return this.x === other.x && this.y === other.y && this.pressure === other.pressure && this.time === other.time;
|
|
25
|
+
}
|
|
26
|
+
velocityFrom(start) {
|
|
27
|
+
return this.time !== start.time ? this.distanceTo(start) / (this.time - start.time) : 0;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var Bezier = class _Bezier {
|
|
31
|
+
constructor(startPoint, control2, control1, endPoint, startWidth, endWidth) {
|
|
32
|
+
this.startPoint = startPoint;
|
|
33
|
+
this.control2 = control2;
|
|
34
|
+
this.control1 = control1;
|
|
35
|
+
this.endPoint = endPoint;
|
|
36
|
+
this.startWidth = startWidth;
|
|
37
|
+
this.endWidth = endWidth;
|
|
38
|
+
}
|
|
39
|
+
static fromPoints(points, widths) {
|
|
40
|
+
const c2 = this.calculateControlPoints(points[0], points[1], points[2]).c2;
|
|
41
|
+
const c3 = this.calculateControlPoints(points[1], points[2], points[3]).c1;
|
|
42
|
+
return new _Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
|
|
43
|
+
}
|
|
44
|
+
static calculateControlPoints(s1, s2, s3) {
|
|
45
|
+
const dx1 = s1.x - s2.x;
|
|
46
|
+
const dy1 = s1.y - s2.y;
|
|
47
|
+
const dx2 = s2.x - s3.x;
|
|
48
|
+
const dy2 = s2.y - s3.y;
|
|
49
|
+
const m1 = {
|
|
50
|
+
x: (s1.x + s2.x) / 2,
|
|
51
|
+
y: (s1.y + s2.y) / 2
|
|
52
|
+
};
|
|
53
|
+
const m2 = {
|
|
54
|
+
x: (s2.x + s3.x) / 2,
|
|
55
|
+
y: (s2.y + s3.y) / 2
|
|
56
|
+
};
|
|
57
|
+
const l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
|
|
58
|
+
const l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
|
59
|
+
const dxm = m1.x - m2.x;
|
|
60
|
+
const dym = m1.y - m2.y;
|
|
61
|
+
const k = l1 + l2 == 0 ? 0 : l2 / (l1 + l2);
|
|
62
|
+
const cm = {
|
|
63
|
+
x: m2.x + dxm * k,
|
|
64
|
+
y: m2.y + dym * k
|
|
65
|
+
};
|
|
66
|
+
const tx = s2.x - cm.x;
|
|
67
|
+
const ty = s2.y - cm.y;
|
|
68
|
+
return {
|
|
69
|
+
c1: new Point(m1.x + tx, m1.y + ty),
|
|
70
|
+
c2: new Point(m2.x + tx, m2.y + ty)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
length() {
|
|
74
|
+
const steps = 10;
|
|
75
|
+
let length = 0;
|
|
76
|
+
let px;
|
|
77
|
+
let py;
|
|
78
|
+
for (let i = 0; i <= steps; i += 1) {
|
|
79
|
+
const t = i / steps;
|
|
80
|
+
const cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
|
|
81
|
+
const cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
|
|
82
|
+
if (i > 0) {
|
|
83
|
+
const xdiff = cx - px;
|
|
84
|
+
const ydiff = cy - py;
|
|
85
|
+
length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
|
|
86
|
+
}
|
|
87
|
+
px = cx;
|
|
88
|
+
py = cy;
|
|
89
|
+
}
|
|
90
|
+
return length;
|
|
91
|
+
}
|
|
92
|
+
point(t, start, c1, c2, end) {
|
|
93
|
+
return start * (1 - t) * (1 - t) * (1 - t) + 3 * c1 * (1 - t) * (1 - t) * t + 3 * c2 * (1 - t) * t * t + end * t * t * t;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var SignatureEventTarget = class {
|
|
97
|
+
_et;
|
|
98
|
+
constructor() {
|
|
99
|
+
try {
|
|
100
|
+
this._et = new EventTarget();
|
|
101
|
+
} catch {
|
|
102
|
+
this._et = document;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
addEventListener(type, listener, options) {
|
|
106
|
+
this._et.addEventListener(type, listener, options);
|
|
107
|
+
}
|
|
108
|
+
dispatchEvent(event) {
|
|
109
|
+
return this._et.dispatchEvent(event);
|
|
110
|
+
}
|
|
111
|
+
removeEventListener(type, callback, options) {
|
|
112
|
+
this._et.removeEventListener(type, callback, options);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
function throttle(fn, wait = 250) {
|
|
116
|
+
let previous = 0;
|
|
117
|
+
let timeout = null;
|
|
118
|
+
let result;
|
|
119
|
+
let storedContext;
|
|
120
|
+
let storedArgs;
|
|
121
|
+
const later = () => {
|
|
122
|
+
previous = Date.now();
|
|
123
|
+
timeout = null;
|
|
124
|
+
result = fn.apply(storedContext, storedArgs);
|
|
125
|
+
if (!timeout) {
|
|
126
|
+
storedContext = null;
|
|
127
|
+
storedArgs = [];
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
return function wrapper(...args) {
|
|
131
|
+
const now = Date.now();
|
|
132
|
+
const remaining = wait - (now - previous);
|
|
133
|
+
storedContext = this;
|
|
134
|
+
storedArgs = args;
|
|
135
|
+
if (remaining <= 0 || remaining > wait) {
|
|
136
|
+
if (timeout) {
|
|
137
|
+
clearTimeout(timeout);
|
|
138
|
+
timeout = null;
|
|
139
|
+
}
|
|
140
|
+
previous = now;
|
|
141
|
+
result = fn.apply(storedContext, storedArgs);
|
|
142
|
+
if (!timeout) {
|
|
143
|
+
storedContext = null;
|
|
144
|
+
storedArgs = [];
|
|
145
|
+
}
|
|
146
|
+
} else if (!timeout) timeout = window.setTimeout(later, remaining);
|
|
147
|
+
return result;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
var SignaturePad = class _SignaturePad extends SignatureEventTarget {
|
|
151
|
+
constructor(canvas, options = {}) {
|
|
152
|
+
super();
|
|
153
|
+
this.canvas = canvas;
|
|
154
|
+
this.velocityFilterWeight = options.velocityFilterWeight || .7;
|
|
155
|
+
this.minWidth = options.minWidth || .5;
|
|
156
|
+
this.maxWidth = options.maxWidth || 2.5;
|
|
157
|
+
this.throttle = options.throttle ?? 16;
|
|
158
|
+
this.minDistance = options.minDistance ?? 5;
|
|
159
|
+
this.dotSize = options.dotSize || 0;
|
|
160
|
+
this.penColor = options.penColor || "black";
|
|
161
|
+
this.backgroundColor = options.backgroundColor || "rgba(0,0,0,0)";
|
|
162
|
+
this.compositeOperation = options.compositeOperation || "source-over";
|
|
163
|
+
this.canvasContextOptions = options.canvasContextOptions ?? {};
|
|
164
|
+
this._strokeMoveUpdate = this.throttle ? throttle(_SignaturePad.prototype._strokeUpdate, this.throttle) : _SignaturePad.prototype._strokeUpdate;
|
|
165
|
+
this._handleMouseDown = this._handleMouseDown.bind(this);
|
|
166
|
+
this._handleMouseMove = this._handleMouseMove.bind(this);
|
|
167
|
+
this._handleMouseUp = this._handleMouseUp.bind(this);
|
|
168
|
+
this._handleTouchStart = this._handleTouchStart.bind(this);
|
|
169
|
+
this._handleTouchMove = this._handleTouchMove.bind(this);
|
|
170
|
+
this._handleTouchEnd = this._handleTouchEnd.bind(this);
|
|
171
|
+
this._handlePointerDown = this._handlePointerDown.bind(this);
|
|
172
|
+
this._handlePointerMove = this._handlePointerMove.bind(this);
|
|
173
|
+
this._handlePointerUp = this._handlePointerUp.bind(this);
|
|
174
|
+
this._handlePointerCancel = this._handlePointerCancel.bind(this);
|
|
175
|
+
this._handleTouchCancel = this._handleTouchCancel.bind(this);
|
|
176
|
+
this._ctx = canvas.getContext("2d", this.canvasContextOptions);
|
|
177
|
+
this.clear();
|
|
178
|
+
this.on();
|
|
179
|
+
}
|
|
180
|
+
dotSize;
|
|
181
|
+
minWidth;
|
|
182
|
+
maxWidth;
|
|
183
|
+
penColor;
|
|
184
|
+
minDistance;
|
|
185
|
+
velocityFilterWeight;
|
|
186
|
+
compositeOperation;
|
|
187
|
+
backgroundColor;
|
|
188
|
+
throttle;
|
|
189
|
+
canvasContextOptions;
|
|
190
|
+
_ctx;
|
|
191
|
+
_drawingStroke = false;
|
|
192
|
+
_isEmpty = true;
|
|
193
|
+
_dataUrl;
|
|
194
|
+
_dataUrlOptions;
|
|
195
|
+
_lastPoints = [];
|
|
196
|
+
_data = [];
|
|
197
|
+
_lastVelocity = 0;
|
|
198
|
+
_lastWidth = 0;
|
|
199
|
+
_strokeMoveUpdate;
|
|
200
|
+
_strokePointerId;
|
|
201
|
+
clear() {
|
|
202
|
+
const { _ctx: ctx, canvas } = this;
|
|
203
|
+
ctx.fillStyle = this.backgroundColor;
|
|
204
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
205
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
206
|
+
this._data = [];
|
|
207
|
+
this._reset(this._getPointGroupOptions());
|
|
208
|
+
this._isEmpty = true;
|
|
209
|
+
this._dataUrl = void 0;
|
|
210
|
+
this._dataUrlOptions = void 0;
|
|
211
|
+
this._strokePointerId = void 0;
|
|
212
|
+
}
|
|
213
|
+
redraw() {
|
|
214
|
+
const data = this._data;
|
|
215
|
+
const dataUrl = this._dataUrl;
|
|
216
|
+
const dataUrlOptions = this._dataUrlOptions;
|
|
217
|
+
this.clear();
|
|
218
|
+
if (dataUrl) this.fromDataURL(dataUrl, dataUrlOptions);
|
|
219
|
+
this.fromData(data, { clear: false });
|
|
220
|
+
}
|
|
221
|
+
fromDataURL(dataUrl, options = {}) {
|
|
222
|
+
return new Promise((resolve, reject) => {
|
|
223
|
+
const image = new Image();
|
|
224
|
+
const ratio = options.ratio || window.devicePixelRatio || 1;
|
|
225
|
+
const width = options.width || this.canvas.width / ratio;
|
|
226
|
+
const height = options.height || this.canvas.height / ratio;
|
|
227
|
+
const xOffset = options.xOffset || 0;
|
|
228
|
+
const yOffset = options.yOffset || 0;
|
|
229
|
+
this._reset(this._getPointGroupOptions());
|
|
230
|
+
image.onload = () => {
|
|
231
|
+
this._ctx.drawImage(image, xOffset, yOffset, width, height);
|
|
232
|
+
resolve();
|
|
233
|
+
};
|
|
234
|
+
image.onerror = (error) => {
|
|
235
|
+
reject(error);
|
|
236
|
+
};
|
|
237
|
+
image.crossOrigin = "anonymous";
|
|
238
|
+
image.src = dataUrl;
|
|
239
|
+
this._isEmpty = false;
|
|
240
|
+
this._dataUrl = dataUrl;
|
|
241
|
+
this._dataUrlOptions = { ...options };
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
toDataURL(type = "image/png", encoderOptions) {
|
|
245
|
+
switch (type) {
|
|
246
|
+
case "image/svg+xml":
|
|
247
|
+
if (typeof encoderOptions !== "object") encoderOptions = void 0;
|
|
248
|
+
return `data:image/svg+xml;base64,${btoa(this.toSVG(encoderOptions))}`;
|
|
249
|
+
default:
|
|
250
|
+
if (typeof encoderOptions !== "number") encoderOptions = void 0;
|
|
251
|
+
return this.canvas.toDataURL(type, encoderOptions);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
on() {
|
|
255
|
+
this.canvas.style.touchAction = "none";
|
|
256
|
+
this.canvas.style.msTouchAction = "none";
|
|
257
|
+
this.canvas.style.userSelect = "none";
|
|
258
|
+
this.canvas.style.webkitUserSelect = "none";
|
|
259
|
+
const isIOS = /Macintosh/.test(navigator.userAgent) && "ontouchstart" in document;
|
|
260
|
+
if (window.PointerEvent && !isIOS) this._handlePointerEvents();
|
|
261
|
+
else {
|
|
262
|
+
this._handleMouseEvents();
|
|
263
|
+
if ("ontouchstart" in window) this._handleTouchEvents();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
off() {
|
|
267
|
+
this.canvas.style.touchAction = "auto";
|
|
268
|
+
this.canvas.style.msTouchAction = "auto";
|
|
269
|
+
this.canvas.style.userSelect = "auto";
|
|
270
|
+
this.canvas.style.webkitUserSelect = "auto";
|
|
271
|
+
this.canvas.removeEventListener("pointerdown", this._handlePointerDown);
|
|
272
|
+
this.canvas.removeEventListener("mousedown", this._handleMouseDown);
|
|
273
|
+
this.canvas.removeEventListener("touchstart", this._handleTouchStart);
|
|
274
|
+
this._removeMoveUpEventListeners();
|
|
275
|
+
}
|
|
276
|
+
_getListenerFunctions() {
|
|
277
|
+
const canvasWindow = window.document === this.canvas.ownerDocument ? window : this.canvas.ownerDocument.defaultView ?? this.canvas.ownerDocument;
|
|
278
|
+
return {
|
|
279
|
+
addEventListener: canvasWindow.addEventListener.bind(canvasWindow),
|
|
280
|
+
removeEventListener: canvasWindow.removeEventListener.bind(canvasWindow)
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
_removeMoveUpEventListeners() {
|
|
284
|
+
const { removeEventListener } = this._getListenerFunctions();
|
|
285
|
+
removeEventListener("pointermove", this._handlePointerMove);
|
|
286
|
+
removeEventListener("pointerup", this._handlePointerUp);
|
|
287
|
+
removeEventListener("pointercancel", this._handlePointerCancel);
|
|
288
|
+
removeEventListener("mousemove", this._handleMouseMove);
|
|
289
|
+
removeEventListener("mouseup", this._handleMouseUp);
|
|
290
|
+
removeEventListener("touchmove", this._handleTouchMove);
|
|
291
|
+
removeEventListener("touchend", this._handleTouchEnd);
|
|
292
|
+
removeEventListener("touchcancel", this._handleTouchCancel);
|
|
293
|
+
}
|
|
294
|
+
isEmpty() {
|
|
295
|
+
return this._isEmpty;
|
|
296
|
+
}
|
|
297
|
+
fromData(pointGroups, { clear = true } = {}) {
|
|
298
|
+
if (clear) this.clear();
|
|
299
|
+
this._fromData(pointGroups, this._drawCurve.bind(this), this._drawDot.bind(this));
|
|
300
|
+
this._data = this._data.concat(pointGroups);
|
|
301
|
+
}
|
|
302
|
+
toData() {
|
|
303
|
+
return this._data;
|
|
304
|
+
}
|
|
305
|
+
_isLeftButtonPressed(event, only) {
|
|
306
|
+
if (only) return event.buttons === 1;
|
|
307
|
+
return (event.buttons & 1) === 1;
|
|
308
|
+
}
|
|
309
|
+
_pointerEventToSignatureEvent(event) {
|
|
310
|
+
return {
|
|
311
|
+
event,
|
|
312
|
+
type: event.type,
|
|
313
|
+
x: event.clientX,
|
|
314
|
+
y: event.clientY,
|
|
315
|
+
pressure: "pressure" in event ? event.pressure : 0
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
_touchEventToSignatureEvent(event) {
|
|
319
|
+
const touch = event.changedTouches[0];
|
|
320
|
+
return {
|
|
321
|
+
event,
|
|
322
|
+
type: event.type,
|
|
323
|
+
x: touch.clientX,
|
|
324
|
+
y: touch.clientY,
|
|
325
|
+
pressure: touch.force
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
_handleMouseDown(event) {
|
|
329
|
+
if (!this._isLeftButtonPressed(event, true) || this._drawingStroke) return;
|
|
330
|
+
this._strokeBegin(this._pointerEventToSignatureEvent(event));
|
|
331
|
+
}
|
|
332
|
+
_handleMouseMove(event) {
|
|
333
|
+
if (!this._isLeftButtonPressed(event, true) || !this._drawingStroke) {
|
|
334
|
+
this._strokeEnd(this._pointerEventToSignatureEvent(event), false);
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
this._strokeMoveUpdate(this._pointerEventToSignatureEvent(event));
|
|
338
|
+
}
|
|
339
|
+
_handleMouseUp(event) {
|
|
340
|
+
if (this._isLeftButtonPressed(event)) return;
|
|
341
|
+
this._strokeEnd(this._pointerEventToSignatureEvent(event));
|
|
342
|
+
}
|
|
343
|
+
_handleTouchStart(event) {
|
|
344
|
+
if (event.targetTouches.length !== 1 || this._drawingStroke) return;
|
|
345
|
+
if (event.cancelable) event.preventDefault();
|
|
346
|
+
this._strokeBegin(this._touchEventToSignatureEvent(event));
|
|
347
|
+
}
|
|
348
|
+
_handleTouchMove(event) {
|
|
349
|
+
if (event.targetTouches.length !== 1) return;
|
|
350
|
+
if (event.cancelable) event.preventDefault();
|
|
351
|
+
if (!this._drawingStroke) {
|
|
352
|
+
this._strokeEnd(this._touchEventToSignatureEvent(event), false);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
this._strokeMoveUpdate(this._touchEventToSignatureEvent(event));
|
|
356
|
+
}
|
|
357
|
+
_handleTouchEnd(event) {
|
|
358
|
+
if (event.targetTouches.length !== 0) return;
|
|
359
|
+
if (event.cancelable) event.preventDefault();
|
|
360
|
+
this._strokeEnd(this._touchEventToSignatureEvent(event));
|
|
361
|
+
}
|
|
362
|
+
_handlePointerCancel(event) {
|
|
363
|
+
if (!this._allowPointerId(event)) return;
|
|
364
|
+
event.preventDefault();
|
|
365
|
+
this._strokeEnd(this._pointerEventToSignatureEvent(event), false);
|
|
366
|
+
}
|
|
367
|
+
_handleTouchCancel(event) {
|
|
368
|
+
if (event.cancelable) event.preventDefault();
|
|
369
|
+
this._strokeEnd(this._touchEventToSignatureEvent(event), false);
|
|
370
|
+
}
|
|
371
|
+
_getPointerId(event) {
|
|
372
|
+
return event.persistentDeviceId || event.pointerId;
|
|
373
|
+
}
|
|
374
|
+
_allowPointerId(event, allowUndefined = false) {
|
|
375
|
+
if (typeof this._strokePointerId === "undefined") return allowUndefined;
|
|
376
|
+
return this._getPointerId(event) === this._strokePointerId;
|
|
377
|
+
}
|
|
378
|
+
_handlePointerDown(event) {
|
|
379
|
+
if (this._drawingStroke || !this._isLeftButtonPressed(event) || !this._allowPointerId(event, true)) return;
|
|
380
|
+
this._strokePointerId = this._getPointerId(event);
|
|
381
|
+
event.preventDefault();
|
|
382
|
+
this._strokeBegin(this._pointerEventToSignatureEvent(event));
|
|
383
|
+
}
|
|
384
|
+
_handlePointerMove(event) {
|
|
385
|
+
if (!this._allowPointerId(event)) return;
|
|
386
|
+
if (!this._isLeftButtonPressed(event, true) || !this._drawingStroke) {
|
|
387
|
+
this._strokeEnd(this._pointerEventToSignatureEvent(event), false);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
event.preventDefault();
|
|
391
|
+
this._strokeMoveUpdate(this._pointerEventToSignatureEvent(event));
|
|
392
|
+
}
|
|
393
|
+
_handlePointerUp(event) {
|
|
394
|
+
if (this._isLeftButtonPressed(event) || !this._allowPointerId(event)) return;
|
|
395
|
+
event.preventDefault();
|
|
396
|
+
this._strokeEnd(this._pointerEventToSignatureEvent(event));
|
|
397
|
+
}
|
|
398
|
+
_getPointGroupOptions(group) {
|
|
399
|
+
return {
|
|
400
|
+
penColor: group && "penColor" in group ? group.penColor : this.penColor,
|
|
401
|
+
dotSize: group && "dotSize" in group ? group.dotSize : this.dotSize,
|
|
402
|
+
minWidth: group && "minWidth" in group ? group.minWidth : this.minWidth,
|
|
403
|
+
maxWidth: group && "maxWidth" in group ? group.maxWidth : this.maxWidth,
|
|
404
|
+
velocityFilterWeight: group && "velocityFilterWeight" in group ? group.velocityFilterWeight : this.velocityFilterWeight,
|
|
405
|
+
compositeOperation: group && "compositeOperation" in group ? group.compositeOperation : this.compositeOperation
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
_strokeBegin(event) {
|
|
409
|
+
if (!this.dispatchEvent(new CustomEvent("beginStroke", {
|
|
410
|
+
detail: event,
|
|
411
|
+
cancelable: true
|
|
412
|
+
}))) return;
|
|
413
|
+
const { addEventListener } = this._getListenerFunctions();
|
|
414
|
+
switch (event.event.type) {
|
|
415
|
+
case "mousedown":
|
|
416
|
+
addEventListener("mousemove", this._handleMouseMove, { passive: false });
|
|
417
|
+
addEventListener("mouseup", this._handleMouseUp, { passive: false });
|
|
418
|
+
break;
|
|
419
|
+
case "touchstart":
|
|
420
|
+
addEventListener("touchmove", this._handleTouchMove, { passive: false });
|
|
421
|
+
addEventListener("touchend", this._handleTouchEnd, { passive: false });
|
|
422
|
+
addEventListener("touchcancel", this._handleTouchCancel, { passive: false });
|
|
423
|
+
break;
|
|
424
|
+
case "pointerdown":
|
|
425
|
+
addEventListener("pointermove", this._handlePointerMove, { passive: false });
|
|
426
|
+
addEventListener("pointerup", this._handlePointerUp, { passive: false });
|
|
427
|
+
addEventListener("pointercancel", this._handlePointerCancel, { passive: false });
|
|
428
|
+
break;
|
|
429
|
+
default:
|
|
430
|
+
}
|
|
431
|
+
this._drawingStroke = true;
|
|
432
|
+
const pointGroupOptions = this._getPointGroupOptions();
|
|
433
|
+
const newPointGroup = {
|
|
434
|
+
...pointGroupOptions,
|
|
435
|
+
points: []
|
|
436
|
+
};
|
|
437
|
+
this._data.push(newPointGroup);
|
|
438
|
+
this._reset(pointGroupOptions);
|
|
439
|
+
this._strokeUpdate(event);
|
|
440
|
+
}
|
|
441
|
+
_strokeUpdate(event) {
|
|
442
|
+
if (!this._drawingStroke) return;
|
|
443
|
+
if (this._data.length === 0) {
|
|
444
|
+
this._strokeBegin(event);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
this.dispatchEvent(new CustomEvent("beforeUpdateStroke", { detail: event }));
|
|
448
|
+
const point = this._createPoint(event.x, event.y, event.pressure);
|
|
449
|
+
const lastPointGroup = this._data[this._data.length - 1];
|
|
450
|
+
const lastPoints = lastPointGroup.points;
|
|
451
|
+
const lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
|
|
452
|
+
const isLastPointTooClose = lastPoint ? point.distanceTo(lastPoint) <= this.minDistance : false;
|
|
453
|
+
const pointGroupOptions = this._getPointGroupOptions(lastPointGroup);
|
|
454
|
+
if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
|
|
455
|
+
const curve = this._addPoint(point, pointGroupOptions);
|
|
456
|
+
if (!lastPoint) this._drawDot(point, pointGroupOptions);
|
|
457
|
+
else if (curve) this._drawCurve(curve, pointGroupOptions);
|
|
458
|
+
lastPoints.push({
|
|
459
|
+
time: point.time,
|
|
460
|
+
x: point.x,
|
|
461
|
+
y: point.y,
|
|
462
|
+
pressure: point.pressure
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
this.dispatchEvent(new CustomEvent("afterUpdateStroke", { detail: event }));
|
|
466
|
+
}
|
|
467
|
+
_strokeEnd(event, shouldUpdate = true) {
|
|
468
|
+
this._removeMoveUpEventListeners();
|
|
469
|
+
if (!this._drawingStroke) return;
|
|
470
|
+
if (shouldUpdate) this._strokeUpdate(event);
|
|
471
|
+
this._drawingStroke = false;
|
|
472
|
+
this._strokePointerId = void 0;
|
|
473
|
+
this.dispatchEvent(new CustomEvent("endStroke", { detail: event }));
|
|
474
|
+
}
|
|
475
|
+
_handlePointerEvents() {
|
|
476
|
+
this._drawingStroke = false;
|
|
477
|
+
this.canvas.addEventListener("pointerdown", this._handlePointerDown, { passive: false });
|
|
478
|
+
}
|
|
479
|
+
_handleMouseEvents() {
|
|
480
|
+
this._drawingStroke = false;
|
|
481
|
+
this.canvas.addEventListener("mousedown", this._handleMouseDown, { passive: false });
|
|
482
|
+
}
|
|
483
|
+
_handleTouchEvents() {
|
|
484
|
+
this.canvas.addEventListener("touchstart", this._handleTouchStart, { passive: false });
|
|
485
|
+
}
|
|
486
|
+
_reset(options) {
|
|
487
|
+
this._lastPoints = [];
|
|
488
|
+
this._lastVelocity = 0;
|
|
489
|
+
this._lastWidth = (options.minWidth + options.maxWidth) / 2;
|
|
490
|
+
this._ctx.fillStyle = options.penColor;
|
|
491
|
+
this._ctx.globalCompositeOperation = options.compositeOperation;
|
|
492
|
+
}
|
|
493
|
+
_createPoint(x, y, pressure) {
|
|
494
|
+
const rect = this.canvas.getBoundingClientRect();
|
|
495
|
+
return new Point(x - rect.left, y - rect.top, pressure, (/* @__PURE__ */ new Date()).getTime());
|
|
496
|
+
}
|
|
497
|
+
_addPoint(point, options) {
|
|
498
|
+
const { _lastPoints } = this;
|
|
499
|
+
_lastPoints.push(point);
|
|
500
|
+
if (_lastPoints.length > 2) {
|
|
501
|
+
if (_lastPoints.length === 3) _lastPoints.unshift(_lastPoints[0]);
|
|
502
|
+
const widths = this._calculateCurveWidths(_lastPoints[1], _lastPoints[2], options);
|
|
503
|
+
const curve = Bezier.fromPoints(_lastPoints, widths);
|
|
504
|
+
_lastPoints.shift();
|
|
505
|
+
return curve;
|
|
506
|
+
}
|
|
507
|
+
return null;
|
|
508
|
+
}
|
|
509
|
+
_calculateCurveWidths(startPoint, endPoint, options) {
|
|
510
|
+
const velocity = options.velocityFilterWeight * endPoint.velocityFrom(startPoint) + (1 - options.velocityFilterWeight) * this._lastVelocity;
|
|
511
|
+
const newWidth = this._strokeWidth(velocity, options);
|
|
512
|
+
const widths = {
|
|
513
|
+
end: newWidth,
|
|
514
|
+
start: this._lastWidth
|
|
515
|
+
};
|
|
516
|
+
this._lastVelocity = velocity;
|
|
517
|
+
this._lastWidth = newWidth;
|
|
518
|
+
return widths;
|
|
519
|
+
}
|
|
520
|
+
_strokeWidth(velocity, options) {
|
|
521
|
+
return Math.max(options.maxWidth / (velocity + 1), options.minWidth);
|
|
522
|
+
}
|
|
523
|
+
_drawCurveSegment(x, y, width) {
|
|
524
|
+
const ctx = this._ctx;
|
|
525
|
+
ctx.moveTo(x, y);
|
|
526
|
+
ctx.arc(x, y, width, 0, 2 * Math.PI, false);
|
|
527
|
+
this._isEmpty = false;
|
|
528
|
+
}
|
|
529
|
+
_drawCurve(curve, options) {
|
|
530
|
+
const ctx = this._ctx;
|
|
531
|
+
const widthDelta = curve.endWidth - curve.startWidth;
|
|
532
|
+
const drawSteps = Math.ceil(curve.length()) * 2;
|
|
533
|
+
ctx.beginPath();
|
|
534
|
+
ctx.fillStyle = options.penColor;
|
|
535
|
+
for (let i = 0; i < drawSteps; i += 1) {
|
|
536
|
+
const t = i / drawSteps;
|
|
537
|
+
const tt = t * t;
|
|
538
|
+
const ttt = tt * t;
|
|
539
|
+
const u = 1 - t;
|
|
540
|
+
const uu = u * u;
|
|
541
|
+
const uuu = uu * u;
|
|
542
|
+
let x = uuu * curve.startPoint.x;
|
|
543
|
+
x += 3 * uu * t * curve.control1.x;
|
|
544
|
+
x += 3 * u * tt * curve.control2.x;
|
|
545
|
+
x += ttt * curve.endPoint.x;
|
|
546
|
+
let y = uuu * curve.startPoint.y;
|
|
547
|
+
y += 3 * uu * t * curve.control1.y;
|
|
548
|
+
y += 3 * u * tt * curve.control2.y;
|
|
549
|
+
y += ttt * curve.endPoint.y;
|
|
550
|
+
const width = Math.min(curve.startWidth + ttt * widthDelta, options.maxWidth);
|
|
551
|
+
this._drawCurveSegment(x, y, width);
|
|
552
|
+
}
|
|
553
|
+
ctx.closePath();
|
|
554
|
+
ctx.fill();
|
|
555
|
+
}
|
|
556
|
+
_drawDot(point, options) {
|
|
557
|
+
const ctx = this._ctx;
|
|
558
|
+
const width = options.dotSize > 0 ? options.dotSize : (options.minWidth + options.maxWidth) / 2;
|
|
559
|
+
ctx.beginPath();
|
|
560
|
+
this._drawCurveSegment(point.x, point.y, width);
|
|
561
|
+
ctx.closePath();
|
|
562
|
+
ctx.fillStyle = options.penColor;
|
|
563
|
+
ctx.fill();
|
|
564
|
+
}
|
|
565
|
+
_fromData(pointGroups, drawCurve, drawDot) {
|
|
566
|
+
for (const group of pointGroups) {
|
|
567
|
+
const { points } = group;
|
|
568
|
+
const pointGroupOptions = this._getPointGroupOptions(group);
|
|
569
|
+
if (points.length > 1) for (let j = 0; j < points.length; j += 1) {
|
|
570
|
+
const basicPoint = points[j];
|
|
571
|
+
const point = new Point(basicPoint.x, basicPoint.y, basicPoint.pressure, basicPoint.time);
|
|
572
|
+
if (j === 0) this._reset(pointGroupOptions);
|
|
573
|
+
const curve = this._addPoint(point, pointGroupOptions);
|
|
574
|
+
if (curve) drawCurve(curve, pointGroupOptions);
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
this._reset(pointGroupOptions);
|
|
578
|
+
drawDot(points[0], pointGroupOptions);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
toSVG({ includeBackgroundColor = false, includeDataUrl = false } = {}) {
|
|
583
|
+
const pointGroups = this._data;
|
|
584
|
+
const ratio = Math.max(window.devicePixelRatio || 1, 1);
|
|
585
|
+
const minX = 0;
|
|
586
|
+
const minY = 0;
|
|
587
|
+
const maxX = this.canvas.width / ratio;
|
|
588
|
+
const maxY = this.canvas.height / ratio;
|
|
589
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
590
|
+
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
591
|
+
svg.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
|
|
592
|
+
svg.setAttribute("viewBox", `${minX} ${minY} ${maxX} ${maxY}`);
|
|
593
|
+
svg.setAttribute("width", maxX.toString());
|
|
594
|
+
svg.setAttribute("height", maxY.toString());
|
|
595
|
+
if (includeBackgroundColor && this.backgroundColor) {
|
|
596
|
+
const rect = document.createElement("rect");
|
|
597
|
+
rect.setAttribute("width", "100%");
|
|
598
|
+
rect.setAttribute("height", "100%");
|
|
599
|
+
rect.setAttribute("fill", this.backgroundColor);
|
|
600
|
+
svg.appendChild(rect);
|
|
601
|
+
}
|
|
602
|
+
if (includeDataUrl && this._dataUrl) {
|
|
603
|
+
const ratio2 = this._dataUrlOptions?.ratio || window.devicePixelRatio || 1;
|
|
604
|
+
const width = this._dataUrlOptions?.width || this.canvas.width / ratio2;
|
|
605
|
+
const height = this._dataUrlOptions?.height || this.canvas.height / ratio2;
|
|
606
|
+
const xOffset = this._dataUrlOptions?.xOffset || 0;
|
|
607
|
+
const yOffset = this._dataUrlOptions?.yOffset || 0;
|
|
608
|
+
const image = document.createElement("image");
|
|
609
|
+
image.setAttribute("x", xOffset.toString());
|
|
610
|
+
image.setAttribute("y", yOffset.toString());
|
|
611
|
+
image.setAttribute("width", width.toString());
|
|
612
|
+
image.setAttribute("height", height.toString());
|
|
613
|
+
image.setAttribute("preserveAspectRatio", "none");
|
|
614
|
+
image.setAttribute("href", this._dataUrl);
|
|
615
|
+
svg.appendChild(image);
|
|
616
|
+
}
|
|
617
|
+
this._fromData(pointGroups, (curve, { penColor }) => {
|
|
618
|
+
const path = document.createElement("path");
|
|
619
|
+
if (!isNaN(curve.control1.x) && !isNaN(curve.control1.y) && !isNaN(curve.control2.x) && !isNaN(curve.control2.y)) {
|
|
620
|
+
const attr = `M ${curve.startPoint.x.toFixed(3)},${curve.startPoint.y.toFixed(3)} C ${curve.control1.x.toFixed(3)},${curve.control1.y.toFixed(3)} ${curve.control2.x.toFixed(3)},${curve.control2.y.toFixed(3)} ${curve.endPoint.x.toFixed(3)},${curve.endPoint.y.toFixed(3)}`;
|
|
621
|
+
path.setAttribute("d", attr);
|
|
622
|
+
path.setAttribute("stroke-width", (curve.endWidth * 2.25).toFixed(3));
|
|
623
|
+
path.setAttribute("stroke", penColor);
|
|
624
|
+
path.setAttribute("fill", "none");
|
|
625
|
+
path.setAttribute("stroke-linecap", "round");
|
|
626
|
+
svg.appendChild(path);
|
|
627
|
+
}
|
|
628
|
+
}, (point, { penColor, dotSize, minWidth, maxWidth }) => {
|
|
629
|
+
const circle = document.createElement("circle");
|
|
630
|
+
const size = dotSize > 0 ? dotSize : (minWidth + maxWidth) / 2;
|
|
631
|
+
circle.setAttribute("r", size.toString());
|
|
632
|
+
circle.setAttribute("cx", point.x.toString());
|
|
633
|
+
circle.setAttribute("cy", point.y.toString());
|
|
634
|
+
circle.setAttribute("fill", penColor);
|
|
635
|
+
svg.appendChild(circle);
|
|
636
|
+
});
|
|
637
|
+
return svg.outerHTML;
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
//#endregion
|
|
641
|
+
//#region src/css/theme/fields/_signature.css?inline
|
|
642
|
+
var _signature_default = "@layer formie-theme{[data-formie-field-type=signature] .formie-field-control{transition:border-color .15s,box-shadow .15s,background-color .15s;position:relative}[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{border-color:var(--formie-focus-ring-border-color);box-shadow:var(--formie-shadow-focus)}.formie-field-has-error[data-formie-field-type=signature] .formie-signature-canvas{border-color:var(--formie-color-danger)}.formie-field-has-error[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{box-shadow:var(--formie-shadow-danger-focus)}[data-formie-field-type=signature] .formie-signature-canvas{width:var(--formie-signature-width);height:var(--formie-signature-height);border:var(--formie-signature-border);background:var(--formie-signature-background);border-radius:var(--formie-signature-border-radius);touch-action:none;transition:border-color .15s,box-shadow .15s,background-color .15s;display:block}[data-formie-field-type=signature] .formie-signature-remove-button{top:var(--formie-signature-remove-button-top);right:var(--formie-signature-remove-button-right);transform:var(--formie-signature-remove-button-transform);font-size:0;line-height:0;position:absolute}}";
|
|
643
|
+
//#endregion
|
|
644
|
+
//#region src/js/modules/fields/signature.ts
|
|
645
|
+
var INPUT_SELECTOR = "input[data-formie-signature-input]";
|
|
646
|
+
var CANVAS_SELECTOR = "canvas[data-formie-signature-canvas]";
|
|
647
|
+
var CLEAR_SELECTOR = "[data-formie-signature-clear]";
|
|
648
|
+
var MODULE_ID = "signature";
|
|
649
|
+
ensureModuleStyles(MODULE_ID, [_signature_default]);
|
|
650
|
+
function getCanvasSize(canvas) {
|
|
651
|
+
const rect = canvas.getBoundingClientRect();
|
|
652
|
+
return {
|
|
653
|
+
width: Math.round(rect.width),
|
|
654
|
+
height: Math.round(rect.height)
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
function drawValueOnCanvas(canvas, value) {
|
|
658
|
+
if (!value) return;
|
|
659
|
+
const image = new Image();
|
|
660
|
+
image.src = value;
|
|
661
|
+
image.onload = () => {
|
|
662
|
+
const ratio = Math.max(window.devicePixelRatio || 1, 1);
|
|
663
|
+
const context = canvas.getContext("2d");
|
|
664
|
+
if (!context) return;
|
|
665
|
+
context.drawImage(image, 0, 0, canvas.width / ratio, canvas.height / ratio);
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
function initSignatureField(root, field, input, canvas, clearButton, options) {
|
|
669
|
+
const penWeight = parseFloat(options.penWeight || "2") || 2;
|
|
670
|
+
const resizeTarget = canvas.parentElement instanceof HTMLElement ? canvas.parentElement : field;
|
|
671
|
+
const signaturePad = new SignaturePad(canvas, {
|
|
672
|
+
backgroundColor: options.backgroundColor || "rgba(255, 255, 255, 0)",
|
|
673
|
+
penColor: options.penColor || "#000000",
|
|
674
|
+
dotSize: penWeight,
|
|
675
|
+
minWidth: penWeight,
|
|
676
|
+
maxWidth: penWeight
|
|
677
|
+
});
|
|
678
|
+
const resizeCanvas = () => {
|
|
679
|
+
const { width, height } = getCanvasSize(canvas);
|
|
680
|
+
if (!(width > 0) || !(height > 0)) return;
|
|
681
|
+
const ratio = Math.max(window.devicePixelRatio || 1, 1);
|
|
682
|
+
const context = canvas.getContext("2d");
|
|
683
|
+
if (!context) return;
|
|
684
|
+
const existingValue = input.value || (signaturePad.isEmpty() ? "" : signaturePad.toDataURL());
|
|
685
|
+
canvas.width = width * ratio;
|
|
686
|
+
canvas.height = height * ratio;
|
|
687
|
+
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
688
|
+
context.scale(ratio, ratio);
|
|
689
|
+
signaturePad.clear();
|
|
690
|
+
drawValueOnCanvas(canvas, existingValue);
|
|
691
|
+
};
|
|
692
|
+
const scheduleResize = (delay = 0) => {
|
|
693
|
+
window.setTimeout(() => {
|
|
694
|
+
window.requestAnimationFrame(() => {
|
|
695
|
+
resizeCanvas();
|
|
696
|
+
});
|
|
697
|
+
}, delay);
|
|
698
|
+
};
|
|
699
|
+
const resizeHandler = () => {
|
|
700
|
+
scheduleResize();
|
|
701
|
+
};
|
|
702
|
+
const pageNavigateHandler = () => {
|
|
703
|
+
scheduleResize(100);
|
|
704
|
+
};
|
|
705
|
+
const resizeObserver = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => {
|
|
706
|
+
scheduleResize();
|
|
707
|
+
});
|
|
708
|
+
const syncInputValue = (nextValue) => {
|
|
709
|
+
const valueChanged = input.value !== nextValue;
|
|
710
|
+
input.value = nextValue;
|
|
711
|
+
if (!valueChanged) return;
|
|
712
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
713
|
+
input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
714
|
+
};
|
|
715
|
+
const syncValue = () => {
|
|
716
|
+
syncInputValue(signaturePad.isEmpty() ? "" : signaturePad.toDataURL());
|
|
717
|
+
};
|
|
718
|
+
const clearSignature = () => {
|
|
719
|
+
signaturePad.clear();
|
|
720
|
+
syncInputValue("");
|
|
721
|
+
};
|
|
722
|
+
signaturePad.addEventListener("endStroke", syncValue);
|
|
723
|
+
window.addEventListener("resize", resizeHandler);
|
|
724
|
+
root.addEventListener("formie:page:navigate:after", pageNavigateHandler);
|
|
725
|
+
resizeObserver?.observe(resizeTarget);
|
|
726
|
+
scheduleResize();
|
|
727
|
+
if (clearButton) clearButton.addEventListener("click", clearSignature);
|
|
728
|
+
dispatchFieldEvent(field, MODULE_ID, "init", { signature: signaturePad });
|
|
729
|
+
return () => {
|
|
730
|
+
signaturePad.removeEventListener("endStroke", syncValue);
|
|
731
|
+
window.removeEventListener("resize", resizeHandler);
|
|
732
|
+
root.removeEventListener("formie:page:navigate:after", pageNavigateHandler);
|
|
733
|
+
resizeObserver?.disconnect();
|
|
734
|
+
if (clearButton) clearButton.removeEventListener("click", clearSignature);
|
|
735
|
+
signaturePad.clear();
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
var signatureModule = {
|
|
739
|
+
id: MODULE_ID,
|
|
740
|
+
kind: "field",
|
|
741
|
+
match: (ctx) => {
|
|
742
|
+
return !!ctx.target.querySelector(CANVAS_SELECTOR);
|
|
743
|
+
},
|
|
744
|
+
setup: async (ctx) => {
|
|
745
|
+
const options = ctx.options || {};
|
|
746
|
+
const root = ctx.root instanceof HTMLElement ? ctx.root : ctx.target instanceof HTMLElement ? ctx.target : null;
|
|
747
|
+
if (!root) return;
|
|
748
|
+
const cleanups = getModuleFieldContainers(ctx).map((field) => {
|
|
749
|
+
const input = field.querySelector(INPUT_SELECTOR);
|
|
750
|
+
const canvas = field.querySelector(CANVAS_SELECTOR);
|
|
751
|
+
const clearButton = field.querySelector(CLEAR_SELECTOR);
|
|
752
|
+
if (!(input instanceof HTMLInputElement) || !(canvas instanceof HTMLCanvasElement)) return () => {};
|
|
753
|
+
return initSignatureField(root, field, input, canvas, clearButton instanceof HTMLElement ? clearButton : null, options);
|
|
754
|
+
});
|
|
755
|
+
await ctx.emit("formie:module:signature:init", { count: cleanups.length });
|
|
756
|
+
return { destroy: () => {
|
|
757
|
+
cleanups.forEach((cleanup) => {
|
|
758
|
+
cleanup();
|
|
759
|
+
});
|
|
760
|
+
ctx.emit("formie:module:signature:destroy", {});
|
|
761
|
+
} };
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
//#endregion
|
|
765
|
+
export { signatureModule };
|