@verbb/formie-browser 1.0.8 → 1.0.9
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-RbSqcQph.js +4 -0
- package/dist/chunks/{address-state-BQ0xGV9n.js → address-state-BwE01m2_.js} +1 -1
- package/dist/chunks/{api-C8wyLC-s.js → api-BYe9YPko.js} +10 -3
- package/dist/chunks/{bpoint-CwSw_p7A.js → bpoint-C0VOftX9.js} +1 -1
- package/dist/chunks/{combobox-D-2b42wn.js → combobox-C0EuExSI.js} +1 -1
- package/dist/chunks/{eway-B30BMlDp.js → eway-CS6Y1Yvo.js} +1 -1
- package/dist/chunks/{file-upload-D49m8-DR.js → file-upload-rqfZNqlH.js} +1 -1
- package/dist/chunks/{go-cardless-BiF3iLel.js → go-cardless-BTPD668l.js} +1 -1
- package/dist/chunks/{mollie-D__SwtcH.js → mollie-CXgBwvo6.js} +1 -1
- package/dist/chunks/{moneris-KJS1BKx7.js → moneris-B6oLu7nj.js} +1 -1
- package/dist/chunks/{opayo-A_LIkc-v.js → opayo-DPUA5CKr.js} +1 -1
- package/dist/chunks/{paddle-BjbOOb0m.js → paddle-GRlsm5mm.js} +1 -1
- package/dist/chunks/{paypal-CyjHIV8v.js → paypal-CdcZnf6r.js} +2 -2
- package/dist/chunks/{payway-a_cyrr3j.js → payway-CfmYOS__.js} +2 -2
- package/dist/chunks/{repeater-B5leVxZU.js → repeater-BVnPUqTj.js} +1 -1
- package/dist/chunks/rich-text-Bg_--4TG.js +349 -0
- package/dist/chunks/{square-Bga6WXHV.js → square-BY--5M-X.js} +1 -1
- package/dist/chunks/{stripe-BlqVocl3.js → stripe-uusYjWty.js} +2 -2
- package/dist/chunks/{survey-likert-DmJ3klhP.js → survey-likert-DkE6bR7B.js} +1 -1
- package/dist/chunks/{survey-rank-DeUenftw.js → survey-rank-DN6x4IZM.js} +1 -1
- package/dist/chunks/{survey-rating-BPUYDgBJ.js → survey-rating-BnsNL9U5.js} +1 -1
- package/dist/chunks/{table-C-lkQN6I.js → table-CAjCJHrL.js} +1 -1
- package/dist/chunks/{upload-manager-BpqWSHmU.js → upload-manager-W-QDgxKD.js} +1 -1
- package/dist/css/theme/_tokens.css +10 -5
- package/dist/css/theme/fields/_check-radio.css +1 -1
- package/dist/css/theme/fields/_combobox.css +1 -1
- package/dist/css/theme/fields/_file.css +3 -3
- package/dist/css/theme/fields/_input.css +1 -1
- package/dist/css/theme/fields/_repeater.css +1 -1
- package/dist/css/theme/fields/_rich-text.css +1 -1
- package/dist/css/theme/fields/_select.css +1 -1
- package/dist/css/theme/fields/_survey-presentations.css +1 -1
- package/dist/css/theme/fields/_table.css +1 -1
- package/dist/css/theme/fields/_upload-manager.css +3 -3
- package/dist/css/theme/integrations/_paypal.css +1 -1
- package/dist/css/theme/integrations/_payway.css +1 -1
- package/dist/css/theme/integrations/_stripe.css +1 -1
- package/dist/index.js +510 -492
- package/dist/js/core/submit-flow.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 +1 -0
- package/dist/js/core/submit-result-ui.d.ts.map +1 -1
- package/dist/js/utils/fields.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/css/theme/_tokens.css +10 -5
- package/src/css/theme/fields/_check-radio.css +1 -1
- package/src/css/theme/fields/_combobox.css +1 -1
- package/src/css/theme/fields/_file.css +3 -3
- package/src/css/theme/fields/_input.css +1 -1
- package/src/css/theme/fields/_repeater.css +1 -1
- package/src/css/theme/fields/_rich-text.css +1 -1
- package/src/css/theme/fields/_select.css +1 -1
- package/src/css/theme/fields/_survey-presentations.css +1 -1
- package/src/css/theme/fields/_table.css +1 -1
- package/src/css/theme/fields/_upload-manager.css +3 -3
- package/src/css/theme/integrations/_paypal.css +1 -1
- package/src/css/theme/integrations/_payway.css +1 -1
- package/src/css/theme/integrations/_stripe.css +1 -1
- package/src/js/core/submit-flow.ts +3 -1
- package/src/js/core/submit-result-state.ts +12 -0
- package/src/js/core/submit-result-ui.ts +47 -9
- package/src/js/utils/fields.ts +14 -2
- package/dist/chunks/_survey-presentations-CFsgToRT.js +0 -4
- package/dist/chunks/rich-text-D0sb8bmX.js +0 -349
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { c as e, d as t, l as n, o as r, r as i, t as a, u as o } from "./chunks/event-names-BCI2FLD8.js";
|
|
2
|
-
import { a as s, c, d as l, f as u, i as d, l as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y } from "./chunks/api-
|
|
3
|
-
import { a as b, i as x, n as
|
|
4
|
-
import { n as
|
|
5
|
-
import { t as
|
|
6
|
-
import { a as
|
|
7
|
-
import { n as
|
|
8
|
-
import { n as
|
|
9
|
-
import { i as
|
|
10
|
-
import { t as
|
|
2
|
+
import { a as s, c, d as l, f as u, i as d, l as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y } from "./chunks/api-BYe9YPko.js";
|
|
3
|
+
import { a as b, i as x, n as ee, r as te, t as S } from "./chunks/debug-BV0DvdHx.js";
|
|
4
|
+
import { n as ne, r as C, t as w } from "./chunks/theme-classes-Tv7q7ToE.js";
|
|
5
|
+
import { t as T } from "./chunks/http-D-JExro7.js";
|
|
6
|
+
import { a as E, i as D, n as re, r as ie, t as ae } from "./chunks/i18n-BY1ds1BL.js";
|
|
7
|
+
import { n as oe, t as se } from "./chunks/api-BUb6P-xu.js";
|
|
8
|
+
import { n as ce, r as le, t as ue } from "./chunks/field-references.keys-58ZSTrCW.js";
|
|
9
|
+
import { i as de, n as fe, r as pe, t as me } from "./chunks/field-references.resolver-CHwn0G0L.js";
|
|
10
|
+
import { t as he } from "./chunks/api-sPqGbOww.js";
|
|
11
11
|
//#region src/js/compatibility/event-map.ts
|
|
12
|
-
var
|
|
12
|
+
var ge = [
|
|
13
13
|
{
|
|
14
14
|
legacyEvent: "onFormieLoaded",
|
|
15
15
|
canonicalEvent: "formie:mount:after",
|
|
@@ -62,7 +62,7 @@ var he = [
|
|
|
62
62
|
canonicalEvent: "formie:submit:after",
|
|
63
63
|
disposition: "approximate"
|
|
64
64
|
}
|
|
65
|
-
],
|
|
65
|
+
], _e = [
|
|
66
66
|
{
|
|
67
67
|
legacyEvent: "formieValidatorInitialized",
|
|
68
68
|
canonicalEvent: "formie:validator:ready",
|
|
@@ -84,7 +84,7 @@ var he = [
|
|
|
84
84
|
disposition: "safe"
|
|
85
85
|
}
|
|
86
86
|
];
|
|
87
|
-
function
|
|
87
|
+
function ve(e) {
|
|
88
88
|
if (!e) return {
|
|
89
89
|
enabled: !1,
|
|
90
90
|
legacyDomEvents: !1,
|
|
@@ -104,18 +104,18 @@ function _e(e) {
|
|
|
104
104
|
}
|
|
105
105
|
//#endregion
|
|
106
106
|
//#region src/js/compatibility/dom-adapter.ts
|
|
107
|
-
function
|
|
107
|
+
function ye(e, t, n) {
|
|
108
108
|
e.dispatchEvent(new CustomEvent(t, {
|
|
109
109
|
bubbles: !0,
|
|
110
110
|
detail: n
|
|
111
111
|
}));
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function be(e, t) {
|
|
114
114
|
if (e.canonicalEvent !== "formie:submit:result") return !0;
|
|
115
115
|
let n = t;
|
|
116
116
|
return e.legacyEvent === "onAfterFormieSubmit" ? !!n?.ok : e.legacyEvent === "onFormieSubmitError" ? n?.ok === !1 : !0;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function xe(e, t) {
|
|
119
119
|
let n = t && typeof t == "object" ? t : {}, r = typeof n.pageId == "string" ? n.pageId : "", i = Array.from(e.querySelectorAll("[data-formie-page-id]"));
|
|
120
120
|
return { data: {
|
|
121
121
|
nextPageId: r,
|
|
@@ -123,7 +123,7 @@ function be(e, t) {
|
|
|
123
123
|
totalPages: i.length
|
|
124
124
|
} };
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function Se(e, t, n, r, i) {
|
|
127
127
|
let a = globalThis.Formie || i;
|
|
128
128
|
return e.legacyEvent === "onFormieLoaded" ? { formie: a } : e.legacyEvent === "onFormieInit" ? {
|
|
129
129
|
formie: a,
|
|
@@ -135,12 +135,12 @@ function xe(e, t, n, r, i) {
|
|
|
135
135
|
form: r,
|
|
136
136
|
target: n,
|
|
137
137
|
instance: i
|
|
138
|
-
} : e.legacyEvent === "onFormiePageToggle" ?
|
|
138
|
+
} : e.legacyEvent === "onFormiePageToggle" ? xe(r, t) : t;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
i.legacyDomEvents &&
|
|
140
|
+
function Ce({ target: e, form: n, instance: r, options: i, unbinds: a }) {
|
|
141
|
+
i.legacyDomEvents && ge.forEach((i) => {
|
|
142
142
|
let o = (t) => {
|
|
143
|
-
!(t instanceof CustomEvent) || !
|
|
143
|
+
!(t instanceof CustomEvent) || !be(i, t.detail) || ye(i.target === "document" ? document : n, i.legacyEvent, Se(i, t.detail, e, n, r));
|
|
144
144
|
};
|
|
145
145
|
e.addEventListener(t(i.canonicalEvent), o), a.push(() => {
|
|
146
146
|
e.removeEventListener(t(i.canonicalEvent), o);
|
|
@@ -149,30 +149,30 @@ function Se({ target: e, form: n, instance: r, options: i, unbinds: a }) {
|
|
|
149
149
|
}
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region src/js/compatibility/validator-adapter.ts
|
|
152
|
-
function
|
|
152
|
+
function O(e, t, n) {
|
|
153
153
|
e.dispatchEvent(new CustomEvent(t, {
|
|
154
154
|
bubbles: !0,
|
|
155
155
|
detail: n
|
|
156
156
|
}));
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function k(e, t) {
|
|
159
159
|
return !!e && typeof e == "object" && e.validator === t;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function we({ target: e, form: t, validatorDetail: n, options: r, unbinds: i }) {
|
|
162
162
|
if (!r.legacyValidatorEvents || !n) return;
|
|
163
163
|
let { validator: a, addValidator: o, removeValidator: s } = n, c = {
|
|
164
164
|
...n,
|
|
165
165
|
form: t,
|
|
166
166
|
target: e
|
|
167
167
|
};
|
|
168
|
-
|
|
168
|
+
O(document, "formieValidatorInitialized", c);
|
|
169
169
|
let l = (e) => {
|
|
170
|
-
!(e instanceof CustomEvent) || !
|
|
170
|
+
!(e instanceof CustomEvent) || !k(e.detail, a) || O(document, "formieValidatorDestroyed", {
|
|
171
171
|
...c,
|
|
172
172
|
...e.detail
|
|
173
173
|
});
|
|
174
174
|
}, u = (n) => {
|
|
175
|
-
!(n instanceof CustomEvent) || !
|
|
175
|
+
!(n instanceof CustomEvent) || !k(n.detail, a) || !(n.target instanceof Element) || t.contains(n.target) && O(n.target, "formieValidatorShowError", {
|
|
176
176
|
...n.detail,
|
|
177
177
|
addValidator: o,
|
|
178
178
|
removeValidator: s,
|
|
@@ -180,7 +180,7 @@ function Ce({ target: e, form: t, validatorDetail: n, options: r, unbinds: i })
|
|
|
180
180
|
target: e
|
|
181
181
|
});
|
|
182
182
|
}, d = (n) => {
|
|
183
|
-
!(n instanceof CustomEvent) || !
|
|
183
|
+
!(n instanceof CustomEvent) || !k(n.detail, a) || !(n.target instanceof Element) || t.contains(n.target) && O(n.target, "formieValidatorClearError", {
|
|
184
184
|
...n.detail,
|
|
185
185
|
addValidator: o,
|
|
186
186
|
removeValidator: s,
|
|
@@ -194,17 +194,17 @@ function Ce({ target: e, form: t, validatorDetail: n, options: r, unbinds: i })
|
|
|
194
194
|
}
|
|
195
195
|
//#endregion
|
|
196
196
|
//#region src/js/core/error-aria-live.ts
|
|
197
|
-
function
|
|
197
|
+
function Te(e) {
|
|
198
198
|
let t = (e.dataset.formieErrorAriaLive || "polite").trim().toLowerCase();
|
|
199
199
|
return t === "assertive" || t === "off" ? t : "polite";
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function Ee(e, t) {
|
|
202
202
|
return e === "off" ? null : t ? e : "polite";
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function De(e) {
|
|
205
205
|
return e === "off" ? null : e;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function Oe(e, t) {
|
|
208
208
|
if (t) {
|
|
209
209
|
e.setAttribute("aria-live", t), e.setAttribute("aria-atomic", "true");
|
|
210
210
|
return;
|
|
@@ -213,38 +213,38 @@ function De(e, t) {
|
|
|
213
213
|
}
|
|
214
214
|
//#endregion
|
|
215
215
|
//#region src/js/core/validation-focus.ts
|
|
216
|
-
function
|
|
216
|
+
function ke(e, t) {
|
|
217
217
|
let n = (e.getAttribute("aria-describedby") || "").trim(), r = n ? n.split(/\s+/) : [];
|
|
218
218
|
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function Ae(e) {
|
|
221
221
|
return Array.from(e.querySelectorAll("[data-formie-field-handle]")).find((e) => e.getAttribute("data-formie-field-has-error") === "true" ? !0 : e.querySelector("[data-formie-field-error]") !== null) || null;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function je(e) {
|
|
224
224
|
return e.querySelector("[aria-invalid=\"true\"]") || e.querySelector("input:not([type=\"hidden\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])");
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function Me(e) {
|
|
227
227
|
return e.querySelector("[data-formie-message-error], [data-formie-error-container], [data-formie-errors]");
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function Ne(e) {
|
|
230
230
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
231
231
|
let n = t;
|
|
232
232
|
if (!(n.getAttribute("data-formie-field-has-error") === "true" || n.querySelector("[data-formie-field-error]") !== null)) return;
|
|
233
|
-
n.setAttribute("data-formie-field-has-error", "true"),
|
|
233
|
+
n.setAttribute("data-formie-field-has-error", "true"), w(n, e, "fieldLayoutError");
|
|
234
234
|
let r = n.querySelector("[data-formie-field-errors]")?.id || "", i = n.querySelector("[data-formie-field-error]")?.id || "";
|
|
235
235
|
n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
236
236
|
let n = t;
|
|
237
|
-
n.setAttribute("aria-invalid", "true"),
|
|
237
|
+
n.setAttribute("aria-invalid", "true"), w(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), r && ke(n, r), i && n.setAttribute("aria-errormessage", i);
|
|
238
238
|
});
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
|
-
function Ne(e) {
|
|
242
|
-
return !!ke(e) || !!je(e);
|
|
243
|
-
}
|
|
244
241
|
function Pe(e) {
|
|
245
|
-
|
|
242
|
+
return !!Ae(e) || !!Me(e);
|
|
243
|
+
}
|
|
244
|
+
function Fe(e) {
|
|
245
|
+
let t = Ae(e);
|
|
246
246
|
if (t) {
|
|
247
|
-
let e =
|
|
247
|
+
let e = je(t);
|
|
248
248
|
if (e) {
|
|
249
249
|
if (e.scrollIntoView({
|
|
250
250
|
behavior: "smooth",
|
|
@@ -261,7 +261,7 @@ function Pe(e) {
|
|
|
261
261
|
block: "center"
|
|
262
262
|
}), !0;
|
|
263
263
|
}
|
|
264
|
-
let n =
|
|
264
|
+
let n = Me(e);
|
|
265
265
|
return n ? (n.scrollIntoView({
|
|
266
266
|
behavior: "smooth",
|
|
267
267
|
block: "center"
|
|
@@ -269,7 +269,7 @@ function Pe(e) {
|
|
|
269
269
|
}
|
|
270
270
|
//#endregion
|
|
271
271
|
//#region src/js/events/event-bus.ts
|
|
272
|
-
var
|
|
272
|
+
var Ie = class {
|
|
273
273
|
constructor() {
|
|
274
274
|
this.listeners = /* @__PURE__ */ new Map();
|
|
275
275
|
}
|
|
@@ -325,8 +325,8 @@ var Fe = class {
|
|
|
325
325
|
clear() {
|
|
326
326
|
this.listeners.clear();
|
|
327
327
|
}
|
|
328
|
-
},
|
|
329
|
-
function
|
|
328
|
+
}, A = S("general", "transport");
|
|
329
|
+
function Le(e) {
|
|
330
330
|
let t = {};
|
|
331
331
|
return [
|
|
332
332
|
"theme",
|
|
@@ -337,17 +337,17 @@ function Ie(e) {
|
|
|
337
337
|
e[n] !== void 0 && (t[n] = e[n]);
|
|
338
338
|
}), t;
|
|
339
339
|
}
|
|
340
|
-
function
|
|
340
|
+
function Re(e, t = "", n = {}) {
|
|
341
341
|
if (Array.isArray(e)) {
|
|
342
342
|
let r = e.map((e) => typeof e == "string" ? e : String(e ?? "")).filter((e) => e.trim() !== "");
|
|
343
343
|
return t && r.length && (n[t] = (n[t] || []).concat(r)), n;
|
|
344
344
|
}
|
|
345
345
|
return e && typeof e == "object" && Object.entries(e).forEach(([e, r]) => {
|
|
346
|
-
|
|
346
|
+
Re(r, t ? `${t}.${e}` : e, n);
|
|
347
347
|
}), n;
|
|
348
348
|
}
|
|
349
|
-
function
|
|
350
|
-
let n = e.success === !0, r = e.keepSubmitLoading === !0, i = e.errors, a =
|
|
349
|
+
function ze(e, t) {
|
|
350
|
+
let n = e.success === !0, r = e.keepSubmitLoading === !0, i = e.errors, a = Re(i || {}), o = a.form || [], s = {};
|
|
351
351
|
Object.entries(a).forEach(([e, t]) => {
|
|
352
352
|
if (e === "form") return;
|
|
353
353
|
let n = e.split(".")[0];
|
|
@@ -372,35 +372,35 @@ function Re(e, t) {
|
|
|
372
372
|
meta: e
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
|
-
async function
|
|
375
|
+
async function Be(e, t, n = {}) {
|
|
376
376
|
let r = JSON.stringify({
|
|
377
377
|
handle: t,
|
|
378
378
|
renderOptions: n
|
|
379
379
|
});
|
|
380
|
-
|
|
380
|
+
A.log("requestRender start.", {
|
|
381
381
|
endpoint: e,
|
|
382
382
|
handle: t
|
|
383
383
|
});
|
|
384
|
-
let i = await
|
|
384
|
+
let i = await T(e, {
|
|
385
385
|
method: "POST",
|
|
386
386
|
body: r,
|
|
387
387
|
headers: { "Content-Type": "application/json" }
|
|
388
388
|
});
|
|
389
|
-
return
|
|
389
|
+
return A.log("requestRender complete.", { hasHtml: !!i.html }), i;
|
|
390
390
|
}
|
|
391
|
-
async function
|
|
391
|
+
async function Ve(e, t, n = {}) {
|
|
392
392
|
let r = JSON.stringify({
|
|
393
393
|
query: "\nquery FormieHtmlForm($handle: String!, $input: ServerRenderPayloadInput) {\n formieHtmlForm(handle: $handle, input: $input) {\n html\n }\n}",
|
|
394
394
|
variables: {
|
|
395
395
|
handle: t,
|
|
396
|
-
input:
|
|
396
|
+
input: Le(n)
|
|
397
397
|
}
|
|
398
398
|
});
|
|
399
|
-
|
|
399
|
+
A.log("requestGraphqlRender start.", {
|
|
400
400
|
endpoint: e,
|
|
401
401
|
handle: t
|
|
402
402
|
});
|
|
403
|
-
let i = await
|
|
403
|
+
let i = await T(e, {
|
|
404
404
|
method: "POST",
|
|
405
405
|
body: r,
|
|
406
406
|
headers: { "Content-Type": "application/json" }
|
|
@@ -408,19 +408,19 @@ async function Be(e, t, n = {}) {
|
|
|
408
408
|
if (Array.isArray(i.errors) && i.errors.length > 0) throw Error(i.errors.map((e) => e.message || "Unknown GraphQL error").join("; "));
|
|
409
409
|
if (!i.data?.formieHtmlForm) throw Error(`Form not found for handle "${t}".`);
|
|
410
410
|
let a = i.data.formieHtmlForm;
|
|
411
|
-
return
|
|
411
|
+
return A.log("requestGraphqlRender complete.", { hasHtml: !!a.html }), a;
|
|
412
412
|
}
|
|
413
|
-
async function
|
|
413
|
+
async function j(e, t, n) {
|
|
414
414
|
let r = new URL(e, window.location.origin);
|
|
415
|
-
r.searchParams.set("handle", t), n && r.searchParams.set("renderId", n),
|
|
415
|
+
r.searchParams.set("handle", t), n && r.searchParams.set("renderId", n), A.log("requestRefreshTokens start.", {
|
|
416
416
|
endpoint: r.toString(),
|
|
417
417
|
handle: t,
|
|
418
418
|
hasRenderId: !!n
|
|
419
419
|
});
|
|
420
|
-
let i = await
|
|
421
|
-
return
|
|
420
|
+
let i = await T(r.toString());
|
|
421
|
+
return A.log("requestRefreshTokens complete.", { hasRefreshTokens: !!i.refreshTokens }), i.refreshTokens || i;
|
|
422
422
|
}
|
|
423
|
-
async function
|
|
423
|
+
async function He(e, t, n) {
|
|
424
424
|
let r = new URL(e, window.location.origin), i = new FormData();
|
|
425
425
|
if (n && i.append("pageId", n), t) {
|
|
426
426
|
[
|
|
@@ -436,17 +436,17 @@ async function Ve(e, t, n) {
|
|
|
436
436
|
let e = t.querySelector("input[name=\"CRAFT_CSRF_TOKEN\"]")?.value?.trim();
|
|
437
437
|
e && i.append("CRAFT_CSRF_TOKEN", e);
|
|
438
438
|
}
|
|
439
|
-
|
|
439
|
+
A.log("requestSetPage start.", {
|
|
440
440
|
requestUrl: r.toString(),
|
|
441
441
|
pageId: n || null
|
|
442
442
|
});
|
|
443
|
-
let a = await
|
|
443
|
+
let a = await T(r.toString(), {
|
|
444
444
|
method: "POST",
|
|
445
445
|
body: i
|
|
446
446
|
});
|
|
447
|
-
return
|
|
447
|
+
return A.log("requestSetPage complete.", a), a;
|
|
448
448
|
}
|
|
449
|
-
function
|
|
449
|
+
function Ue(e, t) {
|
|
450
450
|
let n = new URL(e, window.location.origin), r = new FormData();
|
|
451
451
|
[
|
|
452
452
|
"handle",
|
|
@@ -458,7 +458,7 @@ function He(e, t) {
|
|
|
458
458
|
n && r.append(e, n);
|
|
459
459
|
});
|
|
460
460
|
let i = t.querySelector("input[name=\"CRAFT_CSRF_TOKEN\"]")?.value?.trim();
|
|
461
|
-
i && r.append("CRAFT_CSRF_TOKEN", i),
|
|
461
|
+
i && r.append("CRAFT_CSRF_TOKEN", i), A.log("clearSubmissionOnUnload start.", { requestUrl: n.toString() });
|
|
462
462
|
try {
|
|
463
463
|
if (typeof navigator.sendBeacon == "function" && navigator.sendBeacon(n.toString(), r)) return;
|
|
464
464
|
} catch {}
|
|
@@ -470,9 +470,9 @@ function He(e, t) {
|
|
|
470
470
|
headers: { Accept: "application/json" }
|
|
471
471
|
});
|
|
472
472
|
}
|
|
473
|
-
async function
|
|
473
|
+
async function We(e, t) {
|
|
474
474
|
let n = (e.getAttribute("method") || "POST").toUpperCase(), r = e.getAttribute("action") || window.location.href, i = e.dataset.formieErrorMessage?.trim() || "Submission failed.";
|
|
475
|
-
|
|
475
|
+
A.log("submitForm start.", {
|
|
476
476
|
method: n,
|
|
477
477
|
action: r,
|
|
478
478
|
submitAction: t.get("submitAction")
|
|
@@ -483,13 +483,13 @@ async function Ue(e, t) {
|
|
|
483
483
|
credentials: "include",
|
|
484
484
|
headers: { Accept: "application/json" }
|
|
485
485
|
}), o = a.headers.get("content-type") || "";
|
|
486
|
-
if (!o.includes("application/json")) return a.ok ? (
|
|
486
|
+
if (!o.includes("application/json")) return a.ok ? (A.log("submitForm non-JSON success response.", {
|
|
487
487
|
status: a.status,
|
|
488
488
|
contentType: o
|
|
489
489
|
}), {
|
|
490
490
|
ok: !0,
|
|
491
491
|
message: "Submission completed."
|
|
492
|
-
}) : (
|
|
492
|
+
}) : (A.warn("submitForm non-JSON HTTP error.", {
|
|
493
493
|
status: a.status,
|
|
494
494
|
contentType: o
|
|
495
495
|
}), {
|
|
@@ -498,8 +498,8 @@ async function Ue(e, t) {
|
|
|
498
498
|
message: `Request failed (${a.status}).`,
|
|
499
499
|
formErrors: [`Request failed (${a.status}).`]
|
|
500
500
|
});
|
|
501
|
-
let s =
|
|
502
|
-
return
|
|
501
|
+
let s = ze(await a.json(), i);
|
|
502
|
+
return A.log("submitForm JSON response normalized.", {
|
|
503
503
|
ok: s.ok,
|
|
504
504
|
code: s.code,
|
|
505
505
|
hasRedirect: !!s.redirect?.url,
|
|
@@ -508,7 +508,7 @@ async function Ue(e, t) {
|
|
|
508
508
|
}
|
|
509
509
|
//#endregion
|
|
510
510
|
//#region src/js/submit/pipeline.ts
|
|
511
|
-
var
|
|
511
|
+
var Ge = [
|
|
512
512
|
"prepare",
|
|
513
513
|
"normalize",
|
|
514
514
|
"validate",
|
|
@@ -516,14 +516,14 @@ var We = [
|
|
|
516
516
|
"authorize",
|
|
517
517
|
"dispatch",
|
|
518
518
|
"finalize"
|
|
519
|
-
],
|
|
519
|
+
], Ke = [
|
|
520
520
|
"prepare",
|
|
521
521
|
"normalize",
|
|
522
522
|
"validate",
|
|
523
523
|
"screen",
|
|
524
524
|
"authorize"
|
|
525
|
-
],
|
|
526
|
-
function
|
|
525
|
+
], M = S("general", "pipeline");
|
|
526
|
+
function qe(e, t) {
|
|
527
527
|
return {
|
|
528
528
|
ok: !1,
|
|
529
529
|
stage: e,
|
|
@@ -532,13 +532,13 @@ function Ke(e, t) {
|
|
|
532
532
|
formErrors: [t || "Submission aborted."]
|
|
533
533
|
};
|
|
534
534
|
}
|
|
535
|
-
function
|
|
535
|
+
function Je(e) {
|
|
536
536
|
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
|
|
537
537
|
}
|
|
538
|
-
function
|
|
538
|
+
function Ye(e) {
|
|
539
539
|
return !(!e.name || e.disabled || e instanceof HTMLInputElement && (e.type === "submit" || e.type === "button" || e.type === "reset" || e.type === "image" || (e.type === "checkbox" || e.type === "radio") && !e.checked || e.type === "file" && (!e.files || e.files.length === 0)));
|
|
540
540
|
}
|
|
541
|
-
function
|
|
541
|
+
function Xe(e, t) {
|
|
542
542
|
if (t instanceof HTMLInputElement) {
|
|
543
543
|
if (t.type === "file") {
|
|
544
544
|
Array.from(t.files || []).forEach((n) => {
|
|
@@ -557,49 +557,49 @@ function Ye(e, t) {
|
|
|
557
557
|
}
|
|
558
558
|
e.append(t.name, t.value);
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function Ze(e, t) {
|
|
561
561
|
t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
562
|
-
let n =
|
|
563
|
-
!n || n.closest("[data-formie-page]") ||
|
|
562
|
+
let n = Je(t) ? t : null;
|
|
563
|
+
!n || n.closest("[data-formie-page]") || Ye(n) && Xe(e, n);
|
|
564
564
|
});
|
|
565
565
|
}
|
|
566
|
-
function
|
|
566
|
+
function Qe(e, t) {
|
|
567
567
|
let n = /* @__PURE__ */ new Set();
|
|
568
568
|
return t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
569
|
-
let r =
|
|
570
|
-
!r || !r.name || r.disabled || r instanceof HTMLInputElement && (r.type === "submit" || r.type === "button" || r.type === "reset" || r.type === "image") || (r.name.startsWith("fields[") && n.add(r.name),
|
|
569
|
+
let r = Je(t) ? t : null;
|
|
570
|
+
!r || !r.name || r.disabled || r instanceof HTMLInputElement && (r.type === "submit" || r.type === "button" || r.type === "reset" || r.type === "image") || (r.name.startsWith("fields[") && n.add(r.name), Ye(r) && Xe(e, r));
|
|
571
571
|
}), n;
|
|
572
572
|
}
|
|
573
|
-
function
|
|
573
|
+
function $e(e, t) {
|
|
574
574
|
t.forEach((t) => {
|
|
575
575
|
e.has(t) || e.append(t, "");
|
|
576
576
|
});
|
|
577
577
|
}
|
|
578
|
-
function
|
|
578
|
+
function et(e, t) {
|
|
579
579
|
let n = c(e), r = n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || null;
|
|
580
580
|
if (!n.length || !r) {
|
|
581
581
|
let n = new FormData(e);
|
|
582
582
|
return n.set("submitAction", t), n;
|
|
583
583
|
}
|
|
584
584
|
let i = new FormData();
|
|
585
|
-
return
|
|
585
|
+
return Ze(i, e), $e(i, Qe(i, r)), i.set("submitAction", t), i;
|
|
586
586
|
}
|
|
587
|
-
function
|
|
587
|
+
function tt(e, t) {
|
|
588
588
|
if (t !== "submit") return !1;
|
|
589
589
|
let n = c(e);
|
|
590
590
|
return n.length ? (n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || n[n.length - 1]) === n[n.length - 1] : !0;
|
|
591
591
|
}
|
|
592
|
-
async function
|
|
593
|
-
|
|
592
|
+
async function nt(e, t, n, r = {}) {
|
|
593
|
+
M.log("Starting submit pipeline.", {
|
|
594
594
|
action: t,
|
|
595
595
|
preflightOnly: r.preflightOnly === !0
|
|
596
596
|
});
|
|
597
|
-
let i = !1, a, o = null, s =
|
|
597
|
+
let i = !1, a, o = null, s = tt(e, t), c = {
|
|
598
598
|
form: e,
|
|
599
599
|
action: t,
|
|
600
|
-
formData:
|
|
600
|
+
formData: et(e, t),
|
|
601
601
|
abort: (e) => {
|
|
602
|
-
i = !0, a = e,
|
|
602
|
+
i = !0, a = e, M.warn("Pipeline aborted.", { reason: e });
|
|
603
603
|
},
|
|
604
604
|
isAborted: () => i,
|
|
605
605
|
abortReason: () => a
|
|
@@ -648,68 +648,68 @@ async function tt(e, t, n, r = {}) {
|
|
|
648
648
|
screen: async () => null,
|
|
649
649
|
authorize: async () => null,
|
|
650
650
|
dispatch: async (e) => {
|
|
651
|
-
e.formData =
|
|
652
|
-
let t = await
|
|
651
|
+
e.formData = et(e.form, e.action);
|
|
652
|
+
let t = await We(e.form, e.formData);
|
|
653
653
|
return o = t, t;
|
|
654
654
|
},
|
|
655
655
|
finalize: async (e) => (o && o.ok && o.redirect?.url && (o.redirect.target === "new-tab" ? window.open(o.redirect.url, "_blank") : window.location.href = o.redirect.url), null)
|
|
656
656
|
};
|
|
657
657
|
{
|
|
658
658
|
let e = await n.emitSafe("formie:submit:before", c);
|
|
659
|
-
e.failed.length > 0 &&
|
|
659
|
+
e.failed.length > 0 && M.warn("Submit before listeners failed.", {
|
|
660
660
|
eventName: e.eventName,
|
|
661
661
|
failed: e.failed.length
|
|
662
662
|
});
|
|
663
663
|
}
|
|
664
664
|
if (s) {
|
|
665
665
|
let e = await n.emitSafe("formie:submit:final:before", c);
|
|
666
|
-
e.failed.length > 0 &&
|
|
666
|
+
e.failed.length > 0 && M.warn("Final submit before listeners failed.", {
|
|
667
667
|
eventName: e.eventName,
|
|
668
668
|
failed: e.failed.length
|
|
669
669
|
});
|
|
670
670
|
}
|
|
671
|
-
let u = r.preflightOnly ?
|
|
671
|
+
let u = r.preflightOnly ? Ke : Ge;
|
|
672
672
|
for (let e of u) {
|
|
673
|
-
if (
|
|
673
|
+
if (M.log("Stage start.", {
|
|
674
674
|
stage: e,
|
|
675
675
|
action: t
|
|
676
|
-
}), i) return
|
|
676
|
+
}), i) return M.warn("Stage skipped due to abort.", {
|
|
677
677
|
stage: e,
|
|
678
678
|
reason: a
|
|
679
|
-
}),
|
|
679
|
+
}), qe(e, a);
|
|
680
680
|
{
|
|
681
681
|
let t = await n.emitSafe(`formie:stage:${e}:before`, {
|
|
682
682
|
...c,
|
|
683
683
|
stage: e
|
|
684
684
|
});
|
|
685
|
-
t.failed.length > 0 &&
|
|
685
|
+
t.failed.length > 0 && M.warn("Stage before listeners failed.", {
|
|
686
686
|
stage: e,
|
|
687
687
|
failed: t.failed.length
|
|
688
688
|
});
|
|
689
689
|
}
|
|
690
690
|
if (i) {
|
|
691
|
-
let t =
|
|
691
|
+
let t = qe(e, a);
|
|
692
692
|
{
|
|
693
693
|
let r = await n.emitSafe("formie:submit:after", t);
|
|
694
|
-
r.failed.length > 0 &&
|
|
694
|
+
r.failed.length > 0 && M.warn("Submit after listeners failed (abort before stage).", {
|
|
695
695
|
stage: e,
|
|
696
696
|
failed: r.failed.length
|
|
697
697
|
});
|
|
698
698
|
}
|
|
699
699
|
if (s) {
|
|
700
700
|
let r = await n.emitSafe("formie:submit:final:after", t);
|
|
701
|
-
r.failed.length > 0 &&
|
|
701
|
+
r.failed.length > 0 && M.warn("Final submit after listeners failed (abort before stage).", {
|
|
702
702
|
stage: e,
|
|
703
703
|
failed: r.failed.length
|
|
704
704
|
});
|
|
705
705
|
}
|
|
706
|
-
return
|
|
706
|
+
return M.warn("Aborted after stage before-hooks.", {
|
|
707
707
|
stage: e,
|
|
708
708
|
reason: a
|
|
709
709
|
}), t;
|
|
710
710
|
}
|
|
711
711
|
let r = await l[e](c);
|
|
712
|
-
|
|
712
|
+
M.log("Stage runner complete.", {
|
|
713
713
|
stage: e,
|
|
714
714
|
hasResult: !!r,
|
|
715
715
|
ok: r ? r.ok : void 0,
|
|
@@ -721,28 +721,28 @@ async function tt(e, t, n, r = {}) {
|
|
|
721
721
|
stage: e,
|
|
722
722
|
result: r
|
|
723
723
|
});
|
|
724
|
-
t.failed.length > 0 &&
|
|
724
|
+
t.failed.length > 0 && M.warn("Stage after listeners failed.", {
|
|
725
725
|
stage: e,
|
|
726
726
|
failed: t.failed.length
|
|
727
727
|
});
|
|
728
728
|
}
|
|
729
729
|
if (i) {
|
|
730
|
-
let t =
|
|
730
|
+
let t = qe(e, a);
|
|
731
731
|
{
|
|
732
732
|
let r = await n.emitSafe("formie:submit:after", t);
|
|
733
|
-
r.failed.length > 0 &&
|
|
733
|
+
r.failed.length > 0 && M.warn("Submit after listeners failed (abort after stage).", {
|
|
734
734
|
stage: e,
|
|
735
735
|
failed: r.failed.length
|
|
736
736
|
});
|
|
737
737
|
}
|
|
738
738
|
if (s) {
|
|
739
739
|
let r = await n.emitSafe("formie:submit:final:after", t);
|
|
740
|
-
r.failed.length > 0 &&
|
|
740
|
+
r.failed.length > 0 && M.warn("Final submit after listeners failed (abort after stage).", {
|
|
741
741
|
stage: e,
|
|
742
742
|
failed: r.failed.length
|
|
743
743
|
});
|
|
744
744
|
}
|
|
745
|
-
return
|
|
745
|
+
return M.warn("Aborted after stage after-hooks.", {
|
|
746
746
|
stage: e,
|
|
747
747
|
reason: a
|
|
748
748
|
}), t;
|
|
@@ -750,19 +750,19 @@ async function tt(e, t, n, r = {}) {
|
|
|
750
750
|
if (r && !r.ok) {
|
|
751
751
|
{
|
|
752
752
|
let t = await n.emitSafe("formie:submit:after", r);
|
|
753
|
-
t.failed.length > 0 &&
|
|
753
|
+
t.failed.length > 0 && M.warn("Submit after listeners failed (failed stage).", {
|
|
754
754
|
stage: e,
|
|
755
755
|
failed: t.failed.length
|
|
756
756
|
});
|
|
757
757
|
}
|
|
758
758
|
if (s) {
|
|
759
759
|
let t = await n.emitSafe("formie:submit:final:after", r);
|
|
760
|
-
t.failed.length > 0 &&
|
|
760
|
+
t.failed.length > 0 && M.warn("Final submit after listeners failed (failed stage).", {
|
|
761
761
|
stage: e,
|
|
762
762
|
failed: t.failed.length
|
|
763
763
|
});
|
|
764
764
|
}
|
|
765
|
-
return
|
|
765
|
+
return M.warn("Pipeline short-circuited by failed stage.", {
|
|
766
766
|
stage: e,
|
|
767
767
|
code: r.code,
|
|
768
768
|
message: r.message
|
|
@@ -776,13 +776,13 @@ async function tt(e, t, n, r = {}) {
|
|
|
776
776
|
};
|
|
777
777
|
{
|
|
778
778
|
let e = await n.emitSafe("formie:submit:after", d);
|
|
779
|
-
e.failed.length > 0 &&
|
|
779
|
+
e.failed.length > 0 && M.warn("Submit after listeners failed (success).", { failed: e.failed.length });
|
|
780
780
|
}
|
|
781
781
|
if (s) {
|
|
782
782
|
let e = await n.emitSafe("formie:submit:final:after", d);
|
|
783
|
-
e.failed.length > 0 &&
|
|
783
|
+
e.failed.length > 0 && M.warn("Final submit after listeners failed (success).", { failed: e.failed.length });
|
|
784
784
|
}
|
|
785
|
-
return
|
|
785
|
+
return M.log("Pipeline completed.", {
|
|
786
786
|
ok: d.ok,
|
|
787
787
|
stage: d.stage,
|
|
788
788
|
code: d.code
|
|
@@ -790,27 +790,27 @@ async function tt(e, t, n, r = {}) {
|
|
|
790
790
|
}
|
|
791
791
|
//#endregion
|
|
792
792
|
//#region src/js/core/field-error-container.ts
|
|
793
|
-
function
|
|
793
|
+
function rt(e) {
|
|
794
794
|
return e.querySelector("[data-formie-field-layout]")?.getAttribute("data-formie-error-position")?.trim() === "above" ? "above" : "below";
|
|
795
795
|
}
|
|
796
|
-
function
|
|
796
|
+
function it(e, t) {
|
|
797
797
|
let n = e.querySelector("[data-formie-field-errors]");
|
|
798
798
|
if (n) return n;
|
|
799
|
-
let r = e.querySelector("[data-formie-field-content]"), i = e.querySelector("[data-formie-field-control]"), a =
|
|
799
|
+
let r = e.querySelector("[data-formie-field-content]"), i = e.querySelector("[data-formie-field-control]"), a = rt(e), o = document.createElement("div");
|
|
800
800
|
return o.setAttribute("data-formie-field-errors", "true"), t?.(o), r && i ? a === "above" ? r.insertBefore(o, i) : r.appendChild(o) : e.appendChild(o), o;
|
|
801
801
|
}
|
|
802
802
|
//#endregion
|
|
803
803
|
//#region src/js/validation/rules/email.ts
|
|
804
|
-
var
|
|
804
|
+
var at = {
|
|
805
805
|
rule: ({ input: e, getRule: t }) => !t("email") || !e.value || e.value.length < 1 ? !0 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.value),
|
|
806
806
|
message: ({ input: e, label: t, t: n }) => e.getAttribute("data-formie-validation-email-message") ?? e.getAttribute("data-formie-pattern-email-message") ?? e.getAttribute("data-pattern-email-message") ?? n("{label} is not a valid email address.", { label: t })
|
|
807
807
|
};
|
|
808
808
|
//#endregion
|
|
809
809
|
//#region src/js/validation/rules/shared.ts
|
|
810
|
-
function
|
|
810
|
+
function ot(e) {
|
|
811
811
|
return e?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() || "";
|
|
812
812
|
}
|
|
813
|
-
function
|
|
813
|
+
function st(e) {
|
|
814
814
|
let t = e.getRule("match");
|
|
815
815
|
if (!t || t === !0 || typeof t != "object" || !e.field) return null;
|
|
816
816
|
let n = typeof t.fieldHandle == "string" ? t.fieldHandle.trim() : "";
|
|
@@ -820,7 +820,7 @@ function ot(e) {
|
|
|
820
820
|
}
|
|
821
821
|
//#endregion
|
|
822
822
|
//#region src/js/validation/rules.ts
|
|
823
|
-
var
|
|
823
|
+
var ct = {
|
|
824
824
|
required: {
|
|
825
825
|
rule: ({ input: e, getRule: t }) => {
|
|
826
826
|
if (!t("required") || e.type === "hidden") return !0;
|
|
@@ -832,7 +832,7 @@ var st = {
|
|
|
832
832
|
},
|
|
833
833
|
message: ({ input: e, label: t, t: n }) => e.getAttribute("data-formie-required-message") ?? e.getAttribute("data-required-message") ?? n("{label} cannot be blank.", { label: t })
|
|
834
834
|
},
|
|
835
|
-
email:
|
|
835
|
+
email: at,
|
|
836
836
|
url: {
|
|
837
837
|
rule: ({ input: e, getRule: t }) => {
|
|
838
838
|
if (!t("url") || !e.value || e.value.length < 1) return !0;
|
|
@@ -873,18 +873,18 @@ var st = {
|
|
|
873
873
|
},
|
|
874
874
|
match: {
|
|
875
875
|
rule: (e) => {
|
|
876
|
-
let t =
|
|
876
|
+
let t = st(e);
|
|
877
877
|
return t ? t.value === e.input.value : !0;
|
|
878
878
|
},
|
|
879
879
|
message: (e) => {
|
|
880
|
-
let t =
|
|
880
|
+
let t = st(e)?.closest("[data-formie-field-handle]"), n = ot(t);
|
|
881
881
|
return e.t("{label} must match {value}.", {
|
|
882
882
|
label: e.label,
|
|
883
883
|
value: n
|
|
884
884
|
});
|
|
885
885
|
}
|
|
886
886
|
}
|
|
887
|
-
},
|
|
887
|
+
}, lt = {
|
|
888
888
|
email: /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*(\.\w{2,})+$/,
|
|
889
889
|
url: /^(?:(?:https?|HTTPS?|ftp|FTP):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)(?:\.(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)*(?:\.(?:[a-zA-Z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/,
|
|
890
890
|
number: /^(?:[-+]?[0-9]*[.,]?[0-9]+)$/,
|
|
@@ -892,11 +892,11 @@ var st = {
|
|
|
892
892
|
date: /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))/,
|
|
893
893
|
time: /^(?:(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]))$/,
|
|
894
894
|
month: /^(?:(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])))$/
|
|
895
|
-
},
|
|
896
|
-
function
|
|
895
|
+
}, N = S("general", "validator");
|
|
896
|
+
function P(e) {
|
|
897
897
|
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement);
|
|
898
898
|
}
|
|
899
|
-
function
|
|
899
|
+
function ut(e, t) {
|
|
900
900
|
let n = (e.getAttribute("aria-describedby") || "").trim();
|
|
901
901
|
if (!n) return;
|
|
902
902
|
let r = n.split(/\s+/).filter((e) => e !== t);
|
|
@@ -906,17 +906,17 @@ function lt(e, t) {
|
|
|
906
906
|
}
|
|
907
907
|
e.removeAttribute("aria-describedby");
|
|
908
908
|
}
|
|
909
|
-
function
|
|
909
|
+
function dt(e, t) {
|
|
910
910
|
let n = (e.getAttribute("aria-describedby") || "").trim(), r = n ? n.split(/\s+/) : [];
|
|
911
911
|
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
912
912
|
}
|
|
913
|
-
function
|
|
913
|
+
function ft(e, t) {
|
|
914
914
|
e.setAttribute("aria-errormessage", t);
|
|
915
915
|
}
|
|
916
|
-
function
|
|
916
|
+
function pt(e, t) {
|
|
917
917
|
e.getAttribute("aria-errormessage") === t && e.removeAttribute("aria-errormessage");
|
|
918
918
|
}
|
|
919
|
-
var
|
|
919
|
+
var mt = class {
|
|
920
920
|
constructor(e, t = {}) {
|
|
921
921
|
this.errors = [], this.validators = {}, this.boundListeners = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.submitted = !1, this.initialValues = /* @__PURE__ */ new WeakMap(), this.form = e, this.onBlur = this.blurHandler.bind(this), this.onChange = this.changeHandler.bind(this), this.onInput = this.inputHandler.bind(this), this.config = {
|
|
922
922
|
live: !1,
|
|
@@ -927,14 +927,14 @@ var pt = class {
|
|
|
927
927
|
messagesClass: [],
|
|
928
928
|
messageClass: [],
|
|
929
929
|
fieldsSelector: "input:not([type=\"hidden\"]):not([type=\"submit\"]):not([type=\"button\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])",
|
|
930
|
-
patterns:
|
|
930
|
+
patterns: lt,
|
|
931
931
|
...t
|
|
932
|
-
}, Object.entries(
|
|
932
|
+
}, Object.entries(ct).forEach(([e, t]) => {
|
|
933
933
|
this.addValidator(e, t.rule, t.message);
|
|
934
934
|
}), this.init();
|
|
935
935
|
}
|
|
936
936
|
init() {
|
|
937
|
-
|
|
937
|
+
N.log("Initializing validator.", {
|
|
938
938
|
formId: this.form.id || null,
|
|
939
939
|
live: this.config.live
|
|
940
940
|
}), this.form.setAttribute("novalidate", "true"), this.inputs().forEach((e) => {
|
|
@@ -942,9 +942,9 @@ var pt = class {
|
|
|
942
942
|
}), this.config.live && this.addEventListeners(), this.emitEvent(document, n("ready"), { validator: this });
|
|
943
943
|
}
|
|
944
944
|
inputs(e = null) {
|
|
945
|
-
if (
|
|
945
|
+
if (P(e)) return [e];
|
|
946
946
|
let t = e || this.form;
|
|
947
|
-
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) =>
|
|
947
|
+
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) => P(e));
|
|
948
948
|
}
|
|
949
949
|
getInputValue(e) {
|
|
950
950
|
return e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ? e.checked : e instanceof HTMLInputElement && e.type === "file" ? e.files?.length ? Array.from(e.files).map((e) => e.name).join("|") : "" : e.value ?? "";
|
|
@@ -984,7 +984,7 @@ var pt = class {
|
|
|
984
984
|
}), r = !0;
|
|
985
985
|
}
|
|
986
986
|
}), !r && this.shouldShowError(e) && this.removeError(e);
|
|
987
|
-
}),
|
|
987
|
+
}), N.log("Validation pass complete.", {
|
|
988
988
|
errorCount: this.errors.length,
|
|
989
989
|
includeHiddenPages: t.includeHiddenPages === !0
|
|
990
990
|
}), this.errors;
|
|
@@ -1005,9 +1005,9 @@ var pt = class {
|
|
|
1005
1005
|
e.remove();
|
|
1006
1006
|
}), r && (r.innerHTML = ""), t.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
1007
1007
|
let n = e;
|
|
1008
|
-
n.removeAttribute("aria-invalid"), this.config.inputErrorClass.length && n.classList.remove(...this.config.inputErrorClass), n.removeAttribute("data-formie-input-has-error"), i &&
|
|
1008
|
+
n.removeAttribute("aria-invalid"), this.config.inputErrorClass.length && n.classList.remove(...this.config.inputErrorClass), n.removeAttribute("data-formie-input-has-error"), i && ut(n, i), t.querySelectorAll("[data-formie-field-error]").forEach((e) => {
|
|
1009
1009
|
let t = e.id;
|
|
1010
|
-
t &&
|
|
1010
|
+
t && pt(n, t);
|
|
1011
1011
|
});
|
|
1012
1012
|
});
|
|
1013
1013
|
for (let e = t; e; e = e.parentElement?.closest("[data-formie-field-handle]")) this.config.fieldContainerErrorClass.length && e.classList.remove(...this.config.fieldContainerErrorClass), e.removeAttribute("data-formie-field-has-error");
|
|
@@ -1017,15 +1017,15 @@ var pt = class {
|
|
|
1017
1017
|
let i = e.closest("[data-formie-field-handle]");
|
|
1018
1018
|
if (!i) return;
|
|
1019
1019
|
let a = i.querySelector("[data-formie-field-errors]");
|
|
1020
|
-
a ||=
|
|
1020
|
+
a ||= it(i, (e) => {
|
|
1021
1021
|
this.config.messagesClass.length && e.classList.add(...this.config.messagesClass);
|
|
1022
1022
|
}), this.config.messagesClass.length && a.classList.add(...this.config.messagesClass), a.innerHTML = "";
|
|
1023
1023
|
let o = i.getAttribute("data-formie-field-handle") || "field", s = `${o}-error`;
|
|
1024
|
-
a.id = a.id || `${o}-errors`,
|
|
1024
|
+
a.id = a.id || `${o}-errors`, Oe(a, Ee(this.config.errorAriaLive, this.submitted));
|
|
1025
1025
|
let c = document.createElement("div");
|
|
1026
1026
|
c.setAttribute("data-formie-field-error", "true"), c.setAttribute(`data-formie-field-error-${t}`, "true"), c.setAttribute("id", s), c.setAttribute("role", "alert"), this.config.messageClass.length && c.classList.add(...this.config.messageClass), c.textContent = r, a.appendChild(c), i.setAttribute("data-formie-field-has-error", "true"), i.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
1027
1027
|
let t = e;
|
|
1028
|
-
t.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && t.classList.add(...this.config.inputErrorClass), t.setAttribute("data-formie-input-has-error", "true"),
|
|
1028
|
+
t.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && t.classList.add(...this.config.inputErrorClass), t.setAttribute("data-formie-input-has-error", "true"), dt(t, a.id), ft(t, s);
|
|
1029
1029
|
});
|
|
1030
1030
|
for (let e = i; e; e = e.parentElement?.closest("[data-formie-field-handle]")) this.config.fieldContainerErrorClass.length && e.classList.add(...this.config.fieldContainerErrorClass), e.setAttribute("data-formie-field-has-error", "true");
|
|
1031
1031
|
this.emitEvent(e, n("show-error"), {
|
|
@@ -1037,7 +1037,7 @@ var pt = class {
|
|
|
1037
1037
|
getValidatorCallbackOptions(e) {
|
|
1038
1038
|
let t = e.closest("[data-formie-field-handle]"), n = t?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() ?? "", r = this.parseValidationRules(t?.getAttribute("data-formie-validation"));
|
|
1039
1039
|
return {
|
|
1040
|
-
t:
|
|
1040
|
+
t: D,
|
|
1041
1041
|
input: e,
|
|
1042
1042
|
label: n,
|
|
1043
1043
|
field: t,
|
|
@@ -1048,7 +1048,7 @@ var pt = class {
|
|
|
1048
1048
|
};
|
|
1049
1049
|
}
|
|
1050
1050
|
getErrorMessage(e, t, n, r) {
|
|
1051
|
-
return (typeof n.errorMessage == "function" ? n.errorMessage(r) : n.errorMessage) ??
|
|
1051
|
+
return (typeof n.errorMessage == "function" ? n.errorMessage(r) : n.errorMessage) ?? D("{label} is invalid.", { label: r.label });
|
|
1052
1052
|
}
|
|
1053
1053
|
getErrors() {
|
|
1054
1054
|
return this.errors;
|
|
@@ -1071,7 +1071,7 @@ var pt = class {
|
|
|
1071
1071
|
try {
|
|
1072
1072
|
n = JSON.parse(e);
|
|
1073
1073
|
} catch {
|
|
1074
|
-
return
|
|
1074
|
+
return N.warn("Invalid validation rules payload.", { formId: this.form.id || null }), t;
|
|
1075
1075
|
}
|
|
1076
1076
|
return Array.isArray(n) && n.forEach((e) => {
|
|
1077
1077
|
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
@@ -1080,16 +1080,16 @@ var pt = class {
|
|
|
1080
1080
|
}), t;
|
|
1081
1081
|
}
|
|
1082
1082
|
destroy() {
|
|
1083
|
-
|
|
1083
|
+
N.log("Destroying validator.", { formId: this.form.id || null }), this.removeEventListeners(), this.form.removeAttribute("novalidate"), this.emitEvent(document, n("destroy"), { validator: this });
|
|
1084
1084
|
}
|
|
1085
1085
|
isVisible(e, t = {}) {
|
|
1086
1086
|
return e.disabled || e.hasAttribute("data-formie-conditions-disabled") || e.closest("[data-formie-conditions-disabled]") || e.closest("[data-formie-conditionally-hidden]") ? !1 : e.closest("[data-formie-page-hidden]") ? !!t.includeHiddenPages : !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
1087
1087
|
}
|
|
1088
1088
|
blurHandler(e) {
|
|
1089
|
-
!(e.target instanceof HTMLElement) || !
|
|
1089
|
+
!(e.target instanceof HTMLElement) || !P(e.target) || !e.target.form?.isSameNode(this.form) || e instanceof CustomEvent || e.target instanceof HTMLInputElement && e.target.type === "file" || e.target instanceof HTMLInputElement && (e.target.type === "checkbox" || e.target.type === "radio") || (this.isDirty(e.target) && this.activated.add(e.target), this.shouldShowError(e.target) && this.validate(e.target));
|
|
1090
1090
|
}
|
|
1091
1091
|
changeHandler(e) {
|
|
1092
|
-
if (!(!(e.target instanceof HTMLElement) || !
|
|
1092
|
+
if (!(!(e.target instanceof HTMLElement) || !P(e.target) || !e.target.form?.isSameNode(this.form)) && !(e instanceof CustomEvent)) {
|
|
1093
1093
|
if (e.target instanceof HTMLSelectElement) {
|
|
1094
1094
|
this.activated.add(e.target), this.validate(e.target);
|
|
1095
1095
|
return;
|
|
@@ -1098,19 +1098,19 @@ var pt = class {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
}
|
|
1100
1100
|
inputHandler(e) {
|
|
1101
|
-
!(e.target instanceof HTMLElement) || !
|
|
1101
|
+
!(e.target instanceof HTMLElement) || !P(e.target) || !e.target.form?.isSameNode(this.form) || e instanceof CustomEvent || e.target instanceof HTMLInputElement && (e.target.type === "checkbox" || e.target.type === "radio") || this.shouldShowError(e.target) && this.validate(e.target);
|
|
1102
1102
|
}
|
|
1103
1103
|
submit(e = null, { final: t = !1 } = {}) {
|
|
1104
|
-
return this.submitted = !0,
|
|
1104
|
+
return this.submitted = !0, N.log("Submit validation requested.", { final: t }), this.boundListeners || this.addEventListeners(), this.removeAllErrors(), this.validate(e, { includeHiddenPages: t });
|
|
1105
1105
|
}
|
|
1106
1106
|
resetLiveState() {
|
|
1107
1107
|
this.submitted = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.errors = [], this.removeAllErrors();
|
|
1108
1108
|
}
|
|
1109
1109
|
addEventListeners() {
|
|
1110
|
-
this.boundListeners || (this.form.addEventListener("blur", this.onBlur, !0), this.form.addEventListener("change", this.onChange, !1), this.form.addEventListener("input", this.onInput, !1), this.boundListeners = !0,
|
|
1110
|
+
this.boundListeners || (this.form.addEventListener("blur", this.onBlur, !0), this.form.addEventListener("change", this.onChange, !1), this.form.addEventListener("input", this.onInput, !1), this.boundListeners = !0, N.log("Event listeners attached."));
|
|
1111
1111
|
}
|
|
1112
1112
|
removeEventListeners() {
|
|
1113
|
-
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1,
|
|
1113
|
+
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1, N.log("Event listeners removed.");
|
|
1114
1114
|
}
|
|
1115
1115
|
emitEvent(e, t, n = {}) {
|
|
1116
1116
|
e.dispatchEvent(new CustomEvent(t, {
|
|
@@ -1127,62 +1127,62 @@ var pt = class {
|
|
|
1127
1127
|
removeValidator(e) {
|
|
1128
1128
|
delete this.validators[e];
|
|
1129
1129
|
}
|
|
1130
|
-
},
|
|
1131
|
-
function
|
|
1130
|
+
}, F = /* @__PURE__ */ new WeakMap();
|
|
1131
|
+
function ht(e) {
|
|
1132
1132
|
return (e.dataset.formieSubmitAction || "").trim();
|
|
1133
1133
|
}
|
|
1134
|
-
function
|
|
1134
|
+
function gt(e) {
|
|
1135
1135
|
return (e.dataset.formieErrorMessagePosition || "top-form").trim() || "top-form";
|
|
1136
1136
|
}
|
|
1137
|
-
function
|
|
1137
|
+
function _t(e) {
|
|
1138
1138
|
return (e.dataset.formieSubmitActionMessagePosition || "").trim();
|
|
1139
1139
|
}
|
|
1140
|
-
function
|
|
1140
|
+
function vt(e) {
|
|
1141
1141
|
let t = (e.dataset.formieSubmitActionMessageTimeout || "").trim();
|
|
1142
1142
|
if (!t) return null;
|
|
1143
1143
|
let n = Number.parseFloat(t);
|
|
1144
1144
|
return !Number.isFinite(n) || n < 0 ? null : Math.round(n * 1e3);
|
|
1145
1145
|
}
|
|
1146
|
-
function
|
|
1146
|
+
function yt(e) {
|
|
1147
1147
|
let t = e.dataset.formieSubmitActionFormHide;
|
|
1148
1148
|
if (t === void 0) return !1;
|
|
1149
1149
|
let n = t.trim().toLowerCase();
|
|
1150
1150
|
return n === "true" || n === "1" || n === "";
|
|
1151
1151
|
}
|
|
1152
|
-
function yt(e) {
|
|
1153
|
-
let t = I.get(e);
|
|
1154
|
-
typeof t == "number" && (window.clearTimeout(t), I.delete(e));
|
|
1155
|
-
}
|
|
1156
1152
|
function bt(e) {
|
|
1157
|
-
|
|
1153
|
+
let t = F.get(e);
|
|
1154
|
+
typeof t == "number" && (window.clearTimeout(t), F.delete(e));
|
|
1158
1155
|
}
|
|
1159
1156
|
function xt(e) {
|
|
1160
|
-
return e.querySelector("[data-formie-form-messages-
|
|
1157
|
+
return e.querySelector("[data-formie-form-messages-top]") || e;
|
|
1161
1158
|
}
|
|
1162
|
-
function St(e
|
|
1163
|
-
return
|
|
1159
|
+
function St(e) {
|
|
1160
|
+
return e.querySelector("[data-formie-form-messages-bottom]") || e;
|
|
1164
1161
|
}
|
|
1165
1162
|
function Ct(e, t) {
|
|
1166
|
-
return t === "
|
|
1163
|
+
return t === "bottom-form" ? St(e) : xt(e);
|
|
1167
1164
|
}
|
|
1168
|
-
function wt(e) {
|
|
1169
|
-
|
|
1170
|
-
return r || (r = document.createElement("div"), r.setAttribute("data-formie-errors", "true"), T(r, e, "errors")), r.setAttribute("data-formie-error-container", "true"), t === "bottom-form" ? n.append(r) : n.prepend(r), r;
|
|
1165
|
+
function wt(e, t) {
|
|
1166
|
+
return t === "top-form" ? xt(e) : t === "bottom-form" && !yt(e) ? St(e) : e;
|
|
1171
1167
|
}
|
|
1172
|
-
function Tt(e
|
|
1173
|
-
let n = t.querySelector("[data-formie-error-
|
|
1174
|
-
return
|
|
1168
|
+
function Tt(e) {
|
|
1169
|
+
let t = gt(e), n = Ct(e, t), r = n.querySelector("[data-formie-error-container], [data-formie-errors]");
|
|
1170
|
+
return r || (r = document.createElement("div"), r.setAttribute("data-formie-errors", "true"), w(r, e, "errors")), r.setAttribute("data-formie-error-container", "true"), t === "bottom-form" ? n.append(r) : n.prepend(r), r;
|
|
1175
1171
|
}
|
|
1176
1172
|
function Et(e, t) {
|
|
1177
|
-
let n =
|
|
1178
|
-
return n || (n = document.createElement("div"), n.setAttribute("data-formie-
|
|
1173
|
+
let n = t.querySelector("[data-formie-error-message-container], [data-formie-message][data-formie-message-error]");
|
|
1174
|
+
return n || (n = document.createElement("div"), n.setAttribute("data-formie-error-message-container", "true"), t.appendChild(n)), n.setAttribute("data-formie-message", "true"), n.setAttribute("data-formie-message-error", "true"), w(n, e, "message", "messageError"), n.setAttribute("role", "alert"), Oe(n, De(Te(e))), n;
|
|
1175
|
+
}
|
|
1176
|
+
function Dt(e, t) {
|
|
1177
|
+
let n = e.querySelector("[data-formie-success-container]"), r = wt(e, t);
|
|
1178
|
+
return n || (n = document.createElement("div"), n.setAttribute("data-formie-success-container", "true"), w(n, e, "successes")), t === "bottom-form" ? r.append(n) : r.prepend(n), n;
|
|
1179
1179
|
}
|
|
1180
|
-
function
|
|
1181
|
-
return
|
|
1182
|
-
|
|
1180
|
+
function Ot(e) {
|
|
1181
|
+
return it(e, (t) => {
|
|
1182
|
+
w(t, e, "fieldErrors");
|
|
1183
1183
|
});
|
|
1184
1184
|
}
|
|
1185
|
-
function
|
|
1185
|
+
function kt(e, t) {
|
|
1186
1186
|
let n = (e.getAttribute("aria-describedby") || "").trim();
|
|
1187
1187
|
if (!n) return;
|
|
1188
1188
|
let r = n.split(/\s+/).filter((e) => e !== t).join(" ").trim();
|
|
@@ -1192,118 +1192,136 @@ function Ot(e, t) {
|
|
|
1192
1192
|
}
|
|
1193
1193
|
e.removeAttribute("aria-describedby");
|
|
1194
1194
|
}
|
|
1195
|
-
function
|
|
1195
|
+
function At(e, t) {
|
|
1196
1196
|
e.setAttribute("aria-errormessage", t);
|
|
1197
1197
|
}
|
|
1198
|
-
function
|
|
1198
|
+
function jt(e, t) {
|
|
1199
1199
|
e.getAttribute("aria-errormessage") === t && e.removeAttribute("aria-errormessage");
|
|
1200
1200
|
}
|
|
1201
|
-
function
|
|
1201
|
+
function Mt(e) {
|
|
1202
1202
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
1203
1203
|
let n = t, r = n.querySelector("[data-formie-field-errors]"), i = r?.id || "", a = Array.from(n.querySelectorAll("[data-formie-field-error]")).map((e) => e.id).filter(Boolean);
|
|
1204
|
-
|
|
1204
|
+
C(n, e, "fieldLayoutError"), n.removeAttribute("data-formie-field-has-error"), n.querySelectorAll("[data-formie-field-error]").forEach((e) => {
|
|
1205
1205
|
e.remove();
|
|
1206
1206
|
}), r && !r.querySelector("[data-formie-field-error]") && (r.innerHTML = ""), n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
1207
1207
|
let n = t;
|
|
1208
|
-
n.removeAttribute("aria-invalid"),
|
|
1209
|
-
|
|
1208
|
+
n.removeAttribute("aria-invalid"), C(n, e, "fieldControlError"), n.removeAttribute("data-formie-input-has-error"), i && kt(n, i), a.forEach((e) => {
|
|
1209
|
+
jt(n, e);
|
|
1210
1210
|
});
|
|
1211
1211
|
});
|
|
1212
1212
|
}), y(e);
|
|
1213
1213
|
}
|
|
1214
|
-
function
|
|
1214
|
+
function Nt(e) {
|
|
1215
1215
|
e.querySelectorAll("[data-formie-error-container], [data-formie-errors]").forEach((t) => {
|
|
1216
1216
|
let n = t;
|
|
1217
1217
|
n.querySelectorAll("[data-formie-error]").forEach((e) => {
|
|
1218
1218
|
e.remove();
|
|
1219
|
-
}),
|
|
1219
|
+
}), C(n, e, "message", "messageError"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-error"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-error]") || (n.innerHTML = "");
|
|
1220
1220
|
});
|
|
1221
1221
|
}
|
|
1222
|
-
function
|
|
1223
|
-
|
|
1222
|
+
function Pt(e) {
|
|
1223
|
+
bt(e), e.querySelectorAll("[data-formie-message-success]:not([data-formie-success-container])").forEach((e) => {
|
|
1224
1224
|
e.remove();
|
|
1225
1225
|
}), e.querySelectorAll("[data-formie-success-container]").forEach((t) => {
|
|
1226
1226
|
let n = t;
|
|
1227
1227
|
n.querySelectorAll("[data-formie-success]").forEach((e) => {
|
|
1228
1228
|
e.remove();
|
|
1229
|
-
}),
|
|
1230
|
-
}),
|
|
1229
|
+
}), C(n, e, "message", "messageSuccess"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-success"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-success]") || (n.innerHTML = "");
|
|
1230
|
+
}), ht(e) === "message" && yt(e) || s(e, !1);
|
|
1231
1231
|
}
|
|
1232
|
-
function
|
|
1232
|
+
function Ft(e) {
|
|
1233
1233
|
e.querySelectorAll("[aria-invalid=\"true\"]").forEach((e) => {
|
|
1234
1234
|
e.removeAttribute("aria-invalid");
|
|
1235
1235
|
});
|
|
1236
1236
|
}
|
|
1237
|
-
function
|
|
1237
|
+
function It(e, t) {
|
|
1238
1238
|
let n = (e.getAttribute("aria-describedby") || "").trim(), r = n ? n.split(/\s+/) : [];
|
|
1239
1239
|
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
1240
1240
|
}
|
|
1241
|
-
function
|
|
1242
|
-
let n =
|
|
1241
|
+
function Lt(e, t) {
|
|
1242
|
+
let n = De(Te(e));
|
|
1243
1243
|
Object.entries(t).forEach(([t, r]) => {
|
|
1244
1244
|
let i = e.querySelector(`[data-formie-field-handle="${t}"]`);
|
|
1245
1245
|
if (!i) return;
|
|
1246
|
-
let a =
|
|
1247
|
-
a.id = o,
|
|
1246
|
+
let a = Ot(i), o = a.id && a.id.trim() ? a.id : `${t}-errors`;
|
|
1247
|
+
a.id = o, Oe(a, n), w(i, e, "fieldLayoutError"), i.setAttribute("data-formie-field-has-error", "true"), r.forEach((t, n) => {
|
|
1248
1248
|
let r = document.createElement("div");
|
|
1249
|
-
r.setAttribute("data-formie-field-error", "true"), r.setAttribute("role", "alert"), r.id = `${o}-${n + 1}`,
|
|
1249
|
+
r.setAttribute("data-formie-field-error", "true"), r.setAttribute("role", "alert"), r.id = `${o}-${n + 1}`, w(r, e, "fieldError"), r.textContent = t, a.appendChild(r);
|
|
1250
1250
|
});
|
|
1251
1251
|
let s = a.querySelector("[data-formie-field-error]")?.id;
|
|
1252
1252
|
i.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
1253
1253
|
let n = t;
|
|
1254
|
-
n.setAttribute("aria-invalid", "true"),
|
|
1254
|
+
n.setAttribute("aria-invalid", "true"), w(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), It(n, o), s && At(n, s);
|
|
1255
1255
|
let r = i.querySelector("[data-formie-instructions]");
|
|
1256
|
-
r?.id &&
|
|
1256
|
+
r?.id && It(n, r.id);
|
|
1257
1257
|
});
|
|
1258
1258
|
}), y(e);
|
|
1259
1259
|
}
|
|
1260
|
-
function
|
|
1261
|
-
let n =
|
|
1262
|
-
|
|
1260
|
+
function Rt(e, t) {
|
|
1261
|
+
let n = Tt(e), r = Et(e, n);
|
|
1262
|
+
w(n, e, "errors"), t.forEach((t) => {
|
|
1263
1263
|
let n = document.createElement("div");
|
|
1264
|
-
n.setAttribute("data-formie-error", "true"), n.setAttribute("role", "alert"),
|
|
1264
|
+
n.setAttribute("data-formie-error", "true"), n.setAttribute("role", "alert"), w(n, e, "error"), n.innerHTML = t, r.appendChild(n);
|
|
1265
1265
|
});
|
|
1266
1266
|
}
|
|
1267
|
-
function
|
|
1268
|
-
|
|
1267
|
+
function zt(e) {
|
|
1268
|
+
if (e.ok || e.keepSubmitLoading !== !0) return !1;
|
|
1269
|
+
let t = e.meta || {}, n = String(t.paymentStatus || "");
|
|
1270
|
+
return n === "actionRequired" || n === "pending";
|
|
1271
|
+
}
|
|
1272
|
+
function Bt(e, t) {
|
|
1273
|
+
let n = Tt(e), r = Et(e, n);
|
|
1274
|
+
w(n, e, "errors");
|
|
1275
|
+
let i = document.createElement("div");
|
|
1276
|
+
i.setAttribute("data-formie-notice", "true"), i.setAttribute("role", "status"), w(i, e, "message"), i.textContent = t, r.appendChild(i);
|
|
1269
1277
|
}
|
|
1270
|
-
function
|
|
1271
|
-
|
|
1278
|
+
function Vt(e, t) {
|
|
1279
|
+
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" ? !0 : ht(e) === "message" && _t(e) !== "";
|
|
1280
|
+
}
|
|
1281
|
+
function Ht(e, t) {
|
|
1282
|
+
let n = _t(e);
|
|
1272
1283
|
if (!n) return;
|
|
1273
|
-
let r =
|
|
1274
|
-
|
|
1284
|
+
let r = Dt(e, n);
|
|
1285
|
+
w(r, e, "message", "messageSuccess"), r.setAttribute("data-formie-message", "true"), r.setAttribute("data-formie-message-success", "true"), r.setAttribute("role", "status"), r.setAttribute("aria-live", "polite"), r.setAttribute("aria-atomic", "true");
|
|
1275
1286
|
let i = document.createElement("div");
|
|
1276
|
-
i.setAttribute("data-formie-success", "true"),
|
|
1277
|
-
let a =
|
|
1287
|
+
i.setAttribute("data-formie-success", "true"), w(i, e, "success"), i.innerHTML = t, r.appendChild(i), yt(e) && s(e, !0);
|
|
1288
|
+
let a = vt(e);
|
|
1278
1289
|
if (a !== null) {
|
|
1279
1290
|
let t = window.setTimeout(() => {
|
|
1280
|
-
|
|
1291
|
+
F.delete(e), Pt(e);
|
|
1281
1292
|
}, a);
|
|
1282
|
-
|
|
1293
|
+
F.set(e, t);
|
|
1283
1294
|
}
|
|
1284
1295
|
}
|
|
1285
|
-
function
|
|
1286
|
-
if (
|
|
1287
|
-
|
|
1296
|
+
function I(e, t) {
|
|
1297
|
+
if (Mt(e), Nt(e), Pt(e), Ft(e), t.ok) {
|
|
1298
|
+
Vt(e, t) && Ht(e, t.message || "");
|
|
1288
1299
|
return;
|
|
1289
1300
|
}
|
|
1290
|
-
|
|
1301
|
+
if (!t.ok) {
|
|
1302
|
+
if (zt(t)) {
|
|
1303
|
+
let n = t.meta || {}, r = String(n.paymentMessage || "").trim();
|
|
1304
|
+
r && Bt(e, r);
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
t.fieldErrors && Lt(e, t.fieldErrors), t.formErrors?.length ? Rt(e, t.formErrors) : !t.fieldErrors && t.message && Rt(e, [t.message]), Fe(e);
|
|
1308
|
+
}
|
|
1291
1309
|
}
|
|
1292
1310
|
//#endregion
|
|
1293
1311
|
//#region src/js/core/submit-flow.ts
|
|
1294
|
-
var
|
|
1295
|
-
function
|
|
1312
|
+
var Ut = S("general", "submit-flow");
|
|
1313
|
+
function Wt(e) {
|
|
1296
1314
|
return !(!e.ok && e.stage === "validate");
|
|
1297
1315
|
}
|
|
1298
|
-
function
|
|
1316
|
+
function Gt(e) {
|
|
1299
1317
|
return e ? !!(e.keepSubmitLoading === !0 || e.ok && e.redirect?.url && e.redirect.target !== "new-tab") : !1;
|
|
1300
1318
|
}
|
|
1301
|
-
function
|
|
1302
|
-
|
|
1319
|
+
function Kt(e) {
|
|
1320
|
+
Mt(e), Nt(e), Pt(e), Ft(e);
|
|
1303
1321
|
}
|
|
1304
|
-
async function
|
|
1322
|
+
async function qt(e) {
|
|
1305
1323
|
let { id: t, target: n, form: r, bus: i, validator: a, validateOnSubmit: o, action: s, submitter: c, waitForSubmitDelay: l, onRefreshTokensAfterSubmit: u, dispatchSubmitResult: f } = e;
|
|
1306
|
-
|
|
1324
|
+
Kt(r), m(r, c || null);
|
|
1307
1325
|
let p = {
|
|
1308
1326
|
ok: !1,
|
|
1309
1327
|
code: "SUBMIT_ERROR",
|
|
@@ -1311,30 +1329,30 @@ async function Wt(e) {
|
|
|
1311
1329
|
formErrors: ["Submission failed."]
|
|
1312
1330
|
};
|
|
1313
1331
|
try {
|
|
1314
|
-
await l(r), p = await
|
|
1332
|
+
await l(r), p = await nt(r, s, i, {
|
|
1315
1333
|
validator: a,
|
|
1316
1334
|
validateOnSubmit: o
|
|
1317
|
-
}),
|
|
1335
|
+
}), I(r, p), f(p), g(r, p, s), Wt(p) && await u(p);
|
|
1318
1336
|
} catch (e) {
|
|
1319
1337
|
p = {
|
|
1320
1338
|
ok: !1,
|
|
1321
1339
|
code: "SUBMIT_ERROR",
|
|
1322
1340
|
message: e instanceof Error ? e.message : "Submission failed.",
|
|
1323
1341
|
formErrors: [e instanceof Error ? e.message : "Submission failed."]
|
|
1324
|
-
},
|
|
1342
|
+
}, I(r, p), f(p), Ut.warn("Submit failed with exception.", {
|
|
1325
1343
|
id: t,
|
|
1326
1344
|
action: s,
|
|
1327
1345
|
target: n,
|
|
1328
1346
|
error: e instanceof Error ? e.message : e
|
|
1329
1347
|
});
|
|
1330
1348
|
} finally {
|
|
1331
|
-
|
|
1349
|
+
Gt(p) || d(r);
|
|
1332
1350
|
}
|
|
1333
1351
|
return p;
|
|
1334
1352
|
}
|
|
1335
1353
|
//#endregion
|
|
1336
1354
|
//#region src/js/modules/registry.ts
|
|
1337
|
-
var
|
|
1355
|
+
var L = class {
|
|
1338
1356
|
constructor() {
|
|
1339
1357
|
this.modules = /* @__PURE__ */ new Map();
|
|
1340
1358
|
}
|
|
@@ -1351,12 +1369,12 @@ var R = class {
|
|
|
1351
1369
|
getAll() {
|
|
1352
1370
|
return Array.from(this.modules.values());
|
|
1353
1371
|
}
|
|
1354
|
-
},
|
|
1372
|
+
}, Jt = {
|
|
1355
1373
|
"address-finder": () => import("./chunks/address-finder-k7_BXaRe.js").then((e) => e.addressFinderModule),
|
|
1356
1374
|
"google-address": () => import("./chunks/google-address-BH3Zhi06.js").then((e) => e.googleAddressModule),
|
|
1357
1375
|
loqate: () => import("./chunks/loqate-CJPzBmSm.js").then((e) => e.loqateModule),
|
|
1358
1376
|
"place-kit": () => import("./chunks/place-kit-BGHklIZ-.js").then((e) => e.placeKitModule)
|
|
1359
|
-
},
|
|
1377
|
+
}, Yt = {
|
|
1360
1378
|
"captcha-eu": () => import("./chunks/captcha-eu-CGm8Lbrj.js").then((e) => e.captchaEuModule),
|
|
1361
1379
|
"friendly-captcha-v1": () => import("./chunks/friendly-captcha-v1-C_2reOXr.js").then((e) => e.friendlyCaptchaV1Module),
|
|
1362
1380
|
"friendly-captcha-v2": () => import("./chunks/friendly-captcha-v2-CLSAbkqx.js").then((e) => e.friendlyCaptchaV2Module),
|
|
@@ -1367,108 +1385,108 @@ var R = class {
|
|
|
1367
1385
|
"recaptcha-v3": () => import("./chunks/recaptcha-v3-No4Ykrhk.js").then((e) => e.recaptchaV3Module),
|
|
1368
1386
|
snaptcha: () => import("./chunks/snaptcha-DKx98oon.js").then((e) => e.snaptchaModule),
|
|
1369
1387
|
turnstile: () => import("./chunks/turnstile-DJakPzQD.js").then((e) => e.turnstileModule)
|
|
1370
|
-
},
|
|
1388
|
+
}, Xt = {
|
|
1371
1389
|
calculations: () => import("./chunks/calculations-CeDgB9jt.js").then((e) => e.calculationsModule),
|
|
1372
1390
|
"checkbox-radio": () => import("./chunks/checkbox-radio-DQ0H67Tj.js").then((e) => e.checkboxRadioModule),
|
|
1373
|
-
combobox: () => import("./chunks/combobox-
|
|
1391
|
+
combobox: () => import("./chunks/combobox-C0EuExSI.js").then((e) => e.comboboxModule),
|
|
1374
1392
|
conditions: () => import("./chunks/conditions-B6_nzpeE.js").then((e) => e.conditionsModule),
|
|
1375
1393
|
"custom-google-maps": () => import("./chunks/custom-google-maps-BsaSirEZ.js").then((e) => e.customGoogleMapsModule),
|
|
1376
1394
|
"custom-link": () => import("./chunks/custom-link-CJ1-FjEM.js").then((e) => e.customLinkModule),
|
|
1377
1395
|
"custom-maps": () => import("./chunks/custom-maps-DYW_pBid.js").then((e) => e.customMapsModule),
|
|
1378
1396
|
"date-picker": () => import("./chunks/date-picker-5CA_-zGb.js").then((e) => e.datePickerModule),
|
|
1379
|
-
"file-upload": () => import("./chunks/file-upload-
|
|
1380
|
-
"upload-manager": () => import("./chunks/upload-manager-
|
|
1397
|
+
"file-upload": () => import("./chunks/file-upload-rqfZNqlH.js").then((e) => e.fileUploadModule),
|
|
1398
|
+
"upload-manager": () => import("./chunks/upload-manager-W-QDgxKD.js").then((e) => e.uploadManagerModule),
|
|
1381
1399
|
hidden: () => import("./chunks/hidden-D7_Ch-QN.js").then((e) => e.hiddenModule),
|
|
1382
1400
|
"phone-country": () => import("./chunks/phone-country-D3ayr60L.js").then((e) => e.phoneCountryModule),
|
|
1383
1401
|
"address-country": () => import("./chunks/address-country-Rx6GQTND.js").then((e) => e.addressCountryModule),
|
|
1384
|
-
"address-state": () => import("./chunks/address-state-
|
|
1385
|
-
repeater: () => import("./chunks/repeater-
|
|
1386
|
-
"rich-text": () => import("./chunks/rich-text-
|
|
1402
|
+
"address-state": () => import("./chunks/address-state-BwE01m2_.js").then((e) => e.addressStateModule),
|
|
1403
|
+
repeater: () => import("./chunks/repeater-BVnPUqTj.js").then((e) => e.repeaterModule),
|
|
1404
|
+
"rich-text": () => import("./chunks/rich-text-Bg_--4TG.js").then((e) => e.richTextModule),
|
|
1387
1405
|
signature: () => import("./chunks/signature-xz4QO7CR.js").then((e) => e.signatureModule),
|
|
1388
1406
|
summary: () => import("./chunks/summary-Dks0gXS3.js").then((e) => e.summaryModule),
|
|
1389
|
-
"survey-likert": () => import("./chunks/survey-likert-
|
|
1390
|
-
"survey-rank": () => import("./chunks/survey-rank-
|
|
1391
|
-
"survey-rating": () => import("./chunks/survey-rating-
|
|
1392
|
-
table: () => import("./chunks/table-
|
|
1407
|
+
"survey-likert": () => import("./chunks/survey-likert-DkE6bR7B.js").then((e) => e.surveyLikertModule),
|
|
1408
|
+
"survey-rank": () => import("./chunks/survey-rank-DN6x4IZM.js").then((e) => e.surveyRankModule),
|
|
1409
|
+
"survey-rating": () => import("./chunks/survey-rating-BnsNL9U5.js").then((e) => e.surveyRatingModule),
|
|
1410
|
+
table: () => import("./chunks/table-CAjCJHrL.js").then((e) => e.tableModule),
|
|
1393
1411
|
"text-limit": () => import("./chunks/text-limit-DbgEFHLO.js").then((e) => e.textLimitModule)
|
|
1394
|
-
},
|
|
1395
|
-
bpoint: () => import("./chunks/bpoint-
|
|
1396
|
-
eway: () => import("./chunks/eway-
|
|
1397
|
-
"go-cardless": () => import("./chunks/go-cardless-
|
|
1398
|
-
mollie: () => import("./chunks/mollie-
|
|
1399
|
-
moneris: () => import("./chunks/moneris-
|
|
1400
|
-
opayo: () => import("./chunks/opayo-
|
|
1401
|
-
paddle: () => import("./chunks/paddle-
|
|
1402
|
-
paypal: () => import("./chunks/paypal-
|
|
1403
|
-
payway: () => import("./chunks/payway-
|
|
1404
|
-
square: () => import("./chunks/square-
|
|
1405
|
-
stripe: () => import("./chunks/stripe-
|
|
1406
|
-
},
|
|
1407
|
-
...
|
|
1408
|
-
...
|
|
1409
|
-
...
|
|
1410
|
-
...
|
|
1411
|
-
},
|
|
1412
|
-
async function
|
|
1412
|
+
}, Zt = {
|
|
1413
|
+
bpoint: () => import("./chunks/bpoint-C0VOftX9.js").then((e) => e.bpointModule),
|
|
1414
|
+
eway: () => import("./chunks/eway-CS6Y1Yvo.js").then((e) => e.ewayModule),
|
|
1415
|
+
"go-cardless": () => import("./chunks/go-cardless-BTPD668l.js").then((e) => e.goCardlessModule),
|
|
1416
|
+
mollie: () => import("./chunks/mollie-CXgBwvo6.js").then((e) => e.mollieModule),
|
|
1417
|
+
moneris: () => import("./chunks/moneris-B6oLu7nj.js").then((e) => e.monerisModule),
|
|
1418
|
+
opayo: () => import("./chunks/opayo-DPUA5CKr.js").then((e) => e.opayoModule),
|
|
1419
|
+
paddle: () => import("./chunks/paddle-GRlsm5mm.js").then((e) => e.paddleModule),
|
|
1420
|
+
paypal: () => import("./chunks/paypal-CdcZnf6r.js").then((e) => e.paypalModule),
|
|
1421
|
+
payway: () => import("./chunks/payway-CfmYOS__.js").then((e) => e.paywayModule),
|
|
1422
|
+
square: () => import("./chunks/square-BY--5M-X.js").then((e) => e.squareModule),
|
|
1423
|
+
stripe: () => import("./chunks/stripe-uusYjWty.js").then((e) => e.stripeModule)
|
|
1424
|
+
}, Qt = {
|
|
1425
|
+
...Xt,
|
|
1426
|
+
...Jt,
|
|
1427
|
+
...Yt,
|
|
1428
|
+
...Zt
|
|
1429
|
+
}, R = /* @__PURE__ */ new Map(), z = S("general", "loader"), $t = Function("src", "return import(src);");
|
|
1430
|
+
async function B(t, n, i, a) {
|
|
1413
1431
|
await t(r(i), a), await t(e(n, i), a);
|
|
1414
1432
|
}
|
|
1415
|
-
function
|
|
1433
|
+
function en(e) {
|
|
1416
1434
|
return !!e && typeof e == "object" && typeof e.id == "string" && typeof e.setup == "function" && typeof e.match == "function";
|
|
1417
1435
|
}
|
|
1418
|
-
async function
|
|
1419
|
-
let n =
|
|
1420
|
-
return n ? (
|
|
1436
|
+
async function tn(e, t) {
|
|
1437
|
+
let n = Qt[e];
|
|
1438
|
+
return n ? (R.has(e) || R.set(e, (async () => {
|
|
1421
1439
|
try {
|
|
1422
1440
|
let e = await n();
|
|
1423
|
-
return
|
|
1441
|
+
return en(e) ? (t.registry.register(e), e) : null;
|
|
1424
1442
|
} catch (t) {
|
|
1425
|
-
return console.error("[formie] Failed to load builtin module:", e, t),
|
|
1443
|
+
return console.error("[formie] Failed to load builtin module:", e, t), z.warn("Failed loading builtin module.", {
|
|
1426
1444
|
moduleId: e,
|
|
1427
1445
|
error: t
|
|
1428
1446
|
}), null;
|
|
1429
1447
|
}
|
|
1430
|
-
})()),
|
|
1448
|
+
})()), R.get(e) || null) : null;
|
|
1431
1449
|
}
|
|
1432
|
-
async function
|
|
1450
|
+
async function nn(e) {
|
|
1433
1451
|
try {
|
|
1434
|
-
let t = await
|
|
1435
|
-
return
|
|
1452
|
+
let t = await $t(e), n = t?.default || t?.formieModule || null;
|
|
1453
|
+
return en(n) ? n : null;
|
|
1436
1454
|
} catch (t) {
|
|
1437
|
-
return console.error("[formie] Failed to load module from src:", e, t),
|
|
1455
|
+
return console.error("[formie] Failed to load module from src:", e, t), z.warn("Failed loading module from src.", {
|
|
1438
1456
|
src: e,
|
|
1439
1457
|
error: t
|
|
1440
1458
|
}), null;
|
|
1441
1459
|
}
|
|
1442
1460
|
}
|
|
1443
|
-
async function
|
|
1461
|
+
async function rn(e, t) {
|
|
1444
1462
|
let n = t.registry.get(e.id);
|
|
1445
1463
|
if (n) return n;
|
|
1446
|
-
let r = await
|
|
1464
|
+
let r = await tn(e.id, t);
|
|
1447
1465
|
if (r) return r;
|
|
1448
1466
|
if (e.src) {
|
|
1449
|
-
let n = await
|
|
1467
|
+
let n = await nn(e.src);
|
|
1450
1468
|
if (n) return t.registry.register(n), n;
|
|
1451
1469
|
}
|
|
1452
1470
|
return null;
|
|
1453
1471
|
}
|
|
1454
|
-
function
|
|
1472
|
+
function V(e) {
|
|
1455
1473
|
return typeof window.CSS?.escape == "function" ? window.CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
|
|
1456
1474
|
}
|
|
1457
1475
|
function H(e, t) {
|
|
1458
1476
|
return e.matches(t) ? [e, ...Array.from(e.querySelectorAll(t))] : Array.from(e.querySelectorAll(t));
|
|
1459
1477
|
}
|
|
1460
|
-
function
|
|
1478
|
+
function an(e, t) {
|
|
1461
1479
|
let n = t.setupContext.root, r = t.setupContext.form, i = e.targetType, a = e.targetId;
|
|
1462
1480
|
return i === "selector" ? H(n, a).map((e) => ({
|
|
1463
1481
|
scope: i,
|
|
1464
1482
|
element: e
|
|
1465
|
-
})) : i === "field" ? H(n, `[data-formie-field-handle="${
|
|
1483
|
+
})) : i === "field" ? H(n, `[data-formie-field-handle="${V(a)}"]`).map((e) => ({
|
|
1466
1484
|
scope: i,
|
|
1467
1485
|
element: e
|
|
1468
|
-
})) : i === "page" ? H(n, `[data-formie-page-id="${
|
|
1486
|
+
})) : i === "page" ? H(n, `[data-formie-page-id="${V(a)}"]`).map((e) => ({
|
|
1469
1487
|
scope: i,
|
|
1470
1488
|
element: e
|
|
1471
|
-
})) : i === "button" ? H(n, `[data-formie-action="${
|
|
1489
|
+
})) : i === "button" ? H(n, `[data-formie-action="${V(a)}"]`).map((e) => ({
|
|
1472
1490
|
scope: i,
|
|
1473
1491
|
element: e
|
|
1474
1492
|
})) : [{
|
|
@@ -1476,26 +1494,26 @@ function nn(e, t) {
|
|
|
1476
1494
|
element: r || n
|
|
1477
1495
|
}];
|
|
1478
1496
|
}
|
|
1479
|
-
function
|
|
1497
|
+
function on(e, t) {
|
|
1480
1498
|
return (e.targets && e.targets.length > 0 ? e.targets : [{
|
|
1481
1499
|
targetType: "form",
|
|
1482
1500
|
targetId: "form"
|
|
1483
|
-
}]).flatMap((e) =>
|
|
1501
|
+
}]).flatMap((e) => an(e, t));
|
|
1484
1502
|
}
|
|
1485
|
-
async function
|
|
1503
|
+
async function sn(e, t) {
|
|
1486
1504
|
let n = [];
|
|
1487
|
-
|
|
1505
|
+
z.log("Loading module manifest.", { manifestCount: e.length });
|
|
1488
1506
|
for (let r of e) {
|
|
1489
|
-
let e = await
|
|
1507
|
+
let e = await rn(r, t);
|
|
1490
1508
|
if (!e) {
|
|
1491
|
-
|
|
1509
|
+
z.warn("Skipping manifest item (definition not resolved).", {
|
|
1492
1510
|
moduleId: r.id,
|
|
1493
1511
|
src: r.src
|
|
1494
1512
|
});
|
|
1495
1513
|
continue;
|
|
1496
1514
|
}
|
|
1497
|
-
let i =
|
|
1498
|
-
|
|
1515
|
+
let i = on(r, t);
|
|
1516
|
+
z.log("Resolved module targets.", {
|
|
1499
1517
|
moduleId: e.id,
|
|
1500
1518
|
targets: r.targets || [],
|
|
1501
1519
|
targetCount: i.length
|
|
@@ -1508,7 +1526,7 @@ async function an(e, t) {
|
|
|
1508
1526
|
manifestItem: r
|
|
1509
1527
|
};
|
|
1510
1528
|
if (!e.match(i)) {
|
|
1511
|
-
e.kind === "address" && console.warn(`[formie] Address module "${e.id}" skipped: target element does not contain [data-formie-address-autocomplete-input]. Enable the Auto-Complete subfield.`),
|
|
1529
|
+
e.kind === "address" && console.warn(`[formie] Address module "${e.id}" skipped: target element does not contain [data-formie-address-autocomplete-input]. Enable the Auto-Complete subfield.`), z.log("Module target did not match predicate.", {
|
|
1512
1530
|
moduleId: e.id,
|
|
1513
1531
|
scope: a.scope
|
|
1514
1532
|
});
|
|
@@ -1522,7 +1540,7 @@ async function an(e, t) {
|
|
|
1522
1540
|
options: o,
|
|
1523
1541
|
manifestItem: r
|
|
1524
1542
|
};
|
|
1525
|
-
await
|
|
1543
|
+
await B(t.setupContext.emit, s, "before-setup", c);
|
|
1526
1544
|
let l = null;
|
|
1527
1545
|
try {
|
|
1528
1546
|
let n = await e.setup({
|
|
@@ -1533,25 +1551,25 @@ async function an(e, t) {
|
|
|
1533
1551
|
});
|
|
1534
1552
|
n && (l = n);
|
|
1535
1553
|
} catch (t) {
|
|
1536
|
-
console.error(`[formie] Module "${e.id}" setup failed:`, t),
|
|
1554
|
+
console.error(`[formie] Module "${e.id}" setup failed:`, t), z.warn("Module setup failed.", {
|
|
1537
1555
|
moduleId: e.id,
|
|
1538
1556
|
scope: a.scope,
|
|
1539
1557
|
error: t
|
|
1540
1558
|
});
|
|
1541
1559
|
}
|
|
1542
|
-
await
|
|
1560
|
+
await B(t.setupContext.emit, s, "after-setup", {
|
|
1543
1561
|
...c,
|
|
1544
1562
|
instanceCreated: !!l
|
|
1545
|
-
}), l && (
|
|
1563
|
+
}), l && (z.log("Module instance created.", {
|
|
1546
1564
|
moduleId: e.id,
|
|
1547
1565
|
scope: a.scope
|
|
1548
1566
|
}), n.push({
|
|
1549
1567
|
...l,
|
|
1550
1568
|
destroy: async () => {
|
|
1551
|
-
|
|
1569
|
+
z.log("Destroying module instance.", {
|
|
1552
1570
|
moduleId: e.id,
|
|
1553
1571
|
scope: a.scope
|
|
1554
|
-
}), await
|
|
1572
|
+
}), await B(t.setupContext.emit, s, "before-destroy", c), await l.destroy(), await B(t.setupContext.emit, s, "after-destroy", c), z.log("Module instance destroyed.", {
|
|
1555
1573
|
moduleId: e.id,
|
|
1556
1574
|
scope: a.scope
|
|
1557
1575
|
});
|
|
@@ -1559,20 +1577,20 @@ async function an(e, t) {
|
|
|
1559
1577
|
}));
|
|
1560
1578
|
}
|
|
1561
1579
|
}
|
|
1562
|
-
return
|
|
1580
|
+
return z.log("Module manifest processing complete.", { instanceCount: n.length }), n;
|
|
1563
1581
|
}
|
|
1564
1582
|
//#endregion
|
|
1565
1583
|
//#region src/js/utils/form-started-at.ts
|
|
1566
|
-
var
|
|
1567
|
-
function
|
|
1584
|
+
var cn = "formie:formStartedAt:";
|
|
1585
|
+
function ln(e) {
|
|
1568
1586
|
let t = e.querySelector("input[name=\"formStartedAt\"]");
|
|
1569
1587
|
if (!t) return;
|
|
1570
|
-
let n = e.querySelector("input[name=\"renderId\"]")?.value?.trim() ?? "", r = n ? `${
|
|
1588
|
+
let n = e.querySelector("input[name=\"renderId\"]")?.value?.trim() ?? "", r = n ? `${cn}${n}` : null, i = r ? sessionStorage.getItem(r) : null;
|
|
1571
1589
|
i || (i = String(Date.now()), r && sessionStorage.setItem(r, i)), t.value = i;
|
|
1572
1590
|
}
|
|
1573
1591
|
//#endregion
|
|
1574
1592
|
//#region src/js/utils/unload-warning.ts
|
|
1575
|
-
var
|
|
1593
|
+
var un = new Set([
|
|
1576
1594
|
"CRAFT_CSRF_TOKEN",
|
|
1577
1595
|
"action",
|
|
1578
1596
|
"redirect",
|
|
@@ -1585,38 +1603,38 @@ var cn = new Set([
|
|
|
1585
1603
|
"draftContext",
|
|
1586
1604
|
"continuationToken"
|
|
1587
1605
|
]);
|
|
1588
|
-
function
|
|
1606
|
+
function dn(e, t) {
|
|
1589
1607
|
if (e == null) return String(e);
|
|
1590
1608
|
if (typeof e == "string") return JSON.stringify(e);
|
|
1591
1609
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1592
1610
|
if (typeof e == "function") return "[function]";
|
|
1593
1611
|
if (typeof File < "u" && e instanceof File) return `[file:${e.name}:${e.size}:${e.type}]`;
|
|
1594
1612
|
if (typeof Blob < "u" && e instanceof Blob) return `[blob:${e.size}:${e.type}]`;
|
|
1595
|
-
if (Array.isArray(e)) return `[${e.map((e) =>
|
|
1613
|
+
if (Array.isArray(e)) return `[${e.map((e) => dn(e, t)).join(",")}]`;
|
|
1596
1614
|
if (typeof e == "object") {
|
|
1597
1615
|
if (t.has(e)) return "[circular]";
|
|
1598
1616
|
t.add(e);
|
|
1599
|
-
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${
|
|
1617
|
+
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${dn(n, t)}`);
|
|
1600
1618
|
return t.delete(e), `{${n.join(",")}}`;
|
|
1601
1619
|
}
|
|
1602
1620
|
return JSON.stringify(String(e));
|
|
1603
1621
|
}
|
|
1604
|
-
function
|
|
1605
|
-
return
|
|
1622
|
+
function fn(e) {
|
|
1623
|
+
return dn(e, /* @__PURE__ */ new WeakSet());
|
|
1606
1624
|
}
|
|
1607
|
-
function
|
|
1625
|
+
function pn(e) {
|
|
1608
1626
|
if (!e) return !1;
|
|
1609
1627
|
let t = e.endsWith("[]") ? e.slice(0, -2) : e;
|
|
1610
|
-
return !
|
|
1628
|
+
return !un.has(t);
|
|
1611
1629
|
}
|
|
1612
|
-
function
|
|
1613
|
-
return
|
|
1630
|
+
function mn(e) {
|
|
1631
|
+
return fn(Array.from(new FormData(e).entries()).filter(([e]) => pn(String(e || ""))));
|
|
1614
1632
|
}
|
|
1615
|
-
function
|
|
1633
|
+
function hn(e, t = {}) {
|
|
1616
1634
|
let n = null, r = !1, i = !1, a = null, o = null, s = null, c = () => {
|
|
1617
1635
|
a !== null && (window.cancelAnimationFrame(a), a = null), o !== null && (window.clearTimeout(o), o = null), s !== null && (window.clearTimeout(s), s = null);
|
|
1618
|
-
}, l = () => r ? (i =
|
|
1619
|
-
n =
|
|
1636
|
+
}, l = () => r ? (i = mn(e) !== n, i) : !1, u = () => {
|
|
1637
|
+
n = mn(e), r = !0, i = !1;
|
|
1620
1638
|
}, d = () => {
|
|
1621
1639
|
c(), r = !1, a = window.requestAnimationFrame(() => {
|
|
1622
1640
|
a = null, s = window.setTimeout(() => {
|
|
@@ -1641,25 +1659,25 @@ function pn(e, t = {}) {
|
|
|
1641
1659
|
}
|
|
1642
1660
|
//#endregion
|
|
1643
1661
|
//#region src/js/validation/enter-key-guard.ts
|
|
1644
|
-
function
|
|
1662
|
+
function gn(e) {
|
|
1645
1663
|
return e.hasAttribute("data-formie-conditionally-hidden") || !!e.closest("[data-formie-conditionally-hidden]") || e.hasAttribute("data-formie-page-hidden") || !!e.closest("[data-formie-page-hidden]");
|
|
1646
1664
|
}
|
|
1647
|
-
function
|
|
1665
|
+
function _n(e, t) {
|
|
1648
1666
|
let n = e.querySelectorAll(`[data-formie-action="${t}"]`);
|
|
1649
|
-
return Array.from(n).some((e) => !
|
|
1667
|
+
return Array.from(n).some((e) => !gn(e));
|
|
1650
1668
|
}
|
|
1651
|
-
function
|
|
1669
|
+
function vn(e) {
|
|
1652
1670
|
let { final: t } = f(e);
|
|
1653
1671
|
return "submit";
|
|
1654
1672
|
}
|
|
1655
|
-
function
|
|
1656
|
-
return !
|
|
1673
|
+
function yn(e) {
|
|
1674
|
+
return !_n(e, vn(e));
|
|
1657
1675
|
}
|
|
1658
|
-
function
|
|
1676
|
+
function bn(e) {
|
|
1659
1677
|
let t = (t) => {
|
|
1660
1678
|
if (t.key !== "Enter" || t.defaultPrevented) return;
|
|
1661
1679
|
let n = t.target;
|
|
1662
|
-
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") ||
|
|
1680
|
+
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") || yn(e) && t.preventDefault());
|
|
1663
1681
|
};
|
|
1664
1682
|
return e.addEventListener("keydown", t, !0), () => {
|
|
1665
1683
|
e.removeEventListener("keydown", t, !0);
|
|
@@ -1667,13 +1685,13 @@ function vn(e) {
|
|
|
1667
1685
|
}
|
|
1668
1686
|
//#endregion
|
|
1669
1687
|
//#region src/js/core/create-formie-client.ts
|
|
1670
|
-
var U = "[data-formie]:not([data-formie-init=\"false\"]), [data-formie-form]:not([data-formie-init=\"false\"])",
|
|
1688
|
+
var U = "[data-formie]:not([data-formie-init=\"false\"]), [data-formie-form]:not([data-formie-init=\"false\"])", xn = 300, Sn = "/actions/formie/server/forms/render", Cn = "/api", wn = "/actions/formie/server/forms/refresh-tokens", Tn = "/actions/formie/server/submissions/submit", En = "/actions/formie/server/submissions/set-page", Dn = "/actions/formie/server/submissions/clear-submission", On = "/actions/formie/file-upload/hydrate", W = S("general", "client"), kn = /* @__PURE__ */ new Set();
|
|
1671
1689
|
function G(e, t) {
|
|
1672
1690
|
if (e == null || e === "") return t;
|
|
1673
1691
|
let n = e.toLowerCase();
|
|
1674
1692
|
return !(n === "false" || n === "0" || n === "off");
|
|
1675
1693
|
}
|
|
1676
|
-
function
|
|
1694
|
+
function An(e) {
|
|
1677
1695
|
return e.formieRefreshTokens != null && e.formieRefreshTokens !== "" ? G(e.formieRefreshTokens, !1) : e.formieStaticCache != null && e.formieStaticCache !== "" ? G(e.formieStaticCache, !1) : !1;
|
|
1678
1696
|
}
|
|
1679
1697
|
function K(e) {
|
|
@@ -1683,7 +1701,7 @@ function K(e) {
|
|
|
1683
1701
|
transport: t.formieTransport || "rest",
|
|
1684
1702
|
formHandle: t.formieHandle,
|
|
1685
1703
|
endpoint: t.formieEndpoint,
|
|
1686
|
-
staticCache:
|
|
1704
|
+
staticCache: An(t),
|
|
1687
1705
|
autoVisible: G(t.formieAutoVisible, !0),
|
|
1688
1706
|
compatibility: G(t.formieCompatibility, !1)
|
|
1689
1707
|
};
|
|
@@ -1697,10 +1715,10 @@ function J(e) {
|
|
|
1697
1715
|
function Y(e) {
|
|
1698
1716
|
return e instanceof HTMLFormElement ? e : e.querySelector("form");
|
|
1699
1717
|
}
|
|
1700
|
-
function
|
|
1701
|
-
|
|
1718
|
+
function jn(e, t) {
|
|
1719
|
+
kn.has(e) || (kn.add(e), W.warn(t));
|
|
1702
1720
|
}
|
|
1703
|
-
function
|
|
1721
|
+
function Mn(e, t) {
|
|
1704
1722
|
if (!e) return e;
|
|
1705
1723
|
try {
|
|
1706
1724
|
return new URL(e).toString();
|
|
@@ -1714,19 +1732,19 @@ function An(e, t) {
|
|
|
1714
1732
|
}
|
|
1715
1733
|
function X(e, t) {
|
|
1716
1734
|
let n = (e || "").trim();
|
|
1717
|
-
return n ? n.includes("/actions/") ? n :
|
|
1735
|
+
return n ? n.includes("/actions/") ? n : Mn(t, n) : t;
|
|
1718
1736
|
}
|
|
1719
|
-
function
|
|
1720
|
-
return X(e.endpoint || t.dataset.formieEndpoint,
|
|
1737
|
+
function Nn(e, t) {
|
|
1738
|
+
return X(e.endpoint || t.dataset.formieEndpoint, Sn);
|
|
1721
1739
|
}
|
|
1722
|
-
function
|
|
1740
|
+
function Pn(e, t) {
|
|
1723
1741
|
let n = (e.endpoint || t.dataset.formieEndpoint || "").trim();
|
|
1724
|
-
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n :
|
|
1742
|
+
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n : Mn(Cn, n) : Cn;
|
|
1725
1743
|
}
|
|
1726
|
-
function
|
|
1727
|
-
return X(t.dataset.formieRefreshTokensEndpoint || e.endpoint || t.dataset.formieEndpoint,
|
|
1744
|
+
function Fn(e, t) {
|
|
1745
|
+
return X(t.dataset.formieRefreshTokensEndpoint || e.endpoint || t.dataset.formieEndpoint, wn);
|
|
1728
1746
|
}
|
|
1729
|
-
function
|
|
1747
|
+
function In(e, t) {
|
|
1730
1748
|
if (!e) return t;
|
|
1731
1749
|
try {
|
|
1732
1750
|
let n = new URL(e, window.location.origin), r = new URL(t, window.location.origin);
|
|
@@ -1737,42 +1755,42 @@ function Pn(e, t) {
|
|
|
1737
1755
|
return t;
|
|
1738
1756
|
}
|
|
1739
1757
|
}
|
|
1740
|
-
function
|
|
1741
|
-
let r = n.endpoint || e.dataset.formieEndpoint, i = X(r,
|
|
1742
|
-
t.setAttribute("action",
|
|
1743
|
-
let t = e.getAttribute("href"), n = X(r,
|
|
1744
|
-
e.setAttribute("href",
|
|
1758
|
+
function Ln(e, t, n) {
|
|
1759
|
+
let r = n.endpoint || e.dataset.formieEndpoint, i = X(r, Tn), a = t.getAttribute("action");
|
|
1760
|
+
t.setAttribute("action", In(a, i)), t.querySelectorAll("[data-formie-tab-link]").forEach((e) => {
|
|
1761
|
+
let t = e.getAttribute("href"), n = X(r, En);
|
|
1762
|
+
e.setAttribute("href", In(t, n));
|
|
1745
1763
|
}), t.querySelectorAll("[data-formie-file-upload-hydrate-endpoint]").forEach((e) => {
|
|
1746
|
-
e.setAttribute("data-formie-file-upload-hydrate-endpoint", X(r,
|
|
1764
|
+
e.setAttribute("data-formie-file-upload-hydrate-endpoint", X(r, On));
|
|
1747
1765
|
});
|
|
1748
1766
|
}
|
|
1749
|
-
function
|
|
1767
|
+
function Rn(e, t) {
|
|
1750
1768
|
if (e === "graphql" && t !== "server-rendered") throw Error(`Formie ${t} mode does not support GraphQL transport yet.`);
|
|
1751
1769
|
}
|
|
1752
|
-
function
|
|
1770
|
+
function zn(e) {
|
|
1753
1771
|
if (e == null) return !1;
|
|
1754
1772
|
let t = e.trim().toLowerCase();
|
|
1755
1773
|
return t === "true" || t === "1" || t === "";
|
|
1756
1774
|
}
|
|
1757
|
-
function
|
|
1775
|
+
function Bn(e) {
|
|
1758
1776
|
return G(e.dataset.formieAutomaticSubmissionState, !0);
|
|
1759
1777
|
}
|
|
1760
|
-
function
|
|
1761
|
-
return X(n.dataset.formieClearSubmissionEndpoint || e.endpoint || t.dataset.formieEndpoint,
|
|
1778
|
+
function Vn(e, t, n) {
|
|
1779
|
+
return X(n.dataset.formieClearSubmissionEndpoint || e.endpoint || t.dataset.formieEndpoint, Dn);
|
|
1762
1780
|
}
|
|
1763
|
-
function
|
|
1764
|
-
return
|
|
1781
|
+
function Hn(e) {
|
|
1782
|
+
return zn(e.dataset.formieUnloadWarning);
|
|
1765
1783
|
}
|
|
1766
|
-
function
|
|
1784
|
+
function Un(e, t) {
|
|
1767
1785
|
e.setAttribute("data-formie-internal-navigation", t);
|
|
1768
1786
|
}
|
|
1769
|
-
function
|
|
1787
|
+
function Wn(e) {
|
|
1770
1788
|
e.removeAttribute("data-formie-internal-navigation");
|
|
1771
1789
|
}
|
|
1772
|
-
function
|
|
1790
|
+
function Gn(e) {
|
|
1773
1791
|
return e.getAttribute("data-formie-internal-navigation") !== null;
|
|
1774
1792
|
}
|
|
1775
|
-
function
|
|
1793
|
+
function Kn(e, t) {
|
|
1776
1794
|
if (!e) return !1;
|
|
1777
1795
|
try {
|
|
1778
1796
|
return new URL(e, window.location.origin).searchParams.has(t);
|
|
@@ -1780,30 +1798,30 @@ function Wn(e, t) {
|
|
|
1780
1798
|
return !1;
|
|
1781
1799
|
}
|
|
1782
1800
|
}
|
|
1783
|
-
function
|
|
1784
|
-
return
|
|
1801
|
+
function qn(e) {
|
|
1802
|
+
return Kn(window.location.href, "resumeToken") || Kn(e.getAttribute("action"), "resumeToken");
|
|
1785
1803
|
}
|
|
1786
|
-
function
|
|
1804
|
+
function Jn(e) {
|
|
1787
1805
|
return e instanceof MouseEvent ? e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey : !0;
|
|
1788
1806
|
}
|
|
1789
|
-
function
|
|
1807
|
+
function Yn(e, t = 0) {
|
|
1790
1808
|
if (!e) return t;
|
|
1791
1809
|
let n = Number.parseInt(e, 10);
|
|
1792
1810
|
return Number.isFinite(n) ? n : t;
|
|
1793
1811
|
}
|
|
1794
|
-
function
|
|
1795
|
-
return Math.max(0,
|
|
1812
|
+
function Xn(e) {
|
|
1813
|
+
return Math.max(0, Yn(e.dataset.formieSubmitDelay, xn));
|
|
1796
1814
|
}
|
|
1797
1815
|
function Z(e) {
|
|
1798
|
-
return
|
|
1816
|
+
return zn(e.dataset.formieValidationOnSubmit);
|
|
1799
1817
|
}
|
|
1800
|
-
async function
|
|
1801
|
-
let t =
|
|
1818
|
+
async function Zn(e) {
|
|
1819
|
+
let t = Xn(e);
|
|
1802
1820
|
t < 1 || await new Promise((e) => {
|
|
1803
1821
|
window.setTimeout(e, t);
|
|
1804
1822
|
});
|
|
1805
1823
|
}
|
|
1806
|
-
function
|
|
1824
|
+
function Qn(e, t) {
|
|
1807
1825
|
let n = e?.getAttribute(t)?.trim();
|
|
1808
1826
|
if (!n) return null;
|
|
1809
1827
|
try {
|
|
@@ -1812,29 +1830,29 @@ function Xn(e, t) {
|
|
|
1812
1830
|
return console.error(`[formie] Failed to parse ${t}.`, e), null;
|
|
1813
1831
|
}
|
|
1814
1832
|
}
|
|
1815
|
-
function
|
|
1833
|
+
function $n(e, t) {
|
|
1816
1834
|
let n = t || (e instanceof HTMLFormElement ? e : null);
|
|
1817
1835
|
if (!n) return null;
|
|
1818
|
-
let r =
|
|
1836
|
+
let r = Qn(n, "data-formie-modules"), i = Qn(n, "data-formie-theme");
|
|
1819
1837
|
return !r && !i ? null : {
|
|
1820
1838
|
modules: r || void 0,
|
|
1821
1839
|
theme: i || void 0
|
|
1822
1840
|
};
|
|
1823
1841
|
}
|
|
1824
|
-
function
|
|
1842
|
+
function er(e) {
|
|
1825
1843
|
if (!(e instanceof HTMLElement)) return !0;
|
|
1826
1844
|
if (!e.isConnected || e.hidden || e.closest("[hidden]")) return !1;
|
|
1827
1845
|
let t = window.getComputedStyle(e);
|
|
1828
1846
|
return t.display === "none" || t.visibility === "hidden" ? !1 : e.getClientRects().length > 0;
|
|
1829
1847
|
}
|
|
1830
|
-
function
|
|
1848
|
+
function tr(e, t) {
|
|
1831
1849
|
return t === document ? !0 : t instanceof Element ? t === e || t.contains(e) : !0;
|
|
1832
1850
|
}
|
|
1833
1851
|
function Q(e) {
|
|
1834
1852
|
let t = e, n = t.id ? `#${t.id}` : "", r = t.dataset?.formieHandle ? `[handle="${t.dataset.formieHandle}"]` : "";
|
|
1835
1853
|
return `${t.tagName ? t.tagName.toLowerCase() : "element"}${n}${r}`;
|
|
1836
1854
|
}
|
|
1837
|
-
function
|
|
1855
|
+
function nr(e, t) {
|
|
1838
1856
|
if (t) {
|
|
1839
1857
|
if (t.csrf?.param && t.csrf?.token) {
|
|
1840
1858
|
let n = e.querySelector(`input[name="${t.csrf.param}"]`);
|
|
@@ -1857,11 +1875,11 @@ function er(e, t) {
|
|
|
1857
1875
|
});
|
|
1858
1876
|
}
|
|
1859
1877
|
}
|
|
1860
|
-
async function
|
|
1878
|
+
async function rr(e, t) {
|
|
1861
1879
|
let n = q(t.mode), r = J(t.transport);
|
|
1862
1880
|
if (n !== "server-rendered") return null;
|
|
1863
1881
|
if (t.payload) return t.payload.html && (e.innerHTML = t.payload.html), t.payload;
|
|
1864
|
-
|
|
1882
|
+
Rn(r, n);
|
|
1865
1883
|
let i = !!Y(e), a = t.formHandle || e.dataset.formieHandle;
|
|
1866
1884
|
if (i || !a) return null;
|
|
1867
1885
|
let o = {
|
|
@@ -1871,30 +1889,30 @@ async function tr(e, t) {
|
|
|
1871
1889
|
siteId: t.siteId,
|
|
1872
1890
|
theme: t.theme,
|
|
1873
1891
|
themeConfig: t.themeConfig
|
|
1874
|
-
}, s = r === "graphql" ?
|
|
1892
|
+
}, s = r === "graphql" ? Pn(t, e) : Nn(t, e), c = r === "graphql" ? await Ve(s, a, o) : await Be(s, a, {
|
|
1875
1893
|
...o,
|
|
1876
1894
|
endpoint: s
|
|
1877
1895
|
});
|
|
1878
1896
|
return c?.html && (e.innerHTML = c.html), c;
|
|
1879
1897
|
}
|
|
1880
|
-
async function
|
|
1898
|
+
async function ir(e, t, n) {
|
|
1881
1899
|
if (t.refreshTokens === !1) return;
|
|
1882
|
-
|
|
1900
|
+
Rn(J(t.transport), q(t.mode));
|
|
1883
1901
|
let r = t.formHandle || e.dataset.formieHandle;
|
|
1884
1902
|
if (!r) return;
|
|
1885
|
-
let i = await
|
|
1886
|
-
|
|
1903
|
+
let i = await j(Fn(t, e), r, n.querySelector("input[name=\"renderId\"]")?.value || void 0);
|
|
1904
|
+
nr(n, i), h(e, "formie:refresh-tokens:refreshed", i);
|
|
1887
1905
|
}
|
|
1888
|
-
function
|
|
1889
|
-
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s =
|
|
1906
|
+
function ar(e, t, n, r, i, a) {
|
|
1907
|
+
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s = Vn(n, e, t), c = !1, u = t.querySelectorAll("[data-formie-action]"), g = (e) => {
|
|
1890
1908
|
if (e) {
|
|
1891
1909
|
t.setAttribute("data-formie-pending-action", e);
|
|
1892
1910
|
return;
|
|
1893
1911
|
}
|
|
1894
1912
|
t.removeAttribute("data-formie-pending-action");
|
|
1895
1913
|
};
|
|
1896
|
-
if (
|
|
1897
|
-
let n =
|
|
1914
|
+
if (Hn(t)) {
|
|
1915
|
+
let n = hn(t, { shouldWarn: () => !Gn(t) }), r = (e) => {
|
|
1898
1916
|
if (!(e instanceof CustomEvent)) return;
|
|
1899
1917
|
let t = e.detail;
|
|
1900
1918
|
t?.ok && t.action === "save" && n.scheduleBaselineCapture();
|
|
@@ -1916,7 +1934,7 @@ function rr(e, t, n, r, i, a) {
|
|
|
1916
1934
|
}), t.querySelectorAll("[data-formie-tab-link]").forEach((n) => {
|
|
1917
1935
|
let r = async (n) => {
|
|
1918
1936
|
if (o !== "ajax") {
|
|
1919
|
-
|
|
1937
|
+
Jn(n) && Un(t, "set-page");
|
|
1920
1938
|
return;
|
|
1921
1939
|
}
|
|
1922
1940
|
n.preventDefault();
|
|
@@ -1930,7 +1948,7 @@ function rr(e, t, n, r, i, a) {
|
|
|
1930
1948
|
h(e, "formie:page:navigate:after", {
|
|
1931
1949
|
pageId: i,
|
|
1932
1950
|
href: a,
|
|
1933
|
-
response: await
|
|
1951
|
+
response: await He(a, t, i)
|
|
1934
1952
|
});
|
|
1935
1953
|
} catch (t) {
|
|
1936
1954
|
console.error("[formie] Failed to persist page navigation state.", t), h(e, "formie:page:navigate:error", {
|
|
@@ -1944,9 +1962,9 @@ function rr(e, t, n, r, i, a) {
|
|
|
1944
1962
|
n.addEventListener("click", r), a.push(() => {
|
|
1945
1963
|
n.removeEventListener("click", r);
|
|
1946
1964
|
});
|
|
1947
|
-
}), !
|
|
1965
|
+
}), !Bn(t)) {
|
|
1948
1966
|
let e = !1, n = () => {
|
|
1949
|
-
e ||
|
|
1967
|
+
e || Gn(t) || qn(t) || (e = !0, Ue(s, t));
|
|
1950
1968
|
};
|
|
1951
1969
|
window.addEventListener("pagehide", n), window.addEventListener("beforeunload", n), a.push(() => {
|
|
1952
1970
|
window.removeEventListener("pagehide", n), window.removeEventListener("beforeunload", n);
|
|
@@ -1961,7 +1979,7 @@ function rr(e, t, n, r, i, a) {
|
|
|
1961
1979
|
} else t.removeAttribute("data-formie-internal-resubmit");
|
|
1962
1980
|
let u = a.submitter, p = u?.getAttribute("data-formie-action"), _ = t.getAttribute("data-formie-pending-action"), v = t.querySelector("input[name=\"submitAction\"]"), y = p || _ || v?.value || "submit", b = null, x = !1;
|
|
1963
1981
|
try {
|
|
1964
|
-
if (s) b = await
|
|
1982
|
+
if (s) b = await qt({
|
|
1965
1983
|
target: e,
|
|
1966
1984
|
form: t,
|
|
1967
1985
|
bus: r,
|
|
@@ -1969,25 +1987,25 @@ function rr(e, t, n, r, i, a) {
|
|
|
1969
1987
|
validateOnSubmit: Z(t),
|
|
1970
1988
|
action: y,
|
|
1971
1989
|
submitter: u,
|
|
1972
|
-
waitForSubmitDelay:
|
|
1990
|
+
waitForSubmitDelay: Zn,
|
|
1973
1991
|
onRefreshTokensAfterSubmit: async () => {
|
|
1974
|
-
await
|
|
1992
|
+
await ir(e, n, t);
|
|
1975
1993
|
},
|
|
1976
1994
|
dispatchSubmitResult: (t) => {
|
|
1977
1995
|
h(e, "formie:submit:result", t);
|
|
1978
1996
|
}
|
|
1979
1997
|
});
|
|
1980
1998
|
else {
|
|
1981
|
-
if (
|
|
1999
|
+
if (Kt(t), m(t, u), await Zn(t), b = await nt(t, y, r, {
|
|
1982
2000
|
validator: i,
|
|
1983
2001
|
validateOnSubmit: Z(t),
|
|
1984
2002
|
preflightOnly: !0
|
|
1985
2003
|
}), b.ok) {
|
|
1986
|
-
l(t, y), c = !0,
|
|
2004
|
+
l(t, y), c = !0, Un(t, "submit"), g(null);
|
|
1987
2005
|
let e = !1, n = () => {
|
|
1988
|
-
if (e = !0, c = !1,
|
|
2006
|
+
if (e = !0, c = !1, Wn(t), d(t), i && Z(t)) {
|
|
1989
2007
|
let { scope: e, final: n } = f(t), r = i.submit(n ? t : e, { final: n });
|
|
1990
|
-
r.length > 0 &&
|
|
2008
|
+
r.length > 0 && I(t, {
|
|
1991
2009
|
ok: !1,
|
|
1992
2010
|
stage: "validate",
|
|
1993
2011
|
code: "VALIDATION_FAILED",
|
|
@@ -2009,7 +2027,7 @@ function rr(e, t, n, r, i, a) {
|
|
|
2009
2027
|
x = !0;
|
|
2010
2028
|
return;
|
|
2011
2029
|
}
|
|
2012
|
-
|
|
2030
|
+
I(t, b), h(e, "formie:submit:result", b), Wn(t);
|
|
2013
2031
|
}
|
|
2014
2032
|
} catch (n) {
|
|
2015
2033
|
c = !1, b = {
|
|
@@ -2017,25 +2035,25 @@ function rr(e, t, n, r, i, a) {
|
|
|
2017
2035
|
code: "SUBMIT_ERROR",
|
|
2018
2036
|
message: n instanceof Error ? n.message : "Submission failed.",
|
|
2019
2037
|
formErrors: [n instanceof Error ? n.message : "Submission failed."]
|
|
2020
|
-
},
|
|
2038
|
+
}, I(t, b), h(e, "formie:submit:result", b), Wn(t);
|
|
2021
2039
|
} finally {
|
|
2022
|
-
g(null), !s && !x && !
|
|
2040
|
+
g(null), !s && !x && !Gt(b) && d(t);
|
|
2023
2041
|
}
|
|
2024
2042
|
};
|
|
2025
2043
|
t.addEventListener("submit", _), a.push(() => {
|
|
2026
2044
|
t.removeEventListener("submit", _);
|
|
2027
2045
|
});
|
|
2028
2046
|
}
|
|
2029
|
-
async function
|
|
2047
|
+
async function or(e, t, n) {
|
|
2030
2048
|
if (t.refreshTokens === !1 || !t.staticCache) return;
|
|
2031
|
-
|
|
2032
|
-
let r = t.formHandle || e.dataset.formieHandle, i =
|
|
2049
|
+
Rn(J(t.transport), q(t.mode));
|
|
2050
|
+
let r = t.formHandle || e.dataset.formieHandle, i = Fn(t, e), a = n?.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2033
2051
|
if (!r) return;
|
|
2034
|
-
let o = await
|
|
2035
|
-
!o || !n || (
|
|
2052
|
+
let o = await j(i, r, a);
|
|
2053
|
+
!o || !n || (nr(n, o), h(e, "formie:refresh-tokens:after", o));
|
|
2036
2054
|
}
|
|
2037
|
-
function
|
|
2038
|
-
let e = /* @__PURE__ */ new Map(), t = new
|
|
2055
|
+
function sr() {
|
|
2056
|
+
let e = /* @__PURE__ */ new Map(), t = new L(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = [
|
|
2039
2057
|
"prepare",
|
|
2040
2058
|
"normalize",
|
|
2041
2059
|
"validate",
|
|
@@ -2083,46 +2101,46 @@ function ar() {
|
|
|
2083
2101
|
id: c.instance.id,
|
|
2084
2102
|
target: Q(r)
|
|
2085
2103
|
}), c.instance;
|
|
2086
|
-
let l = new
|
|
2104
|
+
let l = new Ie(), d = [], f = r?.id || `formie-${e.size + 1}`, p = K(r), m = {
|
|
2087
2105
|
...p,
|
|
2088
2106
|
...o,
|
|
2089
2107
|
mode: q(o.mode ?? p.mode),
|
|
2090
2108
|
transport: J(o.transport ?? p.transport)
|
|
2091
|
-
}, g =
|
|
2109
|
+
}, g = ve(m.compatibility);
|
|
2092
2110
|
if (m.mode !== "server-rendered" && !Y(r)) throw Error(`Formie ${m.mode} mode is not implemented yet in the browser client.`);
|
|
2093
|
-
let v = await
|
|
2094
|
-
m.staticCache = o.staticCache ??
|
|
2095
|
-
let x =
|
|
2111
|
+
let v = await rr(r, m), b = Y(r);
|
|
2112
|
+
m.staticCache = o.staticCache ?? An(b ? b.dataset : r.dataset);
|
|
2113
|
+
let x = $n(r, b), ee = v || x ? {
|
|
2096
2114
|
...v || {},
|
|
2097
2115
|
...x || {}
|
|
2098
|
-
} : null,
|
|
2116
|
+
} : null, te = ee?.theme, S = {}, C = (ee?.modules || []).filter((e) => !!e?.id && !!e?.type);
|
|
2099
2117
|
W.log("Resolved mount payload.", {
|
|
2100
2118
|
target: Q(r),
|
|
2101
2119
|
hasRenderPayload: !!v,
|
|
2102
2120
|
hasEmbeddedPayload: !!x,
|
|
2103
|
-
moduleCount:
|
|
2121
|
+
moduleCount: C.length
|
|
2104
2122
|
});
|
|
2105
|
-
let
|
|
2106
|
-
live:
|
|
2107
|
-
errorAriaLive:
|
|
2123
|
+
let w = ne(r, te, b), T = b ? new mt(b, {
|
|
2124
|
+
live: zn(b.dataset.formieValidationOnFocus),
|
|
2125
|
+
errorAriaLive: Te(b),
|
|
2108
2126
|
errorMessage: b.dataset.formieErrorMessage || "",
|
|
2109
|
-
fieldContainerErrorClass:
|
|
2110
|
-
inputErrorClass:
|
|
2111
|
-
messagesClass:
|
|
2112
|
-
messageClass:
|
|
2127
|
+
fieldContainerErrorClass: w.fieldLayoutError || [],
|
|
2128
|
+
inputErrorClass: w.fieldControlError || [],
|
|
2129
|
+
messagesClass: w.fieldErrors || [],
|
|
2130
|
+
messageClass: w.fieldError || []
|
|
2113
2131
|
}) : null;
|
|
2114
|
-
if (b &&
|
|
2132
|
+
if (b && T) {
|
|
2115
2133
|
let e = b;
|
|
2116
|
-
e.formieValidation =
|
|
2134
|
+
e.formieValidation = T, S.validation = T;
|
|
2117
2135
|
let t = {
|
|
2118
|
-
validator:
|
|
2119
|
-
addValidator:
|
|
2120
|
-
removeValidator:
|
|
2136
|
+
validator: T,
|
|
2137
|
+
addValidator: T.addValidator.bind(T),
|
|
2138
|
+
removeValidator: T.removeValidator.bind(T)
|
|
2121
2139
|
};
|
|
2122
2140
|
h(b, "formie:validator:ready", t), h(r, "formie:validator:ready", t);
|
|
2123
2141
|
}
|
|
2124
|
-
b && (
|
|
2125
|
-
let
|
|
2142
|
+
b && (ln(b), m.themeConfig && typeof m.themeConfig == "object" && b.setAttribute("data-formie-theme-config", JSON.stringify(m.themeConfig)), m.theme && m.theme !== "formie" && b.setAttribute("data-formie-frontend-theme", m.theme), (v || m.endpoint || r.dataset.formieEndpoint) && Ln(r, b, m), m.mode === "server-rendered" && Pe(b) && (Ne(b), Fe(b)), y(b)), Object.keys(w).length && h(r, "formie:theme:applied", { hasClasses: !0 });
|
|
2143
|
+
let E = await sn(C, {
|
|
2126
2144
|
registry: t,
|
|
2127
2145
|
matchContext: {
|
|
2128
2146
|
root: r,
|
|
@@ -2135,7 +2153,7 @@ function ar() {
|
|
|
2135
2153
|
form: b,
|
|
2136
2154
|
target: r,
|
|
2137
2155
|
scope: "form",
|
|
2138
|
-
state:
|
|
2156
|
+
state: S,
|
|
2139
2157
|
on: (e, t) => l.on(e, t),
|
|
2140
2158
|
emit: (e, t) => (h(r, e, t), l.emitSafe(e, t).then((t) => {
|
|
2141
2159
|
t.failed.length > 0 && W.warn("Lifecycle listeners failed.", {
|
|
@@ -2147,9 +2165,9 @@ function ar() {
|
|
|
2147
2165
|
});
|
|
2148
2166
|
W.log("Module setup complete.", {
|
|
2149
2167
|
target: Q(r),
|
|
2150
|
-
moduleInstances:
|
|
2168
|
+
moduleInstances: E.length
|
|
2151
2169
|
});
|
|
2152
|
-
let
|
|
2170
|
+
let D = {
|
|
2153
2171
|
id: f,
|
|
2154
2172
|
root: r,
|
|
2155
2173
|
submit: async (e = "submit") => {
|
|
@@ -2170,18 +2188,18 @@ function ar() {
|
|
|
2170
2188
|
message: "Submission already in progress.",
|
|
2171
2189
|
formErrors: []
|
|
2172
2190
|
};
|
|
2173
|
-
let n = b.querySelector(`[data-formie-action="${e}"]`), i = await
|
|
2191
|
+
let n = b.querySelector(`[data-formie-action="${e}"]`), i = await qt({
|
|
2174
2192
|
id: f,
|
|
2175
2193
|
target: r,
|
|
2176
2194
|
form: b,
|
|
2177
2195
|
bus: l,
|
|
2178
|
-
validator:
|
|
2196
|
+
validator: T,
|
|
2179
2197
|
validateOnSubmit: Z(b),
|
|
2180
2198
|
action: e,
|
|
2181
2199
|
submitter: n,
|
|
2182
|
-
waitForSubmitDelay:
|
|
2200
|
+
waitForSubmitDelay: Zn,
|
|
2183
2201
|
onRefreshTokensAfterSubmit: async () => {
|
|
2184
|
-
await
|
|
2202
|
+
await ir(r, m, b);
|
|
2185
2203
|
},
|
|
2186
2204
|
dispatchSubmitResult: (e) => {
|
|
2187
2205
|
h(r, "formie:submit:result", e);
|
|
@@ -2200,52 +2218,52 @@ function ar() {
|
|
|
2200
2218
|
},
|
|
2201
2219
|
on: (e, t) => l.on(e, t)
|
|
2202
2220
|
};
|
|
2203
|
-
b && (
|
|
2221
|
+
b && (we({
|
|
2204
2222
|
target: r,
|
|
2205
2223
|
form: b,
|
|
2206
|
-
validatorDetail:
|
|
2207
|
-
validator:
|
|
2208
|
-
addValidator:
|
|
2209
|
-
removeValidator:
|
|
2224
|
+
validatorDetail: T ? {
|
|
2225
|
+
validator: T,
|
|
2226
|
+
addValidator: T.addValidator.bind(T),
|
|
2227
|
+
removeValidator: T.removeValidator.bind(T)
|
|
2210
2228
|
} : null,
|
|
2211
2229
|
options: g,
|
|
2212
2230
|
unbinds: d
|
|
2213
|
-
}),
|
|
2231
|
+
}), Ce({
|
|
2214
2232
|
target: r,
|
|
2215
2233
|
form: b,
|
|
2216
|
-
instance:
|
|
2234
|
+
instance: D,
|
|
2217
2235
|
options: g,
|
|
2218
2236
|
unbinds: d
|
|
2219
|
-
})), b && (
|
|
2237
|
+
})), b && (ar(r, b, m, l, T, d), T && (d.push(_(b, T, r)), d.push(bn(b))), await or(r, m, b)), i.forEach((e) => {
|
|
2220
2238
|
let t = l.on(`formie:stage:${e}:before`, async (t) => {
|
|
2221
2239
|
h(r, `formie:stage:${e}:before`, t);
|
|
2222
2240
|
}), n = l.on(`formie:stage:${e}:before`, async (e) => {
|
|
2223
|
-
for (let t of
|
|
2241
|
+
for (let t of E) t.onBeforeStage && await t.onBeforeStage(e);
|
|
2224
2242
|
}), i = l.on(`formie:stage:${e}:after`, async (t) => {
|
|
2225
2243
|
h(r, `formie:stage:${e}:after`, t);
|
|
2226
2244
|
}), a = l.on(`formie:stage:${e}:after`, async (e) => {
|
|
2227
2245
|
let t = e;
|
|
2228
|
-
for (let e of
|
|
2246
|
+
for (let e of E) e.onAfterStage && await e.onAfterStage(t, t.result);
|
|
2229
2247
|
});
|
|
2230
2248
|
d.push(t, n, i, a);
|
|
2231
2249
|
});
|
|
2232
|
-
let
|
|
2250
|
+
let re = l.on("formie:submit:before", async (e) => {
|
|
2233
2251
|
h(r, "formie:submit:before", e);
|
|
2234
|
-
}),
|
|
2252
|
+
}), ie = l.on("formie:submit:after", async (e) => {
|
|
2235
2253
|
h(r, "formie:submit:after", e);
|
|
2236
|
-
}),
|
|
2254
|
+
}), ae = l.on("formie:submit:final:before", async (e) => {
|
|
2237
2255
|
h(r, "formie:submit:final:before", e);
|
|
2238
|
-
}),
|
|
2256
|
+
}), oe = l.on("formie:submit:final:after", async (e) => {
|
|
2239
2257
|
h(r, "formie:submit:final:after", e);
|
|
2240
2258
|
});
|
|
2241
|
-
return d.push(
|
|
2259
|
+
return d.push(re, ie, ae, oe), e.set(r, {
|
|
2242
2260
|
options: m,
|
|
2243
2261
|
bus: l,
|
|
2244
2262
|
form: b,
|
|
2245
|
-
validator:
|
|
2246
|
-
modules:
|
|
2263
|
+
validator: T,
|
|
2264
|
+
modules: E,
|
|
2247
2265
|
unbinds: d,
|
|
2248
|
-
instance:
|
|
2266
|
+
instance: D
|
|
2249
2267
|
}), h(r, "formie:mount:after", {
|
|
2250
2268
|
id: f,
|
|
2251
2269
|
mode: m.mode
|
|
@@ -2253,9 +2271,9 @@ function ar() {
|
|
|
2253
2271
|
id: f,
|
|
2254
2272
|
target: Q(r),
|
|
2255
2273
|
mode: m.mode
|
|
2256
|
-
}),
|
|
2274
|
+
}), D;
|
|
2257
2275
|
}, s = (t, r) => {
|
|
2258
|
-
if (!r.autoVisible ||
|
|
2276
|
+
if (!r.autoVisible || er(t) || typeof IntersectionObserver > "u") return o(t, r);
|
|
2259
2277
|
if (e.has(t)) return Promise.resolve(e.get(t)?.instance || null);
|
|
2260
2278
|
if (n.has(t)) return W.log("Mount deferred (already waiting visibility).", { target: Q(t) }), Promise.resolve(null);
|
|
2261
2279
|
let i = new IntersectionObserver((e) => {
|
|
@@ -2282,7 +2300,7 @@ function ar() {
|
|
|
2282
2300
|
...r.options,
|
|
2283
2301
|
...n
|
|
2284
2302
|
};
|
|
2285
|
-
let i =
|
|
2303
|
+
let i = ne(t, n.payload?.theme || r.options.payload?.theme || $n(t, r.form)?.theme, r.form);
|
|
2286
2304
|
return r.validator && (r.validator.config.fieldContainerErrorClass = i.fieldLayoutError || [], r.validator.config.inputErrorClass = i.fieldControlError || [], r.validator.config.messagesClass = i.fieldErrors || [], r.validator.config.messageClass = i.fieldError || []), Object.keys(i).length && h(t, "formie:theme:applied", {
|
|
2287
2305
|
hasClasses: !0,
|
|
2288
2306
|
reason: "update"
|
|
@@ -2290,7 +2308,7 @@ function ar() {
|
|
|
2290
2308
|
},
|
|
2291
2309
|
getInstance: (t) => e.get(t)?.instance || null,
|
|
2292
2310
|
refreshForCache: async (t) => {
|
|
2293
|
-
|
|
2311
|
+
jn("refreshForCache", "Global `Formie.refreshForCache()` has been deprecated. Use built-in static-cache token refresh handling instead.");
|
|
2294
2312
|
let n = null;
|
|
2295
2313
|
if (n = typeof t == "string" ? document.getElementById(t) || document.querySelector(`[data-formie-form-id="${t}"]`) : t, !n) {
|
|
2296
2314
|
W.warn("refreshForCache target not found.", { targetOrId: t });
|
|
@@ -2301,13 +2319,13 @@ function ar() {
|
|
|
2301
2319
|
W.warn("refreshForCache found no form element for target.", { target: Q(n) });
|
|
2302
2320
|
return;
|
|
2303
2321
|
}
|
|
2304
|
-
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s =
|
|
2322
|
+
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s = Fn(a, n), c = i.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2305
2323
|
if (!o) {
|
|
2306
2324
|
W.warn("refreshForCache found no form handle for target.", { target: Q(n) });
|
|
2307
2325
|
return;
|
|
2308
2326
|
}
|
|
2309
|
-
let l = await
|
|
2310
|
-
l && (
|
|
2327
|
+
let l = await j(s, o, c);
|
|
2328
|
+
l && (nr(i, l), h(n, "formie:refresh-tokens:after", l));
|
|
2311
2329
|
},
|
|
2312
2330
|
registerModule: (e, n) => t.register(e, n),
|
|
2313
2331
|
unregisterModule: (e) => {
|
|
@@ -2348,7 +2366,7 @@ function ar() {
|
|
|
2348
2366
|
subtree: !0
|
|
2349
2367
|
}), () => {
|
|
2350
2368
|
i.disconnect(), W.log("Observer stopped."), n.forEach((e, t) => {
|
|
2351
|
-
|
|
2369
|
+
tr(t, r) && (e(), n.delete(t));
|
|
2352
2370
|
});
|
|
2353
2371
|
let t = [];
|
|
2354
2372
|
r instanceof Element && r.matches(U) && t.push(r), r.querySelectorAll(U).forEach((e) => {
|
|
@@ -2362,9 +2380,9 @@ function ar() {
|
|
|
2362
2380
|
}
|
|
2363
2381
|
//#endregion
|
|
2364
2382
|
//#region src/js/core/hydrate-modules.ts
|
|
2365
|
-
var
|
|
2366
|
-
async function
|
|
2367
|
-
let t = e.root, n = e.form ?? (t instanceof HTMLFormElement ? t : t.closest("form")), r = e.modules ?? [], i = e.mode ?? "server-rendered", a = e.registry ?? new
|
|
2383
|
+
var cr = S("general", "module-hydrator");
|
|
2384
|
+
async function lr(e) {
|
|
2385
|
+
let t = e.root, n = e.form ?? (t instanceof HTMLFormElement ? t : t.closest("form")), r = e.modules ?? [], i = e.mode ?? "server-rendered", a = e.registry ?? new L(), o = new Ie(), s = await sn(r, {
|
|
2368
2386
|
registry: a,
|
|
2369
2387
|
setupContext: {
|
|
2370
2388
|
formId: n?.id || t.id || "formie-modules",
|
|
@@ -2385,13 +2403,13 @@ async function sr(e) {
|
|
|
2385
2403
|
mode: i
|
|
2386
2404
|
}
|
|
2387
2405
|
});
|
|
2388
|
-
return
|
|
2406
|
+
return cr.log("Hydrated module manifest.", {
|
|
2389
2407
|
moduleCount: r.length,
|
|
2390
2408
|
instanceCount: s.length,
|
|
2391
2409
|
mode: i
|
|
2392
2410
|
}), {
|
|
2393
2411
|
destroy: async () => {
|
|
2394
|
-
await
|
|
2412
|
+
await ur(s), o.clear();
|
|
2395
2413
|
},
|
|
2396
2414
|
on: (e, t) => o.on(e, t),
|
|
2397
2415
|
emit: async (e, t) => {
|
|
@@ -2404,11 +2422,11 @@ async function sr(e) {
|
|
|
2404
2422
|
getRegisteredModules: () => a.getAll()
|
|
2405
2423
|
};
|
|
2406
2424
|
}
|
|
2407
|
-
async function
|
|
2425
|
+
async function ur(e) {
|
|
2408
2426
|
for (let t of e) try {
|
|
2409
2427
|
await t.destroy();
|
|
2410
2428
|
} catch (e) {
|
|
2411
|
-
console.error("[formie] Failed to destroy module instance.", e),
|
|
2429
|
+
console.error("[formie] Failed to destroy module instance.", e), cr.warn("Failed destroying module instance.", { error: e });
|
|
2412
2430
|
}
|
|
2413
2431
|
}
|
|
2414
2432
|
//#endregion
|
|
@@ -2416,41 +2434,41 @@ async function cr(e) {
|
|
|
2416
2434
|
function $(e) {
|
|
2417
2435
|
return e instanceof Element;
|
|
2418
2436
|
}
|
|
2419
|
-
function
|
|
2437
|
+
function dr(e) {
|
|
2420
2438
|
return e.ok;
|
|
2421
2439
|
}
|
|
2422
|
-
function
|
|
2440
|
+
function fr(e) {
|
|
2423
2441
|
return typeof e == "string" ? `selector "${e}"` : $(e) ? `element "${e.tagName.toLowerCase()}"` : "provided element collection";
|
|
2424
2442
|
}
|
|
2425
|
-
function
|
|
2443
|
+
function pr(e) {
|
|
2426
2444
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2427
2445
|
for (let r of e) !$(r) || t.has(r) || (t.add(r), n.push(r));
|
|
2428
2446
|
return n;
|
|
2429
2447
|
}
|
|
2430
|
-
function
|
|
2431
|
-
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : $(e) ? [e] :
|
|
2448
|
+
function mr(e) {
|
|
2449
|
+
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : $(e) ? [e] : pr(e);
|
|
2432
2450
|
}
|
|
2433
|
-
function
|
|
2451
|
+
function hr() {
|
|
2434
2452
|
return document.readyState === "loading" ? new Promise((e) => {
|
|
2435
2453
|
document.addEventListener("DOMContentLoaded", () => e(), { once: !0 });
|
|
2436
2454
|
}) : Promise.resolve();
|
|
2437
2455
|
}
|
|
2438
|
-
async function
|
|
2439
|
-
let t =
|
|
2440
|
-
return t.length > 0 || typeof e != "string" ? t : (await
|
|
2456
|
+
async function gr(e) {
|
|
2457
|
+
let t = mr(e);
|
|
2458
|
+
return t.length > 0 || typeof e != "string" ? t : (await hr(), mr(e));
|
|
2441
2459
|
}
|
|
2442
|
-
function
|
|
2460
|
+
function _r(e) {
|
|
2443
2461
|
return typeof e == "string" ? document : $(e) ? e.getRootNode() : document;
|
|
2444
2462
|
}
|
|
2445
|
-
function
|
|
2463
|
+
function vr(e) {
|
|
2446
2464
|
let { element: t, observe: n, allowEmpty: r, client: i, onReady: a, onResult: o, onSuccess: s, onError: c, onEvent: l, ...u } = e;
|
|
2447
2465
|
return {
|
|
2448
2466
|
mode: "server-rendered",
|
|
2449
2467
|
...u
|
|
2450
2468
|
};
|
|
2451
2469
|
}
|
|
2452
|
-
async function
|
|
2453
|
-
let i = [], o =
|
|
2470
|
+
async function yr(e, t, n, r) {
|
|
2471
|
+
let i = [], o = vr(e);
|
|
2454
2472
|
for (let s of r) {
|
|
2455
2473
|
let r = n.get(s);
|
|
2456
2474
|
if (r) {
|
|
@@ -2460,7 +2478,7 @@ async function _r(e, t, n, r) {
|
|
|
2460
2478
|
let c = await t.mount(s, o), l = [];
|
|
2461
2479
|
if (e.onReady?.(c), l.push(c.on("formie:submit:result", (t) => {
|
|
2462
2480
|
let n = t;
|
|
2463
|
-
e.onResult?.(n, c),
|
|
2481
|
+
e.onResult?.(n, c), dr(n) ? e.onSuccess?.(n, c) : e.onError?.(n, c);
|
|
2464
2482
|
})), e.onEvent) for (let t of a) l.push(c.on(t, (n) => {
|
|
2465
2483
|
e.onEvent?.({
|
|
2466
2484
|
name: t,
|
|
@@ -2474,11 +2492,11 @@ async function _r(e, t, n, r) {
|
|
|
2474
2492
|
}
|
|
2475
2493
|
return i;
|
|
2476
2494
|
}
|
|
2477
|
-
async function
|
|
2478
|
-
let t = e.client ??
|
|
2479
|
-
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${
|
|
2480
|
-
await
|
|
2481
|
-
let i = e.observe ? t.observe(
|
|
2495
|
+
async function br(e) {
|
|
2496
|
+
let t = e.client ?? sr(), n = /* @__PURE__ */ new Map(), r = await gr(e.element);
|
|
2497
|
+
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${fr(e.element)}.`);
|
|
2498
|
+
await yr(e, t, n, r);
|
|
2499
|
+
let i = e.observe ? t.observe(_r(e.element)) : null;
|
|
2482
2500
|
return {
|
|
2483
2501
|
client: t,
|
|
2484
2502
|
get instances() {
|
|
@@ -2489,8 +2507,8 @@ async function vr(e) {
|
|
|
2489
2507
|
return r ? n.get(r)?.instance ?? t.getInstance(r) : null;
|
|
2490
2508
|
},
|
|
2491
2509
|
async rescan() {
|
|
2492
|
-
let r =
|
|
2493
|
-
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) :
|
|
2510
|
+
let r = mr(e.element);
|
|
2511
|
+
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) : yr(e, t, n, r);
|
|
2494
2512
|
},
|
|
2495
2513
|
async destroy() {
|
|
2496
2514
|
i?.();
|
|
@@ -2500,4 +2518,4 @@ async function vr(e) {
|
|
|
2500
2518
|
};
|
|
2501
2519
|
}
|
|
2502
2520
|
//#endregion
|
|
2503
|
-
export { a as FORMIE_HTML_EVENT_NAMES,
|
|
2521
|
+
export { a as FORMIE_HTML_EVENT_NAMES, mt as FormieValidator, ge as LEGACY_FORMIE_DOM_EVENT_BRIDGES, _e as LEGACY_FORMIE_VALIDATOR_EVENT_BRIDGES, L as ModuleRegistry, Ce as bindLegacyDomEventCompatibility, we as bindLegacyValidatorCompatibility, pe as buildFieldValueRegistry, S as createDebug, sr as createFormieClient, ee as debugLog, te as debugWarn, he as defineAddressModule, se as defineCaptchaModule, oe as definePassiveCaptchaModule, v as definePaymentModule, ue as fieldKeyToInputName, br as formie, i as getFieldModuleEventName, ae as getFormieTranslations, r as getGlobalModuleLifecycleEventName, e as getScopedModuleLifecycleEventName, lr as hydrateFormieModules, ce as inputNameToFieldKey, x as isFormieDebugEnabled, re as mergeFormieTranslations, le as normalizeFieldKey, o as normalizeFormieEventName, de as parseFieldReference, me as resolveFieldReferenceFromFormData, fe as resolveFieldReferenceLive, ve as resolveLegacyCompatibilityOptions, b as setFormieDebugEnabled, ie as setFormieTranslations, D as t, t as toDomEventName, E as translate };
|