@verbb/formie-browser 1.0.14 → 1.0.16
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 +66 -0
- package/dist/chunks/{address-country-Dn71jroa.js → address-country-DLJF-OkC.js} +5 -9
- package/dist/chunks/{address-finder-O49uDRoR.js → address-finder-QK1m1eyv.js} +2 -2
- package/dist/chunks/{address-state-ByYatUur.js → address-state-CHKit8AW.js} +113 -112
- package/dist/chunks/{api-DYYsVIub.js → api-BPtH5RBA.js} +162 -130
- package/dist/chunks/{api-D6kJ7kXZ.js → api-BR2Gqy37.js} +313 -303
- package/dist/chunks/{api-ghNr2uxX.js → api-CmuOZ0i3.js} +1 -1
- package/dist/chunks/{async-nPFRNQ06.js → async-2GdXNFCE.js} +18 -1
- package/dist/chunks/{bpoint-D0RKFM4F.js → bpoint-GvYfyPjD.js} +1 -1
- package/dist/chunks/{calculations-YEoVCG2q.js → calculations-DeEmdUDq.js} +5 -7
- package/dist/chunks/{captcha-eu-DERJbXnH.js → captcha-eu-eU_M6snp.js} +2 -2
- package/dist/chunks/{checkbox-radio-gsm8QPJg.js → checkbox-radio-CSXo6svm.js} +4 -12
- package/dist/chunks/{combobox-CWNdx4Fk.js → combobox-CJh2DoSO.js} +323 -363
- package/dist/chunks/{conditions-DqNHLTbN.js → conditions-Dz3068K0.js} +140 -153
- package/dist/chunks/{country-from-ip-DDj_mFki.js → country-from-ip-BqQ-BqLH.js} +1 -1
- package/dist/chunks/{custom-google-maps-C4l2S3GO.js → custom-google-maps-rNm5VFbb.js} +2 -6
- package/dist/chunks/{custom-link-CLazgKYH.js → custom-link-CLqFCssQ.js} +1 -1
- package/dist/chunks/{custom-maps-DqcAlD0v.js → custom-maps-DgjYQDLj.js} +4 -8
- package/dist/chunks/{date-picker-RUnevF7l.js → date-picker-BVJxJVYT.js} +42 -58
- package/dist/chunks/{debug-BV0DvdHx.js → debug-rhzqP1j2.js} +2 -14
- package/dist/chunks/{dist-ZLeW0zZ3.js → dist-CJReDlDK.js} +13 -8
- package/dist/chunks/{eway-or6dtjoT.js → eway-BZuTBAUW.js} +3 -3
- package/dist/chunks/{field-references.resolver-Ca8MguFv.js → field-references.resolver-uSHf5-NP.js} +1 -1
- package/dist/chunks/{file-upload-Bm-TXyNB.js → file-upload-vEUr_EuP.js} +131 -113
- package/dist/chunks/{friendly-captcha-v1-GFqCt1Mh.js → friendly-captcha-v1-C_cF1WD2.js} +2 -2
- package/dist/chunks/{friendly-captcha-v2-WoW246JG.js → friendly-captcha-v2-BenESH-n.js} +2 -2
- package/dist/chunks/{friendly-challenge-DPG9MJb1.js → friendly-challenge-BgPBEMXx.js} +21 -35
- package/dist/chunks/{go-cardless-DzJ-0FKg.js → go-cardless-DWZeB0Bq.js} +2 -6
- package/dist/chunks/{google-address-C1P1nTDM.js → google-address-DQR6rsbh.js} +15 -10
- package/dist/chunks/{hcaptcha-D0T8aIHz.js → hcaptcha-COilLmRT.js} +2 -2
- package/dist/chunks/{hidden-BZhXnNPe.js → hidden-Bc2TpcgF.js} +1 -1
- package/dist/chunks/{http-C2QdHuWO.js → http-Dj_skqaa.js} +1 -1
- package/dist/chunks/{leaflet-src-DE6rv6M-.js → leaflet-src-Cg-LUOD8.js} +74 -122
- package/dist/chunks/{loqate-DD1S7PY9.js → loqate-ZZClcacr.js} +2 -2
- package/dist/chunks/{mollie-DG8Ju83x.js → mollie-8OMXIYa8.js} +2 -6
- package/dist/chunks/{moneris-C8m3Fvqu.js → moneris-qYHJ9EFy.js} +1 -1
- package/dist/chunks/opayo-DlWPEnla.js +159 -0
- package/dist/chunks/{paddle-BIYR9Um3.js → paddle-CArfWih0.js} +2 -2
- package/dist/chunks/{password-validation-C8_uO_c_.js → password-validation-HGOU9kf3.js} +2 -2
- package/dist/chunks/{paypal-B_yxIo2d.js → paypal-BcaMCMGY.js} +2 -2
- package/dist/chunks/{payway-CeOzS0sL.js → payway-vxC7_bfR.js} +4 -12
- package/dist/chunks/{phone-country-bAqje17P.js → phone-country-Bx9EG50h.js} +124 -141
- package/dist/chunks/{place-kit-BE5gi3vo.js → place-kit-BKk8xDXf.js} +10 -10
- package/dist/chunks/{placekit-autocomplete.esm-CZZERYur.js → placekit-autocomplete.esm-D2A_0iVU.js} +2 -5
- package/dist/chunks/{recaptcha-enterprise-CruXddZq.js → recaptcha-enterprise-Cx6HUpMa.js} +6 -12
- package/dist/chunks/recaptcha-shared-CcMI-r8t.js +33 -0
- package/dist/chunks/{recaptcha-v2-checkbox-CCnJYCnG.js → recaptcha-v2-checkbox-DQ9BJzcv.js} +2 -2
- package/dist/chunks/{recaptcha-v2-invisible-BuVqRRYn.js → recaptcha-v2-invisible-BP0T8Pan.js} +2 -2
- package/dist/chunks/recaptcha-v3-DKMGQ27K.js +38 -0
- package/dist/chunks/{repeater-DwE27jI1.js → repeater-BR0RUvTs.js} +50 -40
- package/dist/chunks/{rich-text-uV4o_pGk.js → rich-text-H2A6cm1t.js} +33 -11
- package/dist/chunks/{rolldown-runtime-DtPi1Y-2.js → rolldown-runtime-VHNaYcLd.js} +1 -1
- package/dist/chunks/{scripts-CbQ7agX3.js → scripts-DrccjrFv.js} +1 -1
- package/dist/chunks/{sdk-lkwSvlpM.js → sdk-_cmrRYgp.js} +4 -16
- package/dist/chunks/{shared-OKhSay59.js → shared-CJ1LIEh3.js} +1 -3
- package/dist/chunks/{signature-7cldFbqj.js → signature-CfKA_poI.js} +9 -41
- package/dist/chunks/skip-CEW89ExY.js +7 -0
- package/dist/chunks/{snaptcha-C04kNGYQ.js → snaptcha-P3EoSQud.js} +1 -1
- package/dist/chunks/{square-DEzxv9D9.js → square-Dyz0p_GU.js} +2 -2
- package/dist/chunks/{stripe-CVPQGDz3.js → stripe-Bfd_jp_k.js} +4 -7
- package/dist/chunks/{summary-BF_8mrXI.js → summary-B3CAebLV.js} +45 -37
- package/dist/chunks/{survey-likert-fk1hUPff.js → survey-likert-CEtUceag.js} +1 -1
- package/dist/chunks/{survey-rank-BsLGl2LX.js → survey-rank-Dtt97y6s.js} +3 -7
- package/dist/chunks/{survey-rating-DVS6e6fM.js → survey-rating-mlDMI0uq.js} +9 -23
- package/dist/chunks/{table-DnIBdeKF.js → table-0k6Md0IO.js} +2 -2
- package/dist/chunks/{text-limit-LGMPhFuC.js → text-limit-CTVML6s7.js} +10 -10
- package/dist/chunks/{turnstile-n9DNyPxi.js → turnstile-Sp4ubowK.js} +2 -2
- package/dist/chunks/{upload-manager-BbiUosZq.js → upload-manager-Ccg3d_4I.js} +258 -260
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +743 -734
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/dom-events.d.ts +5 -0
- package/dist/js/core/dom-events.d.ts.map +1 -1
- package/dist/js/core/page-client-event.d.ts.map +1 -1
- package/dist/js/core/submit-result-state.d.ts.map +1 -1
- package/dist/js/core/submit-result-ui.d.ts +3 -1
- package/dist/js/core/submit-result-ui.d.ts.map +1 -1
- package/dist/js/core/validation-focus.d.ts.map +1 -1
- package/dist/js/modules/address/google-address.d.ts +10 -0
- package/dist/js/modules/address/google-address.d.ts.map +1 -1
- package/dist/js/modules/address/place-kit.d.ts.map +1 -1
- package/dist/js/modules/captchas/factories.d.ts.map +1 -1
- package/dist/js/modules/captchas/host.d.ts +4 -1
- package/dist/js/modules/captchas/host.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-shared.d.ts +1 -1
- package/dist/js/modules/captchas/recaptcha-shared.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-v3.d.ts.map +1 -1
- package/dist/js/modules/fields/address-state.d.ts.map +1 -1
- package/dist/js/modules/fields/combobox.d.ts +2 -0
- package/dist/js/modules/fields/combobox.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions/effects.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions.d.ts.map +1 -1
- package/dist/js/modules/fields/date-picker.d.ts.map +1 -1
- package/dist/js/modules/fields/file-upload.d.ts.map +1 -1
- package/dist/js/modules/fields/phone-country.d.ts.map +1 -1
- package/dist/js/modules/fields/repeater.d.ts.map +1 -1
- package/dist/js/modules/fields/rich-text.d.ts.map +1 -1
- package/dist/js/modules/fields/summary.d.ts.map +1 -1
- package/dist/js/modules/fields/text-limit.d.ts.map +1 -1
- package/dist/js/modules/fields/upload-manager.d.ts.map +1 -1
- package/dist/js/modules/payments/factories.d.ts.map +1 -1
- package/dist/js/modules/payments/opayo.d.ts.map +1 -1
- package/dist/js/submit/pipeline.d.ts +2 -0
- package/dist/js/submit/pipeline.d.ts.map +1 -1
- package/dist/js/utils/async.d.ts +1 -0
- package/dist/js/utils/async.d.ts.map +1 -1
- package/dist/js/utils/form-started-at.d.ts +1 -0
- package/dist/js/utils/form-started-at.d.ts.map +1 -1
- package/dist/js/utils/unload-warning.d.ts +4 -0
- package/dist/js/utils/unload-warning.d.ts.map +1 -1
- package/dist/js/validation/rules/required.d.ts.map +1 -1
- package/dist/js/validation/submit-readiness.d.ts.map +1 -1
- package/dist/js/validation/validator.d.ts +1 -0
- package/dist/js/validation/validator.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/js/core/create-formie-client.ts +37 -28
- package/src/js/core/dom-events.ts +30 -1
- package/src/js/core/page-client-event.ts +5 -7
- package/src/js/core/submit-result-state.ts +30 -2
- package/src/js/core/submit-result-ui.ts +25 -3
- package/src/js/core/validation-focus.ts +17 -3
- package/src/js/modules/address/google-address.ts +95 -37
- package/src/js/modules/address/place-kit.ts +13 -7
- package/src/js/modules/captchas/factories.ts +241 -101
- package/src/js/modules/captchas/host.ts +16 -0
- package/src/js/modules/captchas/recaptcha-enterprise.ts +1 -1
- package/src/js/modules/captchas/recaptcha-shared.ts +23 -5
- package/src/js/modules/captchas/recaptcha-v3.ts +23 -14
- package/src/js/modules/fields/address-country.ts +5 -5
- package/src/js/modules/fields/address-state.ts +80 -27
- package/src/js/modules/fields/combobox.ts +22 -1
- package/src/js/modules/fields/conditions/effects.ts +4 -5
- package/src/js/modules/fields/conditions.ts +9 -0
- package/src/js/modules/fields/date-picker.ts +6 -3
- package/src/js/modules/fields/file-upload.ts +55 -18
- package/src/js/modules/fields/phone-country.ts +25 -2
- package/src/js/modules/fields/repeater.ts +55 -4
- package/src/js/modules/fields/rich-text.ts +33 -0
- package/src/js/modules/fields/summary.ts +63 -10
- package/src/js/modules/fields/text-limit.ts +11 -0
- package/src/js/modules/fields/upload-manager.ts +54 -18
- package/src/js/modules/payments/factories.ts +87 -54
- package/src/js/modules/payments/opayo.ts +7 -0
- package/src/js/submit/pipeline.ts +16 -9
- package/src/js/utils/async.ts +34 -0
- package/src/js/utils/form-started-at.ts +19 -4
- package/src/js/utils/unload-warning.ts +63 -7
- package/src/js/validation/rules/required.ts +18 -0
- package/src/js/validation/submit-readiness.ts +2 -0
- package/src/js/validation/validator.ts +29 -6
- package/src/vendor.d.ts +2 -0
- package/dist/chunks/opayo-B3EvrVxw.js +0 -188
- package/dist/chunks/recaptcha-shared-AQRMDMme.js +0 -27
- package/dist/chunks/recaptcha-v3-CloqhO2A.js +0 -28
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
import { a as e, d as t,
|
|
2
|
-
import { t as
|
|
3
|
-
import { a
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { r as
|
|
7
|
-
import { n as
|
|
1
|
+
import { a as e, d as t, t as n, u as r } from "./event-names-BCI2FLD8.js";
|
|
2
|
+
import { t as i } from "./debug-rhzqP1j2.js";
|
|
3
|
+
import { a, i as o, t as s } from "./theme-classes-DAQuEqdP.js";
|
|
4
|
+
import { n as c, t as l } from "./async-2GdXNFCE.js";
|
|
5
|
+
import { i as u } from "./i18n-BY1ds1BL.js";
|
|
6
|
+
import { r as d, t as f } from "./field-references.keys-58ZSTrCW.js";
|
|
7
|
+
import { n as p, r as m } from "./field-references.resolver-uSHf5-NP.js";
|
|
8
8
|
//#region src/js/core/dom-events.ts
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
var h = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new Set([...n, "formie:state:reset"]);
|
|
10
|
+
function _(e, t, n) {
|
|
11
|
+
let r = new Set(t ? [e, t] : [e]);
|
|
12
|
+
return r.forEach((e) => h.set(e, n)), () => {
|
|
13
|
+
r.forEach((e) => {
|
|
14
|
+
h.get(e) === n && h.delete(e);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function v(e, t) {
|
|
19
|
+
let n = h.get(e);
|
|
20
|
+
return n ? Object.assign(t, { instance: n }) : t;
|
|
21
|
+
}
|
|
22
|
+
function y(e, n, r) {
|
|
23
|
+
(g.has(n) || n.startsWith("formie:stage:")) && (r ??= h.has(e) ? {} : r, r && typeof r == "object" && !Array.isArray(r) && (r = v(e, r))), e.dispatchEvent(new CustomEvent(t(n), {
|
|
11
24
|
bubbles: !0,
|
|
12
25
|
detail: r
|
|
13
26
|
}));
|
|
14
27
|
}
|
|
15
28
|
//#endregion
|
|
16
29
|
//#region src/js/core/page-client-event.ts
|
|
17
|
-
var
|
|
30
|
+
var b = i("general", "page-client-event"), x = "data-formie-client-event", S = "data-formie-pending-client-events";
|
|
18
31
|
function ee(e) {
|
|
19
32
|
return typeof window < "u" && window.CSS?.escape ? window.CSS.escape(e) : e.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
20
33
|
}
|
|
@@ -27,7 +40,7 @@ function ne(e) {
|
|
|
27
40
|
let t = JSON.parse(e);
|
|
28
41
|
return t && typeof t == "object" ? t : null;
|
|
29
42
|
} catch {
|
|
30
|
-
return
|
|
43
|
+
return b.warn("Invalid data-formie-client-event JSON.", { rawPreview: e.slice(0, 80) }), null;
|
|
31
44
|
}
|
|
32
45
|
}
|
|
33
46
|
function re(e) {
|
|
@@ -47,81 +60,74 @@ function ie(e) {
|
|
|
47
60
|
};
|
|
48
61
|
}).filter((e) => e !== null) : [];
|
|
49
62
|
}
|
|
50
|
-
function
|
|
63
|
+
function C(e, t) {
|
|
51
64
|
if (!t.length) return;
|
|
52
65
|
let n = window;
|
|
53
66
|
n.dataLayer = n.dataLayer || [], t.forEach((t) => {
|
|
54
|
-
n.dataLayer.push(t.payload), e
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
}));
|
|
61
|
-
}), h.log("Dispatched resolved client events.", {
|
|
67
|
+
n.dataLayer.push(t.payload), y(e, "formie:client-event", {
|
|
68
|
+
event: t.event,
|
|
69
|
+
payload: t.payload
|
|
70
|
+
});
|
|
71
|
+
}), b.log("Dispatched resolved client events.", {
|
|
62
72
|
count: t.length,
|
|
63
73
|
events: t.map((e) => e.event)
|
|
64
74
|
});
|
|
65
75
|
}
|
|
66
76
|
function ae(e) {
|
|
67
|
-
let t = e.getAttribute(
|
|
77
|
+
let t = e.getAttribute(S);
|
|
68
78
|
if (t?.trim()) try {
|
|
69
79
|
let n = ie(JSON.parse(t));
|
|
70
|
-
n.length &&
|
|
80
|
+
n.length && C(e, n);
|
|
71
81
|
} catch {
|
|
72
|
-
|
|
82
|
+
b.warn("Invalid pending client events JSON on form element.");
|
|
73
83
|
} finally {
|
|
74
|
-
e.removeAttribute(
|
|
84
|
+
e.removeAttribute(S);
|
|
75
85
|
}
|
|
76
86
|
}
|
|
77
|
-
function
|
|
87
|
+
function oe(e, t) {
|
|
78
88
|
if (t !== "submit") return;
|
|
79
89
|
let n = te(e);
|
|
80
90
|
if (!n) {
|
|
81
|
-
|
|
91
|
+
b.log("No submitted page id; skipping client event.");
|
|
82
92
|
return;
|
|
83
93
|
}
|
|
84
94
|
let r = e.querySelector(`[data-formie-page][data-formie-page-id="${ee(n)}"]`);
|
|
85
95
|
if (!r) {
|
|
86
|
-
|
|
96
|
+
b.log("No page section for id; skipping client event.", { pageId: n });
|
|
87
97
|
return;
|
|
88
98
|
}
|
|
89
|
-
let i = r.getAttribute(
|
|
99
|
+
let i = r.getAttribute(x);
|
|
90
100
|
if (i === null) return;
|
|
91
101
|
let a = ne(i);
|
|
92
102
|
if (!a || !Array.isArray(a.fields)) return;
|
|
93
103
|
let o = re(a.fields);
|
|
94
|
-
|
|
104
|
+
C(e, [{
|
|
95
105
|
event: typeof o.event == "string" && o.event !== "" ? o.event : "formPageSubmission",
|
|
96
106
|
payload: o
|
|
97
107
|
}]);
|
|
98
108
|
}
|
|
99
109
|
//#endregion
|
|
100
110
|
//#region src/js/core/page-tab-errors.ts
|
|
101
|
-
function
|
|
102
|
-
|
|
103
|
-
e.setAttribute("data-formie-tab-error", "true");
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
e.removeAttribute("data-formie-tab-error");
|
|
111
|
+
function se(e, t) {
|
|
112
|
+
a(e, e, "tabError", t), t ? e.setAttribute("data-formie-tab-error", "true") : e.removeAttribute("data-formie-tab-error");
|
|
107
113
|
}
|
|
108
|
-
function
|
|
114
|
+
function w(e) {
|
|
109
115
|
let t = /* @__PURE__ */ new Set();
|
|
110
116
|
e.querySelectorAll("[data-formie-page]").forEach((e) => {
|
|
111
117
|
let n = e, r = n.getAttribute("data-formie-page-id");
|
|
112
118
|
r && n.querySelector("[data-formie-field-has-error]") && t.add(r);
|
|
113
119
|
}), e.querySelectorAll("[data-formie-tab]").forEach((e) => {
|
|
114
120
|
let n = e, r = n.getAttribute("data-formie-page-id");
|
|
115
|
-
|
|
121
|
+
se(n, !!r && t.has(r));
|
|
116
122
|
});
|
|
117
123
|
}
|
|
118
124
|
//#endregion
|
|
119
125
|
//#region src/js/validation/scope.ts
|
|
120
|
-
function
|
|
126
|
+
function ce(e) {
|
|
121
127
|
return Array.from(e.querySelectorAll("[data-formie-page]"));
|
|
122
128
|
}
|
|
123
|
-
function
|
|
124
|
-
let t =
|
|
129
|
+
function T(e) {
|
|
130
|
+
let t = ce(e);
|
|
125
131
|
if (!t.length) return {
|
|
126
132
|
scope: e,
|
|
127
133
|
final: !0
|
|
@@ -133,37 +139,51 @@ function S(e) {
|
|
|
133
139
|
};
|
|
134
140
|
}
|
|
135
141
|
//#endregion
|
|
142
|
+
//#region src/js/utils/form-started-at.ts
|
|
143
|
+
var le = "formie:formStartedAt:";
|
|
144
|
+
function E(e) {
|
|
145
|
+
let t = e.querySelector("input[name=\"formStartedAt\"]");
|
|
146
|
+
if (!t) return;
|
|
147
|
+
let n = e.querySelector("input[name=\"renderId\"]")?.value?.trim() ?? "", r = n ? `${le}${n}` : null, i = ["submissionUid", "progressId"].some((t) => e.querySelector(`input[name="${t}"]`)?.value.trim()), a = t.value || (i && r ? sessionStorage.getItem(r) : null);
|
|
148
|
+
a ||= String(Date.now()), r && sessionStorage.setItem(r, a), t.value = a;
|
|
149
|
+
}
|
|
150
|
+
function ue(e) {
|
|
151
|
+
let t = e.querySelector("input[name=\"formStartedAt\"]");
|
|
152
|
+
t && (t.value = String(Date.now()), E(e));
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
136
155
|
//#region src/js/validation/submit-readiness.ts
|
|
137
|
-
var
|
|
138
|
-
function
|
|
156
|
+
var D = "data-formie-submit-validation-disabled", O = "data-formie-preserve-disabled", de = "data-formie-submit-ready";
|
|
157
|
+
function fe(e) {
|
|
139
158
|
let t = e.dataset.formieDisableSubmitUntilValid?.trim().toLowerCase();
|
|
140
159
|
return t === "" || t === "true" || t === "1";
|
|
141
160
|
}
|
|
142
|
-
function
|
|
161
|
+
function pe(e) {
|
|
143
162
|
return Array.from(e.querySelectorAll("button[data-formie-action=\"submit\"]")).filter((e) => e instanceof HTMLButtonElement);
|
|
144
163
|
}
|
|
145
|
-
function
|
|
164
|
+
function me(e) {
|
|
146
165
|
return !e.hasAttribute("data-formie-conditionally-hidden") && !e.closest("[data-formie-conditionally-hidden]");
|
|
147
166
|
}
|
|
148
|
-
function
|
|
149
|
-
if (!
|
|
150
|
-
let { scope: n, final: r } =
|
|
151
|
-
|
|
152
|
-
|
|
167
|
+
function k(e, t) {
|
|
168
|
+
if (!fe(e) || e.getAttribute("data-formie-loading") === "true") return;
|
|
169
|
+
let { scope: n, final: r } = T(e), i = t.isValid(n, {
|
|
170
|
+
includeHiddenPages: r,
|
|
171
|
+
renderErrors: !1
|
|
172
|
+
});
|
|
173
|
+
e.setAttribute(de, i ? "true" : "false"), pe(e).forEach((e) => {
|
|
174
|
+
if (me(e)) {
|
|
153
175
|
if (i) {
|
|
154
|
-
if (!e.hasAttribute(
|
|
155
|
-
e.hasAttribute(
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
e.hasAttribute(C) || (e.disabled && e.setAttribute(w, "true"), e.setAttribute(C, "true")), e.disabled ||= !0;
|
|
176
|
+
if (!e.hasAttribute(D)) return;
|
|
177
|
+
e.hasAttribute(O) ? (e.disabled = !0, e.removeAttribute(O)) : e.disabled = !1, e.removeAttribute(D);
|
|
178
|
+
} else e.hasAttribute(D) || (e.disabled && e.setAttribute(O, "true"), e.setAttribute(D, "true")), e.disabled ||= !0;
|
|
159
179
|
}
|
|
160
180
|
});
|
|
161
181
|
}
|
|
162
|
-
function
|
|
163
|
-
if (!
|
|
182
|
+
function he(e, t, n) {
|
|
183
|
+
if (!fe(e)) return () => {};
|
|
164
184
|
let r = !1, i = () => {
|
|
165
185
|
r || (r = !0, queueMicrotask(() => {
|
|
166
|
-
r = !1,
|
|
186
|
+
r = !1, k(e, t);
|
|
167
187
|
}));
|
|
168
188
|
};
|
|
169
189
|
i();
|
|
@@ -206,18 +226,18 @@ function ue(e, t, n) {
|
|
|
206
226
|
}
|
|
207
227
|
//#endregion
|
|
208
228
|
//#region src/js/core/submit-result-state.ts
|
|
209
|
-
var
|
|
210
|
-
function
|
|
229
|
+
var ge = "STALE_SUBMISSION_STATE", A = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), M = i("general", "submit-result");
|
|
230
|
+
function N(e, t, n) {
|
|
211
231
|
let r = e.querySelector(`input[name="${t}"]`);
|
|
212
232
|
r || (r = document.createElement("input"), r.type = "hidden", r.name = t, e.appendChild(r)), r.value = n;
|
|
213
233
|
}
|
|
214
|
-
function
|
|
234
|
+
function P(e, t) {
|
|
215
235
|
e.setAttribute("data-formie-internal-navigation", t);
|
|
216
236
|
}
|
|
217
|
-
function
|
|
237
|
+
function F(e, t) {
|
|
218
238
|
e.querySelector(`input[name="${t}"]`)?.remove();
|
|
219
239
|
}
|
|
220
|
-
function
|
|
240
|
+
function _e(e, t) {
|
|
221
241
|
try {
|
|
222
242
|
let n = new URL(e, window.location.href);
|
|
223
243
|
return n.searchParams.delete(t), n.toString();
|
|
@@ -225,38 +245,38 @@ function fe(e, t) {
|
|
|
225
245
|
return e;
|
|
226
246
|
}
|
|
227
247
|
}
|
|
228
|
-
function
|
|
248
|
+
function ve(e) {
|
|
229
249
|
try {
|
|
230
250
|
return new URL(e, window.location.href).origin === window.location.origin;
|
|
231
251
|
} catch {
|
|
232
252
|
return !1;
|
|
233
253
|
}
|
|
234
254
|
}
|
|
235
|
-
function
|
|
255
|
+
function I(e) {
|
|
236
256
|
return Array.from(e.querySelectorAll("[data-formie-page]"));
|
|
237
257
|
}
|
|
238
|
-
function
|
|
258
|
+
function ye(e) {
|
|
239
259
|
return Array.from(e.querySelectorAll("[data-formie-tab]"));
|
|
240
260
|
}
|
|
241
|
-
function
|
|
261
|
+
function be(e, t, n) {
|
|
242
262
|
return t < 0 || n < 1 ? 0 : (e.dataset.formieProgressCalculation === "page-position" ? "page-position" : "completion") == "page-position" ? Math.round((t + 1) / n * 100) : Math.round(t / n * 100);
|
|
243
263
|
}
|
|
244
|
-
function
|
|
264
|
+
function xe(e) {
|
|
245
265
|
return e <= 0 ? "start" : e >= 100 ? "end" : "middle";
|
|
246
266
|
}
|
|
247
|
-
function
|
|
267
|
+
function Se(e) {
|
|
248
268
|
return (e.dataset.formieCompletionBehavior || e.dataset.formieSubmitAction || "").trim();
|
|
249
269
|
}
|
|
250
|
-
function
|
|
251
|
-
return t.completion ? String(t.completion.behavior) :
|
|
270
|
+
function L(e, t) {
|
|
271
|
+
return t.completion ? String(t.completion.behavior) : Se(e);
|
|
252
272
|
}
|
|
253
|
-
function
|
|
273
|
+
function R(e) {
|
|
254
274
|
let t = e.dataset.formieHideFormAfterSubmit ?? e.dataset.formieSubmitActionFormHide;
|
|
255
275
|
if (t === void 0) return !1;
|
|
256
276
|
let n = t.trim().toLowerCase();
|
|
257
277
|
return n === "true" || n === "1" || n === "";
|
|
258
278
|
}
|
|
259
|
-
function
|
|
279
|
+
function z(e, t) {
|
|
260
280
|
e.toggleAttribute("data-formie-form-hidden", t), [
|
|
261
281
|
"[data-formie-form-header]",
|
|
262
282
|
"[data-formie-form-navigation]",
|
|
@@ -269,91 +289,90 @@ function I(e, t) {
|
|
|
269
289
|
});
|
|
270
290
|
});
|
|
271
291
|
}
|
|
272
|
-
function
|
|
273
|
-
let t =
|
|
274
|
-
typeof t == "number" && (window.clearTimeout(t),
|
|
292
|
+
function B(e) {
|
|
293
|
+
let t = A.get(e);
|
|
294
|
+
typeof t == "number" && (window.clearTimeout(t), A.delete(e));
|
|
275
295
|
}
|
|
276
|
-
function
|
|
277
|
-
|
|
296
|
+
function Ce(e, t) {
|
|
297
|
+
j.has(e) || j.set(e, e.innerHTML), e.textContent = t;
|
|
278
298
|
}
|
|
279
|
-
function
|
|
280
|
-
let t =
|
|
281
|
-
t !== void 0 && (e.innerHTML = t,
|
|
299
|
+
function V(e) {
|
|
300
|
+
let t = j.get(e);
|
|
301
|
+
t !== void 0 && (e.innerHTML = t, j.delete(e));
|
|
282
302
|
}
|
|
283
|
-
function
|
|
303
|
+
function we(e, t) {
|
|
284
304
|
let n = e.querySelector("[data-formie-progress-bar]"), r = e.querySelector("[data-formie-progress-value]");
|
|
285
|
-
n && (n.style.width = `${t}%`, n.setAttribute("aria-valuenow", `${t}`), n.setAttribute("data-formie-progress-state",
|
|
305
|
+
n && (n.style.width = `${t}%`, n.setAttribute("aria-valuenow", `${t}`), n.setAttribute("data-formie-progress-state", xe(t)), r && (r.textContent = `${t}%`, r.setAttribute("data-formie-progress-value", `${t}`)));
|
|
286
306
|
}
|
|
287
|
-
function
|
|
307
|
+
function Te(e, t) {
|
|
288
308
|
if (!t) return;
|
|
289
309
|
let n = (e.dataset.formieLoadingIndicator || "").trim();
|
|
290
310
|
if (n) {
|
|
291
|
-
if (t.setAttribute("data-formie-loading-indicator", n), n === "spinner")
|
|
292
|
-
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
if (n === "text") {
|
|
311
|
+
if (t.setAttribute("data-formie-loading-indicator", n), n === "spinner") a(t, e, "loading", !0), V(t), t.removeAttribute("data-formie-loading-text");
|
|
312
|
+
else if (n === "text") {
|
|
296
313
|
let n = (e.dataset.formieLoadingIndicatorText || "").trim(), r = t.textContent?.trim() || "", i = n || r;
|
|
297
|
-
t.setAttribute("data-formie-loading-text", i),
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
R(t), t.removeAttribute("data-formie-loading-text");
|
|
314
|
+
t.setAttribute("data-formie-loading-text", i), Ce(t, i);
|
|
315
|
+
} else V(t), t.removeAttribute("data-formie-loading-text");
|
|
301
316
|
}
|
|
302
317
|
}
|
|
303
|
-
function
|
|
318
|
+
function H(e) {
|
|
304
319
|
return Array.from(e.querySelectorAll("[data-formie-action]"));
|
|
305
320
|
}
|
|
306
|
-
function
|
|
307
|
-
e.getAttribute("data-formie-loading") !== "true" && (e.setAttribute("data-formie-loading", "true"),
|
|
321
|
+
function Ee(e, t) {
|
|
322
|
+
e.getAttribute("data-formie-loading") !== "true" && (e.setAttribute("data-formie-loading", "true"), H(e).forEach((e) => {
|
|
308
323
|
"disabled" in e && (e.disabled ? e.setAttribute("data-formie-was-disabled", "true") : e.removeAttribute("data-formie-was-disabled"), e.disabled = !0);
|
|
309
|
-
}), t && (t.setAttribute("data-formie-loading", "true"),
|
|
324
|
+
}), t && (t.setAttribute("data-formie-loading", "true"), Te(e, t)));
|
|
310
325
|
}
|
|
311
|
-
function
|
|
312
|
-
e.removeAttribute("data-formie-loading"),
|
|
326
|
+
function U(e) {
|
|
327
|
+
e.removeAttribute("data-formie-loading"), H(e).forEach((t) => {
|
|
313
328
|
if ("disabled" in t) {
|
|
314
329
|
let e = t;
|
|
315
330
|
e.disabled = e.getAttribute("data-formie-was-disabled") === "true";
|
|
316
331
|
}
|
|
317
|
-
|
|
332
|
+
V(t), t.removeAttribute("data-formie-was-disabled"), t.removeAttribute("data-formie-loading"), a(t, e, "loading", !1), t.removeAttribute("data-formie-loading-indicator"), t.removeAttribute("data-formie-loading-text");
|
|
318
333
|
});
|
|
319
334
|
let t = e;
|
|
320
|
-
t.formieValidation &&
|
|
335
|
+
t.formieValidation && k(e, t.formieValidation);
|
|
321
336
|
}
|
|
322
|
-
function
|
|
323
|
-
let n =
|
|
337
|
+
function W(e, t) {
|
|
338
|
+
let n = I(e), r = ye(e), i = n.findIndex((e) => e.getAttribute("data-formie-page-id") === t);
|
|
324
339
|
n.forEach((n) => {
|
|
325
|
-
n.getAttribute("data-formie-page-id") === t ? (n.removeAttribute("data-formie-page-hidden"),
|
|
340
|
+
n.getAttribute("data-formie-page-id") === t ? (n.removeAttribute("data-formie-page-hidden"), o(n, e, "pageHidden")) : (n.setAttribute("data-formie-page-hidden", "true"), s(n, e, "pageHidden"));
|
|
326
341
|
}), r.forEach((n, r) => {
|
|
327
|
-
let c = n.getAttribute("data-formie-page-id") === t, l =
|
|
328
|
-
|
|
342
|
+
let c = n.getAttribute("data-formie-page-id") === t, l = i > -1 && r < i;
|
|
343
|
+
a(n, e, "tabCurrent", c), a(n, e, "tabComplete", l);
|
|
329
344
|
let u = n.querySelector("[data-formie-tab-link]");
|
|
330
|
-
u && (
|
|
331
|
-
}),
|
|
345
|
+
u && (a(u, e, "tabLinkCurrent", c), c ? o(u, e, "tabLinkInactive") : s(u, e, "tabLinkInactive")), c ? n.setAttribute("aria-current", "page") : n.removeAttribute("aria-current"), l ? n.setAttribute("data-formie-tab-complete", "true") : n.removeAttribute("data-formie-tab-complete");
|
|
346
|
+
}), i > -1 && n.length > 0 && we(e, be(e, i, n.length)), N(e, "pageId", t), w(e);
|
|
332
347
|
let c = e;
|
|
333
|
-
c.formieValidation &&
|
|
348
|
+
c.formieValidation && k(e, c.formieValidation);
|
|
334
349
|
}
|
|
335
|
-
function
|
|
350
|
+
function De(e, t) {
|
|
351
|
+
if (t.meta?.resetSubmissionIdentity === !0) {
|
|
352
|
+
F(e, "submissionId"), F(e, "submissionUid"), F(e, "progressId"), N(e, "expectedVersion", "0"), G(e);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
336
355
|
let n = t.meta?.session?.version ?? t.meta?.version;
|
|
337
|
-
typeof n == "number" &&
|
|
356
|
+
typeof n == "number" && N(e, "expectedVersion", String(n));
|
|
338
357
|
let r = t.meta?.submissionUid;
|
|
339
|
-
typeof r == "string" && r.trim() !== "" &&
|
|
358
|
+
typeof r == "string" && r.trim() !== "" && N(e, "submissionUid", r);
|
|
340
359
|
let i = (t.meta?.session)?.continuation?.progressId;
|
|
341
|
-
typeof i == "string" && i.trim() !== "" ?
|
|
360
|
+
typeof i == "string" && i.trim() !== "" ? N(e, "progressId", i) : F(e, "progressId");
|
|
342
361
|
}
|
|
343
|
-
function
|
|
362
|
+
function G(e) {
|
|
344
363
|
let t = e.getAttribute("action");
|
|
345
|
-
t && e.setAttribute("action",
|
|
364
|
+
t && e.setAttribute("action", _e(t, "resumeToken"));
|
|
346
365
|
try {
|
|
347
366
|
let e = new URL(window.location.href);
|
|
348
367
|
if (!e.searchParams.has("resumeToken")) return;
|
|
349
368
|
e.searchParams.delete("resumeToken"), window.history.replaceState({}, document.title, `${e.pathname}${e.search}${e.hash}`);
|
|
350
369
|
} catch {}
|
|
351
370
|
}
|
|
352
|
-
function
|
|
371
|
+
function Oe(e, t) {
|
|
353
372
|
let n = t.meta?.resumeUrl;
|
|
354
373
|
if (typeof n != "string" || n.trim() === "") return;
|
|
355
374
|
let r = n.trim();
|
|
356
|
-
if (
|
|
375
|
+
if (ve(r)) {
|
|
357
376
|
e.getAttribute("action") && e.setAttribute("action", r);
|
|
358
377
|
try {
|
|
359
378
|
let e = new URL(r, window.location.href);
|
|
@@ -361,89 +380,72 @@ function Ce(e, t) {
|
|
|
361
380
|
} catch {}
|
|
362
381
|
}
|
|
363
382
|
}
|
|
364
|
-
function
|
|
365
|
-
let r = t.formieValidation, i =
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
b(t), t.dispatchEvent(new CustomEvent(e("reset"), { bubbles: !0 }));
|
|
371
|
-
}
|
|
372
|
-
function we(e) {
|
|
373
|
-
return e.code === de || e.meta?.resetState === !0;
|
|
383
|
+
function K(t, n = {}) {
|
|
384
|
+
let r = t.formieValidation, i = I(t)[0]?.getAttribute("data-formie-page-id");
|
|
385
|
+
B(t), t.reset(), t.querySelectorAll("[data-formie-summary-token]").forEach((e) => {
|
|
386
|
+
e instanceof HTMLInputElement ? e.remove() : e.removeAttribute("data-formie-summary-token");
|
|
387
|
+
}), t.querySelectorAll("[data-formie-summary-blocks]").forEach((e) => e.replaceChildren()), n.preserveHiddenState || z(t, !1), F(t, "submissionId"), N(t, "expectedVersion", "0"), F(t, "submissionUid"), F(t, "progressId"), F(t, "pageId"), G(t), ue(t), r?.resetLiveState(), i ? (W(t, i), y(t, e("reset"), void 0)) : (w(t), y(t, e("reset"), void 0));
|
|
374
388
|
}
|
|
375
|
-
function
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
389
|
+
function ke(e) {
|
|
390
|
+
return e.code === ge || e.meta?.resetState === !0;
|
|
391
|
+
}
|
|
392
|
+
function Ae(e, t) {
|
|
393
|
+
let n = t.submitData, i = /* @__PURE__ */ new Set(), a = !1;
|
|
394
|
+
if (Array.isArray(n) && n.length > 0) {
|
|
395
|
+
let t = n.filter((e) => typeof e == "object" && !!e && "event" in e && typeof e.event == "string");
|
|
396
|
+
for (let n of t) {
|
|
397
|
+
let t = r(n.event);
|
|
398
|
+
i.add(t), M.log("Dispatching submitData event.", { eventName: t }), t.startsWith("formie:payment:") && (a = !0), e.dispatchEvent(new CustomEvent(t, {
|
|
382
399
|
bubbles: !0,
|
|
383
|
-
detail: { data:
|
|
400
|
+
detail: { data: n.data }
|
|
384
401
|
}));
|
|
385
402
|
}
|
|
386
403
|
}
|
|
387
|
-
let o = t.payment?.action, s = o ? String(o.event || "") : "", c = o ? o.payload : void 0, l =
|
|
404
|
+
let o = t.payment?.action, s = o ? String(o.event || "") : "", c = o ? o.payload : void 0, l = r(s);
|
|
388
405
|
return l && !i.has(l) && (l.startsWith("formie:payment:") && (a = !0), e.dispatchEvent(new CustomEvent(l, {
|
|
389
406
|
bubbles: !0,
|
|
390
407
|
detail: { data: c }
|
|
391
|
-
})),
|
|
408
|
+
})), M.log("Dispatching fallback payment action event.", { eventName: l })), { hasPaymentFollowUpEvent: a };
|
|
392
409
|
}
|
|
393
|
-
function
|
|
394
|
-
if (
|
|
410
|
+
function je(e, t, n) {
|
|
411
|
+
if (M.log("Applying submit result state.", {
|
|
395
412
|
ok: t.ok,
|
|
396
413
|
action: n,
|
|
397
414
|
code: t.code,
|
|
398
415
|
hasRedirect: !!t.redirect?.url,
|
|
399
416
|
hasSubmitData: Array.isArray(t.submitData) && t.submitData.length > 0
|
|
400
|
-
}),
|
|
401
|
-
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
let r = Te(e, t);
|
|
405
|
-
if (!t.ok && t.redirect?.url && !r.hasPaymentFollowUpEvent) {
|
|
406
|
-
k.log("Applying redirect fallback for failed result.", {
|
|
407
|
-
url: t.redirect.url,
|
|
408
|
-
target: t.redirect.target
|
|
409
|
-
}), L(e), t.redirect.target === "new-tab" ? window.open(t.redirect.url, "_blank", "noopener,noreferrer") : (j(e, "redirect"), window.location.href = t.redirect.url);
|
|
417
|
+
}), ke(t)) {
|
|
418
|
+
K(e), M.log("Resetting state due to stale/reset marker.");
|
|
410
419
|
return;
|
|
411
420
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
if (n === "save")
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
if (t.completion && n === "submit" && !t.redirect?.url) {
|
|
425
|
-
let n = P(e, t), r = n === "message" && F(e);
|
|
421
|
+
t.payment?.action?.type === "redirect" && t.payment.action.url && P(e, "payment-redirect");
|
|
422
|
+
let r = Ae(e, t);
|
|
423
|
+
if (!t.ok && t.redirect?.url && !r.hasPaymentFollowUpEvent) M.log("Applying redirect fallback for failed result.", {
|
|
424
|
+
url: t.redirect.url,
|
|
425
|
+
target: t.redirect.target
|
|
426
|
+
}), B(e), t.redirect.target === "new-tab" ? window.open(t.redirect.url, "_blank", "noopener,noreferrer") : (P(e, "redirect"), window.location.href = t.redirect.url);
|
|
427
|
+
else if (De(e, t), !t.ok) M.log("Non-redirect failure; keeping current form state."), B(e);
|
|
428
|
+
else if (Array.isArray(t.clientEvents) && t.clientEvents.length > 0 ? C(e, t.clientEvents) : oe(e, n), t.nextPage?.id) B(e), e.formieValidation?.resetLiveState(), W(e, t.nextPage.id), y(e, "formie:page:navigate:after", { pageId: t.nextPage.id }), M.log("Advanced to next page.", { nextPageId: t.nextPage.id });
|
|
429
|
+
else if (n === "save") B(e), Oe(e, t), M.log("Applied save/resume token state.");
|
|
430
|
+
else if (t.completion && n === "submit" && !t.redirect?.url) {
|
|
431
|
+
let n = L(e, t), r = n === "message" && R(e);
|
|
426
432
|
if (n === "reload") {
|
|
427
|
-
|
|
433
|
+
B(e), P(e, "reload"), window.location.reload();
|
|
428
434
|
return;
|
|
429
435
|
}
|
|
430
436
|
if (n === "reset") {
|
|
431
|
-
|
|
437
|
+
K(e);
|
|
432
438
|
return;
|
|
433
439
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
L(e), U(e, { preserveHiddenState: n });
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
L(e);
|
|
440
|
+
B(e), K(e, { preserveHiddenState: r });
|
|
441
|
+
} else if (n === "submit" && t.redirect?.url && t.redirect.target === "new-tab") {
|
|
442
|
+
let n = L(e, t) === "message" && R(e);
|
|
443
|
+
B(e), K(e, { preserveHiddenState: n });
|
|
444
|
+
} else B(e);
|
|
443
445
|
}
|
|
444
446
|
//#endregion
|
|
445
447
|
//#region src/js/modules/payments/constants.ts
|
|
446
|
-
var
|
|
448
|
+
var Me = 2500, Ne = {
|
|
447
449
|
bpoint: ["bpointToken"],
|
|
448
450
|
stripe: ["stripePaymentIntentId"],
|
|
449
451
|
paypal: ["paypalOrderId", "paypalAuthId"],
|
|
@@ -458,25 +460,25 @@ var De = 2500, Oe = {
|
|
|
458
460
|
};
|
|
459
461
|
//#endregion
|
|
460
462
|
//#region src/js/utils/fields.ts
|
|
461
|
-
function
|
|
463
|
+
function Pe(e) {
|
|
462
464
|
return e.replace("{field:", "").replace("{", "").replace("}", "").replace("]", "").split("[").join("][");
|
|
463
465
|
}
|
|
464
|
-
function
|
|
465
|
-
return `fields[${
|
|
466
|
+
function Fe(e) {
|
|
467
|
+
return `fields[${Pe(e)}]`;
|
|
466
468
|
}
|
|
467
|
-
function
|
|
468
|
-
let n =
|
|
469
|
+
function Ie(e, t) {
|
|
470
|
+
let n = Fe(t), r = Array.from(e.querySelectorAll(`[name="${n}"]`)), i = Array.from(e.querySelectorAll(`[name="${n}[]"]`));
|
|
469
471
|
return (i.length ? i : r).filter((e) => e instanceof HTMLElement);
|
|
470
472
|
}
|
|
471
|
-
function
|
|
472
|
-
let n =
|
|
473
|
+
function q(e, t) {
|
|
474
|
+
let n = Ie(e, t);
|
|
473
475
|
for (let e of n) {
|
|
474
476
|
let t = e.closest("[data-formie-field-handle]")?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim();
|
|
475
477
|
if (t) return t;
|
|
476
478
|
}
|
|
477
479
|
return "";
|
|
478
480
|
}
|
|
479
|
-
function
|
|
481
|
+
function J(e) {
|
|
480
482
|
let t = e.replace(/[^\d.,-]/g, ""), n = t.includes(","), r = t.includes(".");
|
|
481
483
|
if (n && r) t = t.lastIndexOf(",") > t.lastIndexOf(".") ? t.replace(/\./g, "").replace(",", ".") : t.replace(/,/g, "");
|
|
482
484
|
else if (n && !r) {
|
|
@@ -487,17 +489,17 @@ function G(e) {
|
|
|
487
489
|
}
|
|
488
490
|
//#endregion
|
|
489
491
|
//#region src/js/modules/payments/utils.ts
|
|
490
|
-
function
|
|
492
|
+
function Y(e) {
|
|
491
493
|
let t = e;
|
|
492
494
|
return !t.closest("[data-formie-conditionally-hidden]") && !t.closest("[data-formie-row-hidden]") && !t.closest("[data-formie-page-hidden]") && !t.closest("[hidden]");
|
|
493
495
|
}
|
|
494
|
-
function
|
|
496
|
+
function X(e, t) {
|
|
495
497
|
let n = t.replace(/"/g, "\\\"");
|
|
496
498
|
return e.querySelector(`input[name$="[${n}]"]`) || e.querySelector(`input[name$="${n}"]`);
|
|
497
499
|
}
|
|
498
|
-
function
|
|
500
|
+
function Z(e, t) {
|
|
499
501
|
let n = t.find((t) => {
|
|
500
|
-
let n =
|
|
502
|
+
let n = X(e, t);
|
|
501
503
|
return !n || String(n.value || "").trim() === "";
|
|
502
504
|
});
|
|
503
505
|
return {
|
|
@@ -505,35 +507,35 @@ function J(e, t) {
|
|
|
505
507
|
missingSuffix: n
|
|
506
508
|
};
|
|
507
509
|
}
|
|
508
|
-
async function
|
|
509
|
-
let r =
|
|
510
|
+
async function Le(e, t, n) {
|
|
511
|
+
let r = Z(e, t);
|
|
510
512
|
if (r.ok) return r;
|
|
511
513
|
let i = Date.now() + Math.max(n, 0);
|
|
512
514
|
for (; Date.now() < i;) {
|
|
513
515
|
await c(120);
|
|
514
|
-
let n =
|
|
516
|
+
let n = Z(e, t);
|
|
515
517
|
if (n.ok) return n;
|
|
516
518
|
}
|
|
517
|
-
return
|
|
519
|
+
return Z(e, t);
|
|
518
520
|
}
|
|
519
521
|
//#endregion
|
|
520
522
|
//#region src/js/modules/payments/host.ts
|
|
521
|
-
var
|
|
523
|
+
var Re = /* @__PURE__ */ new Set([
|
|
522
524
|
"handle",
|
|
523
525
|
"requiredInputSuffixes",
|
|
524
526
|
"waitForValueMs",
|
|
525
527
|
"errorMessage"
|
|
526
|
-
]),
|
|
527
|
-
function
|
|
528
|
+
]), ze = "[data-payment-success]", Be = "[data-payment-error]";
|
|
529
|
+
function Ve(e, t) {
|
|
528
530
|
return (typeof t.handle == "string" && t.handle.trim() !== "" ? t.handle.trim() : "") || e;
|
|
529
531
|
}
|
|
530
|
-
function
|
|
531
|
-
let r = t || {}, i = Object.entries(r).reduce((e, [t, n]) => (
|
|
532
|
+
function He(e, t, n) {
|
|
533
|
+
let r = t || {}, i = Object.entries(r).reduce((e, [t, n]) => (Re.has(t) || (e[t] = n), e), {}), a = Array.isArray(r.requiredInputSuffixes) ? r.requiredInputSuffixes.map(String).filter(Boolean) : n.defaultRequiredInputSuffixes || [], o = Number(r.waitForValueMs ?? n.defaultWaitForValueMs ?? 2500), s = typeof r.errorMessage == "string" && r.errorMessage.trim() !== "" ? r.errorMessage.trim() : "Payment authorization is incomplete.";
|
|
532
534
|
return {
|
|
533
|
-
handle:
|
|
535
|
+
handle: Ve(e, r),
|
|
534
536
|
transport: {
|
|
535
537
|
requiredInputSuffixes: a,
|
|
536
|
-
waitForValueMs: Number.isFinite(o) ? o :
|
|
538
|
+
waitForValueMs: Number.isFinite(o) ? o : Me,
|
|
537
539
|
errorMessage: s
|
|
538
540
|
},
|
|
539
541
|
provider: i
|
|
@@ -544,9 +546,9 @@ function Q(e, t, n) {
|
|
|
544
546
|
e.removeEventListener(t, n);
|
|
545
547
|
};
|
|
546
548
|
}
|
|
547
|
-
function
|
|
548
|
-
let n = e.target, r = e.form, i = e.root, a = r || i,
|
|
549
|
-
let t =
|
|
549
|
+
function Ue(e, t) {
|
|
550
|
+
let n = e.target, r = e.form, i = e.root, a = r || i, o = t.transport.requiredInputSuffixes, c = () => m(r || i), h = (e) => {
|
|
551
|
+
let t = p(e, c()).value;
|
|
550
552
|
return Array.isArray(t) ? t[0] || "" : String(t || "");
|
|
551
553
|
};
|
|
552
554
|
return {
|
|
@@ -556,62 +558,62 @@ function Fe(e, t) {
|
|
|
556
558
|
updateInputs: (e, t) => {
|
|
557
559
|
let r = Array.isArray(e) ? e : [e];
|
|
558
560
|
for (let e of r) {
|
|
559
|
-
let r =
|
|
561
|
+
let r = X(a, e) ?? n.querySelector(`input[name*="${e}"]`);
|
|
560
562
|
r && (r.value = t);
|
|
561
563
|
}
|
|
562
564
|
},
|
|
563
565
|
addError: (e) => {
|
|
564
|
-
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(
|
|
566
|
+
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(Be);
|
|
565
567
|
a && a.remove();
|
|
566
|
-
let
|
|
567
|
-
|
|
568
|
+
let o = document.createElement("div");
|
|
569
|
+
o.setAttribute("data-payment-error", ""), o.textContent = e, s(o, r || i, "fieldError"), t.appendChild(o);
|
|
568
570
|
},
|
|
569
571
|
removeError: () => {
|
|
570
|
-
n.querySelector(
|
|
572
|
+
n.querySelector(Be)?.remove();
|
|
571
573
|
},
|
|
572
574
|
addSuccess: (e) => {
|
|
573
|
-
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(
|
|
575
|
+
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(ze);
|
|
574
576
|
a && a.remove();
|
|
575
|
-
let
|
|
576
|
-
|
|
577
|
+
let o = document.createElement("div");
|
|
578
|
+
o.setAttribute("data-payment-success", ""), o.textContent = e, s(o, r || i, "successMessage"), t.appendChild(o);
|
|
577
579
|
},
|
|
578
580
|
removeSuccess: () => {
|
|
579
|
-
n.querySelector(
|
|
581
|
+
n.querySelector(ze)?.remove();
|
|
580
582
|
},
|
|
581
|
-
hasToken: () =>
|
|
582
|
-
waitForToken: (e = t.transport.waitForValueMs) =>
|
|
583
|
+
hasToken: () => Z(a, o).ok,
|
|
584
|
+
waitForToken: (e = t.transport.waitForValueMs) => Le(a, o, e).then((e) => e.ok),
|
|
583
585
|
getFieldValue: (e, t = "string") => {
|
|
584
586
|
let n = h(e);
|
|
585
|
-
return t === "float" || t === "int" || t === "number" ?
|
|
587
|
+
return t === "float" || t === "int" || t === "number" ? J(n) : n;
|
|
586
588
|
},
|
|
587
589
|
resolveAmount: (e) => {
|
|
588
|
-
let t = r || i, n = String(e.type || "").toLowerCase() === "dynamic" && typeof e.variable == "string" && e.variable.trim() !== "", a = e.value ?? (n ? e.variable : e.fixed), o = String(a ?? "").trim(),
|
|
589
|
-
if (Number.isFinite(
|
|
590
|
+
let t = r || i, n = String(e.type || "").toLowerCase() === "dynamic" && typeof e.variable == "string" && e.variable.trim() !== "", a = e.value ?? (n ? e.variable : e.fixed), o = String(a ?? "").trim(), s = typeof a == "number" ? a : J(o);
|
|
591
|
+
if (Number.isFinite(s) && s > 0) return {
|
|
590
592
|
ok: !0,
|
|
591
|
-
value:
|
|
593
|
+
value: s
|
|
592
594
|
};
|
|
593
595
|
if (o !== "") {
|
|
594
|
-
let e = h(o), n =
|
|
596
|
+
let e = h(o), n = J(e);
|
|
595
597
|
if (Number.isFinite(n) && n > 0) return {
|
|
596
598
|
ok: !0,
|
|
597
599
|
value: n
|
|
598
600
|
};
|
|
599
|
-
let r =
|
|
601
|
+
let r = q(t, o);
|
|
600
602
|
if (!e) return {
|
|
601
603
|
ok: !1,
|
|
602
|
-
error: r ?
|
|
604
|
+
error: r ? u("Provide a value for \"{label}\" to proceed.", { label: r }) : u("Provide a payment amount to proceed.")
|
|
603
605
|
};
|
|
604
606
|
}
|
|
605
607
|
return {
|
|
606
608
|
ok: !1,
|
|
607
|
-
error:
|
|
609
|
+
error: u("Payment amount must be greater than 0.")
|
|
608
610
|
};
|
|
609
611
|
},
|
|
610
612
|
resolveCurrency: (e) => {
|
|
611
|
-
let t = r || i, n = String(e.type || "").toLowerCase() === "dynamic" && typeof e.variable == "string" && e.variable.trim() !== "", a = e.value ?? (n ? e.variable : e.fixed ?? e.defaultCurrency ?? ""), o = String(a ?? "").trim(),
|
|
612
|
-
if (/^[A-Z]{3}$/.test(
|
|
613
|
+
let t = r || i, n = String(e.type || "").toLowerCase() === "dynamic" && typeof e.variable == "string" && e.variable.trim() !== "", a = e.value ?? (n ? e.variable : e.fixed ?? e.defaultCurrency ?? ""), o = String(a ?? "").trim(), s = o.toUpperCase();
|
|
614
|
+
if (/^[A-Z]{3}$/.test(s) && !n) return {
|
|
613
615
|
ok: !0,
|
|
614
|
-
value:
|
|
616
|
+
value: s
|
|
615
617
|
};
|
|
616
618
|
if (o !== "") {
|
|
617
619
|
let e = String(h(o) || "").trim(), n = e.toUpperCase();
|
|
@@ -619,47 +621,47 @@ function Fe(e, t) {
|
|
|
619
621
|
ok: !0,
|
|
620
622
|
value: n
|
|
621
623
|
};
|
|
622
|
-
let r =
|
|
624
|
+
let r = q(t, o);
|
|
623
625
|
if (!e) return {
|
|
624
626
|
ok: !1,
|
|
625
|
-
error: r ?
|
|
627
|
+
error: r ? u("Provide a value for \"{label}\" to proceed.", { label: r }) : u("Provide a payment currency to proceed.")
|
|
626
628
|
};
|
|
627
629
|
}
|
|
628
630
|
return {
|
|
629
631
|
ok: !1,
|
|
630
|
-
error:
|
|
632
|
+
error: u("Payment currency must be a valid 3-letter code.")
|
|
631
633
|
};
|
|
632
634
|
},
|
|
633
635
|
watchFieldValueChanges: (e, t, n = 600) => {
|
|
634
636
|
let a = r || i, o = e.map((e) => String(e || "").trim()).filter(Boolean);
|
|
635
637
|
if (o.length === 0) return () => {};
|
|
636
|
-
let s =
|
|
638
|
+
let s = c(), u = /* @__PURE__ */ new Set();
|
|
637
639
|
o.forEach((e) => {
|
|
638
|
-
let t =
|
|
640
|
+
let t = d(e), n = s.get(t);
|
|
639
641
|
if (n?.names?.length) {
|
|
640
642
|
n.names.forEach((e) => {
|
|
641
|
-
|
|
643
|
+
u.add(e);
|
|
642
644
|
});
|
|
643
645
|
return;
|
|
644
646
|
}
|
|
645
|
-
let r =
|
|
646
|
-
r && (
|
|
647
|
+
let r = f(t);
|
|
648
|
+
r && (u.add(r), u.add(`${r}[]`));
|
|
647
649
|
});
|
|
648
|
-
let
|
|
650
|
+
let p = l(() => {
|
|
649
651
|
t();
|
|
650
|
-
}, n),
|
|
652
|
+
}, n), m = (e) => {
|
|
651
653
|
let t = e.target?.name || "";
|
|
652
|
-
t &&
|
|
654
|
+
t && u.has(t) && p();
|
|
653
655
|
};
|
|
654
|
-
return a.addEventListener("input",
|
|
655
|
-
a.removeEventListener("input",
|
|
656
|
+
return a.addEventListener("input", m), a.addEventListener("change", m), () => {
|
|
657
|
+
a.removeEventListener("input", m), a.removeEventListener("change", m);
|
|
656
658
|
};
|
|
657
659
|
},
|
|
658
660
|
triggerSubmit: () => {
|
|
659
661
|
r && r.setAttribute("data-formie-internal-resubmit", "true"), r && typeof r.requestSubmit == "function" ? r.requestSubmit() : r && r.submit();
|
|
660
662
|
},
|
|
661
663
|
releaseSubmitLoading: () => {
|
|
662
|
-
r && (r.removeAttribute("data-formie-internal-resubmit"),
|
|
664
|
+
r && (r.removeAttribute("data-formie-internal-resubmit"), U(r));
|
|
663
665
|
},
|
|
664
666
|
getBillingData: (e) => {
|
|
665
667
|
let t = {};
|
|
@@ -686,9 +688,9 @@ function Fe(e, t) {
|
|
|
686
688
|
}
|
|
687
689
|
//#endregion
|
|
688
690
|
//#region src/js/modules/payments/factories.ts
|
|
689
|
-
var $ =
|
|
690
|
-
function
|
|
691
|
-
let t = e.defaultRequiredInputSuffixes ??
|
|
691
|
+
var $ = i("payments");
|
|
692
|
+
function We(e) {
|
|
693
|
+
let t = e.defaultRequiredInputSuffixes ?? Ne[e.moduleId.split(":")[1]] ?? [];
|
|
692
694
|
return {
|
|
693
695
|
moduleId: e.moduleId,
|
|
694
696
|
version: 2,
|
|
@@ -705,85 +707,93 @@ function Ie(e) {
|
|
|
705
707
|
await o.destroy();
|
|
706
708
|
} catch {}
|
|
707
709
|
}
|
|
708
|
-
let s =
|
|
710
|
+
let s = He(e.moduleId.split(":")[1], n.options || {}, { defaultRequiredInputSuffixes: t }), c = Ue(n, s), l = {
|
|
709
711
|
...n,
|
|
710
712
|
options: s,
|
|
711
713
|
services: c
|
|
712
|
-
}, u = [], d = null, f = null, p = null, m = null, h = async () => (d ||= ($.log("Loading payment provider API.", { moduleId: e.moduleId }), e.load(l)), d),
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
714
|
+
}, u = [], d = null, f = null, p = null, m = null, h = !1, g = null, _ = null, v = async () => (d ||= ($.log("Loading payment provider API.", { moduleId: e.moduleId }), e.load(l)), d), y = async () => {
|
|
715
|
+
let t = e.mount;
|
|
716
|
+
if (!h && t && !f && Y(n.target)) return p ||= (async () => {
|
|
717
|
+
try {
|
|
718
|
+
let r = await v();
|
|
719
|
+
if (h || !Y(n.target)) return;
|
|
720
|
+
c.removeError(), f = await t({
|
|
721
|
+
api: r,
|
|
722
|
+
field: n.target,
|
|
723
|
+
services: c,
|
|
724
|
+
options: s,
|
|
725
|
+
provider: s.provider
|
|
726
|
+
}), $.log("Payment widget mounted.", {
|
|
727
|
+
moduleId: e.moduleId,
|
|
728
|
+
handle: s.handle
|
|
729
|
+
});
|
|
730
|
+
} catch (t) {
|
|
731
|
+
throw $.warn("Payment widget mount failed.", {
|
|
732
|
+
moduleId: e.moduleId,
|
|
733
|
+
handle: s.handle
|
|
734
|
+
}), t;
|
|
735
|
+
}
|
|
736
|
+
})().finally(() => {
|
|
737
|
+
p = null;
|
|
738
|
+
}), p;
|
|
739
|
+
}, b = () => {
|
|
740
|
+
y().catch(() => {
|
|
741
|
+
!h && Y(n.target) && c.addError(s.transport.errorMessage);
|
|
742
|
+
});
|
|
732
743
|
};
|
|
733
744
|
if (u.push(n.on("formie:submit:before", () => {
|
|
734
745
|
c.removeError(), c.removeSuccess();
|
|
735
746
|
})), e.setup) {
|
|
736
747
|
let t = n.root || n.form || n.target;
|
|
737
|
-
|
|
748
|
+
g = await e.setup({
|
|
738
749
|
...l,
|
|
739
750
|
root: t
|
|
740
|
-
}),
|
|
751
|
+
}), g.destroy && u.push(g.destroy);
|
|
741
752
|
}
|
|
742
|
-
e.mount &&
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
};
|
|
746
|
-
n.root.addEventListener(e, t), u.push(() => {
|
|
747
|
-
n.root.removeEventListener(e, t);
|
|
753
|
+
e.mount && Y(n.target) && await y(), ["formie:page:navigate:after", "formie:submit:result"].forEach((e) => {
|
|
754
|
+
n.root.addEventListener(e, b), u.push(() => {
|
|
755
|
+
n.root.removeEventListener(e, b);
|
|
748
756
|
});
|
|
749
|
-
}), u.push(n.on("formie:conditions:evaluated",
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
let _ = async () => {
|
|
753
|
-
if ($.log("Destroying payment module.", {
|
|
757
|
+
}), u.push(n.on("formie:conditions:evaluated", b));
|
|
758
|
+
let x = () => m || (h = !0, m = (async () => {
|
|
759
|
+
$.log("Destroying payment module.", {
|
|
754
760
|
moduleId: e.moduleId,
|
|
755
761
|
handle: s.handle
|
|
756
|
-
}), u.forEach((e) => e()),
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
762
|
+
}), u.forEach((e) => e()), await p?.catch(() => {});
|
|
763
|
+
let t = f;
|
|
764
|
+
f = null;
|
|
765
|
+
try {
|
|
766
|
+
if (t && e.unmount) {
|
|
767
|
+
let r = await v();
|
|
768
|
+
await e.unmount({
|
|
769
|
+
api: r,
|
|
770
|
+
widget: t,
|
|
771
|
+
field: n.target,
|
|
772
|
+
services: c,
|
|
773
|
+
options: s,
|
|
774
|
+
provider: s.provider
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
} finally {
|
|
778
|
+
i[a]?.destroy === x && delete i[a];
|
|
769
779
|
}
|
|
770
|
-
|
|
780
|
+
$.log("Payment module destroy complete.", {
|
|
771
781
|
moduleId: e.moduleId,
|
|
772
782
|
handle: s.handle
|
|
773
783
|
});
|
|
774
|
-
};
|
|
775
|
-
return i[a] = { destroy:
|
|
776
|
-
destroy:
|
|
784
|
+
})(), m);
|
|
785
|
+
return i[a] = { destroy: x }, {
|
|
786
|
+
destroy: x,
|
|
777
787
|
beforeSubmit: async (t) => {
|
|
778
|
-
if (
|
|
779
|
-
await
|
|
788
|
+
if (g?.beforeSubmit) {
|
|
789
|
+
await g.beforeSubmit(t);
|
|
780
790
|
return;
|
|
781
791
|
}
|
|
782
|
-
if (t.action !== "submit" || !
|
|
783
|
-
await
|
|
784
|
-
let r = await
|
|
792
|
+
if (t.action !== "submit" || !Y(n.target)) return;
|
|
793
|
+
await y();
|
|
794
|
+
let r = await v();
|
|
785
795
|
if (e.onBeforePayment) {
|
|
786
|
-
|
|
796
|
+
_ ||= (async () => e.onBeforePayment({
|
|
787
797
|
api: r,
|
|
788
798
|
widget: f,
|
|
789
799
|
field: n.target,
|
|
@@ -792,9 +802,9 @@ function Ie(e) {
|
|
|
792
802
|
provider: s.provider,
|
|
793
803
|
stageCtx: t
|
|
794
804
|
}))().finally(() => {
|
|
795
|
-
|
|
805
|
+
_ = null;
|
|
796
806
|
});
|
|
797
|
-
let i = await
|
|
807
|
+
let i = await _;
|
|
798
808
|
if ($.log("onBeforePayment resolved.", {
|
|
799
809
|
moduleId: e.moduleId,
|
|
800
810
|
handle: s.handle,
|
|
@@ -806,7 +816,7 @@ function Ie(e) {
|
|
|
806
816
|
return;
|
|
807
817
|
}
|
|
808
818
|
if (s.transport.requiredInputSuffixes.length === 0) return;
|
|
809
|
-
let i = await
|
|
819
|
+
let i = await Le(n.form || n.root, s.transport.requiredInputSuffixes, s.transport.waitForValueMs);
|
|
810
820
|
i.ok || ($.warn("Required payment input(s) missing.", {
|
|
811
821
|
moduleId: e.moduleId,
|
|
812
822
|
handle: s.handle,
|
|
@@ -822,7 +832,7 @@ function Ie(e) {
|
|
|
822
832
|
result: r
|
|
823
833
|
}))?.remount && e.mount) {
|
|
824
834
|
if (f && e.unmount) {
|
|
825
|
-
let t = await
|
|
835
|
+
let t = await v();
|
|
826
836
|
await e.unmount({
|
|
827
837
|
api: t,
|
|
828
838
|
widget: f,
|
|
@@ -832,7 +842,7 @@ function Ie(e) {
|
|
|
832
842
|
provider: s.provider
|
|
833
843
|
});
|
|
834
844
|
}
|
|
835
|
-
f = null, await
|
|
845
|
+
f = null, await y();
|
|
836
846
|
}
|
|
837
847
|
}
|
|
838
848
|
};
|
|
@@ -841,6 +851,6 @@ function Ie(e) {
|
|
|
841
851
|
}
|
|
842
852
|
//#endregion
|
|
843
853
|
//#region src/js/modules/payments/api.ts
|
|
844
|
-
var
|
|
854
|
+
var Ge = We;
|
|
845
855
|
//#endregion
|
|
846
|
-
export {
|
|
856
|
+
export { v as _, U as a, he as c, T as d, w as f, y as g, _ as h, je as i, E as l, ae as m, X as n, z as o, oe as p, W as r, Ee as s, Ge as t, ce as u };
|