@verbb/formie-browser 1.0.6 → 1.0.8
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 +23 -0
- package/dist/chunks/_survey-presentations-CFsgToRT.js +4 -0
- package/dist/chunks/{address-finder-yXU5yMjG.js → address-finder-k7_BXaRe.js} +1 -1
- package/dist/chunks/{api-DMK8NSUI.js → api-BUb6P-xu.js} +57 -51
- package/dist/chunks/{api-CmwLRq_n.js → api-C8wyLC-s.js} +235 -193
- package/dist/chunks/{bpoint-DSjqRv63.js → bpoint-CwSw_p7A.js} +1 -1
- package/dist/chunks/{captcha-eu-CWJb64_j.js → captcha-eu-CGm8Lbrj.js} +2 -2
- package/dist/chunks/{conditions-DjZOtHfS.js → conditions-B6_nzpeE.js} +95 -83
- package/dist/chunks/{eway-D3ctTbEk.js → eway-B30BMlDp.js} +2 -2
- package/dist/chunks/{friendly-captcha-v1-ByXzENYZ.js → friendly-captcha-v1-C_2reOXr.js} +1 -1
- package/dist/chunks/{friendly-captcha-v2-BPdlmhQu.js → friendly-captcha-v2-CLSAbkqx.js} +1 -1
- package/dist/chunks/{go-cardless-BwASSYSK.js → go-cardless-BiF3iLel.js} +1 -1
- package/dist/chunks/{google-address-OhKilPWE.js → google-address-BH3Zhi06.js} +1 -1
- package/dist/chunks/{hcaptcha-CdCd9oEi.js → hcaptcha-CGLAmgjO.js} +2 -2
- package/dist/chunks/{loqate-Cp2zvwpE.js → loqate-CJPzBmSm.js} +1 -1
- package/dist/chunks/{mollie-COG-ko2D.js → mollie-D__SwtcH.js} +1 -1
- package/dist/chunks/{moneris-CMH8PlRc.js → moneris-KJS1BKx7.js} +1 -1
- package/dist/chunks/{opayo-D2jsR5vh.js → opayo-A_LIkc-v.js} +4 -4
- package/dist/chunks/{paddle-DxF88RfC.js → paddle-BjbOOb0m.js} +2 -2
- package/dist/chunks/{paypal-b5pnwrA2.js → paypal-CyjHIV8v.js} +2 -2
- package/dist/chunks/{payway-BJYu9DIR.js → payway-a_cyrr3j.js} +2 -2
- package/dist/chunks/{recaptcha-enterprise-BSwi8IVX.js → recaptcha-enterprise-XPId5-bS.js} +19 -20
- package/dist/chunks/{recaptcha-shared-B4zAescW.js → recaptcha-shared-CLYJvojk.js} +15 -3
- package/dist/chunks/{recaptcha-v2-checkbox-CnDQmsKa.js → recaptcha-v2-checkbox-Cy-0PEPc.js} +2 -2
- package/dist/chunks/{recaptcha-v2-invisible-Cz5uIlp-.js → recaptcha-v2-invisible-BwRH540O.js} +2 -2
- package/dist/chunks/recaptcha-v3-No4Ykrhk.js +28 -0
- package/dist/chunks/scripts-CbQ7agX3.js +30 -0
- package/dist/chunks/{snaptcha-vz1RnZ15.js → snaptcha-DKx98oon.js} +1 -1
- package/dist/chunks/{square-BP8RWAKB.js → square-Bga6WXHV.js} +2 -2
- package/dist/chunks/{stripe-MihN63uC.js → stripe-BlqVocl3.js} +2 -2
- package/dist/chunks/{summary-D3AjxpYN.js → summary-Dks0gXS3.js} +42 -38
- package/dist/chunks/survey-likert-DmJ3klhP.js +20 -0
- package/dist/chunks/survey-rank-DeUenftw.js +127 -0
- package/dist/chunks/survey-rating-BPUYDgBJ.js +88 -0
- package/dist/chunks/{turnstile-D_Pi1CKM.js → turnstile-DJakPzQD.js} +3 -3
- package/dist/css/formie-theme.css +1 -0
- package/dist/css/theme/fields/_survey-presentations.css +396 -0
- package/dist/index.js +651 -597
- package/dist/js/contracts/schema.d.ts +5 -0
- package/dist/js/contracts/schema.d.ts.map +1 -1
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/error-aria-live.d.ts +6 -0
- package/dist/js/core/error-aria-live.d.ts.map +1 -0
- package/dist/js/core/page-client-event.d.ts +8 -4
- 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/modules/captchas/factories.d.ts.map +1 -1
- package/dist/js/modules/captchas/host.d.ts +1 -0
- package/dist/js/modules/captchas/host.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-enterprise.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-shared.d.ts +1 -0
- 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/captchas/turnstile.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions/effects.d.ts.map +1 -1
- package/dist/js/modules/fields/index.d.ts.map +1 -1
- package/dist/js/modules/fields/summary.d.ts.map +1 -1
- package/dist/js/modules/fields/survey-likert.d.ts +3 -0
- package/dist/js/modules/fields/survey-likert.d.ts.map +1 -0
- package/dist/js/modules/fields/survey-rank.d.ts +3 -0
- package/dist/js/modules/fields/survey-rank.d.ts.map +1 -0
- package/dist/js/modules/fields/survey-rating.d.ts +3 -0
- package/dist/js/modules/fields/survey-rating.d.ts.map +1 -0
- package/dist/js/transport/forms-api.d.ts.map +1 -1
- package/dist/js/utils/form-started-at.d.ts +2 -0
- package/dist/js/utils/form-started-at.d.ts.map +1 -0
- package/dist/js/utils/scripts.d.ts.map +1 -1
- package/dist/js/utils/unload-warning.d.ts.map +1 -1
- package/dist/js/validation/enter-key-guard.d.ts +2 -0
- package/dist/js/validation/enter-key-guard.d.ts.map +1 -0
- package/dist/js/validation/types.d.ts +1 -0
- package/dist/js/validation/types.d.ts.map +1 -1
- package/dist/js/validation/validator.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/css/formie-theme.css +1 -0
- package/src/css/theme/fields/_survey-presentations.css +396 -0
- package/src/js/contracts/schema.ts +6 -0
- package/src/js/core/create-formie-client.ts +21 -1
- package/src/js/core/error-aria-live.ts +45 -0
- package/src/js/core/page-client-event.ts +86 -18
- package/src/js/core/submit-result-state.ts +10 -2
- package/src/js/core/submit-result-ui.ts +8 -4
- package/src/js/modules/captchas/factories.ts +4 -0
- package/src/js/modules/captchas/host.ts +14 -2
- package/src/js/modules/captchas/recaptcha-enterprise.ts +14 -11
- package/src/js/modules/captchas/recaptcha-shared.ts +14 -0
- package/src/js/modules/captchas/recaptcha-v3.ts +7 -4
- package/src/js/modules/captchas/turnstile.ts +9 -3
- package/src/js/modules/fields/conditions/effects.ts +42 -0
- package/src/js/modules/fields/index.ts +3 -0
- package/src/js/modules/fields/summary.ts +17 -3
- package/src/js/modules/fields/survey-likert.ts +50 -0
- package/src/js/modules/fields/survey-rank.ts +385 -0
- package/src/js/modules/fields/survey-rating.ts +182 -0
- package/src/js/transport/forms-api.ts +1 -0
- package/src/js/utils/form-started-at.ts +25 -0
- package/src/js/utils/scripts.ts +16 -0
- package/src/js/utils/unload-warning.ts +1 -0
- package/src/js/validation/enter-key-guard.ts +63 -0
- package/src/js/validation/types.ts +1 -0
- package/src/js/validation/validator.ts +14 -5
- package/dist/chunks/recaptcha-v3-BtbbP111.js +0 -27
- package/dist/chunks/scripts-6CYSUGKQ.js +0 -24
|
@@ -1,85 +1,127 @@
|
|
|
1
|
-
import { a as e,
|
|
2
|
-
import { t as
|
|
3
|
-
import { i
|
|
4
|
-
import { i as
|
|
5
|
-
import { n as
|
|
6
|
-
import { r as
|
|
7
|
-
import { n as
|
|
1
|
+
import { a as e, d as t, u as n } from "./event-names-BCI2FLD8.js";
|
|
2
|
+
import { t as r } from "./debug-BV0DvdHx.js";
|
|
3
|
+
import { i, r as a, t as o } from "./theme-classes-Tv7q7ToE.js";
|
|
4
|
+
import { i as s } from "./i18n-BY1ds1BL.js";
|
|
5
|
+
import { n as c, t as l } from "./async-nPFRNQ06.js";
|
|
6
|
+
import { r as u, t as d } from "./field-references.keys-58ZSTrCW.js";
|
|
7
|
+
import { n as f, r as p } from "./field-references.resolver-CHwn0G0L.js";
|
|
8
|
+
//#region src/js/core/dom-events.ts
|
|
9
|
+
function m(e, n, r) {
|
|
10
|
+
e.dispatchEvent(new CustomEvent(t(n), {
|
|
11
|
+
bubbles: !0,
|
|
12
|
+
detail: r
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
8
16
|
//#region src/js/core/page-client-event.ts
|
|
9
|
-
var
|
|
10
|
-
function
|
|
17
|
+
var h = r("general", "page-client-event"), g = "data-formie-client-event", _ = "data-formie-pending-client-events";
|
|
18
|
+
function ee(e) {
|
|
11
19
|
return typeof window < "u" && window.CSS?.escape ? window.CSS.escape(e) : e.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
12
20
|
}
|
|
13
|
-
function
|
|
21
|
+
function te(e) {
|
|
14
22
|
return e.querySelector("input[name=\"pageId\"]")?.value?.trim() || e.querySelector("[data-formie-page]:not([data-formie-page-hidden])")?.getAttribute("data-formie-page-id")?.trim() || e.querySelector("[data-formie-page]")?.getAttribute("data-formie-page-id")?.trim() || null;
|
|
15
23
|
}
|
|
16
|
-
function
|
|
24
|
+
function ne(e) {
|
|
17
25
|
if (!e?.trim()) return null;
|
|
18
26
|
try {
|
|
19
27
|
let t = JSON.parse(e);
|
|
20
28
|
return t && typeof t == "object" ? t : null;
|
|
21
29
|
} catch {
|
|
22
|
-
return
|
|
30
|
+
return h.warn("Invalid data-formie-client-event JSON.", { rawPreview: e.slice(0, 80) }), null;
|
|
23
31
|
}
|
|
24
32
|
}
|
|
25
|
-
function
|
|
33
|
+
function re(e) {
|
|
26
34
|
let t = {};
|
|
27
35
|
return e.forEach((e) => {
|
|
28
36
|
let n = typeof e.label == "string" ? e.label.trim() : "";
|
|
29
37
|
n && (t[n] = typeof e.value == "string" ? e.value : "");
|
|
30
38
|
}), t;
|
|
31
39
|
}
|
|
32
|
-
function
|
|
40
|
+
function ie(e) {
|
|
41
|
+
return Array.isArray(e) ? e.map((e) => {
|
|
42
|
+
if (!e || typeof e != "object") return null;
|
|
43
|
+
let t = e, n = typeof t.event == "string" ? t.event.trim() : "", r = t.payload && typeof t.payload == "object" ? t.payload : null;
|
|
44
|
+
return !n || !r ? null : {
|
|
45
|
+
event: n,
|
|
46
|
+
payload: r
|
|
47
|
+
};
|
|
48
|
+
}).filter((e) => e !== null) : [];
|
|
49
|
+
}
|
|
50
|
+
function v(e, t) {
|
|
51
|
+
if (!t.length) return;
|
|
52
|
+
let n = window;
|
|
53
|
+
n.dataLayer = n.dataLayer || [], t.forEach((t) => {
|
|
54
|
+
n.dataLayer.push(t.payload), e.dispatchEvent(new CustomEvent("formie:client-event", {
|
|
55
|
+
bubbles: !0,
|
|
56
|
+
detail: {
|
|
57
|
+
event: t.event,
|
|
58
|
+
payload: t.payload
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
}), h.log("Dispatched resolved client events.", {
|
|
62
|
+
count: t.length,
|
|
63
|
+
events: t.map((e) => e.event)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function ae(e) {
|
|
67
|
+
let t = e.getAttribute(_);
|
|
68
|
+
if (t?.trim()) try {
|
|
69
|
+
let n = ie(JSON.parse(t));
|
|
70
|
+
n.length && v(e, n);
|
|
71
|
+
} catch {
|
|
72
|
+
h.warn("Invalid pending client events JSON on form element.");
|
|
73
|
+
} finally {
|
|
74
|
+
e.removeAttribute(_);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function y(e, t) {
|
|
33
78
|
if (t !== "submit") return;
|
|
34
|
-
let n =
|
|
79
|
+
let n = te(e);
|
|
35
80
|
if (!n) {
|
|
36
|
-
|
|
81
|
+
h.log("No submitted page id; skipping client event.");
|
|
37
82
|
return;
|
|
38
83
|
}
|
|
39
|
-
let r = e.querySelector(`[data-formie-page][data-formie-page-id="${
|
|
84
|
+
let r = e.querySelector(`[data-formie-page][data-formie-page-id="${ee(n)}"]`);
|
|
40
85
|
if (!r) {
|
|
41
|
-
|
|
86
|
+
h.log("No page section for id; skipping client event.", { pageId: n });
|
|
42
87
|
return;
|
|
43
88
|
}
|
|
44
|
-
let i = r.getAttribute(
|
|
89
|
+
let i = r.getAttribute(g);
|
|
45
90
|
if (i === null) return;
|
|
46
|
-
let a =
|
|
91
|
+
let a = ne(i);
|
|
47
92
|
if (!a || !Array.isArray(a.fields)) return;
|
|
48
|
-
let o =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
})
|
|
53
|
-
pageId: n,
|
|
54
|
-
keys: Object.keys(o)
|
|
55
|
-
});
|
|
93
|
+
let o = re(a.fields);
|
|
94
|
+
v(e, [{
|
|
95
|
+
event: typeof o.event == "string" && o.event !== "" ? o.event : "formPageSubmission",
|
|
96
|
+
payload: o
|
|
97
|
+
}]);
|
|
56
98
|
}
|
|
57
99
|
//#endregion
|
|
58
100
|
//#region src/js/core/page-tab-errors.ts
|
|
59
|
-
function
|
|
60
|
-
if (
|
|
101
|
+
function oe(e, t) {
|
|
102
|
+
if (i(e, e, "tabError", t), t) {
|
|
61
103
|
e.setAttribute("data-formie-tab-error", "true");
|
|
62
104
|
return;
|
|
63
105
|
}
|
|
64
106
|
e.removeAttribute("data-formie-tab-error");
|
|
65
107
|
}
|
|
66
|
-
function
|
|
108
|
+
function b(e) {
|
|
67
109
|
let t = /* @__PURE__ */ new Set();
|
|
68
110
|
e.querySelectorAll("[data-formie-page]").forEach((e) => {
|
|
69
111
|
let n = e, r = n.getAttribute("data-formie-page-id");
|
|
70
112
|
r && n.querySelector("[data-formie-field-has-error]") && t.add(r);
|
|
71
113
|
}), e.querySelectorAll("[data-formie-tab]").forEach((e) => {
|
|
72
114
|
let n = e, r = n.getAttribute("data-formie-page-id");
|
|
73
|
-
|
|
115
|
+
oe(n, !!r && t.has(r));
|
|
74
116
|
});
|
|
75
117
|
}
|
|
76
118
|
//#endregion
|
|
77
119
|
//#region src/js/validation/scope.ts
|
|
78
|
-
function
|
|
120
|
+
function x(e) {
|
|
79
121
|
return Array.from(e.querySelectorAll("[data-formie-page]"));
|
|
80
122
|
}
|
|
81
|
-
function
|
|
82
|
-
let t =
|
|
123
|
+
function S(e) {
|
|
124
|
+
let t = x(e);
|
|
83
125
|
if (!t.length) return {
|
|
84
126
|
scope: e,
|
|
85
127
|
final: !0
|
|
@@ -92,35 +134,35 @@ function b(e) {
|
|
|
92
134
|
}
|
|
93
135
|
//#endregion
|
|
94
136
|
//#region src/js/validation/submit-readiness.ts
|
|
95
|
-
var
|
|
96
|
-
function
|
|
137
|
+
var C = "data-formie-submit-validation-disabled", w = "data-formie-preserve-disabled", se = "data-formie-submit-ready";
|
|
138
|
+
function T(e) {
|
|
97
139
|
return e.dataset.formieDisableSubmitUntilValid === "true";
|
|
98
140
|
}
|
|
99
|
-
function
|
|
141
|
+
function ce(e) {
|
|
100
142
|
return Array.from(e.querySelectorAll("button[data-formie-action=\"submit\"]")).filter((e) => e instanceof HTMLButtonElement);
|
|
101
143
|
}
|
|
102
|
-
function
|
|
144
|
+
function le(e) {
|
|
103
145
|
return !e.hasAttribute("data-formie-conditionally-hidden") && !e.closest("[data-formie-conditionally-hidden]");
|
|
104
146
|
}
|
|
105
|
-
function
|
|
106
|
-
if (!
|
|
107
|
-
let { scope: n, final: r } =
|
|
108
|
-
e.setAttribute(
|
|
109
|
-
if (
|
|
147
|
+
function E(e, t) {
|
|
148
|
+
if (!T(e) || e.getAttribute("data-formie-loading") === "true") return;
|
|
149
|
+
let { scope: n, final: r } = S(e), i = t.isValid(n, { includeHiddenPages: r });
|
|
150
|
+
e.setAttribute(se, i ? "true" : "false"), ce(e).forEach((e) => {
|
|
151
|
+
if (le(e)) {
|
|
110
152
|
if (i) {
|
|
111
|
-
if (!e.hasAttribute(
|
|
112
|
-
e.hasAttribute(
|
|
153
|
+
if (!e.hasAttribute(C)) return;
|
|
154
|
+
e.hasAttribute(w) ? (e.disabled = !0, e.removeAttribute(w)) : e.disabled = !1, e.removeAttribute(C);
|
|
113
155
|
return;
|
|
114
156
|
}
|
|
115
|
-
e.hasAttribute(
|
|
157
|
+
e.hasAttribute(C) || (e.disabled && e.setAttribute(w, "true"), e.setAttribute(C, "true")), e.disabled = !0;
|
|
116
158
|
}
|
|
117
159
|
});
|
|
118
160
|
}
|
|
119
|
-
function
|
|
120
|
-
if (!
|
|
161
|
+
function ue(e, t, n) {
|
|
162
|
+
if (!T(e)) return () => {};
|
|
121
163
|
let r = !1, i = () => {
|
|
122
164
|
r || (r = !0, queueMicrotask(() => {
|
|
123
|
-
r = !1,
|
|
165
|
+
r = !1, E(e, t);
|
|
124
166
|
}));
|
|
125
167
|
};
|
|
126
168
|
i();
|
|
@@ -163,18 +205,18 @@ function oe(e, t, n) {
|
|
|
163
205
|
}
|
|
164
206
|
//#endregion
|
|
165
207
|
//#region src/js/core/submit-result-state.ts
|
|
166
|
-
var
|
|
167
|
-
function
|
|
208
|
+
var de = "STALE_SUBMISSION_STATE", D = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), k = r("general", "submit-result");
|
|
209
|
+
function A(e, t, n) {
|
|
168
210
|
let r = e.querySelector(`input[name="${t}"]`);
|
|
169
211
|
r || (r = document.createElement("input"), r.type = "hidden", r.name = t, e.appendChild(r)), r.value = n;
|
|
170
212
|
}
|
|
171
|
-
function
|
|
213
|
+
function j(e, t) {
|
|
172
214
|
e.setAttribute("data-formie-internal-navigation", t);
|
|
173
215
|
}
|
|
174
|
-
function
|
|
216
|
+
function M(e, t) {
|
|
175
217
|
e.querySelector(`input[name="${t}"]`)?.remove();
|
|
176
218
|
}
|
|
177
|
-
function
|
|
219
|
+
function fe(e, t) {
|
|
178
220
|
try {
|
|
179
221
|
let n = new URL(e, window.location.href);
|
|
180
222
|
return n.searchParams.delete(t), n.toString();
|
|
@@ -182,39 +224,39 @@ function ce(e, t) {
|
|
|
182
224
|
return e;
|
|
183
225
|
}
|
|
184
226
|
}
|
|
185
|
-
function
|
|
227
|
+
function pe(e) {
|
|
186
228
|
try {
|
|
187
229
|
return new URL(e, window.location.href).origin === window.location.origin;
|
|
188
230
|
} catch {
|
|
189
231
|
return !1;
|
|
190
232
|
}
|
|
191
233
|
}
|
|
192
|
-
function
|
|
234
|
+
function N(e) {
|
|
193
235
|
return Array.from(e.querySelectorAll("[data-formie-page]"));
|
|
194
236
|
}
|
|
195
|
-
function
|
|
237
|
+
function me(e) {
|
|
196
238
|
return Array.from(e.querySelectorAll("[data-formie-tab]"));
|
|
197
239
|
}
|
|
198
|
-
function
|
|
240
|
+
function he(e, t, n) {
|
|
199
241
|
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);
|
|
200
242
|
}
|
|
201
|
-
function
|
|
243
|
+
function ge(e) {
|
|
202
244
|
return e <= 0 ? "start" : e >= 100 ? "end" : "middle";
|
|
203
245
|
}
|
|
204
|
-
function
|
|
246
|
+
function _e(e) {
|
|
205
247
|
return (e.dataset.formieSubmitAction || "").trim();
|
|
206
248
|
}
|
|
207
|
-
function
|
|
249
|
+
function P(e, t) {
|
|
208
250
|
let n = t.meta?.effectiveSubmitAction;
|
|
209
|
-
return typeof n == "string" && n.trim() !== "" ? n.trim() :
|
|
251
|
+
return typeof n == "string" && n.trim() !== "" ? n.trim() : _e(e);
|
|
210
252
|
}
|
|
211
|
-
function
|
|
253
|
+
function F(e) {
|
|
212
254
|
let t = e.dataset.formieSubmitActionFormHide;
|
|
213
255
|
if (t === void 0) return !1;
|
|
214
256
|
let n = t.trim().toLowerCase();
|
|
215
257
|
return n === "true" || n === "1" || n === "";
|
|
216
258
|
}
|
|
217
|
-
function
|
|
259
|
+
function I(e, t) {
|
|
218
260
|
e.toggleAttribute("data-formie-form-hidden", t), [
|
|
219
261
|
"[data-formie-form-header]",
|
|
220
262
|
"[data-formie-form-navigation]",
|
|
@@ -227,44 +269,44 @@ function F(e, t) {
|
|
|
227
269
|
});
|
|
228
270
|
});
|
|
229
271
|
}
|
|
230
|
-
function
|
|
231
|
-
let t =
|
|
232
|
-
typeof t == "number" && (window.clearTimeout(t),
|
|
272
|
+
function L(e) {
|
|
273
|
+
let t = D.get(e);
|
|
274
|
+
typeof t == "number" && (window.clearTimeout(t), D.delete(e));
|
|
233
275
|
}
|
|
234
|
-
function
|
|
235
|
-
|
|
276
|
+
function ve(e, t) {
|
|
277
|
+
O.has(e) || O.set(e, e.innerHTML), e.textContent = t;
|
|
236
278
|
}
|
|
237
|
-
function
|
|
238
|
-
let t =
|
|
239
|
-
t !== void 0 && (e.innerHTML = t,
|
|
279
|
+
function R(e) {
|
|
280
|
+
let t = O.get(e);
|
|
281
|
+
t !== void 0 && (e.innerHTML = t, O.delete(e));
|
|
240
282
|
}
|
|
241
|
-
function
|
|
283
|
+
function ye(e, t) {
|
|
242
284
|
let n = e.querySelector("[data-formie-progress-bar]"), r = e.querySelector("[data-formie-progress-value]");
|
|
243
|
-
n && (n.style.width = `${t}%`, n.setAttribute("aria-valuenow", `${t}`), n.setAttribute("data-formie-progress-state",
|
|
285
|
+
n && (n.style.width = `${t}%`, n.setAttribute("aria-valuenow", `${t}`), n.setAttribute("data-formie-progress-state", ge(t)), r && (r.textContent = `${t}%`, r.setAttribute("data-formie-progress-value", `${t}`)));
|
|
244
286
|
}
|
|
245
|
-
function
|
|
287
|
+
function be(e, t) {
|
|
246
288
|
if (!t) return;
|
|
247
289
|
let n = (e.dataset.formieLoadingIndicator || "").trim();
|
|
248
290
|
if (n) {
|
|
249
291
|
if (t.setAttribute("data-formie-loading-indicator", n), n === "spinner") {
|
|
250
|
-
|
|
292
|
+
i(t, e, "loading", !0), R(t), t.removeAttribute("data-formie-loading-text");
|
|
251
293
|
return;
|
|
252
294
|
}
|
|
253
295
|
if (n === "text") {
|
|
254
296
|
let n = (e.dataset.formieLoadingIndicatorText || "").trim(), r = t.textContent?.trim() || "", i = n || r;
|
|
255
|
-
t.setAttribute("data-formie-loading-text", i),
|
|
297
|
+
t.setAttribute("data-formie-loading-text", i), ve(t, i);
|
|
256
298
|
return;
|
|
257
299
|
}
|
|
258
|
-
|
|
300
|
+
R(t), t.removeAttribute("data-formie-loading-text");
|
|
259
301
|
}
|
|
260
302
|
}
|
|
261
303
|
function z(e) {
|
|
262
304
|
return Array.from(e.querySelectorAll("[data-formie-action]"));
|
|
263
305
|
}
|
|
264
|
-
function
|
|
306
|
+
function xe(e, t) {
|
|
265
307
|
e.getAttribute("data-formie-loading") !== "true" && (e.setAttribute("data-formie-loading", "true"), z(e).forEach((e) => {
|
|
266
308
|
"disabled" in e && (e.disabled ? e.setAttribute("data-formie-was-disabled", "true") : e.removeAttribute("data-formie-was-disabled"), e.disabled = !0);
|
|
267
|
-
}), t && (t.setAttribute("data-formie-loading", "true"),
|
|
309
|
+
}), t && (t.setAttribute("data-formie-loading", "true"), be(e, t)));
|
|
268
310
|
}
|
|
269
311
|
function B(e) {
|
|
270
312
|
if (e.removeAttribute("data-formie-loading"), z(e).forEach((t) => {
|
|
@@ -272,44 +314,44 @@ function B(e) {
|
|
|
272
314
|
let e = t;
|
|
273
315
|
e.disabled = e.getAttribute("data-formie-was-disabled") === "true";
|
|
274
316
|
}
|
|
275
|
-
|
|
317
|
+
R(t), t.removeAttribute("data-formie-was-disabled"), t.removeAttribute("data-formie-loading"), i(t, e, "loading", !1), t.removeAttribute("data-formie-loading-indicator"), t.removeAttribute("data-formie-loading-text");
|
|
276
318
|
}), e.dataset.formieDisableSubmitUntilValid === "true") {
|
|
277
319
|
let t = e;
|
|
278
|
-
t.formieValidation &&
|
|
320
|
+
t.formieValidation && E(e, t.formieValidation);
|
|
279
321
|
}
|
|
280
322
|
}
|
|
281
323
|
function V(e, t) {
|
|
282
|
-
let n =
|
|
324
|
+
let n = N(e), r = me(e), s = n.findIndex((e) => e.getAttribute("data-formie-page-id") === t);
|
|
283
325
|
if (n.forEach((n) => {
|
|
284
|
-
n.getAttribute("data-formie-page-id") === t ? (n.removeAttribute("data-formie-page-hidden"),
|
|
285
|
-
}),
|
|
286
|
-
let a = n.getAttribute("data-formie-page-id") === t, o = s > -1 &&
|
|
287
|
-
|
|
288
|
-
}), s > -1 && n.length > 0 &&
|
|
326
|
+
n.getAttribute("data-formie-page-id") === t ? (n.removeAttribute("data-formie-page-hidden"), a(n, e, "pageHidden")) : (n.setAttribute("data-formie-page-hidden", "true"), o(n, e, "pageHidden"));
|
|
327
|
+
}), r.forEach((n, r) => {
|
|
328
|
+
let a = n.getAttribute("data-formie-page-id") === t, o = s > -1 && r < s;
|
|
329
|
+
i(n, e, "tabCurrent", a), i(n, e, "tabComplete", o), a ? n.setAttribute("aria-current", "page") : n.removeAttribute("aria-current"), o ? n.setAttribute("data-formie-tab-complete", "true") : n.removeAttribute("data-formie-tab-complete");
|
|
330
|
+
}), s > -1 && n.length > 0 && ye(e, he(e, s, n.length)), A(e, "pageId", t), b(e), e.dataset.formieDisableSubmitUntilValid === "true") {
|
|
289
331
|
let t = e;
|
|
290
|
-
t.formieValidation &&
|
|
332
|
+
t.formieValidation && E(e, t.formieValidation);
|
|
291
333
|
}
|
|
292
334
|
}
|
|
293
|
-
function
|
|
335
|
+
function Se(e, t) {
|
|
294
336
|
let n = t.meta?.submissionUid;
|
|
295
|
-
typeof n == "string" && n.trim() !== "" &&
|
|
337
|
+
typeof n == "string" && n.trim() !== "" && A(e, "submissionUid", n);
|
|
296
338
|
let r = (t.meta?.session)?.continuation?.continuationToken;
|
|
297
|
-
typeof r == "string" && r.trim() !== "" ?
|
|
339
|
+
typeof r == "string" && r.trim() !== "" ? A(e, "continuationToken", r) : M(e, "continuationToken");
|
|
298
340
|
}
|
|
299
|
-
function
|
|
341
|
+
function Ce(e) {
|
|
300
342
|
let t = e.getAttribute("action");
|
|
301
|
-
t && e.setAttribute("action",
|
|
343
|
+
t && e.setAttribute("action", fe(t, "resumeToken"));
|
|
302
344
|
try {
|
|
303
345
|
let e = new URL(window.location.href);
|
|
304
346
|
if (!e.searchParams.has("resumeToken")) return;
|
|
305
347
|
e.searchParams.delete("resumeToken"), window.history.replaceState({}, document.title, `${e.pathname}${e.search}${e.hash}`);
|
|
306
348
|
} catch {}
|
|
307
349
|
}
|
|
308
|
-
function
|
|
350
|
+
function we(e, t) {
|
|
309
351
|
let n = t.meta?.resumeUrl;
|
|
310
352
|
if (typeof n != "string" || n.trim() === "") return;
|
|
311
353
|
let r = n.trim();
|
|
312
|
-
if (
|
|
354
|
+
if (pe(r)) {
|
|
313
355
|
e.getAttribute("action") && e.setAttribute("action", r);
|
|
314
356
|
try {
|
|
315
357
|
let e = new URL(r, window.location.href);
|
|
@@ -318,88 +360,88 @@ function ve(e, t) {
|
|
|
318
360
|
}
|
|
319
361
|
}
|
|
320
362
|
function H(t, n = {}) {
|
|
321
|
-
let r = t.formieValidation, i =
|
|
322
|
-
if (
|
|
363
|
+
let r = t.formieValidation, i = N(t)[0]?.getAttribute("data-formie-page-id");
|
|
364
|
+
if (L(t), t.reset(), n.preserveHiddenState || I(t, !1), M(t, "submissionId"), M(t, "submissionUid"), M(t, "continuationToken"), M(t, "pageId"), Ce(t), r?.resetLiveState(), i) {
|
|
323
365
|
V(t, i), t.dispatchEvent(new CustomEvent(e("reset"), { bubbles: !0 }));
|
|
324
366
|
return;
|
|
325
367
|
}
|
|
326
|
-
|
|
368
|
+
b(t), t.dispatchEvent(new CustomEvent(e("reset"), { bubbles: !0 }));
|
|
327
369
|
}
|
|
328
|
-
function
|
|
329
|
-
return e.code ===
|
|
370
|
+
function Te(e) {
|
|
371
|
+
return e.code === de || e.meta?.resetState === !0;
|
|
330
372
|
}
|
|
331
|
-
function
|
|
332
|
-
let r =
|
|
373
|
+
function Ee(e, t) {
|
|
374
|
+
let r = t.submitData, i = /* @__PURE__ */ new Set(), a = !1;
|
|
333
375
|
if (Array.isArray(r) && r.length > 0) {
|
|
334
|
-
let
|
|
335
|
-
for (let r of
|
|
336
|
-
let
|
|
337
|
-
i.add(
|
|
376
|
+
let t = r.filter((e) => typeof e == "object" && !!e && "event" in e && typeof e.event == "string");
|
|
377
|
+
for (let r of t) {
|
|
378
|
+
let t = n(r.event);
|
|
379
|
+
i.add(t), k.log("Dispatching submitData event.", { eventName: t }), t.startsWith("formie:payment:") && (a = !0), e.dispatchEvent(new CustomEvent(t, {
|
|
338
380
|
bubbles: !0,
|
|
339
381
|
detail: { data: r.data }
|
|
340
382
|
}));
|
|
341
383
|
}
|
|
342
384
|
}
|
|
343
|
-
let o =
|
|
385
|
+
let o = t.meta || {}, s = (o.paymentAction && typeof o.paymentAction == "object" ? o.paymentAction : null) || (o.paymentDecision && typeof o.paymentDecision == "object" ? o.paymentDecision.action : null), c = s ? String(s.event || "") : "", l = s ? s.payload : void 0, u = n(c);
|
|
344
386
|
return u && !i.has(u) && (u.startsWith("formie:payment:") && (a = !0), e.dispatchEvent(new CustomEvent(u, {
|
|
345
387
|
bubbles: !0,
|
|
346
388
|
detail: { data: l }
|
|
347
|
-
})),
|
|
389
|
+
})), k.log("Dispatching fallback payment action event.", { eventName: u })), { hasPaymentFollowUpEvent: a };
|
|
348
390
|
}
|
|
349
|
-
function
|
|
350
|
-
if (
|
|
391
|
+
function De(e, t, n) {
|
|
392
|
+
if (k.log("Applying submit result state.", {
|
|
351
393
|
ok: t.ok,
|
|
352
394
|
action: n,
|
|
353
395
|
code: t.code,
|
|
354
396
|
hasRedirect: !!t.redirect?.url,
|
|
355
397
|
hasSubmitData: Array.isArray(t.submitData) && t.submitData.length > 0
|
|
356
|
-
}),
|
|
357
|
-
H(e),
|
|
398
|
+
}), Te(t)) {
|
|
399
|
+
H(e), k.log("Resetting state due to stale/reset marker.");
|
|
358
400
|
return;
|
|
359
401
|
}
|
|
360
|
-
let r =
|
|
402
|
+
let r = Ee(e, t);
|
|
361
403
|
if (!t.ok && t.redirect?.url && !r.hasPaymentFollowUpEvent) {
|
|
362
|
-
|
|
404
|
+
k.log("Applying redirect fallback for failed result.", {
|
|
363
405
|
url: t.redirect.url,
|
|
364
406
|
target: t.redirect.target
|
|
365
|
-
}),
|
|
407
|
+
}), L(e), t.redirect.target === "new-tab" ? window.open(t.redirect.url, "_blank") : (j(e, "redirect"), window.location.href = t.redirect.url);
|
|
366
408
|
return;
|
|
367
409
|
}
|
|
368
|
-
if (
|
|
369
|
-
|
|
410
|
+
if (Se(e, t), !t.ok) {
|
|
411
|
+
k.log("Non-redirect failure; keeping current form state."), L(e);
|
|
370
412
|
return;
|
|
371
413
|
}
|
|
372
|
-
if (
|
|
373
|
-
|
|
414
|
+
if (Array.isArray(t.clientEvents) && t.clientEvents.length > 0 ? v(e, t.clientEvents) : y(e, n), t.nextPage?.id) {
|
|
415
|
+
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 });
|
|
374
416
|
return;
|
|
375
417
|
}
|
|
376
418
|
if (n === "save") {
|
|
377
|
-
|
|
419
|
+
L(e), we(e, t), k.log("Applied save/resume token state.");
|
|
378
420
|
return;
|
|
379
421
|
}
|
|
380
422
|
if (n === "submit" && !t.redirect?.url) {
|
|
381
|
-
let n =
|
|
423
|
+
let n = P(e, t), r = n === "message" && F(e);
|
|
382
424
|
if (n === "reload") {
|
|
383
|
-
|
|
425
|
+
L(e), j(e, "reload"), window.location.reload();
|
|
384
426
|
return;
|
|
385
427
|
}
|
|
386
428
|
if (n === "reset") {
|
|
387
429
|
H(e);
|
|
388
430
|
return;
|
|
389
431
|
}
|
|
390
|
-
|
|
432
|
+
L(e), H(e, { preserveHiddenState: r });
|
|
391
433
|
return;
|
|
392
434
|
}
|
|
393
435
|
if (n === "submit" && t.redirect?.url && t.redirect.target === "new-tab") {
|
|
394
|
-
let n =
|
|
395
|
-
|
|
436
|
+
let n = P(e, t) === "message" && F(e);
|
|
437
|
+
L(e), H(e, { preserveHiddenState: n });
|
|
396
438
|
return;
|
|
397
439
|
}
|
|
398
|
-
|
|
440
|
+
L(e);
|
|
399
441
|
}
|
|
400
442
|
//#endregion
|
|
401
443
|
//#region src/js/modules/payments/constants.ts
|
|
402
|
-
var
|
|
444
|
+
var Oe = 2500, ke = {
|
|
403
445
|
bpoint: ["bpointToken"],
|
|
404
446
|
stripe: ["stripePaymentIntentId"],
|
|
405
447
|
paypal: ["paypalOrderId", "paypalAuthId"],
|
|
@@ -414,37 +456,37 @@ var Se = 2500, Ce = {
|
|
|
414
456
|
};
|
|
415
457
|
//#endregion
|
|
416
458
|
//#region src/js/utils/fields.ts
|
|
417
|
-
function
|
|
459
|
+
function Ae(e) {
|
|
418
460
|
return e.replace("{field:", "").replace("{", "").replace("}", "").replace("]", "").split("[").join("][");
|
|
419
461
|
}
|
|
420
|
-
function
|
|
421
|
-
return `fields[${
|
|
462
|
+
function je(e) {
|
|
463
|
+
return `fields[${Ae(e)}]`;
|
|
422
464
|
}
|
|
423
|
-
function
|
|
424
|
-
let n =
|
|
465
|
+
function Me(e, t) {
|
|
466
|
+
let n = je(t), r = Array.from(e.querySelectorAll(`[name="${n}"]`)), i = Array.from(e.querySelectorAll(`[name="${n}[]"]`));
|
|
425
467
|
return (i.length ? i : r).filter((e) => e instanceof HTMLElement);
|
|
426
468
|
}
|
|
427
|
-
function
|
|
428
|
-
let n =
|
|
469
|
+
function U(e, t) {
|
|
470
|
+
let n = Me(e, t);
|
|
429
471
|
for (let e of n) {
|
|
430
472
|
let t = e.closest("[data-formie-field-handle]")?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim();
|
|
431
473
|
if (t) return t;
|
|
432
474
|
}
|
|
433
475
|
return "";
|
|
434
476
|
}
|
|
435
|
-
function
|
|
477
|
+
function W(e) {
|
|
436
478
|
let t = e.replace(/[^\d.,-]/g, ""), n = t.includes(","), r = t.includes(".");
|
|
437
479
|
return t = n && r ? t.replace(/\./g, "").replace(/,/, ".") : n && !r ? t.replace(/,/, ".") : t.replace(/,/g, ""), parseFloat(t);
|
|
438
480
|
}
|
|
439
481
|
//#endregion
|
|
440
482
|
//#region src/js/modules/payments/utils.ts
|
|
441
|
-
function
|
|
483
|
+
function G(e, t) {
|
|
442
484
|
let n = t.replace(/"/g, "\\\"");
|
|
443
485
|
return e.querySelector(`input[name$="[${n}]"]`) || e.querySelector(`input[name$="${n}"]`);
|
|
444
486
|
}
|
|
445
|
-
function
|
|
487
|
+
function K(e, t) {
|
|
446
488
|
let n = t.find((t) => {
|
|
447
|
-
let n =
|
|
489
|
+
let n = G(e, t);
|
|
448
490
|
return !n || String(n.value || "").trim() === "";
|
|
449
491
|
});
|
|
450
492
|
return {
|
|
@@ -452,35 +494,35 @@ function q(e, t) {
|
|
|
452
494
|
missingSuffix: n
|
|
453
495
|
};
|
|
454
496
|
}
|
|
455
|
-
async function
|
|
456
|
-
let r =
|
|
497
|
+
async function q(e, t, n) {
|
|
498
|
+
let r = K(e, t);
|
|
457
499
|
if (r.ok) return r;
|
|
458
500
|
let i = Date.now() + Math.max(n, 0);
|
|
459
501
|
for (; Date.now() < i;) {
|
|
460
|
-
await
|
|
461
|
-
let n =
|
|
502
|
+
await c(120);
|
|
503
|
+
let n = K(e, t);
|
|
462
504
|
if (n.ok) return n;
|
|
463
505
|
}
|
|
464
|
-
return
|
|
506
|
+
return K(e, t);
|
|
465
507
|
}
|
|
466
508
|
//#endregion
|
|
467
509
|
//#region src/js/modules/payments/host.ts
|
|
468
|
-
var
|
|
510
|
+
var Ne = new Set([
|
|
469
511
|
"handle",
|
|
470
512
|
"requiredInputSuffixes",
|
|
471
513
|
"waitForValueMs",
|
|
472
514
|
"errorMessage"
|
|
473
|
-
]),
|
|
474
|
-
function
|
|
515
|
+
]), J = "[data-payment-success]", Y = "[data-payment-error]";
|
|
516
|
+
function X(e, t) {
|
|
475
517
|
return (typeof t.handle == "string" && t.handle.trim() !== "" ? t.handle.trim() : "") || e;
|
|
476
518
|
}
|
|
477
|
-
function
|
|
478
|
-
let r = t || {}, i = Object.entries(r).reduce((e, [t, n]) => (
|
|
519
|
+
function Pe(e, t, n) {
|
|
520
|
+
let r = t || {}, i = Object.entries(r).reduce((e, [t, n]) => (Ne.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.";
|
|
479
521
|
return {
|
|
480
|
-
handle:
|
|
522
|
+
handle: X(e, r),
|
|
481
523
|
transport: {
|
|
482
524
|
requiredInputSuffixes: a,
|
|
483
|
-
waitForValueMs: Number.isFinite(o) ? o :
|
|
525
|
+
waitForValueMs: Number.isFinite(o) ? o : Oe,
|
|
484
526
|
errorMessage: s
|
|
485
527
|
},
|
|
486
528
|
provider: i
|
|
@@ -491,9 +533,9 @@ function Z(e, t, n) {
|
|
|
491
533
|
e.removeEventListener(t, n);
|
|
492
534
|
};
|
|
493
535
|
}
|
|
494
|
-
function
|
|
495
|
-
let n = e.target, r = e.form, i = e.root,
|
|
496
|
-
let t =
|
|
536
|
+
function Fe(e, t) {
|
|
537
|
+
let n = e.target, r = e.form, i = e.root, a = r || i, c = t.transport.requiredInputSuffixes, m = () => p(r || i), h = (e) => {
|
|
538
|
+
let t = f(e, m()).value;
|
|
497
539
|
return Array.isArray(t) ? t[0] || "" : String(t || "");
|
|
498
540
|
};
|
|
499
541
|
return {
|
|
@@ -503,100 +545,100 @@ function ke(e, t) {
|
|
|
503
545
|
updateInputs: (e, t) => {
|
|
504
546
|
let r = Array.isArray(e) ? e : [e];
|
|
505
547
|
for (let e of r) {
|
|
506
|
-
let r =
|
|
548
|
+
let r = G(a, e) ?? n.querySelector(`input[name*="${e}"]`);
|
|
507
549
|
r && (r.value = t);
|
|
508
550
|
}
|
|
509
551
|
},
|
|
510
552
|
addError: (e) => {
|
|
511
|
-
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n,
|
|
512
|
-
|
|
553
|
+
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(Y);
|
|
554
|
+
a && a.remove();
|
|
513
555
|
let s = document.createElement("div");
|
|
514
|
-
s.setAttribute("data-payment-error", ""), s.textContent = e,
|
|
556
|
+
s.setAttribute("data-payment-error", ""), s.textContent = e, o(s, r || i, "fieldError"), t.appendChild(s);
|
|
515
557
|
},
|
|
516
558
|
removeError: () => {
|
|
517
|
-
n.querySelector(
|
|
559
|
+
n.querySelector(Y)?.remove();
|
|
518
560
|
},
|
|
519
561
|
addSuccess: (e) => {
|
|
520
|
-
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n,
|
|
521
|
-
|
|
562
|
+
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(J);
|
|
563
|
+
a && a.remove();
|
|
522
564
|
let s = document.createElement("div");
|
|
523
|
-
s.setAttribute("data-payment-success", ""), s.textContent = e,
|
|
565
|
+
s.setAttribute("data-payment-success", ""), s.textContent = e, o(s, r || i, "successMessage"), t.appendChild(s);
|
|
524
566
|
},
|
|
525
567
|
removeSuccess: () => {
|
|
526
|
-
n.querySelector(
|
|
568
|
+
n.querySelector(J)?.remove();
|
|
527
569
|
},
|
|
528
|
-
hasToken: () =>
|
|
529
|
-
waitForToken: (e = t.transport.waitForValueMs) =>
|
|
570
|
+
hasToken: () => K(a, c).ok,
|
|
571
|
+
waitForToken: (e = t.transport.waitForValueMs) => q(a, c, e).then((e) => e.ok),
|
|
530
572
|
getFieldValue: (e, t = "string") => {
|
|
531
573
|
let n = h(e);
|
|
532
|
-
return t === "float" || t === "int" || t === "number" ?
|
|
574
|
+
return t === "float" || t === "int" || t === "number" ? W(n) : n;
|
|
533
575
|
},
|
|
534
576
|
resolveAmount: (e) => {
|
|
535
|
-
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),
|
|
577
|
+
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(), c = typeof a == "number" ? a : W(o);
|
|
536
578
|
if (Number.isFinite(c) && c > 0) return {
|
|
537
579
|
ok: !0,
|
|
538
580
|
value: c
|
|
539
581
|
};
|
|
540
|
-
if (
|
|
541
|
-
let e = h(
|
|
582
|
+
if (o !== "") {
|
|
583
|
+
let e = h(o), n = W(e);
|
|
542
584
|
if (Number.isFinite(n) && n > 0) return {
|
|
543
585
|
ok: !0,
|
|
544
586
|
value: n
|
|
545
587
|
};
|
|
546
|
-
let r =
|
|
588
|
+
let r = U(t, o);
|
|
547
589
|
if (!e) return {
|
|
548
590
|
ok: !1,
|
|
549
|
-
error: r ?
|
|
591
|
+
error: r ? s("Provide a value for \"{label}\" to proceed.", { label: r }) : s("Provide a payment amount to proceed.")
|
|
550
592
|
};
|
|
551
593
|
}
|
|
552
594
|
return {
|
|
553
595
|
ok: !1,
|
|
554
|
-
error:
|
|
596
|
+
error: s("Payment amount must be greater than 0.")
|
|
555
597
|
};
|
|
556
598
|
},
|
|
557
599
|
resolveCurrency: (e) => {
|
|
558
|
-
let t = r || i, n = String(e.type || "").toLowerCase() === "dynamic" && typeof e.variable == "string" && e.variable.trim() !== "", a = e.value ?? (n ? e.variable : e.fixed ?? e.defaultCurrency ?? ""),
|
|
600
|
+
let t = r || i, n = String(e.type || "").toLowerCase() === "dynamic" && typeof e.variable == "string" && e.variable.trim() !== "", a = e.value ?? (n ? e.variable : e.fixed ?? e.defaultCurrency ?? ""), o = String(a ?? "").trim(), c = o.toUpperCase();
|
|
559
601
|
if (/^[A-Z]{3}$/.test(c) && !n) return {
|
|
560
602
|
ok: !0,
|
|
561
603
|
value: c
|
|
562
604
|
};
|
|
563
|
-
if (
|
|
564
|
-
let e = String(h(
|
|
605
|
+
if (o !== "") {
|
|
606
|
+
let e = String(h(o) || "").trim(), n = e.toUpperCase();
|
|
565
607
|
if (/^[A-Z]{3}$/.test(n)) return {
|
|
566
608
|
ok: !0,
|
|
567
609
|
value: n
|
|
568
610
|
};
|
|
569
|
-
let r =
|
|
611
|
+
let r = U(t, o);
|
|
570
612
|
if (!e) return {
|
|
571
613
|
ok: !1,
|
|
572
|
-
error: r ?
|
|
614
|
+
error: r ? s("Provide a value for \"{label}\" to proceed.", { label: r }) : s("Provide a payment currency to proceed.")
|
|
573
615
|
};
|
|
574
616
|
}
|
|
575
617
|
return {
|
|
576
618
|
ok: !1,
|
|
577
|
-
error:
|
|
619
|
+
error: s("Payment currency must be a valid 3-letter code.")
|
|
578
620
|
};
|
|
579
621
|
},
|
|
580
622
|
watchFieldValueChanges: (e, t, n = 600) => {
|
|
581
623
|
let a = r || i, o = e.map((e) => String(e || "").trim()).filter(Boolean);
|
|
582
624
|
if (o.length === 0) return () => {};
|
|
583
|
-
let s = m(),
|
|
625
|
+
let s = m(), c = /* @__PURE__ */ new Set();
|
|
584
626
|
o.forEach((e) => {
|
|
585
|
-
let t =
|
|
627
|
+
let t = u(e), n = s.get(t);
|
|
586
628
|
if (n?.names?.length) {
|
|
587
629
|
n.names.forEach((e) => {
|
|
588
|
-
|
|
630
|
+
c.add(e);
|
|
589
631
|
});
|
|
590
632
|
return;
|
|
591
633
|
}
|
|
592
|
-
let r =
|
|
593
|
-
r && (
|
|
634
|
+
let r = d(t);
|
|
635
|
+
r && (c.add(r), c.add(`${r}[]`));
|
|
594
636
|
});
|
|
595
|
-
let f =
|
|
637
|
+
let f = l(() => {
|
|
596
638
|
t();
|
|
597
639
|
}, n), p = (e) => {
|
|
598
640
|
let t = e.target?.name || "";
|
|
599
|
-
!t || !
|
|
641
|
+
!t || !c.has(t) || f();
|
|
600
642
|
};
|
|
601
643
|
return a.addEventListener("input", p), a.addEventListener("change", p), () => {
|
|
602
644
|
a.removeEventListener("input", p), a.removeEventListener("change", p);
|
|
@@ -633,13 +675,13 @@ function ke(e, t) {
|
|
|
633
675
|
}
|
|
634
676
|
//#endregion
|
|
635
677
|
//#region src/js/modules/payments/factories.ts
|
|
636
|
-
var Q =
|
|
678
|
+
var Q = r("payments");
|
|
637
679
|
function $(e) {
|
|
638
680
|
let t = e;
|
|
639
681
|
return !t.closest("[data-formie-page-hidden]") && !t.closest("[hidden]");
|
|
640
682
|
}
|
|
641
|
-
function
|
|
642
|
-
let t = e.defaultRequiredInputSuffixes ??
|
|
683
|
+
function Ie(e) {
|
|
684
|
+
let t = e.defaultRequiredInputSuffixes ?? ke[e.id] ?? [];
|
|
643
685
|
return {
|
|
644
686
|
id: e.id,
|
|
645
687
|
kind: "payment",
|
|
@@ -654,7 +696,7 @@ function Ae(e) {
|
|
|
654
696
|
await a.destroy();
|
|
655
697
|
} catch {}
|
|
656
698
|
}
|
|
657
|
-
let o =
|
|
699
|
+
let o = Pe(e.id, n.options || {}, { defaultRequiredInputSuffixes: t }), s = Fe(n, o), c = {
|
|
658
700
|
...n,
|
|
659
701
|
options: o,
|
|
660
702
|
services: s
|
|
@@ -753,7 +795,7 @@ function Ae(e) {
|
|
|
753
795
|
return;
|
|
754
796
|
}
|
|
755
797
|
if (o.transport.requiredInputSuffixes.length === 0) return;
|
|
756
|
-
let i = await
|
|
798
|
+
let i = await q(n.form || n.root, o.transport.requiredInputSuffixes, o.transport.waitForValueMs);
|
|
757
799
|
i.ok || (Q.warn("Required payment input(s) missing.", {
|
|
758
800
|
moduleId: e.id,
|
|
759
801
|
handle: o.handle,
|
|
@@ -775,6 +817,6 @@ function Ae(e) {
|
|
|
775
817
|
}
|
|
776
818
|
//#endregion
|
|
777
819
|
//#region src/js/modules/payments/api.ts
|
|
778
|
-
var
|
|
820
|
+
var Le = Ie;
|
|
779
821
|
//#endregion
|
|
780
|
-
export {
|
|
822
|
+
export { I as a, x as c, y as d, ae as f, B as i, S as l, V as n, xe as o, m as p, De as r, ue as s, Le as t, b as u };
|