@verbb/formie-browser 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/chunks/_survey-presentations-RbSqcQph.js +4 -0
- package/dist/chunks/{address-state-BQ0xGV9n.js → address-state-BwE01m2_.js} +1 -1
- package/dist/chunks/{api-DztsCJ4r.js → api-BYe9YPko.js} +194 -153
- package/dist/chunks/{bpoint-2qDxlKD9.js → bpoint-C0VOftX9.js} +1 -1
- package/dist/chunks/{combobox-D-2b42wn.js → combobox-C0EuExSI.js} +1 -1
- package/dist/chunks/{eway-CImXrB4g.js → eway-CS6Y1Yvo.js} +1 -1
- package/dist/chunks/{file-upload-D49m8-DR.js → file-upload-rqfZNqlH.js} +1 -1
- package/dist/chunks/{go-cardless-Bz7HHtH0.js → go-cardless-BTPD668l.js} +1 -1
- package/dist/chunks/{mollie-BtnB3KGh.js → mollie-CXgBwvo6.js} +1 -1
- package/dist/chunks/{moneris-Bd4vUk8b.js → moneris-B6oLu7nj.js} +1 -1
- package/dist/chunks/{opayo-B-eRIXo-.js → opayo-DPUA5CKr.js} +1 -1
- package/dist/chunks/{paddle-BUFeEU4d.js → paddle-GRlsm5mm.js} +1 -1
- package/dist/chunks/{paypal-8Euw7Hrn.js → paypal-CdcZnf6r.js} +2 -2
- package/dist/chunks/{payway-dV0SzJxy.js → payway-CfmYOS__.js} +2 -2
- package/dist/chunks/{repeater-B5leVxZU.js → repeater-BVnPUqTj.js} +1 -1
- package/dist/chunks/rich-text-Bg_--4TG.js +349 -0
- package/dist/chunks/{square-reyJukb7.js → square-BY--5M-X.js} +1 -1
- package/dist/chunks/{stripe-BC-2PBvY.js → stripe-uusYjWty.js} +2 -2
- package/dist/chunks/{summary-D3AjxpYN.js → summary-Dks0gXS3.js} +42 -38
- package/dist/chunks/survey-likert-DkE6bR7B.js +20 -0
- package/dist/chunks/survey-rank-DN6x4IZM.js +127 -0
- package/dist/chunks/survey-rating-BnsNL9U5.js +88 -0
- package/dist/chunks/{table-C-lkQN6I.js → table-CAjCJHrL.js} +1 -1
- package/dist/chunks/{upload-manager-BpqWSHmU.js → upload-manager-W-QDgxKD.js} +1 -1
- package/dist/css/formie-theme.css +1 -0
- package/dist/css/theme/_tokens.css +10 -5
- package/dist/css/theme/fields/_check-radio.css +1 -1
- package/dist/css/theme/fields/_combobox.css +1 -1
- package/dist/css/theme/fields/_file.css +3 -3
- package/dist/css/theme/fields/_input.css +1 -1
- package/dist/css/theme/fields/_repeater.css +1 -1
- package/dist/css/theme/fields/_rich-text.css +1 -1
- package/dist/css/theme/fields/_select.css +1 -1
- package/dist/css/theme/fields/_survey-presentations.css +396 -0
- package/dist/css/theme/fields/_table.css +1 -1
- package/dist/css/theme/fields/_upload-manager.css +3 -3
- package/dist/css/theme/integrations/_paypal.css +1 -1
- package/dist/css/theme/integrations/_payway.css +1 -1
- package/dist/css/theme/integrations/_stripe.css +1 -1
- package/dist/index.js +398 -376
- package/dist/js/contracts/schema.d.ts +5 -0
- package/dist/js/contracts/schema.d.ts.map +1 -1
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/page-client-event.d.ts +8 -4
- package/dist/js/core/page-client-event.d.ts.map +1 -1
- package/dist/js/core/submit-flow.d.ts.map +1 -1
- package/dist/js/core/submit-result-state.d.ts.map +1 -1
- package/dist/js/core/submit-result-ui.d.ts +1 -0
- package/dist/js/core/submit-result-ui.d.ts.map +1 -1
- package/dist/js/modules/fields/index.d.ts.map +1 -1
- package/dist/js/modules/fields/summary.d.ts.map +1 -1
- package/dist/js/modules/fields/survey-likert.d.ts +3 -0
- package/dist/js/modules/fields/survey-likert.d.ts.map +1 -0
- package/dist/js/modules/fields/survey-rank.d.ts +3 -0
- package/dist/js/modules/fields/survey-rank.d.ts.map +1 -0
- package/dist/js/modules/fields/survey-rating.d.ts +3 -0
- package/dist/js/modules/fields/survey-rating.d.ts.map +1 -0
- package/dist/js/transport/forms-api.d.ts.map +1 -1
- package/dist/js/utils/fields.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/css/formie-theme.css +1 -0
- package/src/css/theme/_tokens.css +10 -5
- package/src/css/theme/fields/_check-radio.css +1 -1
- package/src/css/theme/fields/_combobox.css +1 -1
- package/src/css/theme/fields/_file.css +3 -3
- package/src/css/theme/fields/_input.css +1 -1
- package/src/css/theme/fields/_repeater.css +1 -1
- package/src/css/theme/fields/_rich-text.css +1 -1
- package/src/css/theme/fields/_select.css +1 -1
- package/src/css/theme/fields/_survey-presentations.css +396 -0
- package/src/css/theme/fields/_table.css +1 -1
- package/src/css/theme/fields/_upload-manager.css +3 -3
- package/src/css/theme/integrations/_paypal.css +1 -1
- package/src/css/theme/integrations/_payway.css +1 -1
- package/src/css/theme/integrations/_stripe.css +1 -1
- package/src/js/contracts/schema.ts +6 -0
- package/src/js/core/create-formie-client.ts +14 -1
- package/src/js/core/page-client-event.ts +86 -18
- package/src/js/core/submit-flow.ts +3 -1
- package/src/js/core/submit-result-state.ts +18 -2
- package/src/js/core/submit-result-ui.ts +47 -9
- package/src/js/modules/fields/index.ts +3 -0
- package/src/js/modules/fields/summary.ts +17 -3
- package/src/js/modules/fields/survey-likert.ts +50 -0
- package/src/js/modules/fields/survey-rank.ts +385 -0
- package/src/js/modules/fields/survey-rating.ts +182 -0
- package/src/js/transport/forms-api.ts +1 -0
- package/src/js/utils/fields.ts +14 -2
- package/dist/chunks/rich-text-D0sb8bmX.js +0 -349
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { c as e, d as t, l as n, o as r, r as i, t as a, u as o } from "./chunks/event-names-BCI2FLD8.js";
|
|
2
|
-
import { a as s, c, d as l, f as u, i as d, l as f, n as p, o as m,
|
|
3
|
-
import { a as
|
|
4
|
-
import { n as
|
|
2
|
+
import { a as s, c, d as l, f as u, i as d, l as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y } from "./chunks/api-BYe9YPko.js";
|
|
3
|
+
import { a as b, i as x, n as ee, r as te, t as S } from "./chunks/debug-BV0DvdHx.js";
|
|
4
|
+
import { n as ne, r as C, t as w } from "./chunks/theme-classes-Tv7q7ToE.js";
|
|
5
5
|
import { t as T } from "./chunks/http-D-JExro7.js";
|
|
6
|
-
import { a as E, i as D, n as
|
|
7
|
-
import { n as
|
|
8
|
-
import { n as
|
|
9
|
-
import { i as
|
|
10
|
-
import { t as
|
|
6
|
+
import { a as E, i as D, n as re, r as ie, t as ae } from "./chunks/i18n-BY1ds1BL.js";
|
|
7
|
+
import { n as oe, t as se } from "./chunks/api-BUb6P-xu.js";
|
|
8
|
+
import { n as ce, r as le, t as ue } from "./chunks/field-references.keys-58ZSTrCW.js";
|
|
9
|
+
import { i as de, n as fe, r as pe, t as me } from "./chunks/field-references.resolver-CHwn0G0L.js";
|
|
10
|
+
import { t as he } from "./chunks/api-sPqGbOww.js";
|
|
11
11
|
//#region src/js/compatibility/event-map.ts
|
|
12
|
-
var
|
|
12
|
+
var ge = [
|
|
13
13
|
{
|
|
14
14
|
legacyEvent: "onFormieLoaded",
|
|
15
15
|
canonicalEvent: "formie:mount:after",
|
|
@@ -62,7 +62,7 @@ var he = [
|
|
|
62
62
|
canonicalEvent: "formie:submit:after",
|
|
63
63
|
disposition: "approximate"
|
|
64
64
|
}
|
|
65
|
-
],
|
|
65
|
+
], _e = [
|
|
66
66
|
{
|
|
67
67
|
legacyEvent: "formieValidatorInitialized",
|
|
68
68
|
canonicalEvent: "formie:validator:ready",
|
|
@@ -84,7 +84,7 @@ var he = [
|
|
|
84
84
|
disposition: "safe"
|
|
85
85
|
}
|
|
86
86
|
];
|
|
87
|
-
function
|
|
87
|
+
function ve(e) {
|
|
88
88
|
if (!e) return {
|
|
89
89
|
enabled: !1,
|
|
90
90
|
legacyDomEvents: !1,
|
|
@@ -104,18 +104,18 @@ function _e(e) {
|
|
|
104
104
|
}
|
|
105
105
|
//#endregion
|
|
106
106
|
//#region src/js/compatibility/dom-adapter.ts
|
|
107
|
-
function
|
|
107
|
+
function ye(e, t, n) {
|
|
108
108
|
e.dispatchEvent(new CustomEvent(t, {
|
|
109
109
|
bubbles: !0,
|
|
110
110
|
detail: n
|
|
111
111
|
}));
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function be(e, t) {
|
|
114
114
|
if (e.canonicalEvent !== "formie:submit:result") return !0;
|
|
115
115
|
let n = t;
|
|
116
116
|
return e.legacyEvent === "onAfterFormieSubmit" ? !!n?.ok : e.legacyEvent === "onFormieSubmitError" ? n?.ok === !1 : !0;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function xe(e, t) {
|
|
119
119
|
let n = t && typeof t == "object" ? t : {}, r = typeof n.pageId == "string" ? n.pageId : "", i = Array.from(e.querySelectorAll("[data-formie-page-id]"));
|
|
120
120
|
return { data: {
|
|
121
121
|
nextPageId: r,
|
|
@@ -123,7 +123,7 @@ function be(e, t) {
|
|
|
123
123
|
totalPages: i.length
|
|
124
124
|
} };
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function Se(e, t, n, r, i) {
|
|
127
127
|
let a = globalThis.Formie || i;
|
|
128
128
|
return e.legacyEvent === "onFormieLoaded" ? { formie: a } : e.legacyEvent === "onFormieInit" ? {
|
|
129
129
|
formie: a,
|
|
@@ -135,12 +135,12 @@ function xe(e, t, n, r, i) {
|
|
|
135
135
|
form: r,
|
|
136
136
|
target: n,
|
|
137
137
|
instance: i
|
|
138
|
-
} : e.legacyEvent === "onFormiePageToggle" ?
|
|
138
|
+
} : e.legacyEvent === "onFormiePageToggle" ? xe(r, t) : t;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
i.legacyDomEvents &&
|
|
140
|
+
function Ce({ target: e, form: n, instance: r, options: i, unbinds: a }) {
|
|
141
|
+
i.legacyDomEvents && ge.forEach((i) => {
|
|
142
142
|
let o = (t) => {
|
|
143
|
-
!(t instanceof CustomEvent) || !
|
|
143
|
+
!(t instanceof CustomEvent) || !be(i, t.detail) || ye(i.target === "document" ? document : n, i.legacyEvent, Se(i, t.detail, e, n, r));
|
|
144
144
|
};
|
|
145
145
|
e.addEventListener(t(i.canonicalEvent), o), a.push(() => {
|
|
146
146
|
e.removeEventListener(t(i.canonicalEvent), o);
|
|
@@ -158,7 +158,7 @@ function O(e, t, n) {
|
|
|
158
158
|
function k(e, t) {
|
|
159
159
|
return !!e && typeof e == "object" && e.validator === t;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function we({ target: e, form: t, validatorDetail: n, options: r, unbinds: i }) {
|
|
162
162
|
if (!r.legacyValidatorEvents || !n) return;
|
|
163
163
|
let { validator: a, addValidator: o, removeValidator: s } = n, c = {
|
|
164
164
|
...n,
|
|
@@ -194,17 +194,17 @@ function Ce({ target: e, form: t, validatorDetail: n, options: r, unbinds: i })
|
|
|
194
194
|
}
|
|
195
195
|
//#endregion
|
|
196
196
|
//#region src/js/core/error-aria-live.ts
|
|
197
|
-
function
|
|
197
|
+
function Te(e) {
|
|
198
198
|
let t = (e.dataset.formieErrorAriaLive || "polite").trim().toLowerCase();
|
|
199
199
|
return t === "assertive" || t === "off" ? t : "polite";
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function Ee(e, t) {
|
|
202
202
|
return e === "off" ? null : t ? e : "polite";
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function De(e) {
|
|
205
205
|
return e === "off" ? null : e;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function Oe(e, t) {
|
|
208
208
|
if (t) {
|
|
209
209
|
e.setAttribute("aria-live", t), e.setAttribute("aria-atomic", "true");
|
|
210
210
|
return;
|
|
@@ -213,20 +213,20 @@ function De(e, t) {
|
|
|
213
213
|
}
|
|
214
214
|
//#endregion
|
|
215
215
|
//#region src/js/core/validation-focus.ts
|
|
216
|
-
function
|
|
216
|
+
function ke(e, t) {
|
|
217
217
|
let n = (e.getAttribute("aria-describedby") || "").trim(), r = n ? n.split(/\s+/) : [];
|
|
218
218
|
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function Ae(e) {
|
|
221
221
|
return Array.from(e.querySelectorAll("[data-formie-field-handle]")).find((e) => e.getAttribute("data-formie-field-has-error") === "true" ? !0 : e.querySelector("[data-formie-field-error]") !== null) || null;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function je(e) {
|
|
224
224
|
return e.querySelector("[aria-invalid=\"true\"]") || e.querySelector("input:not([type=\"hidden\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])");
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function Me(e) {
|
|
227
227
|
return e.querySelector("[data-formie-message-error], [data-formie-error-container], [data-formie-errors]");
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function Ne(e) {
|
|
230
230
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
231
231
|
let n = t;
|
|
232
232
|
if (!(n.getAttribute("data-formie-field-has-error") === "true" || n.querySelector("[data-formie-field-error]") !== null)) return;
|
|
@@ -234,17 +234,17 @@ function Me(e) {
|
|
|
234
234
|
let r = n.querySelector("[data-formie-field-errors]")?.id || "", i = n.querySelector("[data-formie-field-error]")?.id || "";
|
|
235
235
|
n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
236
236
|
let n = t;
|
|
237
|
-
n.setAttribute("aria-invalid", "true"), w(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), r &&
|
|
237
|
+
n.setAttribute("aria-invalid", "true"), w(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), r && ke(n, r), i && n.setAttribute("aria-errormessage", i);
|
|
238
238
|
});
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
|
-
function Ne(e) {
|
|
242
|
-
return !!ke(e) || !!je(e);
|
|
243
|
-
}
|
|
244
241
|
function Pe(e) {
|
|
245
|
-
|
|
242
|
+
return !!Ae(e) || !!Me(e);
|
|
243
|
+
}
|
|
244
|
+
function Fe(e) {
|
|
245
|
+
let t = Ae(e);
|
|
246
246
|
if (t) {
|
|
247
|
-
let e =
|
|
247
|
+
let e = je(t);
|
|
248
248
|
if (e) {
|
|
249
249
|
if (e.scrollIntoView({
|
|
250
250
|
behavior: "smooth",
|
|
@@ -261,7 +261,7 @@ function Pe(e) {
|
|
|
261
261
|
block: "center"
|
|
262
262
|
}), !0;
|
|
263
263
|
}
|
|
264
|
-
let n =
|
|
264
|
+
let n = Me(e);
|
|
265
265
|
return n ? (n.scrollIntoView({
|
|
266
266
|
behavior: "smooth",
|
|
267
267
|
block: "center"
|
|
@@ -269,7 +269,7 @@ function Pe(e) {
|
|
|
269
269
|
}
|
|
270
270
|
//#endregion
|
|
271
271
|
//#region src/js/events/event-bus.ts
|
|
272
|
-
var
|
|
272
|
+
var Ie = class {
|
|
273
273
|
constructor() {
|
|
274
274
|
this.listeners = /* @__PURE__ */ new Map();
|
|
275
275
|
}
|
|
@@ -326,7 +326,7 @@ var Fe = class {
|
|
|
326
326
|
this.listeners.clear();
|
|
327
327
|
}
|
|
328
328
|
}, A = S("general", "transport");
|
|
329
|
-
function
|
|
329
|
+
function Le(e) {
|
|
330
330
|
let t = {};
|
|
331
331
|
return [
|
|
332
332
|
"theme",
|
|
@@ -337,17 +337,17 @@ function Ie(e) {
|
|
|
337
337
|
e[n] !== void 0 && (t[n] = e[n]);
|
|
338
338
|
}), t;
|
|
339
339
|
}
|
|
340
|
-
function
|
|
340
|
+
function Re(e, t = "", n = {}) {
|
|
341
341
|
if (Array.isArray(e)) {
|
|
342
342
|
let r = e.map((e) => typeof e == "string" ? e : String(e ?? "")).filter((e) => e.trim() !== "");
|
|
343
343
|
return t && r.length && (n[t] = (n[t] || []).concat(r)), n;
|
|
344
344
|
}
|
|
345
345
|
return e && typeof e == "object" && Object.entries(e).forEach(([e, r]) => {
|
|
346
|
-
|
|
346
|
+
Re(r, t ? `${t}.${e}` : e, n);
|
|
347
347
|
}), n;
|
|
348
348
|
}
|
|
349
|
-
function
|
|
350
|
-
let n = e.success === !0, r = e.keepSubmitLoading === !0, i = e.errors, a =
|
|
349
|
+
function ze(e, t) {
|
|
350
|
+
let n = e.success === !0, r = e.keepSubmitLoading === !0, i = e.errors, a = Re(i || {}), o = a.form || [], s = {};
|
|
351
351
|
Object.entries(a).forEach(([e, t]) => {
|
|
352
352
|
if (e === "form") return;
|
|
353
353
|
let n = e.split(".")[0];
|
|
@@ -368,10 +368,11 @@ function Re(e, t) {
|
|
|
368
368
|
target: e.submitActionTab === "new-tab" ? "new-tab" : "same-tab"
|
|
369
369
|
} : null,
|
|
370
370
|
submitData: Array.isArray(e.submitData) ? e.submitData : void 0,
|
|
371
|
+
clientEvents: Array.isArray(e.clientEvents) ? e.clientEvents : void 0,
|
|
371
372
|
meta: e
|
|
372
373
|
};
|
|
373
374
|
}
|
|
374
|
-
async function
|
|
375
|
+
async function Be(e, t, n = {}) {
|
|
375
376
|
let r = JSON.stringify({
|
|
376
377
|
handle: t,
|
|
377
378
|
renderOptions: n
|
|
@@ -387,12 +388,12 @@ async function ze(e, t, n = {}) {
|
|
|
387
388
|
});
|
|
388
389
|
return A.log("requestRender complete.", { hasHtml: !!i.html }), i;
|
|
389
390
|
}
|
|
390
|
-
async function
|
|
391
|
+
async function Ve(e, t, n = {}) {
|
|
391
392
|
let r = JSON.stringify({
|
|
392
393
|
query: "\nquery FormieHtmlForm($handle: String!, $input: ServerRenderPayloadInput) {\n formieHtmlForm(handle: $handle, input: $input) {\n html\n }\n}",
|
|
393
394
|
variables: {
|
|
394
395
|
handle: t,
|
|
395
|
-
input:
|
|
396
|
+
input: Le(n)
|
|
396
397
|
}
|
|
397
398
|
});
|
|
398
399
|
A.log("requestGraphqlRender start.", {
|
|
@@ -409,7 +410,7 @@ async function Be(e, t, n = {}) {
|
|
|
409
410
|
let a = i.data.formieHtmlForm;
|
|
410
411
|
return A.log("requestGraphqlRender complete.", { hasHtml: !!a.html }), a;
|
|
411
412
|
}
|
|
412
|
-
async function
|
|
413
|
+
async function j(e, t, n) {
|
|
413
414
|
let r = new URL(e, window.location.origin);
|
|
414
415
|
r.searchParams.set("handle", t), n && r.searchParams.set("renderId", n), A.log("requestRefreshTokens start.", {
|
|
415
416
|
endpoint: r.toString(),
|
|
@@ -497,7 +498,7 @@ async function We(e, t) {
|
|
|
497
498
|
message: `Request failed (${a.status}).`,
|
|
498
499
|
formErrors: [`Request failed (${a.status}).`]
|
|
499
500
|
});
|
|
500
|
-
let s =
|
|
501
|
+
let s = ze(await a.json(), i);
|
|
501
502
|
return A.log("submitForm JSON response normalized.", {
|
|
502
503
|
ok: s.ok,
|
|
503
504
|
code: s.code,
|
|
@@ -521,7 +522,7 @@ var Ge = [
|
|
|
521
522
|
"validate",
|
|
522
523
|
"screen",
|
|
523
524
|
"authorize"
|
|
524
|
-
],
|
|
525
|
+
], M = S("general", "pipeline");
|
|
525
526
|
function qe(e, t) {
|
|
526
527
|
return {
|
|
527
528
|
ok: !1,
|
|
@@ -589,7 +590,7 @@ function tt(e, t) {
|
|
|
589
590
|
return n.length ? (n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || n[n.length - 1]) === n[n.length - 1] : !0;
|
|
590
591
|
}
|
|
591
592
|
async function nt(e, t, n, r = {}) {
|
|
592
|
-
|
|
593
|
+
M.log("Starting submit pipeline.", {
|
|
593
594
|
action: t,
|
|
594
595
|
preflightOnly: r.preflightOnly === !0
|
|
595
596
|
});
|
|
@@ -598,7 +599,7 @@ async function nt(e, t, n, r = {}) {
|
|
|
598
599
|
action: t,
|
|
599
600
|
formData: et(e, t),
|
|
600
601
|
abort: (e) => {
|
|
601
|
-
i = !0, a = e,
|
|
602
|
+
i = !0, a = e, M.warn("Pipeline aborted.", { reason: e });
|
|
602
603
|
},
|
|
603
604
|
isAborted: () => i,
|
|
604
605
|
abortReason: () => a
|
|
@@ -655,24 +656,24 @@ async function nt(e, t, n, r = {}) {
|
|
|
655
656
|
};
|
|
656
657
|
{
|
|
657
658
|
let e = await n.emitSafe("formie:submit:before", c);
|
|
658
|
-
e.failed.length > 0 &&
|
|
659
|
+
e.failed.length > 0 && M.warn("Submit before listeners failed.", {
|
|
659
660
|
eventName: e.eventName,
|
|
660
661
|
failed: e.failed.length
|
|
661
662
|
});
|
|
662
663
|
}
|
|
663
664
|
if (s) {
|
|
664
665
|
let e = await n.emitSafe("formie:submit:final:before", c);
|
|
665
|
-
e.failed.length > 0 &&
|
|
666
|
+
e.failed.length > 0 && M.warn("Final submit before listeners failed.", {
|
|
666
667
|
eventName: e.eventName,
|
|
667
668
|
failed: e.failed.length
|
|
668
669
|
});
|
|
669
670
|
}
|
|
670
671
|
let u = r.preflightOnly ? Ke : Ge;
|
|
671
672
|
for (let e of u) {
|
|
672
|
-
if (
|
|
673
|
+
if (M.log("Stage start.", {
|
|
673
674
|
stage: e,
|
|
674
675
|
action: t
|
|
675
|
-
}), i) return
|
|
676
|
+
}), i) return M.warn("Stage skipped due to abort.", {
|
|
676
677
|
stage: e,
|
|
677
678
|
reason: a
|
|
678
679
|
}), qe(e, a);
|
|
@@ -681,7 +682,7 @@ async function nt(e, t, n, r = {}) {
|
|
|
681
682
|
...c,
|
|
682
683
|
stage: e
|
|
683
684
|
});
|
|
684
|
-
t.failed.length > 0 &&
|
|
685
|
+
t.failed.length > 0 && M.warn("Stage before listeners failed.", {
|
|
685
686
|
stage: e,
|
|
686
687
|
failed: t.failed.length
|
|
687
688
|
});
|
|
@@ -690,25 +691,25 @@ async function nt(e, t, n, r = {}) {
|
|
|
690
691
|
let t = qe(e, a);
|
|
691
692
|
{
|
|
692
693
|
let r = await n.emitSafe("formie:submit:after", t);
|
|
693
|
-
r.failed.length > 0 &&
|
|
694
|
+
r.failed.length > 0 && M.warn("Submit after listeners failed (abort before stage).", {
|
|
694
695
|
stage: e,
|
|
695
696
|
failed: r.failed.length
|
|
696
697
|
});
|
|
697
698
|
}
|
|
698
699
|
if (s) {
|
|
699
700
|
let r = await n.emitSafe("formie:submit:final:after", t);
|
|
700
|
-
r.failed.length > 0 &&
|
|
701
|
+
r.failed.length > 0 && M.warn("Final submit after listeners failed (abort before stage).", {
|
|
701
702
|
stage: e,
|
|
702
703
|
failed: r.failed.length
|
|
703
704
|
});
|
|
704
705
|
}
|
|
705
|
-
return
|
|
706
|
+
return M.warn("Aborted after stage before-hooks.", {
|
|
706
707
|
stage: e,
|
|
707
708
|
reason: a
|
|
708
709
|
}), t;
|
|
709
710
|
}
|
|
710
711
|
let r = await l[e](c);
|
|
711
|
-
|
|
712
|
+
M.log("Stage runner complete.", {
|
|
712
713
|
stage: e,
|
|
713
714
|
hasResult: !!r,
|
|
714
715
|
ok: r ? r.ok : void 0,
|
|
@@ -720,7 +721,7 @@ async function nt(e, t, n, r = {}) {
|
|
|
720
721
|
stage: e,
|
|
721
722
|
result: r
|
|
722
723
|
});
|
|
723
|
-
t.failed.length > 0 &&
|
|
724
|
+
t.failed.length > 0 && M.warn("Stage after listeners failed.", {
|
|
724
725
|
stage: e,
|
|
725
726
|
failed: t.failed.length
|
|
726
727
|
});
|
|
@@ -729,19 +730,19 @@ async function nt(e, t, n, r = {}) {
|
|
|
729
730
|
let t = qe(e, a);
|
|
730
731
|
{
|
|
731
732
|
let r = await n.emitSafe("formie:submit:after", t);
|
|
732
|
-
r.failed.length > 0 &&
|
|
733
|
+
r.failed.length > 0 && M.warn("Submit after listeners failed (abort after stage).", {
|
|
733
734
|
stage: e,
|
|
734
735
|
failed: r.failed.length
|
|
735
736
|
});
|
|
736
737
|
}
|
|
737
738
|
if (s) {
|
|
738
739
|
let r = await n.emitSafe("formie:submit:final:after", t);
|
|
739
|
-
r.failed.length > 0 &&
|
|
740
|
+
r.failed.length > 0 && M.warn("Final submit after listeners failed (abort after stage).", {
|
|
740
741
|
stage: e,
|
|
741
742
|
failed: r.failed.length
|
|
742
743
|
});
|
|
743
744
|
}
|
|
744
|
-
return
|
|
745
|
+
return M.warn("Aborted after stage after-hooks.", {
|
|
745
746
|
stage: e,
|
|
746
747
|
reason: a
|
|
747
748
|
}), t;
|
|
@@ -749,19 +750,19 @@ async function nt(e, t, n, r = {}) {
|
|
|
749
750
|
if (r && !r.ok) {
|
|
750
751
|
{
|
|
751
752
|
let t = await n.emitSafe("formie:submit:after", r);
|
|
752
|
-
t.failed.length > 0 &&
|
|
753
|
+
t.failed.length > 0 && M.warn("Submit after listeners failed (failed stage).", {
|
|
753
754
|
stage: e,
|
|
754
755
|
failed: t.failed.length
|
|
755
756
|
});
|
|
756
757
|
}
|
|
757
758
|
if (s) {
|
|
758
759
|
let t = await n.emitSafe("formie:submit:final:after", r);
|
|
759
|
-
t.failed.length > 0 &&
|
|
760
|
+
t.failed.length > 0 && M.warn("Final submit after listeners failed (failed stage).", {
|
|
760
761
|
stage: e,
|
|
761
762
|
failed: t.failed.length
|
|
762
763
|
});
|
|
763
764
|
}
|
|
764
|
-
return
|
|
765
|
+
return M.warn("Pipeline short-circuited by failed stage.", {
|
|
765
766
|
stage: e,
|
|
766
767
|
code: r.code,
|
|
767
768
|
message: r.message
|
|
@@ -775,13 +776,13 @@ async function nt(e, t, n, r = {}) {
|
|
|
775
776
|
};
|
|
776
777
|
{
|
|
777
778
|
let e = await n.emitSafe("formie:submit:after", d);
|
|
778
|
-
e.failed.length > 0 &&
|
|
779
|
+
e.failed.length > 0 && M.warn("Submit after listeners failed (success).", { failed: e.failed.length });
|
|
779
780
|
}
|
|
780
781
|
if (s) {
|
|
781
782
|
let e = await n.emitSafe("formie:submit:final:after", d);
|
|
782
|
-
e.failed.length > 0 &&
|
|
783
|
+
e.failed.length > 0 && M.warn("Final submit after listeners failed (success).", { failed: e.failed.length });
|
|
783
784
|
}
|
|
784
|
-
return
|
|
785
|
+
return M.log("Pipeline completed.", {
|
|
785
786
|
ok: d.ok,
|
|
786
787
|
stage: d.stage,
|
|
787
788
|
code: d.code
|
|
@@ -891,8 +892,8 @@ var ct = {
|
|
|
891
892
|
date: /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))/,
|
|
892
893
|
time: /^(?:(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]))$/,
|
|
893
894
|
month: /^(?:(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])))$/
|
|
894
|
-
},
|
|
895
|
-
function
|
|
895
|
+
}, N = S("general", "validator");
|
|
896
|
+
function P(e) {
|
|
896
897
|
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement);
|
|
897
898
|
}
|
|
898
899
|
function ut(e, t) {
|
|
@@ -933,7 +934,7 @@ var mt = class {
|
|
|
933
934
|
}), this.init();
|
|
934
935
|
}
|
|
935
936
|
init() {
|
|
936
|
-
|
|
937
|
+
N.log("Initializing validator.", {
|
|
937
938
|
formId: this.form.id || null,
|
|
938
939
|
live: this.config.live
|
|
939
940
|
}), this.form.setAttribute("novalidate", "true"), this.inputs().forEach((e) => {
|
|
@@ -941,9 +942,9 @@ var mt = class {
|
|
|
941
942
|
}), this.config.live && this.addEventListeners(), this.emitEvent(document, n("ready"), { validator: this });
|
|
942
943
|
}
|
|
943
944
|
inputs(e = null) {
|
|
944
|
-
if (
|
|
945
|
+
if (P(e)) return [e];
|
|
945
946
|
let t = e || this.form;
|
|
946
|
-
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) =>
|
|
947
|
+
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) => P(e));
|
|
947
948
|
}
|
|
948
949
|
getInputValue(e) {
|
|
949
950
|
return e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ? e.checked : e instanceof HTMLInputElement && e.type === "file" ? e.files?.length ? Array.from(e.files).map((e) => e.name).join("|") : "" : e.value ?? "";
|
|
@@ -983,7 +984,7 @@ var mt = class {
|
|
|
983
984
|
}), r = !0;
|
|
984
985
|
}
|
|
985
986
|
}), !r && this.shouldShowError(e) && this.removeError(e);
|
|
986
|
-
}),
|
|
987
|
+
}), N.log("Validation pass complete.", {
|
|
987
988
|
errorCount: this.errors.length,
|
|
988
989
|
includeHiddenPages: t.includeHiddenPages === !0
|
|
989
990
|
}), this.errors;
|
|
@@ -1010,7 +1011,7 @@ var mt = class {
|
|
|
1010
1011
|
});
|
|
1011
1012
|
});
|
|
1012
1013
|
for (let e = t; e; e = e.parentElement?.closest("[data-formie-field-handle]")) this.config.fieldContainerErrorClass.length && e.classList.remove(...this.config.fieldContainerErrorClass), e.removeAttribute("data-formie-field-has-error");
|
|
1013
|
-
this.emitEvent(e, n("clear-error"), { validator: this }),
|
|
1014
|
+
this.emitEvent(e, n("clear-error"), { validator: this }), y(this.form);
|
|
1014
1015
|
}
|
|
1015
1016
|
showError(e, t, r) {
|
|
1016
1017
|
let i = e.closest("[data-formie-field-handle]");
|
|
@@ -1020,7 +1021,7 @@ var mt = class {
|
|
|
1020
1021
|
this.config.messagesClass.length && e.classList.add(...this.config.messagesClass);
|
|
1021
1022
|
}), this.config.messagesClass.length && a.classList.add(...this.config.messagesClass), a.innerHTML = "";
|
|
1022
1023
|
let o = i.getAttribute("data-formie-field-handle") || "field", s = `${o}-error`;
|
|
1023
|
-
a.id = a.id || `${o}-errors`,
|
|
1024
|
+
a.id = a.id || `${o}-errors`, Oe(a, Ee(this.config.errorAriaLive, this.submitted));
|
|
1024
1025
|
let c = document.createElement("div");
|
|
1025
1026
|
c.setAttribute("data-formie-field-error", "true"), c.setAttribute(`data-formie-field-error-${t}`, "true"), c.setAttribute("id", s), c.setAttribute("role", "alert"), this.config.messageClass.length && c.classList.add(...this.config.messageClass), c.textContent = r, a.appendChild(c), i.setAttribute("data-formie-field-has-error", "true"), i.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
1026
1027
|
let t = e;
|
|
@@ -1031,7 +1032,7 @@ var mt = class {
|
|
|
1031
1032
|
validator: this,
|
|
1032
1033
|
validatorName: t,
|
|
1033
1034
|
errorMessage: r
|
|
1034
|
-
}),
|
|
1035
|
+
}), y(this.form);
|
|
1035
1036
|
}
|
|
1036
1037
|
getValidatorCallbackOptions(e) {
|
|
1037
1038
|
let t = e.closest("[data-formie-field-handle]"), n = t?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() ?? "", r = this.parseValidationRules(t?.getAttribute("data-formie-validation"));
|
|
@@ -1070,7 +1071,7 @@ var mt = class {
|
|
|
1070
1071
|
try {
|
|
1071
1072
|
n = JSON.parse(e);
|
|
1072
1073
|
} catch {
|
|
1073
|
-
return
|
|
1074
|
+
return N.warn("Invalid validation rules payload.", { formId: this.form.id || null }), t;
|
|
1074
1075
|
}
|
|
1075
1076
|
return Array.isArray(n) && n.forEach((e) => {
|
|
1076
1077
|
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
@@ -1079,16 +1080,16 @@ var mt = class {
|
|
|
1079
1080
|
}), t;
|
|
1080
1081
|
}
|
|
1081
1082
|
destroy() {
|
|
1082
|
-
|
|
1083
|
+
N.log("Destroying validator.", { formId: this.form.id || null }), this.removeEventListeners(), this.form.removeAttribute("novalidate"), this.emitEvent(document, n("destroy"), { validator: this });
|
|
1083
1084
|
}
|
|
1084
1085
|
isVisible(e, t = {}) {
|
|
1085
1086
|
return e.disabled || e.hasAttribute("data-formie-conditions-disabled") || e.closest("[data-formie-conditions-disabled]") || e.closest("[data-formie-conditionally-hidden]") ? !1 : e.closest("[data-formie-page-hidden]") ? !!t.includeHiddenPages : !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
1086
1087
|
}
|
|
1087
1088
|
blurHandler(e) {
|
|
1088
|
-
!(e.target instanceof HTMLElement) || !
|
|
1089
|
+
!(e.target instanceof HTMLElement) || !P(e.target) || !e.target.form?.isSameNode(this.form) || e instanceof CustomEvent || e.target instanceof HTMLInputElement && e.target.type === "file" || e.target instanceof HTMLInputElement && (e.target.type === "checkbox" || e.target.type === "radio") || (this.isDirty(e.target) && this.activated.add(e.target), this.shouldShowError(e.target) && this.validate(e.target));
|
|
1089
1090
|
}
|
|
1090
1091
|
changeHandler(e) {
|
|
1091
|
-
if (!(!(e.target instanceof HTMLElement) || !
|
|
1092
|
+
if (!(!(e.target instanceof HTMLElement) || !P(e.target) || !e.target.form?.isSameNode(this.form)) && !(e instanceof CustomEvent)) {
|
|
1092
1093
|
if (e.target instanceof HTMLSelectElement) {
|
|
1093
1094
|
this.activated.add(e.target), this.validate(e.target);
|
|
1094
1095
|
return;
|
|
@@ -1097,19 +1098,19 @@ var mt = class {
|
|
|
1097
1098
|
}
|
|
1098
1099
|
}
|
|
1099
1100
|
inputHandler(e) {
|
|
1100
|
-
!(e.target instanceof HTMLElement) || !
|
|
1101
|
+
!(e.target instanceof HTMLElement) || !P(e.target) || !e.target.form?.isSameNode(this.form) || e instanceof CustomEvent || e.target instanceof HTMLInputElement && (e.target.type === "checkbox" || e.target.type === "radio") || this.shouldShowError(e.target) && this.validate(e.target);
|
|
1101
1102
|
}
|
|
1102
1103
|
submit(e = null, { final: t = !1 } = {}) {
|
|
1103
|
-
return this.submitted = !0,
|
|
1104
|
+
return this.submitted = !0, N.log("Submit validation requested.", { final: t }), this.boundListeners || this.addEventListeners(), this.removeAllErrors(), this.validate(e, { includeHiddenPages: t });
|
|
1104
1105
|
}
|
|
1105
1106
|
resetLiveState() {
|
|
1106
1107
|
this.submitted = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.errors = [], this.removeAllErrors();
|
|
1107
1108
|
}
|
|
1108
1109
|
addEventListeners() {
|
|
1109
|
-
this.boundListeners || (this.form.addEventListener("blur", this.onBlur, !0), this.form.addEventListener("change", this.onChange, !1), this.form.addEventListener("input", this.onInput, !1), this.boundListeners = !0,
|
|
1110
|
+
this.boundListeners || (this.form.addEventListener("blur", this.onBlur, !0), this.form.addEventListener("change", this.onChange, !1), this.form.addEventListener("input", this.onInput, !1), this.boundListeners = !0, N.log("Event listeners attached."));
|
|
1110
1111
|
}
|
|
1111
1112
|
removeEventListeners() {
|
|
1112
|
-
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1,
|
|
1113
|
+
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1, N.log("Event listeners removed.");
|
|
1113
1114
|
}
|
|
1114
1115
|
emitEvent(e, t, n = {}) {
|
|
1115
1116
|
e.dispatchEvent(new CustomEvent(t, {
|
|
@@ -1126,7 +1127,7 @@ var mt = class {
|
|
|
1126
1127
|
removeValidator(e) {
|
|
1127
1128
|
delete this.validators[e];
|
|
1128
1129
|
}
|
|
1129
|
-
},
|
|
1130
|
+
}, F = /* @__PURE__ */ new WeakMap();
|
|
1130
1131
|
function ht(e) {
|
|
1131
1132
|
return (e.dataset.formieSubmitAction || "").trim();
|
|
1132
1133
|
}
|
|
@@ -1149,8 +1150,8 @@ function yt(e) {
|
|
|
1149
1150
|
return n === "true" || n === "1" || n === "";
|
|
1150
1151
|
}
|
|
1151
1152
|
function bt(e) {
|
|
1152
|
-
let t =
|
|
1153
|
-
typeof t == "number" && (window.clearTimeout(t),
|
|
1153
|
+
let t = F.get(e);
|
|
1154
|
+
typeof t == "number" && (window.clearTimeout(t), F.delete(e));
|
|
1154
1155
|
}
|
|
1155
1156
|
function xt(e) {
|
|
1156
1157
|
return e.querySelector("[data-formie-form-messages-top]") || e;
|
|
@@ -1170,7 +1171,7 @@ function Tt(e) {
|
|
|
1170
1171
|
}
|
|
1171
1172
|
function Et(e, t) {
|
|
1172
1173
|
let n = t.querySelector("[data-formie-error-message-container], [data-formie-message][data-formie-message-error]");
|
|
1173
|
-
return n || (n = document.createElement("div"), n.setAttribute("data-formie-error-message-container", "true"), t.appendChild(n)), n.setAttribute("data-formie-message", "true"), n.setAttribute("data-formie-message-error", "true"), w(n, e, "message", "messageError"), n.setAttribute("role", "alert"),
|
|
1174
|
+
return n || (n = document.createElement("div"), n.setAttribute("data-formie-error-message-container", "true"), t.appendChild(n)), n.setAttribute("data-formie-message", "true"), n.setAttribute("data-formie-message-error", "true"), w(n, e, "message", "messageError"), n.setAttribute("role", "alert"), Oe(n, De(Te(e))), n;
|
|
1174
1175
|
}
|
|
1175
1176
|
function Dt(e, t) {
|
|
1176
1177
|
let n = e.querySelector("[data-formie-success-container]"), r = wt(e, t);
|
|
@@ -1208,7 +1209,7 @@ function Mt(e) {
|
|
|
1208
1209
|
jt(n, e);
|
|
1209
1210
|
});
|
|
1210
1211
|
});
|
|
1211
|
-
}),
|
|
1212
|
+
}), y(e);
|
|
1212
1213
|
}
|
|
1213
1214
|
function Nt(e) {
|
|
1214
1215
|
e.querySelectorAll("[data-formie-error-container], [data-formie-errors]").forEach((t) => {
|
|
@@ -1238,12 +1239,12 @@ function It(e, t) {
|
|
|
1238
1239
|
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
1239
1240
|
}
|
|
1240
1241
|
function Lt(e, t) {
|
|
1241
|
-
let n =
|
|
1242
|
+
let n = De(Te(e));
|
|
1242
1243
|
Object.entries(t).forEach(([t, r]) => {
|
|
1243
1244
|
let i = e.querySelector(`[data-formie-field-handle="${t}"]`);
|
|
1244
1245
|
if (!i) return;
|
|
1245
1246
|
let a = Ot(i), o = a.id && a.id.trim() ? a.id : `${t}-errors`;
|
|
1246
|
-
a.id = o,
|
|
1247
|
+
a.id = o, Oe(a, n), w(i, e, "fieldLayoutError"), i.setAttribute("data-formie-field-has-error", "true"), r.forEach((t, n) => {
|
|
1247
1248
|
let r = document.createElement("div");
|
|
1248
1249
|
r.setAttribute("data-formie-field-error", "true"), r.setAttribute("role", "alert"), r.id = `${o}-${n + 1}`, w(r, e, "fieldError"), r.textContent = t, a.appendChild(r);
|
|
1249
1250
|
});
|
|
@@ -1254,7 +1255,7 @@ function Lt(e, t) {
|
|
|
1254
1255
|
let r = i.querySelector("[data-formie-instructions]");
|
|
1255
1256
|
r?.id && It(n, r.id);
|
|
1256
1257
|
});
|
|
1257
|
-
}),
|
|
1258
|
+
}), y(e);
|
|
1258
1259
|
}
|
|
1259
1260
|
function Rt(e, t) {
|
|
1260
1261
|
let n = Tt(e), r = Et(e, n);
|
|
@@ -1263,10 +1264,21 @@ function Rt(e, t) {
|
|
|
1263
1264
|
n.setAttribute("data-formie-error", "true"), n.setAttribute("role", "alert"), w(n, e, "error"), n.innerHTML = t, r.appendChild(n);
|
|
1264
1265
|
});
|
|
1265
1266
|
}
|
|
1266
|
-
function zt(e
|
|
1267
|
-
|
|
1267
|
+
function zt(e) {
|
|
1268
|
+
if (e.ok || e.keepSubmitLoading !== !0) return !1;
|
|
1269
|
+
let t = e.meta || {}, n = String(t.paymentStatus || "");
|
|
1270
|
+
return n === "actionRequired" || n === "pending";
|
|
1268
1271
|
}
|
|
1269
1272
|
function Bt(e, t) {
|
|
1273
|
+
let n = Tt(e), r = Et(e, n);
|
|
1274
|
+
w(n, e, "errors");
|
|
1275
|
+
let i = document.createElement("div");
|
|
1276
|
+
i.setAttribute("data-formie-notice", "true"), i.setAttribute("role", "status"), w(i, e, "message"), i.textContent = t, r.appendChild(i);
|
|
1277
|
+
}
|
|
1278
|
+
function Vt(e, t) {
|
|
1279
|
+
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" ? !0 : ht(e) === "message" && _t(e) !== "";
|
|
1280
|
+
}
|
|
1281
|
+
function Ht(e, t) {
|
|
1270
1282
|
let n = _t(e);
|
|
1271
1283
|
if (!n) return;
|
|
1272
1284
|
let r = Dt(e, n);
|
|
@@ -1276,33 +1288,40 @@ function Bt(e, t) {
|
|
|
1276
1288
|
let a = vt(e);
|
|
1277
1289
|
if (a !== null) {
|
|
1278
1290
|
let t = window.setTimeout(() => {
|
|
1279
|
-
|
|
1291
|
+
F.delete(e), Pt(e);
|
|
1280
1292
|
}, a);
|
|
1281
|
-
|
|
1293
|
+
F.set(e, t);
|
|
1282
1294
|
}
|
|
1283
1295
|
}
|
|
1284
|
-
function
|
|
1296
|
+
function I(e, t) {
|
|
1285
1297
|
if (Mt(e), Nt(e), Pt(e), Ft(e), t.ok) {
|
|
1286
|
-
|
|
1298
|
+
Vt(e, t) && Ht(e, t.message || "");
|
|
1287
1299
|
return;
|
|
1288
1300
|
}
|
|
1289
|
-
|
|
1301
|
+
if (!t.ok) {
|
|
1302
|
+
if (zt(t)) {
|
|
1303
|
+
let n = t.meta || {}, r = String(n.paymentMessage || "").trim();
|
|
1304
|
+
r && Bt(e, r);
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
t.fieldErrors && Lt(e, t.fieldErrors), t.formErrors?.length ? Rt(e, t.formErrors) : !t.fieldErrors && t.message && Rt(e, [t.message]), Fe(e);
|
|
1308
|
+
}
|
|
1290
1309
|
}
|
|
1291
1310
|
//#endregion
|
|
1292
1311
|
//#region src/js/core/submit-flow.ts
|
|
1293
|
-
var
|
|
1294
|
-
function
|
|
1312
|
+
var Ut = S("general", "submit-flow");
|
|
1313
|
+
function Wt(e) {
|
|
1295
1314
|
return !(!e.ok && e.stage === "validate");
|
|
1296
1315
|
}
|
|
1297
|
-
function
|
|
1316
|
+
function Gt(e) {
|
|
1298
1317
|
return e ? !!(e.keepSubmitLoading === !0 || e.ok && e.redirect?.url && e.redirect.target !== "new-tab") : !1;
|
|
1299
1318
|
}
|
|
1300
|
-
function
|
|
1319
|
+
function Kt(e) {
|
|
1301
1320
|
Mt(e), Nt(e), Pt(e), Ft(e);
|
|
1302
1321
|
}
|
|
1303
|
-
async function
|
|
1322
|
+
async function qt(e) {
|
|
1304
1323
|
let { id: t, target: n, form: r, bus: i, validator: a, validateOnSubmit: o, action: s, submitter: c, waitForSubmitDelay: l, onRefreshTokensAfterSubmit: u, dispatchSubmitResult: f } = e;
|
|
1305
|
-
|
|
1324
|
+
Kt(r), m(r, c || null);
|
|
1306
1325
|
let p = {
|
|
1307
1326
|
ok: !1,
|
|
1308
1327
|
code: "SUBMIT_ERROR",
|
|
@@ -1313,27 +1332,27 @@ async function Gt(e) {
|
|
|
1313
1332
|
await l(r), p = await nt(r, s, i, {
|
|
1314
1333
|
validator: a,
|
|
1315
1334
|
validateOnSubmit: o
|
|
1316
|
-
}),
|
|
1335
|
+
}), I(r, p), f(p), g(r, p, s), Wt(p) && await u(p);
|
|
1317
1336
|
} catch (e) {
|
|
1318
1337
|
p = {
|
|
1319
1338
|
ok: !1,
|
|
1320
1339
|
code: "SUBMIT_ERROR",
|
|
1321
1340
|
message: e instanceof Error ? e.message : "Submission failed.",
|
|
1322
1341
|
formErrors: [e instanceof Error ? e.message : "Submission failed."]
|
|
1323
|
-
},
|
|
1342
|
+
}, I(r, p), f(p), Ut.warn("Submit failed with exception.", {
|
|
1324
1343
|
id: t,
|
|
1325
1344
|
action: s,
|
|
1326
1345
|
target: n,
|
|
1327
1346
|
error: e instanceof Error ? e.message : e
|
|
1328
1347
|
});
|
|
1329
1348
|
} finally {
|
|
1330
|
-
|
|
1349
|
+
Gt(p) || d(r);
|
|
1331
1350
|
}
|
|
1332
1351
|
return p;
|
|
1333
1352
|
}
|
|
1334
1353
|
//#endregion
|
|
1335
1354
|
//#region src/js/modules/registry.ts
|
|
1336
|
-
var
|
|
1355
|
+
var L = class {
|
|
1337
1356
|
constructor() {
|
|
1338
1357
|
this.modules = /* @__PURE__ */ new Map();
|
|
1339
1358
|
}
|
|
@@ -1350,12 +1369,12 @@ var I = class {
|
|
|
1350
1369
|
getAll() {
|
|
1351
1370
|
return Array.from(this.modules.values());
|
|
1352
1371
|
}
|
|
1353
|
-
},
|
|
1372
|
+
}, Jt = {
|
|
1354
1373
|
"address-finder": () => import("./chunks/address-finder-k7_BXaRe.js").then((e) => e.addressFinderModule),
|
|
1355
1374
|
"google-address": () => import("./chunks/google-address-BH3Zhi06.js").then((e) => e.googleAddressModule),
|
|
1356
1375
|
loqate: () => import("./chunks/loqate-CJPzBmSm.js").then((e) => e.loqateModule),
|
|
1357
1376
|
"place-kit": () => import("./chunks/place-kit-BGHklIZ-.js").then((e) => e.placeKitModule)
|
|
1358
|
-
},
|
|
1377
|
+
}, Yt = {
|
|
1359
1378
|
"captcha-eu": () => import("./chunks/captcha-eu-CGm8Lbrj.js").then((e) => e.captchaEuModule),
|
|
1360
1379
|
"friendly-captcha-v1": () => import("./chunks/friendly-captcha-v1-C_2reOXr.js").then((e) => e.friendlyCaptchaV1Module),
|
|
1361
1380
|
"friendly-captcha-v2": () => import("./chunks/friendly-captcha-v2-CLSAbkqx.js").then((e) => e.friendlyCaptchaV2Module),
|
|
@@ -1366,105 +1385,108 @@ var I = class {
|
|
|
1366
1385
|
"recaptcha-v3": () => import("./chunks/recaptcha-v3-No4Ykrhk.js").then((e) => e.recaptchaV3Module),
|
|
1367
1386
|
snaptcha: () => import("./chunks/snaptcha-DKx98oon.js").then((e) => e.snaptchaModule),
|
|
1368
1387
|
turnstile: () => import("./chunks/turnstile-DJakPzQD.js").then((e) => e.turnstileModule)
|
|
1369
|
-
},
|
|
1388
|
+
}, Xt = {
|
|
1370
1389
|
calculations: () => import("./chunks/calculations-CeDgB9jt.js").then((e) => e.calculationsModule),
|
|
1371
1390
|
"checkbox-radio": () => import("./chunks/checkbox-radio-DQ0H67Tj.js").then((e) => e.checkboxRadioModule),
|
|
1372
|
-
combobox: () => import("./chunks/combobox-
|
|
1391
|
+
combobox: () => import("./chunks/combobox-C0EuExSI.js").then((e) => e.comboboxModule),
|
|
1373
1392
|
conditions: () => import("./chunks/conditions-B6_nzpeE.js").then((e) => e.conditionsModule),
|
|
1374
1393
|
"custom-google-maps": () => import("./chunks/custom-google-maps-BsaSirEZ.js").then((e) => e.customGoogleMapsModule),
|
|
1375
1394
|
"custom-link": () => import("./chunks/custom-link-CJ1-FjEM.js").then((e) => e.customLinkModule),
|
|
1376
1395
|
"custom-maps": () => import("./chunks/custom-maps-DYW_pBid.js").then((e) => e.customMapsModule),
|
|
1377
1396
|
"date-picker": () => import("./chunks/date-picker-5CA_-zGb.js").then((e) => e.datePickerModule),
|
|
1378
|
-
"file-upload": () => import("./chunks/file-upload-
|
|
1379
|
-
"upload-manager": () => import("./chunks/upload-manager-
|
|
1397
|
+
"file-upload": () => import("./chunks/file-upload-rqfZNqlH.js").then((e) => e.fileUploadModule),
|
|
1398
|
+
"upload-manager": () => import("./chunks/upload-manager-W-QDgxKD.js").then((e) => e.uploadManagerModule),
|
|
1380
1399
|
hidden: () => import("./chunks/hidden-D7_Ch-QN.js").then((e) => e.hiddenModule),
|
|
1381
1400
|
"phone-country": () => import("./chunks/phone-country-D3ayr60L.js").then((e) => e.phoneCountryModule),
|
|
1382
1401
|
"address-country": () => import("./chunks/address-country-Rx6GQTND.js").then((e) => e.addressCountryModule),
|
|
1383
|
-
"address-state": () => import("./chunks/address-state-
|
|
1384
|
-
repeater: () => import("./chunks/repeater-
|
|
1385
|
-
"rich-text": () => import("./chunks/rich-text-
|
|
1402
|
+
"address-state": () => import("./chunks/address-state-BwE01m2_.js").then((e) => e.addressStateModule),
|
|
1403
|
+
repeater: () => import("./chunks/repeater-BVnPUqTj.js").then((e) => e.repeaterModule),
|
|
1404
|
+
"rich-text": () => import("./chunks/rich-text-Bg_--4TG.js").then((e) => e.richTextModule),
|
|
1386
1405
|
signature: () => import("./chunks/signature-xz4QO7CR.js").then((e) => e.signatureModule),
|
|
1387
|
-
summary: () => import("./chunks/summary-
|
|
1388
|
-
|
|
1406
|
+
summary: () => import("./chunks/summary-Dks0gXS3.js").then((e) => e.summaryModule),
|
|
1407
|
+
"survey-likert": () => import("./chunks/survey-likert-DkE6bR7B.js").then((e) => e.surveyLikertModule),
|
|
1408
|
+
"survey-rank": () => import("./chunks/survey-rank-DN6x4IZM.js").then((e) => e.surveyRankModule),
|
|
1409
|
+
"survey-rating": () => import("./chunks/survey-rating-BnsNL9U5.js").then((e) => e.surveyRatingModule),
|
|
1410
|
+
table: () => import("./chunks/table-CAjCJHrL.js").then((e) => e.tableModule),
|
|
1389
1411
|
"text-limit": () => import("./chunks/text-limit-DbgEFHLO.js").then((e) => e.textLimitModule)
|
|
1390
|
-
},
|
|
1391
|
-
bpoint: () => import("./chunks/bpoint-
|
|
1392
|
-
eway: () => import("./chunks/eway-
|
|
1393
|
-
"go-cardless": () => import("./chunks/go-cardless-
|
|
1394
|
-
mollie: () => import("./chunks/mollie-
|
|
1395
|
-
moneris: () => import("./chunks/moneris-
|
|
1396
|
-
opayo: () => import("./chunks/opayo-
|
|
1397
|
-
paddle: () => import("./chunks/paddle-
|
|
1398
|
-
paypal: () => import("./chunks/paypal-
|
|
1399
|
-
payway: () => import("./chunks/payway-
|
|
1400
|
-
square: () => import("./chunks/square-
|
|
1401
|
-
stripe: () => import("./chunks/stripe-
|
|
1402
|
-
},
|
|
1412
|
+
}, Zt = {
|
|
1413
|
+
bpoint: () => import("./chunks/bpoint-C0VOftX9.js").then((e) => e.bpointModule),
|
|
1414
|
+
eway: () => import("./chunks/eway-CS6Y1Yvo.js").then((e) => e.ewayModule),
|
|
1415
|
+
"go-cardless": () => import("./chunks/go-cardless-BTPD668l.js").then((e) => e.goCardlessModule),
|
|
1416
|
+
mollie: () => import("./chunks/mollie-CXgBwvo6.js").then((e) => e.mollieModule),
|
|
1417
|
+
moneris: () => import("./chunks/moneris-B6oLu7nj.js").then((e) => e.monerisModule),
|
|
1418
|
+
opayo: () => import("./chunks/opayo-DPUA5CKr.js").then((e) => e.opayoModule),
|
|
1419
|
+
paddle: () => import("./chunks/paddle-GRlsm5mm.js").then((e) => e.paddleModule),
|
|
1420
|
+
paypal: () => import("./chunks/paypal-CdcZnf6r.js").then((e) => e.paypalModule),
|
|
1421
|
+
payway: () => import("./chunks/payway-CfmYOS__.js").then((e) => e.paywayModule),
|
|
1422
|
+
square: () => import("./chunks/square-BY--5M-X.js").then((e) => e.squareModule),
|
|
1423
|
+
stripe: () => import("./chunks/stripe-uusYjWty.js").then((e) => e.stripeModule)
|
|
1424
|
+
}, Qt = {
|
|
1425
|
+
...Xt,
|
|
1403
1426
|
...Jt,
|
|
1404
|
-
...
|
|
1405
|
-
...
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
async function z(t, n, i, a) {
|
|
1427
|
+
...Yt,
|
|
1428
|
+
...Zt
|
|
1429
|
+
}, R = /* @__PURE__ */ new Map(), z = S("general", "loader"), $t = Function("src", "return import(src);");
|
|
1430
|
+
async function B(t, n, i, a) {
|
|
1409
1431
|
await t(r(i), a), await t(e(n, i), a);
|
|
1410
1432
|
}
|
|
1411
|
-
function
|
|
1433
|
+
function en(e) {
|
|
1412
1434
|
return !!e && typeof e == "object" && typeof e.id == "string" && typeof e.setup == "function" && typeof e.match == "function";
|
|
1413
1435
|
}
|
|
1414
|
-
async function
|
|
1415
|
-
let n =
|
|
1416
|
-
return n ? (
|
|
1436
|
+
async function tn(e, t) {
|
|
1437
|
+
let n = Qt[e];
|
|
1438
|
+
return n ? (R.has(e) || R.set(e, (async () => {
|
|
1417
1439
|
try {
|
|
1418
1440
|
let e = await n();
|
|
1419
|
-
return
|
|
1441
|
+
return en(e) ? (t.registry.register(e), e) : null;
|
|
1420
1442
|
} catch (t) {
|
|
1421
|
-
return console.error("[formie] Failed to load builtin module:", e, t),
|
|
1443
|
+
return console.error("[formie] Failed to load builtin module:", e, t), z.warn("Failed loading builtin module.", {
|
|
1422
1444
|
moduleId: e,
|
|
1423
1445
|
error: t
|
|
1424
1446
|
}), null;
|
|
1425
1447
|
}
|
|
1426
|
-
})()),
|
|
1448
|
+
})()), R.get(e) || null) : null;
|
|
1427
1449
|
}
|
|
1428
|
-
async function
|
|
1450
|
+
async function nn(e) {
|
|
1429
1451
|
try {
|
|
1430
|
-
let t = await
|
|
1431
|
-
return
|
|
1452
|
+
let t = await $t(e), n = t?.default || t?.formieModule || null;
|
|
1453
|
+
return en(n) ? n : null;
|
|
1432
1454
|
} catch (t) {
|
|
1433
|
-
return console.error("[formie] Failed to load module from src:", e, t),
|
|
1455
|
+
return console.error("[formie] Failed to load module from src:", e, t), z.warn("Failed loading module from src.", {
|
|
1434
1456
|
src: e,
|
|
1435
1457
|
error: t
|
|
1436
1458
|
}), null;
|
|
1437
1459
|
}
|
|
1438
1460
|
}
|
|
1439
|
-
async function
|
|
1461
|
+
async function rn(e, t) {
|
|
1440
1462
|
let n = t.registry.get(e.id);
|
|
1441
1463
|
if (n) return n;
|
|
1442
|
-
let r = await
|
|
1464
|
+
let r = await tn(e.id, t);
|
|
1443
1465
|
if (r) return r;
|
|
1444
1466
|
if (e.src) {
|
|
1445
|
-
let n = await
|
|
1467
|
+
let n = await nn(e.src);
|
|
1446
1468
|
if (n) return t.registry.register(n), n;
|
|
1447
1469
|
}
|
|
1448
1470
|
return null;
|
|
1449
1471
|
}
|
|
1450
|
-
function
|
|
1472
|
+
function V(e) {
|
|
1451
1473
|
return typeof window.CSS?.escape == "function" ? window.CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
|
|
1452
1474
|
}
|
|
1453
|
-
function
|
|
1475
|
+
function H(e, t) {
|
|
1454
1476
|
return e.matches(t) ? [e, ...Array.from(e.querySelectorAll(t))] : Array.from(e.querySelectorAll(t));
|
|
1455
1477
|
}
|
|
1456
|
-
function
|
|
1478
|
+
function an(e, t) {
|
|
1457
1479
|
let n = t.setupContext.root, r = t.setupContext.form, i = e.targetType, a = e.targetId;
|
|
1458
|
-
return i === "selector" ?
|
|
1480
|
+
return i === "selector" ? H(n, a).map((e) => ({
|
|
1459
1481
|
scope: i,
|
|
1460
1482
|
element: e
|
|
1461
|
-
})) : i === "field" ?
|
|
1483
|
+
})) : i === "field" ? H(n, `[data-formie-field-handle="${V(a)}"]`).map((e) => ({
|
|
1462
1484
|
scope: i,
|
|
1463
1485
|
element: e
|
|
1464
|
-
})) : i === "page" ?
|
|
1486
|
+
})) : i === "page" ? H(n, `[data-formie-page-id="${V(a)}"]`).map((e) => ({
|
|
1465
1487
|
scope: i,
|
|
1466
1488
|
element: e
|
|
1467
|
-
})) : i === "button" ?
|
|
1489
|
+
})) : i === "button" ? H(n, `[data-formie-action="${V(a)}"]`).map((e) => ({
|
|
1468
1490
|
scope: i,
|
|
1469
1491
|
element: e
|
|
1470
1492
|
})) : [{
|
|
@@ -1472,26 +1494,26 @@ function nn(e, t) {
|
|
|
1472
1494
|
element: r || n
|
|
1473
1495
|
}];
|
|
1474
1496
|
}
|
|
1475
|
-
function
|
|
1497
|
+
function on(e, t) {
|
|
1476
1498
|
return (e.targets && e.targets.length > 0 ? e.targets : [{
|
|
1477
1499
|
targetType: "form",
|
|
1478
1500
|
targetId: "form"
|
|
1479
|
-
}]).flatMap((e) =>
|
|
1501
|
+
}]).flatMap((e) => an(e, t));
|
|
1480
1502
|
}
|
|
1481
|
-
async function
|
|
1503
|
+
async function sn(e, t) {
|
|
1482
1504
|
let n = [];
|
|
1483
|
-
|
|
1505
|
+
z.log("Loading module manifest.", { manifestCount: e.length });
|
|
1484
1506
|
for (let r of e) {
|
|
1485
|
-
let e = await
|
|
1507
|
+
let e = await rn(r, t);
|
|
1486
1508
|
if (!e) {
|
|
1487
|
-
|
|
1509
|
+
z.warn("Skipping manifest item (definition not resolved).", {
|
|
1488
1510
|
moduleId: r.id,
|
|
1489
1511
|
src: r.src
|
|
1490
1512
|
});
|
|
1491
1513
|
continue;
|
|
1492
1514
|
}
|
|
1493
|
-
let i =
|
|
1494
|
-
|
|
1515
|
+
let i = on(r, t);
|
|
1516
|
+
z.log("Resolved module targets.", {
|
|
1495
1517
|
moduleId: e.id,
|
|
1496
1518
|
targets: r.targets || [],
|
|
1497
1519
|
targetCount: i.length
|
|
@@ -1504,7 +1526,7 @@ async function an(e, t) {
|
|
|
1504
1526
|
manifestItem: r
|
|
1505
1527
|
};
|
|
1506
1528
|
if (!e.match(i)) {
|
|
1507
|
-
e.kind === "address" && console.warn(`[formie] Address module "${e.id}" skipped: target element does not contain [data-formie-address-autocomplete-input]. Enable the Auto-Complete subfield.`),
|
|
1529
|
+
e.kind === "address" && console.warn(`[formie] Address module "${e.id}" skipped: target element does not contain [data-formie-address-autocomplete-input]. Enable the Auto-Complete subfield.`), z.log("Module target did not match predicate.", {
|
|
1508
1530
|
moduleId: e.id,
|
|
1509
1531
|
scope: a.scope
|
|
1510
1532
|
});
|
|
@@ -1518,7 +1540,7 @@ async function an(e, t) {
|
|
|
1518
1540
|
options: o,
|
|
1519
1541
|
manifestItem: r
|
|
1520
1542
|
};
|
|
1521
|
-
await
|
|
1543
|
+
await B(t.setupContext.emit, s, "before-setup", c);
|
|
1522
1544
|
let l = null;
|
|
1523
1545
|
try {
|
|
1524
1546
|
let n = await e.setup({
|
|
@@ -1529,25 +1551,25 @@ async function an(e, t) {
|
|
|
1529
1551
|
});
|
|
1530
1552
|
n && (l = n);
|
|
1531
1553
|
} catch (t) {
|
|
1532
|
-
console.error(`[formie] Module "${e.id}" setup failed:`, t),
|
|
1554
|
+
console.error(`[formie] Module "${e.id}" setup failed:`, t), z.warn("Module setup failed.", {
|
|
1533
1555
|
moduleId: e.id,
|
|
1534
1556
|
scope: a.scope,
|
|
1535
1557
|
error: t
|
|
1536
1558
|
});
|
|
1537
1559
|
}
|
|
1538
|
-
await
|
|
1560
|
+
await B(t.setupContext.emit, s, "after-setup", {
|
|
1539
1561
|
...c,
|
|
1540
1562
|
instanceCreated: !!l
|
|
1541
|
-
}), l && (
|
|
1563
|
+
}), l && (z.log("Module instance created.", {
|
|
1542
1564
|
moduleId: e.id,
|
|
1543
1565
|
scope: a.scope
|
|
1544
1566
|
}), n.push({
|
|
1545
1567
|
...l,
|
|
1546
1568
|
destroy: async () => {
|
|
1547
|
-
|
|
1569
|
+
z.log("Destroying module instance.", {
|
|
1548
1570
|
moduleId: e.id,
|
|
1549
1571
|
scope: a.scope
|
|
1550
|
-
}), await
|
|
1572
|
+
}), await B(t.setupContext.emit, s, "before-destroy", c), await l.destroy(), await B(t.setupContext.emit, s, "after-destroy", c), z.log("Module instance destroyed.", {
|
|
1551
1573
|
moduleId: e.id,
|
|
1552
1574
|
scope: a.scope
|
|
1553
1575
|
});
|
|
@@ -1555,20 +1577,20 @@ async function an(e, t) {
|
|
|
1555
1577
|
}));
|
|
1556
1578
|
}
|
|
1557
1579
|
}
|
|
1558
|
-
return
|
|
1580
|
+
return z.log("Module manifest processing complete.", { instanceCount: n.length }), n;
|
|
1559
1581
|
}
|
|
1560
1582
|
//#endregion
|
|
1561
1583
|
//#region src/js/utils/form-started-at.ts
|
|
1562
|
-
var
|
|
1563
|
-
function
|
|
1584
|
+
var cn = "formie:formStartedAt:";
|
|
1585
|
+
function ln(e) {
|
|
1564
1586
|
let t = e.querySelector("input[name=\"formStartedAt\"]");
|
|
1565
1587
|
if (!t) return;
|
|
1566
|
-
let n = e.querySelector("input[name=\"renderId\"]")?.value?.trim() ?? "", r = n ? `${
|
|
1588
|
+
let n = e.querySelector("input[name=\"renderId\"]")?.value?.trim() ?? "", r = n ? `${cn}${n}` : null, i = r ? sessionStorage.getItem(r) : null;
|
|
1567
1589
|
i || (i = String(Date.now()), r && sessionStorage.setItem(r, i)), t.value = i;
|
|
1568
1590
|
}
|
|
1569
1591
|
//#endregion
|
|
1570
1592
|
//#region src/js/utils/unload-warning.ts
|
|
1571
|
-
var
|
|
1593
|
+
var un = new Set([
|
|
1572
1594
|
"CRAFT_CSRF_TOKEN",
|
|
1573
1595
|
"action",
|
|
1574
1596
|
"redirect",
|
|
@@ -1581,38 +1603,38 @@ var cn = new Set([
|
|
|
1581
1603
|
"draftContext",
|
|
1582
1604
|
"continuationToken"
|
|
1583
1605
|
]);
|
|
1584
|
-
function
|
|
1606
|
+
function dn(e, t) {
|
|
1585
1607
|
if (e == null) return String(e);
|
|
1586
1608
|
if (typeof e == "string") return JSON.stringify(e);
|
|
1587
1609
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1588
1610
|
if (typeof e == "function") return "[function]";
|
|
1589
1611
|
if (typeof File < "u" && e instanceof File) return `[file:${e.name}:${e.size}:${e.type}]`;
|
|
1590
1612
|
if (typeof Blob < "u" && e instanceof Blob) return `[blob:${e.size}:${e.type}]`;
|
|
1591
|
-
if (Array.isArray(e)) return `[${e.map((e) =>
|
|
1613
|
+
if (Array.isArray(e)) return `[${e.map((e) => dn(e, t)).join(",")}]`;
|
|
1592
1614
|
if (typeof e == "object") {
|
|
1593
1615
|
if (t.has(e)) return "[circular]";
|
|
1594
1616
|
t.add(e);
|
|
1595
|
-
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${
|
|
1617
|
+
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${dn(n, t)}`);
|
|
1596
1618
|
return t.delete(e), `{${n.join(",")}}`;
|
|
1597
1619
|
}
|
|
1598
1620
|
return JSON.stringify(String(e));
|
|
1599
1621
|
}
|
|
1600
|
-
function
|
|
1601
|
-
return
|
|
1622
|
+
function fn(e) {
|
|
1623
|
+
return dn(e, /* @__PURE__ */ new WeakSet());
|
|
1602
1624
|
}
|
|
1603
|
-
function
|
|
1625
|
+
function pn(e) {
|
|
1604
1626
|
if (!e) return !1;
|
|
1605
1627
|
let t = e.endsWith("[]") ? e.slice(0, -2) : e;
|
|
1606
|
-
return !
|
|
1628
|
+
return !un.has(t);
|
|
1607
1629
|
}
|
|
1608
|
-
function
|
|
1609
|
-
return
|
|
1630
|
+
function mn(e) {
|
|
1631
|
+
return fn(Array.from(new FormData(e).entries()).filter(([e]) => pn(String(e || ""))));
|
|
1610
1632
|
}
|
|
1611
|
-
function
|
|
1633
|
+
function hn(e, t = {}) {
|
|
1612
1634
|
let n = null, r = !1, i = !1, a = null, o = null, s = null, c = () => {
|
|
1613
1635
|
a !== null && (window.cancelAnimationFrame(a), a = null), o !== null && (window.clearTimeout(o), o = null), s !== null && (window.clearTimeout(s), s = null);
|
|
1614
|
-
}, l = () => r ? (i =
|
|
1615
|
-
n =
|
|
1636
|
+
}, l = () => r ? (i = mn(e) !== n, i) : !1, u = () => {
|
|
1637
|
+
n = mn(e), r = !0, i = !1;
|
|
1616
1638
|
}, d = () => {
|
|
1617
1639
|
c(), r = !1, a = window.requestAnimationFrame(() => {
|
|
1618
1640
|
a = null, s = window.setTimeout(() => {
|
|
@@ -1637,25 +1659,25 @@ function fn(e, t = {}) {
|
|
|
1637
1659
|
}
|
|
1638
1660
|
//#endregion
|
|
1639
1661
|
//#region src/js/validation/enter-key-guard.ts
|
|
1640
|
-
function
|
|
1662
|
+
function gn(e) {
|
|
1641
1663
|
return e.hasAttribute("data-formie-conditionally-hidden") || !!e.closest("[data-formie-conditionally-hidden]") || e.hasAttribute("data-formie-page-hidden") || !!e.closest("[data-formie-page-hidden]");
|
|
1642
1664
|
}
|
|
1643
|
-
function
|
|
1665
|
+
function _n(e, t) {
|
|
1644
1666
|
let n = e.querySelectorAll(`[data-formie-action="${t}"]`);
|
|
1645
|
-
return Array.from(n).some((e) => !
|
|
1667
|
+
return Array.from(n).some((e) => !gn(e));
|
|
1646
1668
|
}
|
|
1647
|
-
function
|
|
1669
|
+
function vn(e) {
|
|
1648
1670
|
let { final: t } = f(e);
|
|
1649
1671
|
return "submit";
|
|
1650
1672
|
}
|
|
1651
|
-
function
|
|
1652
|
-
return !
|
|
1673
|
+
function yn(e) {
|
|
1674
|
+
return !_n(e, vn(e));
|
|
1653
1675
|
}
|
|
1654
|
-
function
|
|
1676
|
+
function bn(e) {
|
|
1655
1677
|
let t = (t) => {
|
|
1656
1678
|
if (t.key !== "Enter" || t.defaultPrevented) return;
|
|
1657
1679
|
let n = t.target;
|
|
1658
|
-
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") ||
|
|
1680
|
+
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") || yn(e) && t.preventDefault());
|
|
1659
1681
|
};
|
|
1660
1682
|
return e.addEventListener("keydown", t, !0), () => {
|
|
1661
1683
|
e.removeEventListener("keydown", t, !0);
|
|
@@ -1663,13 +1685,13 @@ function _n(e) {
|
|
|
1663
1685
|
}
|
|
1664
1686
|
//#endregion
|
|
1665
1687
|
//#region src/js/core/create-formie-client.ts
|
|
1666
|
-
var U = "[data-formie]:not([data-formie-init=\"false\"]), [data-formie-form]:not([data-formie-init=\"false\"])",
|
|
1688
|
+
var U = "[data-formie]:not([data-formie-init=\"false\"]), [data-formie-form]:not([data-formie-init=\"false\"])", xn = 300, Sn = "/actions/formie/server/forms/render", Cn = "/api", wn = "/actions/formie/server/forms/refresh-tokens", Tn = "/actions/formie/server/submissions/submit", En = "/actions/formie/server/submissions/set-page", Dn = "/actions/formie/server/submissions/clear-submission", On = "/actions/formie/file-upload/hydrate", W = S("general", "client"), kn = /* @__PURE__ */ new Set();
|
|
1667
1689
|
function G(e, t) {
|
|
1668
1690
|
if (e == null || e === "") return t;
|
|
1669
1691
|
let n = e.toLowerCase();
|
|
1670
1692
|
return !(n === "false" || n === "0" || n === "off");
|
|
1671
1693
|
}
|
|
1672
|
-
function
|
|
1694
|
+
function An(e) {
|
|
1673
1695
|
return e.formieRefreshTokens != null && e.formieRefreshTokens !== "" ? G(e.formieRefreshTokens, !1) : e.formieStaticCache != null && e.formieStaticCache !== "" ? G(e.formieStaticCache, !1) : !1;
|
|
1674
1696
|
}
|
|
1675
1697
|
function K(e) {
|
|
@@ -1679,7 +1701,7 @@ function K(e) {
|
|
|
1679
1701
|
transport: t.formieTransport || "rest",
|
|
1680
1702
|
formHandle: t.formieHandle,
|
|
1681
1703
|
endpoint: t.formieEndpoint,
|
|
1682
|
-
staticCache:
|
|
1704
|
+
staticCache: An(t),
|
|
1683
1705
|
autoVisible: G(t.formieAutoVisible, !0),
|
|
1684
1706
|
compatibility: G(t.formieCompatibility, !1)
|
|
1685
1707
|
};
|
|
@@ -1693,10 +1715,10 @@ function J(e) {
|
|
|
1693
1715
|
function Y(e) {
|
|
1694
1716
|
return e instanceof HTMLFormElement ? e : e.querySelector("form");
|
|
1695
1717
|
}
|
|
1696
|
-
function
|
|
1697
|
-
|
|
1718
|
+
function jn(e, t) {
|
|
1719
|
+
kn.has(e) || (kn.add(e), W.warn(t));
|
|
1698
1720
|
}
|
|
1699
|
-
function
|
|
1721
|
+
function Mn(e, t) {
|
|
1700
1722
|
if (!e) return e;
|
|
1701
1723
|
try {
|
|
1702
1724
|
return new URL(e).toString();
|
|
@@ -1710,19 +1732,19 @@ function kn(e, t) {
|
|
|
1710
1732
|
}
|
|
1711
1733
|
function X(e, t) {
|
|
1712
1734
|
let n = (e || "").trim();
|
|
1713
|
-
return n ? n.includes("/actions/") ? n :
|
|
1735
|
+
return n ? n.includes("/actions/") ? n : Mn(t, n) : t;
|
|
1714
1736
|
}
|
|
1715
|
-
function
|
|
1716
|
-
return X(e.endpoint || t.dataset.formieEndpoint,
|
|
1737
|
+
function Nn(e, t) {
|
|
1738
|
+
return X(e.endpoint || t.dataset.formieEndpoint, Sn);
|
|
1717
1739
|
}
|
|
1718
|
-
function
|
|
1740
|
+
function Pn(e, t) {
|
|
1719
1741
|
let n = (e.endpoint || t.dataset.formieEndpoint || "").trim();
|
|
1720
|
-
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n :
|
|
1742
|
+
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n : Mn(Cn, n) : Cn;
|
|
1721
1743
|
}
|
|
1722
|
-
function
|
|
1723
|
-
return X(t.dataset.formieRefreshTokensEndpoint || e.endpoint || t.dataset.formieEndpoint,
|
|
1744
|
+
function Fn(e, t) {
|
|
1745
|
+
return X(t.dataset.formieRefreshTokensEndpoint || e.endpoint || t.dataset.formieEndpoint, wn);
|
|
1724
1746
|
}
|
|
1725
|
-
function
|
|
1747
|
+
function In(e, t) {
|
|
1726
1748
|
if (!e) return t;
|
|
1727
1749
|
try {
|
|
1728
1750
|
let n = new URL(e, window.location.origin), r = new URL(t, window.location.origin);
|
|
@@ -1733,42 +1755,42 @@ function Nn(e, t) {
|
|
|
1733
1755
|
return t;
|
|
1734
1756
|
}
|
|
1735
1757
|
}
|
|
1736
|
-
function
|
|
1737
|
-
let r = n.endpoint || e.dataset.formieEndpoint, i = X(r,
|
|
1738
|
-
t.setAttribute("action",
|
|
1739
|
-
let t = e.getAttribute("href"), n = X(r,
|
|
1740
|
-
e.setAttribute("href",
|
|
1758
|
+
function Ln(e, t, n) {
|
|
1759
|
+
let r = n.endpoint || e.dataset.formieEndpoint, i = X(r, Tn), a = t.getAttribute("action");
|
|
1760
|
+
t.setAttribute("action", In(a, i)), t.querySelectorAll("[data-formie-tab-link]").forEach((e) => {
|
|
1761
|
+
let t = e.getAttribute("href"), n = X(r, En);
|
|
1762
|
+
e.setAttribute("href", In(t, n));
|
|
1741
1763
|
}), t.querySelectorAll("[data-formie-file-upload-hydrate-endpoint]").forEach((e) => {
|
|
1742
|
-
e.setAttribute("data-formie-file-upload-hydrate-endpoint", X(r,
|
|
1764
|
+
e.setAttribute("data-formie-file-upload-hydrate-endpoint", X(r, On));
|
|
1743
1765
|
});
|
|
1744
1766
|
}
|
|
1745
|
-
function
|
|
1767
|
+
function Rn(e, t) {
|
|
1746
1768
|
if (e === "graphql" && t !== "server-rendered") throw Error(`Formie ${t} mode does not support GraphQL transport yet.`);
|
|
1747
1769
|
}
|
|
1748
|
-
function
|
|
1770
|
+
function zn(e) {
|
|
1749
1771
|
if (e == null) return !1;
|
|
1750
1772
|
let t = e.trim().toLowerCase();
|
|
1751
1773
|
return t === "true" || t === "1" || t === "";
|
|
1752
1774
|
}
|
|
1753
|
-
function
|
|
1775
|
+
function Bn(e) {
|
|
1754
1776
|
return G(e.dataset.formieAutomaticSubmissionState, !0);
|
|
1755
1777
|
}
|
|
1756
|
-
function
|
|
1757
|
-
return X(n.dataset.formieClearSubmissionEndpoint || e.endpoint || t.dataset.formieEndpoint,
|
|
1778
|
+
function Vn(e, t, n) {
|
|
1779
|
+
return X(n.dataset.formieClearSubmissionEndpoint || e.endpoint || t.dataset.formieEndpoint, Dn);
|
|
1758
1780
|
}
|
|
1759
|
-
function
|
|
1760
|
-
return
|
|
1781
|
+
function Hn(e) {
|
|
1782
|
+
return zn(e.dataset.formieUnloadWarning);
|
|
1761
1783
|
}
|
|
1762
|
-
function
|
|
1784
|
+
function Un(e, t) {
|
|
1763
1785
|
e.setAttribute("data-formie-internal-navigation", t);
|
|
1764
1786
|
}
|
|
1765
|
-
function
|
|
1787
|
+
function Wn(e) {
|
|
1766
1788
|
e.removeAttribute("data-formie-internal-navigation");
|
|
1767
1789
|
}
|
|
1768
|
-
function
|
|
1790
|
+
function Gn(e) {
|
|
1769
1791
|
return e.getAttribute("data-formie-internal-navigation") !== null;
|
|
1770
1792
|
}
|
|
1771
|
-
function
|
|
1793
|
+
function Kn(e, t) {
|
|
1772
1794
|
if (!e) return !1;
|
|
1773
1795
|
try {
|
|
1774
1796
|
return new URL(e, window.location.origin).searchParams.has(t);
|
|
@@ -1776,30 +1798,30 @@ function Un(e, t) {
|
|
|
1776
1798
|
return !1;
|
|
1777
1799
|
}
|
|
1778
1800
|
}
|
|
1779
|
-
function
|
|
1780
|
-
return
|
|
1801
|
+
function qn(e) {
|
|
1802
|
+
return Kn(window.location.href, "resumeToken") || Kn(e.getAttribute("action"), "resumeToken");
|
|
1781
1803
|
}
|
|
1782
|
-
function
|
|
1804
|
+
function Jn(e) {
|
|
1783
1805
|
return e instanceof MouseEvent ? e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey : !0;
|
|
1784
1806
|
}
|
|
1785
|
-
function
|
|
1807
|
+
function Yn(e, t = 0) {
|
|
1786
1808
|
if (!e) return t;
|
|
1787
1809
|
let n = Number.parseInt(e, 10);
|
|
1788
1810
|
return Number.isFinite(n) ? n : t;
|
|
1789
1811
|
}
|
|
1790
|
-
function
|
|
1791
|
-
return Math.max(0,
|
|
1812
|
+
function Xn(e) {
|
|
1813
|
+
return Math.max(0, Yn(e.dataset.formieSubmitDelay, xn));
|
|
1792
1814
|
}
|
|
1793
1815
|
function Z(e) {
|
|
1794
|
-
return
|
|
1816
|
+
return zn(e.dataset.formieValidationOnSubmit);
|
|
1795
1817
|
}
|
|
1796
|
-
async function
|
|
1797
|
-
let t =
|
|
1818
|
+
async function Zn(e) {
|
|
1819
|
+
let t = Xn(e);
|
|
1798
1820
|
t < 1 || await new Promise((e) => {
|
|
1799
1821
|
window.setTimeout(e, t);
|
|
1800
1822
|
});
|
|
1801
1823
|
}
|
|
1802
|
-
function
|
|
1824
|
+
function Qn(e, t) {
|
|
1803
1825
|
let n = e?.getAttribute(t)?.trim();
|
|
1804
1826
|
if (!n) return null;
|
|
1805
1827
|
try {
|
|
@@ -1808,29 +1830,29 @@ function Yn(e, t) {
|
|
|
1808
1830
|
return console.error(`[formie] Failed to parse ${t}.`, e), null;
|
|
1809
1831
|
}
|
|
1810
1832
|
}
|
|
1811
|
-
function
|
|
1833
|
+
function $n(e, t) {
|
|
1812
1834
|
let n = t || (e instanceof HTMLFormElement ? e : null);
|
|
1813
1835
|
if (!n) return null;
|
|
1814
|
-
let r =
|
|
1836
|
+
let r = Qn(n, "data-formie-modules"), i = Qn(n, "data-formie-theme");
|
|
1815
1837
|
return !r && !i ? null : {
|
|
1816
1838
|
modules: r || void 0,
|
|
1817
1839
|
theme: i || void 0
|
|
1818
1840
|
};
|
|
1819
1841
|
}
|
|
1820
|
-
function
|
|
1842
|
+
function er(e) {
|
|
1821
1843
|
if (!(e instanceof HTMLElement)) return !0;
|
|
1822
1844
|
if (!e.isConnected || e.hidden || e.closest("[hidden]")) return !1;
|
|
1823
1845
|
let t = window.getComputedStyle(e);
|
|
1824
1846
|
return t.display === "none" || t.visibility === "hidden" ? !1 : e.getClientRects().length > 0;
|
|
1825
1847
|
}
|
|
1826
|
-
function
|
|
1848
|
+
function tr(e, t) {
|
|
1827
1849
|
return t === document ? !0 : t instanceof Element ? t === e || t.contains(e) : !0;
|
|
1828
1850
|
}
|
|
1829
1851
|
function Q(e) {
|
|
1830
1852
|
let t = e, n = t.id ? `#${t.id}` : "", r = t.dataset?.formieHandle ? `[handle="${t.dataset.formieHandle}"]` : "";
|
|
1831
1853
|
return `${t.tagName ? t.tagName.toLowerCase() : "element"}${n}${r}`;
|
|
1832
1854
|
}
|
|
1833
|
-
function
|
|
1855
|
+
function nr(e, t) {
|
|
1834
1856
|
if (t) {
|
|
1835
1857
|
if (t.csrf?.param && t.csrf?.token) {
|
|
1836
1858
|
let n = e.querySelector(`input[name="${t.csrf.param}"]`);
|
|
@@ -1853,11 +1875,11 @@ function $n(e, t) {
|
|
|
1853
1875
|
});
|
|
1854
1876
|
}
|
|
1855
1877
|
}
|
|
1856
|
-
async function
|
|
1878
|
+
async function rr(e, t) {
|
|
1857
1879
|
let n = q(t.mode), r = J(t.transport);
|
|
1858
1880
|
if (n !== "server-rendered") return null;
|
|
1859
1881
|
if (t.payload) return t.payload.html && (e.innerHTML = t.payload.html), t.payload;
|
|
1860
|
-
|
|
1882
|
+
Rn(r, n);
|
|
1861
1883
|
let i = !!Y(e), a = t.formHandle || e.dataset.formieHandle;
|
|
1862
1884
|
if (i || !a) return null;
|
|
1863
1885
|
let o = {
|
|
@@ -1867,30 +1889,30 @@ async function er(e, t) {
|
|
|
1867
1889
|
siteId: t.siteId,
|
|
1868
1890
|
theme: t.theme,
|
|
1869
1891
|
themeConfig: t.themeConfig
|
|
1870
|
-
}, s = r === "graphql" ?
|
|
1892
|
+
}, s = r === "graphql" ? Pn(t, e) : Nn(t, e), c = r === "graphql" ? await Ve(s, a, o) : await Be(s, a, {
|
|
1871
1893
|
...o,
|
|
1872
1894
|
endpoint: s
|
|
1873
1895
|
});
|
|
1874
1896
|
return c?.html && (e.innerHTML = c.html), c;
|
|
1875
1897
|
}
|
|
1876
|
-
async function
|
|
1898
|
+
async function ir(e, t, n) {
|
|
1877
1899
|
if (t.refreshTokens === !1) return;
|
|
1878
|
-
|
|
1900
|
+
Rn(J(t.transport), q(t.mode));
|
|
1879
1901
|
let r = t.formHandle || e.dataset.formieHandle;
|
|
1880
1902
|
if (!r) return;
|
|
1881
|
-
let i = await
|
|
1882
|
-
|
|
1903
|
+
let i = await j(Fn(t, e), r, n.querySelector("input[name=\"renderId\"]")?.value || void 0);
|
|
1904
|
+
nr(n, i), h(e, "formie:refresh-tokens:refreshed", i);
|
|
1883
1905
|
}
|
|
1884
|
-
function
|
|
1885
|
-
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s =
|
|
1906
|
+
function ar(e, t, n, r, i, a) {
|
|
1907
|
+
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s = Vn(n, e, t), c = !1, u = t.querySelectorAll("[data-formie-action]"), g = (e) => {
|
|
1886
1908
|
if (e) {
|
|
1887
1909
|
t.setAttribute("data-formie-pending-action", e);
|
|
1888
1910
|
return;
|
|
1889
1911
|
}
|
|
1890
1912
|
t.removeAttribute("data-formie-pending-action");
|
|
1891
1913
|
};
|
|
1892
|
-
if (
|
|
1893
|
-
let n =
|
|
1914
|
+
if (Hn(t)) {
|
|
1915
|
+
let n = hn(t, { shouldWarn: () => !Gn(t) }), r = (e) => {
|
|
1894
1916
|
if (!(e instanceof CustomEvent)) return;
|
|
1895
1917
|
let t = e.detail;
|
|
1896
1918
|
t?.ok && t.action === "save" && n.scheduleBaselineCapture();
|
|
@@ -1901,7 +1923,7 @@ function nr(e, t, n, r, i, a) {
|
|
|
1901
1923
|
e.removeEventListener("formie:submit:result", r), t.removeEventListener("formie:state:reset", i), n.destroy();
|
|
1902
1924
|
});
|
|
1903
1925
|
}
|
|
1904
|
-
if (
|
|
1926
|
+
if (u.forEach((e) => {
|
|
1905
1927
|
let n = (e) => {
|
|
1906
1928
|
let n = e.currentTarget.getAttribute("data-formie-action"), r = t.querySelector("input[name=\"submitAction\"]");
|
|
1907
1929
|
g(n), n && r && (r.value = n);
|
|
@@ -1912,24 +1934,24 @@ function nr(e, t, n, r, i, a) {
|
|
|
1912
1934
|
}), t.querySelectorAll("[data-formie-tab-link]").forEach((n) => {
|
|
1913
1935
|
let r = async (n) => {
|
|
1914
1936
|
if (o !== "ajax") {
|
|
1915
|
-
|
|
1937
|
+
Jn(n) && Un(t, "set-page");
|
|
1916
1938
|
return;
|
|
1917
1939
|
}
|
|
1918
1940
|
n.preventDefault();
|
|
1919
1941
|
let r = n.currentTarget, i = r?.getAttribute("data-formie-page-id"), a = r?.getAttribute("href");
|
|
1920
1942
|
if (!(!i || !a)) {
|
|
1921
|
-
p(t, i),
|
|
1943
|
+
p(t, i), h(e, "formie:page:navigate", {
|
|
1922
1944
|
pageId: i,
|
|
1923
1945
|
href: a
|
|
1924
1946
|
});
|
|
1925
1947
|
try {
|
|
1926
|
-
|
|
1948
|
+
h(e, "formie:page:navigate:after", {
|
|
1927
1949
|
pageId: i,
|
|
1928
1950
|
href: a,
|
|
1929
1951
|
response: await He(a, t, i)
|
|
1930
1952
|
});
|
|
1931
1953
|
} catch (t) {
|
|
1932
|
-
console.error("[formie] Failed to persist page navigation state.", t),
|
|
1954
|
+
console.error("[formie] Failed to persist page navigation state.", t), h(e, "formie:page:navigate:error", {
|
|
1933
1955
|
pageId: i,
|
|
1934
1956
|
href: a,
|
|
1935
1957
|
error: t
|
|
@@ -1940,9 +1962,9 @@ function nr(e, t, n, r, i, a) {
|
|
|
1940
1962
|
n.addEventListener("click", r), a.push(() => {
|
|
1941
1963
|
n.removeEventListener("click", r);
|
|
1942
1964
|
});
|
|
1943
|
-
}), !
|
|
1965
|
+
}), !Bn(t)) {
|
|
1944
1966
|
let e = !1, n = () => {
|
|
1945
|
-
e ||
|
|
1967
|
+
e || Gn(t) || qn(t) || (e = !0, Ue(s, t));
|
|
1946
1968
|
};
|
|
1947
1969
|
window.addEventListener("pagehide", n), window.addEventListener("beforeunload", n), a.push(() => {
|
|
1948
1970
|
window.removeEventListener("pagehide", n), window.removeEventListener("beforeunload", n);
|
|
@@ -1955,35 +1977,35 @@ function nr(e, t, n, r, i, a) {
|
|
|
1955
1977
|
if (t.getAttribute("data-formie-internal-resubmit") !== "true") return;
|
|
1956
1978
|
t.removeAttribute("data-formie-internal-resubmit");
|
|
1957
1979
|
} else t.removeAttribute("data-formie-internal-resubmit");
|
|
1958
|
-
let
|
|
1980
|
+
let u = a.submitter, p = u?.getAttribute("data-formie-action"), _ = t.getAttribute("data-formie-pending-action"), v = t.querySelector("input[name=\"submitAction\"]"), y = p || _ || v?.value || "submit", b = null, x = !1;
|
|
1959
1981
|
try {
|
|
1960
|
-
if (s) b = await
|
|
1982
|
+
if (s) b = await qt({
|
|
1961
1983
|
target: e,
|
|
1962
1984
|
form: t,
|
|
1963
1985
|
bus: r,
|
|
1964
1986
|
validator: i,
|
|
1965
1987
|
validateOnSubmit: Z(t),
|
|
1966
1988
|
action: y,
|
|
1967
|
-
submitter:
|
|
1968
|
-
waitForSubmitDelay:
|
|
1989
|
+
submitter: u,
|
|
1990
|
+
waitForSubmitDelay: Zn,
|
|
1969
1991
|
onRefreshTokensAfterSubmit: async () => {
|
|
1970
|
-
await
|
|
1992
|
+
await ir(e, n, t);
|
|
1971
1993
|
},
|
|
1972
1994
|
dispatchSubmitResult: (t) => {
|
|
1973
|
-
|
|
1995
|
+
h(e, "formie:submit:result", t);
|
|
1974
1996
|
}
|
|
1975
1997
|
});
|
|
1976
1998
|
else {
|
|
1977
|
-
if (
|
|
1999
|
+
if (Kt(t), m(t, u), await Zn(t), b = await nt(t, y, r, {
|
|
1978
2000
|
validator: i,
|
|
1979
2001
|
validateOnSubmit: Z(t),
|
|
1980
2002
|
preflightOnly: !0
|
|
1981
2003
|
}), b.ok) {
|
|
1982
|
-
l(t, y), c = !0,
|
|
2004
|
+
l(t, y), c = !0, Un(t, "submit"), g(null);
|
|
1983
2005
|
let e = !1, n = () => {
|
|
1984
|
-
if (e = !0, c = !1,
|
|
2006
|
+
if (e = !0, c = !1, Wn(t), d(t), i && Z(t)) {
|
|
1985
2007
|
let { scope: e, final: n } = f(t), r = i.submit(n ? t : e, { final: n });
|
|
1986
|
-
r.length > 0 &&
|
|
2008
|
+
r.length > 0 && I(t, {
|
|
1987
2009
|
ok: !1,
|
|
1988
2010
|
stage: "validate",
|
|
1989
2011
|
code: "VALIDATION_FAILED",
|
|
@@ -2005,7 +2027,7 @@ function nr(e, t, n, r, i, a) {
|
|
|
2005
2027
|
x = !0;
|
|
2006
2028
|
return;
|
|
2007
2029
|
}
|
|
2008
|
-
|
|
2030
|
+
I(t, b), h(e, "formie:submit:result", b), Wn(t);
|
|
2009
2031
|
}
|
|
2010
2032
|
} catch (n) {
|
|
2011
2033
|
c = !1, b = {
|
|
@@ -2013,25 +2035,25 @@ function nr(e, t, n, r, i, a) {
|
|
|
2013
2035
|
code: "SUBMIT_ERROR",
|
|
2014
2036
|
message: n instanceof Error ? n.message : "Submission failed.",
|
|
2015
2037
|
formErrors: [n instanceof Error ? n.message : "Submission failed."]
|
|
2016
|
-
},
|
|
2038
|
+
}, I(t, b), h(e, "formie:submit:result", b), Wn(t);
|
|
2017
2039
|
} finally {
|
|
2018
|
-
g(null), !s && !x && !
|
|
2040
|
+
g(null), !s && !x && !Gt(b) && d(t);
|
|
2019
2041
|
}
|
|
2020
2042
|
};
|
|
2021
2043
|
t.addEventListener("submit", _), a.push(() => {
|
|
2022
2044
|
t.removeEventListener("submit", _);
|
|
2023
2045
|
});
|
|
2024
2046
|
}
|
|
2025
|
-
async function
|
|
2047
|
+
async function or(e, t, n) {
|
|
2026
2048
|
if (t.refreshTokens === !1 || !t.staticCache) return;
|
|
2027
|
-
|
|
2028
|
-
let r = t.formHandle || e.dataset.formieHandle, i =
|
|
2049
|
+
Rn(J(t.transport), q(t.mode));
|
|
2050
|
+
let r = t.formHandle || e.dataset.formieHandle, i = Fn(t, e), a = n?.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2029
2051
|
if (!r) return;
|
|
2030
|
-
let o = await
|
|
2031
|
-
!o || !n || (
|
|
2052
|
+
let o = await j(i, r, a);
|
|
2053
|
+
!o || !n || (nr(n, o), h(e, "formie:refresh-tokens:after", o));
|
|
2032
2054
|
}
|
|
2033
|
-
function
|
|
2034
|
-
let e = /* @__PURE__ */ new Map(), t = new
|
|
2055
|
+
function sr() {
|
|
2056
|
+
let e = /* @__PURE__ */ new Map(), t = new L(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = [
|
|
2035
2057
|
"prepare",
|
|
2036
2058
|
"normalize",
|
|
2037
2059
|
"validate",
|
|
@@ -2054,11 +2076,11 @@ function ir() {
|
|
|
2054
2076
|
W.log("Unmount skipped (no mounted state).", { target: Q(t) });
|
|
2055
2077
|
return;
|
|
2056
2078
|
}
|
|
2057
|
-
|
|
2079
|
+
h(t, "formie:unmount:before", { id: i.instance.id }), i.unbinds.forEach((e) => {
|
|
2058
2080
|
e();
|
|
2059
2081
|
}), i.unbinds = [], i.validator?.destroy(), i.validator = null;
|
|
2060
2082
|
for (let e of i.modules) await e.destroy();
|
|
2061
|
-
i.modules = [], i.bus.clear(), e.delete(t),
|
|
2083
|
+
i.modules = [], i.bus.clear(), e.delete(t), h(t, "formie:unmount:after", { id: i.instance.id }), W.log("Unmount complete.", {
|
|
2062
2084
|
id: i.instance.id,
|
|
2063
2085
|
target: Q(t)
|
|
2064
2086
|
});
|
|
@@ -2079,61 +2101,61 @@ function ir() {
|
|
|
2079
2101
|
id: c.instance.id,
|
|
2080
2102
|
target: Q(r)
|
|
2081
2103
|
}), c.instance;
|
|
2082
|
-
let l = new
|
|
2104
|
+
let l = new Ie(), d = [], f = r?.id || `formie-${e.size + 1}`, p = K(r), m = {
|
|
2083
2105
|
...p,
|
|
2084
2106
|
...o,
|
|
2085
2107
|
mode: q(o.mode ?? p.mode),
|
|
2086
2108
|
transport: J(o.transport ?? p.transport)
|
|
2087
|
-
},
|
|
2109
|
+
}, g = ve(m.compatibility);
|
|
2088
2110
|
if (m.mode !== "server-rendered" && !Y(r)) throw Error(`Formie ${m.mode} mode is not implemented yet in the browser client.`);
|
|
2089
|
-
let
|
|
2090
|
-
m.staticCache = o.staticCache ??
|
|
2091
|
-
let
|
|
2092
|
-
...
|
|
2093
|
-
...
|
|
2094
|
-
} : null,
|
|
2111
|
+
let v = await rr(r, m), b = Y(r);
|
|
2112
|
+
m.staticCache = o.staticCache ?? An(b ? b.dataset : r.dataset);
|
|
2113
|
+
let x = $n(r, b), ee = v || x ? {
|
|
2114
|
+
...v || {},
|
|
2115
|
+
...x || {}
|
|
2116
|
+
} : null, te = ee?.theme, S = {}, C = (ee?.modules || []).filter((e) => !!e?.id && !!e?.type);
|
|
2095
2117
|
W.log("Resolved mount payload.", {
|
|
2096
2118
|
target: Q(r),
|
|
2097
|
-
hasRenderPayload: !!
|
|
2098
|
-
hasEmbeddedPayload: !!
|
|
2119
|
+
hasRenderPayload: !!v,
|
|
2120
|
+
hasEmbeddedPayload: !!x,
|
|
2099
2121
|
moduleCount: C.length
|
|
2100
2122
|
});
|
|
2101
|
-
let w =
|
|
2102
|
-
live:
|
|
2103
|
-
errorAriaLive:
|
|
2104
|
-
errorMessage:
|
|
2123
|
+
let w = ne(r, te, b), T = b ? new mt(b, {
|
|
2124
|
+
live: zn(b.dataset.formieValidationOnFocus),
|
|
2125
|
+
errorAriaLive: Te(b),
|
|
2126
|
+
errorMessage: b.dataset.formieErrorMessage || "",
|
|
2105
2127
|
fieldContainerErrorClass: w.fieldLayoutError || [],
|
|
2106
2128
|
inputErrorClass: w.fieldControlError || [],
|
|
2107
2129
|
messagesClass: w.fieldErrors || [],
|
|
2108
2130
|
messageClass: w.fieldError || []
|
|
2109
2131
|
}) : null;
|
|
2110
|
-
if (
|
|
2111
|
-
let e =
|
|
2132
|
+
if (b && T) {
|
|
2133
|
+
let e = b;
|
|
2112
2134
|
e.formieValidation = T, S.validation = T;
|
|
2113
2135
|
let t = {
|
|
2114
2136
|
validator: T,
|
|
2115
2137
|
addValidator: T.addValidator.bind(T),
|
|
2116
2138
|
removeValidator: T.removeValidator.bind(T)
|
|
2117
2139
|
};
|
|
2118
|
-
|
|
2140
|
+
h(b, "formie:validator:ready", t), h(r, "formie:validator:ready", t);
|
|
2119
2141
|
}
|
|
2120
|
-
|
|
2121
|
-
let E = await
|
|
2142
|
+
b && (ln(b), m.themeConfig && typeof m.themeConfig == "object" && b.setAttribute("data-formie-theme-config", JSON.stringify(m.themeConfig)), m.theme && m.theme !== "formie" && b.setAttribute("data-formie-frontend-theme", m.theme), (v || m.endpoint || r.dataset.formieEndpoint) && Ln(r, b, m), m.mode === "server-rendered" && Pe(b) && (Ne(b), Fe(b)), y(b)), Object.keys(w).length && h(r, "formie:theme:applied", { hasClasses: !0 });
|
|
2143
|
+
let E = await sn(C, {
|
|
2122
2144
|
registry: t,
|
|
2123
2145
|
matchContext: {
|
|
2124
2146
|
root: r,
|
|
2125
|
-
form:
|
|
2147
|
+
form: b,
|
|
2126
2148
|
mode: m.mode
|
|
2127
2149
|
},
|
|
2128
2150
|
setupContext: {
|
|
2129
2151
|
formId: f,
|
|
2130
2152
|
root: r,
|
|
2131
|
-
form:
|
|
2153
|
+
form: b,
|
|
2132
2154
|
target: r,
|
|
2133
2155
|
scope: "form",
|
|
2134
2156
|
state: S,
|
|
2135
2157
|
on: (e, t) => l.on(e, t),
|
|
2136
|
-
emit: (e, t) => (
|
|
2158
|
+
emit: (e, t) => (h(r, e, t), l.emitSafe(e, t).then((t) => {
|
|
2137
2159
|
t.failed.length > 0 && W.warn("Lifecycle listeners failed.", {
|
|
2138
2160
|
eventName: e,
|
|
2139
2161
|
failed: t.failed.length
|
|
@@ -2153,34 +2175,34 @@ function ir() {
|
|
|
2153
2175
|
id: f,
|
|
2154
2176
|
target: Q(r),
|
|
2155
2177
|
action: e
|
|
2156
|
-
}), !
|
|
2178
|
+
}), !b) return {
|
|
2157
2179
|
ok: !1,
|
|
2158
2180
|
code: "FORM_NOT_FOUND",
|
|
2159
2181
|
message: "No form element found for mount target.",
|
|
2160
2182
|
formErrors: ["No form element found for mount target."]
|
|
2161
2183
|
};
|
|
2162
|
-
let t =
|
|
2163
|
-
if (t && (t.value = e),
|
|
2184
|
+
let t = b.querySelector("input[name=\"submitAction\"]");
|
|
2185
|
+
if (t && (t.value = e), b.getAttribute("data-formie-loading") === "true") return {
|
|
2164
2186
|
ok: !1,
|
|
2165
2187
|
code: "SUBMIT_IN_PROGRESS",
|
|
2166
2188
|
message: "Submission already in progress.",
|
|
2167
2189
|
formErrors: []
|
|
2168
2190
|
};
|
|
2169
|
-
let n =
|
|
2191
|
+
let n = b.querySelector(`[data-formie-action="${e}"]`), i = await qt({
|
|
2170
2192
|
id: f,
|
|
2171
2193
|
target: r,
|
|
2172
|
-
form:
|
|
2194
|
+
form: b,
|
|
2173
2195
|
bus: l,
|
|
2174
2196
|
validator: T,
|
|
2175
|
-
validateOnSubmit: Z(
|
|
2197
|
+
validateOnSubmit: Z(b),
|
|
2176
2198
|
action: e,
|
|
2177
2199
|
submitter: n,
|
|
2178
|
-
waitForSubmitDelay:
|
|
2200
|
+
waitForSubmitDelay: Zn,
|
|
2179
2201
|
onRefreshTokensAfterSubmit: async () => {
|
|
2180
|
-
await
|
|
2202
|
+
await ir(r, m, b);
|
|
2181
2203
|
},
|
|
2182
2204
|
dispatchSubmitResult: (e) => {
|
|
2183
|
-
|
|
2205
|
+
h(r, "formie:submit:result", e);
|
|
2184
2206
|
}
|
|
2185
2207
|
});
|
|
2186
2208
|
return W.log("Submit completed.", {
|
|
@@ -2196,62 +2218,62 @@ function ir() {
|
|
|
2196
2218
|
},
|
|
2197
2219
|
on: (e, t) => l.on(e, t)
|
|
2198
2220
|
};
|
|
2199
|
-
|
|
2221
|
+
b && (we({
|
|
2200
2222
|
target: r,
|
|
2201
|
-
form:
|
|
2223
|
+
form: b,
|
|
2202
2224
|
validatorDetail: T ? {
|
|
2203
2225
|
validator: T,
|
|
2204
2226
|
addValidator: T.addValidator.bind(T),
|
|
2205
2227
|
removeValidator: T.removeValidator.bind(T)
|
|
2206
2228
|
} : null,
|
|
2207
|
-
options:
|
|
2229
|
+
options: g,
|
|
2208
2230
|
unbinds: d
|
|
2209
|
-
}),
|
|
2231
|
+
}), Ce({
|
|
2210
2232
|
target: r,
|
|
2211
|
-
form:
|
|
2233
|
+
form: b,
|
|
2212
2234
|
instance: D,
|
|
2213
|
-
options:
|
|
2235
|
+
options: g,
|
|
2214
2236
|
unbinds: d
|
|
2215
|
-
})),
|
|
2237
|
+
})), b && (ar(r, b, m, l, T, d), T && (d.push(_(b, T, r)), d.push(bn(b))), await or(r, m, b)), i.forEach((e) => {
|
|
2216
2238
|
let t = l.on(`formie:stage:${e}:before`, async (t) => {
|
|
2217
|
-
|
|
2239
|
+
h(r, `formie:stage:${e}:before`, t);
|
|
2218
2240
|
}), n = l.on(`formie:stage:${e}:before`, async (e) => {
|
|
2219
2241
|
for (let t of E) t.onBeforeStage && await t.onBeforeStage(e);
|
|
2220
2242
|
}), i = l.on(`formie:stage:${e}:after`, async (t) => {
|
|
2221
|
-
|
|
2243
|
+
h(r, `formie:stage:${e}:after`, t);
|
|
2222
2244
|
}), a = l.on(`formie:stage:${e}:after`, async (e) => {
|
|
2223
2245
|
let t = e;
|
|
2224
2246
|
for (let e of E) e.onAfterStage && await e.onAfterStage(t, t.result);
|
|
2225
2247
|
});
|
|
2226
2248
|
d.push(t, n, i, a);
|
|
2227
2249
|
});
|
|
2228
|
-
let
|
|
2229
|
-
|
|
2230
|
-
}),
|
|
2231
|
-
|
|
2232
|
-
}),
|
|
2233
|
-
|
|
2234
|
-
}),
|
|
2235
|
-
|
|
2250
|
+
let re = l.on("formie:submit:before", async (e) => {
|
|
2251
|
+
h(r, "formie:submit:before", e);
|
|
2252
|
+
}), ie = l.on("formie:submit:after", async (e) => {
|
|
2253
|
+
h(r, "formie:submit:after", e);
|
|
2254
|
+
}), ae = l.on("formie:submit:final:before", async (e) => {
|
|
2255
|
+
h(r, "formie:submit:final:before", e);
|
|
2256
|
+
}), oe = l.on("formie:submit:final:after", async (e) => {
|
|
2257
|
+
h(r, "formie:submit:final:after", e);
|
|
2236
2258
|
});
|
|
2237
|
-
return d.push(
|
|
2259
|
+
return d.push(re, ie, ae, oe), e.set(r, {
|
|
2238
2260
|
options: m,
|
|
2239
2261
|
bus: l,
|
|
2240
|
-
form:
|
|
2262
|
+
form: b,
|
|
2241
2263
|
validator: T,
|
|
2242
2264
|
modules: E,
|
|
2243
2265
|
unbinds: d,
|
|
2244
2266
|
instance: D
|
|
2245
|
-
}),
|
|
2267
|
+
}), h(r, "formie:mount:after", {
|
|
2246
2268
|
id: f,
|
|
2247
2269
|
mode: m.mode
|
|
2248
|
-
}), W.log("Mount complete.", {
|
|
2270
|
+
}), b instanceof HTMLFormElement && u(b), W.log("Mount complete.", {
|
|
2249
2271
|
id: f,
|
|
2250
2272
|
target: Q(r),
|
|
2251
2273
|
mode: m.mode
|
|
2252
2274
|
}), D;
|
|
2253
2275
|
}, s = (t, r) => {
|
|
2254
|
-
if (!r.autoVisible ||
|
|
2276
|
+
if (!r.autoVisible || er(t) || typeof IntersectionObserver > "u") return o(t, r);
|
|
2255
2277
|
if (e.has(t)) return Promise.resolve(e.get(t)?.instance || null);
|
|
2256
2278
|
if (n.has(t)) return W.log("Mount deferred (already waiting visibility).", { target: Q(t) }), Promise.resolve(null);
|
|
2257
2279
|
let i = new IntersectionObserver((e) => {
|
|
@@ -2278,15 +2300,15 @@ function ir() {
|
|
|
2278
2300
|
...r.options,
|
|
2279
2301
|
...n
|
|
2280
2302
|
};
|
|
2281
|
-
let i =
|
|
2282
|
-
return r.validator && (r.validator.config.fieldContainerErrorClass = i.fieldLayoutError || [], r.validator.config.inputErrorClass = i.fieldControlError || [], r.validator.config.messagesClass = i.fieldErrors || [], r.validator.config.messageClass = i.fieldError || []), Object.keys(i).length &&
|
|
2303
|
+
let i = ne(t, n.payload?.theme || r.options.payload?.theme || $n(t, r.form)?.theme, r.form);
|
|
2304
|
+
return r.validator && (r.validator.config.fieldContainerErrorClass = i.fieldLayoutError || [], r.validator.config.inputErrorClass = i.fieldControlError || [], r.validator.config.messagesClass = i.fieldErrors || [], r.validator.config.messageClass = i.fieldError || []), Object.keys(i).length && h(t, "formie:theme:applied", {
|
|
2283
2305
|
hasClasses: !0,
|
|
2284
2306
|
reason: "update"
|
|
2285
2307
|
}), r.instance;
|
|
2286
2308
|
},
|
|
2287
2309
|
getInstance: (t) => e.get(t)?.instance || null,
|
|
2288
2310
|
refreshForCache: async (t) => {
|
|
2289
|
-
|
|
2311
|
+
jn("refreshForCache", "Global `Formie.refreshForCache()` has been deprecated. Use built-in static-cache token refresh handling instead.");
|
|
2290
2312
|
let n = null;
|
|
2291
2313
|
if (n = typeof t == "string" ? document.getElementById(t) || document.querySelector(`[data-formie-form-id="${t}"]`) : t, !n) {
|
|
2292
2314
|
W.warn("refreshForCache target not found.", { targetOrId: t });
|
|
@@ -2297,13 +2319,13 @@ function ir() {
|
|
|
2297
2319
|
W.warn("refreshForCache found no form element for target.", { target: Q(n) });
|
|
2298
2320
|
return;
|
|
2299
2321
|
}
|
|
2300
|
-
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s =
|
|
2322
|
+
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s = Fn(a, n), c = i.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2301
2323
|
if (!o) {
|
|
2302
2324
|
W.warn("refreshForCache found no form handle for target.", { target: Q(n) });
|
|
2303
2325
|
return;
|
|
2304
2326
|
}
|
|
2305
|
-
let l = await
|
|
2306
|
-
l && (
|
|
2327
|
+
let l = await j(s, o, c);
|
|
2328
|
+
l && (nr(i, l), h(n, "formie:refresh-tokens:after", l));
|
|
2307
2329
|
},
|
|
2308
2330
|
registerModule: (e, n) => t.register(e, n),
|
|
2309
2331
|
unregisterModule: (e) => {
|
|
@@ -2344,7 +2366,7 @@ function ir() {
|
|
|
2344
2366
|
subtree: !0
|
|
2345
2367
|
}), () => {
|
|
2346
2368
|
i.disconnect(), W.log("Observer stopped."), n.forEach((e, t) => {
|
|
2347
|
-
|
|
2369
|
+
tr(t, r) && (e(), n.delete(t));
|
|
2348
2370
|
});
|
|
2349
2371
|
let t = [];
|
|
2350
2372
|
r instanceof Element && r.matches(U) && t.push(r), r.querySelectorAll(U).forEach((e) => {
|
|
@@ -2358,9 +2380,9 @@ function ir() {
|
|
|
2358
2380
|
}
|
|
2359
2381
|
//#endregion
|
|
2360
2382
|
//#region src/js/core/hydrate-modules.ts
|
|
2361
|
-
var
|
|
2362
|
-
async function
|
|
2363
|
-
let t = e.root, n = e.form ?? (t instanceof HTMLFormElement ? t : t.closest("form")), r = e.modules ?? [], i = e.mode ?? "server-rendered", a = e.registry ?? new
|
|
2383
|
+
var cr = S("general", "module-hydrator");
|
|
2384
|
+
async function lr(e) {
|
|
2385
|
+
let t = e.root, n = e.form ?? (t instanceof HTMLFormElement ? t : t.closest("form")), r = e.modules ?? [], i = e.mode ?? "server-rendered", a = e.registry ?? new L(), o = new Ie(), s = await sn(r, {
|
|
2364
2386
|
registry: a,
|
|
2365
2387
|
setupContext: {
|
|
2366
2388
|
formId: n?.id || t.id || "formie-modules",
|
|
@@ -2381,13 +2403,13 @@ async function or(e) {
|
|
|
2381
2403
|
mode: i
|
|
2382
2404
|
}
|
|
2383
2405
|
});
|
|
2384
|
-
return
|
|
2406
|
+
return cr.log("Hydrated module manifest.", {
|
|
2385
2407
|
moduleCount: r.length,
|
|
2386
2408
|
instanceCount: s.length,
|
|
2387
2409
|
mode: i
|
|
2388
2410
|
}), {
|
|
2389
2411
|
destroy: async () => {
|
|
2390
|
-
await
|
|
2412
|
+
await ur(s), o.clear();
|
|
2391
2413
|
},
|
|
2392
2414
|
on: (e, t) => o.on(e, t),
|
|
2393
2415
|
emit: async (e, t) => {
|
|
@@ -2400,11 +2422,11 @@ async function or(e) {
|
|
|
2400
2422
|
getRegisteredModules: () => a.getAll()
|
|
2401
2423
|
};
|
|
2402
2424
|
}
|
|
2403
|
-
async function
|
|
2425
|
+
async function ur(e) {
|
|
2404
2426
|
for (let t of e) try {
|
|
2405
2427
|
await t.destroy();
|
|
2406
2428
|
} catch (e) {
|
|
2407
|
-
console.error("[formie] Failed to destroy module instance.", e),
|
|
2429
|
+
console.error("[formie] Failed to destroy module instance.", e), cr.warn("Failed destroying module instance.", { error: e });
|
|
2408
2430
|
}
|
|
2409
2431
|
}
|
|
2410
2432
|
//#endregion
|
|
@@ -2412,41 +2434,41 @@ async function sr(e) {
|
|
|
2412
2434
|
function $(e) {
|
|
2413
2435
|
return e instanceof Element;
|
|
2414
2436
|
}
|
|
2415
|
-
function
|
|
2437
|
+
function dr(e) {
|
|
2416
2438
|
return e.ok;
|
|
2417
2439
|
}
|
|
2418
|
-
function
|
|
2440
|
+
function fr(e) {
|
|
2419
2441
|
return typeof e == "string" ? `selector "${e}"` : $(e) ? `element "${e.tagName.toLowerCase()}"` : "provided element collection";
|
|
2420
2442
|
}
|
|
2421
|
-
function
|
|
2443
|
+
function pr(e) {
|
|
2422
2444
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2423
2445
|
for (let r of e) !$(r) || t.has(r) || (t.add(r), n.push(r));
|
|
2424
2446
|
return n;
|
|
2425
2447
|
}
|
|
2426
|
-
function
|
|
2427
|
-
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : $(e) ? [e] :
|
|
2448
|
+
function mr(e) {
|
|
2449
|
+
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : $(e) ? [e] : pr(e);
|
|
2428
2450
|
}
|
|
2429
|
-
function
|
|
2451
|
+
function hr() {
|
|
2430
2452
|
return document.readyState === "loading" ? new Promise((e) => {
|
|
2431
2453
|
document.addEventListener("DOMContentLoaded", () => e(), { once: !0 });
|
|
2432
2454
|
}) : Promise.resolve();
|
|
2433
2455
|
}
|
|
2434
|
-
async function
|
|
2435
|
-
let t =
|
|
2436
|
-
return t.length > 0 || typeof e != "string" ? t : (await
|
|
2456
|
+
async function gr(e) {
|
|
2457
|
+
let t = mr(e);
|
|
2458
|
+
return t.length > 0 || typeof e != "string" ? t : (await hr(), mr(e));
|
|
2437
2459
|
}
|
|
2438
|
-
function
|
|
2460
|
+
function _r(e) {
|
|
2439
2461
|
return typeof e == "string" ? document : $(e) ? e.getRootNode() : document;
|
|
2440
2462
|
}
|
|
2441
|
-
function
|
|
2463
|
+
function vr(e) {
|
|
2442
2464
|
let { element: t, observe: n, allowEmpty: r, client: i, onReady: a, onResult: o, onSuccess: s, onError: c, onEvent: l, ...u } = e;
|
|
2443
2465
|
return {
|
|
2444
2466
|
mode: "server-rendered",
|
|
2445
2467
|
...u
|
|
2446
2468
|
};
|
|
2447
2469
|
}
|
|
2448
|
-
async function
|
|
2449
|
-
let i = [], o =
|
|
2470
|
+
async function yr(e, t, n, r) {
|
|
2471
|
+
let i = [], o = vr(e);
|
|
2450
2472
|
for (let s of r) {
|
|
2451
2473
|
let r = n.get(s);
|
|
2452
2474
|
if (r) {
|
|
@@ -2456,7 +2478,7 @@ async function gr(e, t, n, r) {
|
|
|
2456
2478
|
let c = await t.mount(s, o), l = [];
|
|
2457
2479
|
if (e.onReady?.(c), l.push(c.on("formie:submit:result", (t) => {
|
|
2458
2480
|
let n = t;
|
|
2459
|
-
e.onResult?.(n, c),
|
|
2481
|
+
e.onResult?.(n, c), dr(n) ? e.onSuccess?.(n, c) : e.onError?.(n, c);
|
|
2460
2482
|
})), e.onEvent) for (let t of a) l.push(c.on(t, (n) => {
|
|
2461
2483
|
e.onEvent?.({
|
|
2462
2484
|
name: t,
|
|
@@ -2470,11 +2492,11 @@ async function gr(e, t, n, r) {
|
|
|
2470
2492
|
}
|
|
2471
2493
|
return i;
|
|
2472
2494
|
}
|
|
2473
|
-
async function
|
|
2474
|
-
let t = e.client ??
|
|
2475
|
-
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${
|
|
2476
|
-
await
|
|
2477
|
-
let i = e.observe ? t.observe(
|
|
2495
|
+
async function br(e) {
|
|
2496
|
+
let t = e.client ?? sr(), n = /* @__PURE__ */ new Map(), r = await gr(e.element);
|
|
2497
|
+
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${fr(e.element)}.`);
|
|
2498
|
+
await yr(e, t, n, r);
|
|
2499
|
+
let i = e.observe ? t.observe(_r(e.element)) : null;
|
|
2478
2500
|
return {
|
|
2479
2501
|
client: t,
|
|
2480
2502
|
get instances() {
|
|
@@ -2485,8 +2507,8 @@ async function _r(e) {
|
|
|
2485
2507
|
return r ? n.get(r)?.instance ?? t.getInstance(r) : null;
|
|
2486
2508
|
},
|
|
2487
2509
|
async rescan() {
|
|
2488
|
-
let r =
|
|
2489
|
-
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) :
|
|
2510
|
+
let r = mr(e.element);
|
|
2511
|
+
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) : yr(e, t, n, r);
|
|
2490
2512
|
},
|
|
2491
2513
|
async destroy() {
|
|
2492
2514
|
i?.();
|
|
@@ -2496,4 +2518,4 @@ async function _r(e) {
|
|
|
2496
2518
|
};
|
|
2497
2519
|
}
|
|
2498
2520
|
//#endregion
|
|
2499
|
-
export { a as FORMIE_HTML_EVENT_NAMES, mt as FormieValidator,
|
|
2521
|
+
export { a as FORMIE_HTML_EVENT_NAMES, mt as FormieValidator, ge as LEGACY_FORMIE_DOM_EVENT_BRIDGES, _e as LEGACY_FORMIE_VALIDATOR_EVENT_BRIDGES, L as ModuleRegistry, Ce as bindLegacyDomEventCompatibility, we as bindLegacyValidatorCompatibility, pe as buildFieldValueRegistry, S as createDebug, sr as createFormieClient, ee as debugLog, te as debugWarn, he as defineAddressModule, se as defineCaptchaModule, oe as definePassiveCaptchaModule, v as definePaymentModule, ue as fieldKeyToInputName, br as formie, i as getFieldModuleEventName, ae as getFormieTranslations, r as getGlobalModuleLifecycleEventName, e as getScopedModuleLifecycleEventName, lr as hydrateFormieModules, ce as inputNameToFieldKey, x as isFormieDebugEnabled, re as mergeFormieTranslations, le as normalizeFieldKey, o as normalizeFormieEventName, de as parseFieldReference, me as resolveFieldReferenceFromFormData, fe as resolveFieldReferenceLive, ve as resolveLegacyCompatibilityOptions, b as setFormieDebugEnabled, ie as setFormieTranslations, D as t, t as toDomEventName, E as translate };
|