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