@verbb/formie-browser 1.0.15 → 1.0.17-next.10.g9cef3233dddb
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 +57 -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-OHeW8r8p.js} +26 -35
- package/dist/chunks/{api-BK9b340y.js → api-BPtH5RBA.js} +152 -120
- package/dist/chunks/{api-ghNr2uxX.js → api-CmuOZ0i3.js} +1 -1
- package/dist/chunks/{api-Dxl_CKw-.js → api-DlW6054X.js} +308 -301
- package/dist/chunks/{bpoint-BwtuyN_O.js → bpoint-BKRpTj1e.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-CTfq6v4y.js} +301 -335
- 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-dp41TnRq.js +5351 -0
- 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-9ZTEmiod.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-Bhxg5QZe.js} +116 -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-BN096eDZ.js} +2 -6
- package/dist/chunks/{google-address-JHYvjwgN.js → google-address-DQR6rsbh.js} +2 -2
- package/dist/chunks/{hcaptcha-Dt3ELLlP.js → hcaptcha-lseqzFTP.js} +14 -14
- 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-DCBzpCmt.js} +2 -6
- package/dist/chunks/{moneris-BRbUvI4t.js → moneris-CeryRRRJ.js} +1 -1
- package/dist/chunks/opayo-D5cbEqJy.js +159 -0
- package/dist/chunks/{paddle-CympHVvd.js → paddle-CDiiBCJ8.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-CA-kRKlJ.js} +1 -1
- package/dist/chunks/{payway-C9rHTCC_.js → payway-K9eUUMvk.js} +3 -11
- package/dist/chunks/phone-country-BMyw-Qcz.js +2647 -0
- 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-Bn6y1M0R.js} +1 -1
- package/dist/chunks/{stripe-Dmkdkq1y.js → stripe-CmzSSdMg.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-cGKWwGhu.js} +206 -216
- package/dist/css/formie-base.css +26 -26
- package/dist/css/theme-base/_primitives.css +9 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +784 -759
- package/dist/js/core/client-rendered-modules.d.ts +6 -6
- package/dist/js/core/client-rendered-modules.d.ts.map +1 -1
- 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 +1 -0
- 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/hcaptcha.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/fields/upload-manager.d.ts.map +1 -1
- package/dist/js/modules/loader.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/theme/message-attributes.d.ts +4 -0
- package/dist/js/theme/message-attributes.d.ts.map +1 -0
- package/dist/js/transport/forms-api.d.ts +1 -1
- package/dist/js/transport/forms-api.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 +7 -5
- package/src/css/formie-base.css +26 -26
- package/src/css/theme-base/_primitives.css +9 -8
- package/src/index.ts +1 -0
- package/src/js/core/client-rendered-modules.ts +1 -1
- package/src/js/core/create-formie-client.ts +74 -51
- package/src/js/core/dom-events.ts +30 -1
- package/src/js/core/page-client-event.ts +5 -7
- package/src/js/core/submit-flow.ts +2 -2
- package/src/js/core/submit-result-state.ts +18 -2
- package/src/js/core/submit-result-ui.ts +31 -2
- package/src/js/core/validation-focus.ts +52 -13
- package/src/js/modules/captchas/factories.ts +241 -101
- package/src/js/modules/captchas/hcaptcha.ts +3 -2
- 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 +46 -3
- package/src/js/modules/fields/conditions.ts +3 -0
- package/src/js/modules/fields/date-picker.ts +3 -3
- package/src/js/modules/fields/file-upload.ts +18 -4
- package/src/js/modules/fields/phone-country.ts +42 -11
- 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 +30 -14
- package/src/js/modules/loader.ts +7 -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/theme/message-attributes.ts +54 -0
- package/src/js/transport/forms-api.ts +6 -1
- package/src/js/utils/country-from-ip.ts +1 -1
- 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 +16 -4
- package/src/vendor.d.ts +4 -3
- package/dist/chunks/date-picker-DaPvMrop.js +0 -5338
- package/dist/chunks/opayo-BwWdInEP.js +0 -188
- package/dist/chunks/phone-country-B8fv-L5_.js +0 -2662
- 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,74 @@ function Ce(e, t) {
|
|
|
365
380
|
} catch {}
|
|
366
381
|
}
|
|
367
382
|
}
|
|
368
|
-
function
|
|
369
|
-
let r = t.formieValidation, i =
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
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()), t.querySelectorAll("[data-formie-file-upload-entry]").forEach((e) => e.remove()), t.querySelectorAll("[data-formie-file-summary], [data-formie-upload-manager-list]").forEach((e) => e.replaceChildren()), t.querySelectorAll("[data-formie-upload-manager-status]").forEach((e) => {
|
|
388
|
+
e.value = "";
|
|
389
|
+
}), 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
390
|
}
|
|
379
|
-
function
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
391
|
+
function ke(e) {
|
|
392
|
+
return e.code === ge || e.meta?.resetState === !0;
|
|
393
|
+
}
|
|
394
|
+
function Ae(e, t) {
|
|
395
|
+
let n = t.submitData, i = /* @__PURE__ */ new Set(), a = !1;
|
|
396
|
+
if (Array.isArray(n) && n.length > 0) {
|
|
397
|
+
let t = n.filter((e) => typeof e == "object" && !!e && "event" in e && typeof e.event == "string");
|
|
398
|
+
for (let n of t) {
|
|
399
|
+
let t = r(n.event);
|
|
400
|
+
i.add(t), M.log("Dispatching submitData event.", { eventName: t }), t.startsWith("formie:payment:") && (a = !0), e.dispatchEvent(new CustomEvent(t, {
|
|
386
401
|
bubbles: !0,
|
|
387
|
-
detail: { data:
|
|
402
|
+
detail: { data: n.data }
|
|
388
403
|
}));
|
|
389
404
|
}
|
|
390
405
|
}
|
|
391
|
-
let o = t.payment?.action, s = o ? String(o.event || "") : "", c = o ? o.payload : void 0, l =
|
|
406
|
+
let o = t.payment?.action, s = o ? String(o.event || "") : "", c = o ? o.payload : void 0, l = r(s);
|
|
392
407
|
return l && !i.has(l) && (l.startsWith("formie:payment:") && (a = !0), e.dispatchEvent(new CustomEvent(l, {
|
|
393
408
|
bubbles: !0,
|
|
394
409
|
detail: { data: c }
|
|
395
|
-
})),
|
|
410
|
+
})), M.log("Dispatching fallback payment action event.", { eventName: l })), { hasPaymentFollowUpEvent: a };
|
|
396
411
|
}
|
|
397
|
-
function
|
|
398
|
-
if (
|
|
412
|
+
function je(e, t, n) {
|
|
413
|
+
if (M.log("Applying submit result state.", {
|
|
399
414
|
ok: t.ok,
|
|
400
415
|
action: n,
|
|
401
416
|
code: t.code,
|
|
402
417
|
hasRedirect: !!t.redirect?.url,
|
|
403
418
|
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 });
|
|
419
|
+
}), ke(t)) {
|
|
420
|
+
K(e), M.log("Resetting state due to stale/reset marker.");
|
|
423
421
|
return;
|
|
424
422
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
423
|
+
t.payment?.action?.type === "redirect" && t.payment.action.url && P(e, "payment-redirect");
|
|
424
|
+
let r = Ae(e, t);
|
|
425
|
+
if (!t.ok && t.redirect?.url && !r.hasPaymentFollowUpEvent) M.log("Applying redirect fallback for failed result.", {
|
|
426
|
+
url: t.redirect.url,
|
|
427
|
+
target: t.redirect.target
|
|
428
|
+
}), B(e), t.redirect.target === "new-tab" ? window.open(t.redirect.url, "_blank", "noopener,noreferrer") : (P(e, "redirect"), window.location.href = t.redirect.url);
|
|
429
|
+
else if (De(e, t), !t.ok) M.log("Non-redirect failure; keeping current form state."), B(e);
|
|
430
|
+
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 });
|
|
431
|
+
else if (n === "save") B(e), Oe(e, t), M.log("Applied save/resume token state.");
|
|
432
|
+
else if (t.completion && n === "submit" && !t.redirect?.url) {
|
|
433
|
+
let n = L(e, t), r = n === "message" && R(e);
|
|
431
434
|
if (n === "reload") {
|
|
432
|
-
|
|
435
|
+
B(e), P(e, "reload"), window.location.reload();
|
|
433
436
|
return;
|
|
434
437
|
}
|
|
435
438
|
if (n === "reset") {
|
|
436
|
-
|
|
439
|
+
K(e);
|
|
437
440
|
return;
|
|
438
441
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
L(e), U(e, { preserveHiddenState: n });
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
L(e);
|
|
442
|
+
B(e), K(e, { preserveHiddenState: r });
|
|
443
|
+
} else if (n === "submit" && t.redirect?.url && t.redirect.target === "new-tab") {
|
|
444
|
+
let n = L(e, t) === "message" && R(e);
|
|
445
|
+
B(e), K(e, { preserveHiddenState: n });
|
|
446
|
+
} else B(e);
|
|
448
447
|
}
|
|
449
448
|
//#endregion
|
|
450
449
|
//#region src/js/modules/payments/constants.ts
|
|
451
|
-
var
|
|
450
|
+
var Me = 2500, Ne = {
|
|
452
451
|
bpoint: ["bpointToken"],
|
|
453
452
|
stripe: ["stripePaymentIntentId"],
|
|
454
453
|
paypal: ["paypalOrderId", "paypalAuthId"],
|
|
@@ -463,25 +462,25 @@ var De = 2500, Oe = {
|
|
|
463
462
|
};
|
|
464
463
|
//#endregion
|
|
465
464
|
//#region src/js/utils/fields.ts
|
|
466
|
-
function
|
|
465
|
+
function Pe(e) {
|
|
467
466
|
return e.replace("{field:", "").replace("{", "").replace("}", "").replace("]", "").split("[").join("][");
|
|
468
467
|
}
|
|
469
|
-
function
|
|
470
|
-
return `fields[${
|
|
468
|
+
function Fe(e) {
|
|
469
|
+
return `fields[${Pe(e)}]`;
|
|
471
470
|
}
|
|
472
|
-
function
|
|
473
|
-
let n =
|
|
471
|
+
function Ie(e, t) {
|
|
472
|
+
let n = Fe(t), r = Array.from(e.querySelectorAll(`[name="${n}"]`)), i = Array.from(e.querySelectorAll(`[name="${n}[]"]`));
|
|
474
473
|
return (i.length ? i : r).filter((e) => e instanceof HTMLElement);
|
|
475
474
|
}
|
|
476
|
-
function
|
|
477
|
-
let n =
|
|
475
|
+
function q(e, t) {
|
|
476
|
+
let n = Ie(e, t);
|
|
478
477
|
for (let e of n) {
|
|
479
478
|
let t = e.closest("[data-formie-field-handle]")?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim();
|
|
480
479
|
if (t) return t;
|
|
481
480
|
}
|
|
482
481
|
return "";
|
|
483
482
|
}
|
|
484
|
-
function
|
|
483
|
+
function J(e) {
|
|
485
484
|
let t = e.replace(/[^\d.,-]/g, ""), n = t.includes(","), r = t.includes(".");
|
|
486
485
|
if (n && r) t = t.lastIndexOf(",") > t.lastIndexOf(".") ? t.replace(/\./g, "").replace(",", ".") : t.replace(/,/g, "");
|
|
487
486
|
else if (n && !r) {
|
|
@@ -492,17 +491,17 @@ function G(e) {
|
|
|
492
491
|
}
|
|
493
492
|
//#endregion
|
|
494
493
|
//#region src/js/modules/payments/utils.ts
|
|
495
|
-
function
|
|
494
|
+
function Y(e) {
|
|
496
495
|
let t = e;
|
|
497
496
|
return !t.closest("[data-formie-conditionally-hidden]") && !t.closest("[data-formie-row-hidden]") && !t.closest("[data-formie-page-hidden]") && !t.closest("[hidden]");
|
|
498
497
|
}
|
|
499
|
-
function
|
|
498
|
+
function X(e, t) {
|
|
500
499
|
let n = t.replace(/"/g, "\\\"");
|
|
501
500
|
return e.querySelector(`input[name$="[${n}]"]`) || e.querySelector(`input[name$="${n}"]`);
|
|
502
501
|
}
|
|
503
|
-
function
|
|
502
|
+
function Z(e, t) {
|
|
504
503
|
let n = t.find((t) => {
|
|
505
|
-
let n =
|
|
504
|
+
let n = X(e, t);
|
|
506
505
|
return !n || String(n.value || "").trim() === "";
|
|
507
506
|
});
|
|
508
507
|
return {
|
|
@@ -510,35 +509,35 @@ function J(e, t) {
|
|
|
510
509
|
missingSuffix: n
|
|
511
510
|
};
|
|
512
511
|
}
|
|
513
|
-
async function
|
|
514
|
-
let r =
|
|
512
|
+
async function Le(e, t, n) {
|
|
513
|
+
let r = Z(e, t);
|
|
515
514
|
if (r.ok) return r;
|
|
516
515
|
let i = Date.now() + Math.max(n, 0);
|
|
517
516
|
for (; Date.now() < i;) {
|
|
518
|
-
await
|
|
519
|
-
let n =
|
|
517
|
+
await c(120);
|
|
518
|
+
let n = Z(e, t);
|
|
520
519
|
if (n.ok) return n;
|
|
521
520
|
}
|
|
522
|
-
return
|
|
521
|
+
return Z(e, t);
|
|
523
522
|
}
|
|
524
523
|
//#endregion
|
|
525
524
|
//#region src/js/modules/payments/host.ts
|
|
526
|
-
var
|
|
525
|
+
var Re = /* @__PURE__ */ new Set([
|
|
527
526
|
"handle",
|
|
528
527
|
"requiredInputSuffixes",
|
|
529
528
|
"waitForValueMs",
|
|
530
529
|
"errorMessage"
|
|
531
|
-
]),
|
|
532
|
-
function
|
|
530
|
+
]), ze = "[data-payment-success]", Be = "[data-payment-error]";
|
|
531
|
+
function Ve(e, t) {
|
|
533
532
|
return (typeof t.handle == "string" && t.handle.trim() !== "" ? t.handle.trim() : "") || e;
|
|
534
533
|
}
|
|
535
|
-
function
|
|
536
|
-
let r = t || {}, i = Object.entries(r).reduce((e, [t, n]) => (
|
|
534
|
+
function He(e, t, n) {
|
|
535
|
+
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
536
|
return {
|
|
538
|
-
handle:
|
|
537
|
+
handle: Ve(e, r),
|
|
539
538
|
transport: {
|
|
540
539
|
requiredInputSuffixes: a,
|
|
541
|
-
waitForValueMs: Number.isFinite(o) ? o :
|
|
540
|
+
waitForValueMs: Number.isFinite(o) ? o : Me,
|
|
542
541
|
errorMessage: s
|
|
543
542
|
},
|
|
544
543
|
provider: i
|
|
@@ -549,9 +548,9 @@ function Q(e, t, n) {
|
|
|
549
548
|
e.removeEventListener(t, n);
|
|
550
549
|
};
|
|
551
550
|
}
|
|
552
|
-
function
|
|
553
|
-
let n = e.target, r = e.form, i = e.root, a = r || i,
|
|
554
|
-
let t =
|
|
551
|
+
function Ue(e, t) {
|
|
552
|
+
let n = e.target, r = e.form, i = e.root, a = r || i, o = t.transport.requiredInputSuffixes, c = () => m(r || i), h = (e) => {
|
|
553
|
+
let t = p(e, c()).value;
|
|
555
554
|
return Array.isArray(t) ? t[0] || "" : String(t || "");
|
|
556
555
|
};
|
|
557
556
|
return {
|
|
@@ -561,55 +560,55 @@ function Fe(e, t) {
|
|
|
561
560
|
updateInputs: (e, t) => {
|
|
562
561
|
let r = Array.isArray(e) ? e : [e];
|
|
563
562
|
for (let e of r) {
|
|
564
|
-
let r =
|
|
563
|
+
let r = X(a, e) ?? n.querySelector(`input[name*="${e}"]`);
|
|
565
564
|
r && (r.value = t);
|
|
566
565
|
}
|
|
567
566
|
},
|
|
568
567
|
addError: (e) => {
|
|
569
|
-
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(
|
|
568
|
+
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(Be);
|
|
570
569
|
a && a.remove();
|
|
571
|
-
let
|
|
572
|
-
|
|
570
|
+
let o = document.createElement("div");
|
|
571
|
+
o.setAttribute("data-payment-error", ""), o.textContent = e, s(o, r || i, "fieldError"), t.appendChild(o);
|
|
573
572
|
},
|
|
574
573
|
removeError: () => {
|
|
575
|
-
n.querySelector(
|
|
574
|
+
n.querySelector(Be)?.remove();
|
|
576
575
|
},
|
|
577
576
|
addSuccess: (e) => {
|
|
578
|
-
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(
|
|
577
|
+
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(ze);
|
|
579
578
|
a && a.remove();
|
|
580
|
-
let
|
|
581
|
-
|
|
579
|
+
let o = document.createElement("div");
|
|
580
|
+
o.setAttribute("data-payment-success", ""), o.textContent = e, s(o, r || i, "successMessage"), t.appendChild(o);
|
|
582
581
|
},
|
|
583
582
|
removeSuccess: () => {
|
|
584
|
-
n.querySelector(
|
|
583
|
+
n.querySelector(ze)?.remove();
|
|
585
584
|
},
|
|
586
|
-
hasToken: () =>
|
|
587
|
-
waitForToken: (e = t.transport.waitForValueMs) =>
|
|
585
|
+
hasToken: () => Z(a, o).ok,
|
|
586
|
+
waitForToken: (e = t.transport.waitForValueMs) => Le(a, o, e).then((e) => e.ok),
|
|
588
587
|
getFieldValue: (e, t = "string") => {
|
|
589
588
|
let n = h(e);
|
|
590
|
-
return t === "float" || t === "int" || t === "number" ?
|
|
589
|
+
return t === "float" || t === "int" || t === "number" ? J(n) : n;
|
|
591
590
|
},
|
|
592
591
|
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 :
|
|
592
|
+
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
593
|
if (Number.isFinite(s) && s > 0) return {
|
|
595
594
|
ok: !0,
|
|
596
595
|
value: s
|
|
597
596
|
};
|
|
598
597
|
if (o !== "") {
|
|
599
|
-
let e = h(o), n =
|
|
598
|
+
let e = h(o), n = J(e);
|
|
600
599
|
if (Number.isFinite(n) && n > 0) return {
|
|
601
600
|
ok: !0,
|
|
602
601
|
value: n
|
|
603
602
|
};
|
|
604
|
-
let r =
|
|
603
|
+
let r = q(t, o);
|
|
605
604
|
if (!e) return {
|
|
606
605
|
ok: !1,
|
|
607
|
-
error: r ?
|
|
606
|
+
error: r ? u("Provide a value for \"{label}\" to proceed.", { label: r }) : u("Provide a payment amount to proceed.")
|
|
608
607
|
};
|
|
609
608
|
}
|
|
610
609
|
return {
|
|
611
610
|
ok: !1,
|
|
612
|
-
error:
|
|
611
|
+
error: u("Payment amount must be greater than 0.")
|
|
613
612
|
};
|
|
614
613
|
},
|
|
615
614
|
resolveCurrency: (e) => {
|
|
@@ -624,47 +623,47 @@ function Fe(e, t) {
|
|
|
624
623
|
ok: !0,
|
|
625
624
|
value: n
|
|
626
625
|
};
|
|
627
|
-
let r =
|
|
626
|
+
let r = q(t, o);
|
|
628
627
|
if (!e) return {
|
|
629
628
|
ok: !1,
|
|
630
|
-
error: r ?
|
|
629
|
+
error: r ? u("Provide a value for \"{label}\" to proceed.", { label: r }) : u("Provide a payment currency to proceed.")
|
|
631
630
|
};
|
|
632
631
|
}
|
|
633
632
|
return {
|
|
634
633
|
ok: !1,
|
|
635
|
-
error:
|
|
634
|
+
error: u("Payment currency must be a valid 3-letter code.")
|
|
636
635
|
};
|
|
637
636
|
},
|
|
638
637
|
watchFieldValueChanges: (e, t, n = 600) => {
|
|
639
638
|
let a = r || i, o = e.map((e) => String(e || "").trim()).filter(Boolean);
|
|
640
639
|
if (o.length === 0) return () => {};
|
|
641
|
-
let s =
|
|
640
|
+
let s = c(), u = /* @__PURE__ */ new Set();
|
|
642
641
|
o.forEach((e) => {
|
|
643
|
-
let t =
|
|
642
|
+
let t = d(e), n = s.get(t);
|
|
644
643
|
if (n?.names?.length) {
|
|
645
644
|
n.names.forEach((e) => {
|
|
646
|
-
|
|
645
|
+
u.add(e);
|
|
647
646
|
});
|
|
648
647
|
return;
|
|
649
648
|
}
|
|
650
|
-
let r =
|
|
651
|
-
r && (
|
|
649
|
+
let r = f(t);
|
|
650
|
+
r && (u.add(r), u.add(`${r}[]`));
|
|
652
651
|
});
|
|
653
|
-
let
|
|
652
|
+
let p = l(() => {
|
|
654
653
|
t();
|
|
655
|
-
}, n),
|
|
654
|
+
}, n), m = (e) => {
|
|
656
655
|
let t = e.target?.name || "";
|
|
657
|
-
t &&
|
|
656
|
+
t && u.has(t) && p();
|
|
658
657
|
};
|
|
659
|
-
return a.addEventListener("input",
|
|
660
|
-
a.removeEventListener("input",
|
|
658
|
+
return a.addEventListener("input", m), a.addEventListener("change", m), () => {
|
|
659
|
+
a.removeEventListener("input", m), a.removeEventListener("change", m);
|
|
661
660
|
};
|
|
662
661
|
},
|
|
663
662
|
triggerSubmit: () => {
|
|
664
663
|
r && r.setAttribute("data-formie-internal-resubmit", "true"), r && typeof r.requestSubmit == "function" ? r.requestSubmit() : r && r.submit();
|
|
665
664
|
},
|
|
666
665
|
releaseSubmitLoading: () => {
|
|
667
|
-
r && (r.removeAttribute("data-formie-internal-resubmit"),
|
|
666
|
+
r && (r.removeAttribute("data-formie-internal-resubmit"), U(r));
|
|
668
667
|
},
|
|
669
668
|
getBillingData: (e) => {
|
|
670
669
|
let t = {};
|
|
@@ -691,9 +690,9 @@ function Fe(e, t) {
|
|
|
691
690
|
}
|
|
692
691
|
//#endregion
|
|
693
692
|
//#region src/js/modules/payments/factories.ts
|
|
694
|
-
var $ =
|
|
695
|
-
function
|
|
696
|
-
let t = e.defaultRequiredInputSuffixes ??
|
|
693
|
+
var $ = i("payments");
|
|
694
|
+
function We(e) {
|
|
695
|
+
let t = e.defaultRequiredInputSuffixes ?? Ne[e.moduleId.split(":")[1]] ?? [];
|
|
697
696
|
return {
|
|
698
697
|
moduleId: e.moduleId,
|
|
699
698
|
version: 2,
|
|
@@ -710,85 +709,93 @@ function Ie(e) {
|
|
|
710
709
|
await o.destroy();
|
|
711
710
|
} catch {}
|
|
712
711
|
}
|
|
713
|
-
let s =
|
|
712
|
+
let s = He(e.moduleId.split(":")[1], n.options || {}, { defaultRequiredInputSuffixes: t }), c = Ue(n, s), l = {
|
|
714
713
|
...n,
|
|
715
714
|
options: s,
|
|
716
715
|
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
|
-
|
|
716
|
+
}, 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 () => {
|
|
717
|
+
let t = e.mount;
|
|
718
|
+
if (!h && t && !f && Y(n.target)) return p ||= (async () => {
|
|
719
|
+
try {
|
|
720
|
+
let r = await v();
|
|
721
|
+
if (h || !Y(n.target)) return;
|
|
722
|
+
c.removeError(), f = await t({
|
|
723
|
+
api: r,
|
|
724
|
+
field: n.target,
|
|
725
|
+
services: c,
|
|
726
|
+
options: s,
|
|
727
|
+
provider: s.provider
|
|
728
|
+
}), $.log("Payment widget mounted.", {
|
|
729
|
+
moduleId: e.moduleId,
|
|
730
|
+
handle: s.handle
|
|
731
|
+
});
|
|
732
|
+
} catch (t) {
|
|
733
|
+
throw $.warn("Payment widget mount failed.", {
|
|
734
|
+
moduleId: e.moduleId,
|
|
735
|
+
handle: s.handle
|
|
736
|
+
}), t;
|
|
737
|
+
}
|
|
738
|
+
})().finally(() => {
|
|
739
|
+
p = null;
|
|
740
|
+
}), p;
|
|
741
|
+
}, b = () => {
|
|
742
|
+
y().catch(() => {
|
|
743
|
+
!h && Y(n.target) && c.addError(s.transport.errorMessage);
|
|
744
|
+
});
|
|
737
745
|
};
|
|
738
746
|
if (u.push(n.on("formie:submit:before", () => {
|
|
739
747
|
c.removeError(), c.removeSuccess();
|
|
740
748
|
})), e.setup) {
|
|
741
749
|
let t = n.root || n.form || n.target;
|
|
742
|
-
|
|
750
|
+
g = await e.setup({
|
|
743
751
|
...l,
|
|
744
752
|
root: t
|
|
745
|
-
}),
|
|
753
|
+
}), g.destroy && u.push(g.destroy);
|
|
746
754
|
}
|
|
747
|
-
e.mount &&
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
};
|
|
751
|
-
n.root.addEventListener(e, t), u.push(() => {
|
|
752
|
-
n.root.removeEventListener(e, t);
|
|
755
|
+
e.mount && Y(n.target) && await y(), ["formie:page:navigate:after", "formie:submit:result"].forEach((e) => {
|
|
756
|
+
n.root.addEventListener(e, b), u.push(() => {
|
|
757
|
+
n.root.removeEventListener(e, b);
|
|
753
758
|
});
|
|
754
|
-
}), u.push(n.on("formie:conditions:evaluated",
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
let _ = async () => {
|
|
758
|
-
if ($.log("Destroying payment module.", {
|
|
759
|
+
}), u.push(n.on("formie:conditions:evaluated", b));
|
|
760
|
+
let x = () => m || (h = !0, m = (async () => {
|
|
761
|
+
$.log("Destroying payment module.", {
|
|
759
762
|
moduleId: e.moduleId,
|
|
760
763
|
handle: s.handle
|
|
761
|
-
}), u.forEach((e) => e()),
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
764
|
+
}), u.forEach((e) => e()), await p?.catch(() => {});
|
|
765
|
+
let t = f;
|
|
766
|
+
f = null;
|
|
767
|
+
try {
|
|
768
|
+
if (t && e.unmount) {
|
|
769
|
+
let r = await v();
|
|
770
|
+
await e.unmount({
|
|
771
|
+
api: r,
|
|
772
|
+
widget: t,
|
|
773
|
+
field: n.target,
|
|
774
|
+
services: c,
|
|
775
|
+
options: s,
|
|
776
|
+
provider: s.provider
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
} finally {
|
|
780
|
+
i[a]?.destroy === x && delete i[a];
|
|
774
781
|
}
|
|
775
|
-
|
|
782
|
+
$.log("Payment module destroy complete.", {
|
|
776
783
|
moduleId: e.moduleId,
|
|
777
784
|
handle: s.handle
|
|
778
785
|
});
|
|
779
|
-
};
|
|
780
|
-
return i[a] = { destroy:
|
|
781
|
-
destroy:
|
|
786
|
+
})(), m);
|
|
787
|
+
return i[a] = { destroy: x }, {
|
|
788
|
+
destroy: x,
|
|
782
789
|
beforeSubmit: async (t) => {
|
|
783
|
-
if (
|
|
784
|
-
await
|
|
790
|
+
if (g?.beforeSubmit) {
|
|
791
|
+
await g.beforeSubmit(t);
|
|
785
792
|
return;
|
|
786
793
|
}
|
|
787
|
-
if (t.action !== "submit" || !
|
|
788
|
-
await
|
|
789
|
-
let r = await
|
|
794
|
+
if (t.action !== "submit" || !Y(n.target)) return;
|
|
795
|
+
await y();
|
|
796
|
+
let r = await v();
|
|
790
797
|
if (e.onBeforePayment) {
|
|
791
|
-
|
|
798
|
+
_ ||= (async () => e.onBeforePayment({
|
|
792
799
|
api: r,
|
|
793
800
|
widget: f,
|
|
794
801
|
field: n.target,
|
|
@@ -797,9 +804,9 @@ function Ie(e) {
|
|
|
797
804
|
provider: s.provider,
|
|
798
805
|
stageCtx: t
|
|
799
806
|
}))().finally(() => {
|
|
800
|
-
|
|
807
|
+
_ = null;
|
|
801
808
|
});
|
|
802
|
-
let i = await
|
|
809
|
+
let i = await _;
|
|
803
810
|
if ($.log("onBeforePayment resolved.", {
|
|
804
811
|
moduleId: e.moduleId,
|
|
805
812
|
handle: s.handle,
|
|
@@ -811,7 +818,7 @@ function Ie(e) {
|
|
|
811
818
|
return;
|
|
812
819
|
}
|
|
813
820
|
if (s.transport.requiredInputSuffixes.length === 0) return;
|
|
814
|
-
let i = await
|
|
821
|
+
let i = await Le(n.form || n.root, s.transport.requiredInputSuffixes, s.transport.waitForValueMs);
|
|
815
822
|
i.ok || ($.warn("Required payment input(s) missing.", {
|
|
816
823
|
moduleId: e.moduleId,
|
|
817
824
|
handle: s.handle,
|
|
@@ -827,7 +834,7 @@ function Ie(e) {
|
|
|
827
834
|
result: r
|
|
828
835
|
}))?.remount && e.mount) {
|
|
829
836
|
if (f && e.unmount) {
|
|
830
|
-
let t = await
|
|
837
|
+
let t = await v();
|
|
831
838
|
await e.unmount({
|
|
832
839
|
api: t,
|
|
833
840
|
widget: f,
|
|
@@ -837,7 +844,7 @@ function Ie(e) {
|
|
|
837
844
|
provider: s.provider
|
|
838
845
|
});
|
|
839
846
|
}
|
|
840
|
-
f = null, await
|
|
847
|
+
f = null, await y();
|
|
841
848
|
}
|
|
842
849
|
}
|
|
843
850
|
};
|
|
@@ -846,6 +853,6 @@ function Ie(e) {
|
|
|
846
853
|
}
|
|
847
854
|
//#endregion
|
|
848
855
|
//#region src/js/modules/payments/api.ts
|
|
849
|
-
var
|
|
856
|
+
var Ge = We;
|
|
850
857
|
//#endregion
|
|
851
|
-
export {
|
|
858
|
+
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 };
|