@verbb/formie-browser 1.0.15 → 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 +36 -0
- package/dist/chunks/{address-country-BcEQKw0T.js → address-country-DLJF-OkC.js} +4 -8
- package/dist/chunks/{address-finder-BWGINCSA.js → address-finder-QK1m1eyv.js} +1 -1
- package/dist/chunks/{address-state-DI3ndhMU.js → address-state-CHKit8AW.js} +26 -35
- package/dist/chunks/{api-BK9b340y.js → api-BPtH5RBA.js} +152 -120
- package/dist/chunks/{api-Dxl_CKw-.js → api-BR2Gqy37.js} +306 -301
- package/dist/chunks/{api-ghNr2uxX.js → api-CmuOZ0i3.js} +1 -1
- package/dist/chunks/{bpoint-BwtuyN_O.js → bpoint-GvYfyPjD.js} +1 -1
- package/dist/chunks/{calculations-YEoVCG2q.js → calculations-DeEmdUDq.js} +5 -7
- package/dist/chunks/{captcha-eu-DWLoQFKB.js → captcha-eu-eU_M6snp.js} +1 -1
- package/dist/chunks/{checkbox-radio-gsm8QPJg.js → checkbox-radio-CSXo6svm.js} +4 -12
- package/dist/chunks/{combobox-Ba08_cHL.js → combobox-CJh2DoSO.js} +292 -333
- package/dist/chunks/{conditions-Ceeg6ReZ.js → conditions-Dz3068K0.js} +56 -72
- 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-DaPvMrop.js → date-picker-BVJxJVYT.js} +30 -47
- 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-uw0DzU-L.js → eway-BZuTBAUW.js} +1 -1
- package/dist/chunks/{field-references.resolver-Ca8MguFv.js → field-references.resolver-uSHf5-NP.js} +1 -1
- package/dist/chunks/{file-upload-B8_mH012.js → file-upload-vEUr_EuP.js} +114 -108
- package/dist/chunks/{friendly-captcha-v1-CVXaXgDO.js → friendly-captcha-v1-C_cF1WD2.js} +2 -2
- package/dist/chunks/{friendly-captcha-v2-DkeIVTKI.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-c4wLJdOt.js → go-cardless-DWZeB0Bq.js} +2 -6
- package/dist/chunks/{google-address-JHYvjwgN.js → google-address-DQR6rsbh.js} +2 -2
- package/dist/chunks/{hcaptcha-Dt3ELLlP.js → hcaptcha-COilLmRT.js} +1 -1
- 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-m51iPyO1.js → loqate-ZZClcacr.js} +1 -1
- package/dist/chunks/{mollie-Bn0PX173.js → mollie-8OMXIYa8.js} +2 -6
- package/dist/chunks/{moneris-BRbUvI4t.js → moneris-qYHJ9EFy.js} +1 -1
- package/dist/chunks/opayo-DlWPEnla.js +159 -0
- package/dist/chunks/{paddle-CympHVvd.js → paddle-CArfWih0.js} +1 -1
- package/dist/chunks/{password-validation-C8_uO_c_.js → password-validation-HGOU9kf3.js} +2 -2
- package/dist/chunks/{paypal-h75h6wae.js → paypal-BcaMCMGY.js} +1 -1
- package/dist/chunks/{payway-C9rHTCC_.js → payway-vxC7_bfR.js} +3 -11
- package/dist/chunks/{phone-country-B8fv-L5_.js → phone-country-Bx9EG50h.js} +123 -140
- package/dist/chunks/{place-kit-BnZGQ-L1.js → place-kit-BKk8xDXf.js} +2 -2
- package/dist/chunks/{placekit-autocomplete.esm-CZZERYur.js → placekit-autocomplete.esm-D2A_0iVU.js} +2 -5
- package/dist/chunks/{recaptcha-enterprise-CUs8BO6V.js → recaptcha-enterprise-Cx6HUpMa.js} +6 -12
- package/dist/chunks/recaptcha-shared-CcMI-r8t.js +33 -0
- package/dist/chunks/{recaptcha-v2-checkbox-P1McW4Pv.js → recaptcha-v2-checkbox-DQ9BJzcv.js} +2 -2
- package/dist/chunks/{recaptcha-v2-invisible-FGDqozSP.js → recaptcha-v2-invisible-BP0T8Pan.js} +2 -2
- package/dist/chunks/recaptcha-v3-DKMGQ27K.js +38 -0
- package/dist/chunks/{repeater-CyhDbozO.js → repeater-BR0RUvTs.js} +3 -7
- 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/{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/{snaptcha-C3QLYxFT.js → snaptcha-P3EoSQud.js} +1 -1
- package/dist/chunks/{square-C1z5DPVw.js → square-Dyz0p_GU.js} +1 -1
- package/dist/chunks/{stripe-Dmkdkq1y.js → stripe-Bfd_jp_k.js} +3 -6
- package/dist/chunks/{summary-Bn-g5SDx.js → summary-B3CAebLV.js} +44 -36
- 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-j7MlLLCc.js → table-0k6Md0IO.js} +1 -1
- package/dist/chunks/{text-limit-LGMPhFuC.js → text-limit-CTVML6s7.js} +10 -10
- package/dist/chunks/{turnstile-ptihQfLl.js → turnstile-Sp4ubowK.js} +1 -1
- package/dist/chunks/{upload-manager-BW7l-BhF.js → upload-manager-Ccg3d_4I.js} +11 -25
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +752 -756
- 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.map +1 -1
- package/dist/js/core/validation-focus.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.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/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/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/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 +20 -18
- 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 +13 -2
- package/src/js/core/submit-result-ui.ts +21 -0
- package/src/js/core/validation-focus.ts +17 -3
- 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-state.ts +6 -4
- package/src/js/modules/fields/combobox.ts +19 -1
- package/src/js/modules/fields/conditions.ts +3 -0
- package/src/js/modules/fields/file-upload.ts +11 -4
- package/src/js/modules/fields/phone-country.ts +23 -0
- 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/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/form-started-at.ts +19 -4
- package/src/js/utils/unload-warning.ts +63 -7
- package/src/js/validation/rules/required.ts +6 -0
- package/src/js/validation/submit-readiness.ts +2 -0
- package/src/js/validation/validator.ts +15 -4
- package/src/vendor.d.ts +2 -0
- package/dist/chunks/opayo-BwWdInEP.js +0 -188
- package/dist/chunks/recaptcha-shared-DTbTw-MF.js +0 -27
- package/dist/chunks/recaptcha-v3-CflUHeZD.js +0 -28
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
import { a as e, d as t,
|
|
2
|
-
import { t as
|
|
3
|
-
import { a
|
|
4
|
-
import { n as
|
|
5
|
-
import { i as
|
|
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,95 +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) {
|
|
336
351
|
if (t.meta?.resetSubmissionIdentity === !0) {
|
|
337
|
-
|
|
352
|
+
F(e, "submissionId"), F(e, "submissionUid"), F(e, "progressId"), N(e, "expectedVersion", "0"), G(e);
|
|
338
353
|
return;
|
|
339
354
|
}
|
|
340
355
|
let n = t.meta?.session?.version ?? t.meta?.version;
|
|
341
|
-
typeof n == "number" &&
|
|
356
|
+
typeof n == "number" && N(e, "expectedVersion", String(n));
|
|
342
357
|
let r = t.meta?.submissionUid;
|
|
343
|
-
typeof r == "string" && r.trim() !== "" &&
|
|
358
|
+
typeof r == "string" && r.trim() !== "" && N(e, "submissionUid", r);
|
|
344
359
|
let i = (t.meta?.session)?.continuation?.progressId;
|
|
345
|
-
typeof i == "string" && i.trim() !== "" ?
|
|
360
|
+
typeof i == "string" && i.trim() !== "" ? N(e, "progressId", i) : F(e, "progressId");
|
|
346
361
|
}
|
|
347
|
-
function
|
|
362
|
+
function G(e) {
|
|
348
363
|
let t = e.getAttribute("action");
|
|
349
|
-
t && e.setAttribute("action",
|
|
364
|
+
t && e.setAttribute("action", _e(t, "resumeToken"));
|
|
350
365
|
try {
|
|
351
366
|
let e = new URL(window.location.href);
|
|
352
367
|
if (!e.searchParams.has("resumeToken")) return;
|
|
353
368
|
e.searchParams.delete("resumeToken"), window.history.replaceState({}, document.title, `${e.pathname}${e.search}${e.hash}`);
|
|
354
369
|
} catch {}
|
|
355
370
|
}
|
|
356
|
-
function
|
|
371
|
+
function Oe(e, t) {
|
|
357
372
|
let n = t.meta?.resumeUrl;
|
|
358
373
|
if (typeof n != "string" || n.trim() === "") return;
|
|
359
374
|
let r = n.trim();
|
|
360
|
-
if (
|
|
375
|
+
if (ve(r)) {
|
|
361
376
|
e.getAttribute("action") && e.setAttribute("action", r);
|
|
362
377
|
try {
|
|
363
378
|
let e = new URL(r, window.location.href);
|
|
@@ -365,90 +380,72 @@ function Ce(e, t) {
|
|
|
365
380
|
} catch {}
|
|
366
381
|
}
|
|
367
382
|
}
|
|
368
|
-
function
|
|
369
|
-
let r = t.formieValidation, i =
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
b(t), t.dispatchEvent(new CustomEvent(e("reset"), { bubbles: !0 }));
|
|
375
|
-
}
|
|
376
|
-
function we(e) {
|
|
377
|
-
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));
|
|
378
388
|
}
|
|
379
|
-
function
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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, {
|
|
386
399
|
bubbles: !0,
|
|
387
|
-
detail: { data:
|
|
400
|
+
detail: { data: n.data }
|
|
388
401
|
}));
|
|
389
402
|
}
|
|
390
403
|
}
|
|
391
|
-
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);
|
|
392
405
|
return l && !i.has(l) && (l.startsWith("formie:payment:") && (a = !0), e.dispatchEvent(new CustomEvent(l, {
|
|
393
406
|
bubbles: !0,
|
|
394
407
|
detail: { data: c }
|
|
395
|
-
})),
|
|
408
|
+
})), M.log("Dispatching fallback payment action event.", { eventName: l })), { hasPaymentFollowUpEvent: a };
|
|
396
409
|
}
|
|
397
|
-
function
|
|
398
|
-
if (
|
|
410
|
+
function je(e, t, n) {
|
|
411
|
+
if (M.log("Applying submit result state.", {
|
|
399
412
|
ok: t.ok,
|
|
400
413
|
action: n,
|
|
401
414
|
code: t.code,
|
|
402
415
|
hasRedirect: !!t.redirect?.url,
|
|
403
416
|
hasSubmitData: Array.isArray(t.submitData) && t.submitData.length > 0
|
|
404
|
-
}),
|
|
405
|
-
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
t.payment?.action?.type === "redirect" && t.payment.action.url && j(e, "payment-redirect");
|
|
409
|
-
let r = Te(e, t);
|
|
410
|
-
if (!t.ok && t.redirect?.url && !r.hasPaymentFollowUpEvent) {
|
|
411
|
-
k.log("Applying redirect fallback for failed result.", {
|
|
412
|
-
url: t.redirect.url,
|
|
413
|
-
target: t.redirect.target
|
|
414
|
-
}), L(e), t.redirect.target === "new-tab" ? window.open(t.redirect.url, "_blank", "noopener,noreferrer") : (j(e, "redirect"), window.location.href = t.redirect.url);
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
if (Se(e, t), !t.ok) {
|
|
418
|
-
k.log("Non-redirect failure; keeping current form state."), L(e);
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
if (Array.isArray(t.clientEvents) && t.clientEvents.length > 0 ? v(e, t.clientEvents) : y(e, n), t.nextPage?.id) {
|
|
422
|
-
L(e), e.formieValidation?.resetLiveState(), V(e, t.nextPage.id), m(e, "formie:page:navigate:after", { pageId: t.nextPage.id }), k.log("Advanced to next page.", { nextPageId: t.nextPage.id });
|
|
417
|
+
}), ke(t)) {
|
|
418
|
+
K(e), M.log("Resetting state due to stale/reset marker.");
|
|
423
419
|
return;
|
|
424
420
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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);
|
|
431
432
|
if (n === "reload") {
|
|
432
|
-
|
|
433
|
+
B(e), P(e, "reload"), window.location.reload();
|
|
433
434
|
return;
|
|
434
435
|
}
|
|
435
436
|
if (n === "reset") {
|
|
436
|
-
|
|
437
|
+
K(e);
|
|
437
438
|
return;
|
|
438
439
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
L(e), U(e, { preserveHiddenState: n });
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
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);
|
|
448
445
|
}
|
|
449
446
|
//#endregion
|
|
450
447
|
//#region src/js/modules/payments/constants.ts
|
|
451
|
-
var
|
|
448
|
+
var Me = 2500, Ne = {
|
|
452
449
|
bpoint: ["bpointToken"],
|
|
453
450
|
stripe: ["stripePaymentIntentId"],
|
|
454
451
|
paypal: ["paypalOrderId", "paypalAuthId"],
|
|
@@ -463,25 +460,25 @@ var De = 2500, Oe = {
|
|
|
463
460
|
};
|
|
464
461
|
//#endregion
|
|
465
462
|
//#region src/js/utils/fields.ts
|
|
466
|
-
function
|
|
463
|
+
function Pe(e) {
|
|
467
464
|
return e.replace("{field:", "").replace("{", "").replace("}", "").replace("]", "").split("[").join("][");
|
|
468
465
|
}
|
|
469
|
-
function
|
|
470
|
-
return `fields[${
|
|
466
|
+
function Fe(e) {
|
|
467
|
+
return `fields[${Pe(e)}]`;
|
|
471
468
|
}
|
|
472
|
-
function
|
|
473
|
-
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}[]"]`));
|
|
474
471
|
return (i.length ? i : r).filter((e) => e instanceof HTMLElement);
|
|
475
472
|
}
|
|
476
|
-
function
|
|
477
|
-
let n =
|
|
473
|
+
function q(e, t) {
|
|
474
|
+
let n = Ie(e, t);
|
|
478
475
|
for (let e of n) {
|
|
479
476
|
let t = e.closest("[data-formie-field-handle]")?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim();
|
|
480
477
|
if (t) return t;
|
|
481
478
|
}
|
|
482
479
|
return "";
|
|
483
480
|
}
|
|
484
|
-
function
|
|
481
|
+
function J(e) {
|
|
485
482
|
let t = e.replace(/[^\d.,-]/g, ""), n = t.includes(","), r = t.includes(".");
|
|
486
483
|
if (n && r) t = t.lastIndexOf(",") > t.lastIndexOf(".") ? t.replace(/\./g, "").replace(",", ".") : t.replace(/,/g, "");
|
|
487
484
|
else if (n && !r) {
|
|
@@ -492,17 +489,17 @@ function G(e) {
|
|
|
492
489
|
}
|
|
493
490
|
//#endregion
|
|
494
491
|
//#region src/js/modules/payments/utils.ts
|
|
495
|
-
function
|
|
492
|
+
function Y(e) {
|
|
496
493
|
let t = e;
|
|
497
494
|
return !t.closest("[data-formie-conditionally-hidden]") && !t.closest("[data-formie-row-hidden]") && !t.closest("[data-formie-page-hidden]") && !t.closest("[hidden]");
|
|
498
495
|
}
|
|
499
|
-
function
|
|
496
|
+
function X(e, t) {
|
|
500
497
|
let n = t.replace(/"/g, "\\\"");
|
|
501
498
|
return e.querySelector(`input[name$="[${n}]"]`) || e.querySelector(`input[name$="${n}"]`);
|
|
502
499
|
}
|
|
503
|
-
function
|
|
500
|
+
function Z(e, t) {
|
|
504
501
|
let n = t.find((t) => {
|
|
505
|
-
let n =
|
|
502
|
+
let n = X(e, t);
|
|
506
503
|
return !n || String(n.value || "").trim() === "";
|
|
507
504
|
});
|
|
508
505
|
return {
|
|
@@ -510,35 +507,35 @@ function J(e, t) {
|
|
|
510
507
|
missingSuffix: n
|
|
511
508
|
};
|
|
512
509
|
}
|
|
513
|
-
async function
|
|
514
|
-
let r =
|
|
510
|
+
async function Le(e, t, n) {
|
|
511
|
+
let r = Z(e, t);
|
|
515
512
|
if (r.ok) return r;
|
|
516
513
|
let i = Date.now() + Math.max(n, 0);
|
|
517
514
|
for (; Date.now() < i;) {
|
|
518
|
-
await
|
|
519
|
-
let n =
|
|
515
|
+
await c(120);
|
|
516
|
+
let n = Z(e, t);
|
|
520
517
|
if (n.ok) return n;
|
|
521
518
|
}
|
|
522
|
-
return
|
|
519
|
+
return Z(e, t);
|
|
523
520
|
}
|
|
524
521
|
//#endregion
|
|
525
522
|
//#region src/js/modules/payments/host.ts
|
|
526
|
-
var
|
|
523
|
+
var Re = /* @__PURE__ */ new Set([
|
|
527
524
|
"handle",
|
|
528
525
|
"requiredInputSuffixes",
|
|
529
526
|
"waitForValueMs",
|
|
530
527
|
"errorMessage"
|
|
531
|
-
]),
|
|
532
|
-
function
|
|
528
|
+
]), ze = "[data-payment-success]", Be = "[data-payment-error]";
|
|
529
|
+
function Ve(e, t) {
|
|
533
530
|
return (typeof t.handle == "string" && t.handle.trim() !== "" ? t.handle.trim() : "") || e;
|
|
534
531
|
}
|
|
535
|
-
function
|
|
536
|
-
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.";
|
|
537
534
|
return {
|
|
538
|
-
handle:
|
|
535
|
+
handle: Ve(e, r),
|
|
539
536
|
transport: {
|
|
540
537
|
requiredInputSuffixes: a,
|
|
541
|
-
waitForValueMs: Number.isFinite(o) ? o :
|
|
538
|
+
waitForValueMs: Number.isFinite(o) ? o : Me,
|
|
542
539
|
errorMessage: s
|
|
543
540
|
},
|
|
544
541
|
provider: i
|
|
@@ -549,9 +546,9 @@ function Q(e, t, n) {
|
|
|
549
546
|
e.removeEventListener(t, n);
|
|
550
547
|
};
|
|
551
548
|
}
|
|
552
|
-
function
|
|
553
|
-
let n = e.target, r = e.form, i = e.root, a = r || i,
|
|
554
|
-
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;
|
|
555
552
|
return Array.isArray(t) ? t[0] || "" : String(t || "");
|
|
556
553
|
};
|
|
557
554
|
return {
|
|
@@ -561,55 +558,55 @@ function Fe(e, t) {
|
|
|
561
558
|
updateInputs: (e, t) => {
|
|
562
559
|
let r = Array.isArray(e) ? e : [e];
|
|
563
560
|
for (let e of r) {
|
|
564
|
-
let r =
|
|
561
|
+
let r = X(a, e) ?? n.querySelector(`input[name*="${e}"]`);
|
|
565
562
|
r && (r.value = t);
|
|
566
563
|
}
|
|
567
564
|
},
|
|
568
565
|
addError: (e) => {
|
|
569
|
-
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);
|
|
570
567
|
a && a.remove();
|
|
571
|
-
let
|
|
572
|
-
|
|
568
|
+
let o = document.createElement("div");
|
|
569
|
+
o.setAttribute("data-payment-error", ""), o.textContent = e, s(o, r || i, "fieldError"), t.appendChild(o);
|
|
573
570
|
},
|
|
574
571
|
removeError: () => {
|
|
575
|
-
n.querySelector(
|
|
572
|
+
n.querySelector(Be)?.remove();
|
|
576
573
|
},
|
|
577
574
|
addSuccess: (e) => {
|
|
578
|
-
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);
|
|
579
576
|
a && a.remove();
|
|
580
|
-
let
|
|
581
|
-
|
|
577
|
+
let o = document.createElement("div");
|
|
578
|
+
o.setAttribute("data-payment-success", ""), o.textContent = e, s(o, r || i, "successMessage"), t.appendChild(o);
|
|
582
579
|
},
|
|
583
580
|
removeSuccess: () => {
|
|
584
|
-
n.querySelector(
|
|
581
|
+
n.querySelector(ze)?.remove();
|
|
585
582
|
},
|
|
586
|
-
hasToken: () =>
|
|
587
|
-
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),
|
|
588
585
|
getFieldValue: (e, t = "string") => {
|
|
589
586
|
let n = h(e);
|
|
590
|
-
return t === "float" || t === "int" || t === "number" ?
|
|
587
|
+
return t === "float" || t === "int" || t === "number" ? J(n) : n;
|
|
591
588
|
},
|
|
592
589
|
resolveAmount: (e) => {
|
|
593
|
-
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 :
|
|
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);
|
|
594
591
|
if (Number.isFinite(s) && s > 0) return {
|
|
595
592
|
ok: !0,
|
|
596
593
|
value: s
|
|
597
594
|
};
|
|
598
595
|
if (o !== "") {
|
|
599
|
-
let e = h(o), n =
|
|
596
|
+
let e = h(o), n = J(e);
|
|
600
597
|
if (Number.isFinite(n) && n > 0) return {
|
|
601
598
|
ok: !0,
|
|
602
599
|
value: n
|
|
603
600
|
};
|
|
604
|
-
let r =
|
|
601
|
+
let r = q(t, o);
|
|
605
602
|
if (!e) return {
|
|
606
603
|
ok: !1,
|
|
607
|
-
error: r ?
|
|
604
|
+
error: r ? u("Provide a value for \"{label}\" to proceed.", { label: r }) : u("Provide a payment amount to proceed.")
|
|
608
605
|
};
|
|
609
606
|
}
|
|
610
607
|
return {
|
|
611
608
|
ok: !1,
|
|
612
|
-
error:
|
|
609
|
+
error: u("Payment amount must be greater than 0.")
|
|
613
610
|
};
|
|
614
611
|
},
|
|
615
612
|
resolveCurrency: (e) => {
|
|
@@ -624,47 +621,47 @@ function Fe(e, t) {
|
|
|
624
621
|
ok: !0,
|
|
625
622
|
value: n
|
|
626
623
|
};
|
|
627
|
-
let r =
|
|
624
|
+
let r = q(t, o);
|
|
628
625
|
if (!e) return {
|
|
629
626
|
ok: !1,
|
|
630
|
-
error: r ?
|
|
627
|
+
error: r ? u("Provide a value for \"{label}\" to proceed.", { label: r }) : u("Provide a payment currency to proceed.")
|
|
631
628
|
};
|
|
632
629
|
}
|
|
633
630
|
return {
|
|
634
631
|
ok: !1,
|
|
635
|
-
error:
|
|
632
|
+
error: u("Payment currency must be a valid 3-letter code.")
|
|
636
633
|
};
|
|
637
634
|
},
|
|
638
635
|
watchFieldValueChanges: (e, t, n = 600) => {
|
|
639
636
|
let a = r || i, o = e.map((e) => String(e || "").trim()).filter(Boolean);
|
|
640
637
|
if (o.length === 0) return () => {};
|
|
641
|
-
let s =
|
|
638
|
+
let s = c(), u = /* @__PURE__ */ new Set();
|
|
642
639
|
o.forEach((e) => {
|
|
643
|
-
let t =
|
|
640
|
+
let t = d(e), n = s.get(t);
|
|
644
641
|
if (n?.names?.length) {
|
|
645
642
|
n.names.forEach((e) => {
|
|
646
|
-
|
|
643
|
+
u.add(e);
|
|
647
644
|
});
|
|
648
645
|
return;
|
|
649
646
|
}
|
|
650
|
-
let r =
|
|
651
|
-
r && (
|
|
647
|
+
let r = f(t);
|
|
648
|
+
r && (u.add(r), u.add(`${r}[]`));
|
|
652
649
|
});
|
|
653
|
-
let
|
|
650
|
+
let p = l(() => {
|
|
654
651
|
t();
|
|
655
|
-
}, n),
|
|
652
|
+
}, n), m = (e) => {
|
|
656
653
|
let t = e.target?.name || "";
|
|
657
|
-
t &&
|
|
654
|
+
t && u.has(t) && p();
|
|
658
655
|
};
|
|
659
|
-
return a.addEventListener("input",
|
|
660
|
-
a.removeEventListener("input",
|
|
656
|
+
return a.addEventListener("input", m), a.addEventListener("change", m), () => {
|
|
657
|
+
a.removeEventListener("input", m), a.removeEventListener("change", m);
|
|
661
658
|
};
|
|
662
659
|
},
|
|
663
660
|
triggerSubmit: () => {
|
|
664
661
|
r && r.setAttribute("data-formie-internal-resubmit", "true"), r && typeof r.requestSubmit == "function" ? r.requestSubmit() : r && r.submit();
|
|
665
662
|
},
|
|
666
663
|
releaseSubmitLoading: () => {
|
|
667
|
-
r && (r.removeAttribute("data-formie-internal-resubmit"),
|
|
664
|
+
r && (r.removeAttribute("data-formie-internal-resubmit"), U(r));
|
|
668
665
|
},
|
|
669
666
|
getBillingData: (e) => {
|
|
670
667
|
let t = {};
|
|
@@ -691,9 +688,9 @@ function Fe(e, t) {
|
|
|
691
688
|
}
|
|
692
689
|
//#endregion
|
|
693
690
|
//#region src/js/modules/payments/factories.ts
|
|
694
|
-
var $ =
|
|
695
|
-
function
|
|
696
|
-
let t = e.defaultRequiredInputSuffixes ??
|
|
691
|
+
var $ = i("payments");
|
|
692
|
+
function We(e) {
|
|
693
|
+
let t = e.defaultRequiredInputSuffixes ?? Ne[e.moduleId.split(":")[1]] ?? [];
|
|
697
694
|
return {
|
|
698
695
|
moduleId: e.moduleId,
|
|
699
696
|
version: 2,
|
|
@@ -710,85 +707,93 @@ function Ie(e) {
|
|
|
710
707
|
await o.destroy();
|
|
711
708
|
} catch {}
|
|
712
709
|
}
|
|
713
|
-
let s =
|
|
710
|
+
let s = He(e.moduleId.split(":")[1], n.options || {}, { defaultRequiredInputSuffixes: t }), c = Ue(n, s), l = {
|
|
714
711
|
...n,
|
|
715
712
|
options: s,
|
|
716
713
|
services: c
|
|
717
|
-
}, u = [], d = null, f = null, p = null, m = null, h = async () => (d ||= ($.log("Loading payment provider API.", { moduleId: e.moduleId }), e.load(l)), d),
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
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
|
+
});
|
|
737
743
|
};
|
|
738
744
|
if (u.push(n.on("formie:submit:before", () => {
|
|
739
745
|
c.removeError(), c.removeSuccess();
|
|
740
746
|
})), e.setup) {
|
|
741
747
|
let t = n.root || n.form || n.target;
|
|
742
|
-
|
|
748
|
+
g = await e.setup({
|
|
743
749
|
...l,
|
|
744
750
|
root: t
|
|
745
|
-
}),
|
|
751
|
+
}), g.destroy && u.push(g.destroy);
|
|
746
752
|
}
|
|
747
|
-
e.mount &&
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
};
|
|
751
|
-
n.root.addEventListener(e, t), u.push(() => {
|
|
752
|
-
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);
|
|
753
756
|
});
|
|
754
|
-
}), u.push(n.on("formie:conditions:evaluated",
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
let _ = async () => {
|
|
758
|
-
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.", {
|
|
759
760
|
moduleId: e.moduleId,
|
|
760
761
|
handle: s.handle
|
|
761
|
-
}), u.forEach((e) => e()),
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
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];
|
|
774
779
|
}
|
|
775
|
-
|
|
780
|
+
$.log("Payment module destroy complete.", {
|
|
776
781
|
moduleId: e.moduleId,
|
|
777
782
|
handle: s.handle
|
|
778
783
|
});
|
|
779
|
-
};
|
|
780
|
-
return i[a] = { destroy:
|
|
781
|
-
destroy:
|
|
784
|
+
})(), m);
|
|
785
|
+
return i[a] = { destroy: x }, {
|
|
786
|
+
destroy: x,
|
|
782
787
|
beforeSubmit: async (t) => {
|
|
783
|
-
if (
|
|
784
|
-
await
|
|
788
|
+
if (g?.beforeSubmit) {
|
|
789
|
+
await g.beforeSubmit(t);
|
|
785
790
|
return;
|
|
786
791
|
}
|
|
787
|
-
if (t.action !== "submit" || !
|
|
788
|
-
await
|
|
789
|
-
let r = await
|
|
792
|
+
if (t.action !== "submit" || !Y(n.target)) return;
|
|
793
|
+
await y();
|
|
794
|
+
let r = await v();
|
|
790
795
|
if (e.onBeforePayment) {
|
|
791
|
-
|
|
796
|
+
_ ||= (async () => e.onBeforePayment({
|
|
792
797
|
api: r,
|
|
793
798
|
widget: f,
|
|
794
799
|
field: n.target,
|
|
@@ -797,9 +802,9 @@ function Ie(e) {
|
|
|
797
802
|
provider: s.provider,
|
|
798
803
|
stageCtx: t
|
|
799
804
|
}))().finally(() => {
|
|
800
|
-
|
|
805
|
+
_ = null;
|
|
801
806
|
});
|
|
802
|
-
let i = await
|
|
807
|
+
let i = await _;
|
|
803
808
|
if ($.log("onBeforePayment resolved.", {
|
|
804
809
|
moduleId: e.moduleId,
|
|
805
810
|
handle: s.handle,
|
|
@@ -811,7 +816,7 @@ function Ie(e) {
|
|
|
811
816
|
return;
|
|
812
817
|
}
|
|
813
818
|
if (s.transport.requiredInputSuffixes.length === 0) return;
|
|
814
|
-
let i = await
|
|
819
|
+
let i = await Le(n.form || n.root, s.transport.requiredInputSuffixes, s.transport.waitForValueMs);
|
|
815
820
|
i.ok || ($.warn("Required payment input(s) missing.", {
|
|
816
821
|
moduleId: e.moduleId,
|
|
817
822
|
handle: s.handle,
|
|
@@ -827,7 +832,7 @@ function Ie(e) {
|
|
|
827
832
|
result: r
|
|
828
833
|
}))?.remount && e.mount) {
|
|
829
834
|
if (f && e.unmount) {
|
|
830
|
-
let t = await
|
|
835
|
+
let t = await v();
|
|
831
836
|
await e.unmount({
|
|
832
837
|
api: t,
|
|
833
838
|
widget: f,
|
|
@@ -837,7 +842,7 @@ function Ie(e) {
|
|
|
837
842
|
provider: s.provider
|
|
838
843
|
});
|
|
839
844
|
}
|
|
840
|
-
f = null, await
|
|
845
|
+
f = null, await y();
|
|
841
846
|
}
|
|
842
847
|
}
|
|
843
848
|
};
|
|
@@ -846,6 +851,6 @@ function Ie(e) {
|
|
|
846
851
|
}
|
|
847
852
|
//#endregion
|
|
848
853
|
//#region src/js/modules/payments/api.ts
|
|
849
|
-
var
|
|
854
|
+
var Ge = We;
|
|
850
855
|
//#endregion
|
|
851
|
-
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 };
|