@verbb/formie-browser 1.0.7 → 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 +12 -0
- package/dist/chunks/_survey-presentations-CFsgToRT.js +4 -0
- package/dist/chunks/{api-DztsCJ4r.js → api-C8wyLC-s.js} +184 -150
- package/dist/chunks/{bpoint-2qDxlKD9.js → bpoint-CwSw_p7A.js} +1 -1
- package/dist/chunks/{eway-CImXrB4g.js → eway-B30BMlDp.js} +1 -1
- package/dist/chunks/{go-cardless-Bz7HHtH0.js → go-cardless-BiF3iLel.js} +1 -1
- package/dist/chunks/{mollie-BtnB3KGh.js → mollie-D__SwtcH.js} +1 -1
- package/dist/chunks/{moneris-Bd4vUk8b.js → moneris-KJS1BKx7.js} +1 -1
- package/dist/chunks/{opayo-B-eRIXo-.js → opayo-A_LIkc-v.js} +1 -1
- package/dist/chunks/{paddle-BUFeEU4d.js → paddle-BjbOOb0m.js} +1 -1
- package/dist/chunks/{paypal-8Euw7Hrn.js → paypal-CyjHIV8v.js} +1 -1
- package/dist/chunks/{payway-dV0SzJxy.js → payway-a_cyrr3j.js} +1 -1
- package/dist/chunks/{square-reyJukb7.js → square-Bga6WXHV.js} +1 -1
- package/dist/chunks/{stripe-BC-2PBvY.js → stripe-BlqVocl3.js} +1 -1
- 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/css/formie-theme.css +1 -0
- package/dist/css/theme/fields/_survey-presentations.css +396 -0
- package/dist/index.js +469 -465
- 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/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/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/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 +14 -1
- package/src/js/core/page-client-event.ts +86 -18
- package/src/js/core/submit-result-state.ts +6 -2
- 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
|
@@ -14,14 +14,14 @@ function m(e, n, r) {
|
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/js/core/page-client-event.ts
|
|
17
|
-
var h = r("general", "page-client-event"), g = "data-formie-client-event";
|
|
17
|
+
var h = r("general", "page-client-event"), g = "data-formie-client-event", _ = "data-formie-pending-client-events";
|
|
18
18
|
function ee(e) {
|
|
19
19
|
return typeof window < "u" && window.CSS?.escape ? window.CSS.escape(e) : e.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
20
20
|
}
|
|
21
21
|
function te(e) {
|
|
22
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;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function ne(e) {
|
|
25
25
|
if (!e?.trim()) return null;
|
|
26
26
|
try {
|
|
27
27
|
let t = JSON.parse(e);
|
|
@@ -30,14 +30,51 @@ function _(e) {
|
|
|
30
30
|
return h.warn("Invalid data-formie-client-event JSON.", { rawPreview: e.slice(0, 80) }), null;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function re(e) {
|
|
34
34
|
let t = {};
|
|
35
35
|
return e.forEach((e) => {
|
|
36
36
|
let n = typeof e.label == "string" ? e.label.trim() : "";
|
|
37
37
|
n && (t[n] = typeof e.value == "string" ? e.value : "");
|
|
38
38
|
}), t;
|
|
39
39
|
}
|
|
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
|
+
}
|
|
40
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) {
|
|
41
78
|
if (t !== "submit") return;
|
|
42
79
|
let n = te(e);
|
|
43
80
|
if (!n) {
|
|
@@ -51,43 +88,40 @@ function v(e, t) {
|
|
|
51
88
|
}
|
|
52
89
|
let i = r.getAttribute(g);
|
|
53
90
|
if (i === null) return;
|
|
54
|
-
let a =
|
|
91
|
+
let a = ne(i);
|
|
55
92
|
if (!a || !Array.isArray(a.fields)) return;
|
|
56
|
-
let o =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
pageId: n,
|
|
62
|
-
keys: Object.keys(o)
|
|
63
|
-
});
|
|
93
|
+
let o = re(a.fields);
|
|
94
|
+
v(e, [{
|
|
95
|
+
event: typeof o.event == "string" && o.event !== "" ? o.event : "formPageSubmission",
|
|
96
|
+
payload: o
|
|
97
|
+
}]);
|
|
64
98
|
}
|
|
65
99
|
//#endregion
|
|
66
100
|
//#region src/js/core/page-tab-errors.ts
|
|
67
|
-
function
|
|
101
|
+
function oe(e, t) {
|
|
68
102
|
if (i(e, e, "tabError", t), t) {
|
|
69
103
|
e.setAttribute("data-formie-tab-error", "true");
|
|
70
104
|
return;
|
|
71
105
|
}
|
|
72
106
|
e.removeAttribute("data-formie-tab-error");
|
|
73
107
|
}
|
|
74
|
-
function
|
|
108
|
+
function b(e) {
|
|
75
109
|
let t = /* @__PURE__ */ new Set();
|
|
76
110
|
e.querySelectorAll("[data-formie-page]").forEach((e) => {
|
|
77
111
|
let n = e, r = n.getAttribute("data-formie-page-id");
|
|
78
112
|
r && n.querySelector("[data-formie-field-has-error]") && t.add(r);
|
|
79
113
|
}), e.querySelectorAll("[data-formie-tab]").forEach((e) => {
|
|
80
114
|
let n = e, r = n.getAttribute("data-formie-page-id");
|
|
81
|
-
|
|
115
|
+
oe(n, !!r && t.has(r));
|
|
82
116
|
});
|
|
83
117
|
}
|
|
84
118
|
//#endregion
|
|
85
119
|
//#region src/js/validation/scope.ts
|
|
86
|
-
function
|
|
120
|
+
function x(e) {
|
|
87
121
|
return Array.from(e.querySelectorAll("[data-formie-page]"));
|
|
88
122
|
}
|
|
89
|
-
function
|
|
90
|
-
let t =
|
|
123
|
+
function S(e) {
|
|
124
|
+
let t = x(e);
|
|
91
125
|
if (!t.length) return {
|
|
92
126
|
scope: e,
|
|
93
127
|
final: !0
|
|
@@ -100,35 +134,35 @@ function x(e) {
|
|
|
100
134
|
}
|
|
101
135
|
//#endregion
|
|
102
136
|
//#region src/js/validation/submit-readiness.ts
|
|
103
|
-
var
|
|
104
|
-
function
|
|
137
|
+
var C = "data-formie-submit-validation-disabled", w = "data-formie-preserve-disabled", se = "data-formie-submit-ready";
|
|
138
|
+
function T(e) {
|
|
105
139
|
return e.dataset.formieDisableSubmitUntilValid === "true";
|
|
106
140
|
}
|
|
107
|
-
function
|
|
141
|
+
function ce(e) {
|
|
108
142
|
return Array.from(e.querySelectorAll("button[data-formie-action=\"submit\"]")).filter((e) => e instanceof HTMLButtonElement);
|
|
109
143
|
}
|
|
110
|
-
function
|
|
144
|
+
function le(e) {
|
|
111
145
|
return !e.hasAttribute("data-formie-conditionally-hidden") && !e.closest("[data-formie-conditionally-hidden]");
|
|
112
146
|
}
|
|
113
|
-
function
|
|
114
|
-
if (!
|
|
115
|
-
let { scope: n, final: r } =
|
|
116
|
-
e.setAttribute(
|
|
117
|
-
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)) {
|
|
118
152
|
if (i) {
|
|
119
|
-
if (!e.hasAttribute(
|
|
120
|
-
e.hasAttribute(
|
|
153
|
+
if (!e.hasAttribute(C)) return;
|
|
154
|
+
e.hasAttribute(w) ? (e.disabled = !0, e.removeAttribute(w)) : e.disabled = !1, e.removeAttribute(C);
|
|
121
155
|
return;
|
|
122
156
|
}
|
|
123
|
-
e.hasAttribute(
|
|
157
|
+
e.hasAttribute(C) || (e.disabled && e.setAttribute(w, "true"), e.setAttribute(C, "true")), e.disabled = !0;
|
|
124
158
|
}
|
|
125
159
|
});
|
|
126
160
|
}
|
|
127
|
-
function
|
|
128
|
-
if (!
|
|
161
|
+
function ue(e, t, n) {
|
|
162
|
+
if (!T(e)) return () => {};
|
|
129
163
|
let r = !1, i = () => {
|
|
130
164
|
r || (r = !0, queueMicrotask(() => {
|
|
131
|
-
r = !1,
|
|
165
|
+
r = !1, E(e, t);
|
|
132
166
|
}));
|
|
133
167
|
};
|
|
134
168
|
i();
|
|
@@ -171,18 +205,18 @@ function se(e, t, n) {
|
|
|
171
205
|
}
|
|
172
206
|
//#endregion
|
|
173
207
|
//#region src/js/core/submit-result-state.ts
|
|
174
|
-
var
|
|
175
|
-
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) {
|
|
176
210
|
let r = e.querySelector(`input[name="${t}"]`);
|
|
177
211
|
r || (r = document.createElement("input"), r.type = "hidden", r.name = t, e.appendChild(r)), r.value = n;
|
|
178
212
|
}
|
|
179
|
-
function
|
|
213
|
+
function j(e, t) {
|
|
180
214
|
e.setAttribute("data-formie-internal-navigation", t);
|
|
181
215
|
}
|
|
182
|
-
function
|
|
216
|
+
function M(e, t) {
|
|
183
217
|
e.querySelector(`input[name="${t}"]`)?.remove();
|
|
184
218
|
}
|
|
185
|
-
function
|
|
219
|
+
function fe(e, t) {
|
|
186
220
|
try {
|
|
187
221
|
let n = new URL(e, window.location.href);
|
|
188
222
|
return n.searchParams.delete(t), n.toString();
|
|
@@ -190,39 +224,39 @@ function le(e, t) {
|
|
|
190
224
|
return e;
|
|
191
225
|
}
|
|
192
226
|
}
|
|
193
|
-
function
|
|
227
|
+
function pe(e) {
|
|
194
228
|
try {
|
|
195
229
|
return new URL(e, window.location.href).origin === window.location.origin;
|
|
196
230
|
} catch {
|
|
197
231
|
return !1;
|
|
198
232
|
}
|
|
199
233
|
}
|
|
200
|
-
function
|
|
234
|
+
function N(e) {
|
|
201
235
|
return Array.from(e.querySelectorAll("[data-formie-page]"));
|
|
202
236
|
}
|
|
203
|
-
function
|
|
237
|
+
function me(e) {
|
|
204
238
|
return Array.from(e.querySelectorAll("[data-formie-tab]"));
|
|
205
239
|
}
|
|
206
|
-
function
|
|
240
|
+
function he(e, t, n) {
|
|
207
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);
|
|
208
242
|
}
|
|
209
|
-
function
|
|
243
|
+
function ge(e) {
|
|
210
244
|
return e <= 0 ? "start" : e >= 100 ? "end" : "middle";
|
|
211
245
|
}
|
|
212
|
-
function
|
|
246
|
+
function _e(e) {
|
|
213
247
|
return (e.dataset.formieSubmitAction || "").trim();
|
|
214
248
|
}
|
|
215
|
-
function
|
|
249
|
+
function P(e, t) {
|
|
216
250
|
let n = t.meta?.effectiveSubmitAction;
|
|
217
|
-
return typeof n == "string" && n.trim() !== "" ? n.trim() :
|
|
251
|
+
return typeof n == "string" && n.trim() !== "" ? n.trim() : _e(e);
|
|
218
252
|
}
|
|
219
|
-
function
|
|
253
|
+
function F(e) {
|
|
220
254
|
let t = e.dataset.formieSubmitActionFormHide;
|
|
221
255
|
if (t === void 0) return !1;
|
|
222
256
|
let n = t.trim().toLowerCase();
|
|
223
257
|
return n === "true" || n === "1" || n === "";
|
|
224
258
|
}
|
|
225
|
-
function
|
|
259
|
+
function I(e, t) {
|
|
226
260
|
e.toggleAttribute("data-formie-form-hidden", t), [
|
|
227
261
|
"[data-formie-form-header]",
|
|
228
262
|
"[data-formie-form-navigation]",
|
|
@@ -235,89 +269,89 @@ function F(e, t) {
|
|
|
235
269
|
});
|
|
236
270
|
});
|
|
237
271
|
}
|
|
238
|
-
function I(e) {
|
|
239
|
-
let t = E.get(e);
|
|
240
|
-
typeof t == "number" && (window.clearTimeout(t), E.delete(e));
|
|
241
|
-
}
|
|
242
|
-
function he(e, t) {
|
|
243
|
-
D.has(e) || D.set(e, e.innerHTML), e.textContent = t;
|
|
244
|
-
}
|
|
245
272
|
function L(e) {
|
|
246
273
|
let t = D.get(e);
|
|
247
|
-
t
|
|
274
|
+
typeof t == "number" && (window.clearTimeout(t), D.delete(e));
|
|
275
|
+
}
|
|
276
|
+
function ve(e, t) {
|
|
277
|
+
O.has(e) || O.set(e, e.innerHTML), e.textContent = t;
|
|
248
278
|
}
|
|
249
|
-
function R(e
|
|
279
|
+
function R(e) {
|
|
280
|
+
let t = O.get(e);
|
|
281
|
+
t !== void 0 && (e.innerHTML = t, O.delete(e));
|
|
282
|
+
}
|
|
283
|
+
function ye(e, t) {
|
|
250
284
|
let n = e.querySelector("[data-formie-progress-bar]"), r = e.querySelector("[data-formie-progress-value]");
|
|
251
|
-
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}`)));
|
|
252
286
|
}
|
|
253
|
-
function
|
|
287
|
+
function be(e, t) {
|
|
254
288
|
if (!t) return;
|
|
255
289
|
let n = (e.dataset.formieLoadingIndicator || "").trim();
|
|
256
290
|
if (n) {
|
|
257
291
|
if (t.setAttribute("data-formie-loading-indicator", n), n === "spinner") {
|
|
258
|
-
i(t, e, "loading", !0),
|
|
292
|
+
i(t, e, "loading", !0), R(t), t.removeAttribute("data-formie-loading-text");
|
|
259
293
|
return;
|
|
260
294
|
}
|
|
261
295
|
if (n === "text") {
|
|
262
296
|
let n = (e.dataset.formieLoadingIndicatorText || "").trim(), r = t.textContent?.trim() || "", i = n || r;
|
|
263
|
-
t.setAttribute("data-formie-loading-text", i),
|
|
297
|
+
t.setAttribute("data-formie-loading-text", i), ve(t, i);
|
|
264
298
|
return;
|
|
265
299
|
}
|
|
266
|
-
|
|
300
|
+
R(t), t.removeAttribute("data-formie-loading-text");
|
|
267
301
|
}
|
|
268
302
|
}
|
|
269
303
|
function z(e) {
|
|
270
304
|
return Array.from(e.querySelectorAll("[data-formie-action]"));
|
|
271
305
|
}
|
|
272
|
-
function
|
|
306
|
+
function xe(e, t) {
|
|
273
307
|
e.getAttribute("data-formie-loading") !== "true" && (e.setAttribute("data-formie-loading", "true"), z(e).forEach((e) => {
|
|
274
308
|
"disabled" in e && (e.disabled ? e.setAttribute("data-formie-was-disabled", "true") : e.removeAttribute("data-formie-was-disabled"), e.disabled = !0);
|
|
275
|
-
}), t && (t.setAttribute("data-formie-loading", "true"),
|
|
309
|
+
}), t && (t.setAttribute("data-formie-loading", "true"), be(e, t)));
|
|
276
310
|
}
|
|
277
|
-
function
|
|
311
|
+
function B(e) {
|
|
278
312
|
if (e.removeAttribute("data-formie-loading"), z(e).forEach((t) => {
|
|
279
313
|
if ("disabled" in t) {
|
|
280
314
|
let e = t;
|
|
281
315
|
e.disabled = e.getAttribute("data-formie-was-disabled") === "true";
|
|
282
316
|
}
|
|
283
|
-
|
|
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");
|
|
284
318
|
}), e.dataset.formieDisableSubmitUntilValid === "true") {
|
|
285
319
|
let t = e;
|
|
286
|
-
t.formieValidation &&
|
|
320
|
+
t.formieValidation && E(e, t.formieValidation);
|
|
287
321
|
}
|
|
288
322
|
}
|
|
289
|
-
function
|
|
290
|
-
let n =
|
|
323
|
+
function V(e, t) {
|
|
324
|
+
let n = N(e), r = me(e), s = n.findIndex((e) => e.getAttribute("data-formie-page-id") === t);
|
|
291
325
|
if (n.forEach((n) => {
|
|
292
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"));
|
|
293
327
|
}), r.forEach((n, r) => {
|
|
294
328
|
let a = n.getAttribute("data-formie-page-id") === t, o = s > -1 && r < s;
|
|
295
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");
|
|
296
|
-
}), s > -1 && n.length > 0 &&
|
|
330
|
+
}), s > -1 && n.length > 0 && ye(e, he(e, s, n.length)), A(e, "pageId", t), b(e), e.dataset.formieDisableSubmitUntilValid === "true") {
|
|
297
331
|
let t = e;
|
|
298
|
-
t.formieValidation &&
|
|
332
|
+
t.formieValidation && E(e, t.formieValidation);
|
|
299
333
|
}
|
|
300
334
|
}
|
|
301
|
-
function
|
|
335
|
+
function Se(e, t) {
|
|
302
336
|
let n = t.meta?.submissionUid;
|
|
303
|
-
typeof n == "string" && n.trim() !== "" &&
|
|
337
|
+
typeof n == "string" && n.trim() !== "" && A(e, "submissionUid", n);
|
|
304
338
|
let r = (t.meta?.session)?.continuation?.continuationToken;
|
|
305
|
-
typeof r == "string" && r.trim() !== "" ?
|
|
339
|
+
typeof r == "string" && r.trim() !== "" ? A(e, "continuationToken", r) : M(e, "continuationToken");
|
|
306
340
|
}
|
|
307
|
-
function
|
|
341
|
+
function Ce(e) {
|
|
308
342
|
let t = e.getAttribute("action");
|
|
309
|
-
t && e.setAttribute("action",
|
|
343
|
+
t && e.setAttribute("action", fe(t, "resumeToken"));
|
|
310
344
|
try {
|
|
311
345
|
let e = new URL(window.location.href);
|
|
312
346
|
if (!e.searchParams.has("resumeToken")) return;
|
|
313
347
|
e.searchParams.delete("resumeToken"), window.history.replaceState({}, document.title, `${e.pathname}${e.search}${e.hash}`);
|
|
314
348
|
} catch {}
|
|
315
349
|
}
|
|
316
|
-
function
|
|
350
|
+
function we(e, t) {
|
|
317
351
|
let n = t.meta?.resumeUrl;
|
|
318
352
|
if (typeof n != "string" || n.trim() === "") return;
|
|
319
353
|
let r = n.trim();
|
|
320
|
-
if (
|
|
354
|
+
if (pe(r)) {
|
|
321
355
|
e.getAttribute("action") && e.setAttribute("action", r);
|
|
322
356
|
try {
|
|
323
357
|
let e = new URL(r, window.location.href);
|
|
@@ -325,24 +359,24 @@ function ye(e, t) {
|
|
|
325
359
|
} catch {}
|
|
326
360
|
}
|
|
327
361
|
}
|
|
328
|
-
function
|
|
329
|
-
let r = t.formieValidation, i =
|
|
330
|
-
if (
|
|
331
|
-
|
|
362
|
+
function H(t, n = {}) {
|
|
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) {
|
|
365
|
+
V(t, i), t.dispatchEvent(new CustomEvent(e("reset"), { bubbles: !0 }));
|
|
332
366
|
return;
|
|
333
367
|
}
|
|
334
|
-
|
|
368
|
+
b(t), t.dispatchEvent(new CustomEvent(e("reset"), { bubbles: !0 }));
|
|
335
369
|
}
|
|
336
|
-
function
|
|
337
|
-
return e.code ===
|
|
370
|
+
function Te(e) {
|
|
371
|
+
return e.code === de || e.meta?.resetState === !0;
|
|
338
372
|
}
|
|
339
|
-
function
|
|
373
|
+
function Ee(e, t) {
|
|
340
374
|
let r = t.submitData, i = /* @__PURE__ */ new Set(), a = !1;
|
|
341
375
|
if (Array.isArray(r) && r.length > 0) {
|
|
342
376
|
let t = r.filter((e) => typeof e == "object" && !!e && "event" in e && typeof e.event == "string");
|
|
343
377
|
for (let r of t) {
|
|
344
378
|
let t = n(r.event);
|
|
345
|
-
i.add(t),
|
|
379
|
+
i.add(t), k.log("Dispatching submitData event.", { eventName: t }), t.startsWith("formie:payment:") && (a = !0), e.dispatchEvent(new CustomEvent(t, {
|
|
346
380
|
bubbles: !0,
|
|
347
381
|
detail: { data: r.data }
|
|
348
382
|
}));
|
|
@@ -352,62 +386,62 @@ function xe(e, t) {
|
|
|
352
386
|
return u && !i.has(u) && (u.startsWith("formie:payment:") && (a = !0), e.dispatchEvent(new CustomEvent(u, {
|
|
353
387
|
bubbles: !0,
|
|
354
388
|
detail: { data: l }
|
|
355
|
-
})),
|
|
389
|
+
})), k.log("Dispatching fallback payment action event.", { eventName: u })), { hasPaymentFollowUpEvent: a };
|
|
356
390
|
}
|
|
357
|
-
function
|
|
358
|
-
if (
|
|
391
|
+
function De(e, t, n) {
|
|
392
|
+
if (k.log("Applying submit result state.", {
|
|
359
393
|
ok: t.ok,
|
|
360
394
|
action: n,
|
|
361
395
|
code: t.code,
|
|
362
396
|
hasRedirect: !!t.redirect?.url,
|
|
363
397
|
hasSubmitData: Array.isArray(t.submitData) && t.submitData.length > 0
|
|
364
|
-
}),
|
|
365
|
-
|
|
398
|
+
}), Te(t)) {
|
|
399
|
+
H(e), k.log("Resetting state due to stale/reset marker.");
|
|
366
400
|
return;
|
|
367
401
|
}
|
|
368
|
-
let r =
|
|
402
|
+
let r = Ee(e, t);
|
|
369
403
|
if (!t.ok && t.redirect?.url && !r.hasPaymentFollowUpEvent) {
|
|
370
|
-
|
|
404
|
+
k.log("Applying redirect fallback for failed result.", {
|
|
371
405
|
url: t.redirect.url,
|
|
372
406
|
target: t.redirect.target
|
|
373
|
-
}),
|
|
407
|
+
}), L(e), t.redirect.target === "new-tab" ? window.open(t.redirect.url, "_blank") : (j(e, "redirect"), window.location.href = t.redirect.url);
|
|
374
408
|
return;
|
|
375
409
|
}
|
|
376
|
-
if (
|
|
377
|
-
|
|
410
|
+
if (Se(e, t), !t.ok) {
|
|
411
|
+
k.log("Non-redirect failure; keeping current form state."), L(e);
|
|
378
412
|
return;
|
|
379
413
|
}
|
|
380
|
-
if (v(e, n), t.nextPage?.id) {
|
|
381
|
-
|
|
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 });
|
|
382
416
|
return;
|
|
383
417
|
}
|
|
384
418
|
if (n === "save") {
|
|
385
|
-
|
|
419
|
+
L(e), we(e, t), k.log("Applied save/resume token state.");
|
|
386
420
|
return;
|
|
387
421
|
}
|
|
388
422
|
if (n === "submit" && !t.redirect?.url) {
|
|
389
|
-
let n =
|
|
423
|
+
let n = P(e, t), r = n === "message" && F(e);
|
|
390
424
|
if (n === "reload") {
|
|
391
|
-
|
|
425
|
+
L(e), j(e, "reload"), window.location.reload();
|
|
392
426
|
return;
|
|
393
427
|
}
|
|
394
428
|
if (n === "reset") {
|
|
395
|
-
|
|
429
|
+
H(e);
|
|
396
430
|
return;
|
|
397
431
|
}
|
|
398
|
-
|
|
432
|
+
L(e), H(e, { preserveHiddenState: r });
|
|
399
433
|
return;
|
|
400
434
|
}
|
|
401
435
|
if (n === "submit" && t.redirect?.url && t.redirect.target === "new-tab") {
|
|
402
|
-
let n =
|
|
403
|
-
|
|
436
|
+
let n = P(e, t) === "message" && F(e);
|
|
437
|
+
L(e), H(e, { preserveHiddenState: n });
|
|
404
438
|
return;
|
|
405
439
|
}
|
|
406
|
-
|
|
440
|
+
L(e);
|
|
407
441
|
}
|
|
408
442
|
//#endregion
|
|
409
443
|
//#region src/js/modules/payments/constants.ts
|
|
410
|
-
var
|
|
444
|
+
var Oe = 2500, ke = {
|
|
411
445
|
bpoint: ["bpointToken"],
|
|
412
446
|
stripe: ["stripePaymentIntentId"],
|
|
413
447
|
paypal: ["paypalOrderId", "paypalAuthId"],
|
|
@@ -422,37 +456,37 @@ var Ce = 2500, we = {
|
|
|
422
456
|
};
|
|
423
457
|
//#endregion
|
|
424
458
|
//#region src/js/utils/fields.ts
|
|
425
|
-
function
|
|
459
|
+
function Ae(e) {
|
|
426
460
|
return e.replace("{field:", "").replace("{", "").replace("}", "").replace("]", "").split("[").join("][");
|
|
427
461
|
}
|
|
428
|
-
function
|
|
429
|
-
return `fields[${
|
|
462
|
+
function je(e) {
|
|
463
|
+
return `fields[${Ae(e)}]`;
|
|
430
464
|
}
|
|
431
|
-
function
|
|
432
|
-
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}[]"]`));
|
|
433
467
|
return (i.length ? i : r).filter((e) => e instanceof HTMLElement);
|
|
434
468
|
}
|
|
435
|
-
function
|
|
436
|
-
let n =
|
|
469
|
+
function U(e, t) {
|
|
470
|
+
let n = Me(e, t);
|
|
437
471
|
for (let e of n) {
|
|
438
472
|
let t = e.closest("[data-formie-field-handle]")?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim();
|
|
439
473
|
if (t) return t;
|
|
440
474
|
}
|
|
441
475
|
return "";
|
|
442
476
|
}
|
|
443
|
-
function
|
|
477
|
+
function W(e) {
|
|
444
478
|
let t = e.replace(/[^\d.,-]/g, ""), n = t.includes(","), r = t.includes(".");
|
|
445
479
|
return t = n && r ? t.replace(/\./g, "").replace(/,/, ".") : n && !r ? t.replace(/,/, ".") : t.replace(/,/g, ""), parseFloat(t);
|
|
446
480
|
}
|
|
447
481
|
//#endregion
|
|
448
482
|
//#region src/js/modules/payments/utils.ts
|
|
449
|
-
function
|
|
483
|
+
function G(e, t) {
|
|
450
484
|
let n = t.replace(/"/g, "\\\"");
|
|
451
485
|
return e.querySelector(`input[name$="[${n}]"]`) || e.querySelector(`input[name$="${n}"]`);
|
|
452
486
|
}
|
|
453
|
-
function
|
|
487
|
+
function K(e, t) {
|
|
454
488
|
let n = t.find((t) => {
|
|
455
|
-
let n =
|
|
489
|
+
let n = G(e, t);
|
|
456
490
|
return !n || String(n.value || "").trim() === "";
|
|
457
491
|
});
|
|
458
492
|
return {
|
|
@@ -460,35 +494,35 @@ function q(e, t) {
|
|
|
460
494
|
missingSuffix: n
|
|
461
495
|
};
|
|
462
496
|
}
|
|
463
|
-
async function
|
|
464
|
-
let r =
|
|
497
|
+
async function q(e, t, n) {
|
|
498
|
+
let r = K(e, t);
|
|
465
499
|
if (r.ok) return r;
|
|
466
500
|
let i = Date.now() + Math.max(n, 0);
|
|
467
501
|
for (; Date.now() < i;) {
|
|
468
502
|
await c(120);
|
|
469
|
-
let n =
|
|
503
|
+
let n = K(e, t);
|
|
470
504
|
if (n.ok) return n;
|
|
471
505
|
}
|
|
472
|
-
return
|
|
506
|
+
return K(e, t);
|
|
473
507
|
}
|
|
474
508
|
//#endregion
|
|
475
509
|
//#region src/js/modules/payments/host.ts
|
|
476
|
-
var
|
|
510
|
+
var Ne = new Set([
|
|
477
511
|
"handle",
|
|
478
512
|
"requiredInputSuffixes",
|
|
479
513
|
"waitForValueMs",
|
|
480
514
|
"errorMessage"
|
|
481
|
-
]),
|
|
482
|
-
function
|
|
515
|
+
]), J = "[data-payment-success]", Y = "[data-payment-error]";
|
|
516
|
+
function X(e, t) {
|
|
483
517
|
return (typeof t.handle == "string" && t.handle.trim() !== "" ? t.handle.trim() : "") || e;
|
|
484
518
|
}
|
|
485
|
-
function
|
|
486
|
-
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.";
|
|
487
521
|
return {
|
|
488
|
-
handle:
|
|
522
|
+
handle: X(e, r),
|
|
489
523
|
transport: {
|
|
490
524
|
requiredInputSuffixes: a,
|
|
491
|
-
waitForValueMs: Number.isFinite(o) ? o :
|
|
525
|
+
waitForValueMs: Number.isFinite(o) ? o : Oe,
|
|
492
526
|
errorMessage: s
|
|
493
527
|
},
|
|
494
528
|
provider: i
|
|
@@ -499,7 +533,7 @@ function Z(e, t, n) {
|
|
|
499
533
|
e.removeEventListener(t, n);
|
|
500
534
|
};
|
|
501
535
|
}
|
|
502
|
-
function
|
|
536
|
+
function Fe(e, t) {
|
|
503
537
|
let n = e.target, r = e.form, i = e.root, a = r || i, c = t.transport.requiredInputSuffixes, m = () => p(r || i), h = (e) => {
|
|
504
538
|
let t = f(e, m()).value;
|
|
505
539
|
return Array.isArray(t) ? t[0] || "" : String(t || "");
|
|
@@ -511,47 +545,47 @@ function je(e, t) {
|
|
|
511
545
|
updateInputs: (e, t) => {
|
|
512
546
|
let r = Array.isArray(e) ? e : [e];
|
|
513
547
|
for (let e of r) {
|
|
514
|
-
let r =
|
|
548
|
+
let r = G(a, e) ?? n.querySelector(`input[name*="${e}"]`);
|
|
515
549
|
r && (r.value = t);
|
|
516
550
|
}
|
|
517
551
|
},
|
|
518
552
|
addError: (e) => {
|
|
519
|
-
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(
|
|
553
|
+
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(Y);
|
|
520
554
|
a && a.remove();
|
|
521
555
|
let s = document.createElement("div");
|
|
522
556
|
s.setAttribute("data-payment-error", ""), s.textContent = e, o(s, r || i, "fieldError"), t.appendChild(s);
|
|
523
557
|
},
|
|
524
558
|
removeError: () => {
|
|
525
|
-
n.querySelector(
|
|
559
|
+
n.querySelector(Y)?.remove();
|
|
526
560
|
},
|
|
527
561
|
addSuccess: (e) => {
|
|
528
|
-
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(
|
|
562
|
+
let t = n.querySelector("[data-formie-field-type] > div, [data-field-type] > div") || n, a = t.querySelector(J);
|
|
529
563
|
a && a.remove();
|
|
530
564
|
let s = document.createElement("div");
|
|
531
565
|
s.setAttribute("data-payment-success", ""), s.textContent = e, o(s, r || i, "successMessage"), t.appendChild(s);
|
|
532
566
|
},
|
|
533
567
|
removeSuccess: () => {
|
|
534
|
-
n.querySelector(
|
|
568
|
+
n.querySelector(J)?.remove();
|
|
535
569
|
},
|
|
536
|
-
hasToken: () =>
|
|
537
|
-
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),
|
|
538
572
|
getFieldValue: (e, t = "string") => {
|
|
539
573
|
let n = h(e);
|
|
540
|
-
return t === "float" || t === "int" || t === "number" ?
|
|
574
|
+
return t === "float" || t === "int" || t === "number" ? W(n) : n;
|
|
541
575
|
},
|
|
542
576
|
resolveAmount: (e) => {
|
|
543
|
-
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 :
|
|
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);
|
|
544
578
|
if (Number.isFinite(c) && c > 0) return {
|
|
545
579
|
ok: !0,
|
|
546
580
|
value: c
|
|
547
581
|
};
|
|
548
582
|
if (o !== "") {
|
|
549
|
-
let e = h(o), n =
|
|
583
|
+
let e = h(o), n = W(e);
|
|
550
584
|
if (Number.isFinite(n) && n > 0) return {
|
|
551
585
|
ok: !0,
|
|
552
586
|
value: n
|
|
553
587
|
};
|
|
554
|
-
let r =
|
|
588
|
+
let r = U(t, o);
|
|
555
589
|
if (!e) return {
|
|
556
590
|
ok: !1,
|
|
557
591
|
error: r ? s("Provide a value for \"{label}\" to proceed.", { label: r }) : s("Provide a payment amount to proceed.")
|
|
@@ -574,7 +608,7 @@ function je(e, t) {
|
|
|
574
608
|
ok: !0,
|
|
575
609
|
value: n
|
|
576
610
|
};
|
|
577
|
-
let r =
|
|
611
|
+
let r = U(t, o);
|
|
578
612
|
if (!e) return {
|
|
579
613
|
ok: !1,
|
|
580
614
|
error: r ? s("Provide a value for \"{label}\" to proceed.", { label: r }) : s("Provide a payment currency to proceed.")
|
|
@@ -614,7 +648,7 @@ function je(e, t) {
|
|
|
614
648
|
r && r.setAttribute("data-formie-internal-resubmit", "true"), r && typeof r.requestSubmit == "function" ? r.requestSubmit() : r && r.submit();
|
|
615
649
|
},
|
|
616
650
|
releaseSubmitLoading: () => {
|
|
617
|
-
r && (r.removeAttribute("data-formie-internal-resubmit"),
|
|
651
|
+
r && (r.removeAttribute("data-formie-internal-resubmit"), B(r));
|
|
618
652
|
},
|
|
619
653
|
getBillingData: (e) => {
|
|
620
654
|
let t = {};
|
|
@@ -646,8 +680,8 @@ function $(e) {
|
|
|
646
680
|
let t = e;
|
|
647
681
|
return !t.closest("[data-formie-page-hidden]") && !t.closest("[hidden]");
|
|
648
682
|
}
|
|
649
|
-
function
|
|
650
|
-
let t = e.defaultRequiredInputSuffixes ??
|
|
683
|
+
function Ie(e) {
|
|
684
|
+
let t = e.defaultRequiredInputSuffixes ?? ke[e.id] ?? [];
|
|
651
685
|
return {
|
|
652
686
|
id: e.id,
|
|
653
687
|
kind: "payment",
|
|
@@ -662,7 +696,7 @@ function Me(e) {
|
|
|
662
696
|
await a.destroy();
|
|
663
697
|
} catch {}
|
|
664
698
|
}
|
|
665
|
-
let o =
|
|
699
|
+
let o = Pe(e.id, n.options || {}, { defaultRequiredInputSuffixes: t }), s = Fe(n, o), c = {
|
|
666
700
|
...n,
|
|
667
701
|
options: o,
|
|
668
702
|
services: s
|
|
@@ -761,7 +795,7 @@ function Me(e) {
|
|
|
761
795
|
return;
|
|
762
796
|
}
|
|
763
797
|
if (o.transport.requiredInputSuffixes.length === 0) return;
|
|
764
|
-
let i = await
|
|
798
|
+
let i = await q(n.form || n.root, o.transport.requiredInputSuffixes, o.transport.waitForValueMs);
|
|
765
799
|
i.ok || (Q.warn("Required payment input(s) missing.", {
|
|
766
800
|
moduleId: e.id,
|
|
767
801
|
handle: o.handle,
|
|
@@ -783,6 +817,6 @@ function Me(e) {
|
|
|
783
817
|
}
|
|
784
818
|
//#endregion
|
|
785
819
|
//#region src/js/modules/payments/api.ts
|
|
786
|
-
var
|
|
820
|
+
var Le = Ie;
|
|
787
821
|
//#endregion
|
|
788
|
-
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 };
|