@verbb/formie-browser 1.0.6 → 1.0.8
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 +23 -0
- package/dist/chunks/_survey-presentations-CFsgToRT.js +4 -0
- package/dist/chunks/{address-finder-yXU5yMjG.js → address-finder-k7_BXaRe.js} +1 -1
- package/dist/chunks/{api-DMK8NSUI.js → api-BUb6P-xu.js} +57 -51
- package/dist/chunks/{api-CmwLRq_n.js → api-C8wyLC-s.js} +235 -193
- package/dist/chunks/{bpoint-DSjqRv63.js → bpoint-CwSw_p7A.js} +1 -1
- package/dist/chunks/{captcha-eu-CWJb64_j.js → captcha-eu-CGm8Lbrj.js} +2 -2
- package/dist/chunks/{conditions-DjZOtHfS.js → conditions-B6_nzpeE.js} +95 -83
- package/dist/chunks/{eway-D3ctTbEk.js → eway-B30BMlDp.js} +2 -2
- package/dist/chunks/{friendly-captcha-v1-ByXzENYZ.js → friendly-captcha-v1-C_2reOXr.js} +1 -1
- package/dist/chunks/{friendly-captcha-v2-BPdlmhQu.js → friendly-captcha-v2-CLSAbkqx.js} +1 -1
- package/dist/chunks/{go-cardless-BwASSYSK.js → go-cardless-BiF3iLel.js} +1 -1
- package/dist/chunks/{google-address-OhKilPWE.js → google-address-BH3Zhi06.js} +1 -1
- package/dist/chunks/{hcaptcha-CdCd9oEi.js → hcaptcha-CGLAmgjO.js} +2 -2
- package/dist/chunks/{loqate-Cp2zvwpE.js → loqate-CJPzBmSm.js} +1 -1
- package/dist/chunks/{mollie-COG-ko2D.js → mollie-D__SwtcH.js} +1 -1
- package/dist/chunks/{moneris-CMH8PlRc.js → moneris-KJS1BKx7.js} +1 -1
- package/dist/chunks/{opayo-D2jsR5vh.js → opayo-A_LIkc-v.js} +4 -4
- package/dist/chunks/{paddle-DxF88RfC.js → paddle-BjbOOb0m.js} +2 -2
- package/dist/chunks/{paypal-b5pnwrA2.js → paypal-CyjHIV8v.js} +2 -2
- package/dist/chunks/{payway-BJYu9DIR.js → payway-a_cyrr3j.js} +2 -2
- package/dist/chunks/{recaptcha-enterprise-BSwi8IVX.js → recaptcha-enterprise-XPId5-bS.js} +19 -20
- package/dist/chunks/{recaptcha-shared-B4zAescW.js → recaptcha-shared-CLYJvojk.js} +15 -3
- package/dist/chunks/{recaptcha-v2-checkbox-CnDQmsKa.js → recaptcha-v2-checkbox-Cy-0PEPc.js} +2 -2
- package/dist/chunks/{recaptcha-v2-invisible-Cz5uIlp-.js → recaptcha-v2-invisible-BwRH540O.js} +2 -2
- package/dist/chunks/recaptcha-v3-No4Ykrhk.js +28 -0
- package/dist/chunks/scripts-CbQ7agX3.js +30 -0
- package/dist/chunks/{snaptcha-vz1RnZ15.js → snaptcha-DKx98oon.js} +1 -1
- package/dist/chunks/{square-BP8RWAKB.js → square-Bga6WXHV.js} +2 -2
- package/dist/chunks/{stripe-MihN63uC.js → stripe-BlqVocl3.js} +2 -2
- package/dist/chunks/{summary-D3AjxpYN.js → summary-Dks0gXS3.js} +42 -38
- package/dist/chunks/survey-likert-DmJ3klhP.js +20 -0
- package/dist/chunks/survey-rank-DeUenftw.js +127 -0
- package/dist/chunks/survey-rating-BPUYDgBJ.js +88 -0
- package/dist/chunks/{turnstile-D_Pi1CKM.js → turnstile-DJakPzQD.js} +3 -3
- package/dist/css/formie-theme.css +1 -0
- package/dist/css/theme/fields/_survey-presentations.css +396 -0
- package/dist/index.js +651 -597
- 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/error-aria-live.d.ts +6 -0
- package/dist/js/core/error-aria-live.d.ts.map +1 -0
- 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-result-state.d.ts.map +1 -1
- package/dist/js/core/submit-result-ui.d.ts.map +1 -1
- package/dist/js/modules/captchas/factories.d.ts.map +1 -1
- package/dist/js/modules/captchas/host.d.ts +1 -0
- package/dist/js/modules/captchas/host.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-enterprise.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-shared.d.ts +1 -0
- package/dist/js/modules/captchas/recaptcha-shared.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-v3.d.ts.map +1 -1
- package/dist/js/modules/captchas/turnstile.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions/effects.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/form-started-at.d.ts +2 -0
- package/dist/js/utils/form-started-at.d.ts.map +1 -0
- package/dist/js/utils/scripts.d.ts.map +1 -1
- package/dist/js/utils/unload-warning.d.ts.map +1 -1
- package/dist/js/validation/enter-key-guard.d.ts +2 -0
- package/dist/js/validation/enter-key-guard.d.ts.map +1 -0
- package/dist/js/validation/types.d.ts +1 -0
- package/dist/js/validation/types.d.ts.map +1 -1
- package/dist/js/validation/validator.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/css/formie-theme.css +1 -0
- package/src/css/theme/fields/_survey-presentations.css +396 -0
- package/src/js/contracts/schema.ts +6 -0
- package/src/js/core/create-formie-client.ts +21 -1
- package/src/js/core/error-aria-live.ts +45 -0
- package/src/js/core/page-client-event.ts +86 -18
- package/src/js/core/submit-result-state.ts +10 -2
- package/src/js/core/submit-result-ui.ts +8 -4
- package/src/js/modules/captchas/factories.ts +4 -0
- package/src/js/modules/captchas/host.ts +14 -2
- package/src/js/modules/captchas/recaptcha-enterprise.ts +14 -11
- package/src/js/modules/captchas/recaptcha-shared.ts +14 -0
- package/src/js/modules/captchas/recaptcha-v3.ts +7 -4
- package/src/js/modules/captchas/turnstile.ts +9 -3
- package/src/js/modules/fields/conditions/effects.ts +42 -0
- 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/form-started-at.ts +25 -0
- package/src/js/utils/scripts.ts +16 -0
- package/src/js/utils/unload-warning.ts +1 -0
- package/src/js/validation/enter-key-guard.ts +63 -0
- package/src/js/validation/types.ts +1 -0
- package/src/js/validation/validator.ts +14 -5
- package/dist/chunks/recaptcha-v3-BtbbP111.js +0 -27
- package/dist/chunks/scripts-6CYSUGKQ.js +0 -24
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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, i as
|
|
3
|
-
import { a as
|
|
4
|
-
import { n as te, r as
|
|
5
|
-
import { t as
|
|
6
|
-
import { a as
|
|
7
|
-
import { n as ae, t as oe } from "./chunks/api-
|
|
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-C8wyLC-s.js";
|
|
3
|
+
import { a as b, i as x, n as S, r as ee, t as C } from "./chunks/debug-BV0DvdHx.js";
|
|
4
|
+
import { n as te, r as w, t as T } from "./chunks/theme-classes-Tv7q7ToE.js";
|
|
5
|
+
import { t as E } from "./chunks/http-D-JExro7.js";
|
|
6
|
+
import { a as D, i as O, n as ne, r as re, t as ie } from "./chunks/i18n-BY1ds1BL.js";
|
|
7
|
+
import { n as ae, t as oe } from "./chunks/api-BUb6P-xu.js";
|
|
8
8
|
import { n as se, r as ce, t as le } from "./chunks/field-references.keys-58ZSTrCW.js";
|
|
9
9
|
import { i as ue, n as de, r as fe, t as pe } from "./chunks/field-references.resolver-CHwn0G0L.js";
|
|
10
10
|
import { t as me } from "./chunks/api-sPqGbOww.js";
|
|
@@ -149,30 +149,30 @@ function Se({ target: e, form: n, instance: r, options: i, unbinds: a }) {
|
|
|
149
149
|
}
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region src/js/compatibility/validator-adapter.ts
|
|
152
|
-
function
|
|
152
|
+
function k(e, t, n) {
|
|
153
153
|
e.dispatchEvent(new CustomEvent(t, {
|
|
154
154
|
bubbles: !0,
|
|
155
155
|
detail: n
|
|
156
156
|
}));
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function A(e, t) {
|
|
159
159
|
return !!e && typeof e == "object" && e.validator === t;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function Ce({ 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,
|
|
165
165
|
form: t,
|
|
166
166
|
target: e
|
|
167
167
|
};
|
|
168
|
-
|
|
168
|
+
k(document, "formieValidatorInitialized", c);
|
|
169
169
|
let l = (e) => {
|
|
170
|
-
!(e instanceof CustomEvent) || !
|
|
170
|
+
!(e instanceof CustomEvent) || !A(e.detail, a) || k(document, "formieValidatorDestroyed", {
|
|
171
171
|
...c,
|
|
172
172
|
...e.detail
|
|
173
173
|
});
|
|
174
174
|
}, u = (n) => {
|
|
175
|
-
!(n instanceof CustomEvent) || !
|
|
175
|
+
!(n instanceof CustomEvent) || !A(n.detail, a) || !(n.target instanceof Element) || t.contains(n.target) && k(n.target, "formieValidatorShowError", {
|
|
176
176
|
...n.detail,
|
|
177
177
|
addValidator: o,
|
|
178
178
|
removeValidator: s,
|
|
@@ -180,7 +180,7 @@ function we({ target: e, form: t, validatorDetail: n, options: r, unbinds: i })
|
|
|
180
180
|
target: e
|
|
181
181
|
});
|
|
182
182
|
}, d = (n) => {
|
|
183
|
-
!(n instanceof CustomEvent) || !
|
|
183
|
+
!(n instanceof CustomEvent) || !A(n.detail, a) || !(n.target instanceof Element) || t.contains(n.target) && k(n.target, "formieValidatorClearError", {
|
|
184
184
|
...n.detail,
|
|
185
185
|
addValidator: o,
|
|
186
186
|
removeValidator: s,
|
|
@@ -193,47 +193,58 @@ function we({ target: e, form: t, validatorDetail: n, options: r, unbinds: i })
|
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
195
|
//#endregion
|
|
196
|
-
//#region src/js/core/
|
|
197
|
-
function
|
|
198
|
-
e.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
196
|
+
//#region src/js/core/error-aria-live.ts
|
|
197
|
+
function we(e) {
|
|
198
|
+
let t = (e.dataset.formieErrorAriaLive || "polite").trim().toLowerCase();
|
|
199
|
+
return t === "assertive" || t === "off" ? t : "polite";
|
|
200
|
+
}
|
|
201
|
+
function Te(e, t) {
|
|
202
|
+
return e === "off" ? null : t ? e : "polite";
|
|
203
|
+
}
|
|
204
|
+
function Ee(e) {
|
|
205
|
+
return e === "off" ? null : e;
|
|
206
|
+
}
|
|
207
|
+
function De(e, t) {
|
|
208
|
+
if (t) {
|
|
209
|
+
e.setAttribute("aria-live", t), e.setAttribute("aria-atomic", "true");
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
e.removeAttribute("aria-live"), e.removeAttribute("aria-atomic");
|
|
202
213
|
}
|
|
203
214
|
//#endregion
|
|
204
215
|
//#region src/js/core/validation-focus.ts
|
|
205
|
-
function
|
|
216
|
+
function Oe(e, t) {
|
|
206
217
|
let n = (e.getAttribute("aria-describedby") || "").trim(), r = n ? n.split(/\s+/) : [];
|
|
207
218
|
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
208
219
|
}
|
|
209
|
-
function
|
|
220
|
+
function ke(e) {
|
|
210
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;
|
|
211
222
|
}
|
|
212
|
-
function
|
|
223
|
+
function Ae(e) {
|
|
213
224
|
return e.querySelector("[aria-invalid=\"true\"]") || e.querySelector("input:not([type=\"hidden\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])");
|
|
214
225
|
}
|
|
215
|
-
function
|
|
226
|
+
function je(e) {
|
|
216
227
|
return e.querySelector("[data-formie-message-error], [data-formie-error-container], [data-formie-errors]");
|
|
217
228
|
}
|
|
218
|
-
function
|
|
229
|
+
function Me(e) {
|
|
219
230
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
220
231
|
let n = t;
|
|
221
232
|
if (!(n.getAttribute("data-formie-field-has-error") === "true" || n.querySelector("[data-formie-field-error]") !== null)) return;
|
|
222
|
-
n.setAttribute("data-formie-field-has-error", "true"),
|
|
233
|
+
n.setAttribute("data-formie-field-has-error", "true"), T(n, e, "fieldLayoutError");
|
|
223
234
|
let r = n.querySelector("[data-formie-field-errors]")?.id || "", i = n.querySelector("[data-formie-field-error]")?.id || "";
|
|
224
235
|
n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
225
236
|
let n = t;
|
|
226
|
-
n.setAttribute("aria-invalid", "true"),
|
|
237
|
+
n.setAttribute("aria-invalid", "true"), T(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), r && Oe(n, r), i && n.setAttribute("aria-errormessage", i);
|
|
227
238
|
});
|
|
228
239
|
});
|
|
229
240
|
}
|
|
230
|
-
function
|
|
231
|
-
return !!
|
|
241
|
+
function Ne(e) {
|
|
242
|
+
return !!ke(e) || !!je(e);
|
|
232
243
|
}
|
|
233
|
-
function
|
|
234
|
-
let t =
|
|
244
|
+
function Pe(e) {
|
|
245
|
+
let t = ke(e);
|
|
235
246
|
if (t) {
|
|
236
|
-
let e =
|
|
247
|
+
let e = Ae(t);
|
|
237
248
|
if (e) {
|
|
238
249
|
if (e.scrollIntoView({
|
|
239
250
|
behavior: "smooth",
|
|
@@ -250,7 +261,7 @@ function je(e) {
|
|
|
250
261
|
block: "center"
|
|
251
262
|
}), !0;
|
|
252
263
|
}
|
|
253
|
-
let n =
|
|
264
|
+
let n = je(e);
|
|
254
265
|
return n ? (n.scrollIntoView({
|
|
255
266
|
behavior: "smooth",
|
|
256
267
|
block: "center"
|
|
@@ -258,7 +269,7 @@ function je(e) {
|
|
|
258
269
|
}
|
|
259
270
|
//#endregion
|
|
260
271
|
//#region src/js/events/event-bus.ts
|
|
261
|
-
var
|
|
272
|
+
var Fe = class {
|
|
262
273
|
constructor() {
|
|
263
274
|
this.listeners = /* @__PURE__ */ new Map();
|
|
264
275
|
}
|
|
@@ -314,8 +325,8 @@ var Me = class {
|
|
|
314
325
|
clear() {
|
|
315
326
|
this.listeners.clear();
|
|
316
327
|
}
|
|
317
|
-
},
|
|
318
|
-
function
|
|
328
|
+
}, j = C("general", "transport");
|
|
329
|
+
function Ie(e) {
|
|
319
330
|
let t = {};
|
|
320
331
|
return [
|
|
321
332
|
"theme",
|
|
@@ -326,17 +337,17 @@ function Ne(e) {
|
|
|
326
337
|
e[n] !== void 0 && (t[n] = e[n]);
|
|
327
338
|
}), t;
|
|
328
339
|
}
|
|
329
|
-
function
|
|
340
|
+
function Le(e, t = "", n = {}) {
|
|
330
341
|
if (Array.isArray(e)) {
|
|
331
342
|
let r = e.map((e) => typeof e == "string" ? e : String(e ?? "")).filter((e) => e.trim() !== "");
|
|
332
343
|
return t && r.length && (n[t] = (n[t] || []).concat(r)), n;
|
|
333
344
|
}
|
|
334
345
|
return e && typeof e == "object" && Object.entries(e).forEach(([e, r]) => {
|
|
335
|
-
|
|
346
|
+
Le(r, t ? `${t}.${e}` : e, n);
|
|
336
347
|
}), n;
|
|
337
348
|
}
|
|
338
|
-
function
|
|
339
|
-
let n = e.success === !0, r = e.keepSubmitLoading === !0, i = e.errors, a =
|
|
349
|
+
function Re(e, t) {
|
|
350
|
+
let n = e.success === !0, r = e.keepSubmitLoading === !0, i = e.errors, a = Le(i || {}), o = a.form || [], s = {};
|
|
340
351
|
Object.entries(a).forEach(([e, t]) => {
|
|
341
352
|
if (e === "form") return;
|
|
342
353
|
let n = e.split(".")[0];
|
|
@@ -357,38 +368,39 @@ function Fe(e, t) {
|
|
|
357
368
|
target: e.submitActionTab === "new-tab" ? "new-tab" : "same-tab"
|
|
358
369
|
} : null,
|
|
359
370
|
submitData: Array.isArray(e.submitData) ? e.submitData : void 0,
|
|
371
|
+
clientEvents: Array.isArray(e.clientEvents) ? e.clientEvents : void 0,
|
|
360
372
|
meta: e
|
|
361
373
|
};
|
|
362
374
|
}
|
|
363
|
-
async function
|
|
375
|
+
async function ze(e, t, n = {}) {
|
|
364
376
|
let r = JSON.stringify({
|
|
365
377
|
handle: t,
|
|
366
378
|
renderOptions: n
|
|
367
379
|
});
|
|
368
|
-
|
|
380
|
+
j.log("requestRender start.", {
|
|
369
381
|
endpoint: e,
|
|
370
382
|
handle: t
|
|
371
383
|
});
|
|
372
|
-
let i = await
|
|
384
|
+
let i = await E(e, {
|
|
373
385
|
method: "POST",
|
|
374
386
|
body: r,
|
|
375
387
|
headers: { "Content-Type": "application/json" }
|
|
376
388
|
});
|
|
377
|
-
return
|
|
389
|
+
return j.log("requestRender complete.", { hasHtml: !!i.html }), i;
|
|
378
390
|
}
|
|
379
|
-
async function
|
|
391
|
+
async function Be(e, t, n = {}) {
|
|
380
392
|
let r = JSON.stringify({
|
|
381
393
|
query: "\nquery FormieHtmlForm($handle: String!, $input: ServerRenderPayloadInput) {\n formieHtmlForm(handle: $handle, input: $input) {\n html\n }\n}",
|
|
382
394
|
variables: {
|
|
383
395
|
handle: t,
|
|
384
|
-
input:
|
|
396
|
+
input: Ie(n)
|
|
385
397
|
}
|
|
386
398
|
});
|
|
387
|
-
|
|
399
|
+
j.log("requestGraphqlRender start.", {
|
|
388
400
|
endpoint: e,
|
|
389
401
|
handle: t
|
|
390
402
|
});
|
|
391
|
-
let i = await
|
|
403
|
+
let i = await E(e, {
|
|
392
404
|
method: "POST",
|
|
393
405
|
body: r,
|
|
394
406
|
headers: { "Content-Type": "application/json" }
|
|
@@ -396,19 +408,19 @@ async function Le(e, t, n = {}) {
|
|
|
396
408
|
if (Array.isArray(i.errors) && i.errors.length > 0) throw Error(i.errors.map((e) => e.message || "Unknown GraphQL error").join("; "));
|
|
397
409
|
if (!i.data?.formieHtmlForm) throw Error(`Form not found for handle "${t}".`);
|
|
398
410
|
let a = i.data.formieHtmlForm;
|
|
399
|
-
return
|
|
411
|
+
return j.log("requestGraphqlRender complete.", { hasHtml: !!a.html }), a;
|
|
400
412
|
}
|
|
401
|
-
async function
|
|
413
|
+
async function M(e, t, n) {
|
|
402
414
|
let r = new URL(e, window.location.origin);
|
|
403
|
-
r.searchParams.set("handle", t), n && r.searchParams.set("renderId", n),
|
|
415
|
+
r.searchParams.set("handle", t), n && r.searchParams.set("renderId", n), j.log("requestRefreshTokens start.", {
|
|
404
416
|
endpoint: r.toString(),
|
|
405
417
|
handle: t,
|
|
406
418
|
hasRenderId: !!n
|
|
407
419
|
});
|
|
408
|
-
let i = await
|
|
409
|
-
return
|
|
420
|
+
let i = await E(r.toString());
|
|
421
|
+
return j.log("requestRefreshTokens complete.", { hasRefreshTokens: !!i.refreshTokens }), i.refreshTokens || i;
|
|
410
422
|
}
|
|
411
|
-
async function
|
|
423
|
+
async function Ve(e, t, n) {
|
|
412
424
|
let r = new URL(e, window.location.origin), i = new FormData();
|
|
413
425
|
if (n && i.append("pageId", n), t) {
|
|
414
426
|
[
|
|
@@ -424,17 +436,17 @@ async function ze(e, t, n) {
|
|
|
424
436
|
let e = t.querySelector("input[name=\"CRAFT_CSRF_TOKEN\"]")?.value?.trim();
|
|
425
437
|
e && i.append("CRAFT_CSRF_TOKEN", e);
|
|
426
438
|
}
|
|
427
|
-
|
|
439
|
+
j.log("requestSetPage start.", {
|
|
428
440
|
requestUrl: r.toString(),
|
|
429
441
|
pageId: n || null
|
|
430
442
|
});
|
|
431
|
-
let a = await
|
|
443
|
+
let a = await E(r.toString(), {
|
|
432
444
|
method: "POST",
|
|
433
445
|
body: i
|
|
434
446
|
});
|
|
435
|
-
return
|
|
447
|
+
return j.log("requestSetPage complete.", a), a;
|
|
436
448
|
}
|
|
437
|
-
function
|
|
449
|
+
function He(e, t) {
|
|
438
450
|
let n = new URL(e, window.location.origin), r = new FormData();
|
|
439
451
|
[
|
|
440
452
|
"handle",
|
|
@@ -446,7 +458,7 @@ function Be(e, t) {
|
|
|
446
458
|
n && r.append(e, n);
|
|
447
459
|
});
|
|
448
460
|
let i = t.querySelector("input[name=\"CRAFT_CSRF_TOKEN\"]")?.value?.trim();
|
|
449
|
-
i && r.append("CRAFT_CSRF_TOKEN", i),
|
|
461
|
+
i && r.append("CRAFT_CSRF_TOKEN", i), j.log("clearSubmissionOnUnload start.", { requestUrl: n.toString() });
|
|
450
462
|
try {
|
|
451
463
|
if (typeof navigator.sendBeacon == "function" && navigator.sendBeacon(n.toString(), r)) return;
|
|
452
464
|
} catch {}
|
|
@@ -458,9 +470,9 @@ function Be(e, t) {
|
|
|
458
470
|
headers: { Accept: "application/json" }
|
|
459
471
|
});
|
|
460
472
|
}
|
|
461
|
-
async function
|
|
473
|
+
async function Ue(e, t) {
|
|
462
474
|
let n = (e.getAttribute("method") || "POST").toUpperCase(), r = e.getAttribute("action") || window.location.href, i = e.dataset.formieErrorMessage?.trim() || "Submission failed.";
|
|
463
|
-
|
|
475
|
+
j.log("submitForm start.", {
|
|
464
476
|
method: n,
|
|
465
477
|
action: r,
|
|
466
478
|
submitAction: t.get("submitAction")
|
|
@@ -471,13 +483,13 @@ async function Ve(e, t) {
|
|
|
471
483
|
credentials: "include",
|
|
472
484
|
headers: { Accept: "application/json" }
|
|
473
485
|
}), o = a.headers.get("content-type") || "";
|
|
474
|
-
if (!o.includes("application/json")) return a.ok ? (
|
|
486
|
+
if (!o.includes("application/json")) return a.ok ? (j.log("submitForm non-JSON success response.", {
|
|
475
487
|
status: a.status,
|
|
476
488
|
contentType: o
|
|
477
489
|
}), {
|
|
478
490
|
ok: !0,
|
|
479
491
|
message: "Submission completed."
|
|
480
|
-
}) : (
|
|
492
|
+
}) : (j.warn("submitForm non-JSON HTTP error.", {
|
|
481
493
|
status: a.status,
|
|
482
494
|
contentType: o
|
|
483
495
|
}), {
|
|
@@ -486,8 +498,8 @@ async function Ve(e, t) {
|
|
|
486
498
|
message: `Request failed (${a.status}).`,
|
|
487
499
|
formErrors: [`Request failed (${a.status}).`]
|
|
488
500
|
});
|
|
489
|
-
let s =
|
|
490
|
-
return
|
|
501
|
+
let s = Re(await a.json(), i);
|
|
502
|
+
return j.log("submitForm JSON response normalized.", {
|
|
491
503
|
ok: s.ok,
|
|
492
504
|
code: s.code,
|
|
493
505
|
hasRedirect: !!s.redirect?.url,
|
|
@@ -496,7 +508,7 @@ async function Ve(e, t) {
|
|
|
496
508
|
}
|
|
497
509
|
//#endregion
|
|
498
510
|
//#region src/js/submit/pipeline.ts
|
|
499
|
-
var
|
|
511
|
+
var We = [
|
|
500
512
|
"prepare",
|
|
501
513
|
"normalize",
|
|
502
514
|
"validate",
|
|
@@ -504,14 +516,14 @@ var He = [
|
|
|
504
516
|
"authorize",
|
|
505
517
|
"dispatch",
|
|
506
518
|
"finalize"
|
|
507
|
-
],
|
|
519
|
+
], Ge = [
|
|
508
520
|
"prepare",
|
|
509
521
|
"normalize",
|
|
510
522
|
"validate",
|
|
511
523
|
"screen",
|
|
512
524
|
"authorize"
|
|
513
|
-
],
|
|
514
|
-
function
|
|
525
|
+
], N = C("general", "pipeline");
|
|
526
|
+
function Ke(e, t) {
|
|
515
527
|
return {
|
|
516
528
|
ok: !1,
|
|
517
529
|
stage: e,
|
|
@@ -520,13 +532,13 @@ function We(e, t) {
|
|
|
520
532
|
formErrors: [t || "Submission aborted."]
|
|
521
533
|
};
|
|
522
534
|
}
|
|
523
|
-
function
|
|
535
|
+
function qe(e) {
|
|
524
536
|
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
|
|
525
537
|
}
|
|
526
|
-
function
|
|
538
|
+
function Je(e) {
|
|
527
539
|
return !(!e.name || e.disabled || e instanceof HTMLInputElement && (e.type === "submit" || e.type === "button" || e.type === "reset" || e.type === "image" || (e.type === "checkbox" || e.type === "radio") && !e.checked || e.type === "file" && (!e.files || e.files.length === 0)));
|
|
528
540
|
}
|
|
529
|
-
function
|
|
541
|
+
function Ye(e, t) {
|
|
530
542
|
if (t instanceof HTMLInputElement) {
|
|
531
543
|
if (t.type === "file") {
|
|
532
544
|
Array.from(t.files || []).forEach((n) => {
|
|
@@ -545,49 +557,49 @@ function qe(e, t) {
|
|
|
545
557
|
}
|
|
546
558
|
e.append(t.name, t.value);
|
|
547
559
|
}
|
|
548
|
-
function
|
|
560
|
+
function Xe(e, t) {
|
|
549
561
|
t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
550
|
-
let n =
|
|
551
|
-
!n || n.closest("[data-formie-page]") ||
|
|
562
|
+
let n = qe(t) ? t : null;
|
|
563
|
+
!n || n.closest("[data-formie-page]") || Je(n) && Ye(e, n);
|
|
552
564
|
});
|
|
553
565
|
}
|
|
554
|
-
function
|
|
566
|
+
function Ze(e, t) {
|
|
555
567
|
let n = /* @__PURE__ */ new Set();
|
|
556
568
|
return t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
557
|
-
let r =
|
|
558
|
-
!r || !r.name || r.disabled || r instanceof HTMLInputElement && (r.type === "submit" || r.type === "button" || r.type === "reset" || r.type === "image") || (r.name.startsWith("fields[") && n.add(r.name),
|
|
569
|
+
let r = qe(t) ? t : null;
|
|
570
|
+
!r || !r.name || r.disabled || r instanceof HTMLInputElement && (r.type === "submit" || r.type === "button" || r.type === "reset" || r.type === "image") || (r.name.startsWith("fields[") && n.add(r.name), Je(r) && Ye(e, r));
|
|
559
571
|
}), n;
|
|
560
572
|
}
|
|
561
|
-
function
|
|
573
|
+
function Qe(e, t) {
|
|
562
574
|
t.forEach((t) => {
|
|
563
575
|
e.has(t) || e.append(t, "");
|
|
564
576
|
});
|
|
565
577
|
}
|
|
566
|
-
function
|
|
567
|
-
let n =
|
|
578
|
+
function $e(e, t) {
|
|
579
|
+
let n = c(e), r = n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || null;
|
|
568
580
|
if (!n.length || !r) {
|
|
569
581
|
let n = new FormData(e);
|
|
570
582
|
return n.set("submitAction", t), n;
|
|
571
583
|
}
|
|
572
584
|
let i = new FormData();
|
|
573
|
-
return
|
|
585
|
+
return Xe(i, e), Qe(i, Ze(i, r)), i.set("submitAction", t), i;
|
|
574
586
|
}
|
|
575
|
-
function
|
|
587
|
+
function et(e, t) {
|
|
576
588
|
if (t !== "submit") return !1;
|
|
577
|
-
let n =
|
|
589
|
+
let n = c(e);
|
|
578
590
|
return n.length ? (n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || n[n.length - 1]) === n[n.length - 1] : !0;
|
|
579
591
|
}
|
|
580
|
-
async function
|
|
581
|
-
|
|
592
|
+
async function tt(e, t, n, r = {}) {
|
|
593
|
+
N.log("Starting submit pipeline.", {
|
|
582
594
|
action: t,
|
|
583
595
|
preflightOnly: r.preflightOnly === !0
|
|
584
596
|
});
|
|
585
|
-
let i = !1, a, o = null, s =
|
|
597
|
+
let i = !1, a, o = null, s = et(e, t), c = {
|
|
586
598
|
form: e,
|
|
587
599
|
action: t,
|
|
588
|
-
formData:
|
|
600
|
+
formData: $e(e, t),
|
|
589
601
|
abort: (e) => {
|
|
590
|
-
i = !0, a = e,
|
|
602
|
+
i = !0, a = e, N.warn("Pipeline aborted.", { reason: e });
|
|
591
603
|
},
|
|
592
604
|
isAborted: () => i,
|
|
593
605
|
abortReason: () => a
|
|
@@ -600,7 +612,7 @@ async function $e(e, t, n, r = {}) {
|
|
|
600
612
|
validate: async (e) => {
|
|
601
613
|
if (e.action !== "submit" || r.validateOnSubmit === !1) return null;
|
|
602
614
|
if (r.validator) {
|
|
603
|
-
let { scope: t, final: n } =
|
|
615
|
+
let { scope: t, final: n } = f(e.form), i = r.validator.submit(n ? e.form : t, { final: n });
|
|
604
616
|
if (i.length > 0) {
|
|
605
617
|
let e = i[0]?.input;
|
|
606
618
|
if (e) {
|
|
@@ -636,68 +648,68 @@ async function $e(e, t, n, r = {}) {
|
|
|
636
648
|
screen: async () => null,
|
|
637
649
|
authorize: async () => null,
|
|
638
650
|
dispatch: async (e) => {
|
|
639
|
-
e.formData =
|
|
640
|
-
let t = await
|
|
651
|
+
e.formData = $e(e.form, e.action);
|
|
652
|
+
let t = await Ue(e.form, e.formData);
|
|
641
653
|
return o = t, t;
|
|
642
654
|
},
|
|
643
655
|
finalize: async (e) => (o && o.ok && o.redirect?.url && (o.redirect.target === "new-tab" ? window.open(o.redirect.url, "_blank") : window.location.href = o.redirect.url), null)
|
|
644
656
|
};
|
|
645
657
|
{
|
|
646
658
|
let e = await n.emitSafe("formie:submit:before", c);
|
|
647
|
-
e.failed.length > 0 &&
|
|
659
|
+
e.failed.length > 0 && N.warn("Submit before listeners failed.", {
|
|
648
660
|
eventName: e.eventName,
|
|
649
661
|
failed: e.failed.length
|
|
650
662
|
});
|
|
651
663
|
}
|
|
652
664
|
if (s) {
|
|
653
665
|
let e = await n.emitSafe("formie:submit:final:before", c);
|
|
654
|
-
e.failed.length > 0 &&
|
|
666
|
+
e.failed.length > 0 && N.warn("Final submit before listeners failed.", {
|
|
655
667
|
eventName: e.eventName,
|
|
656
668
|
failed: e.failed.length
|
|
657
669
|
});
|
|
658
670
|
}
|
|
659
|
-
let u = r.preflightOnly ?
|
|
671
|
+
let u = r.preflightOnly ? Ge : We;
|
|
660
672
|
for (let e of u) {
|
|
661
|
-
if (
|
|
673
|
+
if (N.log("Stage start.", {
|
|
662
674
|
stage: e,
|
|
663
675
|
action: t
|
|
664
|
-
}), i) return
|
|
676
|
+
}), i) return N.warn("Stage skipped due to abort.", {
|
|
665
677
|
stage: e,
|
|
666
678
|
reason: a
|
|
667
|
-
}),
|
|
679
|
+
}), Ke(e, a);
|
|
668
680
|
{
|
|
669
681
|
let t = await n.emitSafe(`formie:stage:${e}:before`, {
|
|
670
682
|
...c,
|
|
671
683
|
stage: e
|
|
672
684
|
});
|
|
673
|
-
t.failed.length > 0 &&
|
|
685
|
+
t.failed.length > 0 && N.warn("Stage before listeners failed.", {
|
|
674
686
|
stage: e,
|
|
675
687
|
failed: t.failed.length
|
|
676
688
|
});
|
|
677
689
|
}
|
|
678
690
|
if (i) {
|
|
679
|
-
let t =
|
|
691
|
+
let t = Ke(e, a);
|
|
680
692
|
{
|
|
681
693
|
let r = await n.emitSafe("formie:submit:after", t);
|
|
682
|
-
r.failed.length > 0 &&
|
|
694
|
+
r.failed.length > 0 && N.warn("Submit after listeners failed (abort before stage).", {
|
|
683
695
|
stage: e,
|
|
684
696
|
failed: r.failed.length
|
|
685
697
|
});
|
|
686
698
|
}
|
|
687
699
|
if (s) {
|
|
688
700
|
let r = await n.emitSafe("formie:submit:final:after", t);
|
|
689
|
-
r.failed.length > 0 &&
|
|
701
|
+
r.failed.length > 0 && N.warn("Final submit after listeners failed (abort before stage).", {
|
|
690
702
|
stage: e,
|
|
691
703
|
failed: r.failed.length
|
|
692
704
|
});
|
|
693
705
|
}
|
|
694
|
-
return
|
|
706
|
+
return N.warn("Aborted after stage before-hooks.", {
|
|
695
707
|
stage: e,
|
|
696
708
|
reason: a
|
|
697
709
|
}), t;
|
|
698
710
|
}
|
|
699
711
|
let r = await l[e](c);
|
|
700
|
-
|
|
712
|
+
N.log("Stage runner complete.", {
|
|
701
713
|
stage: e,
|
|
702
714
|
hasResult: !!r,
|
|
703
715
|
ok: r ? r.ok : void 0,
|
|
@@ -709,28 +721,28 @@ async function $e(e, t, n, r = {}) {
|
|
|
709
721
|
stage: e,
|
|
710
722
|
result: r
|
|
711
723
|
});
|
|
712
|
-
t.failed.length > 0 &&
|
|
724
|
+
t.failed.length > 0 && N.warn("Stage after listeners failed.", {
|
|
713
725
|
stage: e,
|
|
714
726
|
failed: t.failed.length
|
|
715
727
|
});
|
|
716
728
|
}
|
|
717
729
|
if (i) {
|
|
718
|
-
let t =
|
|
730
|
+
let t = Ke(e, a);
|
|
719
731
|
{
|
|
720
732
|
let r = await n.emitSafe("formie:submit:after", t);
|
|
721
|
-
r.failed.length > 0 &&
|
|
733
|
+
r.failed.length > 0 && N.warn("Submit after listeners failed (abort after stage).", {
|
|
722
734
|
stage: e,
|
|
723
735
|
failed: r.failed.length
|
|
724
736
|
});
|
|
725
737
|
}
|
|
726
738
|
if (s) {
|
|
727
739
|
let r = await n.emitSafe("formie:submit:final:after", t);
|
|
728
|
-
r.failed.length > 0 &&
|
|
740
|
+
r.failed.length > 0 && N.warn("Final submit after listeners failed (abort after stage).", {
|
|
729
741
|
stage: e,
|
|
730
742
|
failed: r.failed.length
|
|
731
743
|
});
|
|
732
744
|
}
|
|
733
|
-
return
|
|
745
|
+
return N.warn("Aborted after stage after-hooks.", {
|
|
734
746
|
stage: e,
|
|
735
747
|
reason: a
|
|
736
748
|
}), t;
|
|
@@ -738,19 +750,19 @@ async function $e(e, t, n, r = {}) {
|
|
|
738
750
|
if (r && !r.ok) {
|
|
739
751
|
{
|
|
740
752
|
let t = await n.emitSafe("formie:submit:after", r);
|
|
741
|
-
t.failed.length > 0 &&
|
|
753
|
+
t.failed.length > 0 && N.warn("Submit after listeners failed (failed stage).", {
|
|
742
754
|
stage: e,
|
|
743
755
|
failed: t.failed.length
|
|
744
756
|
});
|
|
745
757
|
}
|
|
746
758
|
if (s) {
|
|
747
759
|
let t = await n.emitSafe("formie:submit:final:after", r);
|
|
748
|
-
t.failed.length > 0 &&
|
|
760
|
+
t.failed.length > 0 && N.warn("Final submit after listeners failed (failed stage).", {
|
|
749
761
|
stage: e,
|
|
750
762
|
failed: t.failed.length
|
|
751
763
|
});
|
|
752
764
|
}
|
|
753
|
-
return
|
|
765
|
+
return N.warn("Pipeline short-circuited by failed stage.", {
|
|
754
766
|
stage: e,
|
|
755
767
|
code: r.code,
|
|
756
768
|
message: r.message
|
|
@@ -764,13 +776,13 @@ async function $e(e, t, n, r = {}) {
|
|
|
764
776
|
};
|
|
765
777
|
{
|
|
766
778
|
let e = await n.emitSafe("formie:submit:after", d);
|
|
767
|
-
e.failed.length > 0 &&
|
|
779
|
+
e.failed.length > 0 && N.warn("Submit after listeners failed (success).", { failed: e.failed.length });
|
|
768
780
|
}
|
|
769
781
|
if (s) {
|
|
770
782
|
let e = await n.emitSafe("formie:submit:final:after", d);
|
|
771
|
-
e.failed.length > 0 &&
|
|
783
|
+
e.failed.length > 0 && N.warn("Final submit after listeners failed (success).", { failed: e.failed.length });
|
|
772
784
|
}
|
|
773
|
-
return
|
|
785
|
+
return N.log("Pipeline completed.", {
|
|
774
786
|
ok: d.ok,
|
|
775
787
|
stage: d.stage,
|
|
776
788
|
code: d.code
|
|
@@ -778,27 +790,27 @@ async function $e(e, t, n, r = {}) {
|
|
|
778
790
|
}
|
|
779
791
|
//#endregion
|
|
780
792
|
//#region src/js/core/field-error-container.ts
|
|
781
|
-
function
|
|
793
|
+
function nt(e) {
|
|
782
794
|
return e.querySelector("[data-formie-field-layout]")?.getAttribute("data-formie-error-position")?.trim() === "above" ? "above" : "below";
|
|
783
795
|
}
|
|
784
|
-
function
|
|
796
|
+
function rt(e, t) {
|
|
785
797
|
let n = e.querySelector("[data-formie-field-errors]");
|
|
786
798
|
if (n) return n;
|
|
787
|
-
let r = e.querySelector("[data-formie-field-content]"), i = e.querySelector("[data-formie-field-control]"), a =
|
|
799
|
+
let r = e.querySelector("[data-formie-field-content]"), i = e.querySelector("[data-formie-field-control]"), a = nt(e), o = document.createElement("div");
|
|
788
800
|
return o.setAttribute("data-formie-field-errors", "true"), t?.(o), r && i ? a === "above" ? r.insertBefore(o, i) : r.appendChild(o) : e.appendChild(o), o;
|
|
789
801
|
}
|
|
790
802
|
//#endregion
|
|
791
803
|
//#region src/js/validation/rules/email.ts
|
|
792
|
-
var
|
|
804
|
+
var it = {
|
|
793
805
|
rule: ({ input: e, getRule: t }) => !t("email") || !e.value || e.value.length < 1 ? !0 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.value),
|
|
794
806
|
message: ({ input: e, label: t, t: n }) => e.getAttribute("data-formie-validation-email-message") ?? e.getAttribute("data-formie-pattern-email-message") ?? e.getAttribute("data-pattern-email-message") ?? n("{label} is not a valid email address.", { label: t })
|
|
795
807
|
};
|
|
796
808
|
//#endregion
|
|
797
809
|
//#region src/js/validation/rules/shared.ts
|
|
798
|
-
function
|
|
810
|
+
function at(e) {
|
|
799
811
|
return e?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() || "";
|
|
800
812
|
}
|
|
801
|
-
function
|
|
813
|
+
function ot(e) {
|
|
802
814
|
let t = e.getRule("match");
|
|
803
815
|
if (!t || t === !0 || typeof t != "object" || !e.field) return null;
|
|
804
816
|
let n = typeof t.fieldHandle == "string" ? t.fieldHandle.trim() : "";
|
|
@@ -808,7 +820,7 @@ function it(e) {
|
|
|
808
820
|
}
|
|
809
821
|
//#endregion
|
|
810
822
|
//#region src/js/validation/rules.ts
|
|
811
|
-
var
|
|
823
|
+
var st = {
|
|
812
824
|
required: {
|
|
813
825
|
rule: ({ input: e, getRule: t }) => {
|
|
814
826
|
if (!t("required") || e.type === "hidden") return !0;
|
|
@@ -820,7 +832,7 @@ var at = {
|
|
|
820
832
|
},
|
|
821
833
|
message: ({ input: e, label: t, t: n }) => e.getAttribute("data-formie-required-message") ?? e.getAttribute("data-required-message") ?? n("{label} cannot be blank.", { label: t })
|
|
822
834
|
},
|
|
823
|
-
email:
|
|
835
|
+
email: it,
|
|
824
836
|
url: {
|
|
825
837
|
rule: ({ input: e, getRule: t }) => {
|
|
826
838
|
if (!t("url") || !e.value || e.value.length < 1) return !0;
|
|
@@ -861,18 +873,18 @@ var at = {
|
|
|
861
873
|
},
|
|
862
874
|
match: {
|
|
863
875
|
rule: (e) => {
|
|
864
|
-
let t =
|
|
876
|
+
let t = ot(e);
|
|
865
877
|
return t ? t.value === e.input.value : !0;
|
|
866
878
|
},
|
|
867
879
|
message: (e) => {
|
|
868
|
-
let t =
|
|
880
|
+
let t = ot(e)?.closest("[data-formie-field-handle]"), n = at(t);
|
|
869
881
|
return e.t("{label} must match {value}.", {
|
|
870
882
|
label: e.label,
|
|
871
883
|
value: n
|
|
872
884
|
});
|
|
873
885
|
}
|
|
874
886
|
}
|
|
875
|
-
},
|
|
887
|
+
}, ct = {
|
|
876
888
|
email: /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*(\.\w{2,})+$/,
|
|
877
889
|
url: /^(?:(?:https?|HTTPS?|ftp|FTP):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)(?:\.(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)*(?:\.(?:[a-zA-Z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/,
|
|
878
890
|
number: /^(?:[-+]?[0-9]*[.,]?[0-9]+)$/,
|
|
@@ -880,11 +892,11 @@ var at = {
|
|
|
880
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))/,
|
|
881
893
|
time: /^(?:(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]))$/,
|
|
882
894
|
month: /^(?:(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])))$/
|
|
883
|
-
},
|
|
884
|
-
function
|
|
895
|
+
}, P = C("general", "validator");
|
|
896
|
+
function F(e) {
|
|
885
897
|
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement);
|
|
886
898
|
}
|
|
887
|
-
function
|
|
899
|
+
function lt(e, t) {
|
|
888
900
|
let n = (e.getAttribute("aria-describedby") || "").trim();
|
|
889
901
|
if (!n) return;
|
|
890
902
|
let r = n.split(/\s+/).filter((e) => e !== t);
|
|
@@ -894,34 +906,35 @@ function st(e, t) {
|
|
|
894
906
|
}
|
|
895
907
|
e.removeAttribute("aria-describedby");
|
|
896
908
|
}
|
|
897
|
-
function
|
|
909
|
+
function ut(e, t) {
|
|
898
910
|
let n = (e.getAttribute("aria-describedby") || "").trim(), r = n ? n.split(/\s+/) : [];
|
|
899
911
|
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
900
912
|
}
|
|
901
|
-
function
|
|
913
|
+
function dt(e, t) {
|
|
902
914
|
e.setAttribute("aria-errormessage", t);
|
|
903
915
|
}
|
|
904
|
-
function
|
|
916
|
+
function ft(e, t) {
|
|
905
917
|
e.getAttribute("aria-errormessage") === t && e.removeAttribute("aria-errormessage");
|
|
906
918
|
}
|
|
907
|
-
var
|
|
919
|
+
var pt = class {
|
|
908
920
|
constructor(e, t = {}) {
|
|
909
921
|
this.errors = [], this.validators = {}, this.boundListeners = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.submitted = !1, this.initialValues = /* @__PURE__ */ new WeakMap(), this.form = e, this.onBlur = this.blurHandler.bind(this), this.onChange = this.changeHandler.bind(this), this.onInput = this.inputHandler.bind(this), this.config = {
|
|
910
922
|
live: !1,
|
|
923
|
+
errorAriaLive: "polite",
|
|
911
924
|
errorMessage: "",
|
|
912
925
|
fieldContainerErrorClass: [],
|
|
913
926
|
inputErrorClass: [],
|
|
914
927
|
messagesClass: [],
|
|
915
928
|
messageClass: [],
|
|
916
929
|
fieldsSelector: "input:not([type=\"hidden\"]):not([type=\"submit\"]):not([type=\"button\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])",
|
|
917
|
-
patterns:
|
|
930
|
+
patterns: ct,
|
|
918
931
|
...t
|
|
919
|
-
}, Object.entries(
|
|
932
|
+
}, Object.entries(st).forEach(([e, t]) => {
|
|
920
933
|
this.addValidator(e, t.rule, t.message);
|
|
921
934
|
}), this.init();
|
|
922
935
|
}
|
|
923
936
|
init() {
|
|
924
|
-
|
|
937
|
+
P.log("Initializing validator.", {
|
|
925
938
|
formId: this.form.id || null,
|
|
926
939
|
live: this.config.live
|
|
927
940
|
}), this.form.setAttribute("novalidate", "true"), this.inputs().forEach((e) => {
|
|
@@ -929,9 +942,9 @@ var dt = class {
|
|
|
929
942
|
}), this.config.live && this.addEventListeners(), this.emitEvent(document, n("ready"), { validator: this });
|
|
930
943
|
}
|
|
931
944
|
inputs(e = null) {
|
|
932
|
-
if (
|
|
945
|
+
if (F(e)) return [e];
|
|
933
946
|
let t = e || this.form;
|
|
934
|
-
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) =>
|
|
947
|
+
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) => F(e));
|
|
935
948
|
}
|
|
936
949
|
getInputValue(e) {
|
|
937
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 ?? "";
|
|
@@ -971,7 +984,7 @@ var dt = class {
|
|
|
971
984
|
}), r = !0;
|
|
972
985
|
}
|
|
973
986
|
}), !r && this.shouldShowError(e) && this.removeError(e);
|
|
974
|
-
}),
|
|
987
|
+
}), P.log("Validation pass complete.", {
|
|
975
988
|
errorCount: this.errors.length,
|
|
976
989
|
includeHiddenPages: t.includeHiddenPages === !0
|
|
977
990
|
}), this.errors;
|
|
@@ -992,39 +1005,39 @@ var dt = class {
|
|
|
992
1005
|
e.remove();
|
|
993
1006
|
}), r && (r.innerHTML = ""), t.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
994
1007
|
let n = e;
|
|
995
|
-
n.removeAttribute("aria-invalid"), this.config.inputErrorClass.length && n.classList.remove(...this.config.inputErrorClass), n.removeAttribute("data-formie-input-has-error"), i &&
|
|
1008
|
+
n.removeAttribute("aria-invalid"), this.config.inputErrorClass.length && n.classList.remove(...this.config.inputErrorClass), n.removeAttribute("data-formie-input-has-error"), i && lt(n, i), t.querySelectorAll("[data-formie-field-error]").forEach((e) => {
|
|
996
1009
|
let t = e.id;
|
|
997
|
-
t &&
|
|
1010
|
+
t && ft(n, t);
|
|
998
1011
|
});
|
|
999
1012
|
});
|
|
1000
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");
|
|
1001
|
-
this.emitEvent(e, n("clear-error"), { validator: this }),
|
|
1014
|
+
this.emitEvent(e, n("clear-error"), { validator: this }), y(this.form);
|
|
1002
1015
|
}
|
|
1003
1016
|
showError(e, t, r) {
|
|
1004
1017
|
let i = e.closest("[data-formie-field-handle]");
|
|
1005
1018
|
if (!i) return;
|
|
1006
1019
|
let a = i.querySelector("[data-formie-field-errors]");
|
|
1007
|
-
a ||=
|
|
1020
|
+
a ||= rt(i, (e) => {
|
|
1008
1021
|
this.config.messagesClass.length && e.classList.add(...this.config.messagesClass);
|
|
1009
1022
|
}), this.config.messagesClass.length && a.classList.add(...this.config.messagesClass), a.innerHTML = "";
|
|
1010
1023
|
let o = i.getAttribute("data-formie-field-handle") || "field", s = `${o}-error`;
|
|
1011
|
-
a.id = a.id || `${o}-errors`, a
|
|
1024
|
+
a.id = a.id || `${o}-errors`, De(a, Te(this.config.errorAriaLive, this.submitted));
|
|
1012
1025
|
let c = document.createElement("div");
|
|
1013
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) => {
|
|
1014
1027
|
let t = e;
|
|
1015
|
-
t.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && t.classList.add(...this.config.inputErrorClass), t.setAttribute("data-formie-input-has-error", "true"),
|
|
1028
|
+
t.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && t.classList.add(...this.config.inputErrorClass), t.setAttribute("data-formie-input-has-error", "true"), ut(t, a.id), dt(t, s);
|
|
1016
1029
|
});
|
|
1017
1030
|
for (let e = i; e; e = e.parentElement?.closest("[data-formie-field-handle]")) this.config.fieldContainerErrorClass.length && e.classList.add(...this.config.fieldContainerErrorClass), e.setAttribute("data-formie-field-has-error", "true");
|
|
1018
1031
|
this.emitEvent(e, n("show-error"), {
|
|
1019
1032
|
validator: this,
|
|
1020
1033
|
validatorName: t,
|
|
1021
1034
|
errorMessage: r
|
|
1022
|
-
}),
|
|
1035
|
+
}), y(this.form);
|
|
1023
1036
|
}
|
|
1024
1037
|
getValidatorCallbackOptions(e) {
|
|
1025
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"));
|
|
1026
1039
|
return {
|
|
1027
|
-
t:
|
|
1040
|
+
t: O,
|
|
1028
1041
|
input: e,
|
|
1029
1042
|
label: n,
|
|
1030
1043
|
field: t,
|
|
@@ -1035,7 +1048,7 @@ var dt = class {
|
|
|
1035
1048
|
};
|
|
1036
1049
|
}
|
|
1037
1050
|
getErrorMessage(e, t, n, r) {
|
|
1038
|
-
return (typeof n.errorMessage == "function" ? n.errorMessage(r) : n.errorMessage) ??
|
|
1051
|
+
return (typeof n.errorMessage == "function" ? n.errorMessage(r) : n.errorMessage) ?? O("{label} is invalid.", { label: r.label });
|
|
1039
1052
|
}
|
|
1040
1053
|
getErrors() {
|
|
1041
1054
|
return this.errors;
|
|
@@ -1058,7 +1071,7 @@ var dt = class {
|
|
|
1058
1071
|
try {
|
|
1059
1072
|
n = JSON.parse(e);
|
|
1060
1073
|
} catch {
|
|
1061
|
-
return
|
|
1074
|
+
return P.warn("Invalid validation rules payload.", { formId: this.form.id || null }), t;
|
|
1062
1075
|
}
|
|
1063
1076
|
return Array.isArray(n) && n.forEach((e) => {
|
|
1064
1077
|
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
@@ -1067,16 +1080,16 @@ var dt = class {
|
|
|
1067
1080
|
}), t;
|
|
1068
1081
|
}
|
|
1069
1082
|
destroy() {
|
|
1070
|
-
|
|
1083
|
+
P.log("Destroying validator.", { formId: this.form.id || null }), this.removeEventListeners(), this.form.removeAttribute("novalidate"), this.emitEvent(document, n("destroy"), { validator: this });
|
|
1071
1084
|
}
|
|
1072
1085
|
isVisible(e, t = {}) {
|
|
1073
|
-
return e.closest("[data-formie-conditionally-hidden]") ? !1 : e.closest("[data-formie-page-hidden]") ? !!t.includeHiddenPages : !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
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);
|
|
1074
1087
|
}
|
|
1075
1088
|
blurHandler(e) {
|
|
1076
|
-
!(e.target instanceof HTMLElement) || !
|
|
1089
|
+
!(e.target instanceof HTMLElement) || !F(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));
|
|
1077
1090
|
}
|
|
1078
1091
|
changeHandler(e) {
|
|
1079
|
-
if (!(!(e.target instanceof HTMLElement) || !
|
|
1092
|
+
if (!(!(e.target instanceof HTMLElement) || !F(e.target) || !e.target.form?.isSameNode(this.form)) && !(e instanceof CustomEvent)) {
|
|
1080
1093
|
if (e.target instanceof HTMLSelectElement) {
|
|
1081
1094
|
this.activated.add(e.target), this.validate(e.target);
|
|
1082
1095
|
return;
|
|
@@ -1085,19 +1098,19 @@ var dt = class {
|
|
|
1085
1098
|
}
|
|
1086
1099
|
}
|
|
1087
1100
|
inputHandler(e) {
|
|
1088
|
-
!(e.target instanceof HTMLElement) || !
|
|
1101
|
+
!(e.target instanceof HTMLElement) || !F(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);
|
|
1089
1102
|
}
|
|
1090
1103
|
submit(e = null, { final: t = !1 } = {}) {
|
|
1091
|
-
return this.submitted = !0,
|
|
1104
|
+
return this.submitted = !0, P.log("Submit validation requested.", { final: t }), this.boundListeners || this.addEventListeners(), this.removeAllErrors(), this.validate(e, { includeHiddenPages: t });
|
|
1092
1105
|
}
|
|
1093
1106
|
resetLiveState() {
|
|
1094
1107
|
this.submitted = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.errors = [], this.removeAllErrors();
|
|
1095
1108
|
}
|
|
1096
1109
|
addEventListeners() {
|
|
1097
|
-
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, P.log("Event listeners attached."));
|
|
1098
1111
|
}
|
|
1099
1112
|
removeEventListeners() {
|
|
1100
|
-
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, P.log("Event listeners removed.");
|
|
1101
1114
|
}
|
|
1102
1115
|
emitEvent(e, t, n = {}) {
|
|
1103
1116
|
e.dispatchEvent(new CustomEvent(t, {
|
|
@@ -1114,62 +1127,62 @@ var dt = class {
|
|
|
1114
1127
|
removeValidator(e) {
|
|
1115
1128
|
delete this.validators[e];
|
|
1116
1129
|
}
|
|
1117
|
-
},
|
|
1118
|
-
function
|
|
1130
|
+
}, I = /* @__PURE__ */ new WeakMap();
|
|
1131
|
+
function mt(e) {
|
|
1119
1132
|
return (e.dataset.formieSubmitAction || "").trim();
|
|
1120
1133
|
}
|
|
1121
|
-
function
|
|
1134
|
+
function ht(e) {
|
|
1122
1135
|
return (e.dataset.formieErrorMessagePosition || "top-form").trim() || "top-form";
|
|
1123
1136
|
}
|
|
1124
|
-
function
|
|
1137
|
+
function gt(e) {
|
|
1125
1138
|
return (e.dataset.formieSubmitActionMessagePosition || "").trim();
|
|
1126
1139
|
}
|
|
1127
|
-
function
|
|
1140
|
+
function _t(e) {
|
|
1128
1141
|
let t = (e.dataset.formieSubmitActionMessageTimeout || "").trim();
|
|
1129
1142
|
if (!t) return null;
|
|
1130
1143
|
let n = Number.parseFloat(t);
|
|
1131
1144
|
return !Number.isFinite(n) || n < 0 ? null : Math.round(n * 1e3);
|
|
1132
1145
|
}
|
|
1133
|
-
function
|
|
1146
|
+
function vt(e) {
|
|
1134
1147
|
let t = e.dataset.formieSubmitActionFormHide;
|
|
1135
1148
|
if (t === void 0) return !1;
|
|
1136
1149
|
let n = t.trim().toLowerCase();
|
|
1137
1150
|
return n === "true" || n === "1" || n === "";
|
|
1138
1151
|
}
|
|
1139
|
-
function
|
|
1140
|
-
let t =
|
|
1141
|
-
typeof t == "number" && (window.clearTimeout(t),
|
|
1152
|
+
function yt(e) {
|
|
1153
|
+
let t = I.get(e);
|
|
1154
|
+
typeof t == "number" && (window.clearTimeout(t), I.delete(e));
|
|
1142
1155
|
}
|
|
1143
|
-
function
|
|
1156
|
+
function bt(e) {
|
|
1144
1157
|
return e.querySelector("[data-formie-form-messages-top]") || e;
|
|
1145
1158
|
}
|
|
1146
|
-
function
|
|
1159
|
+
function xt(e) {
|
|
1147
1160
|
return e.querySelector("[data-formie-form-messages-bottom]") || e;
|
|
1148
1161
|
}
|
|
1149
|
-
function
|
|
1150
|
-
return t === "bottom-form" ?
|
|
1162
|
+
function St(e, t) {
|
|
1163
|
+
return t === "bottom-form" ? xt(e) : bt(e);
|
|
1151
1164
|
}
|
|
1152
|
-
function
|
|
1153
|
-
return t === "top-form" ?
|
|
1165
|
+
function Ct(e, t) {
|
|
1166
|
+
return t === "top-form" ? bt(e) : t === "bottom-form" && !vt(e) ? xt(e) : e;
|
|
1154
1167
|
}
|
|
1155
|
-
function
|
|
1156
|
-
let t =
|
|
1157
|
-
return r || (r = document.createElement("div"), r.setAttribute("data-formie-errors", "true"),
|
|
1168
|
+
function wt(e) {
|
|
1169
|
+
let t = ht(e), n = St(e, t), r = n.querySelector("[data-formie-error-container], [data-formie-errors]");
|
|
1170
|
+
return r || (r = document.createElement("div"), r.setAttribute("data-formie-errors", "true"), T(r, e, "errors")), r.setAttribute("data-formie-error-container", "true"), t === "bottom-form" ? n.append(r) : n.prepend(r), r;
|
|
1158
1171
|
}
|
|
1159
|
-
function
|
|
1172
|
+
function Tt(e, t) {
|
|
1160
1173
|
let n = t.querySelector("[data-formie-error-message-container], [data-formie-message][data-formie-message-error]");
|
|
1161
|
-
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"),
|
|
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"), T(n, e, "message", "messageError"), n.setAttribute("role", "alert"), De(n, Ee(we(e))), n;
|
|
1162
1175
|
}
|
|
1163
|
-
function
|
|
1164
|
-
let n = e.querySelector("[data-formie-success-container]"), r =
|
|
1165
|
-
return n || (n = document.createElement("div"), n.setAttribute("data-formie-success-container", "true"),
|
|
1176
|
+
function Et(e, t) {
|
|
1177
|
+
let n = e.querySelector("[data-formie-success-container]"), r = Ct(e, t);
|
|
1178
|
+
return n || (n = document.createElement("div"), n.setAttribute("data-formie-success-container", "true"), T(n, e, "successes")), t === "bottom-form" ? r.append(n) : r.prepend(n), n;
|
|
1166
1179
|
}
|
|
1167
|
-
function
|
|
1168
|
-
return
|
|
1169
|
-
|
|
1180
|
+
function Dt(e) {
|
|
1181
|
+
return rt(e, (t) => {
|
|
1182
|
+
T(t, e, "fieldErrors");
|
|
1170
1183
|
});
|
|
1171
1184
|
}
|
|
1172
|
-
function
|
|
1185
|
+
function Ot(e, t) {
|
|
1173
1186
|
let n = (e.getAttribute("aria-describedby") || "").trim();
|
|
1174
1187
|
if (!n) return;
|
|
1175
1188
|
let r = n.split(/\s+/).filter((e) => e !== t).join(" ").trim();
|
|
@@ -1179,148 +1192,149 @@ function Tt(e, t) {
|
|
|
1179
1192
|
}
|
|
1180
1193
|
e.removeAttribute("aria-describedby");
|
|
1181
1194
|
}
|
|
1182
|
-
function
|
|
1195
|
+
function kt(e, t) {
|
|
1183
1196
|
e.setAttribute("aria-errormessage", t);
|
|
1184
1197
|
}
|
|
1185
|
-
function
|
|
1198
|
+
function At(e, t) {
|
|
1186
1199
|
e.getAttribute("aria-errormessage") === t && e.removeAttribute("aria-errormessage");
|
|
1187
1200
|
}
|
|
1188
|
-
function
|
|
1201
|
+
function jt(e) {
|
|
1189
1202
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
1190
1203
|
let n = t, r = n.querySelector("[data-formie-field-errors]"), i = r?.id || "", a = Array.from(n.querySelectorAll("[data-formie-field-error]")).map((e) => e.id).filter(Boolean);
|
|
1191
|
-
|
|
1204
|
+
w(n, e, "fieldLayoutError"), n.removeAttribute("data-formie-field-has-error"), n.querySelectorAll("[data-formie-field-error]").forEach((e) => {
|
|
1192
1205
|
e.remove();
|
|
1193
1206
|
}), r && !r.querySelector("[data-formie-field-error]") && (r.innerHTML = ""), n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
1194
1207
|
let n = t;
|
|
1195
|
-
n.removeAttribute("aria-invalid"),
|
|
1196
|
-
|
|
1208
|
+
n.removeAttribute("aria-invalid"), w(n, e, "fieldControlError"), n.removeAttribute("data-formie-input-has-error"), i && Ot(n, i), a.forEach((e) => {
|
|
1209
|
+
At(n, e);
|
|
1197
1210
|
});
|
|
1198
1211
|
});
|
|
1199
|
-
}),
|
|
1212
|
+
}), y(e);
|
|
1200
1213
|
}
|
|
1201
|
-
function
|
|
1214
|
+
function Mt(e) {
|
|
1202
1215
|
e.querySelectorAll("[data-formie-error-container], [data-formie-errors]").forEach((t) => {
|
|
1203
1216
|
let n = t;
|
|
1204
1217
|
n.querySelectorAll("[data-formie-error]").forEach((e) => {
|
|
1205
1218
|
e.remove();
|
|
1206
|
-
}),
|
|
1219
|
+
}), w(n, e, "message", "messageError"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-error"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-error]") || (n.innerHTML = "");
|
|
1207
1220
|
});
|
|
1208
1221
|
}
|
|
1209
|
-
function
|
|
1210
|
-
|
|
1222
|
+
function Nt(e) {
|
|
1223
|
+
yt(e), e.querySelectorAll("[data-formie-message-success]:not([data-formie-success-container])").forEach((e) => {
|
|
1211
1224
|
e.remove();
|
|
1212
1225
|
}), e.querySelectorAll("[data-formie-success-container]").forEach((t) => {
|
|
1213
1226
|
let n = t;
|
|
1214
1227
|
n.querySelectorAll("[data-formie-success]").forEach((e) => {
|
|
1215
1228
|
e.remove();
|
|
1216
|
-
}),
|
|
1217
|
-
}),
|
|
1229
|
+
}), w(n, e, "message", "messageSuccess"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-success"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-success]") || (n.innerHTML = "");
|
|
1230
|
+
}), mt(e) === "message" && vt(e) || s(e, !1);
|
|
1218
1231
|
}
|
|
1219
|
-
function
|
|
1232
|
+
function Pt(e) {
|
|
1220
1233
|
e.querySelectorAll("[aria-invalid=\"true\"]").forEach((e) => {
|
|
1221
1234
|
e.removeAttribute("aria-invalid");
|
|
1222
1235
|
});
|
|
1223
1236
|
}
|
|
1224
|
-
function
|
|
1237
|
+
function Ft(e, t) {
|
|
1225
1238
|
let n = (e.getAttribute("aria-describedby") || "").trim(), r = n ? n.split(/\s+/) : [];
|
|
1226
1239
|
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
1227
1240
|
}
|
|
1228
|
-
function
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1241
|
+
function It(e, t) {
|
|
1242
|
+
let n = Ee(we(e));
|
|
1243
|
+
Object.entries(t).forEach(([t, r]) => {
|
|
1244
|
+
let i = e.querySelector(`[data-formie-field-handle="${t}"]`);
|
|
1245
|
+
if (!i) return;
|
|
1246
|
+
let a = Dt(i), o = a.id && a.id.trim() ? a.id : `${t}-errors`;
|
|
1247
|
+
a.id = o, De(a, n), T(i, e, "fieldLayoutError"), i.setAttribute("data-formie-field-has-error", "true"), r.forEach((t, n) => {
|
|
1234
1248
|
let r = document.createElement("div");
|
|
1235
|
-
r.setAttribute("data-formie-field-error", "true"), r.setAttribute("role", "alert"), r.id = `${
|
|
1249
|
+
r.setAttribute("data-formie-field-error", "true"), r.setAttribute("role", "alert"), r.id = `${o}-${n + 1}`, T(r, e, "fieldError"), r.textContent = t, a.appendChild(r);
|
|
1236
1250
|
});
|
|
1237
|
-
let
|
|
1238
|
-
|
|
1251
|
+
let s = a.querySelector("[data-formie-field-error]")?.id;
|
|
1252
|
+
i.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
1239
1253
|
let n = t;
|
|
1240
|
-
n.setAttribute("aria-invalid", "true"),
|
|
1241
|
-
let
|
|
1242
|
-
|
|
1254
|
+
n.setAttribute("aria-invalid", "true"), T(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), Ft(n, o), s && kt(n, s);
|
|
1255
|
+
let r = i.querySelector("[data-formie-instructions]");
|
|
1256
|
+
r?.id && Ft(n, r.id);
|
|
1243
1257
|
});
|
|
1244
|
-
}),
|
|
1258
|
+
}), y(e);
|
|
1245
1259
|
}
|
|
1246
|
-
function
|
|
1247
|
-
let n =
|
|
1248
|
-
|
|
1260
|
+
function Lt(e, t) {
|
|
1261
|
+
let n = wt(e), r = Tt(e, n);
|
|
1262
|
+
T(n, e, "errors"), t.forEach((t) => {
|
|
1249
1263
|
let n = document.createElement("div");
|
|
1250
|
-
n.setAttribute("data-formie-error", "true"), n.setAttribute("role", "alert"),
|
|
1264
|
+
n.setAttribute("data-formie-error", "true"), n.setAttribute("role", "alert"), T(n, e, "error"), n.innerHTML = t, r.appendChild(n);
|
|
1251
1265
|
});
|
|
1252
1266
|
}
|
|
1253
|
-
function
|
|
1254
|
-
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" ? !0 :
|
|
1267
|
+
function Rt(e, t) {
|
|
1268
|
+
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" ? !0 : mt(e) === "message" && gt(e) !== "";
|
|
1255
1269
|
}
|
|
1256
|
-
function
|
|
1257
|
-
let n =
|
|
1270
|
+
function zt(e, t) {
|
|
1271
|
+
let n = gt(e);
|
|
1258
1272
|
if (!n) return;
|
|
1259
|
-
let r =
|
|
1260
|
-
|
|
1273
|
+
let r = Et(e, n);
|
|
1274
|
+
T(r, e, "message", "messageSuccess"), r.setAttribute("data-formie-message", "true"), r.setAttribute("data-formie-message-success", "true"), r.setAttribute("role", "status"), r.setAttribute("aria-live", "polite"), r.setAttribute("aria-atomic", "true");
|
|
1261
1275
|
let i = document.createElement("div");
|
|
1262
|
-
i.setAttribute("data-formie-success", "true"),
|
|
1263
|
-
let a =
|
|
1276
|
+
i.setAttribute("data-formie-success", "true"), T(i, e, "success"), i.innerHTML = t, r.appendChild(i), vt(e) && s(e, !0);
|
|
1277
|
+
let a = _t(e);
|
|
1264
1278
|
if (a !== null) {
|
|
1265
1279
|
let t = window.setTimeout(() => {
|
|
1266
|
-
|
|
1280
|
+
I.delete(e), Nt(e);
|
|
1267
1281
|
}, a);
|
|
1268
|
-
|
|
1282
|
+
I.set(e, t);
|
|
1269
1283
|
}
|
|
1270
1284
|
}
|
|
1271
|
-
function
|
|
1272
|
-
if (
|
|
1273
|
-
|
|
1285
|
+
function L(e, t) {
|
|
1286
|
+
if (jt(e), Mt(e), Nt(e), Pt(e), t.ok) {
|
|
1287
|
+
Rt(e, t) && zt(e, t.message || "");
|
|
1274
1288
|
return;
|
|
1275
1289
|
}
|
|
1276
|
-
t.fieldErrors &&
|
|
1290
|
+
t.fieldErrors && It(e, t.fieldErrors), t.formErrors?.length ? Lt(e, t.formErrors) : !t.fieldErrors && t.message && Lt(e, [t.message]), Pe(e);
|
|
1277
1291
|
}
|
|
1278
1292
|
//#endregion
|
|
1279
1293
|
//#region src/js/core/submit-flow.ts
|
|
1280
|
-
var
|
|
1281
|
-
function
|
|
1294
|
+
var Bt = C("general", "submit-flow");
|
|
1295
|
+
function Vt(e) {
|
|
1282
1296
|
return !(!e.ok && e.stage === "validate");
|
|
1283
1297
|
}
|
|
1284
|
-
function
|
|
1298
|
+
function Ht(e) {
|
|
1285
1299
|
return e ? !!(e.keepSubmitLoading === !0 || e.ok && e.redirect?.url && e.redirect.target !== "new-tab") : !1;
|
|
1286
1300
|
}
|
|
1287
|
-
function
|
|
1288
|
-
|
|
1301
|
+
function Ut(e) {
|
|
1302
|
+
jt(e), Mt(e), Nt(e), Pt(e);
|
|
1289
1303
|
}
|
|
1290
|
-
async function
|
|
1291
|
-
let { id: t, target: n, form: r, bus: i, validator: a, validateOnSubmit: o, action: s, submitter: c, waitForSubmitDelay: l, onRefreshTokensAfterSubmit: u, dispatchSubmitResult:
|
|
1292
|
-
|
|
1293
|
-
let
|
|
1304
|
+
async function Wt(e) {
|
|
1305
|
+
let { id: t, target: n, form: r, bus: i, validator: a, validateOnSubmit: o, action: s, submitter: c, waitForSubmitDelay: l, onRefreshTokensAfterSubmit: u, dispatchSubmitResult: f } = e;
|
|
1306
|
+
Ut(r), m(r, c || null);
|
|
1307
|
+
let p = {
|
|
1294
1308
|
ok: !1,
|
|
1295
1309
|
code: "SUBMIT_ERROR",
|
|
1296
1310
|
message: "Submission failed.",
|
|
1297
1311
|
formErrors: ["Submission failed."]
|
|
1298
1312
|
};
|
|
1299
1313
|
try {
|
|
1300
|
-
await l(r),
|
|
1314
|
+
await l(r), p = await tt(r, s, i, {
|
|
1301
1315
|
validator: a,
|
|
1302
1316
|
validateOnSubmit: o
|
|
1303
|
-
}),
|
|
1317
|
+
}), L(r, p), g(r, p, s), Vt(p) && await u(p), f(p);
|
|
1304
1318
|
} catch (e) {
|
|
1305
|
-
|
|
1319
|
+
p = {
|
|
1306
1320
|
ok: !1,
|
|
1307
1321
|
code: "SUBMIT_ERROR",
|
|
1308
1322
|
message: e instanceof Error ? e.message : "Submission failed.",
|
|
1309
1323
|
formErrors: [e instanceof Error ? e.message : "Submission failed."]
|
|
1310
|
-
},
|
|
1324
|
+
}, L(r, p), f(p), Bt.warn("Submit failed with exception.", {
|
|
1311
1325
|
id: t,
|
|
1312
1326
|
action: s,
|
|
1313
1327
|
target: n,
|
|
1314
1328
|
error: e instanceof Error ? e.message : e
|
|
1315
1329
|
});
|
|
1316
1330
|
} finally {
|
|
1317
|
-
|
|
1331
|
+
Ht(p) || d(r);
|
|
1318
1332
|
}
|
|
1319
|
-
return
|
|
1333
|
+
return p;
|
|
1320
1334
|
}
|
|
1321
1335
|
//#endregion
|
|
1322
1336
|
//#region src/js/modules/registry.ts
|
|
1323
|
-
var
|
|
1337
|
+
var R = class {
|
|
1324
1338
|
constructor() {
|
|
1325
1339
|
this.modules = /* @__PURE__ */ new Map();
|
|
1326
1340
|
}
|
|
@@ -1337,27 +1351,27 @@ var Vt = class {
|
|
|
1337
1351
|
getAll() {
|
|
1338
1352
|
return Array.from(this.modules.values());
|
|
1339
1353
|
}
|
|
1340
|
-
},
|
|
1341
|
-
"address-finder": () => import("./chunks/address-finder-
|
|
1342
|
-
"google-address": () => import("./chunks/google-address-
|
|
1343
|
-
loqate: () => import("./chunks/loqate-
|
|
1354
|
+
}, Gt = {
|
|
1355
|
+
"address-finder": () => import("./chunks/address-finder-k7_BXaRe.js").then((e) => e.addressFinderModule),
|
|
1356
|
+
"google-address": () => import("./chunks/google-address-BH3Zhi06.js").then((e) => e.googleAddressModule),
|
|
1357
|
+
loqate: () => import("./chunks/loqate-CJPzBmSm.js").then((e) => e.loqateModule),
|
|
1344
1358
|
"place-kit": () => import("./chunks/place-kit-BGHklIZ-.js").then((e) => e.placeKitModule)
|
|
1345
|
-
},
|
|
1346
|
-
"captcha-eu": () => import("./chunks/captcha-eu-
|
|
1347
|
-
"friendly-captcha-v1": () => import("./chunks/friendly-captcha-v1-
|
|
1348
|
-
"friendly-captcha-v2": () => import("./chunks/friendly-captcha-v2-
|
|
1349
|
-
hcaptcha: () => import("./chunks/hcaptcha-
|
|
1350
|
-
"recaptcha-enterprise": () => import("./chunks/recaptcha-enterprise-
|
|
1351
|
-
"recaptcha-v2-checkbox": () => import("./chunks/recaptcha-v2-checkbox-
|
|
1352
|
-
"recaptcha-v2-invisible": () => import("./chunks/recaptcha-v2-invisible-
|
|
1353
|
-
"recaptcha-v3": () => import("./chunks/recaptcha-v3-
|
|
1354
|
-
snaptcha: () => import("./chunks/snaptcha-
|
|
1355
|
-
turnstile: () => import("./chunks/turnstile-
|
|
1356
|
-
},
|
|
1359
|
+
}, Kt = {
|
|
1360
|
+
"captcha-eu": () => import("./chunks/captcha-eu-CGm8Lbrj.js").then((e) => e.captchaEuModule),
|
|
1361
|
+
"friendly-captcha-v1": () => import("./chunks/friendly-captcha-v1-C_2reOXr.js").then((e) => e.friendlyCaptchaV1Module),
|
|
1362
|
+
"friendly-captcha-v2": () => import("./chunks/friendly-captcha-v2-CLSAbkqx.js").then((e) => e.friendlyCaptchaV2Module),
|
|
1363
|
+
hcaptcha: () => import("./chunks/hcaptcha-CGLAmgjO.js").then((e) => e.hcaptchaModule),
|
|
1364
|
+
"recaptcha-enterprise": () => import("./chunks/recaptcha-enterprise-XPId5-bS.js").then((e) => e.recaptchaEnterpriseModule),
|
|
1365
|
+
"recaptcha-v2-checkbox": () => import("./chunks/recaptcha-v2-checkbox-Cy-0PEPc.js").then((e) => e.recaptchaV2CheckboxModule),
|
|
1366
|
+
"recaptcha-v2-invisible": () => import("./chunks/recaptcha-v2-invisible-BwRH540O.js").then((e) => e.recaptchaV2InvisibleModule),
|
|
1367
|
+
"recaptcha-v3": () => import("./chunks/recaptcha-v3-No4Ykrhk.js").then((e) => e.recaptchaV3Module),
|
|
1368
|
+
snaptcha: () => import("./chunks/snaptcha-DKx98oon.js").then((e) => e.snaptchaModule),
|
|
1369
|
+
turnstile: () => import("./chunks/turnstile-DJakPzQD.js").then((e) => e.turnstileModule)
|
|
1370
|
+
}, qt = {
|
|
1357
1371
|
calculations: () => import("./chunks/calculations-CeDgB9jt.js").then((e) => e.calculationsModule),
|
|
1358
1372
|
"checkbox-radio": () => import("./chunks/checkbox-radio-DQ0H67Tj.js").then((e) => e.checkboxRadioModule),
|
|
1359
1373
|
combobox: () => import("./chunks/combobox-D-2b42wn.js").then((e) => e.comboboxModule),
|
|
1360
|
-
conditions: () => import("./chunks/conditions-
|
|
1374
|
+
conditions: () => import("./chunks/conditions-B6_nzpeE.js").then((e) => e.conditionsModule),
|
|
1361
1375
|
"custom-google-maps": () => import("./chunks/custom-google-maps-BsaSirEZ.js").then((e) => e.customGoogleMapsModule),
|
|
1362
1376
|
"custom-link": () => import("./chunks/custom-link-CJ1-FjEM.js").then((e) => e.customLinkModule),
|
|
1363
1377
|
"custom-maps": () => import("./chunks/custom-maps-DYW_pBid.js").then((e) => e.customMapsModule),
|
|
@@ -1371,87 +1385,90 @@ var Vt = class {
|
|
|
1371
1385
|
repeater: () => import("./chunks/repeater-B5leVxZU.js").then((e) => e.repeaterModule),
|
|
1372
1386
|
"rich-text": () => import("./chunks/rich-text-D0sb8bmX.js").then((e) => e.richTextModule),
|
|
1373
1387
|
signature: () => import("./chunks/signature-xz4QO7CR.js").then((e) => e.signatureModule),
|
|
1374
|
-
summary: () => import("./chunks/summary-
|
|
1388
|
+
summary: () => import("./chunks/summary-Dks0gXS3.js").then((e) => e.summaryModule),
|
|
1389
|
+
"survey-likert": () => import("./chunks/survey-likert-DmJ3klhP.js").then((e) => e.surveyLikertModule),
|
|
1390
|
+
"survey-rank": () => import("./chunks/survey-rank-DeUenftw.js").then((e) => e.surveyRankModule),
|
|
1391
|
+
"survey-rating": () => import("./chunks/survey-rating-BPUYDgBJ.js").then((e) => e.surveyRatingModule),
|
|
1375
1392
|
table: () => import("./chunks/table-C-lkQN6I.js").then((e) => e.tableModule),
|
|
1376
1393
|
"text-limit": () => import("./chunks/text-limit-DbgEFHLO.js").then((e) => e.textLimitModule)
|
|
1377
|
-
},
|
|
1378
|
-
bpoint: () => import("./chunks/bpoint-
|
|
1379
|
-
eway: () => import("./chunks/eway-
|
|
1380
|
-
"go-cardless": () => import("./chunks/go-cardless-
|
|
1381
|
-
mollie: () => import("./chunks/mollie-
|
|
1382
|
-
moneris: () => import("./chunks/moneris-
|
|
1383
|
-
opayo: () => import("./chunks/opayo-
|
|
1384
|
-
paddle: () => import("./chunks/paddle-
|
|
1385
|
-
paypal: () => import("./chunks/paypal-
|
|
1386
|
-
payway: () => import("./chunks/payway-
|
|
1387
|
-
square: () => import("./chunks/square-
|
|
1388
|
-
stripe: () => import("./chunks/stripe-
|
|
1389
|
-
},
|
|
1390
|
-
...
|
|
1391
|
-
...
|
|
1392
|
-
...
|
|
1393
|
-
...
|
|
1394
|
-
},
|
|
1395
|
-
async function
|
|
1394
|
+
}, Jt = {
|
|
1395
|
+
bpoint: () => import("./chunks/bpoint-CwSw_p7A.js").then((e) => e.bpointModule),
|
|
1396
|
+
eway: () => import("./chunks/eway-B30BMlDp.js").then((e) => e.ewayModule),
|
|
1397
|
+
"go-cardless": () => import("./chunks/go-cardless-BiF3iLel.js").then((e) => e.goCardlessModule),
|
|
1398
|
+
mollie: () => import("./chunks/mollie-D__SwtcH.js").then((e) => e.mollieModule),
|
|
1399
|
+
moneris: () => import("./chunks/moneris-KJS1BKx7.js").then((e) => e.monerisModule),
|
|
1400
|
+
opayo: () => import("./chunks/opayo-A_LIkc-v.js").then((e) => e.opayoModule),
|
|
1401
|
+
paddle: () => import("./chunks/paddle-BjbOOb0m.js").then((e) => e.paddleModule),
|
|
1402
|
+
paypal: () => import("./chunks/paypal-CyjHIV8v.js").then((e) => e.paypalModule),
|
|
1403
|
+
payway: () => import("./chunks/payway-a_cyrr3j.js").then((e) => e.paywayModule),
|
|
1404
|
+
square: () => import("./chunks/square-Bga6WXHV.js").then((e) => e.squareModule),
|
|
1405
|
+
stripe: () => import("./chunks/stripe-BlqVocl3.js").then((e) => e.stripeModule)
|
|
1406
|
+
}, Yt = {
|
|
1407
|
+
...qt,
|
|
1408
|
+
...Gt,
|
|
1409
|
+
...Kt,
|
|
1410
|
+
...Jt
|
|
1411
|
+
}, z = /* @__PURE__ */ new Map(), B = C("general", "loader"), Xt = Function("src", "return import(src);");
|
|
1412
|
+
async function V(t, n, i, a) {
|
|
1396
1413
|
await t(r(i), a), await t(e(n, i), a);
|
|
1397
1414
|
}
|
|
1398
|
-
function
|
|
1415
|
+
function Zt(e) {
|
|
1399
1416
|
return !!e && typeof e == "object" && typeof e.id == "string" && typeof e.setup == "function" && typeof e.match == "function";
|
|
1400
1417
|
}
|
|
1401
|
-
async function
|
|
1402
|
-
let n =
|
|
1403
|
-
return n ? (
|
|
1418
|
+
async function Qt(e, t) {
|
|
1419
|
+
let n = Yt[e];
|
|
1420
|
+
return n ? (z.has(e) || z.set(e, (async () => {
|
|
1404
1421
|
try {
|
|
1405
1422
|
let e = await n();
|
|
1406
|
-
return
|
|
1423
|
+
return Zt(e) ? (t.registry.register(e), e) : null;
|
|
1407
1424
|
} catch (t) {
|
|
1408
|
-
return console.error("[formie] Failed to load builtin module:", e, t),
|
|
1425
|
+
return console.error("[formie] Failed to load builtin module:", e, t), B.warn("Failed loading builtin module.", {
|
|
1409
1426
|
moduleId: e,
|
|
1410
1427
|
error: t
|
|
1411
1428
|
}), null;
|
|
1412
1429
|
}
|
|
1413
|
-
})()),
|
|
1430
|
+
})()), z.get(e) || null) : null;
|
|
1414
1431
|
}
|
|
1415
|
-
async function
|
|
1432
|
+
async function $t(e) {
|
|
1416
1433
|
try {
|
|
1417
|
-
let t = await
|
|
1418
|
-
return
|
|
1434
|
+
let t = await Xt(e), n = t?.default || t?.formieModule || null;
|
|
1435
|
+
return Zt(n) ? n : null;
|
|
1419
1436
|
} catch (t) {
|
|
1420
|
-
return console.error("[formie] Failed to load module from src:", e, t),
|
|
1437
|
+
return console.error("[formie] Failed to load module from src:", e, t), B.warn("Failed loading module from src.", {
|
|
1421
1438
|
src: e,
|
|
1422
1439
|
error: t
|
|
1423
1440
|
}), null;
|
|
1424
1441
|
}
|
|
1425
1442
|
}
|
|
1426
|
-
async function
|
|
1443
|
+
async function en(e, t) {
|
|
1427
1444
|
let n = t.registry.get(e.id);
|
|
1428
1445
|
if (n) return n;
|
|
1429
|
-
let r = await
|
|
1446
|
+
let r = await Qt(e.id, t);
|
|
1430
1447
|
if (r) return r;
|
|
1431
1448
|
if (e.src) {
|
|
1432
|
-
let n = await
|
|
1449
|
+
let n = await $t(e.src);
|
|
1433
1450
|
if (n) return t.registry.register(n), n;
|
|
1434
1451
|
}
|
|
1435
1452
|
return null;
|
|
1436
1453
|
}
|
|
1437
|
-
function
|
|
1454
|
+
function tn(e) {
|
|
1438
1455
|
return typeof window.CSS?.escape == "function" ? window.CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
|
|
1439
1456
|
}
|
|
1440
|
-
function
|
|
1457
|
+
function H(e, t) {
|
|
1441
1458
|
return e.matches(t) ? [e, ...Array.from(e.querySelectorAll(t))] : Array.from(e.querySelectorAll(t));
|
|
1442
1459
|
}
|
|
1443
|
-
function
|
|
1460
|
+
function nn(e, t) {
|
|
1444
1461
|
let n = t.setupContext.root, r = t.setupContext.form, i = e.targetType, a = e.targetId;
|
|
1445
|
-
return i === "selector" ?
|
|
1462
|
+
return i === "selector" ? H(n, a).map((e) => ({
|
|
1446
1463
|
scope: i,
|
|
1447
1464
|
element: e
|
|
1448
|
-
})) : i === "field" ?
|
|
1465
|
+
})) : i === "field" ? H(n, `[data-formie-field-handle="${tn(a)}"]`).map((e) => ({
|
|
1449
1466
|
scope: i,
|
|
1450
1467
|
element: e
|
|
1451
|
-
})) : i === "page" ?
|
|
1468
|
+
})) : i === "page" ? H(n, `[data-formie-page-id="${tn(a)}"]`).map((e) => ({
|
|
1452
1469
|
scope: i,
|
|
1453
1470
|
element: e
|
|
1454
|
-
})) : i === "button" ?
|
|
1471
|
+
})) : i === "button" ? H(n, `[data-formie-action="${tn(a)}"]`).map((e) => ({
|
|
1455
1472
|
scope: i,
|
|
1456
1473
|
element: e
|
|
1457
1474
|
})) : [{
|
|
@@ -1459,26 +1476,26 @@ function Qt(e, t) {
|
|
|
1459
1476
|
element: r || n
|
|
1460
1477
|
}];
|
|
1461
1478
|
}
|
|
1462
|
-
function
|
|
1479
|
+
function rn(e, t) {
|
|
1463
1480
|
return (e.targets && e.targets.length > 0 ? e.targets : [{
|
|
1464
1481
|
targetType: "form",
|
|
1465
1482
|
targetId: "form"
|
|
1466
|
-
}]).flatMap((e) =>
|
|
1483
|
+
}]).flatMap((e) => nn(e, t));
|
|
1467
1484
|
}
|
|
1468
|
-
async function
|
|
1485
|
+
async function an(e, t) {
|
|
1469
1486
|
let n = [];
|
|
1470
|
-
|
|
1487
|
+
B.log("Loading module manifest.", { manifestCount: e.length });
|
|
1471
1488
|
for (let r of e) {
|
|
1472
|
-
let e = await
|
|
1489
|
+
let e = await en(r, t);
|
|
1473
1490
|
if (!e) {
|
|
1474
|
-
|
|
1491
|
+
B.warn("Skipping manifest item (definition not resolved).", {
|
|
1475
1492
|
moduleId: r.id,
|
|
1476
1493
|
src: r.src
|
|
1477
1494
|
});
|
|
1478
1495
|
continue;
|
|
1479
1496
|
}
|
|
1480
|
-
let i =
|
|
1481
|
-
|
|
1497
|
+
let i = rn(r, t);
|
|
1498
|
+
B.log("Resolved module targets.", {
|
|
1482
1499
|
moduleId: e.id,
|
|
1483
1500
|
targets: r.targets || [],
|
|
1484
1501
|
targetCount: i.length
|
|
@@ -1491,7 +1508,7 @@ async function en(e, t) {
|
|
|
1491
1508
|
manifestItem: r
|
|
1492
1509
|
};
|
|
1493
1510
|
if (!e.match(i)) {
|
|
1494
|
-
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.`),
|
|
1511
|
+
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.`), B.log("Module target did not match predicate.", {
|
|
1495
1512
|
moduleId: e.id,
|
|
1496
1513
|
scope: a.scope
|
|
1497
1514
|
});
|
|
@@ -1505,7 +1522,7 @@ async function en(e, t) {
|
|
|
1505
1522
|
options: o,
|
|
1506
1523
|
manifestItem: r
|
|
1507
1524
|
};
|
|
1508
|
-
await
|
|
1525
|
+
await V(t.setupContext.emit, s, "before-setup", c);
|
|
1509
1526
|
let l = null;
|
|
1510
1527
|
try {
|
|
1511
1528
|
let n = await e.setup({
|
|
@@ -1516,25 +1533,25 @@ async function en(e, t) {
|
|
|
1516
1533
|
});
|
|
1517
1534
|
n && (l = n);
|
|
1518
1535
|
} catch (t) {
|
|
1519
|
-
console.error(`[formie] Module "${e.id}" setup failed:`, t),
|
|
1536
|
+
console.error(`[formie] Module "${e.id}" setup failed:`, t), B.warn("Module setup failed.", {
|
|
1520
1537
|
moduleId: e.id,
|
|
1521
1538
|
scope: a.scope,
|
|
1522
1539
|
error: t
|
|
1523
1540
|
});
|
|
1524
1541
|
}
|
|
1525
|
-
await
|
|
1542
|
+
await V(t.setupContext.emit, s, "after-setup", {
|
|
1526
1543
|
...c,
|
|
1527
1544
|
instanceCreated: !!l
|
|
1528
|
-
}), l && (
|
|
1545
|
+
}), l && (B.log("Module instance created.", {
|
|
1529
1546
|
moduleId: e.id,
|
|
1530
1547
|
scope: a.scope
|
|
1531
1548
|
}), n.push({
|
|
1532
1549
|
...l,
|
|
1533
1550
|
destroy: async () => {
|
|
1534
|
-
|
|
1551
|
+
B.log("Destroying module instance.", {
|
|
1535
1552
|
moduleId: e.id,
|
|
1536
1553
|
scope: a.scope
|
|
1537
|
-
}), await
|
|
1554
|
+
}), await V(t.setupContext.emit, s, "before-destroy", c), await l.destroy(), await V(t.setupContext.emit, s, "after-destroy", c), B.log("Module instance destroyed.", {
|
|
1538
1555
|
moduleId: e.id,
|
|
1539
1556
|
scope: a.scope
|
|
1540
1557
|
});
|
|
@@ -1542,54 +1559,64 @@ async function en(e, t) {
|
|
|
1542
1559
|
}));
|
|
1543
1560
|
}
|
|
1544
1561
|
}
|
|
1545
|
-
return
|
|
1562
|
+
return B.log("Module manifest processing complete.", { instanceCount: n.length }), n;
|
|
1563
|
+
}
|
|
1564
|
+
//#endregion
|
|
1565
|
+
//#region src/js/utils/form-started-at.ts
|
|
1566
|
+
var on = "formie:formStartedAt:";
|
|
1567
|
+
function sn(e) {
|
|
1568
|
+
let t = e.querySelector("input[name=\"formStartedAt\"]");
|
|
1569
|
+
if (!t) return;
|
|
1570
|
+
let n = e.querySelector("input[name=\"renderId\"]")?.value?.trim() ?? "", r = n ? `${on}${n}` : null, i = r ? sessionStorage.getItem(r) : null;
|
|
1571
|
+
i || (i = String(Date.now()), r && sessionStorage.setItem(r, i)), t.value = i;
|
|
1546
1572
|
}
|
|
1547
1573
|
//#endregion
|
|
1548
1574
|
//#region src/js/utils/unload-warning.ts
|
|
1549
|
-
var
|
|
1575
|
+
var cn = new Set([
|
|
1550
1576
|
"CRAFT_CSRF_TOKEN",
|
|
1551
1577
|
"action",
|
|
1552
1578
|
"redirect",
|
|
1553
1579
|
"requestToken",
|
|
1554
1580
|
"renderId",
|
|
1581
|
+
"formStartedAt",
|
|
1555
1582
|
"submitAction",
|
|
1556
1583
|
"pageId",
|
|
1557
1584
|
"draftContextToken",
|
|
1558
1585
|
"draftContext",
|
|
1559
1586
|
"continuationToken"
|
|
1560
1587
|
]);
|
|
1561
|
-
function
|
|
1588
|
+
function ln(e, t) {
|
|
1562
1589
|
if (e == null) return String(e);
|
|
1563
1590
|
if (typeof e == "string") return JSON.stringify(e);
|
|
1564
1591
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1565
1592
|
if (typeof e == "function") return "[function]";
|
|
1566
1593
|
if (typeof File < "u" && e instanceof File) return `[file:${e.name}:${e.size}:${e.type}]`;
|
|
1567
1594
|
if (typeof Blob < "u" && e instanceof Blob) return `[blob:${e.size}:${e.type}]`;
|
|
1568
|
-
if (Array.isArray(e)) return `[${e.map((e) =>
|
|
1595
|
+
if (Array.isArray(e)) return `[${e.map((e) => ln(e, t)).join(",")}]`;
|
|
1569
1596
|
if (typeof e == "object") {
|
|
1570
1597
|
if (t.has(e)) return "[circular]";
|
|
1571
1598
|
t.add(e);
|
|
1572
|
-
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${
|
|
1599
|
+
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${ln(n, t)}`);
|
|
1573
1600
|
return t.delete(e), `{${n.join(",")}}`;
|
|
1574
1601
|
}
|
|
1575
1602
|
return JSON.stringify(String(e));
|
|
1576
1603
|
}
|
|
1577
|
-
function
|
|
1578
|
-
return
|
|
1604
|
+
function un(e) {
|
|
1605
|
+
return ln(e, /* @__PURE__ */ new WeakSet());
|
|
1579
1606
|
}
|
|
1580
|
-
function
|
|
1607
|
+
function dn(e) {
|
|
1581
1608
|
if (!e) return !1;
|
|
1582
1609
|
let t = e.endsWith("[]") ? e.slice(0, -2) : e;
|
|
1583
|
-
return !
|
|
1610
|
+
return !cn.has(t);
|
|
1584
1611
|
}
|
|
1585
|
-
function
|
|
1586
|
-
return
|
|
1612
|
+
function fn(e) {
|
|
1613
|
+
return un(Array.from(new FormData(e).entries()).filter(([e]) => dn(String(e || ""))));
|
|
1587
1614
|
}
|
|
1588
|
-
function
|
|
1615
|
+
function pn(e, t = {}) {
|
|
1589
1616
|
let n = null, r = !1, i = !1, a = null, o = null, s = null, c = () => {
|
|
1590
1617
|
a !== null && (window.cancelAnimationFrame(a), a = null), o !== null && (window.clearTimeout(o), o = null), s !== null && (window.clearTimeout(s), s = null);
|
|
1591
|
-
}, l = () => r ? (i =
|
|
1592
|
-
n =
|
|
1618
|
+
}, l = () => r ? (i = fn(e) !== n, i) : !1, u = () => {
|
|
1619
|
+
n = fn(e), r = !0, i = !1;
|
|
1593
1620
|
}, d = () => {
|
|
1594
1621
|
c(), r = !1, a = window.requestAnimationFrame(() => {
|
|
1595
1622
|
a = null, s = window.setTimeout(() => {
|
|
@@ -1613,41 +1640,67 @@ function sn(e, t = {}) {
|
|
|
1613
1640
|
};
|
|
1614
1641
|
}
|
|
1615
1642
|
//#endregion
|
|
1643
|
+
//#region src/js/validation/enter-key-guard.ts
|
|
1644
|
+
function mn(e) {
|
|
1645
|
+
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]");
|
|
1646
|
+
}
|
|
1647
|
+
function hn(e, t) {
|
|
1648
|
+
let n = e.querySelectorAll(`[data-formie-action="${t}"]`);
|
|
1649
|
+
return Array.from(n).some((e) => !mn(e));
|
|
1650
|
+
}
|
|
1651
|
+
function gn(e) {
|
|
1652
|
+
let { final: t } = f(e);
|
|
1653
|
+
return "submit";
|
|
1654
|
+
}
|
|
1655
|
+
function _n(e) {
|
|
1656
|
+
return !hn(e, gn(e));
|
|
1657
|
+
}
|
|
1658
|
+
function vn(e) {
|
|
1659
|
+
let t = (t) => {
|
|
1660
|
+
if (t.key !== "Enter" || t.defaultPrevented) return;
|
|
1661
|
+
let n = t.target;
|
|
1662
|
+
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") || _n(e) && t.preventDefault());
|
|
1663
|
+
};
|
|
1664
|
+
return e.addEventListener("keydown", t, !0), () => {
|
|
1665
|
+
e.removeEventListener("keydown", t, !0);
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
//#endregion
|
|
1616
1669
|
//#region src/js/core/create-formie-client.ts
|
|
1617
|
-
var
|
|
1618
|
-
function
|
|
1670
|
+
var U = "[data-formie]:not([data-formie-init=\"false\"]), [data-formie-form]:not([data-formie-init=\"false\"])", yn = 300, bn = "/actions/formie/server/forms/render", xn = "/api", Sn = "/actions/formie/server/forms/refresh-tokens", Cn = "/actions/formie/server/submissions/submit", wn = "/actions/formie/server/submissions/set-page", Tn = "/actions/formie/server/submissions/clear-submission", En = "/actions/formie/file-upload/hydrate", W = C("general", "client"), Dn = /* @__PURE__ */ new Set();
|
|
1671
|
+
function G(e, t) {
|
|
1619
1672
|
if (e == null || e === "") return t;
|
|
1620
1673
|
let n = e.toLowerCase();
|
|
1621
1674
|
return !(n === "false" || n === "0" || n === "off");
|
|
1622
1675
|
}
|
|
1623
|
-
function
|
|
1624
|
-
return e.formieRefreshTokens != null && e.formieRefreshTokens !== "" ?
|
|
1676
|
+
function On(e) {
|
|
1677
|
+
return e.formieRefreshTokens != null && e.formieRefreshTokens !== "" ? G(e.formieRefreshTokens, !1) : e.formieStaticCache != null && e.formieStaticCache !== "" ? G(e.formieStaticCache, !1) : !1;
|
|
1625
1678
|
}
|
|
1626
|
-
function
|
|
1679
|
+
function K(e) {
|
|
1627
1680
|
let t = e instanceof HTMLElement ? e.dataset : {};
|
|
1628
1681
|
return {
|
|
1629
1682
|
mode: "server-rendered",
|
|
1630
1683
|
transport: t.formieTransport || "rest",
|
|
1631
1684
|
formHandle: t.formieHandle,
|
|
1632
1685
|
endpoint: t.formieEndpoint,
|
|
1633
|
-
staticCache:
|
|
1634
|
-
autoVisible:
|
|
1635
|
-
compatibility:
|
|
1686
|
+
staticCache: On(t),
|
|
1687
|
+
autoVisible: G(t.formieAutoVisible, !0),
|
|
1688
|
+
compatibility: G(t.formieCompatibility, !1)
|
|
1636
1689
|
};
|
|
1637
1690
|
}
|
|
1638
|
-
function
|
|
1691
|
+
function q(e) {
|
|
1639
1692
|
return e || "server-rendered";
|
|
1640
1693
|
}
|
|
1641
|
-
function
|
|
1694
|
+
function J(e) {
|
|
1642
1695
|
return e || "rest";
|
|
1643
1696
|
}
|
|
1644
|
-
function
|
|
1697
|
+
function Y(e) {
|
|
1645
1698
|
return e instanceof HTMLFormElement ? e : e.querySelector("form");
|
|
1646
1699
|
}
|
|
1647
|
-
function
|
|
1648
|
-
|
|
1700
|
+
function kn(e, t) {
|
|
1701
|
+
Dn.has(e) || (Dn.add(e), W.warn(t));
|
|
1649
1702
|
}
|
|
1650
|
-
function
|
|
1703
|
+
function An(e, t) {
|
|
1651
1704
|
if (!e) return e;
|
|
1652
1705
|
try {
|
|
1653
1706
|
return new URL(e).toString();
|
|
@@ -1659,21 +1712,21 @@ function yn(e, t) {
|
|
|
1659
1712
|
return e;
|
|
1660
1713
|
}
|
|
1661
1714
|
}
|
|
1662
|
-
function
|
|
1715
|
+
function X(e, t) {
|
|
1663
1716
|
let n = (e || "").trim();
|
|
1664
|
-
return n ? n.includes("/actions/") ? n :
|
|
1717
|
+
return n ? n.includes("/actions/") ? n : An(t, n) : t;
|
|
1665
1718
|
}
|
|
1666
|
-
function
|
|
1667
|
-
return
|
|
1719
|
+
function jn(e, t) {
|
|
1720
|
+
return X(e.endpoint || t.dataset.formieEndpoint, bn);
|
|
1668
1721
|
}
|
|
1669
|
-
function
|
|
1722
|
+
function Mn(e, t) {
|
|
1670
1723
|
let n = (e.endpoint || t.dataset.formieEndpoint || "").trim();
|
|
1671
|
-
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n :
|
|
1724
|
+
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n : An(xn, n) : xn;
|
|
1672
1725
|
}
|
|
1673
|
-
function
|
|
1674
|
-
return
|
|
1726
|
+
function Nn(e, t) {
|
|
1727
|
+
return X(t.dataset.formieRefreshTokensEndpoint || e.endpoint || t.dataset.formieEndpoint, Sn);
|
|
1675
1728
|
}
|
|
1676
|
-
function
|
|
1729
|
+
function Pn(e, t) {
|
|
1677
1730
|
if (!e) return t;
|
|
1678
1731
|
try {
|
|
1679
1732
|
let n = new URL(e, window.location.origin), r = new URL(t, window.location.origin);
|
|
@@ -1684,42 +1737,42 @@ function Cn(e, t) {
|
|
|
1684
1737
|
return t;
|
|
1685
1738
|
}
|
|
1686
1739
|
}
|
|
1687
|
-
function
|
|
1688
|
-
let r = n.endpoint || e.dataset.formieEndpoint, i =
|
|
1689
|
-
t.setAttribute("action",
|
|
1690
|
-
let t = e.getAttribute("href"), n =
|
|
1691
|
-
e.setAttribute("href",
|
|
1740
|
+
function Fn(e, t, n) {
|
|
1741
|
+
let r = n.endpoint || e.dataset.formieEndpoint, i = X(r, Cn), a = t.getAttribute("action");
|
|
1742
|
+
t.setAttribute("action", Pn(a, i)), t.querySelectorAll("[data-formie-tab-link]").forEach((e) => {
|
|
1743
|
+
let t = e.getAttribute("href"), n = X(r, wn);
|
|
1744
|
+
e.setAttribute("href", Pn(t, n));
|
|
1692
1745
|
}), t.querySelectorAll("[data-formie-file-upload-hydrate-endpoint]").forEach((e) => {
|
|
1693
|
-
e.setAttribute("data-formie-file-upload-hydrate-endpoint",
|
|
1746
|
+
e.setAttribute("data-formie-file-upload-hydrate-endpoint", X(r, En));
|
|
1694
1747
|
});
|
|
1695
1748
|
}
|
|
1696
|
-
function
|
|
1749
|
+
function In(e, t) {
|
|
1697
1750
|
if (e === "graphql" && t !== "server-rendered") throw Error(`Formie ${t} mode does not support GraphQL transport yet.`);
|
|
1698
1751
|
}
|
|
1699
|
-
function
|
|
1752
|
+
function Ln(e) {
|
|
1700
1753
|
if (e == null) return !1;
|
|
1701
1754
|
let t = e.trim().toLowerCase();
|
|
1702
1755
|
return t === "true" || t === "1" || t === "";
|
|
1703
1756
|
}
|
|
1704
|
-
function
|
|
1705
|
-
return
|
|
1757
|
+
function Rn(e) {
|
|
1758
|
+
return G(e.dataset.formieAutomaticSubmissionState, !0);
|
|
1706
1759
|
}
|
|
1707
|
-
function
|
|
1708
|
-
return
|
|
1760
|
+
function zn(e, t, n) {
|
|
1761
|
+
return X(n.dataset.formieClearSubmissionEndpoint || e.endpoint || t.dataset.formieEndpoint, Tn);
|
|
1709
1762
|
}
|
|
1710
|
-
function
|
|
1711
|
-
return
|
|
1763
|
+
function Bn(e) {
|
|
1764
|
+
return Ln(e.dataset.formieUnloadWarning);
|
|
1712
1765
|
}
|
|
1713
|
-
function
|
|
1766
|
+
function Vn(e, t) {
|
|
1714
1767
|
e.setAttribute("data-formie-internal-navigation", t);
|
|
1715
1768
|
}
|
|
1716
|
-
function
|
|
1769
|
+
function Hn(e) {
|
|
1717
1770
|
e.removeAttribute("data-formie-internal-navigation");
|
|
1718
1771
|
}
|
|
1719
|
-
function
|
|
1772
|
+
function Un(e) {
|
|
1720
1773
|
return e.getAttribute("data-formie-internal-navigation") !== null;
|
|
1721
1774
|
}
|
|
1722
|
-
function
|
|
1775
|
+
function Wn(e, t) {
|
|
1723
1776
|
if (!e) return !1;
|
|
1724
1777
|
try {
|
|
1725
1778
|
return new URL(e, window.location.origin).searchParams.has(t);
|
|
@@ -1727,30 +1780,30 @@ function Nn(e, t) {
|
|
|
1727
1780
|
return !1;
|
|
1728
1781
|
}
|
|
1729
1782
|
}
|
|
1730
|
-
function
|
|
1731
|
-
return
|
|
1783
|
+
function Gn(e) {
|
|
1784
|
+
return Wn(window.location.href, "resumeToken") || Wn(e.getAttribute("action"), "resumeToken");
|
|
1732
1785
|
}
|
|
1733
|
-
function
|
|
1786
|
+
function Kn(e) {
|
|
1734
1787
|
return e instanceof MouseEvent ? e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey : !0;
|
|
1735
1788
|
}
|
|
1736
|
-
function
|
|
1789
|
+
function qn(e, t = 0) {
|
|
1737
1790
|
if (!e) return t;
|
|
1738
1791
|
let n = Number.parseInt(e, 10);
|
|
1739
1792
|
return Number.isFinite(n) ? n : t;
|
|
1740
1793
|
}
|
|
1741
|
-
function
|
|
1742
|
-
return Math.max(0,
|
|
1794
|
+
function Jn(e) {
|
|
1795
|
+
return Math.max(0, qn(e.dataset.formieSubmitDelay, yn));
|
|
1743
1796
|
}
|
|
1744
|
-
function
|
|
1745
|
-
return
|
|
1797
|
+
function Z(e) {
|
|
1798
|
+
return Ln(e.dataset.formieValidationOnSubmit);
|
|
1746
1799
|
}
|
|
1747
|
-
async function
|
|
1748
|
-
let t =
|
|
1800
|
+
async function Yn(e) {
|
|
1801
|
+
let t = Jn(e);
|
|
1749
1802
|
t < 1 || await new Promise((e) => {
|
|
1750
1803
|
window.setTimeout(e, t);
|
|
1751
1804
|
});
|
|
1752
1805
|
}
|
|
1753
|
-
function
|
|
1806
|
+
function Xn(e, t) {
|
|
1754
1807
|
let n = e?.getAttribute(t)?.trim();
|
|
1755
1808
|
if (!n) return null;
|
|
1756
1809
|
try {
|
|
@@ -1759,29 +1812,29 @@ function Rn(e, t) {
|
|
|
1759
1812
|
return console.error(`[formie] Failed to parse ${t}.`, e), null;
|
|
1760
1813
|
}
|
|
1761
1814
|
}
|
|
1762
|
-
function
|
|
1815
|
+
function Zn(e, t) {
|
|
1763
1816
|
let n = t || (e instanceof HTMLFormElement ? e : null);
|
|
1764
1817
|
if (!n) return null;
|
|
1765
|
-
let r =
|
|
1818
|
+
let r = Xn(n, "data-formie-modules"), i = Xn(n, "data-formie-theme");
|
|
1766
1819
|
return !r && !i ? null : {
|
|
1767
1820
|
modules: r || void 0,
|
|
1768
1821
|
theme: i || void 0
|
|
1769
1822
|
};
|
|
1770
1823
|
}
|
|
1771
|
-
function
|
|
1824
|
+
function Qn(e) {
|
|
1772
1825
|
if (!(e instanceof HTMLElement)) return !0;
|
|
1773
1826
|
if (!e.isConnected || e.hidden || e.closest("[hidden]")) return !1;
|
|
1774
1827
|
let t = window.getComputedStyle(e);
|
|
1775
1828
|
return t.display === "none" || t.visibility === "hidden" ? !1 : e.getClientRects().length > 0;
|
|
1776
1829
|
}
|
|
1777
|
-
function
|
|
1830
|
+
function $n(e, t) {
|
|
1778
1831
|
return t === document ? !0 : t instanceof Element ? t === e || t.contains(e) : !0;
|
|
1779
1832
|
}
|
|
1780
1833
|
function Q(e) {
|
|
1781
1834
|
let t = e, n = t.id ? `#${t.id}` : "", r = t.dataset?.formieHandle ? `[handle="${t.dataset.formieHandle}"]` : "";
|
|
1782
1835
|
return `${t.tagName ? t.tagName.toLowerCase() : "element"}${n}${r}`;
|
|
1783
1836
|
}
|
|
1784
|
-
function
|
|
1837
|
+
function er(e, t) {
|
|
1785
1838
|
if (t) {
|
|
1786
1839
|
if (t.csrf?.param && t.csrf?.token) {
|
|
1787
1840
|
let n = e.querySelector(`input[name="${t.csrf.param}"]`);
|
|
@@ -1804,12 +1857,12 @@ function Hn(e, t) {
|
|
|
1804
1857
|
});
|
|
1805
1858
|
}
|
|
1806
1859
|
}
|
|
1807
|
-
async function
|
|
1808
|
-
let n =
|
|
1860
|
+
async function tr(e, t) {
|
|
1861
|
+
let n = q(t.mode), r = J(t.transport);
|
|
1809
1862
|
if (n !== "server-rendered") return null;
|
|
1810
1863
|
if (t.payload) return t.payload.html && (e.innerHTML = t.payload.html), t.payload;
|
|
1811
|
-
|
|
1812
|
-
let i = !!
|
|
1864
|
+
In(r, n);
|
|
1865
|
+
let i = !!Y(e), a = t.formHandle || e.dataset.formieHandle;
|
|
1813
1866
|
if (i || !a) return null;
|
|
1814
1867
|
let o = {
|
|
1815
1868
|
mode: n,
|
|
@@ -1818,30 +1871,30 @@ async function Un(e, t) {
|
|
|
1818
1871
|
siteId: t.siteId,
|
|
1819
1872
|
theme: t.theme,
|
|
1820
1873
|
themeConfig: t.themeConfig
|
|
1821
|
-
}, s = r === "graphql" ?
|
|
1874
|
+
}, s = r === "graphql" ? Mn(t, e) : jn(t, e), c = r === "graphql" ? await Be(s, a, o) : await ze(s, a, {
|
|
1822
1875
|
...o,
|
|
1823
1876
|
endpoint: s
|
|
1824
1877
|
});
|
|
1825
1878
|
return c?.html && (e.innerHTML = c.html), c;
|
|
1826
1879
|
}
|
|
1827
|
-
async function
|
|
1880
|
+
async function nr(e, t, n) {
|
|
1828
1881
|
if (t.refreshTokens === !1) return;
|
|
1829
|
-
|
|
1882
|
+
In(J(t.transport), q(t.mode));
|
|
1830
1883
|
let r = t.formHandle || e.dataset.formieHandle;
|
|
1831
1884
|
if (!r) return;
|
|
1832
|
-
let i = await
|
|
1833
|
-
|
|
1885
|
+
let i = await M(Nn(t, e), r, n.querySelector("input[name=\"renderId\"]")?.value || void 0);
|
|
1886
|
+
er(n, i), h(e, "formie:refresh-tokens:refreshed", i);
|
|
1834
1887
|
}
|
|
1835
|
-
function
|
|
1836
|
-
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s =
|
|
1888
|
+
function rr(e, t, n, r, i, a) {
|
|
1889
|
+
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s = zn(n, e, t), c = !1, u = t.querySelectorAll("[data-formie-action]"), g = (e) => {
|
|
1837
1890
|
if (e) {
|
|
1838
1891
|
t.setAttribute("data-formie-pending-action", e);
|
|
1839
1892
|
return;
|
|
1840
1893
|
}
|
|
1841
1894
|
t.removeAttribute("data-formie-pending-action");
|
|
1842
1895
|
};
|
|
1843
|
-
if (
|
|
1844
|
-
let n =
|
|
1896
|
+
if (Bn(t)) {
|
|
1897
|
+
let n = pn(t, { shouldWarn: () => !Un(t) }), r = (e) => {
|
|
1845
1898
|
if (!(e instanceof CustomEvent)) return;
|
|
1846
1899
|
let t = e.detail;
|
|
1847
1900
|
t?.ok && t.action === "save" && n.scheduleBaselineCapture();
|
|
@@ -1852,10 +1905,10 @@ function Gn(e, t, n, r, i, a) {
|
|
|
1852
1905
|
e.removeEventListener("formie:submit:result", r), t.removeEventListener("formie:state:reset", i), n.destroy();
|
|
1853
1906
|
});
|
|
1854
1907
|
}
|
|
1855
|
-
if (
|
|
1908
|
+
if (u.forEach((e) => {
|
|
1856
1909
|
let n = (e) => {
|
|
1857
1910
|
let n = e.currentTarget.getAttribute("data-formie-action"), r = t.querySelector("input[name=\"submitAction\"]");
|
|
1858
|
-
|
|
1911
|
+
g(n), n && r && (r.value = n);
|
|
1859
1912
|
};
|
|
1860
1913
|
e.addEventListener("click", n), a.push(() => {
|
|
1861
1914
|
e.removeEventListener("click", n);
|
|
@@ -1863,24 +1916,24 @@ function Gn(e, t, n, r, i, a) {
|
|
|
1863
1916
|
}), t.querySelectorAll("[data-formie-tab-link]").forEach((n) => {
|
|
1864
1917
|
let r = async (n) => {
|
|
1865
1918
|
if (o !== "ajax") {
|
|
1866
|
-
|
|
1919
|
+
Kn(n) && Vn(t, "set-page");
|
|
1867
1920
|
return;
|
|
1868
1921
|
}
|
|
1869
1922
|
n.preventDefault();
|
|
1870
1923
|
let r = n.currentTarget, i = r?.getAttribute("data-formie-page-id"), a = r?.getAttribute("href");
|
|
1871
1924
|
if (!(!i || !a)) {
|
|
1872
|
-
|
|
1925
|
+
p(t, i), h(e, "formie:page:navigate", {
|
|
1873
1926
|
pageId: i,
|
|
1874
1927
|
href: a
|
|
1875
1928
|
});
|
|
1876
1929
|
try {
|
|
1877
|
-
|
|
1930
|
+
h(e, "formie:page:navigate:after", {
|
|
1878
1931
|
pageId: i,
|
|
1879
1932
|
href: a,
|
|
1880
|
-
response: await
|
|
1933
|
+
response: await Ve(a, t, i)
|
|
1881
1934
|
});
|
|
1882
1935
|
} catch (t) {
|
|
1883
|
-
console.error("[formie] Failed to persist page navigation state.", t),
|
|
1936
|
+
console.error("[formie] Failed to persist page navigation state.", t), h(e, "formie:page:navigate:error", {
|
|
1884
1937
|
pageId: i,
|
|
1885
1938
|
href: a,
|
|
1886
1939
|
error: t
|
|
@@ -1891,50 +1944,50 @@ function Gn(e, t, n, r, i, a) {
|
|
|
1891
1944
|
n.addEventListener("click", r), a.push(() => {
|
|
1892
1945
|
n.removeEventListener("click", r);
|
|
1893
1946
|
});
|
|
1894
|
-
}), !
|
|
1947
|
+
}), !Rn(t)) {
|
|
1895
1948
|
let e = !1, n = () => {
|
|
1896
|
-
e ||
|
|
1949
|
+
e || Un(t) || Gn(t) || (e = !0, He(s, t));
|
|
1897
1950
|
};
|
|
1898
1951
|
window.addEventListener("pagehide", n), window.addEventListener("beforeunload", n), a.push(() => {
|
|
1899
1952
|
window.removeEventListener("pagehide", n), window.removeEventListener("beforeunload", n);
|
|
1900
1953
|
});
|
|
1901
1954
|
}
|
|
1902
|
-
let
|
|
1955
|
+
let _ = async (a) => {
|
|
1903
1956
|
if (c) return;
|
|
1904
1957
|
let s = o === "ajax";
|
|
1905
1958
|
if (a.preventDefault(), t.getAttribute("data-formie-loading") === "true") {
|
|
1906
1959
|
if (t.getAttribute("data-formie-internal-resubmit") !== "true") return;
|
|
1907
1960
|
t.removeAttribute("data-formie-internal-resubmit");
|
|
1908
1961
|
} else t.removeAttribute("data-formie-internal-resubmit");
|
|
1909
|
-
let
|
|
1962
|
+
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;
|
|
1910
1963
|
try {
|
|
1911
|
-
if (s)
|
|
1964
|
+
if (s) b = await Wt({
|
|
1912
1965
|
target: e,
|
|
1913
1966
|
form: t,
|
|
1914
1967
|
bus: r,
|
|
1915
1968
|
validator: i,
|
|
1916
|
-
validateOnSubmit:
|
|
1917
|
-
action:
|
|
1918
|
-
submitter:
|
|
1919
|
-
waitForSubmitDelay:
|
|
1969
|
+
validateOnSubmit: Z(t),
|
|
1970
|
+
action: y,
|
|
1971
|
+
submitter: u,
|
|
1972
|
+
waitForSubmitDelay: Yn,
|
|
1920
1973
|
onRefreshTokensAfterSubmit: async () => {
|
|
1921
|
-
await
|
|
1974
|
+
await nr(e, n, t);
|
|
1922
1975
|
},
|
|
1923
1976
|
dispatchSubmitResult: (t) => {
|
|
1924
|
-
|
|
1977
|
+
h(e, "formie:submit:result", t);
|
|
1925
1978
|
}
|
|
1926
1979
|
});
|
|
1927
1980
|
else {
|
|
1928
|
-
if (
|
|
1981
|
+
if (Ut(t), m(t, u), await Yn(t), b = await tt(t, y, r, {
|
|
1929
1982
|
validator: i,
|
|
1930
|
-
validateOnSubmit:
|
|
1983
|
+
validateOnSubmit: Z(t),
|
|
1931
1984
|
preflightOnly: !0
|
|
1932
|
-
}),
|
|
1933
|
-
|
|
1985
|
+
}), b.ok) {
|
|
1986
|
+
l(t, y), c = !0, Vn(t, "submit"), g(null);
|
|
1934
1987
|
let e = !1, n = () => {
|
|
1935
|
-
if (e = !0, c = !1,
|
|
1936
|
-
let { scope: e, final: n } =
|
|
1937
|
-
r.length > 0 &&
|
|
1988
|
+
if (e = !0, c = !1, Hn(t), d(t), i && Z(t)) {
|
|
1989
|
+
let { scope: e, final: n } = f(t), r = i.submit(n ? t : e, { final: n });
|
|
1990
|
+
r.length > 0 && L(t, {
|
|
1938
1991
|
ok: !1,
|
|
1939
1992
|
stage: "validate",
|
|
1940
1993
|
code: "VALIDATION_FAILED",
|
|
@@ -1953,36 +2006,36 @@ function Gn(e, t, n, r, i, a) {
|
|
|
1953
2006
|
}
|
|
1954
2007
|
} else t.submit();
|
|
1955
2008
|
if (e) return;
|
|
1956
|
-
|
|
2009
|
+
x = !0;
|
|
1957
2010
|
return;
|
|
1958
2011
|
}
|
|
1959
|
-
|
|
2012
|
+
L(t, b), h(e, "formie:submit:result", b), Hn(t);
|
|
1960
2013
|
}
|
|
1961
2014
|
} catch (n) {
|
|
1962
|
-
c = !1,
|
|
2015
|
+
c = !1, b = {
|
|
1963
2016
|
ok: !1,
|
|
1964
2017
|
code: "SUBMIT_ERROR",
|
|
1965
2018
|
message: n instanceof Error ? n.message : "Submission failed.",
|
|
1966
2019
|
formErrors: [n instanceof Error ? n.message : "Submission failed."]
|
|
1967
|
-
},
|
|
2020
|
+
}, L(t, b), h(e, "formie:submit:result", b), Hn(t);
|
|
1968
2021
|
} finally {
|
|
1969
|
-
|
|
2022
|
+
g(null), !s && !x && !Ht(b) && d(t);
|
|
1970
2023
|
}
|
|
1971
2024
|
};
|
|
1972
|
-
t.addEventListener("submit",
|
|
1973
|
-
t.removeEventListener("submit",
|
|
2025
|
+
t.addEventListener("submit", _), a.push(() => {
|
|
2026
|
+
t.removeEventListener("submit", _);
|
|
1974
2027
|
});
|
|
1975
2028
|
}
|
|
1976
|
-
async function
|
|
2029
|
+
async function ir(e, t, n) {
|
|
1977
2030
|
if (t.refreshTokens === !1 || !t.staticCache) return;
|
|
1978
|
-
|
|
1979
|
-
let r = t.formHandle || e.dataset.formieHandle, i =
|
|
2031
|
+
In(J(t.transport), q(t.mode));
|
|
2032
|
+
let r = t.formHandle || e.dataset.formieHandle, i = Nn(t, e), a = n?.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
1980
2033
|
if (!r) return;
|
|
1981
|
-
let o = await
|
|
1982
|
-
!o || !n || (
|
|
2034
|
+
let o = await M(i, r, a);
|
|
2035
|
+
!o || !n || (er(n, o), h(e, "formie:refresh-tokens:after", o));
|
|
1983
2036
|
}
|
|
1984
|
-
function
|
|
1985
|
-
let e = /* @__PURE__ */ new Map(), t = new
|
|
2037
|
+
function ar() {
|
|
2038
|
+
let e = /* @__PURE__ */ new Map(), t = new R(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = [
|
|
1986
2039
|
"prepare",
|
|
1987
2040
|
"normalize",
|
|
1988
2041
|
"validate",
|
|
@@ -1997,19 +2050,19 @@ function qn() {
|
|
|
1997
2050
|
return;
|
|
1998
2051
|
}
|
|
1999
2052
|
let a = (async () => {
|
|
2000
|
-
|
|
2053
|
+
W.log("Unmount requested.", { target: Q(t) });
|
|
2001
2054
|
let r = n.get(t);
|
|
2002
2055
|
r && (r(), n.delete(t));
|
|
2003
2056
|
let i = e.get(t);
|
|
2004
2057
|
if (!i) {
|
|
2005
|
-
|
|
2058
|
+
W.log("Unmount skipped (no mounted state).", { target: Q(t) });
|
|
2006
2059
|
return;
|
|
2007
2060
|
}
|
|
2008
|
-
|
|
2061
|
+
h(t, "formie:unmount:before", { id: i.instance.id }), i.unbinds.forEach((e) => {
|
|
2009
2062
|
e();
|
|
2010
2063
|
}), i.unbinds = [], i.validator?.destroy(), i.validator = null;
|
|
2011
2064
|
for (let e of i.modules) await e.destroy();
|
|
2012
|
-
i.modules = [], i.bus.clear(), e.delete(t),
|
|
2065
|
+
i.modules = [], i.bus.clear(), e.delete(t), h(t, "formie:unmount:after", { id: i.instance.id }), W.log("Unmount complete.", {
|
|
2013
2066
|
id: i.instance.id,
|
|
2014
2067
|
target: Q(t)
|
|
2015
2068
|
});
|
|
@@ -2018,7 +2071,7 @@ function qn() {
|
|
|
2018
2071
|
});
|
|
2019
2072
|
r.set(t, a), await a;
|
|
2020
2073
|
}, o = async (r, o) => {
|
|
2021
|
-
|
|
2074
|
+
W.log("Mount requested.", {
|
|
2022
2075
|
target: Q(r),
|
|
2023
2076
|
mode: o.mode,
|
|
2024
2077
|
autoVisible: o.autoVisible
|
|
@@ -2026,115 +2079,116 @@ function qn() {
|
|
|
2026
2079
|
let s = n.get(r);
|
|
2027
2080
|
s && (s(), n.delete(r));
|
|
2028
2081
|
let c = e.get(r);
|
|
2029
|
-
if (c) return
|
|
2082
|
+
if (c) return W.log("Mount skipped (already mounted).", {
|
|
2030
2083
|
id: c.instance.id,
|
|
2031
2084
|
target: Q(r)
|
|
2032
2085
|
}), c.instance;
|
|
2033
|
-
let l = new
|
|
2034
|
-
...
|
|
2086
|
+
let l = new Fe(), d = [], f = r?.id || `formie-${e.size + 1}`, p = K(r), m = {
|
|
2087
|
+
...p,
|
|
2035
2088
|
...o,
|
|
2036
|
-
mode:
|
|
2037
|
-
transport:
|
|
2038
|
-
},
|
|
2039
|
-
if (
|
|
2040
|
-
let
|
|
2041
|
-
|
|
2042
|
-
let
|
|
2043
|
-
...
|
|
2044
|
-
...
|
|
2045
|
-
} : null,
|
|
2046
|
-
|
|
2089
|
+
mode: q(o.mode ?? p.mode),
|
|
2090
|
+
transport: J(o.transport ?? p.transport)
|
|
2091
|
+
}, g = _e(m.compatibility);
|
|
2092
|
+
if (m.mode !== "server-rendered" && !Y(r)) throw Error(`Formie ${m.mode} mode is not implemented yet in the browser client.`);
|
|
2093
|
+
let v = await tr(r, m), b = Y(r);
|
|
2094
|
+
m.staticCache = o.staticCache ?? On(b ? b.dataset : r.dataset);
|
|
2095
|
+
let x = Zn(r, b), S = v || x ? {
|
|
2096
|
+
...v || {},
|
|
2097
|
+
...x || {}
|
|
2098
|
+
} : null, ee = S?.theme, C = {}, w = (S?.modules || []).filter((e) => !!e?.id && !!e?.type);
|
|
2099
|
+
W.log("Resolved mount payload.", {
|
|
2047
2100
|
target: Q(r),
|
|
2048
|
-
hasRenderPayload: !!
|
|
2049
|
-
hasEmbeddedPayload: !!
|
|
2050
|
-
moduleCount:
|
|
2101
|
+
hasRenderPayload: !!v,
|
|
2102
|
+
hasEmbeddedPayload: !!x,
|
|
2103
|
+
moduleCount: w.length
|
|
2051
2104
|
});
|
|
2052
|
-
let
|
|
2053
|
-
live:
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2105
|
+
let T = te(r, ee, b), E = b ? new pt(b, {
|
|
2106
|
+
live: Ln(b.dataset.formieValidationOnFocus),
|
|
2107
|
+
errorAriaLive: we(b),
|
|
2108
|
+
errorMessage: b.dataset.formieErrorMessage || "",
|
|
2109
|
+
fieldContainerErrorClass: T.fieldLayoutError || [],
|
|
2110
|
+
inputErrorClass: T.fieldControlError || [],
|
|
2111
|
+
messagesClass: T.fieldErrors || [],
|
|
2112
|
+
messageClass: T.fieldError || []
|
|
2059
2113
|
}) : null;
|
|
2060
|
-
if (
|
|
2061
|
-
let e =
|
|
2062
|
-
e.formieValidation =
|
|
2114
|
+
if (b && E) {
|
|
2115
|
+
let e = b;
|
|
2116
|
+
e.formieValidation = E, C.validation = E;
|
|
2063
2117
|
let t = {
|
|
2064
|
-
validator:
|
|
2065
|
-
addValidator:
|
|
2066
|
-
removeValidator:
|
|
2118
|
+
validator: E,
|
|
2119
|
+
addValidator: E.addValidator.bind(E),
|
|
2120
|
+
removeValidator: E.removeValidator.bind(E)
|
|
2067
2121
|
};
|
|
2068
|
-
|
|
2122
|
+
h(b, "formie:validator:ready", t), h(r, "formie:validator:ready", t);
|
|
2069
2123
|
}
|
|
2070
|
-
|
|
2071
|
-
let
|
|
2124
|
+
b && (sn(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) && Fn(r, b, m), m.mode === "server-rendered" && Ne(b) && (Me(b), Pe(b)), y(b)), Object.keys(T).length && h(r, "formie:theme:applied", { hasClasses: !0 });
|
|
2125
|
+
let D = await an(w, {
|
|
2072
2126
|
registry: t,
|
|
2073
2127
|
matchContext: {
|
|
2074
2128
|
root: r,
|
|
2075
|
-
form:
|
|
2076
|
-
mode:
|
|
2129
|
+
form: b,
|
|
2130
|
+
mode: m.mode
|
|
2077
2131
|
},
|
|
2078
2132
|
setupContext: {
|
|
2079
|
-
formId:
|
|
2133
|
+
formId: f,
|
|
2080
2134
|
root: r,
|
|
2081
|
-
form:
|
|
2135
|
+
form: b,
|
|
2082
2136
|
target: r,
|
|
2083
2137
|
scope: "form",
|
|
2084
|
-
state:
|
|
2138
|
+
state: C,
|
|
2085
2139
|
on: (e, t) => l.on(e, t),
|
|
2086
|
-
emit: (e, t) => (
|
|
2087
|
-
t.failed.length > 0 &&
|
|
2140
|
+
emit: (e, t) => (h(r, e, t), l.emitSafe(e, t).then((t) => {
|
|
2141
|
+
t.failed.length > 0 && W.warn("Lifecycle listeners failed.", {
|
|
2088
2142
|
eventName: e,
|
|
2089
2143
|
failed: t.failed.length
|
|
2090
2144
|
});
|
|
2091
2145
|
}))
|
|
2092
2146
|
}
|
|
2093
2147
|
});
|
|
2094
|
-
|
|
2148
|
+
W.log("Module setup complete.", {
|
|
2095
2149
|
target: Q(r),
|
|
2096
|
-
moduleInstances:
|
|
2150
|
+
moduleInstances: D.length
|
|
2097
2151
|
});
|
|
2098
|
-
let
|
|
2099
|
-
id:
|
|
2152
|
+
let O = {
|
|
2153
|
+
id: f,
|
|
2100
2154
|
root: r,
|
|
2101
2155
|
submit: async (e = "submit") => {
|
|
2102
|
-
if (
|
|
2103
|
-
id:
|
|
2156
|
+
if (W.log("Submit requested.", {
|
|
2157
|
+
id: f,
|
|
2104
2158
|
target: Q(r),
|
|
2105
2159
|
action: e
|
|
2106
|
-
}), !
|
|
2160
|
+
}), !b) return {
|
|
2107
2161
|
ok: !1,
|
|
2108
2162
|
code: "FORM_NOT_FOUND",
|
|
2109
2163
|
message: "No form element found for mount target.",
|
|
2110
2164
|
formErrors: ["No form element found for mount target."]
|
|
2111
2165
|
};
|
|
2112
|
-
let t =
|
|
2113
|
-
if (t && (t.value = e),
|
|
2166
|
+
let t = b.querySelector("input[name=\"submitAction\"]");
|
|
2167
|
+
if (t && (t.value = e), b.getAttribute("data-formie-loading") === "true") return {
|
|
2114
2168
|
ok: !1,
|
|
2115
2169
|
code: "SUBMIT_IN_PROGRESS",
|
|
2116
2170
|
message: "Submission already in progress.",
|
|
2117
2171
|
formErrors: []
|
|
2118
2172
|
};
|
|
2119
|
-
let n =
|
|
2120
|
-
id:
|
|
2173
|
+
let n = b.querySelector(`[data-formie-action="${e}"]`), i = await Wt({
|
|
2174
|
+
id: f,
|
|
2121
2175
|
target: r,
|
|
2122
|
-
form:
|
|
2176
|
+
form: b,
|
|
2123
2177
|
bus: l,
|
|
2124
|
-
validator:
|
|
2125
|
-
validateOnSubmit:
|
|
2178
|
+
validator: E,
|
|
2179
|
+
validateOnSubmit: Z(b),
|
|
2126
2180
|
action: e,
|
|
2127
2181
|
submitter: n,
|
|
2128
|
-
waitForSubmitDelay:
|
|
2182
|
+
waitForSubmitDelay: Yn,
|
|
2129
2183
|
onRefreshTokensAfterSubmit: async () => {
|
|
2130
|
-
await
|
|
2184
|
+
await nr(r, m, b);
|
|
2131
2185
|
},
|
|
2132
2186
|
dispatchSubmitResult: (e) => {
|
|
2133
|
-
|
|
2187
|
+
h(r, "formie:submit:result", e);
|
|
2134
2188
|
}
|
|
2135
2189
|
});
|
|
2136
|
-
return
|
|
2137
|
-
id:
|
|
2190
|
+
return W.log("Submit completed.", {
|
|
2191
|
+
id: f,
|
|
2138
2192
|
action: e,
|
|
2139
2193
|
ok: i.ok,
|
|
2140
2194
|
code: i.code,
|
|
@@ -2146,73 +2200,73 @@ function qn() {
|
|
|
2146
2200
|
},
|
|
2147
2201
|
on: (e, t) => l.on(e, t)
|
|
2148
2202
|
};
|
|
2149
|
-
|
|
2203
|
+
b && (Ce({
|
|
2150
2204
|
target: r,
|
|
2151
|
-
form:
|
|
2152
|
-
validatorDetail:
|
|
2153
|
-
validator:
|
|
2154
|
-
addValidator:
|
|
2155
|
-
removeValidator:
|
|
2205
|
+
form: b,
|
|
2206
|
+
validatorDetail: E ? {
|
|
2207
|
+
validator: E,
|
|
2208
|
+
addValidator: E.addValidator.bind(E),
|
|
2209
|
+
removeValidator: E.removeValidator.bind(E)
|
|
2156
2210
|
} : null,
|
|
2157
|
-
options:
|
|
2158
|
-
unbinds:
|
|
2211
|
+
options: g,
|
|
2212
|
+
unbinds: d
|
|
2159
2213
|
}), Se({
|
|
2160
2214
|
target: r,
|
|
2161
|
-
form:
|
|
2162
|
-
instance:
|
|
2163
|
-
options:
|
|
2164
|
-
unbinds:
|
|
2165
|
-
})),
|
|
2215
|
+
form: b,
|
|
2216
|
+
instance: O,
|
|
2217
|
+
options: g,
|
|
2218
|
+
unbinds: d
|
|
2219
|
+
})), b && (rr(r, b, m, l, E, d), E && (d.push(_(b, E, r)), d.push(vn(b))), await ir(r, m, b)), i.forEach((e) => {
|
|
2166
2220
|
let t = l.on(`formie:stage:${e}:before`, async (t) => {
|
|
2167
|
-
|
|
2221
|
+
h(r, `formie:stage:${e}:before`, t);
|
|
2168
2222
|
}), n = l.on(`formie:stage:${e}:before`, async (e) => {
|
|
2169
|
-
for (let t of
|
|
2223
|
+
for (let t of D) t.onBeforeStage && await t.onBeforeStage(e);
|
|
2170
2224
|
}), i = l.on(`formie:stage:${e}:after`, async (t) => {
|
|
2171
|
-
|
|
2225
|
+
h(r, `formie:stage:${e}:after`, t);
|
|
2172
2226
|
}), a = l.on(`formie:stage:${e}:after`, async (e) => {
|
|
2173
2227
|
let t = e;
|
|
2174
|
-
for (let e of
|
|
2228
|
+
for (let e of D) e.onAfterStage && await e.onAfterStage(t, t.result);
|
|
2175
2229
|
});
|
|
2176
|
-
|
|
2230
|
+
d.push(t, n, i, a);
|
|
2177
2231
|
});
|
|
2178
2232
|
let ne = l.on("formie:submit:before", async (e) => {
|
|
2179
|
-
|
|
2233
|
+
h(r, "formie:submit:before", e);
|
|
2180
2234
|
}), re = l.on("formie:submit:after", async (e) => {
|
|
2181
|
-
|
|
2235
|
+
h(r, "formie:submit:after", e);
|
|
2182
2236
|
}), ie = l.on("formie:submit:final:before", async (e) => {
|
|
2183
|
-
|
|
2237
|
+
h(r, "formie:submit:final:before", e);
|
|
2184
2238
|
}), ae = l.on("formie:submit:final:after", async (e) => {
|
|
2185
|
-
|
|
2239
|
+
h(r, "formie:submit:final:after", e);
|
|
2186
2240
|
});
|
|
2187
|
-
return
|
|
2188
|
-
options:
|
|
2241
|
+
return d.push(ne, re, ie, ae), e.set(r, {
|
|
2242
|
+
options: m,
|
|
2189
2243
|
bus: l,
|
|
2190
|
-
form:
|
|
2191
|
-
validator:
|
|
2192
|
-
modules:
|
|
2193
|
-
unbinds:
|
|
2194
|
-
instance:
|
|
2195
|
-
}),
|
|
2196
|
-
id:
|
|
2197
|
-
mode:
|
|
2198
|
-
}),
|
|
2199
|
-
id:
|
|
2244
|
+
form: b,
|
|
2245
|
+
validator: E,
|
|
2246
|
+
modules: D,
|
|
2247
|
+
unbinds: d,
|
|
2248
|
+
instance: O
|
|
2249
|
+
}), h(r, "formie:mount:after", {
|
|
2250
|
+
id: f,
|
|
2251
|
+
mode: m.mode
|
|
2252
|
+
}), b instanceof HTMLFormElement && u(b), W.log("Mount complete.", {
|
|
2253
|
+
id: f,
|
|
2200
2254
|
target: Q(r),
|
|
2201
|
-
mode:
|
|
2202
|
-
}),
|
|
2255
|
+
mode: m.mode
|
|
2256
|
+
}), O;
|
|
2203
2257
|
}, s = (t, r) => {
|
|
2204
|
-
if (!r.autoVisible ||
|
|
2258
|
+
if (!r.autoVisible || Qn(t) || typeof IntersectionObserver > "u") return o(t, r);
|
|
2205
2259
|
if (e.has(t)) return Promise.resolve(e.get(t)?.instance || null);
|
|
2206
|
-
if (n.has(t)) return
|
|
2260
|
+
if (n.has(t)) return W.log("Mount deferred (already waiting visibility).", { target: Q(t) }), Promise.resolve(null);
|
|
2207
2261
|
let i = new IntersectionObserver((e) => {
|
|
2208
|
-
e.some((e) => e.target === t && e.isIntersecting) && (i.disconnect(), n.delete(t),
|
|
2262
|
+
e.some((e) => e.target === t && e.isIntersecting) && (i.disconnect(), n.delete(t), W.log("Visibility reached, proceeding mount.", { target: Q(t) }), o(t, {
|
|
2209
2263
|
...r,
|
|
2210
2264
|
autoVisible: !1
|
|
2211
2265
|
}));
|
|
2212
2266
|
}, { threshold: .01 });
|
|
2213
2267
|
return i.observe(t), n.set(t, () => {
|
|
2214
2268
|
i.disconnect();
|
|
2215
|
-
}),
|
|
2269
|
+
}), W.log("Mount deferred until visible.", { target: Q(t) }), Promise.resolve(null);
|
|
2216
2270
|
};
|
|
2217
2271
|
return {
|
|
2218
2272
|
mount: o,
|
|
@@ -2220,7 +2274,7 @@ function qn() {
|
|
|
2220
2274
|
update: async (t, n) => {
|
|
2221
2275
|
let r = e.get(t);
|
|
2222
2276
|
if (!r) return o(t, {
|
|
2223
|
-
...
|
|
2277
|
+
...K(t),
|
|
2224
2278
|
...n,
|
|
2225
2279
|
mode: n.mode || "server-rendered"
|
|
2226
2280
|
});
|
|
@@ -2228,32 +2282,32 @@ function qn() {
|
|
|
2228
2282
|
...r.options,
|
|
2229
2283
|
...n
|
|
2230
2284
|
};
|
|
2231
|
-
let i = te(t, n.payload?.theme || r.options.payload?.theme ||
|
|
2232
|
-
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 &&
|
|
2285
|
+
let i = te(t, n.payload?.theme || r.options.payload?.theme || Zn(t, r.form)?.theme, r.form);
|
|
2286
|
+
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", {
|
|
2233
2287
|
hasClasses: !0,
|
|
2234
2288
|
reason: "update"
|
|
2235
2289
|
}), r.instance;
|
|
2236
2290
|
},
|
|
2237
2291
|
getInstance: (t) => e.get(t)?.instance || null,
|
|
2238
2292
|
refreshForCache: async (t) => {
|
|
2239
|
-
|
|
2293
|
+
kn("refreshForCache", "Global `Formie.refreshForCache()` has been deprecated. Use built-in static-cache token refresh handling instead.");
|
|
2240
2294
|
let n = null;
|
|
2241
2295
|
if (n = typeof t == "string" ? document.getElementById(t) || document.querySelector(`[data-formie-form-id="${t}"]`) : t, !n) {
|
|
2242
|
-
|
|
2296
|
+
W.warn("refreshForCache target not found.", { targetOrId: t });
|
|
2243
2297
|
return;
|
|
2244
2298
|
}
|
|
2245
|
-
let r = e.get(n), i =
|
|
2299
|
+
let r = e.get(n), i = Y(n), a = r?.options || K(n);
|
|
2246
2300
|
if (!i) {
|
|
2247
|
-
|
|
2301
|
+
W.warn("refreshForCache found no form element for target.", { target: Q(n) });
|
|
2248
2302
|
return;
|
|
2249
2303
|
}
|
|
2250
|
-
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s =
|
|
2304
|
+
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s = Nn(a, n), c = i.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2251
2305
|
if (!o) {
|
|
2252
|
-
|
|
2306
|
+
W.warn("refreshForCache found no form handle for target.", { target: Q(n) });
|
|
2253
2307
|
return;
|
|
2254
2308
|
}
|
|
2255
|
-
let l = await
|
|
2256
|
-
l && (
|
|
2309
|
+
let l = await M(s, o, c);
|
|
2310
|
+
l && (er(i, l), h(n, "formie:refresh-tokens:after", l));
|
|
2257
2311
|
},
|
|
2258
2312
|
registerModule: (e, n) => t.register(e, n),
|
|
2259
2313
|
unregisterModule: (e) => {
|
|
@@ -2261,13 +2315,13 @@ function qn() {
|
|
|
2261
2315
|
},
|
|
2262
2316
|
getRegisteredModules: () => t.getAll(),
|
|
2263
2317
|
scan: async (e) => {
|
|
2264
|
-
let t = e || document, n = Array.from(t.querySelectorAll(
|
|
2265
|
-
|
|
2318
|
+
let t = e || document, n = Array.from(t.querySelectorAll(U));
|
|
2319
|
+
W.log("Scan started.", {
|
|
2266
2320
|
scope: t === document ? "document" : t,
|
|
2267
2321
|
targetCount: n.length
|
|
2268
2322
|
});
|
|
2269
|
-
let r = (await Promise.all(n.map((e) => s(e,
|
|
2270
|
-
return
|
|
2323
|
+
let r = (await Promise.all(n.map((e) => s(e, K(e))))).filter((e) => !!e);
|
|
2324
|
+
return W.log("Scan finished.", {
|
|
2271
2325
|
mountedCount: r.length,
|
|
2272
2326
|
deferredCount: n.length - r.length
|
|
2273
2327
|
}), r;
|
|
@@ -2275,16 +2329,16 @@ function qn() {
|
|
|
2275
2329
|
observe: (t) => {
|
|
2276
2330
|
if (typeof MutationObserver > "u") return () => {};
|
|
2277
2331
|
let r = t || document;
|
|
2278
|
-
|
|
2332
|
+
W.log("Observer started.", { scope: r === document ? "document" : r });
|
|
2279
2333
|
let i = new MutationObserver((t) => {
|
|
2280
2334
|
t.forEach((t) => {
|
|
2281
2335
|
t.addedNodes.forEach((e) => {
|
|
2282
|
-
e instanceof Element && (e.matches(
|
|
2283
|
-
|
|
2336
|
+
e instanceof Element && (e.matches(U) && (W.log("Observer detected new root.", { target: Q(e) }), s(e, K(e))), e.querySelectorAll(U).forEach((e) => {
|
|
2337
|
+
W.log("Observer detected new nested root.", { target: Q(e) }), s(e, K(e));
|
|
2284
2338
|
}));
|
|
2285
2339
|
}), t.removedNodes.forEach((t) => {
|
|
2286
|
-
t instanceof Element && (e.has(t) && (
|
|
2287
|
-
e.has(t) && (
|
|
2340
|
+
t instanceof Element && (e.has(t) && (W.log("Observer detected removed root.", { target: Q(t) }), a(t)), t.querySelectorAll(U).forEach((t) => {
|
|
2341
|
+
e.has(t) && (W.log("Observer detected removed nested root.", { target: Q(t) }), a(t));
|
|
2288
2342
|
}));
|
|
2289
2343
|
});
|
|
2290
2344
|
});
|
|
@@ -2293,11 +2347,11 @@ function qn() {
|
|
|
2293
2347
|
childList: !0,
|
|
2294
2348
|
subtree: !0
|
|
2295
2349
|
}), () => {
|
|
2296
|
-
i.disconnect(),
|
|
2297
|
-
|
|
2350
|
+
i.disconnect(), W.log("Observer stopped."), n.forEach((e, t) => {
|
|
2351
|
+
$n(t, r) && (e(), n.delete(t));
|
|
2298
2352
|
});
|
|
2299
2353
|
let t = [];
|
|
2300
|
-
r instanceof Element && r.matches(
|
|
2354
|
+
r instanceof Element && r.matches(U) && t.push(r), r.querySelectorAll(U).forEach((e) => {
|
|
2301
2355
|
t.push(e);
|
|
2302
2356
|
}), t.forEach((t) => {
|
|
2303
2357
|
e.has(t) && a(t);
|
|
@@ -2308,9 +2362,9 @@ function qn() {
|
|
|
2308
2362
|
}
|
|
2309
2363
|
//#endregion
|
|
2310
2364
|
//#region src/js/core/hydrate-modules.ts
|
|
2311
|
-
var
|
|
2312
|
-
async function
|
|
2313
|
-
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
|
|
2365
|
+
var or = C("general", "module-hydrator");
|
|
2366
|
+
async function sr(e) {
|
|
2367
|
+
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 R(), o = new Fe(), s = await an(r, {
|
|
2314
2368
|
registry: a,
|
|
2315
2369
|
setupContext: {
|
|
2316
2370
|
formId: n?.id || t.id || "formie-modules",
|
|
@@ -2331,13 +2385,13 @@ async function Yn(e) {
|
|
|
2331
2385
|
mode: i
|
|
2332
2386
|
}
|
|
2333
2387
|
});
|
|
2334
|
-
return
|
|
2388
|
+
return or.log("Hydrated module manifest.", {
|
|
2335
2389
|
moduleCount: r.length,
|
|
2336
2390
|
instanceCount: s.length,
|
|
2337
2391
|
mode: i
|
|
2338
2392
|
}), {
|
|
2339
2393
|
destroy: async () => {
|
|
2340
|
-
await
|
|
2394
|
+
await cr(s), o.clear();
|
|
2341
2395
|
},
|
|
2342
2396
|
on: (e, t) => o.on(e, t),
|
|
2343
2397
|
emit: async (e, t) => {
|
|
@@ -2350,11 +2404,11 @@ async function Yn(e) {
|
|
|
2350
2404
|
getRegisteredModules: () => a.getAll()
|
|
2351
2405
|
};
|
|
2352
2406
|
}
|
|
2353
|
-
async function
|
|
2407
|
+
async function cr(e) {
|
|
2354
2408
|
for (let t of e) try {
|
|
2355
2409
|
await t.destroy();
|
|
2356
2410
|
} catch (e) {
|
|
2357
|
-
console.error("[formie] Failed to destroy module instance.", e),
|
|
2411
|
+
console.error("[formie] Failed to destroy module instance.", e), or.warn("Failed destroying module instance.", { error: e });
|
|
2358
2412
|
}
|
|
2359
2413
|
}
|
|
2360
2414
|
//#endregion
|
|
@@ -2362,41 +2416,41 @@ async function Xn(e) {
|
|
|
2362
2416
|
function $(e) {
|
|
2363
2417
|
return e instanceof Element;
|
|
2364
2418
|
}
|
|
2365
|
-
function
|
|
2419
|
+
function lr(e) {
|
|
2366
2420
|
return e.ok;
|
|
2367
2421
|
}
|
|
2368
|
-
function
|
|
2422
|
+
function ur(e) {
|
|
2369
2423
|
return typeof e == "string" ? `selector "${e}"` : $(e) ? `element "${e.tagName.toLowerCase()}"` : "provided element collection";
|
|
2370
2424
|
}
|
|
2371
|
-
function
|
|
2425
|
+
function dr(e) {
|
|
2372
2426
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2373
2427
|
for (let r of e) !$(r) || t.has(r) || (t.add(r), n.push(r));
|
|
2374
2428
|
return n;
|
|
2375
2429
|
}
|
|
2376
|
-
function
|
|
2377
|
-
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : $(e) ? [e] :
|
|
2430
|
+
function fr(e) {
|
|
2431
|
+
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : $(e) ? [e] : dr(e);
|
|
2378
2432
|
}
|
|
2379
|
-
function
|
|
2433
|
+
function pr() {
|
|
2380
2434
|
return document.readyState === "loading" ? new Promise((e) => {
|
|
2381
2435
|
document.addEventListener("DOMContentLoaded", () => e(), { once: !0 });
|
|
2382
2436
|
}) : Promise.resolve();
|
|
2383
2437
|
}
|
|
2384
|
-
async function
|
|
2385
|
-
let t =
|
|
2386
|
-
return t.length > 0 || typeof e != "string" ? t : (await
|
|
2438
|
+
async function mr(e) {
|
|
2439
|
+
let t = fr(e);
|
|
2440
|
+
return t.length > 0 || typeof e != "string" ? t : (await pr(), fr(e));
|
|
2387
2441
|
}
|
|
2388
|
-
function
|
|
2442
|
+
function hr(e) {
|
|
2389
2443
|
return typeof e == "string" ? document : $(e) ? e.getRootNode() : document;
|
|
2390
2444
|
}
|
|
2391
|
-
function
|
|
2445
|
+
function gr(e) {
|
|
2392
2446
|
let { element: t, observe: n, allowEmpty: r, client: i, onReady: a, onResult: o, onSuccess: s, onError: c, onEvent: l, ...u } = e;
|
|
2393
2447
|
return {
|
|
2394
2448
|
mode: "server-rendered",
|
|
2395
2449
|
...u
|
|
2396
2450
|
};
|
|
2397
2451
|
}
|
|
2398
|
-
async function
|
|
2399
|
-
let i = [], o =
|
|
2452
|
+
async function _r(e, t, n, r) {
|
|
2453
|
+
let i = [], o = gr(e);
|
|
2400
2454
|
for (let s of r) {
|
|
2401
2455
|
let r = n.get(s);
|
|
2402
2456
|
if (r) {
|
|
@@ -2406,7 +2460,7 @@ async function ar(e, t, n, r) {
|
|
|
2406
2460
|
let c = await t.mount(s, o), l = [];
|
|
2407
2461
|
if (e.onReady?.(c), l.push(c.on("formie:submit:result", (t) => {
|
|
2408
2462
|
let n = t;
|
|
2409
|
-
e.onResult?.(n, c),
|
|
2463
|
+
e.onResult?.(n, c), lr(n) ? e.onSuccess?.(n, c) : e.onError?.(n, c);
|
|
2410
2464
|
})), e.onEvent) for (let t of a) l.push(c.on(t, (n) => {
|
|
2411
2465
|
e.onEvent?.({
|
|
2412
2466
|
name: t,
|
|
@@ -2420,11 +2474,11 @@ async function ar(e, t, n, r) {
|
|
|
2420
2474
|
}
|
|
2421
2475
|
return i;
|
|
2422
2476
|
}
|
|
2423
|
-
async function
|
|
2424
|
-
let t = e.client ??
|
|
2425
|
-
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${
|
|
2426
|
-
await
|
|
2427
|
-
let i = e.observe ? t.observe(
|
|
2477
|
+
async function vr(e) {
|
|
2478
|
+
let t = e.client ?? ar(), n = /* @__PURE__ */ new Map(), r = await mr(e.element);
|
|
2479
|
+
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${ur(e.element)}.`);
|
|
2480
|
+
await _r(e, t, n, r);
|
|
2481
|
+
let i = e.observe ? t.observe(hr(e.element)) : null;
|
|
2428
2482
|
return {
|
|
2429
2483
|
client: t,
|
|
2430
2484
|
get instances() {
|
|
@@ -2435,8 +2489,8 @@ async function or(e) {
|
|
|
2435
2489
|
return r ? n.get(r)?.instance ?? t.getInstance(r) : null;
|
|
2436
2490
|
},
|
|
2437
2491
|
async rescan() {
|
|
2438
|
-
let r =
|
|
2439
|
-
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) :
|
|
2492
|
+
let r = fr(e.element);
|
|
2493
|
+
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) : _r(e, t, n, r);
|
|
2440
2494
|
},
|
|
2441
2495
|
async destroy() {
|
|
2442
2496
|
i?.();
|
|
@@ -2446,4 +2500,4 @@ async function or(e) {
|
|
|
2446
2500
|
};
|
|
2447
2501
|
}
|
|
2448
2502
|
//#endregion
|
|
2449
|
-
export { a as FORMIE_HTML_EVENT_NAMES,
|
|
2503
|
+
export { a as FORMIE_HTML_EVENT_NAMES, pt as FormieValidator, he as LEGACY_FORMIE_DOM_EVENT_BRIDGES, ge as LEGACY_FORMIE_VALIDATOR_EVENT_BRIDGES, R as ModuleRegistry, Se as bindLegacyDomEventCompatibility, Ce as bindLegacyValidatorCompatibility, fe as buildFieldValueRegistry, C as createDebug, ar as createFormieClient, S as debugLog, ee as debugWarn, me as defineAddressModule, oe as defineCaptchaModule, ae as definePassiveCaptchaModule, v as definePaymentModule, le as fieldKeyToInputName, vr as formie, i as getFieldModuleEventName, ie as getFormieTranslations, r as getGlobalModuleLifecycleEventName, e as getScopedModuleLifecycleEventName, sr as hydrateFormieModules, se as inputNameToFieldKey, x as isFormieDebugEnabled, ne as mergeFormieTranslations, ce as normalizeFieldKey, o as normalizeFormieEventName, ue as parseFieldReference, pe as resolveFieldReferenceFromFormData, de as resolveFieldReferenceLive, _e as resolveLegacyCompatibilityOptions, b as setFormieDebugEnabled, re as setFormieTranslations, O as t, t as toDomEventName, D as translate };
|