@verbb/formie-browser 1.0.16 → 1.0.17-next.7.gf88643cc06da
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 +15 -0
- package/dist/chunks/{address-state-CHKit8AW.js → address-state-D9KfV-qB.js} +1 -1
- package/dist/chunks/{combobox-CJh2DoSO.js → combobox-B6ROYFW7.js} +1 -1
- package/dist/chunks/date-picker-dp41TnRq.js +5351 -0
- package/dist/chunks/{hcaptcha-COilLmRT.js → hcaptcha-lseqzFTP.js} +14 -14
- package/dist/chunks/phone-country-BMyw-Qcz.js +2647 -0
- package/dist/chunks/{upload-manager-Ccg3d_4I.js → upload-manager-CkmsPJRl.js} +1 -1
- package/dist/index.js +407 -386
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/submit-result-ui.d.ts.map +1 -1
- package/dist/js/modules/captchas/hcaptcha.d.ts.map +1 -1
- package/dist/js/modules/fields/combobox.d.ts.map +1 -1
- package/dist/js/modules/fields/phone-country.d.ts.map +1 -1
- package/dist/js/modules/fields/upload-manager.d.ts.map +1 -1
- package/dist/js/modules/loader.d.ts.map +1 -1
- package/dist/js/theme/message-attributes.d.ts +4 -0
- package/dist/js/theme/message-attributes.d.ts.map +1 -0
- package/dist/js/transport/forms-api.d.ts +1 -1
- package/dist/js/transport/forms-api.d.ts.map +1 -1
- package/dist/js/validation/validator.d.ts.map +1 -1
- package/package.json +6 -4
- package/src/js/core/create-formie-client.ts +49 -33
- package/src/js/core/submit-result-ui.ts +10 -2
- package/src/js/modules/captchas/hcaptcha.ts +3 -2
- package/src/js/modules/fields/combobox.ts +4 -0
- package/src/js/modules/fields/date-picker.ts +3 -3
- package/src/js/modules/fields/phone-country.ts +25 -17
- package/src/js/modules/fields/upload-manager.ts +3 -2
- package/src/js/modules/loader.ts +7 -0
- package/src/js/theme/message-attributes.ts +54 -0
- package/src/js/transport/forms-api.ts +6 -1
- package/src/js/validation/validator.ts +3 -2
- package/src/vendor.d.ts +2 -3
- package/dist/chunks/date-picker-BVJxJVYT.js +0 -5321
- package/dist/chunks/phone-country-Bx9EG50h.js +0 -2645
package/dist/index.js
CHANGED
|
@@ -224,36 +224,36 @@ function Re(e, t = document) {
|
|
|
224
224
|
let r = n.split(/\s+/).filter((e) => !!e && !!t.getElementById(e));
|
|
225
225
|
r.length ? e.setAttribute("aria-describedby", r.join(" ")) : e.removeAttribute("aria-describedby");
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function ze(e, t) {
|
|
228
228
|
e.setAttribute("aria-errormessage", t), Le(e, t);
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function Be(e, t = []) {
|
|
231
231
|
t.forEach((t) => {
|
|
232
232
|
e.getAttribute("aria-errormessage") === t && e.removeAttribute("aria-errormessage");
|
|
233
233
|
}), !t.length && e.hasAttribute("aria-errormessage") && e.removeAttribute("aria-errormessage"), Re(e);
|
|
234
234
|
}
|
|
235
235
|
//#endregion
|
|
236
236
|
//#region src/js/core/validation-focus.ts
|
|
237
|
-
function
|
|
237
|
+
function Ve(e) {
|
|
238
238
|
return Array.from(e.querySelectorAll("[data-formie-field-handle]")).find((e) => e.getAttribute("data-formie-field-has-error") === "true" || e.querySelector("[data-formie-field-error]") !== null) || null;
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function He(e) {
|
|
241
241
|
if (e instanceof HTMLTextAreaElement) {
|
|
242
242
|
let t = e.richText;
|
|
243
243
|
if (t) return t.content;
|
|
244
244
|
}
|
|
245
245
|
return e;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function Ue(e) {
|
|
248
248
|
let t = Array.from(e.querySelectorAll("[aria-invalid=\"true\"]")).find((e) => !j(e));
|
|
249
|
-
if (t) return
|
|
249
|
+
if (t) return He(t);
|
|
250
250
|
let n = Array.from(e.querySelectorAll("input:not([type=\"hidden\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])")).find((e) => !j(e));
|
|
251
|
-
return n ?
|
|
251
|
+
return n ? He(n) : null;
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function We(e) {
|
|
254
254
|
return e.querySelector("[data-formie-message-error], [data-formie-error-container], [data-formie-errors]");
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function Ge(e) {
|
|
257
257
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
258
258
|
let n = t;
|
|
259
259
|
if (n.getAttribute("data-formie-field-has-error") !== "true" && n.querySelector("[data-formie-field-error]") === null) return;
|
|
@@ -262,19 +262,19 @@ function We(e) {
|
|
|
262
262
|
n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
263
263
|
let i = t;
|
|
264
264
|
if (j(i)) return;
|
|
265
|
-
i.setAttribute("aria-invalid", "true"), A(i, e, "fieldControlError"), i.setAttribute("data-formie-input-has-error", "true"), r &&
|
|
265
|
+
i.setAttribute("aria-invalid", "true"), A(i, e, "fieldControlError"), i.setAttribute("data-formie-input-has-error", "true"), r && ze(i, r);
|
|
266
266
|
let a = n.querySelector("[data-formie-instructions]");
|
|
267
267
|
a?.id && Le(i, a.id);
|
|
268
268
|
});
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
|
-
function
|
|
272
|
-
return !!
|
|
271
|
+
function Ke(e) {
|
|
272
|
+
return !!Ve(e) || !!We(e);
|
|
273
273
|
}
|
|
274
|
-
function
|
|
275
|
-
let t =
|
|
274
|
+
function qe(e) {
|
|
275
|
+
let t = Ve(e);
|
|
276
276
|
if (t) {
|
|
277
|
-
let e =
|
|
277
|
+
let e = Ue(t);
|
|
278
278
|
if (e) {
|
|
279
279
|
if (e.scrollIntoView({
|
|
280
280
|
behavior: "smooth",
|
|
@@ -291,7 +291,7 @@ function F(e) {
|
|
|
291
291
|
block: "center"
|
|
292
292
|
}), !0;
|
|
293
293
|
}
|
|
294
|
-
let n =
|
|
294
|
+
let n = We(e);
|
|
295
295
|
return n ? (n.scrollIntoView({
|
|
296
296
|
behavior: "smooth",
|
|
297
297
|
block: "center"
|
|
@@ -299,8 +299,8 @@ function F(e) {
|
|
|
299
299
|
}
|
|
300
300
|
//#endregion
|
|
301
301
|
//#region src/js/transport/forms-api.ts
|
|
302
|
-
var
|
|
303
|
-
function
|
|
302
|
+
var P = O("general", "transport");
|
|
303
|
+
function Je(e) {
|
|
304
304
|
let t = {};
|
|
305
305
|
return [
|
|
306
306
|
"theme",
|
|
@@ -311,7 +311,7 @@ function Ke(e) {
|
|
|
311
311
|
e[n] !== void 0 && (t[n] = e[n]);
|
|
312
312
|
}), t;
|
|
313
313
|
}
|
|
314
|
-
function
|
|
314
|
+
function Ye(e, t) {
|
|
315
315
|
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
316
|
"requiresAction",
|
|
317
317
|
"pending",
|
|
@@ -352,12 +352,12 @@ function qe(e, t) {
|
|
|
352
352
|
meta: e
|
|
353
353
|
};
|
|
354
354
|
}
|
|
355
|
-
async function
|
|
355
|
+
async function Xe(e, t, n = {}, r = {}) {
|
|
356
356
|
let i = JSON.stringify({
|
|
357
357
|
handle: t,
|
|
358
358
|
renderOptions: n
|
|
359
359
|
});
|
|
360
|
-
|
|
360
|
+
P.log("requestRender start.", {
|
|
361
361
|
endpoint: e,
|
|
362
362
|
handle: t
|
|
363
363
|
});
|
|
@@ -367,17 +367,17 @@ async function Je(e, t, n = {}, r = {}) {
|
|
|
367
367
|
body: i,
|
|
368
368
|
headers: { "Content-Type": "application/json" }
|
|
369
369
|
});
|
|
370
|
-
return
|
|
370
|
+
return P.log("requestRender complete.", { hasHtml: !!a.html }), a;
|
|
371
371
|
}
|
|
372
|
-
async function
|
|
372
|
+
async function Ze(e, t, n = {}, r = {}) {
|
|
373
373
|
let i = JSON.stringify({
|
|
374
374
|
query: "\nquery FormieHtmlForm($handle: String!, $input: ServerRenderPayloadInput) {\n formieHtmlForm(handle: $handle, input: $input) {\n html\n }\n}",
|
|
375
375
|
variables: {
|
|
376
376
|
handle: t,
|
|
377
|
-
input:
|
|
377
|
+
input: Je(n)
|
|
378
378
|
}
|
|
379
379
|
});
|
|
380
|
-
|
|
380
|
+
P.log("requestGraphqlRender start.", {
|
|
381
381
|
endpoint: e,
|
|
382
382
|
handle: t
|
|
383
383
|
});
|
|
@@ -390,19 +390,19 @@ async function Ye(e, t, n = {}, r = {}) {
|
|
|
390
390
|
if (Array.isArray(a.errors) && a.errors.length > 0) throw Error(a.errors.map((e) => e.message || "Unknown GraphQL error").join("; "));
|
|
391
391
|
if (!a.data?.formieHtmlForm) throw Error(`Form not found for handle "${t}".`);
|
|
392
392
|
let o = a.data.formieHtmlForm;
|
|
393
|
-
return
|
|
393
|
+
return P.log("requestGraphqlRender complete.", { hasHtml: !!o.html }), o;
|
|
394
394
|
}
|
|
395
|
-
async function
|
|
396
|
-
let
|
|
397
|
-
|
|
398
|
-
endpoint:
|
|
395
|
+
async function Qe(e, t, n, r = {}, i, a) {
|
|
396
|
+
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), P.log("requestRefreshTokens start.", {
|
|
398
|
+
endpoint: o.toString(),
|
|
399
399
|
handle: t,
|
|
400
400
|
hasRenderId: !!n
|
|
401
401
|
});
|
|
402
|
-
let
|
|
403
|
-
return
|
|
402
|
+
let s = await M(o.toString(), r);
|
|
403
|
+
return P.log("requestRefreshTokens complete.", { hasRefreshTokens: !!s.refreshTokens }), s.refreshTokens || s;
|
|
404
404
|
}
|
|
405
|
-
async function
|
|
405
|
+
async function $e(e, t, n) {
|
|
406
406
|
let r = new URL(e, window.location.origin), i = new FormData();
|
|
407
407
|
if (n && i.append("pageId", n), t) {
|
|
408
408
|
[
|
|
@@ -419,7 +419,7 @@ async function Ze(e, t, n) {
|
|
|
419
419
|
}), ae(i, t);
|
|
420
420
|
for (let [e, n] of new FormData(t)) e.startsWith("fields[") && i.append(e, n);
|
|
421
421
|
}
|
|
422
|
-
|
|
422
|
+
P.log("requestSetPage start.", {
|
|
423
423
|
requestUrl: r.toString(),
|
|
424
424
|
pageId: n || null
|
|
425
425
|
});
|
|
@@ -432,9 +432,9 @@ async function Ze(e, t, n) {
|
|
|
432
432
|
let e = a.session, n = t.querySelector("input[name=\"expectedVersion\"]"), r = t.querySelector("input[name=\"requestToken\"]");
|
|
433
433
|
n && (n.value = String(e.version)), r && e.tokens?.request && (r.value = e.tokens.request);
|
|
434
434
|
}
|
|
435
|
-
return
|
|
435
|
+
return P.log("requestSetPage complete.", a), a;
|
|
436
436
|
}
|
|
437
|
-
function
|
|
437
|
+
function et(e, t) {
|
|
438
438
|
let n = new URL(e, window.location.origin), i = new FormData();
|
|
439
439
|
[
|
|
440
440
|
"handle",
|
|
@@ -444,7 +444,7 @@ function Qe(e, t) {
|
|
|
444
444
|
].forEach((e) => {
|
|
445
445
|
let n = t.querySelector(`input[name="${e}"]`)?.value?.trim();
|
|
446
446
|
n && i.append(e, n);
|
|
447
|
-
}), ae(i, t),
|
|
447
|
+
}), ae(i, t), P.log("clearSubmissionOnUnload start.", { requestUrl: n.toString() });
|
|
448
448
|
try {
|
|
449
449
|
if (t.dataset.formieRequestProfile !== "cross-origin-public" && typeof navigator.sendBeacon == "function" && navigator.sendBeacon(n.toString(), i)) return;
|
|
450
450
|
} catch {}
|
|
@@ -455,9 +455,9 @@ function Qe(e, t) {
|
|
|
455
455
|
headers: { Accept: "application/json" }
|
|
456
456
|
}, { profile: t.dataset.formieRequestProfile });
|
|
457
457
|
}
|
|
458
|
-
async function
|
|
458
|
+
async function tt(e, t) {
|
|
459
459
|
let n = (e.getAttribute("method") || "POST").toUpperCase(), i = e.getAttribute("action") || window.location.href, a = e.dataset.formieErrorMessage?.trim() || "Submission failed.";
|
|
460
|
-
|
|
460
|
+
P.log("submitForm start.", {
|
|
461
461
|
method: n,
|
|
462
462
|
action: i,
|
|
463
463
|
submitAction: t.get("submitAction")
|
|
@@ -467,13 +467,13 @@ async function $e(e, t) {
|
|
|
467
467
|
body: t,
|
|
468
468
|
headers: { Accept: "application/json" }
|
|
469
469
|
}, { profile: e.dataset.formieRequestProfile }), s = o.headers.get("content-type") || "";
|
|
470
|
-
if (!s.includes("application/json")) return o.ok ? (
|
|
470
|
+
if (!s.includes("application/json")) return o.ok ? (P.log("submitForm non-JSON success response.", {
|
|
471
471
|
status: o.status,
|
|
472
472
|
contentType: s
|
|
473
473
|
}), {
|
|
474
474
|
ok: !0,
|
|
475
475
|
message: "Submission completed."
|
|
476
|
-
}) : (
|
|
476
|
+
}) : (P.warn("submitForm non-JSON HTTP error.", {
|
|
477
477
|
status: o.status,
|
|
478
478
|
contentType: s
|
|
479
479
|
}), {
|
|
@@ -482,8 +482,8 @@ async function $e(e, t) {
|
|
|
482
482
|
message: `Request failed (${o.status}).`,
|
|
483
483
|
formErrors: [`Request failed (${o.status}).`]
|
|
484
484
|
});
|
|
485
|
-
let c =
|
|
486
|
-
return
|
|
485
|
+
let c = Ye(await o.json(), a);
|
|
486
|
+
return P.log("submitForm JSON response normalized.", {
|
|
487
487
|
ok: c.ok,
|
|
488
488
|
code: c.code,
|
|
489
489
|
hasRedirect: !!c.redirect?.url,
|
|
@@ -492,20 +492,20 @@ async function $e(e, t) {
|
|
|
492
492
|
}
|
|
493
493
|
//#endregion
|
|
494
494
|
//#region src/js/submit/pipeline.ts
|
|
495
|
-
var
|
|
495
|
+
var nt = [
|
|
496
496
|
"prepare",
|
|
497
497
|
"validate",
|
|
498
498
|
"challenge",
|
|
499
499
|
"payment",
|
|
500
500
|
"send",
|
|
501
501
|
"result"
|
|
502
|
-
],
|
|
502
|
+
], rt = [
|
|
503
503
|
"prepare",
|
|
504
504
|
"validate",
|
|
505
505
|
"challenge",
|
|
506
506
|
"payment"
|
|
507
|
-
],
|
|
508
|
-
function
|
|
507
|
+
], F = O("general", "pipeline");
|
|
508
|
+
function it(e, t) {
|
|
509
509
|
return {
|
|
510
510
|
ok: !1,
|
|
511
511
|
stage: e,
|
|
@@ -514,13 +514,13 @@ function nt(e, t) {
|
|
|
514
514
|
formErrors: [t || "Submission aborted."]
|
|
515
515
|
};
|
|
516
516
|
}
|
|
517
|
-
function
|
|
517
|
+
function at(e) {
|
|
518
518
|
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
|
|
519
519
|
}
|
|
520
|
-
function
|
|
520
|
+
function ot(e) {
|
|
521
521
|
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
522
|
}
|
|
523
|
-
function
|
|
523
|
+
function st(e, t) {
|
|
524
524
|
if (t instanceof HTMLInputElement) {
|
|
525
525
|
if (t.type === "file") {
|
|
526
526
|
Array.from(t.files || []).forEach((n) => {
|
|
@@ -533,49 +533,49 @@ function at(e, t) {
|
|
|
533
533
|
e.append(t.name, n.value);
|
|
534
534
|
}) : e.append(t.name, t.value);
|
|
535
535
|
}
|
|
536
|
-
function
|
|
536
|
+
function ct(e, t) {
|
|
537
537
|
t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
538
|
-
let n =
|
|
539
|
-
n && !n.closest("[data-formie-page]") &&
|
|
538
|
+
let n = at(t) ? t : null;
|
|
539
|
+
n && !n.closest("[data-formie-page]") && ot(n) && st(e, n);
|
|
540
540
|
});
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function lt(e, t) {
|
|
543
543
|
let n = /* @__PURE__ */ new Set();
|
|
544
544
|
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),
|
|
545
|
+
let r = at(t) ? t : null;
|
|
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), ot(r) && st(e, r)));
|
|
547
547
|
}), n;
|
|
548
548
|
}
|
|
549
|
-
function
|
|
549
|
+
function ut(e, t) {
|
|
550
550
|
t.forEach((t) => {
|
|
551
551
|
e.has(t) || e.append(t, "");
|
|
552
552
|
});
|
|
553
553
|
}
|
|
554
|
-
function
|
|
554
|
+
function dt(e, t) {
|
|
555
555
|
let n = T(e), r = n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || null;
|
|
556
556
|
if (!n.length || !r) {
|
|
557
557
|
let n = new FormData(e);
|
|
558
558
|
return n.set("submitAction", t), n;
|
|
559
559
|
}
|
|
560
560
|
let i = new FormData();
|
|
561
|
-
return
|
|
561
|
+
return ct(i, e), ut(i, lt(i, r)), i.set("submitAction", t), i;
|
|
562
562
|
}
|
|
563
|
-
function
|
|
563
|
+
function ft(e, t) {
|
|
564
564
|
if (t !== "submit") return !1;
|
|
565
565
|
let n = T(e);
|
|
566
566
|
return !n.length || (n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || n[n.length - 1]) === n[n.length - 1];
|
|
567
567
|
}
|
|
568
|
-
async function
|
|
569
|
-
|
|
568
|
+
async function pt(e, t, n, r = {}) {
|
|
569
|
+
F.log("Starting submit pipeline.", {
|
|
570
570
|
action: t,
|
|
571
571
|
preflightOnly: r.preflightOnly === !0
|
|
572
572
|
});
|
|
573
|
-
let i = !1, a, o = null, s =
|
|
573
|
+
let i = !1, a, o = null, s = ft(e, t), c = d(e, {
|
|
574
574
|
form: e,
|
|
575
575
|
action: t,
|
|
576
|
-
formData:
|
|
576
|
+
formData: dt(e, t),
|
|
577
577
|
abort: (e) => {
|
|
578
|
-
i = !0, a = e,
|
|
578
|
+
i = !0, a = e, F.warn("Pipeline aborted.", { reason: e });
|
|
579
579
|
},
|
|
580
580
|
isAborted: () => i,
|
|
581
581
|
abortReason: () => a
|
|
@@ -623,68 +623,68 @@ async function dt(e, t, n, r = {}) {
|
|
|
623
623
|
challenge: async () => null,
|
|
624
624
|
payment: async () => null,
|
|
625
625
|
send: async (e) => {
|
|
626
|
-
e.formData =
|
|
627
|
-
let t = await
|
|
626
|
+
e.formData = dt(e.form, e.action);
|
|
627
|
+
let t = await tt(e.form, e.formData);
|
|
628
628
|
return o = t, t;
|
|
629
629
|
},
|
|
630
630
|
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
631
|
};
|
|
632
632
|
{
|
|
633
633
|
let e = await n.emitSafe("formie:submit:before", c);
|
|
634
|
-
e.failed.length > 0 &&
|
|
634
|
+
e.failed.length > 0 && F.warn("Submit before listeners failed.", {
|
|
635
635
|
eventName: e.eventName,
|
|
636
636
|
failed: e.failed.length
|
|
637
637
|
});
|
|
638
638
|
}
|
|
639
639
|
if (s) {
|
|
640
640
|
let e = await n.emitSafe("formie:submit:final:before", c);
|
|
641
|
-
e.failed.length > 0 &&
|
|
641
|
+
e.failed.length > 0 && F.warn("Final submit before listeners failed.", {
|
|
642
642
|
eventName: e.eventName,
|
|
643
643
|
failed: e.failed.length
|
|
644
644
|
});
|
|
645
645
|
}
|
|
646
|
-
let f = r.preflightOnly ?
|
|
646
|
+
let f = r.preflightOnly ? rt : nt;
|
|
647
647
|
for (let e of f) {
|
|
648
|
-
if (
|
|
648
|
+
if (F.log("Stage start.", {
|
|
649
649
|
stage: e,
|
|
650
650
|
action: t
|
|
651
|
-
}), i) return
|
|
651
|
+
}), i) return F.warn("Stage skipped due to abort.", {
|
|
652
652
|
stage: e,
|
|
653
653
|
reason: a
|
|
654
|
-
}),
|
|
654
|
+
}), it(e, a);
|
|
655
655
|
{
|
|
656
656
|
let t = await n.emitSafe(`formie:stage:${e}:before`, {
|
|
657
657
|
...c,
|
|
658
658
|
stage: e
|
|
659
659
|
});
|
|
660
|
-
t.failed.length > 0 &&
|
|
660
|
+
t.failed.length > 0 && F.warn("Stage before listeners failed.", {
|
|
661
661
|
stage: e,
|
|
662
662
|
failed: t.failed.length
|
|
663
663
|
});
|
|
664
664
|
}
|
|
665
665
|
if (i) {
|
|
666
|
-
let t =
|
|
666
|
+
let t = it(e, a);
|
|
667
667
|
{
|
|
668
668
|
let n = await l("formie:submit:after", t);
|
|
669
|
-
n.failed.length > 0 &&
|
|
669
|
+
n.failed.length > 0 && F.warn("Submit after listeners failed (abort before stage).", {
|
|
670
670
|
stage: e,
|
|
671
671
|
failed: n.failed.length
|
|
672
672
|
});
|
|
673
673
|
}
|
|
674
674
|
if (s) {
|
|
675
675
|
let n = await l("formie:submit:final:after", t);
|
|
676
|
-
n.failed.length > 0 &&
|
|
676
|
+
n.failed.length > 0 && F.warn("Final submit after listeners failed (abort before stage).", {
|
|
677
677
|
stage: e,
|
|
678
678
|
failed: n.failed.length
|
|
679
679
|
});
|
|
680
680
|
}
|
|
681
|
-
return
|
|
681
|
+
return F.warn("Aborted after stage before-hooks.", {
|
|
682
682
|
stage: e,
|
|
683
683
|
reason: a
|
|
684
684
|
}), t;
|
|
685
685
|
}
|
|
686
686
|
let r = await u[e](c);
|
|
687
|
-
|
|
687
|
+
F.log("Stage runner complete.", {
|
|
688
688
|
stage: e,
|
|
689
689
|
hasResult: !!r,
|
|
690
690
|
ok: r ? r.ok : void 0,
|
|
@@ -696,28 +696,28 @@ async function dt(e, t, n, r = {}) {
|
|
|
696
696
|
stage: e,
|
|
697
697
|
result: r
|
|
698
698
|
});
|
|
699
|
-
t.failed.length > 0 &&
|
|
699
|
+
t.failed.length > 0 && F.warn("Stage after listeners failed.", {
|
|
700
700
|
stage: e,
|
|
701
701
|
failed: t.failed.length
|
|
702
702
|
});
|
|
703
703
|
}
|
|
704
704
|
if (i) {
|
|
705
|
-
let t =
|
|
705
|
+
let t = it(e, a);
|
|
706
706
|
{
|
|
707
707
|
let n = await l("formie:submit:after", t);
|
|
708
|
-
n.failed.length > 0 &&
|
|
708
|
+
n.failed.length > 0 && F.warn("Submit after listeners failed (abort after stage).", {
|
|
709
709
|
stage: e,
|
|
710
710
|
failed: n.failed.length
|
|
711
711
|
});
|
|
712
712
|
}
|
|
713
713
|
if (s) {
|
|
714
714
|
let n = await l("formie:submit:final:after", t);
|
|
715
|
-
n.failed.length > 0 &&
|
|
715
|
+
n.failed.length > 0 && F.warn("Final submit after listeners failed (abort after stage).", {
|
|
716
716
|
stage: e,
|
|
717
717
|
failed: n.failed.length
|
|
718
718
|
});
|
|
719
719
|
}
|
|
720
|
-
return
|
|
720
|
+
return F.warn("Aborted after stage after-hooks.", {
|
|
721
721
|
stage: e,
|
|
722
722
|
reason: a
|
|
723
723
|
}), t;
|
|
@@ -725,19 +725,19 @@ async function dt(e, t, n, r = {}) {
|
|
|
725
725
|
if (r && !r.ok) {
|
|
726
726
|
{
|
|
727
727
|
let t = await l("formie:submit:after", r);
|
|
728
|
-
t.failed.length > 0 &&
|
|
728
|
+
t.failed.length > 0 && F.warn("Submit after listeners failed (failed stage).", {
|
|
729
729
|
stage: e,
|
|
730
730
|
failed: t.failed.length
|
|
731
731
|
});
|
|
732
732
|
}
|
|
733
733
|
if (s) {
|
|
734
734
|
let t = await l("formie:submit:final:after", r);
|
|
735
|
-
t.failed.length > 0 &&
|
|
735
|
+
t.failed.length > 0 && F.warn("Final submit after listeners failed (failed stage).", {
|
|
736
736
|
stage: e,
|
|
737
737
|
failed: t.failed.length
|
|
738
738
|
});
|
|
739
739
|
}
|
|
740
|
-
return
|
|
740
|
+
return F.warn("Pipeline short-circuited by failed stage.", {
|
|
741
741
|
stage: e,
|
|
742
742
|
code: r.code,
|
|
743
743
|
message: r.message
|
|
@@ -752,13 +752,13 @@ async function dt(e, t, n, r = {}) {
|
|
|
752
752
|
};
|
|
753
753
|
{
|
|
754
754
|
let e = await l("formie:submit:after", p);
|
|
755
|
-
e.failed.length > 0 &&
|
|
755
|
+
e.failed.length > 0 && F.warn("Submit after listeners failed (success).", { failed: e.failed.length });
|
|
756
756
|
}
|
|
757
757
|
if (s) {
|
|
758
758
|
let e = await l("formie:submit:final:after", p);
|
|
759
|
-
e.failed.length > 0 &&
|
|
759
|
+
e.failed.length > 0 && F.warn("Final submit after listeners failed (success).", { failed: e.failed.length });
|
|
760
760
|
}
|
|
761
|
-
return
|
|
761
|
+
return F.log("Pipeline completed.", {
|
|
762
762
|
ok: p.ok,
|
|
763
763
|
stage: p.stage,
|
|
764
764
|
code: p.code
|
|
@@ -766,84 +766,101 @@ async function dt(e, t, n, r = {}) {
|
|
|
766
766
|
}
|
|
767
767
|
//#endregion
|
|
768
768
|
//#region src/js/core/field-error-container.ts
|
|
769
|
-
function
|
|
769
|
+
function mt(e) {
|
|
770
770
|
return e.querySelector("[data-formie-field-layout]")?.getAttribute("data-formie-error-position")?.trim() === "above" ? "above" : "below";
|
|
771
771
|
}
|
|
772
|
-
function
|
|
772
|
+
function ht(e, t) {
|
|
773
773
|
let n = e.querySelector("[data-formie-field-errors]");
|
|
774
774
|
if (n) return n;
|
|
775
|
-
let r = e.querySelector("[data-formie-field-content]"), i = e.querySelector("[data-formie-field-control]"), a =
|
|
775
|
+
let r = e.querySelector("[data-formie-field-content]"), i = e.querySelector("[data-formie-field-control]"), a = mt(e), o = document.createElement("div");
|
|
776
776
|
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
777
|
}
|
|
778
778
|
//#endregion
|
|
779
|
+
//#region src/js/theme/message-attributes.ts
|
|
780
|
+
function gt(e, t, n, r = !1) {
|
|
781
|
+
let i = t.getAttribute("data-formie-message-attributes");
|
|
782
|
+
if (!i) return;
|
|
783
|
+
let a;
|
|
784
|
+
try {
|
|
785
|
+
a = JSON.parse(i);
|
|
786
|
+
} catch {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
if (!a || typeof a != "object" || Array.isArray(a)) return;
|
|
790
|
+
let o = a[n];
|
|
791
|
+
o && typeof o == "object" && !Array.isArray(o) && Object.entries(o).forEach(([t, n]) => {
|
|
792
|
+
t === "class" || !/^[^\s"'<>/=]+$/.test(t) || typeof n != "string" && n !== !0 || (r ? e.removeAttribute(t) : e.setAttribute(t, n === !0 ? "" : n));
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
//#endregion
|
|
779
796
|
//#region src/js/core/submit-result-ui.ts
|
|
780
|
-
var
|
|
781
|
-
function
|
|
797
|
+
var I = /* @__PURE__ */ new WeakMap();
|
|
798
|
+
function _t(e) {
|
|
782
799
|
return (e.dataset.formieCompletionBehavior || e.dataset.formieSubmitAction || "").trim();
|
|
783
800
|
}
|
|
784
|
-
function
|
|
785
|
-
return (e.dataset.formieErrorMessagePosition
|
|
801
|
+
function vt(e) {
|
|
802
|
+
return (e.dataset.formieErrorMessagePosition ?? "top-form").trim();
|
|
786
803
|
}
|
|
787
|
-
function
|
|
804
|
+
function yt(e) {
|
|
788
805
|
return (e.dataset.formieSuccessMessagePosition || e.dataset.formieSubmitActionMessagePosition || "").trim();
|
|
789
806
|
}
|
|
790
|
-
function
|
|
807
|
+
function bt(e) {
|
|
791
808
|
let t = (e.dataset.formieSuccessMessageTimeout || e.dataset.formieSubmitActionMessageTimeout || "").trim();
|
|
792
809
|
if (!t) return null;
|
|
793
810
|
let n = Number.parseFloat(t);
|
|
794
811
|
return !Number.isFinite(n) || n < 0 ? null : Math.round(n * 1e3);
|
|
795
812
|
}
|
|
796
|
-
function
|
|
813
|
+
function xt(e) {
|
|
797
814
|
let t = e.dataset.formieHideFormAfterSubmit ?? e.dataset.formieSubmitActionFormHide;
|
|
798
815
|
if (t === void 0) return !1;
|
|
799
816
|
let n = t.trim().toLowerCase();
|
|
800
817
|
return n === "true" || n === "1" || n === "";
|
|
801
818
|
}
|
|
802
|
-
function
|
|
803
|
-
let t =
|
|
804
|
-
typeof t == "number" && (window.clearTimeout(t),
|
|
819
|
+
function St(e) {
|
|
820
|
+
let t = I.get(e);
|
|
821
|
+
typeof t == "number" && (window.clearTimeout(t), I.delete(e));
|
|
805
822
|
}
|
|
806
|
-
function
|
|
823
|
+
function Ct(e) {
|
|
807
824
|
return e.querySelector("[data-formie-form-messages-top]") || e;
|
|
808
825
|
}
|
|
809
|
-
function
|
|
826
|
+
function wt(e) {
|
|
810
827
|
return e.querySelector("[data-formie-form-messages-bottom]") || e;
|
|
811
828
|
}
|
|
812
|
-
function
|
|
813
|
-
return t === "bottom-form" ?
|
|
829
|
+
function Tt(e, t) {
|
|
830
|
+
return t === "bottom-form" ? wt(e) : Ct(e);
|
|
814
831
|
}
|
|
815
|
-
function
|
|
816
|
-
return t === "top-form" ?
|
|
832
|
+
function Et(e, t) {
|
|
833
|
+
return t === "top-form" ? Ct(e) : t === "bottom-form" && !xt(e) ? wt(e) : e;
|
|
817
834
|
}
|
|
818
|
-
function
|
|
819
|
-
let t =
|
|
835
|
+
function Dt(e) {
|
|
836
|
+
let t = vt(e), n = Tt(e, t), r = n.querySelector("[data-formie-error-container], [data-formie-errors]");
|
|
820
837
|
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;
|
|
821
838
|
}
|
|
822
|
-
function
|
|
839
|
+
function Ot(e, t) {
|
|
823
840
|
let n = t.querySelector("[data-formie-error-message-container], [data-formie-message][data-formie-message-error]");
|
|
824
|
-
return n || (n = document.createElement("div"), n.setAttribute("data-formie-error-message-container", "true"), t.appendChild(n)), n.setAttribute("data-formie-message", "true"), n.setAttribute("data-formie-message-error", "true"), A(n, e, "message", "messageError"), n.setAttribute("role", "alert"), Ie(n, Fe(Ne(e))), n;
|
|
841
|
+
return n || (n = document.createElement("div"), n.setAttribute("data-formie-error-message-container", "true"), t.appendChild(n)), gt(n, e, "messageError"), n.setAttribute("data-formie-message", "true"), n.setAttribute("data-formie-message-error", "true"), A(n, e, "message", "messageError"), n.setAttribute("role", "alert"), Ie(n, Fe(Ne(e))), n;
|
|
825
842
|
}
|
|
826
|
-
function
|
|
827
|
-
let n = e.querySelector("[data-formie-success-container]"), r =
|
|
843
|
+
function kt(e, t) {
|
|
844
|
+
let n = e.querySelector("[data-formie-success-container]"), r = Et(e, t);
|
|
828
845
|
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;
|
|
829
846
|
}
|
|
830
|
-
function
|
|
831
|
-
return
|
|
847
|
+
function At(e) {
|
|
848
|
+
return ht(e, (t) => {
|
|
832
849
|
A(t, e, "fieldErrors");
|
|
833
850
|
});
|
|
834
851
|
}
|
|
835
|
-
function
|
|
852
|
+
function jt(e) {
|
|
836
853
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
837
854
|
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);
|
|
838
855
|
k(n, e, "fieldLayoutError"), n.removeAttribute("data-formie-field-has-error"), n.querySelectorAll("[data-formie-field-error]").forEach((e) => {
|
|
839
856
|
e.remove();
|
|
840
857
|
}), r && !r.querySelector("[data-formie-field-error]") && (r.innerHTML = ""), n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
841
858
|
let n = t;
|
|
842
|
-
n.removeAttribute("aria-invalid"), k(n, e, "fieldControlError"), n.removeAttribute("data-formie-input-has-error"),
|
|
859
|
+
n.removeAttribute("aria-invalid"), k(n, e, "fieldControlError"), n.removeAttribute("data-formie-input-has-error"), Be(n, i);
|
|
843
860
|
});
|
|
844
861
|
}), h(e);
|
|
845
862
|
}
|
|
846
|
-
function
|
|
863
|
+
function Mt(e) {
|
|
847
864
|
e.querySelectorAll("[data-formie-error-container], [data-formie-errors]").forEach((t) => {
|
|
848
865
|
let n = t;
|
|
849
866
|
n.querySelectorAll("[data-formie-error]").forEach((e) => {
|
|
@@ -851,27 +868,27 @@ function kt(e) {
|
|
|
851
868
|
}), 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 = "");
|
|
852
869
|
});
|
|
853
870
|
}
|
|
854
|
-
function
|
|
855
|
-
|
|
871
|
+
function Nt(e) {
|
|
872
|
+
St(e), e.querySelectorAll("[data-formie-message-success]:not([data-formie-success-container])").forEach((e) => {
|
|
856
873
|
e.remove();
|
|
857
874
|
}), e.querySelectorAll("[data-formie-success-container]").forEach((t) => {
|
|
858
875
|
let n = t;
|
|
859
876
|
n.querySelectorAll("[data-formie-success]").forEach((e) => {
|
|
860
877
|
e.remove();
|
|
861
|
-
}), 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 = "");
|
|
862
|
-
}),
|
|
878
|
+
}), gt(n, e, "messageSuccess", !0), k(n, e, "message", "messageSuccess"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-success"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-success]") || (n.innerHTML = "");
|
|
879
|
+
}), _t(e) === "message" && xt(e) || b(e, !1);
|
|
863
880
|
}
|
|
864
|
-
function
|
|
881
|
+
function Pt(e) {
|
|
865
882
|
e.querySelectorAll("[aria-invalid=\"true\"]").forEach((e) => {
|
|
866
883
|
e.removeAttribute("aria-invalid");
|
|
867
884
|
});
|
|
868
885
|
}
|
|
869
|
-
function
|
|
886
|
+
function Ft(e, t) {
|
|
870
887
|
let n = Fe(Ne(e));
|
|
871
888
|
Object.entries(t).forEach(([t, r]) => {
|
|
872
889
|
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)}"]`);
|
|
873
890
|
if (!a) return;
|
|
874
|
-
let o =
|
|
891
|
+
let o = At(a), s = o.id && o.id.trim() ? o.id : `${t}-errors`;
|
|
875
892
|
o.id = s, Ie(o, n), A(a, e, "fieldLayoutError"), a.setAttribute("data-formie-field-has-error", "true"), r.forEach((t, n) => {
|
|
876
893
|
let r = document.createElement("div");
|
|
877
894
|
r.setAttribute("data-formie-field-error", "true"), r.id = `${s}-${n + 1}`, A(r, e, "fieldError"), r.textContent = t, o.appendChild(r);
|
|
@@ -879,40 +896,41 @@ function Mt(e, t) {
|
|
|
879
896
|
let c = o.querySelector("[data-formie-field-error]")?.id;
|
|
880
897
|
a.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
881
898
|
let n = t;
|
|
882
|
-
n.setAttribute("aria-invalid", "true"), A(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), c &&
|
|
899
|
+
n.setAttribute("aria-invalid", "true"), A(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), c && ze(n, c);
|
|
883
900
|
let r = a.querySelector("[data-formie-instructions]");
|
|
884
901
|
r?.id && Le(n, r.id);
|
|
885
902
|
});
|
|
886
903
|
}), h(e);
|
|
887
904
|
}
|
|
888
|
-
function
|
|
889
|
-
|
|
905
|
+
function It(e, t) {
|
|
906
|
+
if (!vt(e)) return;
|
|
907
|
+
let n = Dt(e), r = Ot(e, n);
|
|
890
908
|
A(n, e, "errors"), t.forEach((t) => {
|
|
891
909
|
let n = document.createElement("div");
|
|
892
|
-
n.setAttribute("data-formie-error", "true"),
|
|
910
|
+
n.setAttribute("data-formie-error", "true"), A(n, e, "error"), n.innerHTML = t, r.appendChild(n);
|
|
893
911
|
});
|
|
894
912
|
}
|
|
895
|
-
function
|
|
913
|
+
function Lt(e) {
|
|
896
914
|
if (e.ok || e.keepSubmitLoading !== !0) return !1;
|
|
897
915
|
let t = e.payment?.status;
|
|
898
916
|
return t === "requiresAction" || t === "pending" || t === "unknown";
|
|
899
917
|
}
|
|
900
|
-
function
|
|
901
|
-
let n =
|
|
918
|
+
function Rt(e, t) {
|
|
919
|
+
let n = Dt(e), r = Ot(e, n);
|
|
902
920
|
A(n, e, "errors");
|
|
903
921
|
let i = document.createElement("div");
|
|
904
922
|
i.setAttribute("data-formie-notice", "true"), i.setAttribute("role", "status"), A(i, e, "message"), i.textContent = t, r.appendChild(i);
|
|
905
923
|
}
|
|
906
|
-
function
|
|
907
|
-
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" ||
|
|
924
|
+
function zt(e, t) {
|
|
925
|
+
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" || _t(e) === "message" && yt(e) !== "";
|
|
908
926
|
}
|
|
909
|
-
function
|
|
910
|
-
let r =
|
|
927
|
+
function Bt(e, t, n = {}) {
|
|
928
|
+
let r = yt(e);
|
|
911
929
|
if (!r) return;
|
|
912
|
-
let i =
|
|
913
|
-
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");
|
|
930
|
+
let i = kt(e, r);
|
|
931
|
+
gt(i, e, "messageSuccess"), A(i, e, "message", "messageSuccess"), i.setAttribute("data-formie-message", "true"), i.setAttribute("data-formie-message-success", "true"), i.setAttribute("role", "status"), i.setAttribute("aria-live", "polite"), i.setAttribute("aria-atomic", "true");
|
|
914
932
|
let a = document.createElement("div");
|
|
915
|
-
a.setAttribute("data-formie-success", "true"), A(a, e, "success"), a.innerHTML = t, i.appendChild(a), n.hideForm !== !1 &&
|
|
933
|
+
a.setAttribute("data-formie-success", "true"), A(a, e, "success"), a.innerHTML = t, i.appendChild(a), n.hideForm !== !1 && xt(e) && b(e, !0);
|
|
916
934
|
let o = e.dataset.formieScrollToTop?.trim().toLowerCase();
|
|
917
935
|
o !== void 0 && [
|
|
918
936
|
"",
|
|
@@ -922,45 +940,45 @@ function Lt(e, t, n = {}) {
|
|
|
922
940
|
behavior: "smooth",
|
|
923
941
|
block: "start"
|
|
924
942
|
});
|
|
925
|
-
let s =
|
|
943
|
+
let s = bt(e);
|
|
926
944
|
if (s !== null) {
|
|
927
945
|
let t = window.setTimeout(() => {
|
|
928
|
-
|
|
946
|
+
I.delete(e), Nt(e);
|
|
929
947
|
}, s);
|
|
930
|
-
|
|
948
|
+
I.set(e, t);
|
|
931
949
|
}
|
|
932
950
|
}
|
|
933
|
-
function
|
|
934
|
-
if (
|
|
951
|
+
function L(e, t) {
|
|
952
|
+
if (jt(e), Mt(e), Nt(e), Pt(e), t.ok) {
|
|
935
953
|
let n = t.meta?.summaryTokens;
|
|
936
954
|
n && typeof n == "object" && e.querySelectorAll("[data-formie-field-uid]").forEach((e) => {
|
|
937
955
|
let t = n[e.dataset.formieFieldUid || ""];
|
|
938
956
|
typeof t == "string" && t && e.querySelector("[data-formie-summary-container]")?.setAttribute("data-formie-summary-token", t);
|
|
939
|
-
}),
|
|
957
|
+
}), zt(e, t) && Bt(e, t.message || "", { hideForm: t.action !== "save" });
|
|
940
958
|
} else if (!t.ok) {
|
|
941
|
-
if (
|
|
959
|
+
if (Lt(t)) {
|
|
942
960
|
let n = String(t.payment?.message || "").trim();
|
|
943
|
-
n &&
|
|
961
|
+
n && Rt(e, n);
|
|
944
962
|
return;
|
|
945
963
|
}
|
|
946
|
-
t.fieldErrors &&
|
|
964
|
+
t.fieldErrors && Ft(e, t.fieldErrors), t.formErrors?.length ? It(e, t.formErrors) : !t.fieldErrors && t.message && It(e, [t.message]), qe(e);
|
|
947
965
|
}
|
|
948
966
|
}
|
|
949
967
|
//#endregion
|
|
950
968
|
//#region src/js/core/submit-flow.ts
|
|
951
|
-
var
|
|
952
|
-
function
|
|
969
|
+
var Vt = O("general", "submit-flow");
|
|
970
|
+
function Ht(e) {
|
|
953
971
|
return !(!e.ok && e.stage === "validate");
|
|
954
972
|
}
|
|
955
|
-
function
|
|
973
|
+
function Ut(e) {
|
|
956
974
|
return e ? !!(e.keepSubmitLoading === !0 || e.ok && e.redirect?.url && e.redirect.target !== "new-tab") : !1;
|
|
957
975
|
}
|
|
958
|
-
function
|
|
959
|
-
|
|
976
|
+
function Wt(e) {
|
|
977
|
+
jt(e), Mt(e), Nt(e), Pt(e);
|
|
960
978
|
}
|
|
961
|
-
async function
|
|
979
|
+
async function Gt(e) {
|
|
962
980
|
let { id: t, target: n, form: r, bus: i, validator: a, validateOnSubmit: o, action: s, submitter: c, waitForSubmitDelay: l, onRefreshTokensAfterSubmit: u, dispatchSubmitResult: d } = e;
|
|
963
|
-
|
|
981
|
+
Wt(r), C(r, c || null);
|
|
964
982
|
let p = {
|
|
965
983
|
ok: !1,
|
|
966
984
|
code: "SUBMIT_ERROR",
|
|
@@ -968,30 +986,30 @@ async function Ht(e) {
|
|
|
968
986
|
formErrors: ["Submission failed."]
|
|
969
987
|
};
|
|
970
988
|
try {
|
|
971
|
-
await l(r), p = await
|
|
989
|
+
await l(r), p = await pt(r, s, i, {
|
|
972
990
|
validator: a,
|
|
973
991
|
validateOnSubmit: o
|
|
974
|
-
}),
|
|
992
|
+
}), L(r, p), d(p), v(r, p, s), Ht(p) && await u(p);
|
|
975
993
|
} catch (e) {
|
|
976
994
|
p = {
|
|
977
995
|
ok: !1,
|
|
978
996
|
code: "SUBMIT_ERROR",
|
|
979
997
|
message: e instanceof Error ? e.message : "Submission failed.",
|
|
980
998
|
formErrors: [e instanceof Error ? e.message : "Submission failed."]
|
|
981
|
-
},
|
|
999
|
+
}, L(r, p), d(p), Vt.warn("Submit failed with exception.", {
|
|
982
1000
|
id: t,
|
|
983
1001
|
action: s,
|
|
984
1002
|
target: n,
|
|
985
1003
|
error: e instanceof Error ? e.message : e
|
|
986
1004
|
});
|
|
987
1005
|
} finally {
|
|
988
|
-
|
|
1006
|
+
Ut(p) || f(r);
|
|
989
1007
|
}
|
|
990
1008
|
return p;
|
|
991
1009
|
}
|
|
992
1010
|
//#endregion
|
|
993
1011
|
//#region src/js/events/event-bus.ts
|
|
994
|
-
var
|
|
1012
|
+
var Kt = class {
|
|
995
1013
|
listeners = /* @__PURE__ */ new Map();
|
|
996
1014
|
on(e, t) {
|
|
997
1015
|
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e)?.add(t), () => {
|
|
@@ -1041,7 +1059,7 @@ var Ut = class {
|
|
|
1041
1059
|
clear() {
|
|
1042
1060
|
this.listeners.clear();
|
|
1043
1061
|
}
|
|
1044
|
-
},
|
|
1062
|
+
}, R = class {
|
|
1045
1063
|
modules = /* @__PURE__ */ new Map();
|
|
1046
1064
|
register(e, t = {}) {
|
|
1047
1065
|
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) => ![
|
|
@@ -1067,38 +1085,38 @@ var Ut = class {
|
|
|
1067
1085
|
getAll() {
|
|
1068
1086
|
return Array.from(this.modules.values());
|
|
1069
1087
|
}
|
|
1070
|
-
},
|
|
1088
|
+
}, qt = new R(), Jt = {
|
|
1071
1089
|
"address-finder": () => import("./chunks/address-finder-QK1m1eyv.js").then((e) => e.addressFinderModule),
|
|
1072
1090
|
"google-address": () => import("./chunks/google-address-DQR6rsbh.js").then((e) => e.googleAddressModule),
|
|
1073
1091
|
loqate: () => import("./chunks/loqate-ZZClcacr.js").then((e) => e.loqateModule),
|
|
1074
1092
|
"place-kit": () => import("./chunks/place-kit-BKk8xDXf.js").then((e) => e.placeKitModule)
|
|
1075
|
-
},
|
|
1093
|
+
}, Yt = {
|
|
1076
1094
|
"captcha-eu": () => import("./chunks/captcha-eu-eU_M6snp.js").then((e) => e.captchaEuModule),
|
|
1077
1095
|
"friendly-captcha-v1": () => import("./chunks/friendly-captcha-v1-C_cF1WD2.js").then((e) => e.friendlyCaptchaV1Module),
|
|
1078
1096
|
"friendly-captcha-v2": () => import("./chunks/friendly-captcha-v2-BenESH-n.js").then((e) => e.friendlyCaptchaV2Module),
|
|
1079
|
-
hcaptcha: () => import("./chunks/hcaptcha-
|
|
1097
|
+
hcaptcha: () => import("./chunks/hcaptcha-lseqzFTP.js").then((e) => e.hcaptchaModule),
|
|
1080
1098
|
"recaptcha-enterprise": () => import("./chunks/recaptcha-enterprise-Cx6HUpMa.js").then((e) => e.recaptchaEnterpriseModule),
|
|
1081
1099
|
"recaptcha-v2-checkbox": () => import("./chunks/recaptcha-v2-checkbox-DQ9BJzcv.js").then((e) => e.recaptchaV2CheckboxModule),
|
|
1082
1100
|
"recaptcha-v2-invisible": () => import("./chunks/recaptcha-v2-invisible-BP0T8Pan.js").then((e) => e.recaptchaV2InvisibleModule),
|
|
1083
1101
|
"recaptcha-v3": () => import("./chunks/recaptcha-v3-DKMGQ27K.js").then((e) => e.recaptchaV3Module),
|
|
1084
1102
|
snaptcha: () => import("./chunks/snaptcha-P3EoSQud.js").then((e) => e.snaptchaModule),
|
|
1085
1103
|
turnstile: () => import("./chunks/turnstile-Sp4ubowK.js").then((e) => e.turnstileModule)
|
|
1086
|
-
},
|
|
1104
|
+
}, Xt = {
|
|
1087
1105
|
calculations: () => import("./chunks/calculations-DeEmdUDq.js").then((e) => e.calculationsModule),
|
|
1088
1106
|
"checkbox-radio": () => import("./chunks/checkbox-radio-CSXo6svm.js").then((e) => e.checkboxRadioModule),
|
|
1089
|
-
combobox: () => import("./chunks/combobox-
|
|
1107
|
+
combobox: () => import("./chunks/combobox-B6ROYFW7.js").then((e) => e.comboboxModule),
|
|
1090
1108
|
conditions: () => import("./chunks/conditions-Dz3068K0.js").then((e) => e.conditionsModule),
|
|
1091
1109
|
"custom-google-maps": () => import("./chunks/custom-google-maps-rNm5VFbb.js").then((e) => e.customGoogleMapsModule),
|
|
1092
1110
|
"custom-link": () => import("./chunks/custom-link-CLqFCssQ.js").then((e) => e.customLinkModule),
|
|
1093
1111
|
"custom-maps": () => import("./chunks/custom-maps-DgjYQDLj.js").then((e) => e.customMapsModule),
|
|
1094
|
-
"date-picker": () => import("./chunks/date-picker-
|
|
1112
|
+
"date-picker": () => import("./chunks/date-picker-dp41TnRq.js").then((e) => e.datePickerModule),
|
|
1095
1113
|
"file-upload": () => import("./chunks/file-upload-vEUr_EuP.js").then((e) => e.fileUploadModule),
|
|
1096
|
-
"upload-manager": () => import("./chunks/upload-manager-
|
|
1114
|
+
"upload-manager": () => import("./chunks/upload-manager-CkmsPJRl.js").then((e) => e.uploadManagerModule),
|
|
1097
1115
|
hidden: () => import("./chunks/hidden-Bc2TpcgF.js").then((e) => e.hiddenModule),
|
|
1098
|
-
"phone-country": () => import("./chunks/phone-country-
|
|
1116
|
+
"phone-country": () => import("./chunks/phone-country-BMyw-Qcz.js").then((e) => e.phoneCountryModule),
|
|
1099
1117
|
"password-validation": () => import("./chunks/password-validation-HGOU9kf3.js").then((e) => e.passwordValidationModule),
|
|
1100
1118
|
"address-country": () => import("./chunks/address-country-DLJF-OkC.js").then((e) => e.addressCountryModule),
|
|
1101
|
-
"address-state": () => import("./chunks/address-state-
|
|
1119
|
+
"address-state": () => import("./chunks/address-state-D9KfV-qB.js").then((e) => e.addressStateModule),
|
|
1102
1120
|
repeater: () => import("./chunks/repeater-BR0RUvTs.js").then((e) => e.repeaterModule),
|
|
1103
1121
|
"rich-text": () => import("./chunks/rich-text-H2A6cm1t.js").then((e) => e.richTextModule),
|
|
1104
1122
|
signature: () => import("./chunks/signature-CfKA_poI.js").then((e) => e.signatureModule),
|
|
@@ -1108,7 +1126,7 @@ var Ut = class {
|
|
|
1108
1126
|
"survey-rating": () => import("./chunks/survey-rating-mlDMI0uq.js").then((e) => e.surveyRatingModule),
|
|
1109
1127
|
table: () => import("./chunks/table-0k6Md0IO.js").then((e) => e.tableModule),
|
|
1110
1128
|
"text-limit": () => import("./chunks/text-limit-CTVML6s7.js").then((e) => e.textLimitModule)
|
|
1111
|
-
},
|
|
1129
|
+
}, Zt = {
|
|
1112
1130
|
bpoint: () => import("./chunks/bpoint-GvYfyPjD.js").then((e) => e.bpointModule),
|
|
1113
1131
|
eway: () => import("./chunks/eway-BZuTBAUW.js").then((e) => e.ewayModule),
|
|
1114
1132
|
"go-cardless": () => import("./chunks/go-cardless-DWZeB0Bq.js").then((e) => e.goCardlessModule),
|
|
@@ -1120,13 +1138,13 @@ var Ut = class {
|
|
|
1120
1138
|
payway: () => import("./chunks/payway-vxC7_bfR.js").then((e) => e.paywayModule),
|
|
1121
1139
|
square: () => import("./chunks/square-Dyz0p_GU.js").then((e) => e.squareModule),
|
|
1122
1140
|
stripe: () => import("./chunks/stripe-Bfd_jp_k.js").then((e) => e.stripeModule)
|
|
1123
|
-
},
|
|
1124
|
-
...
|
|
1125
|
-
...
|
|
1126
|
-
...
|
|
1127
|
-
...
|
|
1128
|
-
},
|
|
1129
|
-
function
|
|
1141
|
+
}, Qt = {
|
|
1142
|
+
...Xt,
|
|
1143
|
+
...Jt,
|
|
1144
|
+
...Yt,
|
|
1145
|
+
...Zt
|
|
1146
|
+
}, z = /* @__PURE__ */ new Map();
|
|
1147
|
+
function $t(e) {
|
|
1130
1148
|
if (e instanceof Error) return {
|
|
1131
1149
|
name: e.name || "Error",
|
|
1132
1150
|
message: e.message || "No error message was provided.",
|
|
@@ -1148,7 +1166,7 @@ function Xt(e) {
|
|
|
1148
1166
|
};
|
|
1149
1167
|
}
|
|
1150
1168
|
}
|
|
1151
|
-
function
|
|
1169
|
+
function en(e, t, n) {
|
|
1152
1170
|
let r = [...t].filter((e) => e.required), i = [
|
|
1153
1171
|
"Formie browser module diagnostics",
|
|
1154
1172
|
`Surface: ${e}`,
|
|
@@ -1159,7 +1177,7 @@ function Zt(e, t, n) {
|
|
|
1159
1177
|
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));
|
|
1160
1178
|
}), i.join("\n");
|
|
1161
1179
|
}
|
|
1162
|
-
async function
|
|
1180
|
+
async function tn(e) {
|
|
1163
1181
|
if (navigator.clipboard?.writeText) {
|
|
1164
1182
|
await navigator.clipboard.writeText(e);
|
|
1165
1183
|
return;
|
|
@@ -1172,26 +1190,26 @@ async function Qt(e) {
|
|
|
1172
1190
|
t.remove();
|
|
1173
1191
|
}
|
|
1174
1192
|
}
|
|
1175
|
-
async function
|
|
1193
|
+
async function nn(e, t) {
|
|
1176
1194
|
let n = t.get(e);
|
|
1177
1195
|
if (n) return n;
|
|
1178
|
-
let r = e.startsWith("formie:") && Object.prototype.hasOwnProperty.call(
|
|
1196
|
+
let r = e.startsWith("formie:") && Object.prototype.hasOwnProperty.call(Qt, e.slice(7)) ? Qt[e.slice(7)] : void 0;
|
|
1179
1197
|
if (!r) throw Error(`Browser module ${e} is not registered.`);
|
|
1180
|
-
|
|
1181
|
-
throw
|
|
1198
|
+
z.has(e) || z.set(e, r().catch((t) => {
|
|
1199
|
+
throw z.delete(e), t;
|
|
1182
1200
|
}));
|
|
1183
|
-
let i = await
|
|
1201
|
+
let i = await z.get(e);
|
|
1184
1202
|
if (i.moduleId !== e) throw Error(`Module definition does not match ${e}.`);
|
|
1185
1203
|
return t.register(i), i;
|
|
1186
1204
|
}
|
|
1187
|
-
function
|
|
1205
|
+
function rn(e, t, n) {
|
|
1188
1206
|
return [...new Set(e.targets.flatMap((e) => {
|
|
1189
1207
|
if (e.type === "form") return [n || t];
|
|
1190
1208
|
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)}"]`;
|
|
1191
1209
|
return [...t.matches(r) ? [t] : [], ...t.querySelectorAll(r)];
|
|
1192
1210
|
}))].filter((e) => !e.closest("[hidden], [data-formie-hidden=\"true\"], [data-formie-conditionally-hidden], [data-formie-page-hidden]"));
|
|
1193
1211
|
}
|
|
1194
|
-
async function
|
|
1212
|
+
async function an(e, t) {
|
|
1195
1213
|
n(e);
|
|
1196
1214
|
let r = e.surface;
|
|
1197
1215
|
if (t.matchContext.surface !== r || t.setupContext.surface !== r) throw Error(`Browser module manifest surface ${r} cannot mount as ${t.matchContext.surface}.`);
|
|
@@ -1204,7 +1222,7 @@ async function tn(e, t) {
|
|
|
1204
1222
|
code: "MODULE_UNAVAILABLE",
|
|
1205
1223
|
message: "A form feature could not start. Reload the page or contact the site administrator."
|
|
1206
1224
|
};
|
|
1207
|
-
s.set(e.key, i), c.set(e.key,
|
|
1225
|
+
s.set(e.key, i), c.set(e.key, $t(n)), console.error("[formie] Browser module failure", i, n), await t.setupContext.emit("formie:browser:module:error", i);
|
|
1208
1226
|
}, m = async (e) => {
|
|
1209
1227
|
try {
|
|
1210
1228
|
await e.destroy();
|
|
@@ -1246,7 +1264,7 @@ async function tn(e, t) {
|
|
|
1246
1264
|
let d = document.createElement("span");
|
|
1247
1265
|
d.className = "formie-module-error__copy-status", d.setAttribute("role", "status"), d.setAttribute("aria-live", "polite"), u.addEventListener("click", async () => {
|
|
1248
1266
|
try {
|
|
1249
|
-
await
|
|
1267
|
+
await tn(n.textContent || ""), d.textContent = "Details copied.";
|
|
1250
1268
|
} catch {
|
|
1251
1269
|
d.textContent = "Copy failed. Select the details above and copy them manually.";
|
|
1252
1270
|
let e = document.createRange();
|
|
@@ -1256,7 +1274,7 @@ async function tn(e, t) {
|
|
|
1256
1274
|
}
|
|
1257
1275
|
e.dataset.formieModuleError = "true", i !== a && a.contains(i) ? i.before(e) : a.prepend(e);
|
|
1258
1276
|
}
|
|
1259
|
-
let t = e.querySelector("[data-formie-module-error-details]"), n =
|
|
1277
|
+
let t = e.querySelector("[data-formie-module-error-details]"), n = en(r, s.values(), c);
|
|
1260
1278
|
t && t.textContent !== n && (t.textContent = n);
|
|
1261
1279
|
}, _ = (e) => {
|
|
1262
1280
|
h() && (e.preventDefault(), e.stopImmediatePropagation(), g());
|
|
@@ -1275,7 +1293,7 @@ async function tn(e, t) {
|
|
|
1275
1293
|
});
|
|
1276
1294
|
let d;
|
|
1277
1295
|
try {
|
|
1278
|
-
d =
|
|
1296
|
+
d = rn(n, i, a);
|
|
1279
1297
|
} catch (e) {
|
|
1280
1298
|
s.has(n.key) || await p(n, e);
|
|
1281
1299
|
continue;
|
|
@@ -1285,7 +1303,7 @@ async function tn(e, t) {
|
|
|
1285
1303
|
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));
|
|
1286
1304
|
let h;
|
|
1287
1305
|
try {
|
|
1288
|
-
h = await
|
|
1306
|
+
h = await nn(n.moduleId, t.registry);
|
|
1289
1307
|
} catch (e) {
|
|
1290
1308
|
s.has(n.key) || await p(n, e);
|
|
1291
1309
|
continue;
|
|
@@ -1322,7 +1340,13 @@ async function tn(e, t) {
|
|
|
1322
1340
|
target: e,
|
|
1323
1341
|
scope: c.scope,
|
|
1324
1342
|
manifestItem: n
|
|
1325
|
-
}))
|
|
1343
|
+
})) {
|
|
1344
|
+
if (h.kind === "field" || h.kind === "core") {
|
|
1345
|
+
_ = !0;
|
|
1346
|
+
continue;
|
|
1347
|
+
}
|
|
1348
|
+
throw Error(`Module ${n.moduleId} does not support the rendered target.`);
|
|
1349
|
+
}
|
|
1326
1350
|
let s = await h.setup(c);
|
|
1327
1351
|
if (!s) throw Error(`Module ${n.moduleId} did not initialize.`);
|
|
1328
1352
|
if (u || !i.contains(e) && e !== i) {
|
|
@@ -1409,7 +1433,7 @@ async function tn(e, t) {
|
|
|
1409
1433
|
}
|
|
1410
1434
|
//#endregion
|
|
1411
1435
|
//#region src/js/utils/unload-warning.ts
|
|
1412
|
-
var
|
|
1436
|
+
var on = /* @__PURE__ */ new Set([
|
|
1413
1437
|
"action",
|
|
1414
1438
|
"redirect",
|
|
1415
1439
|
"requestToken",
|
|
@@ -1422,7 +1446,7 @@ var nn = /* @__PURE__ */ new Set([
|
|
|
1422
1446
|
"draftContext",
|
|
1423
1447
|
"progressId"
|
|
1424
1448
|
]);
|
|
1425
|
-
function
|
|
1449
|
+
function sn(e) {
|
|
1426
1450
|
let t = /* @__PURE__ */ new Set(), n = !0;
|
|
1427
1451
|
return g(e, "formie:unload-warning:collect-exclusions", {
|
|
1428
1452
|
form: e,
|
|
@@ -1433,40 +1457,40 @@ function rn(e) {
|
|
|
1433
1457
|
}
|
|
1434
1458
|
}), n = !1, t;
|
|
1435
1459
|
}
|
|
1436
|
-
function
|
|
1460
|
+
function cn(e, t) {
|
|
1437
1461
|
if (e == null) return String(e);
|
|
1438
1462
|
if (typeof e == "string") return JSON.stringify(e);
|
|
1439
1463
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1440
1464
|
if (typeof e == "function") return "[function]";
|
|
1441
1465
|
if (typeof File < "u" && e instanceof File) return `[file:${e.name}:${e.size}:${e.type}]`;
|
|
1442
1466
|
if (typeof Blob < "u" && e instanceof Blob) return `[blob:${e.size}:${e.type}]`;
|
|
1443
|
-
if (Array.isArray(e)) return `[${e.map((e) =>
|
|
1467
|
+
if (Array.isArray(e)) return `[${e.map((e) => cn(e, t)).join(",")}]`;
|
|
1444
1468
|
if (typeof e == "object") {
|
|
1445
1469
|
if (t.has(e)) return "[circular]";
|
|
1446
1470
|
t.add(e);
|
|
1447
|
-
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${
|
|
1471
|
+
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${cn(n, t)}`);
|
|
1448
1472
|
return t.delete(e), `{${n.join(",")}}`;
|
|
1449
1473
|
}
|
|
1450
1474
|
return JSON.stringify(String(e));
|
|
1451
1475
|
}
|
|
1452
|
-
function
|
|
1453
|
-
return
|
|
1476
|
+
function ln(e) {
|
|
1477
|
+
return cn(e, /* @__PURE__ */ new WeakSet());
|
|
1454
1478
|
}
|
|
1455
|
-
function
|
|
1479
|
+
function un(e, t) {
|
|
1456
1480
|
if (!e) return !1;
|
|
1457
1481
|
let n = e.endsWith("[]") ? e.slice(0, -2) : e;
|
|
1458
|
-
return !ie(n, t) && !
|
|
1482
|
+
return !ie(n, t) && !on.has(n);
|
|
1459
1483
|
}
|
|
1460
|
-
function
|
|
1461
|
-
return
|
|
1484
|
+
function dn(e, t, n) {
|
|
1485
|
+
return ln(e.filter(([e]) => !n.has(e) && un(String(e || ""), t)));
|
|
1462
1486
|
}
|
|
1463
|
-
function
|
|
1487
|
+
function fn(e, t = {}) {
|
|
1464
1488
|
let n = [], r = !1, i = !1, a = !1, o = null, s = null, c = null, l = () => {
|
|
1465
1489
|
o !== null && (window.cancelAnimationFrame(o), o = null), s !== null && (window.clearTimeout(s), s = null), c !== null && (window.clearTimeout(c), c = null);
|
|
1466
1490
|
}, u = () => {
|
|
1467
1491
|
if (!r) return !1;
|
|
1468
|
-
let t =
|
|
1469
|
-
return a =
|
|
1492
|
+
let t = sn(e);
|
|
1493
|
+
return a = dn(Array.from(new FormData(e).entries()), e, t) !== dn(n, e, t), a;
|
|
1470
1494
|
}, d = () => {
|
|
1471
1495
|
i || (l(), n = Array.from(new FormData(e).entries()), r = !0, a = !1);
|
|
1472
1496
|
}, f = () => {
|
|
@@ -1493,7 +1517,7 @@ function cn(e, t = {}) {
|
|
|
1493
1517
|
}
|
|
1494
1518
|
//#endregion
|
|
1495
1519
|
//#region src/js/validation/rules/email.ts
|
|
1496
|
-
var
|
|
1520
|
+
var pn = {
|
|
1497
1521
|
rule: ({ input: e, getRule: n }) => {
|
|
1498
1522
|
let r = n("email");
|
|
1499
1523
|
return !r || t(e.value, {
|
|
@@ -1505,10 +1529,10 @@ var ln = {
|
|
|
1505
1529
|
};
|
|
1506
1530
|
//#endregion
|
|
1507
1531
|
//#region src/js/validation/rules/shared.ts
|
|
1508
|
-
function
|
|
1532
|
+
function mn(e) {
|
|
1509
1533
|
return e?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() || "";
|
|
1510
1534
|
}
|
|
1511
|
-
function
|
|
1535
|
+
function hn(e) {
|
|
1512
1536
|
let t = e.getRule("match");
|
|
1513
1537
|
if (!t || t === !0 || typeof t != "object" || !e.field) return null;
|
|
1514
1538
|
let n = typeof t.fieldHandle == "string" ? t.fieldHandle.trim() : "";
|
|
@@ -1518,7 +1542,7 @@ function dn(e) {
|
|
|
1518
1542
|
}
|
|
1519
1543
|
//#endregion
|
|
1520
1544
|
//#region src/js/validation/rules.ts
|
|
1521
|
-
var
|
|
1545
|
+
var gn = {
|
|
1522
1546
|
required: {
|
|
1523
1547
|
rule: ({ input: e, getRule: n }) => {
|
|
1524
1548
|
if (!n("required") || e.type === "hidden" || e.closest("[data-formie-field-handle]")?.getAttribute("data-formie-field-type") === "table") return !0;
|
|
@@ -1535,7 +1559,7 @@ var fn = {
|
|
|
1535
1559
|
},
|
|
1536
1560
|
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 })
|
|
1537
1561
|
},
|
|
1538
|
-
email:
|
|
1562
|
+
email: pn,
|
|
1539
1563
|
url: {
|
|
1540
1564
|
rule: ({ input: e, getRule: n }) => {
|
|
1541
1565
|
let r = n("url");
|
|
@@ -1564,18 +1588,18 @@ var fn = {
|
|
|
1564
1588
|
},
|
|
1565
1589
|
match: {
|
|
1566
1590
|
rule: (e) => {
|
|
1567
|
-
let n =
|
|
1591
|
+
let n = hn(e);
|
|
1568
1592
|
return !n || t(e.input.value, { type: "match" }, { comparison: n.value }) === null;
|
|
1569
1593
|
},
|
|
1570
1594
|
message: (e) => {
|
|
1571
|
-
let t =
|
|
1595
|
+
let t = hn(e)?.closest("[data-formie-field-handle]"), n = mn(t);
|
|
1572
1596
|
return e.input.getAttribute("data-formie-validation-match-message") ?? e.t("{label} must match {value}.", {
|
|
1573
1597
|
label: e.label,
|
|
1574
1598
|
value: n
|
|
1575
1599
|
});
|
|
1576
1600
|
}
|
|
1577
1601
|
}
|
|
1578
|
-
},
|
|
1602
|
+
}, _n = {
|
|
1579
1603
|
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,})+$/,
|
|
1580
1604
|
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*)?$/,
|
|
1581
1605
|
number: /^(?:[-+]?[0-9]*[.,]?[0-9]+)$/,
|
|
@@ -1583,14 +1607,14 @@ var fn = {
|
|
|
1583
1607
|
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))/,
|
|
1584
1608
|
time: /^(?:(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]))$/,
|
|
1585
1609
|
month: /^(?:(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])))$/
|
|
1586
|
-
},
|
|
1587
|
-
function
|
|
1588
|
-
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement) && !!e.name;
|
|
1610
|
+
}, B = O("general", "validator");
|
|
1611
|
+
function V(e) {
|
|
1612
|
+
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement) && (!!e.name || e.hasAttribute("data-formie-date-datepicker-input"));
|
|
1589
1613
|
}
|
|
1590
|
-
function
|
|
1614
|
+
function H(e) {
|
|
1591
1615
|
return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
1592
1616
|
}
|
|
1593
|
-
var
|
|
1617
|
+
var vn = class {
|
|
1594
1618
|
form;
|
|
1595
1619
|
errors = [];
|
|
1596
1620
|
validators = {};
|
|
@@ -1612,14 +1636,14 @@ var mn = class {
|
|
|
1612
1636
|
messagesClass: [],
|
|
1613
1637
|
messageClass: [],
|
|
1614
1638
|
fieldsSelector: "input:not([type=\"hidden\"]):not([type=\"submit\"]):not([type=\"button\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])",
|
|
1615
|
-
patterns:
|
|
1639
|
+
patterns: _n,
|
|
1616
1640
|
...t
|
|
1617
|
-
}, Object.entries(
|
|
1641
|
+
}, Object.entries(gn).forEach(([e, t]) => {
|
|
1618
1642
|
this.addValidator(e, t.rule, t.message);
|
|
1619
1643
|
}), this.init();
|
|
1620
1644
|
}
|
|
1621
1645
|
init() {
|
|
1622
|
-
|
|
1646
|
+
B.log("Initializing validator.", {
|
|
1623
1647
|
formId: this.form.id || null,
|
|
1624
1648
|
live: this.config.live
|
|
1625
1649
|
}), this.form.setAttribute("novalidate", "true"), this.inputs().forEach((e) => {
|
|
@@ -1627,9 +1651,9 @@ var mn = class {
|
|
|
1627
1651
|
}), this.config.live && this.addEventListeners(), this.emitEvent(document, o("ready"), { validator: this });
|
|
1628
1652
|
}
|
|
1629
1653
|
inputs(e = null) {
|
|
1630
|
-
if (
|
|
1654
|
+
if (V(e)) return j(e) ? [] : [e];
|
|
1631
1655
|
let t = e || this.form;
|
|
1632
|
-
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) =>
|
|
1656
|
+
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) => V(e) && !j(e));
|
|
1633
1657
|
}
|
|
1634
1658
|
getInputValue(e) {
|
|
1635
1659
|
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 ?? "";
|
|
@@ -1669,7 +1693,7 @@ var mn = class {
|
|
|
1669
1693
|
}), r = !0;
|
|
1670
1694
|
}
|
|
1671
1695
|
}), !r && i && this.removeError(e);
|
|
1672
|
-
}),
|
|
1696
|
+
}), B.log("Validation pass complete.", {
|
|
1673
1697
|
errorCount: this.errors.length,
|
|
1674
1698
|
includeHiddenPages: t.includeHiddenPages === !0
|
|
1675
1699
|
}), this.errors;
|
|
@@ -1690,7 +1714,7 @@ var mn = class {
|
|
|
1690
1714
|
e.remove();
|
|
1691
1715
|
}), n && (n.innerHTML = ""), t.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
1692
1716
|
let t = e;
|
|
1693
|
-
t.removeAttribute("aria-invalid"), this.config.inputErrorClass.length && t.classList.remove(...this.config.inputErrorClass), t.removeAttribute("data-formie-input-has-error"),
|
|
1717
|
+
t.removeAttribute("aria-invalid"), this.config.inputErrorClass.length && t.classList.remove(...this.config.inputErrorClass), t.removeAttribute("data-formie-input-has-error"), Be(t, r);
|
|
1694
1718
|
});
|
|
1695
1719
|
for (let e = t; e; e = e.parentElement?.closest("[data-formie-field-handle]")) this.config.fieldContainerErrorClass.length && e.classList.remove(...this.config.fieldContainerErrorClass), e.removeAttribute("data-formie-field-has-error");
|
|
1696
1720
|
this.emitEvent(e, o("clear-error"), { validator: this }), h(this.form);
|
|
@@ -1699,7 +1723,7 @@ var mn = class {
|
|
|
1699
1723
|
let r = e.closest("[data-formie-field-handle]");
|
|
1700
1724
|
if (!r) return;
|
|
1701
1725
|
let i = r.querySelector("[data-formie-field-errors]");
|
|
1702
|
-
i ||=
|
|
1726
|
+
i ||= ht(r, (e) => {
|
|
1703
1727
|
this.config.messagesClass.length && e.classList.add(...this.config.messagesClass);
|
|
1704
1728
|
}), this.config.messagesClass.length && i.classList.add(...this.config.messagesClass), i.innerHTML = "";
|
|
1705
1729
|
let a = r.getAttribute("data-formie-field-handle") || "field";
|
|
@@ -1709,7 +1733,7 @@ var mn = class {
|
|
|
1709
1733
|
let c = document.createElement("div");
|
|
1710
1734
|
c.setAttribute("data-formie-field-error", "true"), c.setAttribute(`data-formie-field-error-${t}`, "true"), c.setAttribute("id", s), this.config.messageClass.length && c.classList.add(...this.config.messageClass), c.textContent = n, i.appendChild(c), r.setAttribute("data-formie-field-has-error", "true"), r.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
1711
1735
|
let t = e;
|
|
1712
|
-
j(t) || (t.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && t.classList.add(...this.config.inputErrorClass), t.setAttribute("data-formie-input-has-error", "true"),
|
|
1736
|
+
j(t) || (t.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && t.classList.add(...this.config.inputErrorClass), t.setAttribute("data-formie-input-has-error", "true"), ze(t, s));
|
|
1713
1737
|
});
|
|
1714
1738
|
for (let e = r; e; e = e.parentElement?.closest("[data-formie-field-handle]")) this.config.fieldContainerErrorClass.length && e.classList.add(...this.config.fieldContainerErrorClass), e.setAttribute("data-formie-field-has-error", "true");
|
|
1715
1739
|
this.emitEvent(e, o("show-error"), {
|
|
@@ -1755,7 +1779,7 @@ var mn = class {
|
|
|
1755
1779
|
try {
|
|
1756
1780
|
n = JSON.parse(e);
|
|
1757
1781
|
} catch {
|
|
1758
|
-
return
|
|
1782
|
+
return B.warn("Invalid validation rules payload.", { formId: this.form.id || null }), t;
|
|
1759
1783
|
}
|
|
1760
1784
|
return Array.isArray(n) && n.forEach((e) => {
|
|
1761
1785
|
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
@@ -1764,39 +1788,39 @@ var mn = class {
|
|
|
1764
1788
|
}), t;
|
|
1765
1789
|
}
|
|
1766
1790
|
destroy() {
|
|
1767
|
-
|
|
1791
|
+
B.log("Destroying validator.", { formId: this.form.id || null }), this.removeEventListeners(), this.form.removeAttribute("novalidate"), this.emitEvent(document, o("destroy"), { validator: this });
|
|
1768
1792
|
}
|
|
1769
1793
|
isVisible(e, t = {}) {
|
|
1770
1794
|
if (e.disabled || e.hasAttribute("data-formie-conditions-disabled") || e.closest("[data-formie-conditions-disabled]") || e.closest("[data-formie-conditionally-hidden]")) return !1;
|
|
1771
1795
|
if (e.closest("[data-formie-page-hidden]")) return !!t.includeHiddenPages;
|
|
1772
1796
|
let n = e.closest("[data-formie-field-handle]"), r = n?.querySelector("[data-formie-rich-text]");
|
|
1773
|
-
if (r instanceof HTMLElement) return
|
|
1797
|
+
if (r instanceof HTMLElement) return H(r);
|
|
1774
1798
|
if (e instanceof HTMLSelectElement && e.hasAttribute("data-formie-combobox-input")) {
|
|
1775
1799
|
let t = e.nextElementSibling;
|
|
1776
|
-
if (t instanceof HTMLElement && t.classList.contains("formie-combobox")) return
|
|
1800
|
+
if (t instanceof HTMLElement && t.classList.contains("formie-combobox")) return H(t);
|
|
1777
1801
|
}
|
|
1778
|
-
return e instanceof HTMLSelectElement && n instanceof HTMLElement ?
|
|
1802
|
+
return e instanceof HTMLSelectElement && n instanceof HTMLElement ? H(e) || H(n) : H(e);
|
|
1779
1803
|
}
|
|
1780
1804
|
blurHandler(e) {
|
|
1781
|
-
e.target instanceof HTMLElement &&
|
|
1805
|
+
e.target instanceof HTMLElement && V(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)));
|
|
1782
1806
|
}
|
|
1783
1807
|
changeHandler(e) {
|
|
1784
|
-
e.target instanceof HTMLElement &&
|
|
1808
|
+
e.target instanceof HTMLElement && V(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)));
|
|
1785
1809
|
}
|
|
1786
1810
|
inputHandler(e) {
|
|
1787
|
-
e.target instanceof HTMLElement &&
|
|
1811
|
+
e.target instanceof HTMLElement && V(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));
|
|
1788
1812
|
}
|
|
1789
1813
|
submit(e = null, { final: t = !1 } = {}) {
|
|
1790
|
-
return this.submitted = !0,
|
|
1814
|
+
return this.submitted = !0, B.log("Submit validation requested.", { final: t }), this.boundListeners || this.addEventListeners(), this.removeAllErrors(), this.validate(e, { includeHiddenPages: t });
|
|
1791
1815
|
}
|
|
1792
1816
|
resetLiveState() {
|
|
1793
1817
|
this.submitted = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.errors = [], this.removeAllErrors();
|
|
1794
1818
|
}
|
|
1795
1819
|
addEventListeners() {
|
|
1796
|
-
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,
|
|
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, B.log("Event listeners attached."));
|
|
1797
1821
|
}
|
|
1798
1822
|
removeEventListeners() {
|
|
1799
|
-
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1,
|
|
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, B.log("Event listeners removed.");
|
|
1800
1824
|
}
|
|
1801
1825
|
emitEvent(e, t, n = {}) {
|
|
1802
1826
|
e.dispatchEvent(new CustomEvent(t, {
|
|
@@ -1816,25 +1840,25 @@ var mn = class {
|
|
|
1816
1840
|
};
|
|
1817
1841
|
//#endregion
|
|
1818
1842
|
//#region src/js/validation/enter-key-guard.ts
|
|
1819
|
-
function
|
|
1843
|
+
function yn(e) {
|
|
1820
1844
|
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]");
|
|
1821
1845
|
}
|
|
1822
|
-
function
|
|
1846
|
+
function bn(e, t) {
|
|
1823
1847
|
let n = e.querySelectorAll(`[data-formie-action="${t}"]`);
|
|
1824
|
-
return Array.from(n).some((e) => !
|
|
1848
|
+
return Array.from(n).some((e) => !yn(e));
|
|
1825
1849
|
}
|
|
1826
|
-
function
|
|
1850
|
+
function xn(e) {
|
|
1827
1851
|
let { final: t } = m(e);
|
|
1828
1852
|
return "submit";
|
|
1829
1853
|
}
|
|
1830
|
-
function
|
|
1831
|
-
return !
|
|
1854
|
+
function Sn(e) {
|
|
1855
|
+
return !bn(e, xn(e));
|
|
1832
1856
|
}
|
|
1833
|
-
function
|
|
1857
|
+
function Cn(e) {
|
|
1834
1858
|
let t = (t) => {
|
|
1835
1859
|
if (t.key !== "Enter" || t.defaultPrevented) return;
|
|
1836
1860
|
let n = t.target;
|
|
1837
|
-
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") ||
|
|
1861
|
+
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") || Sn(e) && t.preventDefault());
|
|
1838
1862
|
};
|
|
1839
1863
|
return e.addEventListener("keydown", t, !0), () => {
|
|
1840
1864
|
e.removeEventListener("keydown", t, !0);
|
|
@@ -1842,16 +1866,16 @@ function yn(e) {
|
|
|
1842
1866
|
}
|
|
1843
1867
|
//#endregion
|
|
1844
1868
|
//#region src/js/core/create-formie-client.ts
|
|
1845
|
-
var
|
|
1846
|
-
function
|
|
1869
|
+
var U = "[data-formie]:not([data-formie-init=\"false\"]), [data-formie-form]:not([data-formie-init=\"false\"])", wn = 300, Tn = "/actions/formie/server/forms/render", En = "/api", Dn = "/actions/formie/server/forms/refresh-tokens", On = "/actions/formie/server/submissions/submit", kn = "/actions/formie/server/submissions/set-page", An = "/actions/formie/server/submissions/clear-submission", jn = "/actions/formie/file-upload/hydrate", W = O("general", "client"), Mn = /* @__PURE__ */ new Set();
|
|
1870
|
+
function G(e, t) {
|
|
1847
1871
|
if (e == null || e === "") return t;
|
|
1848
1872
|
let n = e.toLowerCase();
|
|
1849
1873
|
return n !== "false" && n !== "0" && n !== "off";
|
|
1850
1874
|
}
|
|
1851
|
-
function
|
|
1852
|
-
return e.formieRefreshTokens == null ? e.formieStaticCache != null &&
|
|
1875
|
+
function Nn(e) {
|
|
1876
|
+
return e.formieRefreshTokens == null ? e.formieStaticCache != null && G(e.formieStaticCache, !0) : G(e.formieRefreshTokens, !0);
|
|
1853
1877
|
}
|
|
1854
|
-
function
|
|
1878
|
+
function K(e) {
|
|
1855
1879
|
let t = e instanceof HTMLElement ? e.dataset : {};
|
|
1856
1880
|
return {
|
|
1857
1881
|
mode: "server-rendered",
|
|
@@ -1859,25 +1883,25 @@ function Y(e) {
|
|
|
1859
1883
|
profile: t.formieRequestProfile,
|
|
1860
1884
|
formHandle: t.formieHandle,
|
|
1861
1885
|
endpoint: t.formieEndpoint,
|
|
1862
|
-
staticCache:
|
|
1863
|
-
autoVisible:
|
|
1864
|
-
compatibility:
|
|
1886
|
+
staticCache: Nn(t),
|
|
1887
|
+
autoVisible: G(t.formieAutoVisible, !0),
|
|
1888
|
+
compatibility: G(t.formieCompatibility, !1)
|
|
1865
1889
|
};
|
|
1866
1890
|
}
|
|
1867
|
-
function
|
|
1891
|
+
function Pn(e) {
|
|
1868
1892
|
if (e && e !== "server-rendered") throw Error("@verbb/formie-browser enhances server-rendered HTML only. Use @verbb/formie-core for client-rendered forms.");
|
|
1869
1893
|
return "server-rendered";
|
|
1870
1894
|
}
|
|
1871
|
-
function
|
|
1895
|
+
function Fn(e) {
|
|
1872
1896
|
return e || "rest";
|
|
1873
1897
|
}
|
|
1874
|
-
function
|
|
1898
|
+
function q(e) {
|
|
1875
1899
|
return e instanceof HTMLFormElement ? e : e.querySelector("form");
|
|
1876
1900
|
}
|
|
1877
|
-
function
|
|
1878
|
-
|
|
1901
|
+
function In(e, t) {
|
|
1902
|
+
Mn.has(e) || (Mn.add(e), W.warn(t));
|
|
1879
1903
|
}
|
|
1880
|
-
function
|
|
1904
|
+
function J(e, t) {
|
|
1881
1905
|
if (!e) return e;
|
|
1882
1906
|
try {
|
|
1883
1907
|
return new URL(e).toString();
|
|
@@ -1889,64 +1913,61 @@ function Pn(e, t) {
|
|
|
1889
1913
|
return e;
|
|
1890
1914
|
}
|
|
1891
1915
|
}
|
|
1892
|
-
function
|
|
1916
|
+
function Y(e, t) {
|
|
1893
1917
|
let n = (e || "").trim();
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
return
|
|
1918
|
+
if (!n) return t;
|
|
1919
|
+
if (n.includes(t)) return n;
|
|
1920
|
+
let r = t.replace(/^\/actions/, "");
|
|
1921
|
+
try {
|
|
1922
|
+
let e = new URL(n, window.location.origin);
|
|
1923
|
+
if (e.pathname.endsWith(r) || Array.from(e.searchParams.values()).some((e) => e.endsWith(r))) return n;
|
|
1924
|
+
} catch {}
|
|
1925
|
+
return J(t, n);
|
|
1902
1926
|
}
|
|
1903
1927
|
function Ln(e, t) {
|
|
1904
|
-
return
|
|
1928
|
+
return Y(e.endpoint || t.dataset.formieEndpoint, Tn);
|
|
1905
1929
|
}
|
|
1906
1930
|
function Rn(e, t) {
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
} catch {
|
|
1914
|
-
return t;
|
|
1915
|
-
}
|
|
1931
|
+
let n = (e.endpoint || t.dataset.formieEndpoint || "").trim();
|
|
1932
|
+
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n : J(En, n) : En;
|
|
1933
|
+
}
|
|
1934
|
+
function zn(e, t) {
|
|
1935
|
+
let n = t.dataset.formieRefreshTokensEndpoint || q(t)?.dataset.formieRefreshTokensEndpoint;
|
|
1936
|
+
return n ? J(n, e.endpoint || t.dataset.formieEndpoint) : Y(e.endpoint || t.dataset.formieEndpoint, Dn);
|
|
1916
1937
|
}
|
|
1917
|
-
function
|
|
1918
|
-
let r = n.endpoint || e.dataset.formieEndpoint, i =
|
|
1919
|
-
t.setAttribute("action",
|
|
1920
|
-
let t = e.getAttribute("href")
|
|
1921
|
-
e.setAttribute("href",
|
|
1938
|
+
function Bn(e, t, n) {
|
|
1939
|
+
let r = n.endpoint || e.dataset.formieEndpoint, i = t.getAttribute("action") || t.dataset.formieSubmitEndpoint;
|
|
1940
|
+
t.setAttribute("action", i ? J(i, r) : Y(r, On)), t.querySelectorAll("[data-formie-tab-link]").forEach((e) => {
|
|
1941
|
+
let t = e.getAttribute("href");
|
|
1942
|
+
e.setAttribute("href", t ? J(t, r) : Y(r, kn));
|
|
1922
1943
|
}), t.querySelectorAll("[data-formie-file-upload-hydrate-endpoint]").forEach((e) => {
|
|
1923
|
-
e.setAttribute("data-formie-file-upload-hydrate-endpoint",
|
|
1944
|
+
e.setAttribute("data-formie-file-upload-hydrate-endpoint", J(e.getAttribute("data-formie-file-upload-hydrate-endpoint") || jn, r));
|
|
1924
1945
|
});
|
|
1925
1946
|
}
|
|
1926
|
-
function
|
|
1947
|
+
function Vn(e) {
|
|
1927
1948
|
if (e == null) return !1;
|
|
1928
1949
|
let t = e.trim().toLowerCase();
|
|
1929
1950
|
return t === "true" || t === "1" || t === "";
|
|
1930
1951
|
}
|
|
1931
|
-
function
|
|
1932
|
-
return
|
|
1952
|
+
function Hn(e) {
|
|
1953
|
+
return G(e.dataset.formieAutomaticSubmissionState, !0);
|
|
1933
1954
|
}
|
|
1934
|
-
function
|
|
1935
|
-
return
|
|
1955
|
+
function Un(e, t, n) {
|
|
1956
|
+
return n.dataset.formieClearSubmissionEndpoint ? J(n.dataset.formieClearSubmissionEndpoint, e.endpoint || t.dataset.formieEndpoint) : Y(e.endpoint || t.dataset.formieEndpoint, An);
|
|
1936
1957
|
}
|
|
1937
|
-
function
|
|
1938
|
-
return
|
|
1958
|
+
function Wn(e) {
|
|
1959
|
+
return Vn(e.dataset.formieUnloadWarning);
|
|
1939
1960
|
}
|
|
1940
|
-
function
|
|
1961
|
+
function Gn(e, t) {
|
|
1941
1962
|
e.setAttribute("data-formie-internal-navigation", t);
|
|
1942
1963
|
}
|
|
1943
|
-
function
|
|
1964
|
+
function Kn(e) {
|
|
1944
1965
|
e.removeAttribute("data-formie-internal-navigation");
|
|
1945
1966
|
}
|
|
1946
|
-
function
|
|
1967
|
+
function qn(e) {
|
|
1947
1968
|
return e.getAttribute("data-formie-internal-navigation") !== null;
|
|
1948
1969
|
}
|
|
1949
|
-
function
|
|
1970
|
+
function Jn(e, t) {
|
|
1950
1971
|
if (!e) return !1;
|
|
1951
1972
|
try {
|
|
1952
1973
|
return new URL(e, window.location.origin).searchParams.has(t);
|
|
@@ -1954,25 +1975,25 @@ function qn(e, t) {
|
|
|
1954
1975
|
return !1;
|
|
1955
1976
|
}
|
|
1956
1977
|
}
|
|
1957
|
-
function Jn(e) {
|
|
1958
|
-
return qn(window.location.href, "resumeToken") || qn(e.getAttribute("action"), "resumeToken");
|
|
1959
|
-
}
|
|
1960
1978
|
function Yn(e) {
|
|
1979
|
+
return Jn(window.location.href, "resumeToken") || Jn(e.getAttribute("action"), "resumeToken");
|
|
1980
|
+
}
|
|
1981
|
+
function Xn(e) {
|
|
1961
1982
|
return e instanceof MouseEvent ? e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey : !0;
|
|
1962
1983
|
}
|
|
1963
|
-
function
|
|
1984
|
+
function Zn(e, t = 0) {
|
|
1964
1985
|
if (!e) return t;
|
|
1965
1986
|
let n = Number.parseInt(e, 10);
|
|
1966
1987
|
return Number.isFinite(n) ? n : t;
|
|
1967
1988
|
}
|
|
1968
|
-
function
|
|
1969
|
-
return Math.max(0,
|
|
1989
|
+
function Qn(e) {
|
|
1990
|
+
return Math.max(0, Zn(e.dataset.formieSubmitDelay, wn));
|
|
1970
1991
|
}
|
|
1971
|
-
function
|
|
1972
|
-
return
|
|
1992
|
+
function X(e) {
|
|
1993
|
+
return Vn(e.dataset.formieValidationOnSubmit);
|
|
1973
1994
|
}
|
|
1974
|
-
async function
|
|
1975
|
-
let t =
|
|
1995
|
+
async function Z(e) {
|
|
1996
|
+
let t = Qn(e);
|
|
1976
1997
|
await new Promise((e) => {
|
|
1977
1998
|
window.setTimeout(e, t);
|
|
1978
1999
|
});
|
|
@@ -2037,10 +2058,10 @@ function rr(e, t) {
|
|
|
2037
2058
|
}
|
|
2038
2059
|
}
|
|
2039
2060
|
async function ir(e, t) {
|
|
2040
|
-
let n =
|
|
2061
|
+
let n = Pn(t.mode), r = Fn(t.transport);
|
|
2041
2062
|
if (n !== "server-rendered") return null;
|
|
2042
2063
|
if (t.payload) return t.payload.html && (e.innerHTML = t.payload.html), t.payload;
|
|
2043
|
-
let i = !!
|
|
2064
|
+
let i = !!q(e), a = t.formHandle || e.dataset.formieHandle;
|
|
2044
2065
|
if (i || !a) return null;
|
|
2045
2066
|
let o = {
|
|
2046
2067
|
mode: n,
|
|
@@ -2049,7 +2070,7 @@ async function ir(e, t) {
|
|
|
2049
2070
|
siteId: t.siteId,
|
|
2050
2071
|
theme: t.theme,
|
|
2051
2072
|
themeConfig: t.themeConfig
|
|
2052
|
-
}, s = r === "graphql" ?
|
|
2073
|
+
}, s = r === "graphql" ? Rn(t, e) : Ln(t, e), c = r === "graphql" ? await Ze(s, a, o, t) : await Xe(s, a, {
|
|
2053
2074
|
...o,
|
|
2054
2075
|
endpoint: s
|
|
2055
2076
|
}, t);
|
|
@@ -2059,16 +2080,16 @@ async function ar(e, t, n) {
|
|
|
2059
2080
|
if (t.refreshTokens === !1) return;
|
|
2060
2081
|
let r = t.formHandle || e.dataset.formieHandle;
|
|
2061
2082
|
if (!r) return;
|
|
2062
|
-
let i = await
|
|
2083
|
+
let i = await Qe(zn(t, e), r, n.querySelector("input[name=\"renderId\"]")?.value || void 0, t, n.querySelector("input[name=\"requestToken\"]")?.value, n.querySelector("input[name=\"siteId\"]")?.value || t.siteId);
|
|
2063
2084
|
rr(n, i), g(e, "formie:refresh-tokens:refreshed", i);
|
|
2064
2085
|
}
|
|
2065
2086
|
function or(e, t, n, r, i, a) {
|
|
2066
2087
|
t.dataset.formieRequestProfile = n.profile ?? "same-origin-browser", n.profile === "cross-origin-public" && (t.dataset.formieSubmitMethod = "ajax");
|
|
2067
|
-
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s =
|
|
2088
|
+
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s = Un(n, e, t), c = !1, l = t.querySelectorAll("[data-formie-action]"), u = (e) => {
|
|
2068
2089
|
e ? t.setAttribute("data-formie-pending-action", e) : t.removeAttribute("data-formie-pending-action");
|
|
2069
2090
|
};
|
|
2070
|
-
if (
|
|
2071
|
-
let n =
|
|
2091
|
+
if (Wn(t)) {
|
|
2092
|
+
let n = fn(t, { shouldWarn: () => !qn(t) }), r = (e) => {
|
|
2072
2093
|
if (!(e instanceof CustomEvent)) return;
|
|
2073
2094
|
let t = e.detail;
|
|
2074
2095
|
t?.ok && (t.action === "save" || t.outcome === "revised") && n.scheduleBaselineCapture();
|
|
@@ -2090,7 +2111,7 @@ function or(e, t, n, r, i, a) {
|
|
|
2090
2111
|
}), t.querySelectorAll("[data-formie-tab-link]").forEach((n) => {
|
|
2091
2112
|
let r = async (n) => {
|
|
2092
2113
|
if (o !== "ajax") {
|
|
2093
|
-
|
|
2114
|
+
Xn(n) && Gn(t, "set-page");
|
|
2094
2115
|
return;
|
|
2095
2116
|
}
|
|
2096
2117
|
n.preventDefault();
|
|
@@ -2101,10 +2122,10 @@ function or(e, t, n, r, i, a) {
|
|
|
2101
2122
|
href: a
|
|
2102
2123
|
});
|
|
2103
2124
|
try {
|
|
2104
|
-
let n = await
|
|
2125
|
+
let n = await $e(a, t, i);
|
|
2105
2126
|
if (n.pageId && S(t, String(n.pageId)), !n.success) {
|
|
2106
2127
|
let { form: e = [], ...r } = n.errors ?? {};
|
|
2107
|
-
|
|
2128
|
+
Wt(t), Ft(t, r), It(t, e), qe(t);
|
|
2108
2129
|
return;
|
|
2109
2130
|
}
|
|
2110
2131
|
g(e, "formie:page:navigate:after", {
|
|
@@ -2124,9 +2145,9 @@ function or(e, t, n, r, i, a) {
|
|
|
2124
2145
|
n.addEventListener("click", r), a.push(() => {
|
|
2125
2146
|
n.removeEventListener("click", r);
|
|
2126
2147
|
});
|
|
2127
|
-
}), !
|
|
2148
|
+
}), !Hn(t)) {
|
|
2128
2149
|
let e = !1, n = () => {
|
|
2129
|
-
e ||
|
|
2150
|
+
e || qn(t) || Yn(t) || (e = !0, et(s, t));
|
|
2130
2151
|
};
|
|
2131
2152
|
window.addEventListener("pagehide", n), window.addEventListener("beforeunload", n), a.push(() => {
|
|
2132
2153
|
window.removeEventListener("pagehide", n), window.removeEventListener("beforeunload", n);
|
|
@@ -2141,15 +2162,15 @@ function or(e, t, n, r, i, a) {
|
|
|
2141
2162
|
} else t.removeAttribute("data-formie-internal-resubmit");
|
|
2142
2163
|
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;
|
|
2143
2164
|
try {
|
|
2144
|
-
if (s) v = await
|
|
2165
|
+
if (s) v = await Gt({
|
|
2145
2166
|
target: e,
|
|
2146
2167
|
form: t,
|
|
2147
2168
|
bus: r,
|
|
2148
2169
|
validator: i,
|
|
2149
|
-
validateOnSubmit:
|
|
2170
|
+
validateOnSubmit: X(t),
|
|
2150
2171
|
action: _,
|
|
2151
2172
|
submitter: l,
|
|
2152
|
-
waitForSubmitDelay:
|
|
2173
|
+
waitForSubmitDelay: Z,
|
|
2153
2174
|
onRefreshTokensAfterSubmit: async () => {
|
|
2154
2175
|
await ar(e, n, t);
|
|
2155
2176
|
},
|
|
@@ -2158,16 +2179,16 @@ function or(e, t, n, r, i, a) {
|
|
|
2158
2179
|
}
|
|
2159
2180
|
});
|
|
2160
2181
|
else {
|
|
2161
|
-
if (
|
|
2182
|
+
if (Wt(t), C(t, l), await Z(t), v = await pt(t, _, r, {
|
|
2162
2183
|
validator: i,
|
|
2163
|
-
validateOnSubmit:
|
|
2184
|
+
validateOnSubmit: X(t),
|
|
2164
2185
|
preflightOnly: !0
|
|
2165
2186
|
}), v.ok) {
|
|
2166
|
-
x(t, _), c = !0,
|
|
2187
|
+
x(t, _), c = !0, Gn(t, "submit"), u(null);
|
|
2167
2188
|
let e = !1, n = () => {
|
|
2168
|
-
if (e = !0, c = !1,
|
|
2189
|
+
if (e = !0, c = !1, Kn(t), f(t), i && X(t)) {
|
|
2169
2190
|
let { scope: e, final: n } = m(t), r = i.submit(n ? t : e, { final: n });
|
|
2170
|
-
r.length > 0 &&
|
|
2191
|
+
r.length > 0 && L(t, {
|
|
2171
2192
|
ok: !1,
|
|
2172
2193
|
stage: "validate",
|
|
2173
2194
|
code: "VALIDATION_FAILED",
|
|
@@ -2189,7 +2210,7 @@ function or(e, t, n, r, i, a) {
|
|
|
2189
2210
|
y = !0;
|
|
2190
2211
|
return;
|
|
2191
2212
|
}
|
|
2192
|
-
|
|
2213
|
+
L(t, v), g(e, "formie:submit:result", v), Kn(t);
|
|
2193
2214
|
}
|
|
2194
2215
|
} catch (n) {
|
|
2195
2216
|
c = !1, v = {
|
|
@@ -2197,9 +2218,9 @@ function or(e, t, n, r, i, a) {
|
|
|
2197
2218
|
code: "SUBMIT_ERROR",
|
|
2198
2219
|
message: n instanceof Error ? n.message : "Submission failed.",
|
|
2199
2220
|
formErrors: [n instanceof Error ? n.message : "Submission failed."]
|
|
2200
|
-
},
|
|
2221
|
+
}, L(t, v), g(e, "formie:submit:result", v), Kn(t);
|
|
2201
2222
|
} finally {
|
|
2202
|
-
u(null), !s && !y && !
|
|
2223
|
+
u(null), !s && !y && !Ut(v) && f(t);
|
|
2203
2224
|
}
|
|
2204
2225
|
};
|
|
2205
2226
|
t.addEventListener("submit", d), a.push(() => {
|
|
@@ -2208,13 +2229,13 @@ function or(e, t, n, r, i, a) {
|
|
|
2208
2229
|
}
|
|
2209
2230
|
async function sr(e, t, n) {
|
|
2210
2231
|
if (t.refreshTokens === !1 || !t.staticCache) return;
|
|
2211
|
-
let r = t.formHandle || e.dataset.formieHandle, i =
|
|
2232
|
+
let r = t.formHandle || e.dataset.formieHandle, i = zn(t, e), a = n?.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2212
2233
|
if (!r) return;
|
|
2213
|
-
let o = await
|
|
2234
|
+
let o = await Qe(i, r, a, t, n?.querySelector("input[name=\"requestToken\"]")?.value, n?.querySelector("input[name=\"siteId\"]")?.value || t.siteId);
|
|
2214
2235
|
o && n && (rr(n, o), g(e, "formie:refresh-tokens:after", o));
|
|
2215
2236
|
}
|
|
2216
2237
|
function cr() {
|
|
2217
|
-
let t = /* @__PURE__ */ new Map(), r = new
|
|
2238
|
+
let t = /* @__PURE__ */ new Map(), r = new R(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = [
|
|
2218
2239
|
"prepare",
|
|
2219
2240
|
"normalize",
|
|
2220
2241
|
"validate",
|
|
@@ -2229,22 +2250,22 @@ function cr() {
|
|
|
2229
2250
|
return;
|
|
2230
2251
|
}
|
|
2231
2252
|
let r = (async () => {
|
|
2232
|
-
|
|
2253
|
+
W.log("Unmount requested.", { target: Q(e) });
|
|
2233
2254
|
let n = i.get(e);
|
|
2234
2255
|
n && (n(), i.delete(e));
|
|
2235
2256
|
let r = t.get(e);
|
|
2236
2257
|
r ? (g(e, "formie:unmount:before", { id: r.instance.id }), r.unbinds.forEach((e) => {
|
|
2237
2258
|
e();
|
|
2238
|
-
}), 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(),
|
|
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(), W.log("Unmount complete.", {
|
|
2239
2260
|
id: r.instance.id,
|
|
2240
2261
|
target: Q(e)
|
|
2241
|
-
})) :
|
|
2262
|
+
})) : W.log("Unmount skipped (no mounted state).", { target: Q(e) });
|
|
2242
2263
|
})().finally(() => {
|
|
2243
2264
|
a.delete(e);
|
|
2244
2265
|
});
|
|
2245
2266
|
a.set(e, r), await r;
|
|
2246
2267
|
}, c = async (a, c) => {
|
|
2247
|
-
|
|
2268
|
+
W.log("Mount requested.", {
|
|
2248
2269
|
target: Q(a),
|
|
2249
2270
|
mode: c.mode,
|
|
2250
2271
|
autoVisible: c.autoVisible
|
|
@@ -2252,19 +2273,19 @@ function cr() {
|
|
|
2252
2273
|
let l = i.get(a);
|
|
2253
2274
|
l && (l(), i.delete(a));
|
|
2254
2275
|
let u = t.get(a);
|
|
2255
|
-
if (u) return
|
|
2276
|
+
if (u) return W.log("Mount skipped (already mounted).", {
|
|
2256
2277
|
id: u.instance.id,
|
|
2257
2278
|
target: Q(a)
|
|
2258
2279
|
}), u.instance;
|
|
2259
|
-
let d = new
|
|
2280
|
+
let d = new Kt(), f = [], m = a?.id || `formie-${t.size + 1}`, v = K(a), b = {
|
|
2260
2281
|
...v,
|
|
2261
2282
|
...c,
|
|
2262
|
-
mode:
|
|
2263
|
-
transport:
|
|
2264
|
-
}, x = await ir(a, b), S =
|
|
2265
|
-
c.compatibility === void 0 && S?.hasAttribute("data-formie-compatibility") && (b.compatibility =
|
|
2283
|
+
mode: Pn(c.mode ?? v.mode),
|
|
2284
|
+
transport: Fn(c.transport ?? v.transport)
|
|
2285
|
+
}, x = await ir(a, b), S = q(a);
|
|
2286
|
+
c.compatibility === void 0 && S?.hasAttribute("data-formie-compatibility") && (b.compatibility = K(S).compatibility);
|
|
2266
2287
|
let C = Te(b.compatibility);
|
|
2267
|
-
S && e(S, b), b.staticCache = c.staticCache ??
|
|
2288
|
+
S && e(S, b), b.staticCache = c.staticCache ?? Nn(S ? S.dataset : a.dataset);
|
|
2268
2289
|
let w;
|
|
2269
2290
|
try {
|
|
2270
2291
|
w = er(a, S), x?.modules && n(x.modules), w?.modules && n(w.modules);
|
|
@@ -2286,14 +2307,14 @@ function cr() {
|
|
|
2286
2307
|
surface: "server-rendered",
|
|
2287
2308
|
entries: []
|
|
2288
2309
|
};
|
|
2289
|
-
n(E),
|
|
2310
|
+
n(E), W.log("Resolved mount payload.", {
|
|
2290
2311
|
target: Q(a),
|
|
2291
2312
|
hasRenderPayload: !!x,
|
|
2292
2313
|
hasEmbeddedPayload: !!w,
|
|
2293
2314
|
moduleCount: E.entries.length
|
|
2294
2315
|
});
|
|
2295
|
-
let D = re(a, te, S), O = S ? new
|
|
2296
|
-
live:
|
|
2316
|
+
let D = re(a, te, S), O = S ? new vn(S, {
|
|
2317
|
+
live: Vn(S.dataset.formieValidationOnFocus),
|
|
2297
2318
|
errorAriaLive: Ne(S),
|
|
2298
2319
|
errorMessage: S.dataset.formieErrorMessage || "",
|
|
2299
2320
|
fieldContainerErrorClass: D.fieldLayoutError || [],
|
|
@@ -2311,8 +2332,8 @@ function cr() {
|
|
|
2311
2332
|
};
|
|
2312
2333
|
g(S, "formie:validator:ready", t), g(a, "formie:validator:ready", t);
|
|
2313
2334
|
}
|
|
2314
|
-
S && (y(S), (x || b.endpoint || a.dataset.formieEndpoint) &&
|
|
2315
|
-
let k = await
|
|
2335
|
+
S && (y(S), (x || b.endpoint || a.dataset.formieEndpoint) && Bn(a, S, b), b.mode === "server-rendered" && Ke(S) && (Ge(S), qe(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);
|
|
2336
|
+
let k = await an(E, {
|
|
2316
2337
|
registry: r,
|
|
2317
2338
|
matchContext: {
|
|
2318
2339
|
root: a,
|
|
@@ -2329,14 +2350,14 @@ function cr() {
|
|
|
2329
2350
|
state: ne,
|
|
2330
2351
|
on: (e, t) => d.on(e, t),
|
|
2331
2352
|
emit: (e, t) => (g(a, e, t), d.emitSafe(e, t).then((t) => {
|
|
2332
|
-
t.failed.length > 0 &&
|
|
2353
|
+
t.failed.length > 0 && W.warn("Lifecycle listeners failed.", {
|
|
2333
2354
|
eventName: e,
|
|
2334
2355
|
failed: t.failed.length
|
|
2335
2356
|
});
|
|
2336
2357
|
}))
|
|
2337
2358
|
}
|
|
2338
2359
|
});
|
|
2339
|
-
|
|
2360
|
+
W.log("Module setup complete.", {
|
|
2340
2361
|
target: Q(a),
|
|
2341
2362
|
moduleInstances: k.instances.length
|
|
2342
2363
|
});
|
|
@@ -2344,7 +2365,7 @@ function cr() {
|
|
|
2344
2365
|
id: m,
|
|
2345
2366
|
root: a,
|
|
2346
2367
|
submit: async (e = "submit") => {
|
|
2347
|
-
if (
|
|
2368
|
+
if (W.log("Submit requested.", {
|
|
2348
2369
|
id: m,
|
|
2349
2370
|
target: Q(a),
|
|
2350
2371
|
action: e
|
|
@@ -2361,16 +2382,16 @@ function cr() {
|
|
|
2361
2382
|
message: "Submission already in progress.",
|
|
2362
2383
|
formErrors: []
|
|
2363
2384
|
};
|
|
2364
|
-
let n = S.querySelector(`[data-formie-action="${e}"]`), r = await
|
|
2385
|
+
let n = S.querySelector(`[data-formie-action="${e}"]`), r = await Gt({
|
|
2365
2386
|
id: m,
|
|
2366
2387
|
target: a,
|
|
2367
2388
|
form: S,
|
|
2368
2389
|
bus: d,
|
|
2369
2390
|
validator: O,
|
|
2370
|
-
validateOnSubmit:
|
|
2391
|
+
validateOnSubmit: X(S),
|
|
2371
2392
|
action: e,
|
|
2372
2393
|
submitter: n,
|
|
2373
|
-
waitForSubmitDelay:
|
|
2394
|
+
waitForSubmitDelay: Z,
|
|
2374
2395
|
onRefreshTokensAfterSubmit: async () => {
|
|
2375
2396
|
await ar(a, b, S);
|
|
2376
2397
|
},
|
|
@@ -2378,7 +2399,7 @@ function cr() {
|
|
|
2378
2399
|
g(a, "formie:submit:result", e);
|
|
2379
2400
|
}
|
|
2380
2401
|
});
|
|
2381
|
-
return
|
|
2402
|
+
return W.log("Submit completed.", {
|
|
2382
2403
|
id: m,
|
|
2383
2404
|
action: e,
|
|
2384
2405
|
ok: r.ok,
|
|
@@ -2408,7 +2429,7 @@ function cr() {
|
|
|
2408
2429
|
options: C,
|
|
2409
2430
|
unbinds: f
|
|
2410
2431
|
})), S) {
|
|
2411
|
-
or(a, S, b, d, O, f), O && (f.push(p(S, O, a)), f.push(
|
|
2432
|
+
or(a, S, b, d, O, f), O && (f.push(p(S, O, a)), f.push(Cn(S)));
|
|
2412
2433
|
try {
|
|
2413
2434
|
await sr(a, b, S);
|
|
2414
2435
|
} catch (e) {
|
|
@@ -2478,7 +2499,7 @@ function cr() {
|
|
|
2478
2499
|
id: m,
|
|
2479
2500
|
mode: b.mode,
|
|
2480
2501
|
instance: A
|
|
2481
|
-
}), S instanceof HTMLFormElement && ee(S),
|
|
2502
|
+
}), S instanceof HTMLFormElement && ee(S), W.log("Mount complete.", {
|
|
2482
2503
|
id: m,
|
|
2483
2504
|
target: Q(a),
|
|
2484
2505
|
mode: b.mode
|
|
@@ -2486,16 +2507,16 @@ function cr() {
|
|
|
2486
2507
|
}, l = (e, n) => {
|
|
2487
2508
|
if (!n.autoVisible || tr(e) || typeof IntersectionObserver > "u") return c(e, n);
|
|
2488
2509
|
if (t.has(e)) return Promise.resolve(t.get(e)?.instance || null);
|
|
2489
|
-
if (i.has(e)) return
|
|
2510
|
+
if (i.has(e)) return W.log("Mount deferred (already waiting visibility).", { target: Q(e) }), Promise.resolve(null);
|
|
2490
2511
|
let r = new IntersectionObserver((t) => {
|
|
2491
|
-
t.some((t) => t.target === e && t.isIntersecting) && (r.disconnect(), i.delete(e),
|
|
2512
|
+
t.some((t) => t.target === e && t.isIntersecting) && (r.disconnect(), i.delete(e), W.log("Visibility reached, proceeding mount.", { target: Q(e) }), c(e, {
|
|
2492
2513
|
...n,
|
|
2493
2514
|
autoVisible: !1
|
|
2494
2515
|
}));
|
|
2495
2516
|
}, { threshold: .01 });
|
|
2496
2517
|
return r.observe(e), i.set(e, () => {
|
|
2497
2518
|
r.disconnect();
|
|
2498
|
-
}),
|
|
2519
|
+
}), W.log("Mount deferred until visible.", { target: Q(e) }), Promise.resolve(null);
|
|
2499
2520
|
};
|
|
2500
2521
|
return {
|
|
2501
2522
|
mount: c,
|
|
@@ -2503,7 +2524,7 @@ function cr() {
|
|
|
2503
2524
|
update: async (e, n) => {
|
|
2504
2525
|
let r = t.get(e);
|
|
2505
2526
|
if (!r) return c(e, {
|
|
2506
|
-
...
|
|
2527
|
+
...K(e),
|
|
2507
2528
|
...n,
|
|
2508
2529
|
mode: n.mode || "server-rendered"
|
|
2509
2530
|
});
|
|
@@ -2519,23 +2540,23 @@ function cr() {
|
|
|
2519
2540
|
},
|
|
2520
2541
|
getInstance: (e) => t.get(e)?.instance || null,
|
|
2521
2542
|
refreshForCache: async (e) => {
|
|
2522
|
-
|
|
2543
|
+
In("refreshForCache", "Global `Formie.refreshForCache()` has been deprecated. Use built-in static-cache token refresh handling instead.");
|
|
2523
2544
|
let n = null;
|
|
2524
2545
|
if (n = typeof e == "string" ? document.getElementById(e) || document.querySelector(`[data-formie-form-id="${e}"]`) : e, !n) {
|
|
2525
|
-
|
|
2546
|
+
W.warn("refreshForCache target not found.", { targetOrId: e });
|
|
2526
2547
|
return;
|
|
2527
2548
|
}
|
|
2528
|
-
let r = t.get(n), i =
|
|
2549
|
+
let r = t.get(n), i = q(n), a = r?.options || K(n);
|
|
2529
2550
|
if (!i) {
|
|
2530
|
-
|
|
2551
|
+
W.warn("refreshForCache found no form element for target.", { target: Q(n) });
|
|
2531
2552
|
return;
|
|
2532
2553
|
}
|
|
2533
|
-
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s =
|
|
2554
|
+
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s = zn(a, n), c = i.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2534
2555
|
if (!o) {
|
|
2535
|
-
|
|
2556
|
+
W.warn("refreshForCache found no form handle for target.", { target: Q(n) });
|
|
2536
2557
|
return;
|
|
2537
2558
|
}
|
|
2538
|
-
let l = await
|
|
2559
|
+
let l = await Qe(s, o, c, a, i.querySelector("input[name=\"requestToken\"]")?.value, i.querySelector("input[name=\"siteId\"]")?.value || a.siteId);
|
|
2539
2560
|
l && (rr(i, l), g(n, "formie:refresh-tokens:after", l));
|
|
2540
2561
|
},
|
|
2541
2562
|
registerModule: (e, t) => r.register(e, t),
|
|
@@ -2544,16 +2565,16 @@ function cr() {
|
|
|
2544
2565
|
},
|
|
2545
2566
|
getRegisteredModules: () => r.getAll(),
|
|
2546
2567
|
scan: async (e) => {
|
|
2547
|
-
let t = e || document, n = Array.from(t.querySelectorAll(
|
|
2548
|
-
|
|
2568
|
+
let t = e || document, n = Array.from(t.querySelectorAll(U));
|
|
2569
|
+
W.log("Scan started.", {
|
|
2549
2570
|
scope: t === document ? "document" : t,
|
|
2550
2571
|
targetCount: n.length
|
|
2551
2572
|
});
|
|
2552
2573
|
let r = (await Promise.all(n.map((e) => {
|
|
2553
|
-
let t =
|
|
2574
|
+
let t = K(e);
|
|
2554
2575
|
return l(e, t);
|
|
2555
2576
|
}))).filter((e) => !!e);
|
|
2556
|
-
return
|
|
2577
|
+
return W.log("Scan finished.", {
|
|
2557
2578
|
mountedCount: r.length,
|
|
2558
2579
|
deferredCount: n.length - r.length
|
|
2559
2580
|
}), r;
|
|
@@ -2561,16 +2582,16 @@ function cr() {
|
|
|
2561
2582
|
observe: (e) => {
|
|
2562
2583
|
if (typeof MutationObserver > "u") return () => {};
|
|
2563
2584
|
let n = e || document;
|
|
2564
|
-
|
|
2585
|
+
W.log("Observer started.", { scope: n === document ? "document" : n });
|
|
2565
2586
|
let r = new MutationObserver((e) => {
|
|
2566
2587
|
e.forEach((e) => {
|
|
2567
2588
|
e.addedNodes.forEach((e) => {
|
|
2568
|
-
e instanceof Element && (e.matches(
|
|
2569
|
-
|
|
2589
|
+
e instanceof Element && (e.matches(U) && (W.log("Observer detected new root.", { target: Q(e) }), l(e, K(e))), e.querySelectorAll(U).forEach((e) => {
|
|
2590
|
+
W.log("Observer detected new nested root.", { target: Q(e) }), l(e, K(e));
|
|
2570
2591
|
}));
|
|
2571
2592
|
}), e.removedNodes.forEach((e) => {
|
|
2572
|
-
e instanceof Element && (t.has(e) && (
|
|
2573
|
-
t.has(e) && (
|
|
2593
|
+
e instanceof Element && (t.has(e) && (W.log("Observer detected removed root.", { target: Q(e) }), s(e)), e.querySelectorAll(U).forEach((e) => {
|
|
2594
|
+
t.has(e) && (W.log("Observer detected removed nested root.", { target: Q(e) }), s(e));
|
|
2574
2595
|
}));
|
|
2575
2596
|
});
|
|
2576
2597
|
});
|
|
@@ -2579,11 +2600,11 @@ function cr() {
|
|
|
2579
2600
|
childList: !0,
|
|
2580
2601
|
subtree: !0
|
|
2581
2602
|
}), () => {
|
|
2582
|
-
r.disconnect(),
|
|
2603
|
+
r.disconnect(), W.log("Observer stopped."), i.forEach((e, t) => {
|
|
2583
2604
|
nr(t, n) && (e(), i.delete(t));
|
|
2584
2605
|
});
|
|
2585
2606
|
let e = [];
|
|
2586
|
-
n instanceof Element && n.matches(
|
|
2607
|
+
n instanceof Element && n.matches(U) && e.push(n), n.querySelectorAll(U).forEach((t) => {
|
|
2587
2608
|
e.push(t);
|
|
2588
2609
|
}), e.forEach((e) => {
|
|
2589
2610
|
t.has(e) && s(e);
|
|
@@ -2600,7 +2621,7 @@ async function ur(e) {
|
|
|
2600
2621
|
contractVersion: 2,
|
|
2601
2622
|
surface: r,
|
|
2602
2623
|
entries: []
|
|
2603
|
-
}, a = e.registry ?? new
|
|
2624
|
+
}, a = e.registry ?? new R(), o = new Kt(), s = await an(i, {
|
|
2604
2625
|
registry: a,
|
|
2605
2626
|
setupContext: {
|
|
2606
2627
|
formId: n?.id || t.id || "formie-modules",
|
|
@@ -2814,7 +2835,7 @@ var xr = {
|
|
|
2814
2835
|
reason: "The adapter renders the structured date input contract."
|
|
2815
2836
|
}
|
|
2816
2837
|
};
|
|
2817
|
-
async function Sr(t, n, r =
|
|
2838
|
+
async function Sr(t, n, r = qt) {
|
|
2818
2839
|
for (let [e, t] of Object.entries(xr)) {
|
|
2819
2840
|
let n = `formie:${e}`;
|
|
2820
2841
|
r.get(n) || r.register({
|
|
@@ -2877,4 +2898,4 @@ async function Sr(t, n, r = Wt) {
|
|
|
2877
2898
|
};
|
|
2878
2899
|
}
|
|
2879
2900
|
//#endregion
|
|
2880
|
-
export { l as FORMIE_HTML_EVENT_NAMES,
|
|
2901
|
+
export { l as FORMIE_HTML_EVENT_NAMES, vn as FormieValidator, Ce as LEGACY_FORMIE_DOM_EVENT_BRIDGES, we as LEGACY_FORMIE_VALIDATOR_EVENT_BRIDGES, R as ModuleRegistry, Ae as bindLegacyDomEventCompatibility, Me as bindLegacyValidatorCompatibility, be as buildFieldValueRegistry, qt as clientRenderedModuleRegistry, O as createDebug, cr as createFormieClient, E as debugLog, D as debugWarn, Se as defineAddressModule, me as defineCaptchaModule, pe as definePassiveCaptchaModule, w as definePaymentModule, _e as fieldKeyToInputName, br as formie, c as getFieldModuleEventName, fe as getFormieTranslations, s as getGlobalModuleLifecycleEventName, i as getScopedModuleLifecycleEventName, ur as hydrateFormieModules, he as inputNameToFieldKey, ne as isFormieDebugEnabled, ue as mergeFormieTranslations, Sr 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 };
|