@verbb/formie-browser 4.0.8 → 4.0.9-next.15.g698e7c066059
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 +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +490 -421
- package/dist/js/core/craft-forms.d.ts +12 -0
- package/dist/js/core/craft-forms.d.ts.map +1 -0
- package/package.json +6 -4
- package/src/index.ts +2 -0
- package/src/js/core/craft-forms.ts +139 -0
package/dist/index.js
CHANGED
|
@@ -199,65 +199,65 @@ function Me({ target: e, form: t, validatorDetail: n, options: r, unbinds: i })
|
|
|
199
199
|
}
|
|
200
200
|
//#endregion
|
|
201
201
|
//#region src/js/core/error-aria-live.ts
|
|
202
|
-
function
|
|
202
|
+
function P(e) {
|
|
203
203
|
let t = (e.dataset.formieErrorAriaLive || "polite").trim().toLowerCase();
|
|
204
204
|
return t === "assertive" || t === "off" ? t : "polite";
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function Ne(e, t) {
|
|
207
207
|
return e === "off" ? null : t ? e : "polite";
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function Pe(e) {
|
|
210
210
|
return e === "off" ? null : e;
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function Fe(e, t) {
|
|
213
213
|
t ? (e.setAttribute("aria-live", t), e.setAttribute("aria-atomic", "true")) : (e.removeAttribute("aria-live"), e.removeAttribute("aria-atomic"));
|
|
214
214
|
}
|
|
215
215
|
//#endregion
|
|
216
216
|
//#region src/js/core/field-error-aria.ts
|
|
217
|
-
function
|
|
217
|
+
function Ie(e, t) {
|
|
218
218
|
let n = (e.getAttribute("aria-describedby") || "").trim(), r = n ? n.split(/\s+/) : [];
|
|
219
219
|
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function Le(e, t = document) {
|
|
222
222
|
let n = (e.getAttribute("aria-describedby") || "").trim();
|
|
223
223
|
if (!n) return;
|
|
224
224
|
let r = n.split(/\s+/).filter((e) => !!e && !!t.getElementById(e));
|
|
225
225
|
r.length ? e.setAttribute("aria-describedby", r.join(" ")) : e.removeAttribute("aria-describedby");
|
|
226
226
|
}
|
|
227
|
-
function
|
|
228
|
-
e.setAttribute("aria-errormessage", t),
|
|
227
|
+
function Re(e, t) {
|
|
228
|
+
e.setAttribute("aria-errormessage", t), Ie(e, t);
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function ze(e, t = []) {
|
|
231
231
|
t.forEach((t) => {
|
|
232
232
|
e.getAttribute("aria-errormessage") === t && e.removeAttribute("aria-errormessage");
|
|
233
|
-
}), !t.length && e.hasAttribute("aria-errormessage") && e.removeAttribute("aria-errormessage"),
|
|
233
|
+
}), !t.length && e.hasAttribute("aria-errormessage") && e.removeAttribute("aria-errormessage"), Le(e);
|
|
234
234
|
}
|
|
235
235
|
//#endregion
|
|
236
236
|
//#region src/js/core/validation-focus.ts
|
|
237
|
-
function
|
|
237
|
+
function Be(e) {
|
|
238
238
|
return Array.from(e.querySelectorAll("[data-formie-field-handle]")).find((e) => e.getAttribute("data-formie-field-has-error") === "true" || e.querySelector("[data-formie-field-error]") !== null) || null;
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function Ve(e) {
|
|
241
241
|
if (e instanceof HTMLTextAreaElement) {
|
|
242
242
|
let t = e.richText;
|
|
243
243
|
if (t) return t.content;
|
|
244
244
|
}
|
|
245
245
|
return e;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function He(e) {
|
|
248
248
|
for (let t of e) {
|
|
249
|
-
let e =
|
|
249
|
+
let e = Ve(t);
|
|
250
250
|
if (!(e instanceof HTMLInputElement && e.type === "hidden") && e.getClientRects().length > 0) return e;
|
|
251
251
|
}
|
|
252
252
|
return null;
|
|
253
253
|
}
|
|
254
|
-
function
|
|
255
|
-
return
|
|
254
|
+
function Ue(e) {
|
|
255
|
+
return He(Array.from(e.querySelectorAll("[aria-invalid=\"true\"]")).filter((e) => !j(e))) || He(Array.from(e.querySelectorAll("input:not([type=\"hidden\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])")));
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function We(e) {
|
|
258
258
|
return e.querySelector("[data-formie-message-error], [data-formie-error-container], [data-formie-errors]");
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function Ge(e) {
|
|
261
261
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
262
262
|
let n = t, r = Array.from(n.querySelectorAll("[data-formie-field-error]")), i = r.some((e) => e.closest("[data-formie-field-handle]") === n), a = n.getAttribute("data-formie-field-has-error") === "true" && r.length === 0;
|
|
263
263
|
if (!i && !a) return;
|
|
@@ -266,23 +266,23 @@ function Ke(e) {
|
|
|
266
266
|
n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
267
267
|
let r = t;
|
|
268
268
|
if (j(r)) return;
|
|
269
|
-
r.setAttribute("aria-invalid", "true"), A(r, e, "fieldControlError"), r.setAttribute("data-formie-input-has-error", "true"), o &&
|
|
269
|
+
r.setAttribute("aria-invalid", "true"), A(r, e, "fieldControlError"), r.setAttribute("data-formie-input-has-error", "true"), o && Re(r, o);
|
|
270
270
|
let i = n.querySelector("[data-formie-instructions]");
|
|
271
|
-
i?.id &&
|
|
271
|
+
i?.id && Ie(r, i.id);
|
|
272
272
|
});
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
|
-
function
|
|
276
|
-
return !!
|
|
275
|
+
function Ke(e) {
|
|
276
|
+
return !!Be(e) || !!We(e);
|
|
277
277
|
}
|
|
278
|
-
function
|
|
278
|
+
function qe(e) {
|
|
279
279
|
let t = document.activeElement;
|
|
280
|
-
(!t || t === document.body || t.getClientRects().length === 0) &&
|
|
280
|
+
(!t || t === document.body || t.getClientRects().length === 0) && F(e);
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
let t =
|
|
282
|
+
function F(e) {
|
|
283
|
+
let t = Be(e);
|
|
284
284
|
if (t) {
|
|
285
|
-
let e =
|
|
285
|
+
let e = Ue(t);
|
|
286
286
|
if (e) {
|
|
287
287
|
if (e.scrollIntoView({
|
|
288
288
|
behavior: "smooth",
|
|
@@ -299,7 +299,7 @@ function P(e) {
|
|
|
299
299
|
block: "center"
|
|
300
300
|
}), !0;
|
|
301
301
|
}
|
|
302
|
-
let n =
|
|
302
|
+
let n = We(e);
|
|
303
303
|
return n ? (n.scrollIntoView({
|
|
304
304
|
behavior: "smooth",
|
|
305
305
|
block: "center"
|
|
@@ -307,8 +307,8 @@ function P(e) {
|
|
|
307
307
|
}
|
|
308
308
|
//#endregion
|
|
309
309
|
//#region src/js/transport/forms-api.ts
|
|
310
|
-
var
|
|
311
|
-
function
|
|
310
|
+
var I = O("general", "transport");
|
|
311
|
+
function Je(e) {
|
|
312
312
|
let t = {};
|
|
313
313
|
return [
|
|
314
314
|
"theme",
|
|
@@ -319,7 +319,7 @@ function Ye(e) {
|
|
|
319
319
|
e[n] !== void 0 && (t[n] = e[n]);
|
|
320
320
|
}), t;
|
|
321
321
|
}
|
|
322
|
-
function
|
|
322
|
+
function Ye(e, t) {
|
|
323
323
|
let n = e.success === !0, r = e.completion && typeof e.completion == "object" ? e.completion : null, i = e.payment && typeof e.payment == "object" ? e.payment : null, a = [
|
|
324
324
|
"requiresAction",
|
|
325
325
|
"pending",
|
|
@@ -360,12 +360,12 @@ function Xe(e, t) {
|
|
|
360
360
|
meta: e
|
|
361
361
|
};
|
|
362
362
|
}
|
|
363
|
-
async function
|
|
363
|
+
async function Xe(e, t, n = {}, r = {}) {
|
|
364
364
|
let i = JSON.stringify({
|
|
365
365
|
handle: t,
|
|
366
366
|
renderOptions: n
|
|
367
367
|
});
|
|
368
|
-
|
|
368
|
+
I.log("requestRender start.", {
|
|
369
369
|
endpoint: e,
|
|
370
370
|
handle: t
|
|
371
371
|
});
|
|
@@ -375,17 +375,17 @@ async function Ze(e, t, n = {}, r = {}) {
|
|
|
375
375
|
body: i,
|
|
376
376
|
headers: { "Content-Type": "application/json" }
|
|
377
377
|
});
|
|
378
|
-
return
|
|
378
|
+
return I.log("requestRender complete.", { hasHtml: !!a.html }), a;
|
|
379
379
|
}
|
|
380
|
-
async function
|
|
380
|
+
async function Ze(e, t, n = {}, r = {}) {
|
|
381
381
|
let i = JSON.stringify({
|
|
382
382
|
query: "\nquery FormieHtmlForm($handle: String!, $input: ServerRenderPayloadInput) {\n formieHtmlForm(handle: $handle, input: $input) {\n html\n }\n}",
|
|
383
383
|
variables: {
|
|
384
384
|
handle: t,
|
|
385
|
-
input:
|
|
385
|
+
input: Je(n)
|
|
386
386
|
}
|
|
387
387
|
});
|
|
388
|
-
|
|
388
|
+
I.log("requestGraphqlRender start.", {
|
|
389
389
|
endpoint: e,
|
|
390
390
|
handle: t
|
|
391
391
|
});
|
|
@@ -398,19 +398,19 @@ async function Qe(e, t, n = {}, r = {}) {
|
|
|
398
398
|
if (Array.isArray(a.errors) && a.errors.length > 0) throw Error(a.errors.map((e) => e.message || "Unknown GraphQL error").join("; "));
|
|
399
399
|
if (!a.data?.formieHtmlForm) throw Error(`Form not found for handle "${t}".`);
|
|
400
400
|
let o = a.data.formieHtmlForm;
|
|
401
|
-
return
|
|
401
|
+
return I.log("requestGraphqlRender complete.", { hasHtml: !!o.html }), o;
|
|
402
402
|
}
|
|
403
|
-
async function
|
|
403
|
+
async function Qe(e, t, n, r = {}, i, a) {
|
|
404
404
|
let o = new URL(e, window.location.origin);
|
|
405
|
-
o.searchParams.set("handle", t), a !== void 0 && a !== "" && o.searchParams.set("siteId", String(a)), n && o.searchParams.set("renderId", n), i && o.searchParams.set("requestToken", i),
|
|
405
|
+
o.searchParams.set("handle", t), a !== void 0 && a !== "" && o.searchParams.set("siteId", String(a)), n && o.searchParams.set("renderId", n), i && o.searchParams.set("requestToken", i), I.log("requestRefreshTokens start.", {
|
|
406
406
|
endpoint: o.toString(),
|
|
407
407
|
handle: t,
|
|
408
408
|
hasRenderId: !!n
|
|
409
409
|
});
|
|
410
410
|
let s = await M(o.toString(), r);
|
|
411
|
-
return
|
|
411
|
+
return I.log("requestRefreshTokens complete.", { hasRefreshTokens: !!s.refreshTokens }), s.refreshTokens || s;
|
|
412
412
|
}
|
|
413
|
-
async function
|
|
413
|
+
async function $e(e, t, n) {
|
|
414
414
|
let r = new URL(e, window.location.origin), i = new FormData();
|
|
415
415
|
if (n && i.append("pageId", n), t) {
|
|
416
416
|
[
|
|
@@ -427,7 +427,7 @@ async function et(e, t, n) {
|
|
|
427
427
|
}), ae(i, t);
|
|
428
428
|
for (let [e, n] of new FormData(t)) e.startsWith("fields[") && i.append(e, n);
|
|
429
429
|
}
|
|
430
|
-
|
|
430
|
+
I.log("requestSetPage start.", {
|
|
431
431
|
requestUrl: r.toString(),
|
|
432
432
|
pageId: n || null
|
|
433
433
|
});
|
|
@@ -440,9 +440,9 @@ async function et(e, t, n) {
|
|
|
440
440
|
let e = a.session, n = t.querySelector("input[name=\"expectedVersion\"]"), r = t.querySelector("input[name=\"requestToken\"]");
|
|
441
441
|
n && (n.value = String(e.version)), r && e.tokens?.request && (r.value = e.tokens.request);
|
|
442
442
|
}
|
|
443
|
-
return
|
|
443
|
+
return I.log("requestSetPage complete.", a), a;
|
|
444
444
|
}
|
|
445
|
-
function
|
|
445
|
+
function et(e, t) {
|
|
446
446
|
let n = new URL(e, window.location.origin), i = new FormData();
|
|
447
447
|
[
|
|
448
448
|
"handle",
|
|
@@ -452,7 +452,7 @@ function tt(e, t) {
|
|
|
452
452
|
].forEach((e) => {
|
|
453
453
|
let n = t.querySelector(`input[name="${e}"]`)?.value?.trim();
|
|
454
454
|
n && i.append(e, n);
|
|
455
|
-
}), ae(i, t),
|
|
455
|
+
}), ae(i, t), I.log("clearSubmissionOnUnload start.", { requestUrl: n.toString() });
|
|
456
456
|
try {
|
|
457
457
|
if (t.dataset.formieRequestProfile !== "cross-origin-public" && typeof navigator.sendBeacon == "function" && navigator.sendBeacon(n.toString(), i)) return;
|
|
458
458
|
} catch {}
|
|
@@ -463,9 +463,9 @@ function tt(e, t) {
|
|
|
463
463
|
headers: { Accept: "application/json" }
|
|
464
464
|
}, { profile: t.dataset.formieRequestProfile });
|
|
465
465
|
}
|
|
466
|
-
async function
|
|
466
|
+
async function tt(e, t) {
|
|
467
467
|
let n = (e.getAttribute("method") || "POST").toUpperCase(), i = e.getAttribute("action") || window.location.href, a = e.dataset.formieErrorMessage?.trim() || "Submission failed.";
|
|
468
|
-
|
|
468
|
+
I.log("submitForm start.", {
|
|
469
469
|
method: n,
|
|
470
470
|
action: i,
|
|
471
471
|
submitAction: t.get("submitAction")
|
|
@@ -475,13 +475,13 @@ async function nt(e, t) {
|
|
|
475
475
|
body: t,
|
|
476
476
|
headers: { Accept: "application/json" }
|
|
477
477
|
}, { profile: e.dataset.formieRequestProfile }), s = o.headers.get("content-type") || "";
|
|
478
|
-
if (!s.includes("application/json")) return o.ok ? (
|
|
478
|
+
if (!s.includes("application/json")) return o.ok ? (I.log("submitForm non-JSON success response.", {
|
|
479
479
|
status: o.status,
|
|
480
480
|
contentType: s
|
|
481
481
|
}), {
|
|
482
482
|
ok: !0,
|
|
483
483
|
message: "Submission completed."
|
|
484
|
-
}) : (
|
|
484
|
+
}) : (I.warn("submitForm non-JSON HTTP error.", {
|
|
485
485
|
status: o.status,
|
|
486
486
|
contentType: s
|
|
487
487
|
}), {
|
|
@@ -490,8 +490,8 @@ async function nt(e, t) {
|
|
|
490
490
|
message: `Request failed (${o.status}).`,
|
|
491
491
|
formErrors: [`Request failed (${o.status}).`]
|
|
492
492
|
});
|
|
493
|
-
let c =
|
|
494
|
-
return
|
|
493
|
+
let c = Ye(await o.json(), a);
|
|
494
|
+
return I.log("submitForm JSON response normalized.", {
|
|
495
495
|
ok: c.ok,
|
|
496
496
|
code: c.code,
|
|
497
497
|
hasRedirect: !!c.redirect?.url,
|
|
@@ -500,20 +500,20 @@ async function nt(e, t) {
|
|
|
500
500
|
}
|
|
501
501
|
//#endregion
|
|
502
502
|
//#region src/js/submit/pipeline.ts
|
|
503
|
-
var
|
|
503
|
+
var nt = [
|
|
504
504
|
"prepare",
|
|
505
505
|
"validate",
|
|
506
506
|
"challenge",
|
|
507
507
|
"payment",
|
|
508
508
|
"send",
|
|
509
509
|
"result"
|
|
510
|
-
],
|
|
510
|
+
], rt = [
|
|
511
511
|
"prepare",
|
|
512
512
|
"validate",
|
|
513
513
|
"challenge",
|
|
514
514
|
"payment"
|
|
515
|
-
],
|
|
516
|
-
function
|
|
515
|
+
], L = O("general", "pipeline");
|
|
516
|
+
function it(e, t) {
|
|
517
517
|
return {
|
|
518
518
|
ok: !1,
|
|
519
519
|
stage: e,
|
|
@@ -522,13 +522,13 @@ function at(e, t) {
|
|
|
522
522
|
formErrors: [t || "Submission aborted."]
|
|
523
523
|
};
|
|
524
524
|
}
|
|
525
|
-
function
|
|
525
|
+
function at(e) {
|
|
526
526
|
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
|
|
527
527
|
}
|
|
528
|
-
function
|
|
528
|
+
function ot(e) {
|
|
529
529
|
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)));
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function st(e, t) {
|
|
532
532
|
if (t instanceof HTMLInputElement) {
|
|
533
533
|
if (t.type === "file") {
|
|
534
534
|
Array.from(t.files || []).forEach((n) => {
|
|
@@ -541,49 +541,49 @@ function ct(e, t) {
|
|
|
541
541
|
e.append(t.name, n.value);
|
|
542
542
|
}) : e.append(t.name, t.value);
|
|
543
543
|
}
|
|
544
|
-
function
|
|
544
|
+
function ct(e, t) {
|
|
545
545
|
t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
546
|
-
let n =
|
|
547
|
-
n && !n.closest("[data-formie-page]") &&
|
|
546
|
+
let n = at(t) ? t : null;
|
|
547
|
+
n && !n.closest("[data-formie-page]") && ot(n) && st(e, n);
|
|
548
548
|
});
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function lt(e, t) {
|
|
551
551
|
let n = /* @__PURE__ */ new Set();
|
|
552
552
|
return t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
553
|
-
let r =
|
|
554
|
-
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),
|
|
553
|
+
let r = at(t) ? t : null;
|
|
554
|
+
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), ot(r) && st(e, r)));
|
|
555
555
|
}), n;
|
|
556
556
|
}
|
|
557
|
-
function
|
|
557
|
+
function ut(e, t) {
|
|
558
558
|
t.forEach((t) => {
|
|
559
559
|
e.has(t) || e.append(t, "");
|
|
560
560
|
});
|
|
561
561
|
}
|
|
562
|
-
function
|
|
562
|
+
function dt(e, t) {
|
|
563
563
|
let n = T(e), r = n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || null;
|
|
564
564
|
if (!n.length || !r) {
|
|
565
565
|
let n = new FormData(e);
|
|
566
566
|
return n.set("submitAction", t), n;
|
|
567
567
|
}
|
|
568
568
|
let i = new FormData();
|
|
569
|
-
return
|
|
569
|
+
return ct(i, e), ut(i, lt(i, r)), i.set("submitAction", t), i;
|
|
570
570
|
}
|
|
571
|
-
function
|
|
571
|
+
function ft(e, t) {
|
|
572
572
|
if (t !== "submit") return !1;
|
|
573
573
|
let n = T(e);
|
|
574
574
|
return !n.length || (n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || n[n.length - 1]) === n[n.length - 1];
|
|
575
575
|
}
|
|
576
|
-
async function
|
|
577
|
-
|
|
576
|
+
async function pt(e, t, n, r = {}) {
|
|
577
|
+
L.log("Starting submit pipeline.", {
|
|
578
578
|
action: t,
|
|
579
579
|
preflightOnly: r.preflightOnly === !0
|
|
580
580
|
});
|
|
581
|
-
let i = !1, a, o = null, s =
|
|
581
|
+
let i = !1, a, o = null, s = ft(e, t), c = d(e, {
|
|
582
582
|
form: e,
|
|
583
583
|
action: t,
|
|
584
|
-
formData:
|
|
584
|
+
formData: dt(e, t),
|
|
585
585
|
abort: (e) => {
|
|
586
|
-
i = !0, a = e,
|
|
586
|
+
i = !0, a = e, L.warn("Pipeline aborted.", { reason: e });
|
|
587
587
|
},
|
|
588
588
|
isAborted: () => i,
|
|
589
589
|
abortReason: () => a
|
|
@@ -631,68 +631,68 @@ async function mt(e, t, n, r = {}) {
|
|
|
631
631
|
challenge: async () => null,
|
|
632
632
|
payment: async () => null,
|
|
633
633
|
send: async (e) => {
|
|
634
|
-
e.formData =
|
|
635
|
-
let t = await
|
|
634
|
+
e.formData = dt(e.form, e.action);
|
|
635
|
+
let t = await tt(e.form, e.formData);
|
|
636
636
|
return o = t, t;
|
|
637
637
|
},
|
|
638
638
|
result: async (e) => (o && o.ok && o.redirect?.url && (o.redirect.target === "new-tab" ? window.open(o.redirect.url, "_blank", "noopener,noreferrer") : (e.form.setAttribute("data-formie-internal-navigation", "redirect"), window.location.href = o.redirect.url)), null)
|
|
639
639
|
};
|
|
640
640
|
{
|
|
641
641
|
let e = await n.emitSafe("formie:submit:before", c);
|
|
642
|
-
e.failed.length > 0 &&
|
|
642
|
+
e.failed.length > 0 && L.warn("Submit before listeners failed.", {
|
|
643
643
|
eventName: e.eventName,
|
|
644
644
|
failed: e.failed.length
|
|
645
645
|
});
|
|
646
646
|
}
|
|
647
647
|
if (s) {
|
|
648
648
|
let e = await n.emitSafe("formie:submit:final:before", c);
|
|
649
|
-
e.failed.length > 0 &&
|
|
649
|
+
e.failed.length > 0 && L.warn("Final submit before listeners failed.", {
|
|
650
650
|
eventName: e.eventName,
|
|
651
651
|
failed: e.failed.length
|
|
652
652
|
});
|
|
653
653
|
}
|
|
654
|
-
let f = r.preflightOnly ?
|
|
654
|
+
let f = r.preflightOnly ? rt : nt;
|
|
655
655
|
for (let e of f) {
|
|
656
|
-
if (
|
|
656
|
+
if (L.log("Stage start.", {
|
|
657
657
|
stage: e,
|
|
658
658
|
action: t
|
|
659
|
-
}), i) return
|
|
659
|
+
}), i) return L.warn("Stage skipped due to abort.", {
|
|
660
660
|
stage: e,
|
|
661
661
|
reason: a
|
|
662
|
-
}),
|
|
662
|
+
}), it(e, a);
|
|
663
663
|
{
|
|
664
664
|
let t = await n.emitSafe(`formie:stage:${e}:before`, {
|
|
665
665
|
...c,
|
|
666
666
|
stage: e
|
|
667
667
|
});
|
|
668
|
-
t.failed.length > 0 &&
|
|
668
|
+
t.failed.length > 0 && L.warn("Stage before listeners failed.", {
|
|
669
669
|
stage: e,
|
|
670
670
|
failed: t.failed.length
|
|
671
671
|
});
|
|
672
672
|
}
|
|
673
673
|
if (i) {
|
|
674
|
-
let t =
|
|
674
|
+
let t = it(e, a);
|
|
675
675
|
{
|
|
676
676
|
let n = await l("formie:submit:after", t);
|
|
677
|
-
n.failed.length > 0 &&
|
|
677
|
+
n.failed.length > 0 && L.warn("Submit after listeners failed (abort before stage).", {
|
|
678
678
|
stage: e,
|
|
679
679
|
failed: n.failed.length
|
|
680
680
|
});
|
|
681
681
|
}
|
|
682
682
|
if (s) {
|
|
683
683
|
let n = await l("formie:submit:final:after", t);
|
|
684
|
-
n.failed.length > 0 &&
|
|
684
|
+
n.failed.length > 0 && L.warn("Final submit after listeners failed (abort before stage).", {
|
|
685
685
|
stage: e,
|
|
686
686
|
failed: n.failed.length
|
|
687
687
|
});
|
|
688
688
|
}
|
|
689
|
-
return
|
|
689
|
+
return L.warn("Aborted after stage before-hooks.", {
|
|
690
690
|
stage: e,
|
|
691
691
|
reason: a
|
|
692
692
|
}), t;
|
|
693
693
|
}
|
|
694
694
|
let r = await u[e](c);
|
|
695
|
-
|
|
695
|
+
L.log("Stage runner complete.", {
|
|
696
696
|
stage: e,
|
|
697
697
|
hasResult: !!r,
|
|
698
698
|
ok: r ? r.ok : void 0,
|
|
@@ -704,28 +704,28 @@ async function mt(e, t, n, r = {}) {
|
|
|
704
704
|
stage: e,
|
|
705
705
|
result: r
|
|
706
706
|
});
|
|
707
|
-
t.failed.length > 0 &&
|
|
707
|
+
t.failed.length > 0 && L.warn("Stage after listeners failed.", {
|
|
708
708
|
stage: e,
|
|
709
709
|
failed: t.failed.length
|
|
710
710
|
});
|
|
711
711
|
}
|
|
712
712
|
if (i) {
|
|
713
|
-
let t =
|
|
713
|
+
let t = it(e, a);
|
|
714
714
|
{
|
|
715
715
|
let n = await l("formie:submit:after", t);
|
|
716
|
-
n.failed.length > 0 &&
|
|
716
|
+
n.failed.length > 0 && L.warn("Submit after listeners failed (abort after stage).", {
|
|
717
717
|
stage: e,
|
|
718
718
|
failed: n.failed.length
|
|
719
719
|
});
|
|
720
720
|
}
|
|
721
721
|
if (s) {
|
|
722
722
|
let n = await l("formie:submit:final:after", t);
|
|
723
|
-
n.failed.length > 0 &&
|
|
723
|
+
n.failed.length > 0 && L.warn("Final submit after listeners failed (abort after stage).", {
|
|
724
724
|
stage: e,
|
|
725
725
|
failed: n.failed.length
|
|
726
726
|
});
|
|
727
727
|
}
|
|
728
|
-
return
|
|
728
|
+
return L.warn("Aborted after stage after-hooks.", {
|
|
729
729
|
stage: e,
|
|
730
730
|
reason: a
|
|
731
731
|
}), t;
|
|
@@ -733,19 +733,19 @@ async function mt(e, t, n, r = {}) {
|
|
|
733
733
|
if (r && !r.ok) {
|
|
734
734
|
{
|
|
735
735
|
let t = await l("formie:submit:after", r);
|
|
736
|
-
t.failed.length > 0 &&
|
|
736
|
+
t.failed.length > 0 && L.warn("Submit after listeners failed (failed stage).", {
|
|
737
737
|
stage: e,
|
|
738
738
|
failed: t.failed.length
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
741
|
if (s) {
|
|
742
742
|
let t = await l("formie:submit:final:after", r);
|
|
743
|
-
t.failed.length > 0 &&
|
|
743
|
+
t.failed.length > 0 && L.warn("Final submit after listeners failed (failed stage).", {
|
|
744
744
|
stage: e,
|
|
745
745
|
failed: t.failed.length
|
|
746
746
|
});
|
|
747
747
|
}
|
|
748
|
-
return
|
|
748
|
+
return L.warn("Pipeline short-circuited by failed stage.", {
|
|
749
749
|
stage: e,
|
|
750
750
|
code: r.code,
|
|
751
751
|
message: r.message
|
|
@@ -760,13 +760,13 @@ async function mt(e, t, n, r = {}) {
|
|
|
760
760
|
};
|
|
761
761
|
{
|
|
762
762
|
let e = await l("formie:submit:after", p);
|
|
763
|
-
e.failed.length > 0 &&
|
|
763
|
+
e.failed.length > 0 && L.warn("Submit after listeners failed (success).", { failed: e.failed.length });
|
|
764
764
|
}
|
|
765
765
|
if (s) {
|
|
766
766
|
let e = await l("formie:submit:final:after", p);
|
|
767
|
-
e.failed.length > 0 &&
|
|
767
|
+
e.failed.length > 0 && L.warn("Final submit after listeners failed (success).", { failed: e.failed.length });
|
|
768
768
|
}
|
|
769
|
-
return
|
|
769
|
+
return L.log("Pipeline completed.", {
|
|
770
770
|
ok: p.ok,
|
|
771
771
|
stage: p.stage,
|
|
772
772
|
code: p.code
|
|
@@ -774,18 +774,18 @@ async function mt(e, t, n, r = {}) {
|
|
|
774
774
|
}
|
|
775
775
|
//#endregion
|
|
776
776
|
//#region src/js/core/field-error-container.ts
|
|
777
|
-
function
|
|
777
|
+
function mt(e) {
|
|
778
778
|
return e.querySelector("[data-formie-field-layout]")?.getAttribute("data-formie-error-position")?.trim() === "above" ? "above" : "below";
|
|
779
779
|
}
|
|
780
|
-
function
|
|
780
|
+
function ht(e, t) {
|
|
781
781
|
let n = e.querySelector("[data-formie-field-errors]");
|
|
782
782
|
if (n) return n;
|
|
783
|
-
let r = e.querySelector("[data-formie-field-content]"), i = e.querySelector("[data-formie-field-control]"), a =
|
|
783
|
+
let r = e.querySelector("[data-formie-field-content]"), i = e.querySelector("[data-formie-field-control]"), a = mt(e), o = document.createElement("div");
|
|
784
784
|
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;
|
|
785
785
|
}
|
|
786
786
|
//#endregion
|
|
787
787
|
//#region src/js/theme/message-attributes.ts
|
|
788
|
-
function
|
|
788
|
+
function gt(e, t, n, r = !1) {
|
|
789
789
|
let i = t.getAttribute("data-formie-message-attributes");
|
|
790
790
|
if (!i) return;
|
|
791
791
|
let a;
|
|
@@ -802,73 +802,73 @@ function _t(e, t, n, r = !1) {
|
|
|
802
802
|
}
|
|
803
803
|
//#endregion
|
|
804
804
|
//#region src/js/core/submit-result-ui.ts
|
|
805
|
-
var
|
|
806
|
-
function
|
|
805
|
+
var R = /* @__PURE__ */ new WeakMap();
|
|
806
|
+
function _t(e) {
|
|
807
807
|
return (e.dataset.formieCompletionBehavior || e.dataset.formieSubmitAction || "").trim();
|
|
808
808
|
}
|
|
809
|
-
function
|
|
809
|
+
function vt(e) {
|
|
810
810
|
return (e.dataset.formieErrorMessagePosition ?? "top-form").trim();
|
|
811
811
|
}
|
|
812
|
-
function
|
|
812
|
+
function yt(e) {
|
|
813
813
|
return (e.dataset.formieSuccessMessagePosition || e.dataset.formieSubmitActionMessagePosition || "").trim();
|
|
814
814
|
}
|
|
815
|
-
function
|
|
815
|
+
function bt(e) {
|
|
816
816
|
let t = (e.dataset.formieSuccessMessageTimeout || e.dataset.formieSubmitActionMessageTimeout || "").trim();
|
|
817
817
|
if (!t) return null;
|
|
818
818
|
let n = Number.parseFloat(t);
|
|
819
819
|
return !Number.isFinite(n) || n < 0 ? null : Math.round(n * 1e3);
|
|
820
820
|
}
|
|
821
|
-
function
|
|
821
|
+
function xt(e) {
|
|
822
822
|
let t = e.dataset.formieHideFormAfterSubmit ?? e.dataset.formieSubmitActionFormHide;
|
|
823
823
|
if (t === void 0) return !1;
|
|
824
824
|
let n = t.trim().toLowerCase();
|
|
825
825
|
return n === "true" || n === "1" || n === "";
|
|
826
826
|
}
|
|
827
|
-
function
|
|
828
|
-
let t =
|
|
829
|
-
typeof t == "number" && (window.clearTimeout(t),
|
|
827
|
+
function St(e) {
|
|
828
|
+
let t = R.get(e);
|
|
829
|
+
typeof t == "number" && (window.clearTimeout(t), R.delete(e));
|
|
830
830
|
}
|
|
831
|
-
function
|
|
831
|
+
function Ct(e) {
|
|
832
832
|
return e.querySelector("[data-formie-form-messages-top]") || e;
|
|
833
833
|
}
|
|
834
|
-
function
|
|
834
|
+
function wt(e) {
|
|
835
835
|
return e.querySelector("[data-formie-form-messages-bottom]") || e;
|
|
836
836
|
}
|
|
837
|
-
function
|
|
838
|
-
return t === "bottom-form" ?
|
|
837
|
+
function Tt(e, t) {
|
|
838
|
+
return t === "bottom-form" ? wt(e) : Ct(e);
|
|
839
839
|
}
|
|
840
|
-
function
|
|
841
|
-
return t === "top-form" ?
|
|
840
|
+
function Et(e, t) {
|
|
841
|
+
return t === "top-form" ? Ct(e) : t === "bottom-form" && !xt(e) ? wt(e) : e;
|
|
842
842
|
}
|
|
843
|
-
function
|
|
844
|
-
let t =
|
|
843
|
+
function Dt(e) {
|
|
844
|
+
let t = vt(e), n = Tt(e, t), r = n.querySelector("[data-formie-error-container], [data-formie-errors]");
|
|
845
845
|
return r || (r = document.createElement("div"), r.setAttribute("data-formie-errors", "true"), A(r, e, "errors")), r.setAttribute("data-formie-error-container", "true"), t === "bottom-form" ? n.append(r) : n.prepend(r), r;
|
|
846
846
|
}
|
|
847
|
-
function
|
|
847
|
+
function Ot(e, t) {
|
|
848
848
|
let n = t.querySelector("[data-formie-error-message-container], [data-formie-message][data-formie-message-error]");
|
|
849
|
-
return n || (n = document.createElement("div"), n.setAttribute("data-formie-error-message-container", "true"), t.appendChild(n)),
|
|
849
|
+
return n || (n = document.createElement("div"), n.setAttribute("data-formie-error-message-container", "true"), t.appendChild(n)), gt(n, e, "messageError"), n.setAttribute("data-formie-message", "true"), n.setAttribute("data-formie-message-error", "true"), A(n, e, "message", "messageError"), n.setAttribute("role", "alert"), Fe(n, Pe(P(e))), n;
|
|
850
850
|
}
|
|
851
|
-
function
|
|
852
|
-
let n = e.querySelector("[data-formie-success-container]"), r =
|
|
851
|
+
function kt(e, t) {
|
|
852
|
+
let n = e.querySelector("[data-formie-success-container]"), r = Et(e, t);
|
|
853
853
|
return n || (n = document.createElement("div"), n.setAttribute("data-formie-success-container", "true"), A(n, e, "successes")), t === "bottom-form" ? r.append(n) : r.prepend(n), n;
|
|
854
854
|
}
|
|
855
|
-
function
|
|
856
|
-
return
|
|
855
|
+
function At(e) {
|
|
856
|
+
return ht(e, (t) => {
|
|
857
857
|
A(t, e, "fieldErrors");
|
|
858
858
|
});
|
|
859
859
|
}
|
|
860
|
-
function
|
|
860
|
+
function jt(e) {
|
|
861
861
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
862
862
|
let n = t, r = n.querySelector("[data-formie-field-errors]"), i = Array.from(n.querySelectorAll("[data-formie-field-error]")).map((e) => e.id).filter(Boolean);
|
|
863
863
|
k(n, e, "fieldLayoutError"), n.removeAttribute("data-formie-field-has-error"), n.querySelectorAll("[data-formie-field-error]").forEach((e) => {
|
|
864
864
|
e.remove();
|
|
865
865
|
}), r && !r.querySelector("[data-formie-field-error]") && (r.innerHTML = ""), n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
866
866
|
let n = t;
|
|
867
|
-
n.removeAttribute("aria-invalid"), k(n, e, "fieldControlError"), n.removeAttribute("data-formie-input-has-error"),
|
|
867
|
+
n.removeAttribute("aria-invalid"), k(n, e, "fieldControlError"), n.removeAttribute("data-formie-input-has-error"), ze(n, i);
|
|
868
868
|
});
|
|
869
869
|
}), h(e);
|
|
870
870
|
}
|
|
871
|
-
function
|
|
871
|
+
function Mt(e) {
|
|
872
872
|
e.querySelectorAll("[data-formie-error-container], [data-formie-errors]").forEach((t) => {
|
|
873
873
|
let n = t;
|
|
874
874
|
n.querySelectorAll("[data-formie-error]").forEach((e) => {
|
|
@@ -876,69 +876,69 @@ function Nt(e) {
|
|
|
876
876
|
}), k(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 = "");
|
|
877
877
|
});
|
|
878
878
|
}
|
|
879
|
-
function
|
|
880
|
-
|
|
879
|
+
function Nt(e) {
|
|
880
|
+
St(e), e.querySelectorAll("[data-formie-message-success]:not([data-formie-success-container])").forEach((e) => {
|
|
881
881
|
e.remove();
|
|
882
882
|
}), e.querySelectorAll("[data-formie-success-container]").forEach((t) => {
|
|
883
883
|
let n = t;
|
|
884
884
|
n.querySelectorAll("[data-formie-success]").forEach((e) => {
|
|
885
885
|
e.remove();
|
|
886
|
-
}),
|
|
887
|
-
}),
|
|
886
|
+
}), gt(n, e, "messageSuccess", !0), k(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 = "");
|
|
887
|
+
}), _t(e) === "message" && xt(e) || b(e, !1);
|
|
888
888
|
}
|
|
889
|
-
function
|
|
889
|
+
function Pt(e) {
|
|
890
890
|
e.querySelectorAll("[aria-invalid=\"true\"]").forEach((e) => {
|
|
891
891
|
e.removeAttribute("aria-invalid");
|
|
892
892
|
});
|
|
893
893
|
}
|
|
894
|
-
function
|
|
895
|
-
let n =
|
|
894
|
+
function Ft(e, t) {
|
|
895
|
+
let n = Pe(P(e));
|
|
896
896
|
Object.entries(t).forEach(([t, r]) => {
|
|
897
897
|
let i = `fields[${t.split(".").join("][")}]`, a = e.querySelector(`[name="${CSS.escape(i)}"], [name="${CSS.escape(i + "[]")}"]`)?.closest("[data-formie-field-handle]") || e.querySelector(`[data-formie-field-handle="${CSS.escape(t)}"]`);
|
|
898
898
|
if (!a) return;
|
|
899
|
-
let o =
|
|
900
|
-
o.id = s,
|
|
899
|
+
let o = At(a), s = o.id && o.id.trim() ? o.id : `${t}-errors`;
|
|
900
|
+
o.id = s, Fe(o, n), A(a, e, "fieldLayoutError"), a.setAttribute("data-formie-field-has-error", "true"), r.forEach((t, n) => {
|
|
901
901
|
let r = document.createElement("div");
|
|
902
902
|
r.setAttribute("data-formie-field-error", "true"), r.id = `${s}-${n + 1}`, A(r, e, "fieldError"), r.textContent = t, o.appendChild(r);
|
|
903
903
|
});
|
|
904
904
|
let c = o.querySelector("[data-formie-field-error]")?.id;
|
|
905
905
|
a.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
906
906
|
let n = t;
|
|
907
|
-
n.setAttribute("aria-invalid", "true"), A(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), c &&
|
|
907
|
+
n.setAttribute("aria-invalid", "true"), A(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), c && Re(n, c);
|
|
908
908
|
let r = a.querySelector("[data-formie-instructions]");
|
|
909
|
-
r?.id &&
|
|
909
|
+
r?.id && Ie(n, r.id);
|
|
910
910
|
});
|
|
911
911
|
}), h(e);
|
|
912
912
|
}
|
|
913
|
-
function
|
|
914
|
-
if (!
|
|
915
|
-
let n =
|
|
913
|
+
function It(e, t) {
|
|
914
|
+
if (!vt(e)) return;
|
|
915
|
+
let n = Dt(e), r = Ot(e, n);
|
|
916
916
|
A(n, e, "errors"), t.forEach((t) => {
|
|
917
917
|
let n = document.createElement("div");
|
|
918
918
|
n.setAttribute("data-formie-error", "true"), A(n, e, "error"), n.innerHTML = t, r.appendChild(n);
|
|
919
919
|
});
|
|
920
920
|
}
|
|
921
|
-
function
|
|
921
|
+
function Lt(e) {
|
|
922
922
|
if (e.ok || e.keepSubmitLoading !== !0) return !1;
|
|
923
923
|
let t = e.payment?.status;
|
|
924
924
|
return t === "requiresAction" || t === "pending" || t === "unknown";
|
|
925
925
|
}
|
|
926
|
-
function
|
|
927
|
-
let n =
|
|
926
|
+
function Rt(e, t) {
|
|
927
|
+
let n = Dt(e), r = Ot(e, n);
|
|
928
928
|
A(n, e, "errors");
|
|
929
929
|
let i = document.createElement("div");
|
|
930
930
|
i.setAttribute("data-formie-notice", "true"), i.setAttribute("role", "status"), A(i, e, "message"), i.textContent = t, r.appendChild(i);
|
|
931
931
|
}
|
|
932
|
-
function
|
|
933
|
-
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" ||
|
|
932
|
+
function zt(e, t) {
|
|
933
|
+
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" || _t(e) === "message" && yt(e) !== "";
|
|
934
934
|
}
|
|
935
|
-
function
|
|
936
|
-
let r =
|
|
935
|
+
function Bt(e, t, n = {}) {
|
|
936
|
+
let r = yt(e);
|
|
937
937
|
if (!r) return;
|
|
938
|
-
let i =
|
|
939
|
-
|
|
938
|
+
let i = kt(e, r);
|
|
939
|
+
gt(i, e, "messageSuccess"), A(i, e, "message", "messageSuccess"), i.setAttribute("data-formie-message", "true"), i.setAttribute("data-formie-message-success", "true"), i.setAttribute("role", "status"), i.setAttribute("aria-live", "polite"), i.setAttribute("aria-atomic", "true");
|
|
940
940
|
let a = document.createElement("div");
|
|
941
|
-
a.setAttribute("data-formie-success", "true"), A(a, e, "success"), a.innerHTML = t, i.appendChild(a), n.hideForm !== !1 &&
|
|
941
|
+
a.setAttribute("data-formie-success", "true"), A(a, e, "success"), a.innerHTML = t, i.appendChild(a), n.hideForm !== !1 && xt(e) && b(e, !0);
|
|
942
942
|
let o = e.dataset.formieScrollToTop?.trim().toLowerCase();
|
|
943
943
|
o !== void 0 && [
|
|
944
944
|
"",
|
|
@@ -948,45 +948,45 @@ function Vt(e, t, n = {}) {
|
|
|
948
948
|
behavior: "smooth",
|
|
949
949
|
block: "start"
|
|
950
950
|
});
|
|
951
|
-
let s =
|
|
951
|
+
let s = bt(e);
|
|
952
952
|
if (s !== null) {
|
|
953
953
|
let t = window.setTimeout(() => {
|
|
954
|
-
|
|
954
|
+
R.delete(e), Nt(e);
|
|
955
955
|
}, s);
|
|
956
|
-
|
|
956
|
+
R.set(e, t);
|
|
957
957
|
}
|
|
958
958
|
}
|
|
959
|
-
function
|
|
960
|
-
if (
|
|
959
|
+
function z(e, t) {
|
|
960
|
+
if (jt(e), Mt(e), Nt(e), Pt(e), t.ok) {
|
|
961
961
|
let n = t.meta?.summaryTokens;
|
|
962
962
|
n && typeof n == "object" && e.querySelectorAll("[data-formie-field-uid]").forEach((e) => {
|
|
963
963
|
let t = n[e.dataset.formieFieldUid || ""];
|
|
964
964
|
typeof t == "string" && t && e.querySelector("[data-formie-summary-container]")?.setAttribute("data-formie-summary-token", t);
|
|
965
|
-
}),
|
|
965
|
+
}), zt(e, t) && Bt(e, t.message || "", { hideForm: t.action !== "save" });
|
|
966
966
|
} else if (!t.ok) {
|
|
967
|
-
if (
|
|
967
|
+
if (Lt(t)) {
|
|
968
968
|
let n = String(t.payment?.message || "").trim();
|
|
969
|
-
n &&
|
|
969
|
+
n && Rt(e, n);
|
|
970
970
|
return;
|
|
971
971
|
}
|
|
972
|
-
t.fieldErrors &&
|
|
972
|
+
t.fieldErrors && Ft(e, t.fieldErrors), t.formErrors?.length ? It(e, t.formErrors) : !t.fieldErrors && t.message && It(e, [t.message]), F(e);
|
|
973
973
|
}
|
|
974
974
|
}
|
|
975
975
|
//#endregion
|
|
976
976
|
//#region src/js/core/submit-flow.ts
|
|
977
|
-
var
|
|
978
|
-
function
|
|
977
|
+
var Vt = O("general", "submit-flow");
|
|
978
|
+
function Ht(e) {
|
|
979
979
|
return !(!e.ok && e.stage === "validate");
|
|
980
980
|
}
|
|
981
|
-
function
|
|
981
|
+
function Ut(e) {
|
|
982
982
|
return e ? !!(e.keepSubmitLoading === !0 || e.ok && e.redirect?.url && e.redirect.target !== "new-tab") : !1;
|
|
983
983
|
}
|
|
984
|
-
function
|
|
985
|
-
|
|
984
|
+
function Wt(e) {
|
|
985
|
+
jt(e), Mt(e), Nt(e), Pt(e);
|
|
986
986
|
}
|
|
987
|
-
async function
|
|
987
|
+
async function Gt(e) {
|
|
988
988
|
let { id: t, target: n, form: r, bus: i, validator: a, validateOnSubmit: o, action: s, submitter: c, waitForSubmitDelay: l, onRefreshTokensAfterSubmit: u, dispatchSubmitResult: d } = e;
|
|
989
|
-
|
|
989
|
+
Wt(r), C(r, c || null);
|
|
990
990
|
let p = {
|
|
991
991
|
ok: !1,
|
|
992
992
|
code: "SUBMIT_ERROR",
|
|
@@ -994,30 +994,30 @@ async function Kt(e) {
|
|
|
994
994
|
formErrors: ["Submission failed."]
|
|
995
995
|
};
|
|
996
996
|
try {
|
|
997
|
-
await l(r), p = await
|
|
997
|
+
await l(r), p = await pt(r, s, i, {
|
|
998
998
|
validator: a,
|
|
999
999
|
validateOnSubmit: o
|
|
1000
|
-
}),
|
|
1000
|
+
}), z(r, p), d(p), v(r, p, s), Ht(p) && await u(p);
|
|
1001
1001
|
} catch (e) {
|
|
1002
1002
|
p = {
|
|
1003
1003
|
ok: !1,
|
|
1004
1004
|
code: "SUBMIT_ERROR",
|
|
1005
1005
|
message: e instanceof Error ? e.message : "Submission failed.",
|
|
1006
1006
|
formErrors: [e instanceof Error ? e.message : "Submission failed."]
|
|
1007
|
-
},
|
|
1007
|
+
}, z(r, p), d(p), Vt.warn("Submit failed with exception.", {
|
|
1008
1008
|
id: t,
|
|
1009
1009
|
action: s,
|
|
1010
1010
|
target: n,
|
|
1011
1011
|
error: e instanceof Error ? e.message : e
|
|
1012
1012
|
});
|
|
1013
1013
|
} finally {
|
|
1014
|
-
|
|
1014
|
+
Ut(p) || f(r);
|
|
1015
1015
|
}
|
|
1016
1016
|
return p;
|
|
1017
1017
|
}
|
|
1018
1018
|
//#endregion
|
|
1019
1019
|
//#region src/js/events/event-bus.ts
|
|
1020
|
-
var
|
|
1020
|
+
var Kt = class {
|
|
1021
1021
|
listeners = /* @__PURE__ */ new Map();
|
|
1022
1022
|
on(e, t) {
|
|
1023
1023
|
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e)?.add(t), () => {
|
|
@@ -1067,7 +1067,7 @@ var qt = class {
|
|
|
1067
1067
|
clear() {
|
|
1068
1068
|
this.listeners.clear();
|
|
1069
1069
|
}
|
|
1070
|
-
},
|
|
1070
|
+
}, B = class {
|
|
1071
1071
|
modules = /* @__PURE__ */ new Map();
|
|
1072
1072
|
register(e, t = {}) {
|
|
1073
1073
|
if (!/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/.test(e.moduleId) || e.version !== 2 || !Array.isArray(e.surfaces) || e.surfaces.length === 0 || e.surfaces.some((e) => ![
|
|
@@ -1093,12 +1093,12 @@ var qt = class {
|
|
|
1093
1093
|
getAll() {
|
|
1094
1094
|
return Array.from(this.modules.values());
|
|
1095
1095
|
}
|
|
1096
|
-
},
|
|
1096
|
+
}, qt = new B(), Jt = {
|
|
1097
1097
|
"address-finder": () => import("./chunks/address-finder-QK1m1eyv.js").then((e) => e.addressFinderModule),
|
|
1098
1098
|
"google-address": () => import("./chunks/google-address-DQR6rsbh.js").then((e) => e.googleAddressModule),
|
|
1099
1099
|
loqate: () => import("./chunks/loqate-ZZClcacr.js").then((e) => e.loqateModule),
|
|
1100
1100
|
"place-kit": () => import("./chunks/place-kit-BKk8xDXf.js").then((e) => e.placeKitModule)
|
|
1101
|
-
},
|
|
1101
|
+
}, Yt = {
|
|
1102
1102
|
"captcha-eu": () => import("./chunks/captcha-eu-eU_M6snp.js").then((e) => e.captchaEuModule),
|
|
1103
1103
|
"friendly-captcha-v1": () => import("./chunks/friendly-captcha-v1-C_cF1WD2.js").then((e) => e.friendlyCaptchaV1Module),
|
|
1104
1104
|
"friendly-captcha-v2": () => import("./chunks/friendly-captcha-v2-BenESH-n.js").then((e) => e.friendlyCaptchaV2Module),
|
|
@@ -1109,7 +1109,7 @@ var qt = class {
|
|
|
1109
1109
|
"recaptcha-v3": () => import("./chunks/recaptcha-v3-DKMGQ27K.js").then((e) => e.recaptchaV3Module),
|
|
1110
1110
|
snaptcha: () => import("./chunks/snaptcha-P3EoSQud.js").then((e) => e.snaptchaModule),
|
|
1111
1111
|
turnstile: () => import("./chunks/turnstile-Sp4ubowK.js").then((e) => e.turnstileModule)
|
|
1112
|
-
},
|
|
1112
|
+
}, Xt = {
|
|
1113
1113
|
calculations: () => import("./chunks/calculations-DeEmdUDq.js").then((e) => e.calculationsModule),
|
|
1114
1114
|
"checkbox-radio": () => import("./chunks/checkbox-radio-CSXo6svm.js").then((e) => e.checkboxRadioModule),
|
|
1115
1115
|
combobox: () => import("./chunks/combobox-CTfq6v4y.js").then((e) => e.comboboxModule),
|
|
@@ -1134,7 +1134,7 @@ var qt = class {
|
|
|
1134
1134
|
"survey-rating": () => import("./chunks/survey-rating-mlDMI0uq.js").then((e) => e.surveyRatingModule),
|
|
1135
1135
|
table: () => import("./chunks/table-0k6Md0IO.js").then((e) => e.tableModule),
|
|
1136
1136
|
"text-limit": () => import("./chunks/text-limit-CTVML6s7.js").then((e) => e.textLimitModule)
|
|
1137
|
-
},
|
|
1137
|
+
}, Zt = {
|
|
1138
1138
|
bpoint: () => import("./chunks/bpoint-BKRpTj1e.js").then((e) => e.bpointModule),
|
|
1139
1139
|
eway: () => import("./chunks/eway-9ZTEmiod.js").then((e) => e.ewayModule),
|
|
1140
1140
|
"go-cardless": () => import("./chunks/go-cardless-BN096eDZ.js").then((e) => e.goCardlessModule),
|
|
@@ -1146,13 +1146,13 @@ var qt = class {
|
|
|
1146
1146
|
payway: () => import("./chunks/payway-K9eUUMvk.js").then((e) => e.paywayModule),
|
|
1147
1147
|
square: () => import("./chunks/square-Bn6y1M0R.js").then((e) => e.squareModule),
|
|
1148
1148
|
stripe: () => import("./chunks/stripe-CmzSSdMg.js").then((e) => e.stripeModule)
|
|
1149
|
-
},
|
|
1150
|
-
...Zt,
|
|
1151
|
-
...Yt,
|
|
1149
|
+
}, Qt = {
|
|
1152
1150
|
...Xt,
|
|
1153
|
-
...
|
|
1154
|
-
|
|
1155
|
-
|
|
1151
|
+
...Jt,
|
|
1152
|
+
...Yt,
|
|
1153
|
+
...Zt
|
|
1154
|
+
}, V = /* @__PURE__ */ new Map();
|
|
1155
|
+
function $t(e) {
|
|
1156
1156
|
if (e instanceof Error) return {
|
|
1157
1157
|
name: e.name || "Error",
|
|
1158
1158
|
message: e.message || "No error message was provided.",
|
|
@@ -1174,7 +1174,7 @@ function en(e) {
|
|
|
1174
1174
|
};
|
|
1175
1175
|
}
|
|
1176
1176
|
}
|
|
1177
|
-
function
|
|
1177
|
+
function en(e, t, n) {
|
|
1178
1178
|
let r = [...t].filter((e) => e.required), i = [
|
|
1179
1179
|
"Formie browser module diagnostics",
|
|
1180
1180
|
`Surface: ${e}`,
|
|
@@ -1185,7 +1185,7 @@ function tn(e, t, n) {
|
|
|
1185
1185
|
i.push("", `Failure ${r + 1}`, `Module: ${t.moduleId}`, `Key: ${t.key}`, `Code: ${t.code}`), e === "cp-edit" && a && (i.push(`Error: ${a.name}: ${a.message}`), a.stack && i.push("Stack:", a.stack));
|
|
1186
1186
|
}), i.join("\n");
|
|
1187
1187
|
}
|
|
1188
|
-
async function
|
|
1188
|
+
async function tn(e) {
|
|
1189
1189
|
if (navigator.clipboard?.writeText) {
|
|
1190
1190
|
await navigator.clipboard.writeText(e);
|
|
1191
1191
|
return;
|
|
@@ -1198,26 +1198,26 @@ async function nn(e) {
|
|
|
1198
1198
|
t.remove();
|
|
1199
1199
|
}
|
|
1200
1200
|
}
|
|
1201
|
-
async function
|
|
1201
|
+
async function nn(e, t) {
|
|
1202
1202
|
let n = t.get(e);
|
|
1203
1203
|
if (n) return n;
|
|
1204
|
-
let r = e.startsWith("formie:") && Object.prototype.hasOwnProperty.call(
|
|
1204
|
+
let r = e.startsWith("formie:") && Object.prototype.hasOwnProperty.call(Qt, e.slice(7)) ? Qt[e.slice(7)] : void 0;
|
|
1205
1205
|
if (!r) throw Error(`Browser module ${e} is not registered.`);
|
|
1206
|
-
|
|
1207
|
-
throw
|
|
1206
|
+
V.has(e) || V.set(e, r().catch((t) => {
|
|
1207
|
+
throw V.delete(e), t;
|
|
1208
1208
|
}));
|
|
1209
|
-
let i = await
|
|
1209
|
+
let i = await V.get(e);
|
|
1210
1210
|
if (i.moduleId !== e) throw Error(`Module definition does not match ${e}.`);
|
|
1211
1211
|
return t.register(i), i;
|
|
1212
1212
|
}
|
|
1213
|
-
function
|
|
1213
|
+
function rn(e, t, n) {
|
|
1214
1214
|
return [...new Set(e.targets.flatMap((e) => {
|
|
1215
1215
|
if (e.type === "form") return [n || t];
|
|
1216
1216
|
let r = e.type === "selector" ? e.selector : e.type === "field" ? `[data-formie-field-uid="${CSS.escape(e.uid)}"]` : e.type === "page" ? `[data-formie-page-id="${CSS.escape(e.id)}"]` : `[data-formie-action="${CSS.escape(e.action)}"]`;
|
|
1217
1217
|
return [...t.matches(r) ? [t] : [], ...t.querySelectorAll(r)];
|
|
1218
1218
|
}))].filter((e) => !e.closest("[hidden], [data-formie-hidden=\"true\"], [data-formie-conditionally-hidden], [data-formie-page-hidden]"));
|
|
1219
1219
|
}
|
|
1220
|
-
async function
|
|
1220
|
+
async function an(e, t) {
|
|
1221
1221
|
n(e);
|
|
1222
1222
|
let r = e.surface;
|
|
1223
1223
|
if (t.matchContext.surface !== r || t.setupContext.surface !== r) throw Error(`Browser module manifest surface ${r} cannot mount as ${t.matchContext.surface}.`);
|
|
@@ -1230,7 +1230,7 @@ async function on(e, t) {
|
|
|
1230
1230
|
code: "MODULE_UNAVAILABLE",
|
|
1231
1231
|
message: "A form feature could not start. Reload the page or contact the site administrator."
|
|
1232
1232
|
};
|
|
1233
|
-
s.set(e.key, i), c.set(e.key,
|
|
1233
|
+
s.set(e.key, i), c.set(e.key, $t(n)), console.error("[formie] Browser module failure", i, n), await t.setupContext.emit("formie:browser:module:error", i);
|
|
1234
1234
|
}, m = async (e) => {
|
|
1235
1235
|
try {
|
|
1236
1236
|
await e.destroy();
|
|
@@ -1272,7 +1272,7 @@ async function on(e, t) {
|
|
|
1272
1272
|
let d = document.createElement("span");
|
|
1273
1273
|
d.className = "formie-module-error__copy-status", d.setAttribute("role", "status"), d.setAttribute("aria-live", "polite"), u.addEventListener("click", async () => {
|
|
1274
1274
|
try {
|
|
1275
|
-
await
|
|
1275
|
+
await tn(n.textContent || ""), d.textContent = "Details copied.";
|
|
1276
1276
|
} catch {
|
|
1277
1277
|
d.textContent = "Copy failed. Select the details above and copy them manually.";
|
|
1278
1278
|
let e = document.createRange();
|
|
@@ -1282,7 +1282,7 @@ async function on(e, t) {
|
|
|
1282
1282
|
}
|
|
1283
1283
|
e.dataset.formieModuleError = "true", i !== a && a.contains(i) ? i.before(e) : a.prepend(e);
|
|
1284
1284
|
}
|
|
1285
|
-
let t = e.querySelector("[data-formie-module-error-details]"), n =
|
|
1285
|
+
let t = e.querySelector("[data-formie-module-error-details]"), n = en(r, s.values(), c);
|
|
1286
1286
|
t && t.textContent !== n && (t.textContent = n);
|
|
1287
1287
|
}, _ = (e) => {
|
|
1288
1288
|
h() && (e.preventDefault(), e.stopImmediatePropagation(), g());
|
|
@@ -1301,7 +1301,7 @@ async function on(e, t) {
|
|
|
1301
1301
|
});
|
|
1302
1302
|
let d;
|
|
1303
1303
|
try {
|
|
1304
|
-
d =
|
|
1304
|
+
d = rn(n, i, a);
|
|
1305
1305
|
} catch (e) {
|
|
1306
1306
|
s.has(n.key) || await p(n, e);
|
|
1307
1307
|
continue;
|
|
@@ -1311,7 +1311,7 @@ async function on(e, t) {
|
|
|
1311
1311
|
for (let [e, t] of Array.from(f.entries()).reverse()) d.includes(e) || (await m(t.instance), f.delete(e), l.splice(l.indexOf(t.instance), 1));
|
|
1312
1312
|
let h;
|
|
1313
1313
|
try {
|
|
1314
|
-
h = await
|
|
1314
|
+
h = await nn(n.moduleId, t.registry);
|
|
1315
1315
|
} catch (e) {
|
|
1316
1316
|
s.has(n.key) || await p(n, e);
|
|
1317
1317
|
continue;
|
|
@@ -1441,7 +1441,7 @@ async function on(e, t) {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
//#endregion
|
|
1443
1443
|
//#region src/js/utils/unload-warning.ts
|
|
1444
|
-
var
|
|
1444
|
+
var on = /* @__PURE__ */ new Set([
|
|
1445
1445
|
"action",
|
|
1446
1446
|
"redirect",
|
|
1447
1447
|
"requestToken",
|
|
@@ -1454,7 +1454,7 @@ var sn = /* @__PURE__ */ new Set([
|
|
|
1454
1454
|
"draftContext",
|
|
1455
1455
|
"progressId"
|
|
1456
1456
|
]);
|
|
1457
|
-
function
|
|
1457
|
+
function sn(e) {
|
|
1458
1458
|
let t = /* @__PURE__ */ new Set(), n = !0;
|
|
1459
1459
|
return g(e, "formie:unload-warning:collect-exclusions", {
|
|
1460
1460
|
form: e,
|
|
@@ -1465,40 +1465,40 @@ function cn(e) {
|
|
|
1465
1465
|
}
|
|
1466
1466
|
}), n = !1, t;
|
|
1467
1467
|
}
|
|
1468
|
-
function
|
|
1468
|
+
function cn(e, t) {
|
|
1469
1469
|
if (e == null) return String(e);
|
|
1470
1470
|
if (typeof e == "string") return JSON.stringify(e);
|
|
1471
1471
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1472
1472
|
if (typeof e == "function") return "[function]";
|
|
1473
1473
|
if (typeof File < "u" && e instanceof File) return `[file:${e.name}:${e.size}:${e.type}]`;
|
|
1474
1474
|
if (typeof Blob < "u" && e instanceof Blob) return `[blob:${e.size}:${e.type}]`;
|
|
1475
|
-
if (Array.isArray(e)) return `[${e.map((e) =>
|
|
1475
|
+
if (Array.isArray(e)) return `[${e.map((e) => cn(e, t)).join(",")}]`;
|
|
1476
1476
|
if (typeof e == "object") {
|
|
1477
1477
|
if (t.has(e)) return "[circular]";
|
|
1478
1478
|
t.add(e);
|
|
1479
|
-
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${
|
|
1479
|
+
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${cn(n, t)}`);
|
|
1480
1480
|
return t.delete(e), `{${n.join(",")}}`;
|
|
1481
1481
|
}
|
|
1482
1482
|
return JSON.stringify(String(e));
|
|
1483
1483
|
}
|
|
1484
|
-
function
|
|
1485
|
-
return
|
|
1484
|
+
function ln(e) {
|
|
1485
|
+
return cn(e, /* @__PURE__ */ new WeakSet());
|
|
1486
1486
|
}
|
|
1487
|
-
function
|
|
1487
|
+
function un(e, t) {
|
|
1488
1488
|
if (!e) return !1;
|
|
1489
1489
|
let n = e.endsWith("[]") ? e.slice(0, -2) : e;
|
|
1490
|
-
return !ie(n, t) && !
|
|
1490
|
+
return !ie(n, t) && !on.has(n);
|
|
1491
1491
|
}
|
|
1492
|
-
function
|
|
1493
|
-
return
|
|
1492
|
+
function dn(e, t, n) {
|
|
1493
|
+
return ln(e.filter(([e]) => !n.has(e) && un(String(e || ""), t)));
|
|
1494
1494
|
}
|
|
1495
|
-
function
|
|
1495
|
+
function fn(e, t = {}) {
|
|
1496
1496
|
let n = [], r = !1, i = !1, a = !1, o = null, s = null, c = null, l = () => {
|
|
1497
1497
|
o !== null && (window.cancelAnimationFrame(o), o = null), s !== null && (window.clearTimeout(s), s = null), c !== null && (window.clearTimeout(c), c = null);
|
|
1498
1498
|
}, u = () => {
|
|
1499
1499
|
if (!r) return !1;
|
|
1500
|
-
let t =
|
|
1501
|
-
return a =
|
|
1500
|
+
let t = sn(e);
|
|
1501
|
+
return a = dn(Array.from(new FormData(e).entries()), e, t) !== dn(n, e, t), a;
|
|
1502
1502
|
}, d = () => {
|
|
1503
1503
|
i || (l(), n = Array.from(new FormData(e).entries()), r = !0, a = !1);
|
|
1504
1504
|
}, f = () => {
|
|
@@ -1525,7 +1525,7 @@ function pn(e, t = {}) {
|
|
|
1525
1525
|
}
|
|
1526
1526
|
//#endregion
|
|
1527
1527
|
//#region src/js/validation/rules/email.ts
|
|
1528
|
-
var
|
|
1528
|
+
var pn = {
|
|
1529
1529
|
rule: ({ input: e, getRule: n }) => {
|
|
1530
1530
|
let r = n("email");
|
|
1531
1531
|
return !r || t(e.value, {
|
|
@@ -1537,10 +1537,10 @@ var mn = {
|
|
|
1537
1537
|
};
|
|
1538
1538
|
//#endregion
|
|
1539
1539
|
//#region src/js/validation/rules/shared.ts
|
|
1540
|
-
function
|
|
1540
|
+
function mn(e) {
|
|
1541
1541
|
return e?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() || "";
|
|
1542
1542
|
}
|
|
1543
|
-
function
|
|
1543
|
+
function hn(e) {
|
|
1544
1544
|
let t = e.getRule("match");
|
|
1545
1545
|
if (!t || t === !0 || typeof t != "object" || !e.field) return null;
|
|
1546
1546
|
let n = typeof t.fieldHandle == "string" ? t.fieldHandle.trim() : "";
|
|
@@ -1550,7 +1550,7 @@ function gn(e) {
|
|
|
1550
1550
|
}
|
|
1551
1551
|
//#endregion
|
|
1552
1552
|
//#region src/js/validation/rules.ts
|
|
1553
|
-
var
|
|
1553
|
+
var gn = {
|
|
1554
1554
|
required: {
|
|
1555
1555
|
rule: ({ input: e, getRule: n }) => {
|
|
1556
1556
|
if (!n("required") || e.type === "hidden" || e.closest("[data-formie-field-handle]")?.getAttribute("data-formie-field-type") === "table") return !0;
|
|
@@ -1567,7 +1567,7 @@ var _n = {
|
|
|
1567
1567
|
},
|
|
1568
1568
|
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 })
|
|
1569
1569
|
},
|
|
1570
|
-
email:
|
|
1570
|
+
email: pn,
|
|
1571
1571
|
url: {
|
|
1572
1572
|
rule: ({ input: e, getRule: n }) => {
|
|
1573
1573
|
let r = n("url");
|
|
@@ -1596,18 +1596,18 @@ var _n = {
|
|
|
1596
1596
|
},
|
|
1597
1597
|
match: {
|
|
1598
1598
|
rule: (e) => {
|
|
1599
|
-
let n =
|
|
1599
|
+
let n = hn(e);
|
|
1600
1600
|
return !n || t(e.input.value, { type: "match" }, { comparison: n.value }) === null;
|
|
1601
1601
|
},
|
|
1602
1602
|
message: (e) => {
|
|
1603
|
-
let t =
|
|
1603
|
+
let t = hn(e)?.closest("[data-formie-field-handle]"), n = mn(t);
|
|
1604
1604
|
return e.input.getAttribute("data-formie-validation-match-message") ?? e.t("{label} must match {value}.", {
|
|
1605
1605
|
label: e.label,
|
|
1606
1606
|
value: n
|
|
1607
1607
|
});
|
|
1608
1608
|
}
|
|
1609
1609
|
}
|
|
1610
|
-
},
|
|
1610
|
+
}, _n = {
|
|
1611
1611
|
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,})+$/,
|
|
1612
1612
|
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*)?$/,
|
|
1613
1613
|
number: /^(?:[-+]?[0-9]*[.,]?[0-9]+)$/,
|
|
@@ -1615,14 +1615,14 @@ var _n = {
|
|
|
1615
1615
|
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))/,
|
|
1616
1616
|
time: /^(?:(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]))$/,
|
|
1617
1617
|
month: /^(?:(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])))$/
|
|
1618
|
-
},
|
|
1619
|
-
function
|
|
1618
|
+
}, H = O("general", "validator");
|
|
1619
|
+
function U(e) {
|
|
1620
1620
|
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement) && (!!e.name || e.hasAttribute("data-formie-date-datepicker-input"));
|
|
1621
1621
|
}
|
|
1622
|
-
function
|
|
1622
|
+
function W(e) {
|
|
1623
1623
|
return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
1624
1624
|
}
|
|
1625
|
-
var
|
|
1625
|
+
var vn = class {
|
|
1626
1626
|
form;
|
|
1627
1627
|
errors = [];
|
|
1628
1628
|
validators = {};
|
|
@@ -1644,14 +1644,14 @@ var yn = class {
|
|
|
1644
1644
|
messagesClass: [],
|
|
1645
1645
|
messageClass: [],
|
|
1646
1646
|
fieldsSelector: "input:not([type=\"hidden\"]):not([type=\"submit\"]):not([type=\"button\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])",
|
|
1647
|
-
patterns:
|
|
1647
|
+
patterns: _n,
|
|
1648
1648
|
...t
|
|
1649
|
-
}, Object.entries(
|
|
1649
|
+
}, Object.entries(gn).forEach(([e, t]) => {
|
|
1650
1650
|
this.addValidator(e, t.rule, t.message);
|
|
1651
1651
|
}), this.init();
|
|
1652
1652
|
}
|
|
1653
1653
|
init() {
|
|
1654
|
-
|
|
1654
|
+
H.log("Initializing validator.", {
|
|
1655
1655
|
formId: this.form.id || null,
|
|
1656
1656
|
live: this.config.live
|
|
1657
1657
|
}), this.form.setAttribute("novalidate", "true"), this.inputs().forEach((e) => {
|
|
@@ -1659,9 +1659,9 @@ var yn = class {
|
|
|
1659
1659
|
}), this.config.live && this.addEventListeners(), this.emitEvent(document, o("ready"), { validator: this });
|
|
1660
1660
|
}
|
|
1661
1661
|
inputs(e = null) {
|
|
1662
|
-
if (
|
|
1662
|
+
if (U(e)) return j(e) ? [] : [e];
|
|
1663
1663
|
let t = e || this.form;
|
|
1664
|
-
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) =>
|
|
1664
|
+
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) => U(e) && !j(e));
|
|
1665
1665
|
}
|
|
1666
1666
|
getInputValue(e) {
|
|
1667
1667
|
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 ?? "";
|
|
@@ -1701,7 +1701,7 @@ var yn = class {
|
|
|
1701
1701
|
}), r = !0;
|
|
1702
1702
|
}
|
|
1703
1703
|
}), !r && i && this.removeError(e);
|
|
1704
|
-
}),
|
|
1704
|
+
}), H.log("Validation pass complete.", {
|
|
1705
1705
|
errorCount: this.errors.length,
|
|
1706
1706
|
includeHiddenPages: t.includeHiddenPages === !0
|
|
1707
1707
|
}), this.errors;
|
|
@@ -1722,7 +1722,7 @@ var yn = class {
|
|
|
1722
1722
|
e.remove();
|
|
1723
1723
|
}), n && (n.innerHTML = ""), t.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
1724
1724
|
let t = e;
|
|
1725
|
-
t.removeAttribute("aria-invalid"), this.config.inputErrorClass.length && t.classList.remove(...this.config.inputErrorClass), t.removeAttribute("data-formie-input-has-error"),
|
|
1725
|
+
t.removeAttribute("aria-invalid"), this.config.inputErrorClass.length && t.classList.remove(...this.config.inputErrorClass), t.removeAttribute("data-formie-input-has-error"), ze(t, r);
|
|
1726
1726
|
});
|
|
1727
1727
|
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");
|
|
1728
1728
|
this.emitEvent(e, o("clear-error"), { validator: this }), h(this.form);
|
|
@@ -1731,17 +1731,17 @@ var yn = class {
|
|
|
1731
1731
|
let r = e.closest("[data-formie-field-handle]");
|
|
1732
1732
|
if (!r) return;
|
|
1733
1733
|
let i = r.querySelector("[data-formie-field-errors]");
|
|
1734
|
-
i ||=
|
|
1734
|
+
i ||= ht(r, (e) => {
|
|
1735
1735
|
this.config.messagesClass.length && e.classList.add(...this.config.messagesClass);
|
|
1736
1736
|
}), this.config.messagesClass.length && i.classList.add(...this.config.messagesClass), i.innerHTML = "";
|
|
1737
1737
|
let a = r.getAttribute("data-formie-field-handle") || "field";
|
|
1738
1738
|
i.id = i.id || `${e.id || `${this.form.id}-${a}`}-errors`;
|
|
1739
1739
|
let s = `${i.id}-1`;
|
|
1740
|
-
|
|
1740
|
+
Fe(i, Ne(this.config.errorAriaLive, this.submitted));
|
|
1741
1741
|
let c = document.createElement("div");
|
|
1742
1742
|
c.setAttribute("data-formie-field-error", "true"), c.setAttribute(`data-formie-field-error-${t}`, "true"), c.setAttribute("id", s), this.config.messageClass.length && c.classList.add(...this.config.messageClass), c.textContent = n, i.appendChild(c), r.setAttribute("data-formie-field-has-error", "true"), r.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
1743
1743
|
let t = e;
|
|
1744
|
-
j(t) || (t.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && t.classList.add(...this.config.inputErrorClass), t.setAttribute("data-formie-input-has-error", "true"),
|
|
1744
|
+
j(t) || (t.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && t.classList.add(...this.config.inputErrorClass), t.setAttribute("data-formie-input-has-error", "true"), Re(t, s));
|
|
1745
1745
|
});
|
|
1746
1746
|
for (let e = r; 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");
|
|
1747
1747
|
this.emitEvent(e, o("show-error"), {
|
|
@@ -1787,7 +1787,7 @@ var yn = class {
|
|
|
1787
1787
|
try {
|
|
1788
1788
|
n = JSON.parse(e);
|
|
1789
1789
|
} catch {
|
|
1790
|
-
return
|
|
1790
|
+
return H.warn("Invalid validation rules payload.", { formId: this.form.id || null }), t;
|
|
1791
1791
|
}
|
|
1792
1792
|
return Array.isArray(n) && n.forEach((e) => {
|
|
1793
1793
|
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
@@ -1796,39 +1796,39 @@ var yn = class {
|
|
|
1796
1796
|
}), t;
|
|
1797
1797
|
}
|
|
1798
1798
|
destroy() {
|
|
1799
|
-
|
|
1799
|
+
H.log("Destroying validator.", { formId: this.form.id || null }), this.removeEventListeners(), this.form.removeAttribute("novalidate"), this.emitEvent(document, o("destroy"), { validator: this });
|
|
1800
1800
|
}
|
|
1801
1801
|
isVisible(e, t = {}) {
|
|
1802
1802
|
if (e.disabled || e.hasAttribute("data-formie-conditions-disabled") || e.closest("[data-formie-conditions-disabled]") || e.closest("[data-formie-conditionally-hidden]")) return !1;
|
|
1803
1803
|
if (e.closest("[data-formie-page-hidden]")) return !!t.includeHiddenPages;
|
|
1804
1804
|
let n = e.closest("[data-formie-field-handle]"), r = n?.querySelector("[data-formie-rich-text]");
|
|
1805
|
-
if (r instanceof HTMLElement) return
|
|
1805
|
+
if (r instanceof HTMLElement) return W(r);
|
|
1806
1806
|
if (e instanceof HTMLSelectElement && e.hasAttribute("data-formie-combobox-input")) {
|
|
1807
1807
|
let t = e.nextElementSibling;
|
|
1808
|
-
if (t instanceof HTMLElement && t.classList.contains("formie-combobox")) return
|
|
1808
|
+
if (t instanceof HTMLElement && t.classList.contains("formie-combobox")) return W(t);
|
|
1809
1809
|
}
|
|
1810
|
-
return e instanceof HTMLSelectElement && n instanceof HTMLElement ?
|
|
1810
|
+
return e instanceof HTMLSelectElement && n instanceof HTMLElement ? W(e) || W(n) : W(e);
|
|
1811
1811
|
}
|
|
1812
1812
|
blurHandler(e) {
|
|
1813
|
-
e.target instanceof HTMLElement &&
|
|
1813
|
+
e.target instanceof HTMLElement && U(e.target) && !j(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)));
|
|
1814
1814
|
}
|
|
1815
1815
|
changeHandler(e) {
|
|
1816
|
-
e.target instanceof HTMLElement &&
|
|
1816
|
+
e.target instanceof HTMLElement && U(e.target) && !j(e.target) && e.target.form?.isSameNode(this.form) && (e instanceof CustomEvent || (e.target instanceof HTMLSelectElement || e.target instanceof HTMLInputElement && (e.target.type === "file" || e.target.type === "checkbox" || e.target.type === "radio")) && (this.activated.add(e.target), this.validate(e.target)));
|
|
1817
1817
|
}
|
|
1818
1818
|
inputHandler(e) {
|
|
1819
|
-
e.target instanceof HTMLElement &&
|
|
1819
|
+
e.target instanceof HTMLElement && U(e.target) && !j(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));
|
|
1820
1820
|
}
|
|
1821
1821
|
submit(e = null, { final: t = !1 } = {}) {
|
|
1822
|
-
return this.submitted = !0,
|
|
1822
|
+
return this.submitted = !0, H.log("Submit validation requested.", { final: t }), this.boundListeners || this.addEventListeners(), this.removeAllErrors(), this.validate(e, { includeHiddenPages: t });
|
|
1823
1823
|
}
|
|
1824
1824
|
resetLiveState() {
|
|
1825
1825
|
this.submitted = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.errors = [], this.removeAllErrors();
|
|
1826
1826
|
}
|
|
1827
1827
|
addEventListeners() {
|
|
1828
|
-
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,
|
|
1828
|
+
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, H.log("Event listeners attached."));
|
|
1829
1829
|
}
|
|
1830
1830
|
removeEventListeners() {
|
|
1831
|
-
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1,
|
|
1831
|
+
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1, H.log("Event listeners removed.");
|
|
1832
1832
|
}
|
|
1833
1833
|
emitEvent(e, t, n = {}) {
|
|
1834
1834
|
e.dispatchEvent(new CustomEvent(t, {
|
|
@@ -1848,25 +1848,25 @@ var yn = class {
|
|
|
1848
1848
|
};
|
|
1849
1849
|
//#endregion
|
|
1850
1850
|
//#region src/js/validation/enter-key-guard.ts
|
|
1851
|
-
function
|
|
1851
|
+
function yn(e) {
|
|
1852
1852
|
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]");
|
|
1853
1853
|
}
|
|
1854
|
-
function
|
|
1854
|
+
function bn(e, t) {
|
|
1855
1855
|
let n = e.querySelectorAll(`[data-formie-action="${t}"]`);
|
|
1856
|
-
return Array.from(n).some((e) => !
|
|
1856
|
+
return Array.from(n).some((e) => !yn(e));
|
|
1857
1857
|
}
|
|
1858
|
-
function
|
|
1858
|
+
function xn(e) {
|
|
1859
1859
|
let { final: t } = m(e);
|
|
1860
1860
|
return "submit";
|
|
1861
1861
|
}
|
|
1862
|
-
function
|
|
1863
|
-
return !
|
|
1862
|
+
function Sn(e) {
|
|
1863
|
+
return !bn(e, xn(e));
|
|
1864
1864
|
}
|
|
1865
|
-
function
|
|
1865
|
+
function Cn(e) {
|
|
1866
1866
|
let t = (t) => {
|
|
1867
1867
|
if (t.key !== "Enter" || t.defaultPrevented) return;
|
|
1868
1868
|
let n = t.target;
|
|
1869
|
-
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") ||
|
|
1869
|
+
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") || Sn(e) && t.preventDefault());
|
|
1870
1870
|
};
|
|
1871
1871
|
return e.addEventListener("keydown", t, !0), () => {
|
|
1872
1872
|
e.removeEventListener("keydown", t, !0);
|
|
@@ -1874,16 +1874,16 @@ function wn(e) {
|
|
|
1874
1874
|
}
|
|
1875
1875
|
//#endregion
|
|
1876
1876
|
//#region src/js/core/create-formie-client.ts
|
|
1877
|
-
var
|
|
1878
|
-
function
|
|
1877
|
+
var G = "[data-formie]:not([data-formie-init=\"false\"]), [data-formie-form]:not([data-formie-init=\"false\"])", wn = 300, Tn = "/actions/formie/server/forms/render", En = "/api", Dn = "/actions/formie/server/forms/refresh-tokens", On = "/actions/formie/server/submissions/submit", kn = "/actions/formie/server/submissions/set-page", An = "/actions/formie/server/submissions/clear-submission", jn = "/actions/formie/file-upload/hydrate", K = O("general", "client"), Mn = /* @__PURE__ */ new Set();
|
|
1878
|
+
function q(e, t) {
|
|
1879
1879
|
if (e == null || e === "") return t;
|
|
1880
1880
|
let n = e.toLowerCase();
|
|
1881
1881
|
return n !== "false" && n !== "0" && n !== "off";
|
|
1882
1882
|
}
|
|
1883
|
-
function
|
|
1884
|
-
return e.formieRefreshTokens == null ? e.formieStaticCache != null &&
|
|
1883
|
+
function Nn(e) {
|
|
1884
|
+
return e.formieRefreshTokens == null ? e.formieStaticCache != null && q(e.formieStaticCache, !0) : q(e.formieRefreshTokens, !0);
|
|
1885
1885
|
}
|
|
1886
|
-
function
|
|
1886
|
+
function J(e) {
|
|
1887
1887
|
let t = e instanceof HTMLElement ? e.dataset : {};
|
|
1888
1888
|
return {
|
|
1889
1889
|
mode: "server-rendered",
|
|
@@ -1891,25 +1891,25 @@ function q(e) {
|
|
|
1891
1891
|
profile: t.formieRequestProfile,
|
|
1892
1892
|
formHandle: t.formieHandle,
|
|
1893
1893
|
endpoint: t.formieEndpoint,
|
|
1894
|
-
staticCache:
|
|
1895
|
-
autoVisible:
|
|
1896
|
-
compatibility:
|
|
1894
|
+
staticCache: Nn(t),
|
|
1895
|
+
autoVisible: q(t.formieAutoVisible, !0),
|
|
1896
|
+
compatibility: q(t.formieCompatibility, !1)
|
|
1897
1897
|
};
|
|
1898
1898
|
}
|
|
1899
|
-
function
|
|
1899
|
+
function Pn(e) {
|
|
1900
1900
|
if (e && e !== "server-rendered") throw Error("@verbb/formie-browser enhances server-rendered HTML only. Use @verbb/formie-core for client-rendered forms.");
|
|
1901
1901
|
return "server-rendered";
|
|
1902
1902
|
}
|
|
1903
|
-
function
|
|
1903
|
+
function Fn(e) {
|
|
1904
1904
|
return e || "rest";
|
|
1905
1905
|
}
|
|
1906
|
-
function
|
|
1906
|
+
function Y(e) {
|
|
1907
1907
|
return e instanceof HTMLFormElement ? e : e.querySelector("form");
|
|
1908
1908
|
}
|
|
1909
|
-
function
|
|
1910
|
-
|
|
1909
|
+
function In(e, t) {
|
|
1910
|
+
Mn.has(e) || (Mn.add(e), K.warn(t));
|
|
1911
1911
|
}
|
|
1912
|
-
function
|
|
1912
|
+
function X(e, t) {
|
|
1913
1913
|
if (!e) return e;
|
|
1914
1914
|
try {
|
|
1915
1915
|
return new URL(e).toString();
|
|
@@ -1921,7 +1921,7 @@ function Y(e, t) {
|
|
|
1921
1921
|
return e;
|
|
1922
1922
|
}
|
|
1923
1923
|
}
|
|
1924
|
-
function
|
|
1924
|
+
function Z(e, t) {
|
|
1925
1925
|
let n = (e || "").trim();
|
|
1926
1926
|
if (!n) return t;
|
|
1927
1927
|
if (n.includes(t)) return n;
|
|
@@ -1930,52 +1930,52 @@ function X(e, t) {
|
|
|
1930
1930
|
let e = new URL(n, window.location.origin);
|
|
1931
1931
|
if (e.pathname.endsWith(r) || Array.from(e.searchParams.values()).some((e) => e.endsWith(r))) return n;
|
|
1932
1932
|
} catch {}
|
|
1933
|
-
return
|
|
1933
|
+
return X(t, n);
|
|
1934
1934
|
}
|
|
1935
|
-
function
|
|
1936
|
-
return
|
|
1935
|
+
function Ln(e, t) {
|
|
1936
|
+
return Z(e.endpoint || t.dataset.formieEndpoint, Tn);
|
|
1937
1937
|
}
|
|
1938
|
-
function
|
|
1938
|
+
function Rn(e, t) {
|
|
1939
1939
|
let n = (e.endpoint || t.dataset.formieEndpoint || "").trim();
|
|
1940
|
-
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n :
|
|
1940
|
+
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n : X(En, n) : En;
|
|
1941
1941
|
}
|
|
1942
|
-
function
|
|
1943
|
-
let n = t.dataset.formieRefreshTokensEndpoint ||
|
|
1944
|
-
return n ?
|
|
1942
|
+
function zn(e, t) {
|
|
1943
|
+
let n = t.dataset.formieRefreshTokensEndpoint || Y(t)?.dataset.formieRefreshTokensEndpoint;
|
|
1944
|
+
return n ? X(n, e.endpoint || t.dataset.formieEndpoint) : Z(e.endpoint || t.dataset.formieEndpoint, Dn);
|
|
1945
1945
|
}
|
|
1946
|
-
function
|
|
1946
|
+
function Bn(e, t, n) {
|
|
1947
1947
|
let r = n.endpoint || e.dataset.formieEndpoint, i = t.getAttribute("action") || t.dataset.formieSubmitEndpoint;
|
|
1948
|
-
t.setAttribute("action", i ?
|
|
1948
|
+
t.setAttribute("action", i ? X(i, r) : Z(r, On)), t.querySelectorAll("[data-formie-tab-link]").forEach((e) => {
|
|
1949
1949
|
let t = e.getAttribute("href");
|
|
1950
|
-
e.setAttribute("href", t ?
|
|
1950
|
+
e.setAttribute("href", t ? X(t, r) : Z(r, kn));
|
|
1951
1951
|
}), t.querySelectorAll("[data-formie-file-upload-hydrate-endpoint]").forEach((e) => {
|
|
1952
|
-
e.setAttribute("data-formie-file-upload-hydrate-endpoint",
|
|
1952
|
+
e.setAttribute("data-formie-file-upload-hydrate-endpoint", X(e.getAttribute("data-formie-file-upload-hydrate-endpoint") || jn, r));
|
|
1953
1953
|
});
|
|
1954
1954
|
}
|
|
1955
|
-
function
|
|
1955
|
+
function Vn(e) {
|
|
1956
1956
|
if (e == null) return !1;
|
|
1957
1957
|
let t = e.trim().toLowerCase();
|
|
1958
1958
|
return t === "true" || t === "1" || t === "";
|
|
1959
1959
|
}
|
|
1960
|
-
function
|
|
1961
|
-
return
|
|
1960
|
+
function Hn(e) {
|
|
1961
|
+
return q(e.dataset.formieAutomaticSubmissionState, !0);
|
|
1962
1962
|
}
|
|
1963
|
-
function
|
|
1964
|
-
return n.dataset.formieClearSubmissionEndpoint ?
|
|
1963
|
+
function Un(e, t, n) {
|
|
1964
|
+
return n.dataset.formieClearSubmissionEndpoint ? X(n.dataset.formieClearSubmissionEndpoint, e.endpoint || t.dataset.formieEndpoint) : Z(e.endpoint || t.dataset.formieEndpoint, An);
|
|
1965
1965
|
}
|
|
1966
|
-
function
|
|
1967
|
-
return
|
|
1966
|
+
function Wn(e) {
|
|
1967
|
+
return Vn(e.dataset.formieUnloadWarning);
|
|
1968
1968
|
}
|
|
1969
|
-
function
|
|
1969
|
+
function Gn(e, t) {
|
|
1970
1970
|
e.setAttribute("data-formie-internal-navigation", t);
|
|
1971
1971
|
}
|
|
1972
|
-
function
|
|
1972
|
+
function Kn(e) {
|
|
1973
1973
|
e.removeAttribute("data-formie-internal-navigation");
|
|
1974
1974
|
}
|
|
1975
|
-
function
|
|
1975
|
+
function qn(e) {
|
|
1976
1976
|
return e.getAttribute("data-formie-internal-navigation") !== null;
|
|
1977
1977
|
}
|
|
1978
|
-
function
|
|
1978
|
+
function Jn(e, t) {
|
|
1979
1979
|
if (!e) return !1;
|
|
1980
1980
|
try {
|
|
1981
1981
|
return new URL(e, window.location.origin).searchParams.has(t);
|
|
@@ -1983,30 +1983,30 @@ function Yn(e, t) {
|
|
|
1983
1983
|
return !1;
|
|
1984
1984
|
}
|
|
1985
1985
|
}
|
|
1986
|
-
function
|
|
1987
|
-
return
|
|
1986
|
+
function Yn(e) {
|
|
1987
|
+
return Jn(window.location.href, "resumeToken") || Jn(e.getAttribute("action"), "resumeToken");
|
|
1988
1988
|
}
|
|
1989
|
-
function
|
|
1989
|
+
function Xn(e) {
|
|
1990
1990
|
return e instanceof MouseEvent ? e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey : !0;
|
|
1991
1991
|
}
|
|
1992
|
-
function
|
|
1992
|
+
function Zn(e, t = 0) {
|
|
1993
1993
|
if (!e) return t;
|
|
1994
1994
|
let n = Number.parseInt(e, 10);
|
|
1995
1995
|
return Number.isFinite(n) ? n : t;
|
|
1996
1996
|
}
|
|
1997
|
-
function
|
|
1998
|
-
return Math.max(0,
|
|
1997
|
+
function Qn(e) {
|
|
1998
|
+
return Math.max(0, Zn(e.dataset.formieSubmitDelay, wn));
|
|
1999
1999
|
}
|
|
2000
|
-
function
|
|
2001
|
-
return
|
|
2000
|
+
function Q(e) {
|
|
2001
|
+
return Vn(e.dataset.formieValidationOnSubmit);
|
|
2002
2002
|
}
|
|
2003
|
-
async function
|
|
2004
|
-
let t =
|
|
2003
|
+
async function $n(e) {
|
|
2004
|
+
let t = Qn(e);
|
|
2005
2005
|
await new Promise((e) => {
|
|
2006
2006
|
window.setTimeout(e, t);
|
|
2007
2007
|
});
|
|
2008
2008
|
}
|
|
2009
|
-
function
|
|
2009
|
+
function er(e, t) {
|
|
2010
2010
|
let n = e?.getAttribute(t)?.trim();
|
|
2011
2011
|
if (!n) return null;
|
|
2012
2012
|
try {
|
|
@@ -2016,29 +2016,29 @@ function tr(e, t) {
|
|
|
2016
2016
|
return console.error(`[formie] Failed to parse ${t}.`, e), null;
|
|
2017
2017
|
}
|
|
2018
2018
|
}
|
|
2019
|
-
function
|
|
2019
|
+
function tr(e, t) {
|
|
2020
2020
|
let n = t || (e instanceof HTMLFormElement ? e : null);
|
|
2021
2021
|
if (!n) return null;
|
|
2022
|
-
let r =
|
|
2022
|
+
let r = er(n, "data-formie-modules"), i = er(n, "data-formie-theme-classes") || er(n, "data-formie-theme");
|
|
2023
2023
|
return !r && !i ? null : {
|
|
2024
2024
|
modules: r || void 0,
|
|
2025
2025
|
theme: i || void 0
|
|
2026
2026
|
};
|
|
2027
2027
|
}
|
|
2028
|
-
function
|
|
2028
|
+
function nr(e) {
|
|
2029
2029
|
if (!(e instanceof HTMLElement)) return !0;
|
|
2030
2030
|
if (!e.isConnected || e.hidden || e.closest("[hidden]")) return !1;
|
|
2031
2031
|
let t = window.getComputedStyle(e);
|
|
2032
2032
|
return t.display === "none" || t.visibility === "hidden" ? !1 : e.getClientRects().length > 0;
|
|
2033
2033
|
}
|
|
2034
|
-
function
|
|
2034
|
+
function rr(e, t) {
|
|
2035
2035
|
return t === document ? !0 : t instanceof Element ? t === e || t.contains(e) : !0;
|
|
2036
2036
|
}
|
|
2037
|
-
function
|
|
2037
|
+
function $(e) {
|
|
2038
2038
|
let t = e, n = t.id ? `#${t.id}` : "", r = t.dataset?.formieHandle ? `[handle="${t.dataset.formieHandle}"]` : "";
|
|
2039
2039
|
return `${t.tagName ? t.tagName.toLowerCase() : "element"}${n}${r}`;
|
|
2040
2040
|
}
|
|
2041
|
-
function
|
|
2041
|
+
function ir(e, t) {
|
|
2042
2042
|
if (t) {
|
|
2043
2043
|
if (t.csrf?.param && t.csrf?.token) {
|
|
2044
2044
|
let n = e.querySelector(`input[name="${t.csrf.param}"]`);
|
|
@@ -2065,11 +2065,11 @@ function ar(e, t) {
|
|
|
2065
2065
|
});
|
|
2066
2066
|
}
|
|
2067
2067
|
}
|
|
2068
|
-
async function
|
|
2069
|
-
let n =
|
|
2068
|
+
async function ar(e, t) {
|
|
2069
|
+
let n = Pn(t.mode), r = Fn(t.transport);
|
|
2070
2070
|
if (n !== "server-rendered") return null;
|
|
2071
2071
|
if (t.payload) return t.payload.html && (e.innerHTML = t.payload.html), t.payload;
|
|
2072
|
-
let i = !!
|
|
2072
|
+
let i = !!Y(e), a = t.formHandle || e.dataset.formieHandle;
|
|
2073
2073
|
if (i || !a) return null;
|
|
2074
2074
|
let o = {
|
|
2075
2075
|
mode: n,
|
|
@@ -2078,26 +2078,26 @@ async function or(e, t) {
|
|
|
2078
2078
|
siteId: t.siteId,
|
|
2079
2079
|
theme: t.theme,
|
|
2080
2080
|
themeConfig: t.themeConfig
|
|
2081
|
-
}, s = r === "graphql" ?
|
|
2081
|
+
}, s = r === "graphql" ? Rn(t, e) : Ln(t, e), c = r === "graphql" ? await Ze(s, a, o, t) : await Xe(s, a, {
|
|
2082
2082
|
...o,
|
|
2083
2083
|
endpoint: s
|
|
2084
2084
|
}, t);
|
|
2085
2085
|
return c?.html && (e.innerHTML = c.html), c;
|
|
2086
2086
|
}
|
|
2087
|
-
async function
|
|
2087
|
+
async function or(e, t, n) {
|
|
2088
2088
|
if (t.refreshTokens === !1) return;
|
|
2089
2089
|
let r = t.formHandle || e.dataset.formieHandle;
|
|
2090
2090
|
if (!r) return;
|
|
2091
|
-
let i = await
|
|
2092
|
-
|
|
2091
|
+
let i = await Qe(zn(t, e), r, n.querySelector("input[name=\"renderId\"]")?.value || void 0, t, n.querySelector("input[name=\"requestToken\"]")?.value, n.querySelector("input[name=\"siteId\"]")?.value || t.siteId);
|
|
2092
|
+
ir(n, i), g(e, "formie:refresh-tokens:refreshed", i);
|
|
2093
2093
|
}
|
|
2094
|
-
function
|
|
2094
|
+
function sr(e, t, n, r, i, a) {
|
|
2095
2095
|
t.dataset.formieRequestProfile = n.profile ?? "same-origin-browser", n.profile === "cross-origin-public" && (t.dataset.formieSubmitMethod = "ajax");
|
|
2096
|
-
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s =
|
|
2096
|
+
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s = Un(n, e, t), c = !1, l = t.querySelectorAll("[data-formie-action]"), u = (e) => {
|
|
2097
2097
|
e ? t.setAttribute("data-formie-pending-action", e) : t.removeAttribute("data-formie-pending-action");
|
|
2098
2098
|
};
|
|
2099
|
-
if (
|
|
2100
|
-
let n =
|
|
2099
|
+
if (Wn(t)) {
|
|
2100
|
+
let n = fn(t, { shouldWarn: () => !qn(t) }), r = (e) => {
|
|
2101
2101
|
if (!(e instanceof CustomEvent)) return;
|
|
2102
2102
|
let t = e.detail;
|
|
2103
2103
|
t?.ok && (t.action === "save" || t.outcome === "revised") && n.scheduleBaselineCapture();
|
|
@@ -2119,7 +2119,7 @@ function cr(e, t, n, r, i, a) {
|
|
|
2119
2119
|
}), t.querySelectorAll("[data-formie-tab-link]").forEach((n) => {
|
|
2120
2120
|
let r = async (n) => {
|
|
2121
2121
|
if (o !== "ajax") {
|
|
2122
|
-
|
|
2122
|
+
Xn(n) && Gn(t, "set-page");
|
|
2123
2123
|
return;
|
|
2124
2124
|
}
|
|
2125
2125
|
n.preventDefault();
|
|
@@ -2130,10 +2130,10 @@ function cr(e, t, n, r, i, a) {
|
|
|
2130
2130
|
href: a
|
|
2131
2131
|
});
|
|
2132
2132
|
try {
|
|
2133
|
-
let n = await
|
|
2133
|
+
let n = await $e(a, t, i);
|
|
2134
2134
|
if (n.pageId && S(t, String(n.pageId)), !n.success) {
|
|
2135
2135
|
let { form: e = [], ...r } = n.errors ?? {};
|
|
2136
|
-
|
|
2136
|
+
Wt(t), Ft(t, r), It(t, e), F(t);
|
|
2137
2137
|
return;
|
|
2138
2138
|
}
|
|
2139
2139
|
g(e, "formie:page:navigate:after", {
|
|
@@ -2153,9 +2153,9 @@ function cr(e, t, n, r, i, a) {
|
|
|
2153
2153
|
n.addEventListener("click", r), a.push(() => {
|
|
2154
2154
|
n.removeEventListener("click", r);
|
|
2155
2155
|
});
|
|
2156
|
-
}), !
|
|
2156
|
+
}), !Hn(t)) {
|
|
2157
2157
|
let e = !1, n = () => {
|
|
2158
|
-
e ||
|
|
2158
|
+
e || qn(t) || Yn(t) || (e = !0, et(s, t));
|
|
2159
2159
|
};
|
|
2160
2160
|
window.addEventListener("pagehide", n), window.addEventListener("beforeunload", n), a.push(() => {
|
|
2161
2161
|
window.removeEventListener("pagehide", n), window.removeEventListener("beforeunload", n);
|
|
@@ -2170,33 +2170,33 @@ function cr(e, t, n, r, i, a) {
|
|
|
2170
2170
|
} else t.removeAttribute("data-formie-internal-resubmit");
|
|
2171
2171
|
let l = a.submitter, d = l?.getAttribute("data-formie-action"), p = t.getAttribute("data-formie-pending-action"), h = t.querySelector("input[name=\"submitAction\"]"), _ = d || p || h?.value || "submit", v = null, y = !1;
|
|
2172
2172
|
try {
|
|
2173
|
-
if (s) v = await
|
|
2173
|
+
if (s) v = await Gt({
|
|
2174
2174
|
target: e,
|
|
2175
2175
|
form: t,
|
|
2176
2176
|
bus: r,
|
|
2177
2177
|
validator: i,
|
|
2178
|
-
validateOnSubmit:
|
|
2178
|
+
validateOnSubmit: Q(t),
|
|
2179
2179
|
action: _,
|
|
2180
2180
|
submitter: l,
|
|
2181
|
-
waitForSubmitDelay:
|
|
2181
|
+
waitForSubmitDelay: $n,
|
|
2182
2182
|
onRefreshTokensAfterSubmit: async () => {
|
|
2183
|
-
await
|
|
2183
|
+
await or(e, n, t);
|
|
2184
2184
|
},
|
|
2185
2185
|
dispatchSubmitResult: (t) => {
|
|
2186
2186
|
g(e, "formie:submit:result", t);
|
|
2187
2187
|
}
|
|
2188
2188
|
});
|
|
2189
2189
|
else {
|
|
2190
|
-
if (
|
|
2190
|
+
if (Wt(t), C(t, l), await $n(t), v = await pt(t, _, r, {
|
|
2191
2191
|
validator: i,
|
|
2192
|
-
validateOnSubmit:
|
|
2192
|
+
validateOnSubmit: Q(t),
|
|
2193
2193
|
preflightOnly: !0
|
|
2194
2194
|
}), v.ok) {
|
|
2195
|
-
x(t, _), c = !0,
|
|
2195
|
+
x(t, _), c = !0, Gn(t, "submit"), u(null);
|
|
2196
2196
|
let e = !1, n = () => {
|
|
2197
|
-
if (e = !0, c = !1,
|
|
2197
|
+
if (e = !0, c = !1, Kn(t), f(t), i && Q(t)) {
|
|
2198
2198
|
let { scope: e, final: n } = m(t), r = i.submit(n ? t : e, { final: n });
|
|
2199
|
-
r.length > 0 &&
|
|
2199
|
+
r.length > 0 && z(t, {
|
|
2200
2200
|
ok: !1,
|
|
2201
2201
|
stage: "validate",
|
|
2202
2202
|
code: "VALIDATION_FAILED",
|
|
@@ -2218,7 +2218,7 @@ function cr(e, t, n, r, i, a) {
|
|
|
2218
2218
|
y = !0;
|
|
2219
2219
|
return;
|
|
2220
2220
|
}
|
|
2221
|
-
|
|
2221
|
+
z(t, v), g(e, "formie:submit:result", v), Kn(t);
|
|
2222
2222
|
}
|
|
2223
2223
|
} catch (n) {
|
|
2224
2224
|
c = !1, v = {
|
|
@@ -2226,24 +2226,24 @@ function cr(e, t, n, r, i, a) {
|
|
|
2226
2226
|
code: "SUBMIT_ERROR",
|
|
2227
2227
|
message: n instanceof Error ? n.message : "Submission failed.",
|
|
2228
2228
|
formErrors: [n instanceof Error ? n.message : "Submission failed."]
|
|
2229
|
-
},
|
|
2229
|
+
}, z(t, v), g(e, "formie:submit:result", v), Kn(t);
|
|
2230
2230
|
} finally {
|
|
2231
|
-
u(null), !s && !y && !
|
|
2231
|
+
u(null), !s && !y && !Ut(v) && f(t);
|
|
2232
2232
|
}
|
|
2233
2233
|
};
|
|
2234
2234
|
t.addEventListener("submit", d), a.push(() => {
|
|
2235
2235
|
t.removeEventListener("submit", d);
|
|
2236
2236
|
});
|
|
2237
2237
|
}
|
|
2238
|
-
async function
|
|
2238
|
+
async function cr(e, t, n) {
|
|
2239
2239
|
if (t.refreshTokens === !1 || !t.staticCache) return;
|
|
2240
|
-
let r = t.formHandle || e.dataset.formieHandle, i =
|
|
2240
|
+
let r = t.formHandle || e.dataset.formieHandle, i = zn(t, e), a = n?.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2241
2241
|
if (!r) return;
|
|
2242
|
-
let o = await
|
|
2243
|
-
o && n && (
|
|
2242
|
+
let o = await Qe(i, r, a, t, n?.querySelector("input[name=\"requestToken\"]")?.value, n?.querySelector("input[name=\"siteId\"]")?.value || t.siteId);
|
|
2243
|
+
o && n && (ir(n, o), g(e, "formie:refresh-tokens:after", o));
|
|
2244
2244
|
}
|
|
2245
|
-
function
|
|
2246
|
-
let t = /* @__PURE__ */ new Map(), r = new
|
|
2245
|
+
function lr() {
|
|
2246
|
+
let t = /* @__PURE__ */ new Map(), r = new B(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = [
|
|
2247
2247
|
"prepare",
|
|
2248
2248
|
"normalize",
|
|
2249
2249
|
"validate",
|
|
@@ -2258,45 +2258,45 @@ function ur() {
|
|
|
2258
2258
|
return;
|
|
2259
2259
|
}
|
|
2260
2260
|
let r = (async () => {
|
|
2261
|
-
|
|
2261
|
+
K.log("Unmount requested.", { target: $(e) });
|
|
2262
2262
|
let n = i.get(e);
|
|
2263
2263
|
n && (n(), i.delete(e));
|
|
2264
2264
|
let r = t.get(e);
|
|
2265
2265
|
r ? (g(e, "formie:unmount:before", { id: r.instance.id }), r.unbinds.forEach((e) => {
|
|
2266
2266
|
e();
|
|
2267
|
-
}), r.unbinds = [], r.validator?.destroy(), r.validator = null, await r.modules.destroy(), r.bus.clear(), t.delete(e), g(e, "formie:unmount:after", { id: r.instance.id }), r.unbindEventContext(),
|
|
2267
|
+
}), r.unbinds = [], r.validator?.destroy(), r.validator = null, await r.modules.destroy(), r.bus.clear(), t.delete(e), g(e, "formie:unmount:after", { id: r.instance.id }), r.unbindEventContext(), K.log("Unmount complete.", {
|
|
2268
2268
|
id: r.instance.id,
|
|
2269
|
-
target:
|
|
2270
|
-
})) :
|
|
2269
|
+
target: $(e)
|
|
2270
|
+
})) : K.log("Unmount skipped (no mounted state).", { target: $(e) });
|
|
2271
2271
|
})().finally(() => {
|
|
2272
2272
|
a.delete(e);
|
|
2273
2273
|
});
|
|
2274
2274
|
a.set(e, r), await r;
|
|
2275
2275
|
}, c = async (a, c) => {
|
|
2276
|
-
|
|
2277
|
-
target:
|
|
2276
|
+
K.log("Mount requested.", {
|
|
2277
|
+
target: $(a),
|
|
2278
2278
|
mode: c.mode,
|
|
2279
2279
|
autoVisible: c.autoVisible
|
|
2280
2280
|
});
|
|
2281
2281
|
let l = i.get(a);
|
|
2282
2282
|
l && (l(), i.delete(a));
|
|
2283
2283
|
let u = t.get(a);
|
|
2284
|
-
if (u) return
|
|
2284
|
+
if (u) return K.log("Mount skipped (already mounted).", {
|
|
2285
2285
|
id: u.instance.id,
|
|
2286
|
-
target:
|
|
2286
|
+
target: $(a)
|
|
2287
2287
|
}), u.instance;
|
|
2288
|
-
let d = new
|
|
2288
|
+
let d = new Kt(), f = [], m = a?.id || `formie-${t.size + 1}`, v = J(a), b = {
|
|
2289
2289
|
...v,
|
|
2290
2290
|
...c,
|
|
2291
|
-
mode:
|
|
2292
|
-
transport:
|
|
2293
|
-
}, x = await
|
|
2294
|
-
c.compatibility === void 0 && S?.hasAttribute("data-formie-compatibility") && (b.compatibility =
|
|
2291
|
+
mode: Pn(c.mode ?? v.mode),
|
|
2292
|
+
transport: Fn(c.transport ?? v.transport)
|
|
2293
|
+
}, x = await ar(a, b), S = Y(a);
|
|
2294
|
+
c.compatibility === void 0 && S?.hasAttribute("data-formie-compatibility") && (b.compatibility = J(S).compatibility);
|
|
2295
2295
|
let C = Te(b.compatibility);
|
|
2296
|
-
S && e(S, b), b.staticCache = c.staticCache ??
|
|
2296
|
+
S && e(S, b), b.staticCache = c.staticCache ?? Nn(S ? S.dataset : a.dataset);
|
|
2297
2297
|
let w;
|
|
2298
2298
|
try {
|
|
2299
|
-
w =
|
|
2299
|
+
w = tr(a, S), x?.modules && n(x.modules), w?.modules && n(w.modules);
|
|
2300
2300
|
} catch (e) {
|
|
2301
2301
|
if (S) {
|
|
2302
2302
|
S.addEventListener("submit", (e) => {
|
|
@@ -2315,15 +2315,15 @@ function ur() {
|
|
|
2315
2315
|
surface: "server-rendered",
|
|
2316
2316
|
entries: []
|
|
2317
2317
|
};
|
|
2318
|
-
n(E),
|
|
2319
|
-
target:
|
|
2318
|
+
n(E), K.log("Resolved mount payload.", {
|
|
2319
|
+
target: $(a),
|
|
2320
2320
|
hasRenderPayload: !!x,
|
|
2321
2321
|
hasEmbeddedPayload: !!w,
|
|
2322
2322
|
moduleCount: E.entries.length
|
|
2323
2323
|
});
|
|
2324
|
-
let D = re(a, te, S), O = S ? new
|
|
2325
|
-
live:
|
|
2326
|
-
errorAriaLive:
|
|
2324
|
+
let D = re(a, te, S), O = S ? new vn(S, {
|
|
2325
|
+
live: Vn(S.dataset.formieValidationOnFocus),
|
|
2326
|
+
errorAriaLive: P(S),
|
|
2327
2327
|
errorMessage: S.dataset.formieErrorMessage || "",
|
|
2328
2328
|
fieldContainerErrorClass: D.fieldLayoutError || [],
|
|
2329
2329
|
inputErrorClass: D.fieldControlError || [],
|
|
@@ -2340,8 +2340,8 @@ function ur() {
|
|
|
2340
2340
|
};
|
|
2341
2341
|
g(S, "formie:validator:ready", t), g(a, "formie:validator:ready", t);
|
|
2342
2342
|
}
|
|
2343
|
-
S && (y(S), (x || b.endpoint || a.dataset.formieEndpoint) &&
|
|
2344
|
-
let k = await
|
|
2343
|
+
S && (y(S), (x || b.endpoint || a.dataset.formieEndpoint) && Bn(a, S, b), b.mode === "server-rendered" && Ke(S) && (Ge(S), F(S)), h(S)), Object.keys(D).length && g(a, "formie:theme:applied", { hasClasses: !0 }), S?.querySelector("craft-csrf-input") && await se("craft-csrf-input", S);
|
|
2344
|
+
let k = await an(E, {
|
|
2345
2345
|
registry: r,
|
|
2346
2346
|
matchContext: {
|
|
2347
2347
|
root: a,
|
|
@@ -2358,24 +2358,24 @@ function ur() {
|
|
|
2358
2358
|
state: ne,
|
|
2359
2359
|
on: (e, t) => d.on(e, t),
|
|
2360
2360
|
emit: (e, t) => (g(a, e, t), d.emitSafe(e, t).then((t) => {
|
|
2361
|
-
t.failed.length > 0 &&
|
|
2361
|
+
t.failed.length > 0 && K.warn("Lifecycle listeners failed.", {
|
|
2362
2362
|
eventName: e,
|
|
2363
2363
|
failed: t.failed.length
|
|
2364
2364
|
});
|
|
2365
2365
|
}))
|
|
2366
2366
|
}
|
|
2367
2367
|
});
|
|
2368
|
-
|
|
2369
|
-
target:
|
|
2368
|
+
K.log("Module setup complete.", {
|
|
2369
|
+
target: $(a),
|
|
2370
2370
|
moduleInstances: k.instances.length
|
|
2371
2371
|
});
|
|
2372
2372
|
let A = {
|
|
2373
2373
|
id: m,
|
|
2374
2374
|
root: a,
|
|
2375
2375
|
submit: async (e = "submit") => {
|
|
2376
|
-
if (
|
|
2376
|
+
if (K.log("Submit requested.", {
|
|
2377
2377
|
id: m,
|
|
2378
|
-
target:
|
|
2378
|
+
target: $(a),
|
|
2379
2379
|
action: e
|
|
2380
2380
|
}), !S) return {
|
|
2381
2381
|
ok: !1,
|
|
@@ -2390,24 +2390,24 @@ function ur() {
|
|
|
2390
2390
|
message: "Submission already in progress.",
|
|
2391
2391
|
formErrors: []
|
|
2392
2392
|
};
|
|
2393
|
-
let n = S.querySelector(`[data-formie-action="${e}"]`), r = await
|
|
2393
|
+
let n = S.querySelector(`[data-formie-action="${e}"]`), r = await Gt({
|
|
2394
2394
|
id: m,
|
|
2395
2395
|
target: a,
|
|
2396
2396
|
form: S,
|
|
2397
2397
|
bus: d,
|
|
2398
2398
|
validator: O,
|
|
2399
|
-
validateOnSubmit:
|
|
2399
|
+
validateOnSubmit: Q(S),
|
|
2400
2400
|
action: e,
|
|
2401
2401
|
submitter: n,
|
|
2402
|
-
waitForSubmitDelay:
|
|
2402
|
+
waitForSubmitDelay: $n,
|
|
2403
2403
|
onRefreshTokensAfterSubmit: async () => {
|
|
2404
|
-
await
|
|
2404
|
+
await or(a, b, S);
|
|
2405
2405
|
},
|
|
2406
2406
|
dispatchSubmitResult: (e) => {
|
|
2407
2407
|
g(a, "formie:submit:result", e);
|
|
2408
2408
|
}
|
|
2409
2409
|
});
|
|
2410
|
-
return
|
|
2410
|
+
return K.log("Submit completed.", {
|
|
2411
2411
|
id: m,
|
|
2412
2412
|
action: e,
|
|
2413
2413
|
ok: r.ok,
|
|
@@ -2437,9 +2437,9 @@ function ur() {
|
|
|
2437
2437
|
options: C,
|
|
2438
2438
|
unbinds: f
|
|
2439
2439
|
})), S) {
|
|
2440
|
-
|
|
2440
|
+
sr(a, S, b, d, O, f), O && (f.push(p(S, O, a)), f.push(Cn(S)));
|
|
2441
2441
|
try {
|
|
2442
|
-
await
|
|
2442
|
+
await cr(a, b, S);
|
|
2443
2443
|
} catch (e) {
|
|
2444
2444
|
throw j(), e;
|
|
2445
2445
|
}
|
|
@@ -2503,28 +2503,28 @@ function ur() {
|
|
|
2503
2503
|
unbinds: f,
|
|
2504
2504
|
instance: A,
|
|
2505
2505
|
unbindEventContext: j
|
|
2506
|
-
}), S instanceof HTMLFormElement && b.mode === "server-rendered" &&
|
|
2506
|
+
}), S instanceof HTMLFormElement && b.mode === "server-rendered" && Ke(S) && qe(S), g(a, "formie:mount:after", {
|
|
2507
2507
|
id: m,
|
|
2508
2508
|
mode: b.mode,
|
|
2509
2509
|
instance: A
|
|
2510
|
-
}), S instanceof HTMLFormElement && ee(S),
|
|
2510
|
+
}), S instanceof HTMLFormElement && ee(S), K.log("Mount complete.", {
|
|
2511
2511
|
id: m,
|
|
2512
|
-
target:
|
|
2512
|
+
target: $(a),
|
|
2513
2513
|
mode: b.mode
|
|
2514
2514
|
}), A;
|
|
2515
2515
|
}, l = (e, n) => {
|
|
2516
|
-
if (!n.autoVisible ||
|
|
2516
|
+
if (!n.autoVisible || nr(e) || typeof IntersectionObserver > "u") return c(e, n);
|
|
2517
2517
|
if (t.has(e)) return Promise.resolve(t.get(e)?.instance || null);
|
|
2518
|
-
if (i.has(e)) return
|
|
2518
|
+
if (i.has(e)) return K.log("Mount deferred (already waiting visibility).", { target: $(e) }), Promise.resolve(null);
|
|
2519
2519
|
let r = new IntersectionObserver((t) => {
|
|
2520
|
-
t.some((t) => t.target === e && t.isIntersecting) && (r.disconnect(), i.delete(e),
|
|
2520
|
+
t.some((t) => t.target === e && t.isIntersecting) && (r.disconnect(), i.delete(e), K.log("Visibility reached, proceeding mount.", { target: $(e) }), c(e, {
|
|
2521
2521
|
...n,
|
|
2522
2522
|
autoVisible: !1
|
|
2523
2523
|
}));
|
|
2524
2524
|
}, { threshold: .01 });
|
|
2525
2525
|
return r.observe(e), i.set(e, () => {
|
|
2526
2526
|
r.disconnect();
|
|
2527
|
-
}),
|
|
2527
|
+
}), K.log("Mount deferred until visible.", { target: $(e) }), Promise.resolve(null);
|
|
2528
2528
|
};
|
|
2529
2529
|
return {
|
|
2530
2530
|
mount: c,
|
|
@@ -2532,7 +2532,7 @@ function ur() {
|
|
|
2532
2532
|
update: async (e, n) => {
|
|
2533
2533
|
let r = t.get(e);
|
|
2534
2534
|
if (!r) return c(e, {
|
|
2535
|
-
...
|
|
2535
|
+
...J(e),
|
|
2536
2536
|
...n,
|
|
2537
2537
|
mode: n.mode || "server-rendered"
|
|
2538
2538
|
});
|
|
@@ -2540,7 +2540,7 @@ function ur() {
|
|
|
2540
2540
|
...r.options,
|
|
2541
2541
|
...n
|
|
2542
2542
|
};
|
|
2543
|
-
let i = n.payload?.theme || r.options.payload?.theme ||
|
|
2543
|
+
let i = n.payload?.theme || r.options.payload?.theme || tr(e, r.form)?.theme, a = re(e, i, r.form);
|
|
2544
2544
|
return r.validator && (r.validator.config.fieldContainerErrorClass = a.fieldLayoutError || [], r.validator.config.inputErrorClass = a.fieldControlError || [], r.validator.config.messagesClass = a.fieldErrors || [], r.validator.config.messageClass = a.fieldError || []), Object.keys(a).length && g(e, "formie:theme:applied", {
|
|
2545
2545
|
hasClasses: !0,
|
|
2546
2546
|
reason: "update"
|
|
@@ -2548,24 +2548,24 @@ function ur() {
|
|
|
2548
2548
|
},
|
|
2549
2549
|
getInstance: (e) => t.get(e)?.instance || null,
|
|
2550
2550
|
refreshForCache: async (e) => {
|
|
2551
|
-
|
|
2551
|
+
In("refreshForCache", "Global `Formie.refreshForCache()` has been deprecated. Use built-in static-cache token refresh handling instead.");
|
|
2552
2552
|
let n = null;
|
|
2553
2553
|
if (n = typeof e == "string" ? document.getElementById(e) || document.querySelector(`[data-formie-form-id="${e}"]`) : e, !n) {
|
|
2554
|
-
|
|
2554
|
+
K.warn("refreshForCache target not found.", { targetOrId: e });
|
|
2555
2555
|
return;
|
|
2556
2556
|
}
|
|
2557
|
-
let r = t.get(n), i =
|
|
2557
|
+
let r = t.get(n), i = Y(n), a = r?.options || J(n);
|
|
2558
2558
|
if (!i) {
|
|
2559
|
-
|
|
2559
|
+
K.warn("refreshForCache found no form element for target.", { target: $(n) });
|
|
2560
2560
|
return;
|
|
2561
2561
|
}
|
|
2562
|
-
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s =
|
|
2562
|
+
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s = zn(a, n), c = i.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2563
2563
|
if (!o) {
|
|
2564
|
-
|
|
2564
|
+
K.warn("refreshForCache found no form handle for target.", { target: $(n) });
|
|
2565
2565
|
return;
|
|
2566
2566
|
}
|
|
2567
|
-
let l = await
|
|
2568
|
-
l && (
|
|
2567
|
+
let l = await Qe(s, o, c, a, i.querySelector("input[name=\"requestToken\"]")?.value, i.querySelector("input[name=\"siteId\"]")?.value || a.siteId);
|
|
2568
|
+
l && (ir(i, l), g(n, "formie:refresh-tokens:after", l));
|
|
2569
2569
|
},
|
|
2570
2570
|
registerModule: (e, t) => r.register(e, t),
|
|
2571
2571
|
unregisterModule: (e) => {
|
|
@@ -2573,16 +2573,16 @@ function ur() {
|
|
|
2573
2573
|
},
|
|
2574
2574
|
getRegisteredModules: () => r.getAll(),
|
|
2575
2575
|
scan: async (e) => {
|
|
2576
|
-
let t = e || document, n = Array.from(t.querySelectorAll(
|
|
2577
|
-
|
|
2576
|
+
let t = e || document, n = Array.from(t.querySelectorAll(G));
|
|
2577
|
+
K.log("Scan started.", {
|
|
2578
2578
|
scope: t === document ? "document" : t,
|
|
2579
2579
|
targetCount: n.length
|
|
2580
2580
|
});
|
|
2581
2581
|
let r = (await Promise.all(n.map((e) => {
|
|
2582
|
-
let t =
|
|
2582
|
+
let t = J(e);
|
|
2583
2583
|
return l(e, t);
|
|
2584
2584
|
}))).filter((e) => !!e);
|
|
2585
|
-
return
|
|
2585
|
+
return K.log("Scan finished.", {
|
|
2586
2586
|
mountedCount: r.length,
|
|
2587
2587
|
deferredCount: n.length - r.length
|
|
2588
2588
|
}), r;
|
|
@@ -2590,16 +2590,16 @@ function ur() {
|
|
|
2590
2590
|
observe: (e) => {
|
|
2591
2591
|
if (typeof MutationObserver > "u") return () => {};
|
|
2592
2592
|
let n = e || document;
|
|
2593
|
-
|
|
2593
|
+
K.log("Observer started.", { scope: n === document ? "document" : n });
|
|
2594
2594
|
let r = new MutationObserver((e) => {
|
|
2595
2595
|
e.forEach((e) => {
|
|
2596
2596
|
e.addedNodes.forEach((e) => {
|
|
2597
|
-
e instanceof Element && (e.matches(
|
|
2598
|
-
|
|
2597
|
+
e instanceof Element && (e.matches(G) && (K.log("Observer detected new root.", { target: $(e) }), l(e, J(e))), e.querySelectorAll(G).forEach((e) => {
|
|
2598
|
+
K.log("Observer detected new nested root.", { target: $(e) }), l(e, J(e));
|
|
2599
2599
|
}));
|
|
2600
2600
|
}), e.removedNodes.forEach((e) => {
|
|
2601
|
-
e instanceof Element && (t.has(e) && (
|
|
2602
|
-
t.has(e) && (
|
|
2601
|
+
e instanceof Element && (t.has(e) && (K.log("Observer detected removed root.", { target: $(e) }), s(e)), e.querySelectorAll(G).forEach((e) => {
|
|
2602
|
+
t.has(e) && (K.log("Observer detected removed nested root.", { target: $(e) }), s(e));
|
|
2603
2603
|
}));
|
|
2604
2604
|
});
|
|
2605
2605
|
});
|
|
@@ -2608,11 +2608,11 @@ function ur() {
|
|
|
2608
2608
|
childList: !0,
|
|
2609
2609
|
subtree: !0
|
|
2610
2610
|
}), () => {
|
|
2611
|
-
r.disconnect(),
|
|
2612
|
-
|
|
2611
|
+
r.disconnect(), K.log("Observer stopped."), i.forEach((e, t) => {
|
|
2612
|
+
rr(t, n) && (e(), i.delete(t));
|
|
2613
2613
|
});
|
|
2614
2614
|
let e = [];
|
|
2615
|
-
n instanceof Element && n.matches(
|
|
2615
|
+
n instanceof Element && n.matches(G) && e.push(n), n.querySelectorAll(G).forEach((t) => {
|
|
2616
2616
|
e.push(t);
|
|
2617
2617
|
}), e.forEach((e) => {
|
|
2618
2618
|
t.has(e) && s(e);
|
|
@@ -2623,13 +2623,13 @@ function ur() {
|
|
|
2623
2623
|
}
|
|
2624
2624
|
//#endregion
|
|
2625
2625
|
//#region src/js/core/hydrate-modules.ts
|
|
2626
|
-
var
|
|
2627
|
-
async function
|
|
2626
|
+
var ur = O("general", "module-hydrator");
|
|
2627
|
+
async function dr(e) {
|
|
2628
2628
|
let t = e.root, n = e.form ?? (t instanceof HTMLFormElement ? t : t.closest("form") ?? t.querySelector("form")), r = e.surface ?? "cp-edit", i = e.modules ?? {
|
|
2629
2629
|
contractVersion: 2,
|
|
2630
2630
|
surface: r,
|
|
2631
2631
|
entries: []
|
|
2632
|
-
}, a = e.registry ?? new
|
|
2632
|
+
}, a = e.registry ?? new B(), o = new Kt(), s = await an(i, {
|
|
2633
2633
|
registry: a,
|
|
2634
2634
|
setupContext: {
|
|
2635
2635
|
formId: n?.id || t.id || "formie-modules",
|
|
@@ -2654,7 +2654,7 @@ async function fr(e) {
|
|
|
2654
2654
|
surface: r
|
|
2655
2655
|
}
|
|
2656
2656
|
});
|
|
2657
|
-
return
|
|
2657
|
+
return ur.log("Hydrated module manifest.", {
|
|
2658
2658
|
moduleCount: i.entries.length,
|
|
2659
2659
|
instanceCount: s.instances.length,
|
|
2660
2660
|
surface: r
|
|
@@ -2721,22 +2721,22 @@ async function fr(e) {
|
|
|
2721
2721
|
}
|
|
2722
2722
|
//#endregion
|
|
2723
2723
|
//#region src/js/core/formie.ts
|
|
2724
|
-
function
|
|
2724
|
+
function fr(e) {
|
|
2725
2725
|
return e instanceof Element;
|
|
2726
2726
|
}
|
|
2727
2727
|
function pr(e) {
|
|
2728
2728
|
return e.ok;
|
|
2729
2729
|
}
|
|
2730
2730
|
function mr(e) {
|
|
2731
|
-
return typeof e == "string" ? `selector "${e}"` :
|
|
2731
|
+
return typeof e == "string" ? `selector "${e}"` : fr(e) ? `element "${e.tagName.toLowerCase()}"` : "provided element collection";
|
|
2732
2732
|
}
|
|
2733
2733
|
function hr(e) {
|
|
2734
2734
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2735
|
-
for (let r of e)
|
|
2735
|
+
for (let r of e) fr(r) && !t.has(r) && (t.add(r), n.push(r));
|
|
2736
2736
|
return n;
|
|
2737
2737
|
}
|
|
2738
2738
|
function gr(e) {
|
|
2739
|
-
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) :
|
|
2739
|
+
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : fr(e) ? [e] : hr(e);
|
|
2740
2740
|
}
|
|
2741
2741
|
function _r() {
|
|
2742
2742
|
return document.readyState === "loading" ? new Promise((e) => {
|
|
@@ -2748,7 +2748,7 @@ async function vr(e) {
|
|
|
2748
2748
|
return t.length > 0 || typeof e != "string" ? t : (await _r(), gr(e));
|
|
2749
2749
|
}
|
|
2750
2750
|
function yr(e) {
|
|
2751
|
-
return typeof e == "string" ? document :
|
|
2751
|
+
return typeof e == "string" ? document : fr(e) ? e.getRootNode() : document;
|
|
2752
2752
|
}
|
|
2753
2753
|
function br(e) {
|
|
2754
2754
|
let { element: t, observe: n, allowEmpty: r, client: i, onReady: a, onResult: o, onSuccess: s, onError: c, onEvent: l, ...u } = e;
|
|
@@ -2783,7 +2783,7 @@ async function xr(e, t, n, r) {
|
|
|
2783
2783
|
return i;
|
|
2784
2784
|
}
|
|
2785
2785
|
async function Sr(e) {
|
|
2786
|
-
let t = e.client ??
|
|
2786
|
+
let t = e.client ?? lr(), n = /* @__PURE__ */ new Map(), r = await vr(e.element);
|
|
2787
2787
|
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${mr(e.element)}.`);
|
|
2788
2788
|
await xr(e, t, n, r);
|
|
2789
2789
|
let i = e.observe ? t.observe(yr(e.element)) : null;
|
|
@@ -2808,8 +2808,77 @@ async function Sr(e) {
|
|
|
2808
2808
|
};
|
|
2809
2809
|
}
|
|
2810
2810
|
//#endregion
|
|
2811
|
+
//#region src/js/core/craft-forms.ts
|
|
2812
|
+
var Cr = "form[data-formie-craft-form]:not([data-formie-init=\"false\"])", wr = /* @__PURE__ */ new WeakMap();
|
|
2813
|
+
function Tr(e) {
|
|
2814
|
+
let t = wr.get(e);
|
|
2815
|
+
if (t) return t;
|
|
2816
|
+
let n = JSON.parse(e.dataset.formieThemeClasses || "{}"), r = re(e, n), i = e.getAttribute("novalidate"), a = new vn(e, {
|
|
2817
|
+
live: e.dataset.formieValidationOnFocus === "true",
|
|
2818
|
+
errorAriaLive: P(e),
|
|
2819
|
+
fieldContainerErrorClass: r.fieldLayoutError || [],
|
|
2820
|
+
inputErrorClass: r.fieldControlError || [],
|
|
2821
|
+
messagesClass: r.fieldErrors || [],
|
|
2822
|
+
messageClass: r.fieldError || []
|
|
2823
|
+
}), o = (t) => {
|
|
2824
|
+
let n = t.submitter;
|
|
2825
|
+
t.defaultPrevented || i !== null || e.dataset.formieValidationOnSubmit === "false" || n?.hasAttribute("formnovalidate") || a.submit().length && (t.preventDefault(), F(e));
|
|
2826
|
+
}, s = (t) => {
|
|
2827
|
+
queueMicrotask(() => {
|
|
2828
|
+
!t.defaultPrevented && wr.has(e) && a.resetLiveState();
|
|
2829
|
+
});
|
|
2830
|
+
};
|
|
2831
|
+
e.addEventListener("submit", o), e.addEventListener("reset", s);
|
|
2832
|
+
let c = {
|
|
2833
|
+
validator: a,
|
|
2834
|
+
owners: /* @__PURE__ */ new Set(),
|
|
2835
|
+
destroy: () => {
|
|
2836
|
+
e.removeEventListener("submit", o), e.removeEventListener("reset", s), a.removeEventListeners(), a.resetLiveState(), i === null ? e.removeAttribute("novalidate") : e.setAttribute("novalidate", i), wr.delete(e);
|
|
2837
|
+
}
|
|
2838
|
+
};
|
|
2839
|
+
return wr.set(e, c), e.dispatchEvent(new CustomEvent("formie:validator:ready", {
|
|
2840
|
+
bubbles: !0,
|
|
2841
|
+
detail: {
|
|
2842
|
+
validator: a,
|
|
2843
|
+
addValidator: a.addValidator.bind(a),
|
|
2844
|
+
removeValidator: a.removeValidator.bind(a)
|
|
2845
|
+
}
|
|
2846
|
+
})), c;
|
|
2847
|
+
}
|
|
2848
|
+
function Er({ root: e = document, observe: t = !1 } = {}) {
|
|
2849
|
+
let n = Symbol("craftForms"), r = /* @__PURE__ */ new Map(), i = !1, a = (e, t) => {
|
|
2850
|
+
t.owners.delete(n), t.owners.size || t.destroy(), r.delete(e);
|
|
2851
|
+
}, o = () => {
|
|
2852
|
+
if (i) return;
|
|
2853
|
+
let t = new Set(e.querySelectorAll(Cr));
|
|
2854
|
+
e instanceof HTMLFormElement && e.matches(Cr) && t.add(e);
|
|
2855
|
+
for (let [e, n] of r) t.has(e) || a(e, n);
|
|
2856
|
+
for (let e of t) if (!r.has(e)) try {
|
|
2857
|
+
let t = Tr(e);
|
|
2858
|
+
t.owners.add(n), r.set(e, t);
|
|
2859
|
+
} catch (e) {
|
|
2860
|
+
console.warn("Formie could not initialize Craft form validation.", e);
|
|
2861
|
+
}
|
|
2862
|
+
};
|
|
2863
|
+
o();
|
|
2864
|
+
let s = t ? new MutationObserver(o) : null;
|
|
2865
|
+
return s?.observe(e, {
|
|
2866
|
+
childList: !0,
|
|
2867
|
+
subtree: !0,
|
|
2868
|
+
attributes: !0,
|
|
2869
|
+
attributeFilter: ["data-formie-craft-form", "data-formie-init"]
|
|
2870
|
+
}), {
|
|
2871
|
+
get: (e) => r.get(e)?.validator || null,
|
|
2872
|
+
rescan: o,
|
|
2873
|
+
destroy: () => {
|
|
2874
|
+
i = !0, s?.disconnect();
|
|
2875
|
+
for (let [e, t] of r) a(e, t);
|
|
2876
|
+
}
|
|
2877
|
+
};
|
|
2878
|
+
}
|
|
2879
|
+
//#endregion
|
|
2811
2880
|
//#region src/js/core/client-rendered-modules.ts
|
|
2812
|
-
var
|
|
2881
|
+
var Dr = {
|
|
2813
2882
|
conditions: {
|
|
2814
2883
|
kind: "core",
|
|
2815
2884
|
reason: "Core evaluates structured conditions and the adapter renders visibility."
|
|
@@ -2843,8 +2912,8 @@ var Cr = {
|
|
|
2843
2912
|
reason: "The adapter renders the structured date input contract."
|
|
2844
2913
|
}
|
|
2845
2914
|
};
|
|
2846
|
-
async function
|
|
2847
|
-
for (let [e, t] of Object.entries(
|
|
2915
|
+
async function Or(t, n, r = qt) {
|
|
2916
|
+
for (let [e, t] of Object.entries(Dr)) {
|
|
2848
2917
|
let n = `formie:${e}`;
|
|
2849
2918
|
r.get(n) || r.register({
|
|
2850
2919
|
moduleId: n,
|
|
@@ -2872,7 +2941,7 @@ async function wr(t, n, r = Jt) {
|
|
|
2872
2941
|
}
|
|
2873
2942
|
};
|
|
2874
2943
|
a();
|
|
2875
|
-
let o = n.subscribe(a), s = await
|
|
2944
|
+
let o = n.subscribe(a), s = await dr({
|
|
2876
2945
|
root: t,
|
|
2877
2946
|
modules: n.getState().definition.modules,
|
|
2878
2947
|
surface: "client-rendered",
|
|
@@ -2906,4 +2975,4 @@ async function wr(t, n, r = Jt) {
|
|
|
2906
2975
|
};
|
|
2907
2976
|
}
|
|
2908
2977
|
//#endregion
|
|
2909
|
-
export { l as FORMIE_HTML_EVENT_NAMES,
|
|
2978
|
+
export { l as FORMIE_HTML_EVENT_NAMES, vn as FormieValidator, Ce as LEGACY_FORMIE_DOM_EVENT_BRIDGES, we as LEGACY_FORMIE_VALIDATOR_EVENT_BRIDGES, B as ModuleRegistry, Ae as bindLegacyDomEventCompatibility, Me as bindLegacyValidatorCompatibility, be as buildFieldValueRegistry, qt as clientRenderedModuleRegistry, Er as craftForms, O as createDebug, lr as createFormieClient, E as debugLog, D as debugWarn, Se as defineAddressModule, me as defineCaptchaModule, pe as definePassiveCaptchaModule, w as definePaymentModule, _e as fieldKeyToInputName, Sr as formie, c as getFieldModuleEventName, fe as getFormieTranslations, s as getGlobalModuleLifecycleEventName, i as getScopedModuleLifecycleEventName, dr as hydrateFormieModules, he as inputNameToFieldKey, ne as isFormieDebugEnabled, ue as mergeFormieTranslations, Or as mountClientRenderedModules, ge as normalizeFieldKey, u as normalizeFormieEventName, ve as parseFieldReference, xe as resolveFieldReferenceFromFormData, ye as resolveFieldReferenceLive, Te as resolveLegacyCompatibilityOptions, te as setFormieDebugEnabled, de as setFormieTranslations, le as t, a as toDomEventName, ce as translate };
|