@verbb/formie-browser 1.0.17-next.8.g031176b155cf → 4.0.7
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 +7 -0
- package/dist/chunks/{api-BR2Gqy37.js → api-DlW6054X.js} +3 -1
- package/dist/chunks/{bpoint-GvYfyPjD.js → bpoint-BKRpTj1e.js} +1 -1
- package/dist/chunks/{eway-BZuTBAUW.js → eway-9ZTEmiod.js} +1 -1
- package/dist/chunks/{file-upload-vEUr_EuP.js → file-upload-Bhxg5QZe.js} +2 -0
- package/dist/chunks/{go-cardless-DWZeB0Bq.js → go-cardless-BN096eDZ.js} +1 -1
- package/dist/chunks/{mollie-8OMXIYa8.js → mollie-DCBzpCmt.js} +1 -1
- package/dist/chunks/{moneris-qYHJ9EFy.js → moneris-CeryRRRJ.js} +1 -1
- package/dist/chunks/{opayo-DlWPEnla.js → opayo-D5cbEqJy.js} +1 -1
- package/dist/chunks/{paddle-CArfWih0.js → paddle-CDiiBCJ8.js} +1 -1
- package/dist/chunks/{paypal-BcaMCMGY.js → paypal-CA-kRKlJ.js} +1 -1
- package/dist/chunks/{payway-vxC7_bfR.js → payway-K9eUUMvk.js} +1 -1
- package/dist/chunks/{square-Dyz0p_GU.js → square-Bn6y1M0R.js} +1 -1
- package/dist/chunks/{stripe-Bfd_jp_k.js → stripe-CmzSSdMg.js} +1 -1
- package/dist/chunks/{upload-manager-CkmsPJRl.js → upload-manager-cGKWwGhu.js} +196 -192
- package/dist/css/formie-base.css +26 -26
- package/dist/css/theme-base/_primitives.css +9 -8
- package/dist/index.js +430 -422
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/submit-result-state.d.ts.map +1 -1
- package/dist/js/core/validation-focus.d.ts +1 -0
- package/dist/js/core/validation-focus.d.ts.map +1 -1
- package/dist/js/modules/fields/file-upload.d.ts.map +1 -1
- package/dist/js/modules/fields/upload-manager.d.ts.map +1 -1
- package/package.json +4 -6
- package/src/css/formie-base.css +26 -26
- package/src/css/theme-base/_primitives.css +9 -8
- package/src/js/core/create-formie-client.ts +5 -0
- package/src/js/core/submit-result-state.ts +5 -0
- package/src/js/core/validation-focus.ts +40 -15
- package/src/js/modules/fields/file-upload.ts +7 -0
- package/src/js/modules/fields/upload-manager.ts +27 -12
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as e } from "./chunks/request-profile-DhwkeCpS.js";
|
|
2
2
|
import { i as t, m as n, t as r } from "./chunks/dist-CJReDlDK.js";
|
|
3
3
|
import { c as i, d as a, l as o, o as s, r as c, t as l, u } from "./chunks/event-names-BCI2FLD8.js";
|
|
4
|
-
import { _ as d, a as f, c as p, d as m, f as h, g, h as _, i as v, l as y, m as ee, o as b, p as x, r as S, s as C, t as w, u as T } from "./chunks/api-
|
|
4
|
+
import { _ as d, a as f, c as p, d as m, f as h, g, h as _, i as v, l as y, m as ee, o as b, p as x, r as S, s as C, t as w, u as T } from "./chunks/api-DlW6054X.js";
|
|
5
5
|
import { a as te, i as ne, n as E, r as D, t as O } from "./chunks/debug-rhzqP1j2.js";
|
|
6
6
|
import { i as k, r as re, t as A } from "./chunks/theme-classes-DAQuEqdP.js";
|
|
7
7
|
import { n as j } from "./chunks/skip-CEW89ExY.js";
|
|
@@ -245,36 +245,44 @@ function He(e) {
|
|
|
245
245
|
return e;
|
|
246
246
|
}
|
|
247
247
|
function Ue(e) {
|
|
248
|
-
let t
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
for (let t of e) {
|
|
249
|
+
let e = He(t);
|
|
250
|
+
if (!(e instanceof HTMLInputElement && e.type === "hidden") && e.getClientRects().length > 0) return e;
|
|
251
|
+
}
|
|
252
|
+
return null;
|
|
252
253
|
}
|
|
253
254
|
function We(e) {
|
|
254
|
-
return e.
|
|
255
|
+
return Ue(Array.from(e.querySelectorAll("[aria-invalid=\"true\"]")).filter((e) => !j(e))) || Ue(Array.from(e.querySelectorAll("input:not([type=\"hidden\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])")));
|
|
255
256
|
}
|
|
256
257
|
function Ge(e) {
|
|
258
|
+
return e.querySelector("[data-formie-message-error], [data-formie-error-container], [data-formie-errors]");
|
|
259
|
+
}
|
|
260
|
+
function Ke(e) {
|
|
257
261
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
258
|
-
let n = t;
|
|
259
|
-
if (
|
|
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
|
+
if (!i && !a) return;
|
|
260
264
|
n.setAttribute("data-formie-field-has-error", "true"), A(n, e, "fieldLayoutError");
|
|
261
|
-
let
|
|
265
|
+
let o = n.querySelector("[data-formie-field-error]")?.id || "";
|
|
262
266
|
n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
263
|
-
let
|
|
264
|
-
if (j(
|
|
265
|
-
|
|
266
|
-
let
|
|
267
|
-
|
|
267
|
+
let r = t;
|
|
268
|
+
if (j(r)) return;
|
|
269
|
+
r.setAttribute("aria-invalid", "true"), A(r, e, "fieldControlError"), r.setAttribute("data-formie-input-has-error", "true"), o && ze(r, o);
|
|
270
|
+
let i = n.querySelector("[data-formie-instructions]");
|
|
271
|
+
i?.id && Le(r, i.id);
|
|
268
272
|
});
|
|
269
273
|
});
|
|
270
274
|
}
|
|
271
|
-
function Ke(e) {
|
|
272
|
-
return !!Ve(e) || !!We(e);
|
|
273
|
-
}
|
|
274
275
|
function qe(e) {
|
|
276
|
+
return !!Ve(e) || !!Ge(e);
|
|
277
|
+
}
|
|
278
|
+
function Je(e) {
|
|
279
|
+
let t = document.activeElement;
|
|
280
|
+
(!t || t === document.body || t.getClientRects().length === 0) && P(e);
|
|
281
|
+
}
|
|
282
|
+
function P(e) {
|
|
275
283
|
let t = Ve(e);
|
|
276
284
|
if (t) {
|
|
277
|
-
let e =
|
|
285
|
+
let e = We(t);
|
|
278
286
|
if (e) {
|
|
279
287
|
if (e.scrollIntoView({
|
|
280
288
|
behavior: "smooth",
|
|
@@ -291,7 +299,7 @@ function qe(e) {
|
|
|
291
299
|
block: "center"
|
|
292
300
|
}), !0;
|
|
293
301
|
}
|
|
294
|
-
let n =
|
|
302
|
+
let n = Ge(e);
|
|
295
303
|
return n ? (n.scrollIntoView({
|
|
296
304
|
behavior: "smooth",
|
|
297
305
|
block: "center"
|
|
@@ -299,8 +307,8 @@ function qe(e) {
|
|
|
299
307
|
}
|
|
300
308
|
//#endregion
|
|
301
309
|
//#region src/js/transport/forms-api.ts
|
|
302
|
-
var
|
|
303
|
-
function
|
|
310
|
+
var F = O("general", "transport");
|
|
311
|
+
function Ye(e) {
|
|
304
312
|
let t = {};
|
|
305
313
|
return [
|
|
306
314
|
"theme",
|
|
@@ -311,7 +319,7 @@ function Je(e) {
|
|
|
311
319
|
e[n] !== void 0 && (t[n] = e[n]);
|
|
312
320
|
}), t;
|
|
313
321
|
}
|
|
314
|
-
function
|
|
322
|
+
function Xe(e, t) {
|
|
315
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 = [
|
|
316
324
|
"requiresAction",
|
|
317
325
|
"pending",
|
|
@@ -352,12 +360,12 @@ function Ye(e, t) {
|
|
|
352
360
|
meta: e
|
|
353
361
|
};
|
|
354
362
|
}
|
|
355
|
-
async function
|
|
363
|
+
async function Ze(e, t, n = {}, r = {}) {
|
|
356
364
|
let i = JSON.stringify({
|
|
357
365
|
handle: t,
|
|
358
366
|
renderOptions: n
|
|
359
367
|
});
|
|
360
|
-
|
|
368
|
+
F.log("requestRender start.", {
|
|
361
369
|
endpoint: e,
|
|
362
370
|
handle: t
|
|
363
371
|
});
|
|
@@ -367,17 +375,17 @@ async function Xe(e, t, n = {}, r = {}) {
|
|
|
367
375
|
body: i,
|
|
368
376
|
headers: { "Content-Type": "application/json" }
|
|
369
377
|
});
|
|
370
|
-
return
|
|
378
|
+
return F.log("requestRender complete.", { hasHtml: !!a.html }), a;
|
|
371
379
|
}
|
|
372
|
-
async function
|
|
380
|
+
async function Qe(e, t, n = {}, r = {}) {
|
|
373
381
|
let i = JSON.stringify({
|
|
374
382
|
query: "\nquery FormieHtmlForm($handle: String!, $input: ServerRenderPayloadInput) {\n formieHtmlForm(handle: $handle, input: $input) {\n html\n }\n}",
|
|
375
383
|
variables: {
|
|
376
384
|
handle: t,
|
|
377
|
-
input:
|
|
385
|
+
input: Ye(n)
|
|
378
386
|
}
|
|
379
387
|
});
|
|
380
|
-
|
|
388
|
+
F.log("requestGraphqlRender start.", {
|
|
381
389
|
endpoint: e,
|
|
382
390
|
handle: t
|
|
383
391
|
});
|
|
@@ -390,19 +398,19 @@ async function Ze(e, t, n = {}, r = {}) {
|
|
|
390
398
|
if (Array.isArray(a.errors) && a.errors.length > 0) throw Error(a.errors.map((e) => e.message || "Unknown GraphQL error").join("; "));
|
|
391
399
|
if (!a.data?.formieHtmlForm) throw Error(`Form not found for handle "${t}".`);
|
|
392
400
|
let o = a.data.formieHtmlForm;
|
|
393
|
-
return
|
|
401
|
+
return F.log("requestGraphqlRender complete.", { hasHtml: !!o.html }), o;
|
|
394
402
|
}
|
|
395
|
-
async function
|
|
403
|
+
async function $e(e, t, n, r = {}, i, a) {
|
|
396
404
|
let o = new URL(e, window.location.origin);
|
|
397
|
-
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), F.log("requestRefreshTokens start.", {
|
|
398
406
|
endpoint: o.toString(),
|
|
399
407
|
handle: t,
|
|
400
408
|
hasRenderId: !!n
|
|
401
409
|
});
|
|
402
410
|
let s = await M(o.toString(), r);
|
|
403
|
-
return
|
|
411
|
+
return F.log("requestRefreshTokens complete.", { hasRefreshTokens: !!s.refreshTokens }), s.refreshTokens || s;
|
|
404
412
|
}
|
|
405
|
-
async function
|
|
413
|
+
async function et(e, t, n) {
|
|
406
414
|
let r = new URL(e, window.location.origin), i = new FormData();
|
|
407
415
|
if (n && i.append("pageId", n), t) {
|
|
408
416
|
[
|
|
@@ -419,7 +427,7 @@ async function $e(e, t, n) {
|
|
|
419
427
|
}), ae(i, t);
|
|
420
428
|
for (let [e, n] of new FormData(t)) e.startsWith("fields[") && i.append(e, n);
|
|
421
429
|
}
|
|
422
|
-
|
|
430
|
+
F.log("requestSetPage start.", {
|
|
423
431
|
requestUrl: r.toString(),
|
|
424
432
|
pageId: n || null
|
|
425
433
|
});
|
|
@@ -432,9 +440,9 @@ async function $e(e, t, n) {
|
|
|
432
440
|
let e = a.session, n = t.querySelector("input[name=\"expectedVersion\"]"), r = t.querySelector("input[name=\"requestToken\"]");
|
|
433
441
|
n && (n.value = String(e.version)), r && e.tokens?.request && (r.value = e.tokens.request);
|
|
434
442
|
}
|
|
435
|
-
return
|
|
443
|
+
return F.log("requestSetPage complete.", a), a;
|
|
436
444
|
}
|
|
437
|
-
function
|
|
445
|
+
function tt(e, t) {
|
|
438
446
|
let n = new URL(e, window.location.origin), i = new FormData();
|
|
439
447
|
[
|
|
440
448
|
"handle",
|
|
@@ -444,7 +452,7 @@ function et(e, t) {
|
|
|
444
452
|
].forEach((e) => {
|
|
445
453
|
let n = t.querySelector(`input[name="${e}"]`)?.value?.trim();
|
|
446
454
|
n && i.append(e, n);
|
|
447
|
-
}), ae(i, t),
|
|
455
|
+
}), ae(i, t), F.log("clearSubmissionOnUnload start.", { requestUrl: n.toString() });
|
|
448
456
|
try {
|
|
449
457
|
if (t.dataset.formieRequestProfile !== "cross-origin-public" && typeof navigator.sendBeacon == "function" && navigator.sendBeacon(n.toString(), i)) return;
|
|
450
458
|
} catch {}
|
|
@@ -455,9 +463,9 @@ function et(e, t) {
|
|
|
455
463
|
headers: { Accept: "application/json" }
|
|
456
464
|
}, { profile: t.dataset.formieRequestProfile });
|
|
457
465
|
}
|
|
458
|
-
async function
|
|
466
|
+
async function nt(e, t) {
|
|
459
467
|
let n = (e.getAttribute("method") || "POST").toUpperCase(), i = e.getAttribute("action") || window.location.href, a = e.dataset.formieErrorMessage?.trim() || "Submission failed.";
|
|
460
|
-
|
|
468
|
+
F.log("submitForm start.", {
|
|
461
469
|
method: n,
|
|
462
470
|
action: i,
|
|
463
471
|
submitAction: t.get("submitAction")
|
|
@@ -467,13 +475,13 @@ async function tt(e, t) {
|
|
|
467
475
|
body: t,
|
|
468
476
|
headers: { Accept: "application/json" }
|
|
469
477
|
}, { profile: e.dataset.formieRequestProfile }), s = o.headers.get("content-type") || "";
|
|
470
|
-
if (!s.includes("application/json")) return o.ok ? (
|
|
478
|
+
if (!s.includes("application/json")) return o.ok ? (F.log("submitForm non-JSON success response.", {
|
|
471
479
|
status: o.status,
|
|
472
480
|
contentType: s
|
|
473
481
|
}), {
|
|
474
482
|
ok: !0,
|
|
475
483
|
message: "Submission completed."
|
|
476
|
-
}) : (
|
|
484
|
+
}) : (F.warn("submitForm non-JSON HTTP error.", {
|
|
477
485
|
status: o.status,
|
|
478
486
|
contentType: s
|
|
479
487
|
}), {
|
|
@@ -482,8 +490,8 @@ async function tt(e, t) {
|
|
|
482
490
|
message: `Request failed (${o.status}).`,
|
|
483
491
|
formErrors: [`Request failed (${o.status}).`]
|
|
484
492
|
});
|
|
485
|
-
let c =
|
|
486
|
-
return
|
|
493
|
+
let c = Xe(await o.json(), a);
|
|
494
|
+
return F.log("submitForm JSON response normalized.", {
|
|
487
495
|
ok: c.ok,
|
|
488
496
|
code: c.code,
|
|
489
497
|
hasRedirect: !!c.redirect?.url,
|
|
@@ -492,20 +500,20 @@ async function tt(e, t) {
|
|
|
492
500
|
}
|
|
493
501
|
//#endregion
|
|
494
502
|
//#region src/js/submit/pipeline.ts
|
|
495
|
-
var
|
|
503
|
+
var rt = [
|
|
496
504
|
"prepare",
|
|
497
505
|
"validate",
|
|
498
506
|
"challenge",
|
|
499
507
|
"payment",
|
|
500
508
|
"send",
|
|
501
509
|
"result"
|
|
502
|
-
],
|
|
510
|
+
], it = [
|
|
503
511
|
"prepare",
|
|
504
512
|
"validate",
|
|
505
513
|
"challenge",
|
|
506
514
|
"payment"
|
|
507
|
-
],
|
|
508
|
-
function
|
|
515
|
+
], I = O("general", "pipeline");
|
|
516
|
+
function at(e, t) {
|
|
509
517
|
return {
|
|
510
518
|
ok: !1,
|
|
511
519
|
stage: e,
|
|
@@ -514,13 +522,13 @@ function it(e, t) {
|
|
|
514
522
|
formErrors: [t || "Submission aborted."]
|
|
515
523
|
};
|
|
516
524
|
}
|
|
517
|
-
function
|
|
525
|
+
function ot(e) {
|
|
518
526
|
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
|
|
519
527
|
}
|
|
520
|
-
function
|
|
528
|
+
function st(e) {
|
|
521
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)));
|
|
522
530
|
}
|
|
523
|
-
function
|
|
531
|
+
function ct(e, t) {
|
|
524
532
|
if (t instanceof HTMLInputElement) {
|
|
525
533
|
if (t.type === "file") {
|
|
526
534
|
Array.from(t.files || []).forEach((n) => {
|
|
@@ -533,49 +541,49 @@ function st(e, t) {
|
|
|
533
541
|
e.append(t.name, n.value);
|
|
534
542
|
}) : e.append(t.name, t.value);
|
|
535
543
|
}
|
|
536
|
-
function
|
|
544
|
+
function lt(e, t) {
|
|
537
545
|
t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
538
|
-
let n =
|
|
539
|
-
n && !n.closest("[data-formie-page]") &&
|
|
546
|
+
let n = ot(t) ? t : null;
|
|
547
|
+
n && !n.closest("[data-formie-page]") && st(n) && ct(e, n);
|
|
540
548
|
});
|
|
541
549
|
}
|
|
542
|
-
function
|
|
550
|
+
function ut(e, t) {
|
|
543
551
|
let n = /* @__PURE__ */ new Set();
|
|
544
552
|
return t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
545
|
-
let r =
|
|
546
|
-
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 = ot(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), st(r) && ct(e, r)));
|
|
547
555
|
}), n;
|
|
548
556
|
}
|
|
549
|
-
function
|
|
557
|
+
function dt(e, t) {
|
|
550
558
|
t.forEach((t) => {
|
|
551
559
|
e.has(t) || e.append(t, "");
|
|
552
560
|
});
|
|
553
561
|
}
|
|
554
|
-
function
|
|
562
|
+
function ft(e, t) {
|
|
555
563
|
let n = T(e), r = n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || null;
|
|
556
564
|
if (!n.length || !r) {
|
|
557
565
|
let n = new FormData(e);
|
|
558
566
|
return n.set("submitAction", t), n;
|
|
559
567
|
}
|
|
560
568
|
let i = new FormData();
|
|
561
|
-
return
|
|
569
|
+
return lt(i, e), dt(i, ut(i, r)), i.set("submitAction", t), i;
|
|
562
570
|
}
|
|
563
|
-
function
|
|
571
|
+
function pt(e, t) {
|
|
564
572
|
if (t !== "submit") return !1;
|
|
565
573
|
let n = T(e);
|
|
566
574
|
return !n.length || (n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || n[n.length - 1]) === n[n.length - 1];
|
|
567
575
|
}
|
|
568
|
-
async function
|
|
569
|
-
|
|
576
|
+
async function mt(e, t, n, r = {}) {
|
|
577
|
+
I.log("Starting submit pipeline.", {
|
|
570
578
|
action: t,
|
|
571
579
|
preflightOnly: r.preflightOnly === !0
|
|
572
580
|
});
|
|
573
|
-
let i = !1, a, o = null, s =
|
|
581
|
+
let i = !1, a, o = null, s = pt(e, t), c = d(e, {
|
|
574
582
|
form: e,
|
|
575
583
|
action: t,
|
|
576
|
-
formData:
|
|
584
|
+
formData: ft(e, t),
|
|
577
585
|
abort: (e) => {
|
|
578
|
-
i = !0, a = e,
|
|
586
|
+
i = !0, a = e, I.warn("Pipeline aborted.", { reason: e });
|
|
579
587
|
},
|
|
580
588
|
isAborted: () => i,
|
|
581
589
|
abortReason: () => a
|
|
@@ -623,68 +631,68 @@ async function pt(e, t, n, r = {}) {
|
|
|
623
631
|
challenge: async () => null,
|
|
624
632
|
payment: async () => null,
|
|
625
633
|
send: async (e) => {
|
|
626
|
-
e.formData =
|
|
627
|
-
let t = await
|
|
634
|
+
e.formData = ft(e.form, e.action);
|
|
635
|
+
let t = await nt(e.form, e.formData);
|
|
628
636
|
return o = t, t;
|
|
629
637
|
},
|
|
630
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)
|
|
631
639
|
};
|
|
632
640
|
{
|
|
633
641
|
let e = await n.emitSafe("formie:submit:before", c);
|
|
634
|
-
e.failed.length > 0 &&
|
|
642
|
+
e.failed.length > 0 && I.warn("Submit before listeners failed.", {
|
|
635
643
|
eventName: e.eventName,
|
|
636
644
|
failed: e.failed.length
|
|
637
645
|
});
|
|
638
646
|
}
|
|
639
647
|
if (s) {
|
|
640
648
|
let e = await n.emitSafe("formie:submit:final:before", c);
|
|
641
|
-
e.failed.length > 0 &&
|
|
649
|
+
e.failed.length > 0 && I.warn("Final submit before listeners failed.", {
|
|
642
650
|
eventName: e.eventName,
|
|
643
651
|
failed: e.failed.length
|
|
644
652
|
});
|
|
645
653
|
}
|
|
646
|
-
let f = r.preflightOnly ?
|
|
654
|
+
let f = r.preflightOnly ? it : rt;
|
|
647
655
|
for (let e of f) {
|
|
648
|
-
if (
|
|
656
|
+
if (I.log("Stage start.", {
|
|
649
657
|
stage: e,
|
|
650
658
|
action: t
|
|
651
|
-
}), i) return
|
|
659
|
+
}), i) return I.warn("Stage skipped due to abort.", {
|
|
652
660
|
stage: e,
|
|
653
661
|
reason: a
|
|
654
|
-
}),
|
|
662
|
+
}), at(e, a);
|
|
655
663
|
{
|
|
656
664
|
let t = await n.emitSafe(`formie:stage:${e}:before`, {
|
|
657
665
|
...c,
|
|
658
666
|
stage: e
|
|
659
667
|
});
|
|
660
|
-
t.failed.length > 0 &&
|
|
668
|
+
t.failed.length > 0 && I.warn("Stage before listeners failed.", {
|
|
661
669
|
stage: e,
|
|
662
670
|
failed: t.failed.length
|
|
663
671
|
});
|
|
664
672
|
}
|
|
665
673
|
if (i) {
|
|
666
|
-
let t =
|
|
674
|
+
let t = at(e, a);
|
|
667
675
|
{
|
|
668
676
|
let n = await l("formie:submit:after", t);
|
|
669
|
-
n.failed.length > 0 &&
|
|
677
|
+
n.failed.length > 0 && I.warn("Submit after listeners failed (abort before stage).", {
|
|
670
678
|
stage: e,
|
|
671
679
|
failed: n.failed.length
|
|
672
680
|
});
|
|
673
681
|
}
|
|
674
682
|
if (s) {
|
|
675
683
|
let n = await l("formie:submit:final:after", t);
|
|
676
|
-
n.failed.length > 0 &&
|
|
684
|
+
n.failed.length > 0 && I.warn("Final submit after listeners failed (abort before stage).", {
|
|
677
685
|
stage: e,
|
|
678
686
|
failed: n.failed.length
|
|
679
687
|
});
|
|
680
688
|
}
|
|
681
|
-
return
|
|
689
|
+
return I.warn("Aborted after stage before-hooks.", {
|
|
682
690
|
stage: e,
|
|
683
691
|
reason: a
|
|
684
692
|
}), t;
|
|
685
693
|
}
|
|
686
694
|
let r = await u[e](c);
|
|
687
|
-
|
|
695
|
+
I.log("Stage runner complete.", {
|
|
688
696
|
stage: e,
|
|
689
697
|
hasResult: !!r,
|
|
690
698
|
ok: r ? r.ok : void 0,
|
|
@@ -696,28 +704,28 @@ async function pt(e, t, n, r = {}) {
|
|
|
696
704
|
stage: e,
|
|
697
705
|
result: r
|
|
698
706
|
});
|
|
699
|
-
t.failed.length > 0 &&
|
|
707
|
+
t.failed.length > 0 && I.warn("Stage after listeners failed.", {
|
|
700
708
|
stage: e,
|
|
701
709
|
failed: t.failed.length
|
|
702
710
|
});
|
|
703
711
|
}
|
|
704
712
|
if (i) {
|
|
705
|
-
let t =
|
|
713
|
+
let t = at(e, a);
|
|
706
714
|
{
|
|
707
715
|
let n = await l("formie:submit:after", t);
|
|
708
|
-
n.failed.length > 0 &&
|
|
716
|
+
n.failed.length > 0 && I.warn("Submit after listeners failed (abort after stage).", {
|
|
709
717
|
stage: e,
|
|
710
718
|
failed: n.failed.length
|
|
711
719
|
});
|
|
712
720
|
}
|
|
713
721
|
if (s) {
|
|
714
722
|
let n = await l("formie:submit:final:after", t);
|
|
715
|
-
n.failed.length > 0 &&
|
|
723
|
+
n.failed.length > 0 && I.warn("Final submit after listeners failed (abort after stage).", {
|
|
716
724
|
stage: e,
|
|
717
725
|
failed: n.failed.length
|
|
718
726
|
});
|
|
719
727
|
}
|
|
720
|
-
return
|
|
728
|
+
return I.warn("Aborted after stage after-hooks.", {
|
|
721
729
|
stage: e,
|
|
722
730
|
reason: a
|
|
723
731
|
}), t;
|
|
@@ -725,19 +733,19 @@ async function pt(e, t, n, r = {}) {
|
|
|
725
733
|
if (r && !r.ok) {
|
|
726
734
|
{
|
|
727
735
|
let t = await l("formie:submit:after", r);
|
|
728
|
-
t.failed.length > 0 &&
|
|
736
|
+
t.failed.length > 0 && I.warn("Submit after listeners failed (failed stage).", {
|
|
729
737
|
stage: e,
|
|
730
738
|
failed: t.failed.length
|
|
731
739
|
});
|
|
732
740
|
}
|
|
733
741
|
if (s) {
|
|
734
742
|
let t = await l("formie:submit:final:after", r);
|
|
735
|
-
t.failed.length > 0 &&
|
|
743
|
+
t.failed.length > 0 && I.warn("Final submit after listeners failed (failed stage).", {
|
|
736
744
|
stage: e,
|
|
737
745
|
failed: t.failed.length
|
|
738
746
|
});
|
|
739
747
|
}
|
|
740
|
-
return
|
|
748
|
+
return I.warn("Pipeline short-circuited by failed stage.", {
|
|
741
749
|
stage: e,
|
|
742
750
|
code: r.code,
|
|
743
751
|
message: r.message
|
|
@@ -752,13 +760,13 @@ async function pt(e, t, n, r = {}) {
|
|
|
752
760
|
};
|
|
753
761
|
{
|
|
754
762
|
let e = await l("formie:submit:after", p);
|
|
755
|
-
e.failed.length > 0 &&
|
|
763
|
+
e.failed.length > 0 && I.warn("Submit after listeners failed (success).", { failed: e.failed.length });
|
|
756
764
|
}
|
|
757
765
|
if (s) {
|
|
758
766
|
let e = await l("formie:submit:final:after", p);
|
|
759
|
-
e.failed.length > 0 &&
|
|
767
|
+
e.failed.length > 0 && I.warn("Final submit after listeners failed (success).", { failed: e.failed.length });
|
|
760
768
|
}
|
|
761
|
-
return
|
|
769
|
+
return I.log("Pipeline completed.", {
|
|
762
770
|
ok: p.ok,
|
|
763
771
|
stage: p.stage,
|
|
764
772
|
code: p.code
|
|
@@ -766,18 +774,18 @@ async function pt(e, t, n, r = {}) {
|
|
|
766
774
|
}
|
|
767
775
|
//#endregion
|
|
768
776
|
//#region src/js/core/field-error-container.ts
|
|
769
|
-
function
|
|
777
|
+
function ht(e) {
|
|
770
778
|
return e.querySelector("[data-formie-field-layout]")?.getAttribute("data-formie-error-position")?.trim() === "above" ? "above" : "below";
|
|
771
779
|
}
|
|
772
|
-
function
|
|
780
|
+
function gt(e, t) {
|
|
773
781
|
let n = e.querySelector("[data-formie-field-errors]");
|
|
774
782
|
if (n) return n;
|
|
775
|
-
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 = ht(e), o = document.createElement("div");
|
|
776
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;
|
|
777
785
|
}
|
|
778
786
|
//#endregion
|
|
779
787
|
//#region src/js/theme/message-attributes.ts
|
|
780
|
-
function
|
|
788
|
+
function _t(e, t, n, r = !1) {
|
|
781
789
|
let i = t.getAttribute("data-formie-message-attributes");
|
|
782
790
|
if (!i) return;
|
|
783
791
|
let a;
|
|
@@ -794,62 +802,62 @@ function gt(e, t, n, r = !1) {
|
|
|
794
802
|
}
|
|
795
803
|
//#endregion
|
|
796
804
|
//#region src/js/core/submit-result-ui.ts
|
|
797
|
-
var
|
|
798
|
-
function
|
|
805
|
+
var L = /* @__PURE__ */ new WeakMap();
|
|
806
|
+
function vt(e) {
|
|
799
807
|
return (e.dataset.formieCompletionBehavior || e.dataset.formieSubmitAction || "").trim();
|
|
800
808
|
}
|
|
801
|
-
function
|
|
809
|
+
function yt(e) {
|
|
802
810
|
return (e.dataset.formieErrorMessagePosition ?? "top-form").trim();
|
|
803
811
|
}
|
|
804
|
-
function
|
|
812
|
+
function bt(e) {
|
|
805
813
|
return (e.dataset.formieSuccessMessagePosition || e.dataset.formieSubmitActionMessagePosition || "").trim();
|
|
806
814
|
}
|
|
807
|
-
function
|
|
815
|
+
function xt(e) {
|
|
808
816
|
let t = (e.dataset.formieSuccessMessageTimeout || e.dataset.formieSubmitActionMessageTimeout || "").trim();
|
|
809
817
|
if (!t) return null;
|
|
810
818
|
let n = Number.parseFloat(t);
|
|
811
819
|
return !Number.isFinite(n) || n < 0 ? null : Math.round(n * 1e3);
|
|
812
820
|
}
|
|
813
|
-
function
|
|
821
|
+
function St(e) {
|
|
814
822
|
let t = e.dataset.formieHideFormAfterSubmit ?? e.dataset.formieSubmitActionFormHide;
|
|
815
823
|
if (t === void 0) return !1;
|
|
816
824
|
let n = t.trim().toLowerCase();
|
|
817
825
|
return n === "true" || n === "1" || n === "";
|
|
818
826
|
}
|
|
819
|
-
function St(e) {
|
|
820
|
-
let t = I.get(e);
|
|
821
|
-
typeof t == "number" && (window.clearTimeout(t), I.delete(e));
|
|
822
|
-
}
|
|
823
827
|
function Ct(e) {
|
|
824
|
-
|
|
828
|
+
let t = L.get(e);
|
|
829
|
+
typeof t == "number" && (window.clearTimeout(t), L.delete(e));
|
|
825
830
|
}
|
|
826
831
|
function wt(e) {
|
|
827
|
-
return e.querySelector("[data-formie-form-messages-
|
|
832
|
+
return e.querySelector("[data-formie-form-messages-top]") || e;
|
|
828
833
|
}
|
|
829
|
-
function Tt(e
|
|
830
|
-
return
|
|
834
|
+
function Tt(e) {
|
|
835
|
+
return e.querySelector("[data-formie-form-messages-bottom]") || e;
|
|
831
836
|
}
|
|
832
837
|
function Et(e, t) {
|
|
833
|
-
return t === "
|
|
838
|
+
return t === "bottom-form" ? Tt(e) : wt(e);
|
|
839
|
+
}
|
|
840
|
+
function Dt(e, t) {
|
|
841
|
+
return t === "top-form" ? wt(e) : t === "bottom-form" && !St(e) ? Tt(e) : e;
|
|
834
842
|
}
|
|
835
|
-
function
|
|
836
|
-
let t =
|
|
843
|
+
function Ot(e) {
|
|
844
|
+
let t = yt(e), n = Et(e, t), r = n.querySelector("[data-formie-error-container], [data-formie-errors]");
|
|
837
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;
|
|
838
846
|
}
|
|
839
|
-
function
|
|
847
|
+
function kt(e, t) {
|
|
840
848
|
let n = t.querySelector("[data-formie-error-message-container], [data-formie-message][data-formie-message-error]");
|
|
841
|
-
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)), _t(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"), Ie(n, Fe(Ne(e))), n;
|
|
842
850
|
}
|
|
843
|
-
function
|
|
844
|
-
let n = e.querySelector("[data-formie-success-container]"), r =
|
|
851
|
+
function At(e, t) {
|
|
852
|
+
let n = e.querySelector("[data-formie-success-container]"), r = Dt(e, t);
|
|
845
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;
|
|
846
854
|
}
|
|
847
|
-
function
|
|
848
|
-
return
|
|
855
|
+
function jt(e) {
|
|
856
|
+
return gt(e, (t) => {
|
|
849
857
|
A(t, e, "fieldErrors");
|
|
850
858
|
});
|
|
851
859
|
}
|
|
852
|
-
function
|
|
860
|
+
function Mt(e) {
|
|
853
861
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
854
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);
|
|
855
863
|
k(n, e, "fieldLayoutError"), n.removeAttribute("data-formie-field-has-error"), n.querySelectorAll("[data-formie-field-error]").forEach((e) => {
|
|
@@ -860,7 +868,7 @@ function jt(e) {
|
|
|
860
868
|
});
|
|
861
869
|
}), h(e);
|
|
862
870
|
}
|
|
863
|
-
function
|
|
871
|
+
function Nt(e) {
|
|
864
872
|
e.querySelectorAll("[data-formie-error-container], [data-formie-errors]").forEach((t) => {
|
|
865
873
|
let n = t;
|
|
866
874
|
n.querySelectorAll("[data-formie-error]").forEach((e) => {
|
|
@@ -868,27 +876,27 @@ function Mt(e) {
|
|
|
868
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 = "");
|
|
869
877
|
});
|
|
870
878
|
}
|
|
871
|
-
function
|
|
872
|
-
|
|
879
|
+
function Pt(e) {
|
|
880
|
+
Ct(e), e.querySelectorAll("[data-formie-message-success]:not([data-formie-success-container])").forEach((e) => {
|
|
873
881
|
e.remove();
|
|
874
882
|
}), e.querySelectorAll("[data-formie-success-container]").forEach((t) => {
|
|
875
883
|
let n = t;
|
|
876
884
|
n.querySelectorAll("[data-formie-success]").forEach((e) => {
|
|
877
885
|
e.remove();
|
|
878
|
-
}),
|
|
879
|
-
}),
|
|
886
|
+
}), _t(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
|
+
}), vt(e) === "message" && St(e) || b(e, !1);
|
|
880
888
|
}
|
|
881
|
-
function
|
|
889
|
+
function Ft(e) {
|
|
882
890
|
e.querySelectorAll("[aria-invalid=\"true\"]").forEach((e) => {
|
|
883
891
|
e.removeAttribute("aria-invalid");
|
|
884
892
|
});
|
|
885
893
|
}
|
|
886
|
-
function
|
|
894
|
+
function It(e, t) {
|
|
887
895
|
let n = Fe(Ne(e));
|
|
888
896
|
Object.entries(t).forEach(([t, r]) => {
|
|
889
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)}"]`);
|
|
890
898
|
if (!a) return;
|
|
891
|
-
let o =
|
|
899
|
+
let o = jt(a), s = o.id && o.id.trim() ? o.id : `${t}-errors`;
|
|
892
900
|
o.id = s, Ie(o, n), A(a, e, "fieldLayoutError"), a.setAttribute("data-formie-field-has-error", "true"), r.forEach((t, n) => {
|
|
893
901
|
let r = document.createElement("div");
|
|
894
902
|
r.setAttribute("data-formie-field-error", "true"), r.id = `${s}-${n + 1}`, A(r, e, "fieldError"), r.textContent = t, o.appendChild(r);
|
|
@@ -902,35 +910,35 @@ function Ft(e, t) {
|
|
|
902
910
|
});
|
|
903
911
|
}), h(e);
|
|
904
912
|
}
|
|
905
|
-
function
|
|
906
|
-
if (!
|
|
907
|
-
let n =
|
|
913
|
+
function Lt(e, t) {
|
|
914
|
+
if (!yt(e)) return;
|
|
915
|
+
let n = Ot(e), r = kt(e, n);
|
|
908
916
|
A(n, e, "errors"), t.forEach((t) => {
|
|
909
917
|
let n = document.createElement("div");
|
|
910
918
|
n.setAttribute("data-formie-error", "true"), A(n, e, "error"), n.innerHTML = t, r.appendChild(n);
|
|
911
919
|
});
|
|
912
920
|
}
|
|
913
|
-
function
|
|
921
|
+
function Rt(e) {
|
|
914
922
|
if (e.ok || e.keepSubmitLoading !== !0) return !1;
|
|
915
923
|
let t = e.payment?.status;
|
|
916
924
|
return t === "requiresAction" || t === "pending" || t === "unknown";
|
|
917
925
|
}
|
|
918
|
-
function
|
|
919
|
-
let n =
|
|
926
|
+
function zt(e, t) {
|
|
927
|
+
let n = Ot(e), r = kt(e, n);
|
|
920
928
|
A(n, e, "errors");
|
|
921
929
|
let i = document.createElement("div");
|
|
922
930
|
i.setAttribute("data-formie-notice", "true"), i.setAttribute("role", "status"), A(i, e, "message"), i.textContent = t, r.appendChild(i);
|
|
923
931
|
}
|
|
924
|
-
function
|
|
925
|
-
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" ||
|
|
932
|
+
function Bt(e, t) {
|
|
933
|
+
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" || vt(e) === "message" && bt(e) !== "";
|
|
926
934
|
}
|
|
927
|
-
function
|
|
928
|
-
let r =
|
|
935
|
+
function Vt(e, t, n = {}) {
|
|
936
|
+
let r = bt(e);
|
|
929
937
|
if (!r) return;
|
|
930
|
-
let i =
|
|
931
|
-
|
|
938
|
+
let i = At(e, r);
|
|
939
|
+
_t(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");
|
|
932
940
|
let a = document.createElement("div");
|
|
933
|
-
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 && St(e) && b(e, !0);
|
|
934
942
|
let o = e.dataset.formieScrollToTop?.trim().toLowerCase();
|
|
935
943
|
o !== void 0 && [
|
|
936
944
|
"",
|
|
@@ -940,45 +948,45 @@ function Bt(e, t, n = {}) {
|
|
|
940
948
|
behavior: "smooth",
|
|
941
949
|
block: "start"
|
|
942
950
|
});
|
|
943
|
-
let s =
|
|
951
|
+
let s = xt(e);
|
|
944
952
|
if (s !== null) {
|
|
945
953
|
let t = window.setTimeout(() => {
|
|
946
|
-
|
|
954
|
+
L.delete(e), Pt(e);
|
|
947
955
|
}, s);
|
|
948
|
-
|
|
956
|
+
L.set(e, t);
|
|
949
957
|
}
|
|
950
958
|
}
|
|
951
|
-
function
|
|
952
|
-
if (
|
|
959
|
+
function R(e, t) {
|
|
960
|
+
if (Mt(e), Nt(e), Pt(e), Ft(e), t.ok) {
|
|
953
961
|
let n = t.meta?.summaryTokens;
|
|
954
962
|
n && typeof n == "object" && e.querySelectorAll("[data-formie-field-uid]").forEach((e) => {
|
|
955
963
|
let t = n[e.dataset.formieFieldUid || ""];
|
|
956
964
|
typeof t == "string" && t && e.querySelector("[data-formie-summary-container]")?.setAttribute("data-formie-summary-token", t);
|
|
957
|
-
}),
|
|
965
|
+
}), Bt(e, t) && Vt(e, t.message || "", { hideForm: t.action !== "save" });
|
|
958
966
|
} else if (!t.ok) {
|
|
959
|
-
if (
|
|
967
|
+
if (Rt(t)) {
|
|
960
968
|
let n = String(t.payment?.message || "").trim();
|
|
961
|
-
n &&
|
|
969
|
+
n && zt(e, n);
|
|
962
970
|
return;
|
|
963
971
|
}
|
|
964
|
-
t.fieldErrors &&
|
|
972
|
+
t.fieldErrors && It(e, t.fieldErrors), t.formErrors?.length ? Lt(e, t.formErrors) : !t.fieldErrors && t.message && Lt(e, [t.message]), P(e);
|
|
965
973
|
}
|
|
966
974
|
}
|
|
967
975
|
//#endregion
|
|
968
976
|
//#region src/js/core/submit-flow.ts
|
|
969
|
-
var
|
|
970
|
-
function
|
|
977
|
+
var Ht = O("general", "submit-flow");
|
|
978
|
+
function Ut(e) {
|
|
971
979
|
return !(!e.ok && e.stage === "validate");
|
|
972
980
|
}
|
|
973
|
-
function
|
|
981
|
+
function Wt(e) {
|
|
974
982
|
return e ? !!(e.keepSubmitLoading === !0 || e.ok && e.redirect?.url && e.redirect.target !== "new-tab") : !1;
|
|
975
983
|
}
|
|
976
|
-
function
|
|
977
|
-
|
|
984
|
+
function Gt(e) {
|
|
985
|
+
Mt(e), Nt(e), Pt(e), Ft(e);
|
|
978
986
|
}
|
|
979
|
-
async function
|
|
987
|
+
async function Kt(e) {
|
|
980
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;
|
|
981
|
-
|
|
989
|
+
Gt(r), C(r, c || null);
|
|
982
990
|
let p = {
|
|
983
991
|
ok: !1,
|
|
984
992
|
code: "SUBMIT_ERROR",
|
|
@@ -986,30 +994,30 @@ async function Gt(e) {
|
|
|
986
994
|
formErrors: ["Submission failed."]
|
|
987
995
|
};
|
|
988
996
|
try {
|
|
989
|
-
await l(r), p = await
|
|
997
|
+
await l(r), p = await mt(r, s, i, {
|
|
990
998
|
validator: a,
|
|
991
999
|
validateOnSubmit: o
|
|
992
|
-
}),
|
|
1000
|
+
}), R(r, p), d(p), v(r, p, s), Ut(p) && await u(p);
|
|
993
1001
|
} catch (e) {
|
|
994
1002
|
p = {
|
|
995
1003
|
ok: !1,
|
|
996
1004
|
code: "SUBMIT_ERROR",
|
|
997
1005
|
message: e instanceof Error ? e.message : "Submission failed.",
|
|
998
1006
|
formErrors: [e instanceof Error ? e.message : "Submission failed."]
|
|
999
|
-
},
|
|
1007
|
+
}, R(r, p), d(p), Ht.warn("Submit failed with exception.", {
|
|
1000
1008
|
id: t,
|
|
1001
1009
|
action: s,
|
|
1002
1010
|
target: n,
|
|
1003
1011
|
error: e instanceof Error ? e.message : e
|
|
1004
1012
|
});
|
|
1005
1013
|
} finally {
|
|
1006
|
-
|
|
1014
|
+
Wt(p) || f(r);
|
|
1007
1015
|
}
|
|
1008
1016
|
return p;
|
|
1009
1017
|
}
|
|
1010
1018
|
//#endregion
|
|
1011
1019
|
//#region src/js/events/event-bus.ts
|
|
1012
|
-
var
|
|
1020
|
+
var qt = class {
|
|
1013
1021
|
listeners = /* @__PURE__ */ new Map();
|
|
1014
1022
|
on(e, t) {
|
|
1015
1023
|
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e)?.add(t), () => {
|
|
@@ -1059,7 +1067,7 @@ var Kt = class {
|
|
|
1059
1067
|
clear() {
|
|
1060
1068
|
this.listeners.clear();
|
|
1061
1069
|
}
|
|
1062
|
-
},
|
|
1070
|
+
}, z = class {
|
|
1063
1071
|
modules = /* @__PURE__ */ new Map();
|
|
1064
1072
|
register(e, t = {}) {
|
|
1065
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) => ![
|
|
@@ -1085,12 +1093,12 @@ var Kt = class {
|
|
|
1085
1093
|
getAll() {
|
|
1086
1094
|
return Array.from(this.modules.values());
|
|
1087
1095
|
}
|
|
1088
|
-
},
|
|
1096
|
+
}, Jt = new z(), Yt = {
|
|
1089
1097
|
"address-finder": () => import("./chunks/address-finder-QK1m1eyv.js").then((e) => e.addressFinderModule),
|
|
1090
1098
|
"google-address": () => import("./chunks/google-address-DQR6rsbh.js").then((e) => e.googleAddressModule),
|
|
1091
1099
|
loqate: () => import("./chunks/loqate-ZZClcacr.js").then((e) => e.loqateModule),
|
|
1092
1100
|
"place-kit": () => import("./chunks/place-kit-BKk8xDXf.js").then((e) => e.placeKitModule)
|
|
1093
|
-
},
|
|
1101
|
+
}, Xt = {
|
|
1094
1102
|
"captcha-eu": () => import("./chunks/captcha-eu-eU_M6snp.js").then((e) => e.captchaEuModule),
|
|
1095
1103
|
"friendly-captcha-v1": () => import("./chunks/friendly-captcha-v1-C_cF1WD2.js").then((e) => e.friendlyCaptchaV1Module),
|
|
1096
1104
|
"friendly-captcha-v2": () => import("./chunks/friendly-captcha-v2-BenESH-n.js").then((e) => e.friendlyCaptchaV2Module),
|
|
@@ -1101,7 +1109,7 @@ var Kt = class {
|
|
|
1101
1109
|
"recaptcha-v3": () => import("./chunks/recaptcha-v3-DKMGQ27K.js").then((e) => e.recaptchaV3Module),
|
|
1102
1110
|
snaptcha: () => import("./chunks/snaptcha-P3EoSQud.js").then((e) => e.snaptchaModule),
|
|
1103
1111
|
turnstile: () => import("./chunks/turnstile-Sp4ubowK.js").then((e) => e.turnstileModule)
|
|
1104
|
-
},
|
|
1112
|
+
}, Zt = {
|
|
1105
1113
|
calculations: () => import("./chunks/calculations-DeEmdUDq.js").then((e) => e.calculationsModule),
|
|
1106
1114
|
"checkbox-radio": () => import("./chunks/checkbox-radio-CSXo6svm.js").then((e) => e.checkboxRadioModule),
|
|
1107
1115
|
combobox: () => import("./chunks/combobox-CTfq6v4y.js").then((e) => e.comboboxModule),
|
|
@@ -1110,8 +1118,8 @@ var Kt = class {
|
|
|
1110
1118
|
"custom-link": () => import("./chunks/custom-link-CLqFCssQ.js").then((e) => e.customLinkModule),
|
|
1111
1119
|
"custom-maps": () => import("./chunks/custom-maps-DgjYQDLj.js").then((e) => e.customMapsModule),
|
|
1112
1120
|
"date-picker": () => import("./chunks/date-picker-dp41TnRq.js").then((e) => e.datePickerModule),
|
|
1113
|
-
"file-upload": () => import("./chunks/file-upload-
|
|
1114
|
-
"upload-manager": () => import("./chunks/upload-manager-
|
|
1121
|
+
"file-upload": () => import("./chunks/file-upload-Bhxg5QZe.js").then((e) => e.fileUploadModule),
|
|
1122
|
+
"upload-manager": () => import("./chunks/upload-manager-cGKWwGhu.js").then((e) => e.uploadManagerModule),
|
|
1115
1123
|
hidden: () => import("./chunks/hidden-Bc2TpcgF.js").then((e) => e.hiddenModule),
|
|
1116
1124
|
"phone-country": () => import("./chunks/phone-country-BMyw-Qcz.js").then((e) => e.phoneCountryModule),
|
|
1117
1125
|
"password-validation": () => import("./chunks/password-validation-HGOU9kf3.js").then((e) => e.passwordValidationModule),
|
|
@@ -1126,25 +1134,25 @@ var Kt = class {
|
|
|
1126
1134
|
"survey-rating": () => import("./chunks/survey-rating-mlDMI0uq.js").then((e) => e.surveyRatingModule),
|
|
1127
1135
|
table: () => import("./chunks/table-0k6Md0IO.js").then((e) => e.tableModule),
|
|
1128
1136
|
"text-limit": () => import("./chunks/text-limit-CTVML6s7.js").then((e) => e.textLimitModule)
|
|
1129
|
-
}, Zt = {
|
|
1130
|
-
bpoint: () => import("./chunks/bpoint-GvYfyPjD.js").then((e) => e.bpointModule),
|
|
1131
|
-
eway: () => import("./chunks/eway-BZuTBAUW.js").then((e) => e.ewayModule),
|
|
1132
|
-
"go-cardless": () => import("./chunks/go-cardless-DWZeB0Bq.js").then((e) => e.goCardlessModule),
|
|
1133
|
-
mollie: () => import("./chunks/mollie-8OMXIYa8.js").then((e) => e.mollieModule),
|
|
1134
|
-
moneris: () => import("./chunks/moneris-qYHJ9EFy.js").then((e) => e.monerisModule),
|
|
1135
|
-
opayo: () => import("./chunks/opayo-DlWPEnla.js").then((e) => e.opayoModule),
|
|
1136
|
-
paddle: () => import("./chunks/paddle-CArfWih0.js").then((e) => e.paddleModule),
|
|
1137
|
-
paypal: () => import("./chunks/paypal-BcaMCMGY.js").then((e) => e.paypalModule),
|
|
1138
|
-
payway: () => import("./chunks/payway-vxC7_bfR.js").then((e) => e.paywayModule),
|
|
1139
|
-
square: () => import("./chunks/square-Dyz0p_GU.js").then((e) => e.squareModule),
|
|
1140
|
-
stripe: () => import("./chunks/stripe-Bfd_jp_k.js").then((e) => e.stripeModule)
|
|
1141
1137
|
}, Qt = {
|
|
1142
|
-
|
|
1143
|
-
|
|
1138
|
+
bpoint: () => import("./chunks/bpoint-BKRpTj1e.js").then((e) => e.bpointModule),
|
|
1139
|
+
eway: () => import("./chunks/eway-9ZTEmiod.js").then((e) => e.ewayModule),
|
|
1140
|
+
"go-cardless": () => import("./chunks/go-cardless-BN096eDZ.js").then((e) => e.goCardlessModule),
|
|
1141
|
+
mollie: () => import("./chunks/mollie-DCBzpCmt.js").then((e) => e.mollieModule),
|
|
1142
|
+
moneris: () => import("./chunks/moneris-CeryRRRJ.js").then((e) => e.monerisModule),
|
|
1143
|
+
opayo: () => import("./chunks/opayo-D5cbEqJy.js").then((e) => e.opayoModule),
|
|
1144
|
+
paddle: () => import("./chunks/paddle-CDiiBCJ8.js").then((e) => e.paddleModule),
|
|
1145
|
+
paypal: () => import("./chunks/paypal-CA-kRKlJ.js").then((e) => e.paypalModule),
|
|
1146
|
+
payway: () => import("./chunks/payway-K9eUUMvk.js").then((e) => e.paywayModule),
|
|
1147
|
+
square: () => import("./chunks/square-Bn6y1M0R.js").then((e) => e.squareModule),
|
|
1148
|
+
stripe: () => import("./chunks/stripe-CmzSSdMg.js").then((e) => e.stripeModule)
|
|
1149
|
+
}, $t = {
|
|
1150
|
+
...Zt,
|
|
1144
1151
|
...Yt,
|
|
1145
|
-
...
|
|
1146
|
-
|
|
1147
|
-
|
|
1152
|
+
...Xt,
|
|
1153
|
+
...Qt
|
|
1154
|
+
}, B = /* @__PURE__ */ new Map();
|
|
1155
|
+
function en(e) {
|
|
1148
1156
|
if (e instanceof Error) return {
|
|
1149
1157
|
name: e.name || "Error",
|
|
1150
1158
|
message: e.message || "No error message was provided.",
|
|
@@ -1166,7 +1174,7 @@ function $t(e) {
|
|
|
1166
1174
|
};
|
|
1167
1175
|
}
|
|
1168
1176
|
}
|
|
1169
|
-
function
|
|
1177
|
+
function tn(e, t, n) {
|
|
1170
1178
|
let r = [...t].filter((e) => e.required), i = [
|
|
1171
1179
|
"Formie browser module diagnostics",
|
|
1172
1180
|
`Surface: ${e}`,
|
|
@@ -1177,7 +1185,7 @@ function en(e, t, n) {
|
|
|
1177
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));
|
|
1178
1186
|
}), i.join("\n");
|
|
1179
1187
|
}
|
|
1180
|
-
async function
|
|
1188
|
+
async function nn(e) {
|
|
1181
1189
|
if (navigator.clipboard?.writeText) {
|
|
1182
1190
|
await navigator.clipboard.writeText(e);
|
|
1183
1191
|
return;
|
|
@@ -1190,26 +1198,26 @@ async function tn(e) {
|
|
|
1190
1198
|
t.remove();
|
|
1191
1199
|
}
|
|
1192
1200
|
}
|
|
1193
|
-
async function
|
|
1201
|
+
async function rn(e, t) {
|
|
1194
1202
|
let n = t.get(e);
|
|
1195
1203
|
if (n) return n;
|
|
1196
|
-
let r = e.startsWith("formie:") && Object.prototype.hasOwnProperty.call(
|
|
1204
|
+
let r = e.startsWith("formie:") && Object.prototype.hasOwnProperty.call($t, e.slice(7)) ? $t[e.slice(7)] : void 0;
|
|
1197
1205
|
if (!r) throw Error(`Browser module ${e} is not registered.`);
|
|
1198
|
-
|
|
1199
|
-
throw
|
|
1206
|
+
B.has(e) || B.set(e, r().catch((t) => {
|
|
1207
|
+
throw B.delete(e), t;
|
|
1200
1208
|
}));
|
|
1201
|
-
let i = await
|
|
1209
|
+
let i = await B.get(e);
|
|
1202
1210
|
if (i.moduleId !== e) throw Error(`Module definition does not match ${e}.`);
|
|
1203
1211
|
return t.register(i), i;
|
|
1204
1212
|
}
|
|
1205
|
-
function
|
|
1213
|
+
function an(e, t, n) {
|
|
1206
1214
|
return [...new Set(e.targets.flatMap((e) => {
|
|
1207
1215
|
if (e.type === "form") return [n || t];
|
|
1208
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)}"]`;
|
|
1209
1217
|
return [...t.matches(r) ? [t] : [], ...t.querySelectorAll(r)];
|
|
1210
1218
|
}))].filter((e) => !e.closest("[hidden], [data-formie-hidden=\"true\"], [data-formie-conditionally-hidden], [data-formie-page-hidden]"));
|
|
1211
1219
|
}
|
|
1212
|
-
async function
|
|
1220
|
+
async function on(e, t) {
|
|
1213
1221
|
n(e);
|
|
1214
1222
|
let r = e.surface;
|
|
1215
1223
|
if (t.matchContext.surface !== r || t.setupContext.surface !== r) throw Error(`Browser module manifest surface ${r} cannot mount as ${t.matchContext.surface}.`);
|
|
@@ -1222,7 +1230,7 @@ async function an(e, t) {
|
|
|
1222
1230
|
code: "MODULE_UNAVAILABLE",
|
|
1223
1231
|
message: "A form feature could not start. Reload the page or contact the site administrator."
|
|
1224
1232
|
};
|
|
1225
|
-
s.set(e.key, i), c.set(e.key,
|
|
1233
|
+
s.set(e.key, i), c.set(e.key, en(n)), console.error("[formie] Browser module failure", i, n), await t.setupContext.emit("formie:browser:module:error", i);
|
|
1226
1234
|
}, m = async (e) => {
|
|
1227
1235
|
try {
|
|
1228
1236
|
await e.destroy();
|
|
@@ -1264,7 +1272,7 @@ async function an(e, t) {
|
|
|
1264
1272
|
let d = document.createElement("span");
|
|
1265
1273
|
d.className = "formie-module-error__copy-status", d.setAttribute("role", "status"), d.setAttribute("aria-live", "polite"), u.addEventListener("click", async () => {
|
|
1266
1274
|
try {
|
|
1267
|
-
await
|
|
1275
|
+
await nn(n.textContent || ""), d.textContent = "Details copied.";
|
|
1268
1276
|
} catch {
|
|
1269
1277
|
d.textContent = "Copy failed. Select the details above and copy them manually.";
|
|
1270
1278
|
let e = document.createRange();
|
|
@@ -1274,7 +1282,7 @@ async function an(e, t) {
|
|
|
1274
1282
|
}
|
|
1275
1283
|
e.dataset.formieModuleError = "true", i !== a && a.contains(i) ? i.before(e) : a.prepend(e);
|
|
1276
1284
|
}
|
|
1277
|
-
let t = e.querySelector("[data-formie-module-error-details]"), n =
|
|
1285
|
+
let t = e.querySelector("[data-formie-module-error-details]"), n = tn(r, s.values(), c);
|
|
1278
1286
|
t && t.textContent !== n && (t.textContent = n);
|
|
1279
1287
|
}, _ = (e) => {
|
|
1280
1288
|
h() && (e.preventDefault(), e.stopImmediatePropagation(), g());
|
|
@@ -1293,7 +1301,7 @@ async function an(e, t) {
|
|
|
1293
1301
|
});
|
|
1294
1302
|
let d;
|
|
1295
1303
|
try {
|
|
1296
|
-
d =
|
|
1304
|
+
d = an(n, i, a);
|
|
1297
1305
|
} catch (e) {
|
|
1298
1306
|
s.has(n.key) || await p(n, e);
|
|
1299
1307
|
continue;
|
|
@@ -1303,7 +1311,7 @@ async function an(e, t) {
|
|
|
1303
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));
|
|
1304
1312
|
let h;
|
|
1305
1313
|
try {
|
|
1306
|
-
h = await
|
|
1314
|
+
h = await rn(n.moduleId, t.registry);
|
|
1307
1315
|
} catch (e) {
|
|
1308
1316
|
s.has(n.key) || await p(n, e);
|
|
1309
1317
|
continue;
|
|
@@ -1433,7 +1441,7 @@ async function an(e, t) {
|
|
|
1433
1441
|
}
|
|
1434
1442
|
//#endregion
|
|
1435
1443
|
//#region src/js/utils/unload-warning.ts
|
|
1436
|
-
var
|
|
1444
|
+
var sn = /* @__PURE__ */ new Set([
|
|
1437
1445
|
"action",
|
|
1438
1446
|
"redirect",
|
|
1439
1447
|
"requestToken",
|
|
@@ -1446,7 +1454,7 @@ var on = /* @__PURE__ */ new Set([
|
|
|
1446
1454
|
"draftContext",
|
|
1447
1455
|
"progressId"
|
|
1448
1456
|
]);
|
|
1449
|
-
function
|
|
1457
|
+
function cn(e) {
|
|
1450
1458
|
let t = /* @__PURE__ */ new Set(), n = !0;
|
|
1451
1459
|
return g(e, "formie:unload-warning:collect-exclusions", {
|
|
1452
1460
|
form: e,
|
|
@@ -1457,40 +1465,40 @@ function sn(e) {
|
|
|
1457
1465
|
}
|
|
1458
1466
|
}), n = !1, t;
|
|
1459
1467
|
}
|
|
1460
|
-
function
|
|
1468
|
+
function ln(e, t) {
|
|
1461
1469
|
if (e == null) return String(e);
|
|
1462
1470
|
if (typeof e == "string") return JSON.stringify(e);
|
|
1463
1471
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1464
1472
|
if (typeof e == "function") return "[function]";
|
|
1465
1473
|
if (typeof File < "u" && e instanceof File) return `[file:${e.name}:${e.size}:${e.type}]`;
|
|
1466
1474
|
if (typeof Blob < "u" && e instanceof Blob) return `[blob:${e.size}:${e.type}]`;
|
|
1467
|
-
if (Array.isArray(e)) return `[${e.map((e) =>
|
|
1475
|
+
if (Array.isArray(e)) return `[${e.map((e) => ln(e, t)).join(",")}]`;
|
|
1468
1476
|
if (typeof e == "object") {
|
|
1469
1477
|
if (t.has(e)) return "[circular]";
|
|
1470
1478
|
t.add(e);
|
|
1471
|
-
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)}:${ln(n, t)}`);
|
|
1472
1480
|
return t.delete(e), `{${n.join(",")}}`;
|
|
1473
1481
|
}
|
|
1474
1482
|
return JSON.stringify(String(e));
|
|
1475
1483
|
}
|
|
1476
|
-
function
|
|
1477
|
-
return
|
|
1484
|
+
function un(e) {
|
|
1485
|
+
return ln(e, /* @__PURE__ */ new WeakSet());
|
|
1478
1486
|
}
|
|
1479
|
-
function
|
|
1487
|
+
function dn(e, t) {
|
|
1480
1488
|
if (!e) return !1;
|
|
1481
1489
|
let n = e.endsWith("[]") ? e.slice(0, -2) : e;
|
|
1482
|
-
return !ie(n, t) && !
|
|
1490
|
+
return !ie(n, t) && !sn.has(n);
|
|
1483
1491
|
}
|
|
1484
|
-
function
|
|
1485
|
-
return
|
|
1492
|
+
function fn(e, t, n) {
|
|
1493
|
+
return un(e.filter(([e]) => !n.has(e) && dn(String(e || ""), t)));
|
|
1486
1494
|
}
|
|
1487
|
-
function
|
|
1495
|
+
function pn(e, t = {}) {
|
|
1488
1496
|
let n = [], r = !1, i = !1, a = !1, o = null, s = null, c = null, l = () => {
|
|
1489
1497
|
o !== null && (window.cancelAnimationFrame(o), o = null), s !== null && (window.clearTimeout(s), s = null), c !== null && (window.clearTimeout(c), c = null);
|
|
1490
1498
|
}, u = () => {
|
|
1491
1499
|
if (!r) return !1;
|
|
1492
|
-
let t =
|
|
1493
|
-
return a =
|
|
1500
|
+
let t = cn(e);
|
|
1501
|
+
return a = fn(Array.from(new FormData(e).entries()), e, t) !== fn(n, e, t), a;
|
|
1494
1502
|
}, d = () => {
|
|
1495
1503
|
i || (l(), n = Array.from(new FormData(e).entries()), r = !0, a = !1);
|
|
1496
1504
|
}, f = () => {
|
|
@@ -1517,7 +1525,7 @@ function fn(e, t = {}) {
|
|
|
1517
1525
|
}
|
|
1518
1526
|
//#endregion
|
|
1519
1527
|
//#region src/js/validation/rules/email.ts
|
|
1520
|
-
var
|
|
1528
|
+
var mn = {
|
|
1521
1529
|
rule: ({ input: e, getRule: n }) => {
|
|
1522
1530
|
let r = n("email");
|
|
1523
1531
|
return !r || t(e.value, {
|
|
@@ -1529,10 +1537,10 @@ var pn = {
|
|
|
1529
1537
|
};
|
|
1530
1538
|
//#endregion
|
|
1531
1539
|
//#region src/js/validation/rules/shared.ts
|
|
1532
|
-
function
|
|
1540
|
+
function hn(e) {
|
|
1533
1541
|
return e?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() || "";
|
|
1534
1542
|
}
|
|
1535
|
-
function
|
|
1543
|
+
function gn(e) {
|
|
1536
1544
|
let t = e.getRule("match");
|
|
1537
1545
|
if (!t || t === !0 || typeof t != "object" || !e.field) return null;
|
|
1538
1546
|
let n = typeof t.fieldHandle == "string" ? t.fieldHandle.trim() : "";
|
|
@@ -1542,7 +1550,7 @@ function hn(e) {
|
|
|
1542
1550
|
}
|
|
1543
1551
|
//#endregion
|
|
1544
1552
|
//#region src/js/validation/rules.ts
|
|
1545
|
-
var
|
|
1553
|
+
var _n = {
|
|
1546
1554
|
required: {
|
|
1547
1555
|
rule: ({ input: e, getRule: n }) => {
|
|
1548
1556
|
if (!n("required") || e.type === "hidden" || e.closest("[data-formie-field-handle]")?.getAttribute("data-formie-field-type") === "table") return !0;
|
|
@@ -1559,7 +1567,7 @@ var gn = {
|
|
|
1559
1567
|
},
|
|
1560
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 })
|
|
1561
1569
|
},
|
|
1562
|
-
email:
|
|
1570
|
+
email: mn,
|
|
1563
1571
|
url: {
|
|
1564
1572
|
rule: ({ input: e, getRule: n }) => {
|
|
1565
1573
|
let r = n("url");
|
|
@@ -1588,18 +1596,18 @@ var gn = {
|
|
|
1588
1596
|
},
|
|
1589
1597
|
match: {
|
|
1590
1598
|
rule: (e) => {
|
|
1591
|
-
let n =
|
|
1599
|
+
let n = gn(e);
|
|
1592
1600
|
return !n || t(e.input.value, { type: "match" }, { comparison: n.value }) === null;
|
|
1593
1601
|
},
|
|
1594
1602
|
message: (e) => {
|
|
1595
|
-
let t =
|
|
1603
|
+
let t = gn(e)?.closest("[data-formie-field-handle]"), n = hn(t);
|
|
1596
1604
|
return e.input.getAttribute("data-formie-validation-match-message") ?? e.t("{label} must match {value}.", {
|
|
1597
1605
|
label: e.label,
|
|
1598
1606
|
value: n
|
|
1599
1607
|
});
|
|
1600
1608
|
}
|
|
1601
1609
|
}
|
|
1602
|
-
},
|
|
1610
|
+
}, vn = {
|
|
1603
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,})+$/,
|
|
1604
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*)?$/,
|
|
1605
1613
|
number: /^(?:[-+]?[0-9]*[.,]?[0-9]+)$/,
|
|
@@ -1607,14 +1615,14 @@ var gn = {
|
|
|
1607
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))/,
|
|
1608
1616
|
time: /^(?:(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]))$/,
|
|
1609
1617
|
month: /^(?:(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])))$/
|
|
1610
|
-
},
|
|
1611
|
-
function
|
|
1618
|
+
}, V = O("general", "validator");
|
|
1619
|
+
function H(e) {
|
|
1612
1620
|
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement) && (!!e.name || e.hasAttribute("data-formie-date-datepicker-input"));
|
|
1613
1621
|
}
|
|
1614
|
-
function
|
|
1622
|
+
function U(e) {
|
|
1615
1623
|
return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
1616
1624
|
}
|
|
1617
|
-
var
|
|
1625
|
+
var yn = class {
|
|
1618
1626
|
form;
|
|
1619
1627
|
errors = [];
|
|
1620
1628
|
validators = {};
|
|
@@ -1636,14 +1644,14 @@ var vn = class {
|
|
|
1636
1644
|
messagesClass: [],
|
|
1637
1645
|
messageClass: [],
|
|
1638
1646
|
fieldsSelector: "input:not([type=\"hidden\"]):not([type=\"submit\"]):not([type=\"button\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])",
|
|
1639
|
-
patterns:
|
|
1647
|
+
patterns: vn,
|
|
1640
1648
|
...t
|
|
1641
|
-
}, Object.entries(
|
|
1649
|
+
}, Object.entries(_n).forEach(([e, t]) => {
|
|
1642
1650
|
this.addValidator(e, t.rule, t.message);
|
|
1643
1651
|
}), this.init();
|
|
1644
1652
|
}
|
|
1645
1653
|
init() {
|
|
1646
|
-
|
|
1654
|
+
V.log("Initializing validator.", {
|
|
1647
1655
|
formId: this.form.id || null,
|
|
1648
1656
|
live: this.config.live
|
|
1649
1657
|
}), this.form.setAttribute("novalidate", "true"), this.inputs().forEach((e) => {
|
|
@@ -1651,9 +1659,9 @@ var vn = class {
|
|
|
1651
1659
|
}), this.config.live && this.addEventListeners(), this.emitEvent(document, o("ready"), { validator: this });
|
|
1652
1660
|
}
|
|
1653
1661
|
inputs(e = null) {
|
|
1654
|
-
if (
|
|
1662
|
+
if (H(e)) return j(e) ? [] : [e];
|
|
1655
1663
|
let t = e || this.form;
|
|
1656
|
-
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) =>
|
|
1664
|
+
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) => H(e) && !j(e));
|
|
1657
1665
|
}
|
|
1658
1666
|
getInputValue(e) {
|
|
1659
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 ?? "";
|
|
@@ -1693,7 +1701,7 @@ var vn = class {
|
|
|
1693
1701
|
}), r = !0;
|
|
1694
1702
|
}
|
|
1695
1703
|
}), !r && i && this.removeError(e);
|
|
1696
|
-
}),
|
|
1704
|
+
}), V.log("Validation pass complete.", {
|
|
1697
1705
|
errorCount: this.errors.length,
|
|
1698
1706
|
includeHiddenPages: t.includeHiddenPages === !0
|
|
1699
1707
|
}), this.errors;
|
|
@@ -1723,7 +1731,7 @@ var vn = class {
|
|
|
1723
1731
|
let r = e.closest("[data-formie-field-handle]");
|
|
1724
1732
|
if (!r) return;
|
|
1725
1733
|
let i = r.querySelector("[data-formie-field-errors]");
|
|
1726
|
-
i ||=
|
|
1734
|
+
i ||= gt(r, (e) => {
|
|
1727
1735
|
this.config.messagesClass.length && e.classList.add(...this.config.messagesClass);
|
|
1728
1736
|
}), this.config.messagesClass.length && i.classList.add(...this.config.messagesClass), i.innerHTML = "";
|
|
1729
1737
|
let a = r.getAttribute("data-formie-field-handle") || "field";
|
|
@@ -1779,7 +1787,7 @@ var vn = class {
|
|
|
1779
1787
|
try {
|
|
1780
1788
|
n = JSON.parse(e);
|
|
1781
1789
|
} catch {
|
|
1782
|
-
return
|
|
1790
|
+
return V.warn("Invalid validation rules payload.", { formId: this.form.id || null }), t;
|
|
1783
1791
|
}
|
|
1784
1792
|
return Array.isArray(n) && n.forEach((e) => {
|
|
1785
1793
|
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
@@ -1788,39 +1796,39 @@ var vn = class {
|
|
|
1788
1796
|
}), t;
|
|
1789
1797
|
}
|
|
1790
1798
|
destroy() {
|
|
1791
|
-
|
|
1799
|
+
V.log("Destroying validator.", { formId: this.form.id || null }), this.removeEventListeners(), this.form.removeAttribute("novalidate"), this.emitEvent(document, o("destroy"), { validator: this });
|
|
1792
1800
|
}
|
|
1793
1801
|
isVisible(e, t = {}) {
|
|
1794
1802
|
if (e.disabled || e.hasAttribute("data-formie-conditions-disabled") || e.closest("[data-formie-conditions-disabled]") || e.closest("[data-formie-conditionally-hidden]")) return !1;
|
|
1795
1803
|
if (e.closest("[data-formie-page-hidden]")) return !!t.includeHiddenPages;
|
|
1796
1804
|
let n = e.closest("[data-formie-field-handle]"), r = n?.querySelector("[data-formie-rich-text]");
|
|
1797
|
-
if (r instanceof HTMLElement) return
|
|
1805
|
+
if (r instanceof HTMLElement) return U(r);
|
|
1798
1806
|
if (e instanceof HTMLSelectElement && e.hasAttribute("data-formie-combobox-input")) {
|
|
1799
1807
|
let t = e.nextElementSibling;
|
|
1800
|
-
if (t instanceof HTMLElement && t.classList.contains("formie-combobox")) return
|
|
1808
|
+
if (t instanceof HTMLElement && t.classList.contains("formie-combobox")) return U(t);
|
|
1801
1809
|
}
|
|
1802
|
-
return e instanceof HTMLSelectElement && n instanceof HTMLElement ?
|
|
1810
|
+
return e instanceof HTMLSelectElement && n instanceof HTMLElement ? U(e) || U(n) : U(e);
|
|
1803
1811
|
}
|
|
1804
1812
|
blurHandler(e) {
|
|
1805
|
-
e.target instanceof HTMLElement &&
|
|
1813
|
+
e.target instanceof HTMLElement && H(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)));
|
|
1806
1814
|
}
|
|
1807
1815
|
changeHandler(e) {
|
|
1808
|
-
e.target instanceof HTMLElement &&
|
|
1816
|
+
e.target instanceof HTMLElement && H(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)));
|
|
1809
1817
|
}
|
|
1810
1818
|
inputHandler(e) {
|
|
1811
|
-
e.target instanceof HTMLElement &&
|
|
1819
|
+
e.target instanceof HTMLElement && H(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));
|
|
1812
1820
|
}
|
|
1813
1821
|
submit(e = null, { final: t = !1 } = {}) {
|
|
1814
|
-
return this.submitted = !0,
|
|
1822
|
+
return this.submitted = !0, V.log("Submit validation requested.", { final: t }), this.boundListeners || this.addEventListeners(), this.removeAllErrors(), this.validate(e, { includeHiddenPages: t });
|
|
1815
1823
|
}
|
|
1816
1824
|
resetLiveState() {
|
|
1817
1825
|
this.submitted = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.errors = [], this.removeAllErrors();
|
|
1818
1826
|
}
|
|
1819
1827
|
addEventListeners() {
|
|
1820
|
-
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, V.log("Event listeners attached."));
|
|
1821
1829
|
}
|
|
1822
1830
|
removeEventListeners() {
|
|
1823
|
-
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, V.log("Event listeners removed.");
|
|
1824
1832
|
}
|
|
1825
1833
|
emitEvent(e, t, n = {}) {
|
|
1826
1834
|
e.dispatchEvent(new CustomEvent(t, {
|
|
@@ -1840,25 +1848,25 @@ var vn = class {
|
|
|
1840
1848
|
};
|
|
1841
1849
|
//#endregion
|
|
1842
1850
|
//#region src/js/validation/enter-key-guard.ts
|
|
1843
|
-
function
|
|
1851
|
+
function bn(e) {
|
|
1844
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]");
|
|
1845
1853
|
}
|
|
1846
|
-
function
|
|
1854
|
+
function xn(e, t) {
|
|
1847
1855
|
let n = e.querySelectorAll(`[data-formie-action="${t}"]`);
|
|
1848
|
-
return Array.from(n).some((e) => !
|
|
1856
|
+
return Array.from(n).some((e) => !bn(e));
|
|
1849
1857
|
}
|
|
1850
|
-
function
|
|
1858
|
+
function Sn(e) {
|
|
1851
1859
|
let { final: t } = m(e);
|
|
1852
1860
|
return "submit";
|
|
1853
1861
|
}
|
|
1854
|
-
function Sn(e) {
|
|
1855
|
-
return !bn(e, xn(e));
|
|
1856
|
-
}
|
|
1857
1862
|
function Cn(e) {
|
|
1863
|
+
return !xn(e, Sn(e));
|
|
1864
|
+
}
|
|
1865
|
+
function wn(e) {
|
|
1858
1866
|
let t = (t) => {
|
|
1859
1867
|
if (t.key !== "Enter" || t.defaultPrevented) return;
|
|
1860
1868
|
let n = t.target;
|
|
1861
|
-
(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") || Cn(e) && t.preventDefault());
|
|
1862
1870
|
};
|
|
1863
1871
|
return e.addEventListener("keydown", t, !0), () => {
|
|
1864
1872
|
e.removeEventListener("keydown", t, !0);
|
|
@@ -1866,16 +1874,16 @@ function Cn(e) {
|
|
|
1866
1874
|
}
|
|
1867
1875
|
//#endregion
|
|
1868
1876
|
//#region src/js/core/create-formie-client.ts
|
|
1869
|
-
var
|
|
1870
|
-
function
|
|
1877
|
+
var W = "[data-formie]:not([data-formie-init=\"false\"]), [data-formie-form]:not([data-formie-init=\"false\"])", Tn = 300, En = "/actions/formie/server/forms/render", Dn = "/api", On = "/actions/formie/server/forms/refresh-tokens", kn = "/actions/formie/server/submissions/submit", An = "/actions/formie/server/submissions/set-page", jn = "/actions/formie/server/submissions/clear-submission", Mn = "/actions/formie/file-upload/hydrate", G = O("general", "client"), Nn = /* @__PURE__ */ new Set();
|
|
1878
|
+
function K(e, t) {
|
|
1871
1879
|
if (e == null || e === "") return t;
|
|
1872
1880
|
let n = e.toLowerCase();
|
|
1873
1881
|
return n !== "false" && n !== "0" && n !== "off";
|
|
1874
1882
|
}
|
|
1875
|
-
function
|
|
1876
|
-
return e.formieRefreshTokens == null ? e.formieStaticCache != null &&
|
|
1883
|
+
function Pn(e) {
|
|
1884
|
+
return e.formieRefreshTokens == null ? e.formieStaticCache != null && K(e.formieStaticCache, !0) : K(e.formieRefreshTokens, !0);
|
|
1877
1885
|
}
|
|
1878
|
-
function
|
|
1886
|
+
function q(e) {
|
|
1879
1887
|
let t = e instanceof HTMLElement ? e.dataset : {};
|
|
1880
1888
|
return {
|
|
1881
1889
|
mode: "server-rendered",
|
|
@@ -1883,25 +1891,25 @@ function K(e) {
|
|
|
1883
1891
|
profile: t.formieRequestProfile,
|
|
1884
1892
|
formHandle: t.formieHandle,
|
|
1885
1893
|
endpoint: t.formieEndpoint,
|
|
1886
|
-
staticCache:
|
|
1887
|
-
autoVisible:
|
|
1888
|
-
compatibility:
|
|
1894
|
+
staticCache: Pn(t),
|
|
1895
|
+
autoVisible: K(t.formieAutoVisible, !0),
|
|
1896
|
+
compatibility: K(t.formieCompatibility, !1)
|
|
1889
1897
|
};
|
|
1890
1898
|
}
|
|
1891
|
-
function
|
|
1899
|
+
function Fn(e) {
|
|
1892
1900
|
if (e && e !== "server-rendered") throw Error("@verbb/formie-browser enhances server-rendered HTML only. Use @verbb/formie-core for client-rendered forms.");
|
|
1893
1901
|
return "server-rendered";
|
|
1894
1902
|
}
|
|
1895
|
-
function
|
|
1903
|
+
function In(e) {
|
|
1896
1904
|
return e || "rest";
|
|
1897
1905
|
}
|
|
1898
|
-
function
|
|
1906
|
+
function J(e) {
|
|
1899
1907
|
return e instanceof HTMLFormElement ? e : e.querySelector("form");
|
|
1900
1908
|
}
|
|
1901
|
-
function
|
|
1902
|
-
|
|
1909
|
+
function Ln(e, t) {
|
|
1910
|
+
Nn.has(e) || (Nn.add(e), G.warn(t));
|
|
1903
1911
|
}
|
|
1904
|
-
function
|
|
1912
|
+
function Y(e, t) {
|
|
1905
1913
|
if (!e) return e;
|
|
1906
1914
|
try {
|
|
1907
1915
|
return new URL(e).toString();
|
|
@@ -1913,7 +1921,7 @@ function J(e, t) {
|
|
|
1913
1921
|
return e;
|
|
1914
1922
|
}
|
|
1915
1923
|
}
|
|
1916
|
-
function
|
|
1924
|
+
function X(e, t) {
|
|
1917
1925
|
let n = (e || "").trim();
|
|
1918
1926
|
if (!n) return t;
|
|
1919
1927
|
if (n.includes(t)) return n;
|
|
@@ -1922,52 +1930,52 @@ function Y(e, t) {
|
|
|
1922
1930
|
let e = new URL(n, window.location.origin);
|
|
1923
1931
|
if (e.pathname.endsWith(r) || Array.from(e.searchParams.values()).some((e) => e.endsWith(r))) return n;
|
|
1924
1932
|
} catch {}
|
|
1925
|
-
return
|
|
1926
|
-
}
|
|
1927
|
-
function Ln(e, t) {
|
|
1928
|
-
return Y(e.endpoint || t.dataset.formieEndpoint, Tn);
|
|
1933
|
+
return Y(t, n);
|
|
1929
1934
|
}
|
|
1930
1935
|
function Rn(e, t) {
|
|
1931
|
-
|
|
1932
|
-
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n : J(En, n) : En;
|
|
1936
|
+
return X(e.endpoint || t.dataset.formieEndpoint, En);
|
|
1933
1937
|
}
|
|
1934
1938
|
function zn(e, t) {
|
|
1935
|
-
let n = t.dataset.
|
|
1936
|
-
return n ?
|
|
1939
|
+
let n = (e.endpoint || t.dataset.formieEndpoint || "").trim();
|
|
1940
|
+
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n : Y(Dn, n) : Dn;
|
|
1937
1941
|
}
|
|
1938
|
-
function Bn(e, t
|
|
1942
|
+
function Bn(e, t) {
|
|
1943
|
+
let n = t.dataset.formieRefreshTokensEndpoint || J(t)?.dataset.formieRefreshTokensEndpoint;
|
|
1944
|
+
return n ? Y(n, e.endpoint || t.dataset.formieEndpoint) : X(e.endpoint || t.dataset.formieEndpoint, On);
|
|
1945
|
+
}
|
|
1946
|
+
function Vn(e, t, n) {
|
|
1939
1947
|
let r = n.endpoint || e.dataset.formieEndpoint, i = t.getAttribute("action") || t.dataset.formieSubmitEndpoint;
|
|
1940
|
-
t.setAttribute("action", i ?
|
|
1948
|
+
t.setAttribute("action", i ? Y(i, r) : X(r, kn)), t.querySelectorAll("[data-formie-tab-link]").forEach((e) => {
|
|
1941
1949
|
let t = e.getAttribute("href");
|
|
1942
|
-
e.setAttribute("href", t ?
|
|
1950
|
+
e.setAttribute("href", t ? Y(t, r) : X(r, An));
|
|
1943
1951
|
}), t.querySelectorAll("[data-formie-file-upload-hydrate-endpoint]").forEach((e) => {
|
|
1944
|
-
e.setAttribute("data-formie-file-upload-hydrate-endpoint",
|
|
1952
|
+
e.setAttribute("data-formie-file-upload-hydrate-endpoint", Y(e.getAttribute("data-formie-file-upload-hydrate-endpoint") || Mn, r));
|
|
1945
1953
|
});
|
|
1946
1954
|
}
|
|
1947
|
-
function
|
|
1955
|
+
function Hn(e) {
|
|
1948
1956
|
if (e == null) return !1;
|
|
1949
1957
|
let t = e.trim().toLowerCase();
|
|
1950
1958
|
return t === "true" || t === "1" || t === "";
|
|
1951
1959
|
}
|
|
1952
|
-
function
|
|
1953
|
-
return
|
|
1960
|
+
function Un(e) {
|
|
1961
|
+
return K(e.dataset.formieAutomaticSubmissionState, !0);
|
|
1954
1962
|
}
|
|
1955
|
-
function
|
|
1956
|
-
return n.dataset.formieClearSubmissionEndpoint ?
|
|
1963
|
+
function Wn(e, t, n) {
|
|
1964
|
+
return n.dataset.formieClearSubmissionEndpoint ? Y(n.dataset.formieClearSubmissionEndpoint, e.endpoint || t.dataset.formieEndpoint) : X(e.endpoint || t.dataset.formieEndpoint, jn);
|
|
1957
1965
|
}
|
|
1958
|
-
function
|
|
1959
|
-
return
|
|
1966
|
+
function Gn(e) {
|
|
1967
|
+
return Hn(e.dataset.formieUnloadWarning);
|
|
1960
1968
|
}
|
|
1961
|
-
function
|
|
1969
|
+
function Kn(e, t) {
|
|
1962
1970
|
e.setAttribute("data-formie-internal-navigation", t);
|
|
1963
1971
|
}
|
|
1964
|
-
function
|
|
1972
|
+
function qn(e) {
|
|
1965
1973
|
e.removeAttribute("data-formie-internal-navigation");
|
|
1966
1974
|
}
|
|
1967
|
-
function
|
|
1975
|
+
function Jn(e) {
|
|
1968
1976
|
return e.getAttribute("data-formie-internal-navigation") !== null;
|
|
1969
1977
|
}
|
|
1970
|
-
function
|
|
1978
|
+
function Yn(e, t) {
|
|
1971
1979
|
if (!e) return !1;
|
|
1972
1980
|
try {
|
|
1973
1981
|
return new URL(e, window.location.origin).searchParams.has(t);
|
|
@@ -1975,30 +1983,30 @@ function Jn(e, t) {
|
|
|
1975
1983
|
return !1;
|
|
1976
1984
|
}
|
|
1977
1985
|
}
|
|
1978
|
-
function Yn(e) {
|
|
1979
|
-
return Jn(window.location.href, "resumeToken") || Jn(e.getAttribute("action"), "resumeToken");
|
|
1980
|
-
}
|
|
1981
1986
|
function Xn(e) {
|
|
1987
|
+
return Yn(window.location.href, "resumeToken") || Yn(e.getAttribute("action"), "resumeToken");
|
|
1988
|
+
}
|
|
1989
|
+
function Zn(e) {
|
|
1982
1990
|
return e instanceof MouseEvent ? e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey : !0;
|
|
1983
1991
|
}
|
|
1984
|
-
function
|
|
1992
|
+
function Qn(e, t = 0) {
|
|
1985
1993
|
if (!e) return t;
|
|
1986
1994
|
let n = Number.parseInt(e, 10);
|
|
1987
1995
|
return Number.isFinite(n) ? n : t;
|
|
1988
1996
|
}
|
|
1989
|
-
function
|
|
1990
|
-
return Math.max(0,
|
|
1997
|
+
function $n(e) {
|
|
1998
|
+
return Math.max(0, Qn(e.dataset.formieSubmitDelay, Tn));
|
|
1991
1999
|
}
|
|
1992
|
-
function
|
|
1993
|
-
return
|
|
2000
|
+
function Z(e) {
|
|
2001
|
+
return Hn(e.dataset.formieValidationOnSubmit);
|
|
1994
2002
|
}
|
|
1995
|
-
async function
|
|
1996
|
-
let t =
|
|
2003
|
+
async function er(e) {
|
|
2004
|
+
let t = $n(e);
|
|
1997
2005
|
await new Promise((e) => {
|
|
1998
2006
|
window.setTimeout(e, t);
|
|
1999
2007
|
});
|
|
2000
2008
|
}
|
|
2001
|
-
function
|
|
2009
|
+
function tr(e, t) {
|
|
2002
2010
|
let n = e?.getAttribute(t)?.trim();
|
|
2003
2011
|
if (!n) return null;
|
|
2004
2012
|
try {
|
|
@@ -2008,29 +2016,29 @@ function $n(e, t) {
|
|
|
2008
2016
|
return console.error(`[formie] Failed to parse ${t}.`, e), null;
|
|
2009
2017
|
}
|
|
2010
2018
|
}
|
|
2011
|
-
function
|
|
2019
|
+
function nr(e, t) {
|
|
2012
2020
|
let n = t || (e instanceof HTMLFormElement ? e : null);
|
|
2013
2021
|
if (!n) return null;
|
|
2014
|
-
let r =
|
|
2022
|
+
let r = tr(n, "data-formie-modules"), i = tr(n, "data-formie-theme-classes") || tr(n, "data-formie-theme");
|
|
2015
2023
|
return !r && !i ? null : {
|
|
2016
2024
|
modules: r || void 0,
|
|
2017
2025
|
theme: i || void 0
|
|
2018
2026
|
};
|
|
2019
2027
|
}
|
|
2020
|
-
function
|
|
2028
|
+
function rr(e) {
|
|
2021
2029
|
if (!(e instanceof HTMLElement)) return !0;
|
|
2022
2030
|
if (!e.isConnected || e.hidden || e.closest("[hidden]")) return !1;
|
|
2023
2031
|
let t = window.getComputedStyle(e);
|
|
2024
2032
|
return t.display === "none" || t.visibility === "hidden" ? !1 : e.getClientRects().length > 0;
|
|
2025
2033
|
}
|
|
2026
|
-
function
|
|
2034
|
+
function ir(e, t) {
|
|
2027
2035
|
return t === document ? !0 : t instanceof Element ? t === e || t.contains(e) : !0;
|
|
2028
2036
|
}
|
|
2029
2037
|
function Q(e) {
|
|
2030
2038
|
let t = e, n = t.id ? `#${t.id}` : "", r = t.dataset?.formieHandle ? `[handle="${t.dataset.formieHandle}"]` : "";
|
|
2031
2039
|
return `${t.tagName ? t.tagName.toLowerCase() : "element"}${n}${r}`;
|
|
2032
2040
|
}
|
|
2033
|
-
function
|
|
2041
|
+
function ar(e, t) {
|
|
2034
2042
|
if (t) {
|
|
2035
2043
|
if (t.csrf?.param && t.csrf?.token) {
|
|
2036
2044
|
let n = e.querySelector(`input[name="${t.csrf.param}"]`);
|
|
@@ -2057,11 +2065,11 @@ function rr(e, t) {
|
|
|
2057
2065
|
});
|
|
2058
2066
|
}
|
|
2059
2067
|
}
|
|
2060
|
-
async function
|
|
2061
|
-
let n =
|
|
2068
|
+
async function or(e, t) {
|
|
2069
|
+
let n = Fn(t.mode), r = In(t.transport);
|
|
2062
2070
|
if (n !== "server-rendered") return null;
|
|
2063
2071
|
if (t.payload) return t.payload.html && (e.innerHTML = t.payload.html), t.payload;
|
|
2064
|
-
let i = !!
|
|
2072
|
+
let i = !!J(e), a = t.formHandle || e.dataset.formieHandle;
|
|
2065
2073
|
if (i || !a) return null;
|
|
2066
2074
|
let o = {
|
|
2067
2075
|
mode: n,
|
|
@@ -2070,26 +2078,26 @@ async function ir(e, t) {
|
|
|
2070
2078
|
siteId: t.siteId,
|
|
2071
2079
|
theme: t.theme,
|
|
2072
2080
|
themeConfig: t.themeConfig
|
|
2073
|
-
}, s = r === "graphql" ?
|
|
2081
|
+
}, s = r === "graphql" ? zn(t, e) : Rn(t, e), c = r === "graphql" ? await Qe(s, a, o, t) : await Ze(s, a, {
|
|
2074
2082
|
...o,
|
|
2075
2083
|
endpoint: s
|
|
2076
2084
|
}, t);
|
|
2077
2085
|
return c?.html && (e.innerHTML = c.html), c;
|
|
2078
2086
|
}
|
|
2079
|
-
async function
|
|
2087
|
+
async function sr(e, t, n) {
|
|
2080
2088
|
if (t.refreshTokens === !1) return;
|
|
2081
2089
|
let r = t.formHandle || e.dataset.formieHandle;
|
|
2082
2090
|
if (!r) return;
|
|
2083
|
-
let i = await
|
|
2084
|
-
|
|
2091
|
+
let i = await $e(Bn(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
|
+
ar(n, i), g(e, "formie:refresh-tokens:refreshed", i);
|
|
2085
2093
|
}
|
|
2086
|
-
function
|
|
2094
|
+
function cr(e, t, n, r, i, a) {
|
|
2087
2095
|
t.dataset.formieRequestProfile = n.profile ?? "same-origin-browser", n.profile === "cross-origin-public" && (t.dataset.formieSubmitMethod = "ajax");
|
|
2088
|
-
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s =
|
|
2096
|
+
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s = Wn(n, e, t), c = !1, l = t.querySelectorAll("[data-formie-action]"), u = (e) => {
|
|
2089
2097
|
e ? t.setAttribute("data-formie-pending-action", e) : t.removeAttribute("data-formie-pending-action");
|
|
2090
2098
|
};
|
|
2091
|
-
if (
|
|
2092
|
-
let n =
|
|
2099
|
+
if (Gn(t)) {
|
|
2100
|
+
let n = pn(t, { shouldWarn: () => !Jn(t) }), r = (e) => {
|
|
2093
2101
|
if (!(e instanceof CustomEvent)) return;
|
|
2094
2102
|
let t = e.detail;
|
|
2095
2103
|
t?.ok && (t.action === "save" || t.outcome === "revised") && n.scheduleBaselineCapture();
|
|
@@ -2111,7 +2119,7 @@ function or(e, t, n, r, i, a) {
|
|
|
2111
2119
|
}), t.querySelectorAll("[data-formie-tab-link]").forEach((n) => {
|
|
2112
2120
|
let r = async (n) => {
|
|
2113
2121
|
if (o !== "ajax") {
|
|
2114
|
-
|
|
2122
|
+
Zn(n) && Kn(t, "set-page");
|
|
2115
2123
|
return;
|
|
2116
2124
|
}
|
|
2117
2125
|
n.preventDefault();
|
|
@@ -2122,10 +2130,10 @@ function or(e, t, n, r, i, a) {
|
|
|
2122
2130
|
href: a
|
|
2123
2131
|
});
|
|
2124
2132
|
try {
|
|
2125
|
-
let n = await
|
|
2133
|
+
let n = await et(a, t, i);
|
|
2126
2134
|
if (n.pageId && S(t, String(n.pageId)), !n.success) {
|
|
2127
2135
|
let { form: e = [], ...r } = n.errors ?? {};
|
|
2128
|
-
|
|
2136
|
+
Gt(t), It(t, r), Lt(t, e), P(t);
|
|
2129
2137
|
return;
|
|
2130
2138
|
}
|
|
2131
2139
|
g(e, "formie:page:navigate:after", {
|
|
@@ -2145,9 +2153,9 @@ function or(e, t, n, r, i, a) {
|
|
|
2145
2153
|
n.addEventListener("click", r), a.push(() => {
|
|
2146
2154
|
n.removeEventListener("click", r);
|
|
2147
2155
|
});
|
|
2148
|
-
}), !
|
|
2156
|
+
}), !Un(t)) {
|
|
2149
2157
|
let e = !1, n = () => {
|
|
2150
|
-
e ||
|
|
2158
|
+
e || Jn(t) || Xn(t) || (e = !0, tt(s, t));
|
|
2151
2159
|
};
|
|
2152
2160
|
window.addEventListener("pagehide", n), window.addEventListener("beforeunload", n), a.push(() => {
|
|
2153
2161
|
window.removeEventListener("pagehide", n), window.removeEventListener("beforeunload", n);
|
|
@@ -2162,33 +2170,33 @@ function or(e, t, n, r, i, a) {
|
|
|
2162
2170
|
} else t.removeAttribute("data-formie-internal-resubmit");
|
|
2163
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;
|
|
2164
2172
|
try {
|
|
2165
|
-
if (s) v = await
|
|
2173
|
+
if (s) v = await Kt({
|
|
2166
2174
|
target: e,
|
|
2167
2175
|
form: t,
|
|
2168
2176
|
bus: r,
|
|
2169
2177
|
validator: i,
|
|
2170
|
-
validateOnSubmit:
|
|
2178
|
+
validateOnSubmit: Z(t),
|
|
2171
2179
|
action: _,
|
|
2172
2180
|
submitter: l,
|
|
2173
|
-
waitForSubmitDelay:
|
|
2181
|
+
waitForSubmitDelay: er,
|
|
2174
2182
|
onRefreshTokensAfterSubmit: async () => {
|
|
2175
|
-
await
|
|
2183
|
+
await sr(e, n, t);
|
|
2176
2184
|
},
|
|
2177
2185
|
dispatchSubmitResult: (t) => {
|
|
2178
2186
|
g(e, "formie:submit:result", t);
|
|
2179
2187
|
}
|
|
2180
2188
|
});
|
|
2181
2189
|
else {
|
|
2182
|
-
if (
|
|
2190
|
+
if (Gt(t), C(t, l), await er(t), v = await mt(t, _, r, {
|
|
2183
2191
|
validator: i,
|
|
2184
|
-
validateOnSubmit:
|
|
2192
|
+
validateOnSubmit: Z(t),
|
|
2185
2193
|
preflightOnly: !0
|
|
2186
2194
|
}), v.ok) {
|
|
2187
|
-
x(t, _), c = !0,
|
|
2195
|
+
x(t, _), c = !0, Kn(t, "submit"), u(null);
|
|
2188
2196
|
let e = !1, n = () => {
|
|
2189
|
-
if (e = !0, c = !1,
|
|
2197
|
+
if (e = !0, c = !1, qn(t), f(t), i && Z(t)) {
|
|
2190
2198
|
let { scope: e, final: n } = m(t), r = i.submit(n ? t : e, { final: n });
|
|
2191
|
-
r.length > 0 &&
|
|
2199
|
+
r.length > 0 && R(t, {
|
|
2192
2200
|
ok: !1,
|
|
2193
2201
|
stage: "validate",
|
|
2194
2202
|
code: "VALIDATION_FAILED",
|
|
@@ -2210,7 +2218,7 @@ function or(e, t, n, r, i, a) {
|
|
|
2210
2218
|
y = !0;
|
|
2211
2219
|
return;
|
|
2212
2220
|
}
|
|
2213
|
-
|
|
2221
|
+
R(t, v), g(e, "formie:submit:result", v), qn(t);
|
|
2214
2222
|
}
|
|
2215
2223
|
} catch (n) {
|
|
2216
2224
|
c = !1, v = {
|
|
@@ -2218,24 +2226,24 @@ function or(e, t, n, r, i, a) {
|
|
|
2218
2226
|
code: "SUBMIT_ERROR",
|
|
2219
2227
|
message: n instanceof Error ? n.message : "Submission failed.",
|
|
2220
2228
|
formErrors: [n instanceof Error ? n.message : "Submission failed."]
|
|
2221
|
-
},
|
|
2229
|
+
}, R(t, v), g(e, "formie:submit:result", v), qn(t);
|
|
2222
2230
|
} finally {
|
|
2223
|
-
u(null), !s && !y && !
|
|
2231
|
+
u(null), !s && !y && !Wt(v) && f(t);
|
|
2224
2232
|
}
|
|
2225
2233
|
};
|
|
2226
2234
|
t.addEventListener("submit", d), a.push(() => {
|
|
2227
2235
|
t.removeEventListener("submit", d);
|
|
2228
2236
|
});
|
|
2229
2237
|
}
|
|
2230
|
-
async function
|
|
2238
|
+
async function lr(e, t, n) {
|
|
2231
2239
|
if (t.refreshTokens === !1 || !t.staticCache) return;
|
|
2232
|
-
let r = t.formHandle || e.dataset.formieHandle, i =
|
|
2240
|
+
let r = t.formHandle || e.dataset.formieHandle, i = Bn(t, e), a = n?.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2233
2241
|
if (!r) return;
|
|
2234
|
-
let o = await
|
|
2235
|
-
o && n && (
|
|
2242
|
+
let o = await $e(i, r, a, t, n?.querySelector("input[name=\"requestToken\"]")?.value, n?.querySelector("input[name=\"siteId\"]")?.value || t.siteId);
|
|
2243
|
+
o && n && (ar(n, o), g(e, "formie:refresh-tokens:after", o));
|
|
2236
2244
|
}
|
|
2237
|
-
function
|
|
2238
|
-
let t = /* @__PURE__ */ new Map(), r = new
|
|
2245
|
+
function ur() {
|
|
2246
|
+
let t = /* @__PURE__ */ new Map(), r = new z(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = [
|
|
2239
2247
|
"prepare",
|
|
2240
2248
|
"normalize",
|
|
2241
2249
|
"validate",
|
|
@@ -2250,22 +2258,22 @@ function cr() {
|
|
|
2250
2258
|
return;
|
|
2251
2259
|
}
|
|
2252
2260
|
let r = (async () => {
|
|
2253
|
-
|
|
2261
|
+
G.log("Unmount requested.", { target: Q(e) });
|
|
2254
2262
|
let n = i.get(e);
|
|
2255
2263
|
n && (n(), i.delete(e));
|
|
2256
2264
|
let r = t.get(e);
|
|
2257
2265
|
r ? (g(e, "formie:unmount:before", { id: r.instance.id }), r.unbinds.forEach((e) => {
|
|
2258
2266
|
e();
|
|
2259
|
-
}), 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(), G.log("Unmount complete.", {
|
|
2260
2268
|
id: r.instance.id,
|
|
2261
2269
|
target: Q(e)
|
|
2262
|
-
})) :
|
|
2270
|
+
})) : G.log("Unmount skipped (no mounted state).", { target: Q(e) });
|
|
2263
2271
|
})().finally(() => {
|
|
2264
2272
|
a.delete(e);
|
|
2265
2273
|
});
|
|
2266
2274
|
a.set(e, r), await r;
|
|
2267
2275
|
}, c = async (a, c) => {
|
|
2268
|
-
|
|
2276
|
+
G.log("Mount requested.", {
|
|
2269
2277
|
target: Q(a),
|
|
2270
2278
|
mode: c.mode,
|
|
2271
2279
|
autoVisible: c.autoVisible
|
|
@@ -2273,22 +2281,22 @@ function cr() {
|
|
|
2273
2281
|
let l = i.get(a);
|
|
2274
2282
|
l && (l(), i.delete(a));
|
|
2275
2283
|
let u = t.get(a);
|
|
2276
|
-
if (u) return
|
|
2284
|
+
if (u) return G.log("Mount skipped (already mounted).", {
|
|
2277
2285
|
id: u.instance.id,
|
|
2278
2286
|
target: Q(a)
|
|
2279
2287
|
}), u.instance;
|
|
2280
|
-
let d = new
|
|
2288
|
+
let d = new qt(), f = [], m = a?.id || `formie-${t.size + 1}`, v = q(a), b = {
|
|
2281
2289
|
...v,
|
|
2282
2290
|
...c,
|
|
2283
|
-
mode:
|
|
2284
|
-
transport:
|
|
2285
|
-
}, x = await
|
|
2286
|
-
c.compatibility === void 0 && S?.hasAttribute("data-formie-compatibility") && (b.compatibility =
|
|
2291
|
+
mode: Fn(c.mode ?? v.mode),
|
|
2292
|
+
transport: In(c.transport ?? v.transport)
|
|
2293
|
+
}, x = await or(a, b), S = J(a);
|
|
2294
|
+
c.compatibility === void 0 && S?.hasAttribute("data-formie-compatibility") && (b.compatibility = q(S).compatibility);
|
|
2287
2295
|
let C = Te(b.compatibility);
|
|
2288
|
-
S && e(S, b), b.staticCache = c.staticCache ??
|
|
2296
|
+
S && e(S, b), b.staticCache = c.staticCache ?? Pn(S ? S.dataset : a.dataset);
|
|
2289
2297
|
let w;
|
|
2290
2298
|
try {
|
|
2291
|
-
w =
|
|
2299
|
+
w = nr(a, S), x?.modules && n(x.modules), w?.modules && n(w.modules);
|
|
2292
2300
|
} catch (e) {
|
|
2293
2301
|
if (S) {
|
|
2294
2302
|
S.addEventListener("submit", (e) => {
|
|
@@ -2307,14 +2315,14 @@ function cr() {
|
|
|
2307
2315
|
surface: "server-rendered",
|
|
2308
2316
|
entries: []
|
|
2309
2317
|
};
|
|
2310
|
-
n(E),
|
|
2318
|
+
n(E), G.log("Resolved mount payload.", {
|
|
2311
2319
|
target: Q(a),
|
|
2312
2320
|
hasRenderPayload: !!x,
|
|
2313
2321
|
hasEmbeddedPayload: !!w,
|
|
2314
2322
|
moduleCount: E.entries.length
|
|
2315
2323
|
});
|
|
2316
|
-
let D = re(a, te, S), O = S ? new
|
|
2317
|
-
live:
|
|
2324
|
+
let D = re(a, te, S), O = S ? new yn(S, {
|
|
2325
|
+
live: Hn(S.dataset.formieValidationOnFocus),
|
|
2318
2326
|
errorAriaLive: Ne(S),
|
|
2319
2327
|
errorMessage: S.dataset.formieErrorMessage || "",
|
|
2320
2328
|
fieldContainerErrorClass: D.fieldLayoutError || [],
|
|
@@ -2332,8 +2340,8 @@ function cr() {
|
|
|
2332
2340
|
};
|
|
2333
2341
|
g(S, "formie:validator:ready", t), g(a, "formie:validator:ready", t);
|
|
2334
2342
|
}
|
|
2335
|
-
S && (y(S), (x || b.endpoint || a.dataset.formieEndpoint) &&
|
|
2336
|
-
let k = await
|
|
2343
|
+
S && (y(S), (x || b.endpoint || a.dataset.formieEndpoint) && Vn(a, S, b), b.mode === "server-rendered" && qe(S) && (Ke(S), P(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 on(E, {
|
|
2337
2345
|
registry: r,
|
|
2338
2346
|
matchContext: {
|
|
2339
2347
|
root: a,
|
|
@@ -2350,14 +2358,14 @@ function cr() {
|
|
|
2350
2358
|
state: ne,
|
|
2351
2359
|
on: (e, t) => d.on(e, t),
|
|
2352
2360
|
emit: (e, t) => (g(a, e, t), d.emitSafe(e, t).then((t) => {
|
|
2353
|
-
t.failed.length > 0 &&
|
|
2361
|
+
t.failed.length > 0 && G.warn("Lifecycle listeners failed.", {
|
|
2354
2362
|
eventName: e,
|
|
2355
2363
|
failed: t.failed.length
|
|
2356
2364
|
});
|
|
2357
2365
|
}))
|
|
2358
2366
|
}
|
|
2359
2367
|
});
|
|
2360
|
-
|
|
2368
|
+
G.log("Module setup complete.", {
|
|
2361
2369
|
target: Q(a),
|
|
2362
2370
|
moduleInstances: k.instances.length
|
|
2363
2371
|
});
|
|
@@ -2365,7 +2373,7 @@ function cr() {
|
|
|
2365
2373
|
id: m,
|
|
2366
2374
|
root: a,
|
|
2367
2375
|
submit: async (e = "submit") => {
|
|
2368
|
-
if (
|
|
2376
|
+
if (G.log("Submit requested.", {
|
|
2369
2377
|
id: m,
|
|
2370
2378
|
target: Q(a),
|
|
2371
2379
|
action: e
|
|
@@ -2382,24 +2390,24 @@ function cr() {
|
|
|
2382
2390
|
message: "Submission already in progress.",
|
|
2383
2391
|
formErrors: []
|
|
2384
2392
|
};
|
|
2385
|
-
let n = S.querySelector(`[data-formie-action="${e}"]`), r = await
|
|
2393
|
+
let n = S.querySelector(`[data-formie-action="${e}"]`), r = await Kt({
|
|
2386
2394
|
id: m,
|
|
2387
2395
|
target: a,
|
|
2388
2396
|
form: S,
|
|
2389
2397
|
bus: d,
|
|
2390
2398
|
validator: O,
|
|
2391
|
-
validateOnSubmit:
|
|
2399
|
+
validateOnSubmit: Z(S),
|
|
2392
2400
|
action: e,
|
|
2393
2401
|
submitter: n,
|
|
2394
|
-
waitForSubmitDelay:
|
|
2402
|
+
waitForSubmitDelay: er,
|
|
2395
2403
|
onRefreshTokensAfterSubmit: async () => {
|
|
2396
|
-
await
|
|
2404
|
+
await sr(a, b, S);
|
|
2397
2405
|
},
|
|
2398
2406
|
dispatchSubmitResult: (e) => {
|
|
2399
2407
|
g(a, "formie:submit:result", e);
|
|
2400
2408
|
}
|
|
2401
2409
|
});
|
|
2402
|
-
return
|
|
2410
|
+
return G.log("Submit completed.", {
|
|
2403
2411
|
id: m,
|
|
2404
2412
|
action: e,
|
|
2405
2413
|
ok: r.ok,
|
|
@@ -2429,9 +2437,9 @@ function cr() {
|
|
|
2429
2437
|
options: C,
|
|
2430
2438
|
unbinds: f
|
|
2431
2439
|
})), S) {
|
|
2432
|
-
|
|
2440
|
+
cr(a, S, b, d, O, f), O && (f.push(p(S, O, a)), f.push(wn(S)));
|
|
2433
2441
|
try {
|
|
2434
|
-
await
|
|
2442
|
+
await lr(a, b, S);
|
|
2435
2443
|
} catch (e) {
|
|
2436
2444
|
throw j(), e;
|
|
2437
2445
|
}
|
|
@@ -2495,28 +2503,28 @@ function cr() {
|
|
|
2495
2503
|
unbinds: f,
|
|
2496
2504
|
instance: A,
|
|
2497
2505
|
unbindEventContext: j
|
|
2498
|
-
}), g(a, "formie:mount:after", {
|
|
2506
|
+
}), S instanceof HTMLFormElement && b.mode === "server-rendered" && qe(S) && Je(S), g(a, "formie:mount:after", {
|
|
2499
2507
|
id: m,
|
|
2500
2508
|
mode: b.mode,
|
|
2501
2509
|
instance: A
|
|
2502
|
-
}), S instanceof HTMLFormElement && ee(S),
|
|
2510
|
+
}), S instanceof HTMLFormElement && ee(S), G.log("Mount complete.", {
|
|
2503
2511
|
id: m,
|
|
2504
2512
|
target: Q(a),
|
|
2505
2513
|
mode: b.mode
|
|
2506
2514
|
}), A;
|
|
2507
2515
|
}, l = (e, n) => {
|
|
2508
|
-
if (!n.autoVisible ||
|
|
2516
|
+
if (!n.autoVisible || rr(e) || typeof IntersectionObserver > "u") return c(e, n);
|
|
2509
2517
|
if (t.has(e)) return Promise.resolve(t.get(e)?.instance || null);
|
|
2510
|
-
if (i.has(e)) return
|
|
2518
|
+
if (i.has(e)) return G.log("Mount deferred (already waiting visibility).", { target: Q(e) }), Promise.resolve(null);
|
|
2511
2519
|
let r = new IntersectionObserver((t) => {
|
|
2512
|
-
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), G.log("Visibility reached, proceeding mount.", { target: Q(e) }), c(e, {
|
|
2513
2521
|
...n,
|
|
2514
2522
|
autoVisible: !1
|
|
2515
2523
|
}));
|
|
2516
2524
|
}, { threshold: .01 });
|
|
2517
2525
|
return r.observe(e), i.set(e, () => {
|
|
2518
2526
|
r.disconnect();
|
|
2519
|
-
}),
|
|
2527
|
+
}), G.log("Mount deferred until visible.", { target: Q(e) }), Promise.resolve(null);
|
|
2520
2528
|
};
|
|
2521
2529
|
return {
|
|
2522
2530
|
mount: c,
|
|
@@ -2524,7 +2532,7 @@ function cr() {
|
|
|
2524
2532
|
update: async (e, n) => {
|
|
2525
2533
|
let r = t.get(e);
|
|
2526
2534
|
if (!r) return c(e, {
|
|
2527
|
-
...
|
|
2535
|
+
...q(e),
|
|
2528
2536
|
...n,
|
|
2529
2537
|
mode: n.mode || "server-rendered"
|
|
2530
2538
|
});
|
|
@@ -2532,7 +2540,7 @@ function cr() {
|
|
|
2532
2540
|
...r.options,
|
|
2533
2541
|
...n
|
|
2534
2542
|
};
|
|
2535
|
-
let i = n.payload?.theme || r.options.payload?.theme ||
|
|
2543
|
+
let i = n.payload?.theme || r.options.payload?.theme || nr(e, r.form)?.theme, a = re(e, i, r.form);
|
|
2536
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", {
|
|
2537
2545
|
hasClasses: !0,
|
|
2538
2546
|
reason: "update"
|
|
@@ -2540,24 +2548,24 @@ function cr() {
|
|
|
2540
2548
|
},
|
|
2541
2549
|
getInstance: (e) => t.get(e)?.instance || null,
|
|
2542
2550
|
refreshForCache: async (e) => {
|
|
2543
|
-
|
|
2551
|
+
Ln("refreshForCache", "Global `Formie.refreshForCache()` has been deprecated. Use built-in static-cache token refresh handling instead.");
|
|
2544
2552
|
let n = null;
|
|
2545
2553
|
if (n = typeof e == "string" ? document.getElementById(e) || document.querySelector(`[data-formie-form-id="${e}"]`) : e, !n) {
|
|
2546
|
-
|
|
2554
|
+
G.warn("refreshForCache target not found.", { targetOrId: e });
|
|
2547
2555
|
return;
|
|
2548
2556
|
}
|
|
2549
|
-
let r = t.get(n), i =
|
|
2557
|
+
let r = t.get(n), i = J(n), a = r?.options || q(n);
|
|
2550
2558
|
if (!i) {
|
|
2551
|
-
|
|
2559
|
+
G.warn("refreshForCache found no form element for target.", { target: Q(n) });
|
|
2552
2560
|
return;
|
|
2553
2561
|
}
|
|
2554
|
-
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s =
|
|
2562
|
+
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s = Bn(a, n), c = i.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2555
2563
|
if (!o) {
|
|
2556
|
-
|
|
2564
|
+
G.warn("refreshForCache found no form handle for target.", { target: Q(n) });
|
|
2557
2565
|
return;
|
|
2558
2566
|
}
|
|
2559
|
-
let l = await
|
|
2560
|
-
l && (
|
|
2567
|
+
let l = await $e(s, o, c, a, i.querySelector("input[name=\"requestToken\"]")?.value, i.querySelector("input[name=\"siteId\"]")?.value || a.siteId);
|
|
2568
|
+
l && (ar(i, l), g(n, "formie:refresh-tokens:after", l));
|
|
2561
2569
|
},
|
|
2562
2570
|
registerModule: (e, t) => r.register(e, t),
|
|
2563
2571
|
unregisterModule: (e) => {
|
|
@@ -2565,16 +2573,16 @@ function cr() {
|
|
|
2565
2573
|
},
|
|
2566
2574
|
getRegisteredModules: () => r.getAll(),
|
|
2567
2575
|
scan: async (e) => {
|
|
2568
|
-
let t = e || document, n = Array.from(t.querySelectorAll(
|
|
2569
|
-
|
|
2576
|
+
let t = e || document, n = Array.from(t.querySelectorAll(W));
|
|
2577
|
+
G.log("Scan started.", {
|
|
2570
2578
|
scope: t === document ? "document" : t,
|
|
2571
2579
|
targetCount: n.length
|
|
2572
2580
|
});
|
|
2573
2581
|
let r = (await Promise.all(n.map((e) => {
|
|
2574
|
-
let t =
|
|
2582
|
+
let t = q(e);
|
|
2575
2583
|
return l(e, t);
|
|
2576
2584
|
}))).filter((e) => !!e);
|
|
2577
|
-
return
|
|
2585
|
+
return G.log("Scan finished.", {
|
|
2578
2586
|
mountedCount: r.length,
|
|
2579
2587
|
deferredCount: n.length - r.length
|
|
2580
2588
|
}), r;
|
|
@@ -2582,16 +2590,16 @@ function cr() {
|
|
|
2582
2590
|
observe: (e) => {
|
|
2583
2591
|
if (typeof MutationObserver > "u") return () => {};
|
|
2584
2592
|
let n = e || document;
|
|
2585
|
-
|
|
2593
|
+
G.log("Observer started.", { scope: n === document ? "document" : n });
|
|
2586
2594
|
let r = new MutationObserver((e) => {
|
|
2587
2595
|
e.forEach((e) => {
|
|
2588
2596
|
e.addedNodes.forEach((e) => {
|
|
2589
|
-
e instanceof Element && (e.matches(
|
|
2590
|
-
|
|
2597
|
+
e instanceof Element && (e.matches(W) && (G.log("Observer detected new root.", { target: Q(e) }), l(e, q(e))), e.querySelectorAll(W).forEach((e) => {
|
|
2598
|
+
G.log("Observer detected new nested root.", { target: Q(e) }), l(e, q(e));
|
|
2591
2599
|
}));
|
|
2592
2600
|
}), e.removedNodes.forEach((e) => {
|
|
2593
|
-
e instanceof Element && (t.has(e) && (
|
|
2594
|
-
t.has(e) && (
|
|
2601
|
+
e instanceof Element && (t.has(e) && (G.log("Observer detected removed root.", { target: Q(e) }), s(e)), e.querySelectorAll(W).forEach((e) => {
|
|
2602
|
+
t.has(e) && (G.log("Observer detected removed nested root.", { target: Q(e) }), s(e));
|
|
2595
2603
|
}));
|
|
2596
2604
|
});
|
|
2597
2605
|
});
|
|
@@ -2600,11 +2608,11 @@ function cr() {
|
|
|
2600
2608
|
childList: !0,
|
|
2601
2609
|
subtree: !0
|
|
2602
2610
|
}), () => {
|
|
2603
|
-
r.disconnect(),
|
|
2604
|
-
|
|
2611
|
+
r.disconnect(), G.log("Observer stopped."), i.forEach((e, t) => {
|
|
2612
|
+
ir(t, n) && (e(), i.delete(t));
|
|
2605
2613
|
});
|
|
2606
2614
|
let e = [];
|
|
2607
|
-
n instanceof Element && n.matches(
|
|
2615
|
+
n instanceof Element && n.matches(W) && e.push(n), n.querySelectorAll(W).forEach((t) => {
|
|
2608
2616
|
e.push(t);
|
|
2609
2617
|
}), e.forEach((e) => {
|
|
2610
2618
|
t.has(e) && s(e);
|
|
@@ -2615,13 +2623,13 @@ function cr() {
|
|
|
2615
2623
|
}
|
|
2616
2624
|
//#endregion
|
|
2617
2625
|
//#region src/js/core/hydrate-modules.ts
|
|
2618
|
-
var
|
|
2619
|
-
async function
|
|
2626
|
+
var dr = O("general", "module-hydrator");
|
|
2627
|
+
async function fr(e) {
|
|
2620
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 ?? {
|
|
2621
2629
|
contractVersion: 2,
|
|
2622
2630
|
surface: r,
|
|
2623
2631
|
entries: []
|
|
2624
|
-
}, a = e.registry ?? new
|
|
2632
|
+
}, a = e.registry ?? new z(), o = new qt(), s = await on(i, {
|
|
2625
2633
|
registry: a,
|
|
2626
2634
|
setupContext: {
|
|
2627
2635
|
formId: n?.id || t.id || "formie-modules",
|
|
@@ -2646,7 +2654,7 @@ async function ur(e) {
|
|
|
2646
2654
|
surface: r
|
|
2647
2655
|
}
|
|
2648
2656
|
});
|
|
2649
|
-
return
|
|
2657
|
+
return dr.log("Hydrated module manifest.", {
|
|
2650
2658
|
moduleCount: i.entries.length,
|
|
2651
2659
|
instanceCount: s.instances.length,
|
|
2652
2660
|
surface: r
|
|
@@ -2716,41 +2724,41 @@ async function ur(e) {
|
|
|
2716
2724
|
function $(e) {
|
|
2717
2725
|
return e instanceof Element;
|
|
2718
2726
|
}
|
|
2719
|
-
function
|
|
2727
|
+
function pr(e) {
|
|
2720
2728
|
return e.ok;
|
|
2721
2729
|
}
|
|
2722
|
-
function
|
|
2730
|
+
function mr(e) {
|
|
2723
2731
|
return typeof e == "string" ? `selector "${e}"` : $(e) ? `element "${e.tagName.toLowerCase()}"` : "provided element collection";
|
|
2724
2732
|
}
|
|
2725
|
-
function
|
|
2733
|
+
function hr(e) {
|
|
2726
2734
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2727
2735
|
for (let r of e) $(r) && !t.has(r) && (t.add(r), n.push(r));
|
|
2728
2736
|
return n;
|
|
2729
2737
|
}
|
|
2730
|
-
function
|
|
2731
|
-
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : $(e) ? [e] :
|
|
2738
|
+
function gr(e) {
|
|
2739
|
+
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : $(e) ? [e] : hr(e);
|
|
2732
2740
|
}
|
|
2733
|
-
function
|
|
2741
|
+
function _r() {
|
|
2734
2742
|
return document.readyState === "loading" ? new Promise((e) => {
|
|
2735
2743
|
document.addEventListener("DOMContentLoaded", () => e(), { once: !0 });
|
|
2736
2744
|
}) : Promise.resolve();
|
|
2737
2745
|
}
|
|
2738
|
-
async function
|
|
2739
|
-
let t =
|
|
2740
|
-
return t.length > 0 || typeof e != "string" ? t : (await
|
|
2746
|
+
async function vr(e) {
|
|
2747
|
+
let t = gr(e);
|
|
2748
|
+
return t.length > 0 || typeof e != "string" ? t : (await _r(), gr(e));
|
|
2741
2749
|
}
|
|
2742
|
-
function
|
|
2750
|
+
function yr(e) {
|
|
2743
2751
|
return typeof e == "string" ? document : $(e) ? e.getRootNode() : document;
|
|
2744
2752
|
}
|
|
2745
|
-
function
|
|
2753
|
+
function br(e) {
|
|
2746
2754
|
let { element: t, observe: n, allowEmpty: r, client: i, onReady: a, onResult: o, onSuccess: s, onError: c, onEvent: l, ...u } = e;
|
|
2747
2755
|
return {
|
|
2748
2756
|
mode: "server-rendered",
|
|
2749
2757
|
...u
|
|
2750
2758
|
};
|
|
2751
2759
|
}
|
|
2752
|
-
async function
|
|
2753
|
-
let i = [], a =
|
|
2760
|
+
async function xr(e, t, n, r) {
|
|
2761
|
+
let i = [], a = br(e);
|
|
2754
2762
|
for (let o of r) {
|
|
2755
2763
|
let r = n.get(o);
|
|
2756
2764
|
if (r) {
|
|
@@ -2760,7 +2768,7 @@ async function yr(e, t, n, r) {
|
|
|
2760
2768
|
let s = await t.mount(o, a), c = [];
|
|
2761
2769
|
if (e.onReady?.(s), c.push(s.on("formie:submit:result", (t) => {
|
|
2762
2770
|
let n = t;
|
|
2763
|
-
e.onResult?.(n, s),
|
|
2771
|
+
e.onResult?.(n, s), pr(n) ? e.onSuccess?.(n, s) : e.onError?.(n, s);
|
|
2764
2772
|
})), e.onEvent) for (let t of l) c.push(s.on(t, (n) => {
|
|
2765
2773
|
e.onEvent?.({
|
|
2766
2774
|
name: t,
|
|
@@ -2774,11 +2782,11 @@ async function yr(e, t, n, r) {
|
|
|
2774
2782
|
}
|
|
2775
2783
|
return i;
|
|
2776
2784
|
}
|
|
2777
|
-
async function
|
|
2778
|
-
let t = e.client ??
|
|
2779
|
-
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${
|
|
2780
|
-
await
|
|
2781
|
-
let i = e.observe ? t.observe(
|
|
2785
|
+
async function Sr(e) {
|
|
2786
|
+
let t = e.client ?? ur(), n = /* @__PURE__ */ new Map(), r = await vr(e.element);
|
|
2787
|
+
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${mr(e.element)}.`);
|
|
2788
|
+
await xr(e, t, n, r);
|
|
2789
|
+
let i = e.observe ? t.observe(yr(e.element)) : null;
|
|
2782
2790
|
return {
|
|
2783
2791
|
client: t,
|
|
2784
2792
|
get instances() {
|
|
@@ -2789,8 +2797,8 @@ async function br(e) {
|
|
|
2789
2797
|
return r ? n.get(r)?.instance ?? t.getInstance(r) : null;
|
|
2790
2798
|
},
|
|
2791
2799
|
async rescan() {
|
|
2792
|
-
let r =
|
|
2793
|
-
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) :
|
|
2800
|
+
let r = gr(e.element);
|
|
2801
|
+
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) : xr(e, t, n, r);
|
|
2794
2802
|
},
|
|
2795
2803
|
async destroy() {
|
|
2796
2804
|
i?.();
|
|
@@ -2801,7 +2809,7 @@ async function br(e) {
|
|
|
2801
2809
|
}
|
|
2802
2810
|
//#endregion
|
|
2803
2811
|
//#region src/js/core/client-rendered-modules.ts
|
|
2804
|
-
var
|
|
2812
|
+
var Cr = {
|
|
2805
2813
|
conditions: {
|
|
2806
2814
|
kind: "core",
|
|
2807
2815
|
reason: "Core evaluates structured conditions and the adapter renders visibility."
|
|
@@ -2835,8 +2843,8 @@ var xr = {
|
|
|
2835
2843
|
reason: "The adapter renders the structured date input contract."
|
|
2836
2844
|
}
|
|
2837
2845
|
};
|
|
2838
|
-
async function
|
|
2839
|
-
for (let [e, t] of Object.entries(
|
|
2846
|
+
async function wr(t, n, r = Jt) {
|
|
2847
|
+
for (let [e, t] of Object.entries(Cr)) {
|
|
2840
2848
|
let n = `formie:${e}`;
|
|
2841
2849
|
r.get(n) || r.register({
|
|
2842
2850
|
moduleId: n,
|
|
@@ -2864,7 +2872,7 @@ async function Sr(t, n, r = qt) {
|
|
|
2864
2872
|
}
|
|
2865
2873
|
};
|
|
2866
2874
|
a();
|
|
2867
|
-
let o = n.subscribe(a), s = await
|
|
2875
|
+
let o = n.subscribe(a), s = await fr({
|
|
2868
2876
|
root: t,
|
|
2869
2877
|
modules: n.getState().definition.modules,
|
|
2870
2878
|
surface: "client-rendered",
|
|
@@ -2898,4 +2906,4 @@ async function Sr(t, n, r = qt) {
|
|
|
2898
2906
|
};
|
|
2899
2907
|
}
|
|
2900
2908
|
//#endregion
|
|
2901
|
-
export { l as FORMIE_HTML_EVENT_NAMES,
|
|
2909
|
+
export { l as FORMIE_HTML_EVENT_NAMES, yn as FormieValidator, Ce as LEGACY_FORMIE_DOM_EVENT_BRIDGES, we as LEGACY_FORMIE_VALIDATOR_EVENT_BRIDGES, z as ModuleRegistry, Ae as bindLegacyDomEventCompatibility, Me as bindLegacyValidatorCompatibility, be as buildFieldValueRegistry, Jt as clientRenderedModuleRegistry, O as createDebug, ur 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, fr as hydrateFormieModules, he as inputNameToFieldKey, ne as isFormieDebugEnabled, ue as mergeFormieTranslations, wr 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 };
|