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