@verbb/formie-browser 1.0.15 → 1.0.16
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 +36 -0
- package/dist/chunks/{address-country-BcEQKw0T.js → address-country-DLJF-OkC.js} +4 -8
- package/dist/chunks/{address-finder-BWGINCSA.js → address-finder-QK1m1eyv.js} +1 -1
- package/dist/chunks/{address-state-DI3ndhMU.js → address-state-CHKit8AW.js} +26 -35
- package/dist/chunks/{api-BK9b340y.js → api-BPtH5RBA.js} +152 -120
- package/dist/chunks/{api-Dxl_CKw-.js → api-BR2Gqy37.js} +306 -301
- package/dist/chunks/{api-ghNr2uxX.js → api-CmuOZ0i3.js} +1 -1
- package/dist/chunks/{bpoint-BwtuyN_O.js → bpoint-GvYfyPjD.js} +1 -1
- package/dist/chunks/{calculations-YEoVCG2q.js → calculations-DeEmdUDq.js} +5 -7
- package/dist/chunks/{captcha-eu-DWLoQFKB.js → captcha-eu-eU_M6snp.js} +1 -1
- package/dist/chunks/{checkbox-radio-gsm8QPJg.js → checkbox-radio-CSXo6svm.js} +4 -12
- package/dist/chunks/{combobox-Ba08_cHL.js → combobox-CJh2DoSO.js} +292 -333
- package/dist/chunks/{conditions-Ceeg6ReZ.js → conditions-Dz3068K0.js} +56 -72
- package/dist/chunks/{country-from-ip-DDj_mFki.js → country-from-ip-BqQ-BqLH.js} +1 -1
- package/dist/chunks/{custom-google-maps-C4l2S3GO.js → custom-google-maps-rNm5VFbb.js} +2 -6
- package/dist/chunks/{custom-link-CLazgKYH.js → custom-link-CLqFCssQ.js} +1 -1
- package/dist/chunks/{custom-maps-DqcAlD0v.js → custom-maps-DgjYQDLj.js} +4 -8
- package/dist/chunks/{date-picker-DaPvMrop.js → date-picker-BVJxJVYT.js} +30 -47
- package/dist/chunks/{debug-BV0DvdHx.js → debug-rhzqP1j2.js} +2 -14
- package/dist/chunks/{dist-ZLeW0zZ3.js → dist-CJReDlDK.js} +13 -8
- package/dist/chunks/{eway-uw0DzU-L.js → eway-BZuTBAUW.js} +1 -1
- package/dist/chunks/{field-references.resolver-Ca8MguFv.js → field-references.resolver-uSHf5-NP.js} +1 -1
- package/dist/chunks/{file-upload-B8_mH012.js → file-upload-vEUr_EuP.js} +114 -108
- package/dist/chunks/{friendly-captcha-v1-CVXaXgDO.js → friendly-captcha-v1-C_cF1WD2.js} +2 -2
- package/dist/chunks/{friendly-captcha-v2-DkeIVTKI.js → friendly-captcha-v2-BenESH-n.js} +2 -2
- package/dist/chunks/{friendly-challenge-DPG9MJb1.js → friendly-challenge-BgPBEMXx.js} +21 -35
- package/dist/chunks/{go-cardless-c4wLJdOt.js → go-cardless-DWZeB0Bq.js} +2 -6
- package/dist/chunks/{google-address-JHYvjwgN.js → google-address-DQR6rsbh.js} +2 -2
- package/dist/chunks/{hcaptcha-Dt3ELLlP.js → hcaptcha-COilLmRT.js} +1 -1
- package/dist/chunks/{hidden-BZhXnNPe.js → hidden-Bc2TpcgF.js} +1 -1
- package/dist/chunks/{http-C2QdHuWO.js → http-Dj_skqaa.js} +1 -1
- package/dist/chunks/{leaflet-src-DE6rv6M-.js → leaflet-src-Cg-LUOD8.js} +74 -122
- package/dist/chunks/{loqate-m51iPyO1.js → loqate-ZZClcacr.js} +1 -1
- package/dist/chunks/{mollie-Bn0PX173.js → mollie-8OMXIYa8.js} +2 -6
- package/dist/chunks/{moneris-BRbUvI4t.js → moneris-qYHJ9EFy.js} +1 -1
- package/dist/chunks/opayo-DlWPEnla.js +159 -0
- package/dist/chunks/{paddle-CympHVvd.js → paddle-CArfWih0.js} +1 -1
- package/dist/chunks/{password-validation-C8_uO_c_.js → password-validation-HGOU9kf3.js} +2 -2
- package/dist/chunks/{paypal-h75h6wae.js → paypal-BcaMCMGY.js} +1 -1
- package/dist/chunks/{payway-C9rHTCC_.js → payway-vxC7_bfR.js} +3 -11
- package/dist/chunks/{phone-country-B8fv-L5_.js → phone-country-Bx9EG50h.js} +123 -140
- package/dist/chunks/{place-kit-BnZGQ-L1.js → place-kit-BKk8xDXf.js} +2 -2
- package/dist/chunks/{placekit-autocomplete.esm-CZZERYur.js → placekit-autocomplete.esm-D2A_0iVU.js} +2 -5
- package/dist/chunks/{recaptcha-enterprise-CUs8BO6V.js → recaptcha-enterprise-Cx6HUpMa.js} +6 -12
- package/dist/chunks/recaptcha-shared-CcMI-r8t.js +33 -0
- package/dist/chunks/{recaptcha-v2-checkbox-P1McW4Pv.js → recaptcha-v2-checkbox-DQ9BJzcv.js} +2 -2
- package/dist/chunks/{recaptcha-v2-invisible-FGDqozSP.js → recaptcha-v2-invisible-BP0T8Pan.js} +2 -2
- package/dist/chunks/recaptcha-v3-DKMGQ27K.js +38 -0
- package/dist/chunks/{repeater-CyhDbozO.js → repeater-BR0RUvTs.js} +3 -7
- package/dist/chunks/{rich-text-uV4o_pGk.js → rich-text-H2A6cm1t.js} +33 -11
- package/dist/chunks/{rolldown-runtime-DtPi1Y-2.js → rolldown-runtime-VHNaYcLd.js} +1 -1
- package/dist/chunks/{sdk-lkwSvlpM.js → sdk-_cmrRYgp.js} +4 -16
- package/dist/chunks/{shared-OKhSay59.js → shared-CJ1LIEh3.js} +1 -3
- package/dist/chunks/{signature-7cldFbqj.js → signature-CfKA_poI.js} +9 -41
- package/dist/chunks/{snaptcha-C3QLYxFT.js → snaptcha-P3EoSQud.js} +1 -1
- package/dist/chunks/{square-C1z5DPVw.js → square-Dyz0p_GU.js} +1 -1
- package/dist/chunks/{stripe-Dmkdkq1y.js → stripe-Bfd_jp_k.js} +3 -6
- package/dist/chunks/{summary-Bn-g5SDx.js → summary-B3CAebLV.js} +44 -36
- package/dist/chunks/{survey-likert-fk1hUPff.js → survey-likert-CEtUceag.js} +1 -1
- package/dist/chunks/{survey-rank-BsLGl2LX.js → survey-rank-Dtt97y6s.js} +3 -7
- package/dist/chunks/{survey-rating-DVS6e6fM.js → survey-rating-mlDMI0uq.js} +9 -23
- package/dist/chunks/{table-j7MlLLCc.js → table-0k6Md0IO.js} +1 -1
- package/dist/chunks/{text-limit-LGMPhFuC.js → text-limit-CTVML6s7.js} +10 -10
- package/dist/chunks/{turnstile-ptihQfLl.js → turnstile-Sp4ubowK.js} +1 -1
- package/dist/chunks/{upload-manager-BW7l-BhF.js → upload-manager-Ccg3d_4I.js} +11 -25
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +752 -756
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/dom-events.d.ts +5 -0
- package/dist/js/core/dom-events.d.ts.map +1 -1
- package/dist/js/core/page-client-event.d.ts.map +1 -1
- package/dist/js/core/submit-result-state.d.ts.map +1 -1
- package/dist/js/core/submit-result-ui.d.ts.map +1 -1
- package/dist/js/core/validation-focus.d.ts.map +1 -1
- package/dist/js/modules/captchas/factories.d.ts.map +1 -1
- package/dist/js/modules/captchas/host.d.ts +4 -1
- package/dist/js/modules/captchas/host.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-shared.d.ts +1 -1
- package/dist/js/modules/captchas/recaptcha-shared.d.ts.map +1 -1
- package/dist/js/modules/captchas/recaptcha-v3.d.ts.map +1 -1
- package/dist/js/modules/fields/address-state.d.ts.map +1 -1
- package/dist/js/modules/fields/combobox.d.ts +2 -0
- package/dist/js/modules/fields/combobox.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions.d.ts.map +1 -1
- package/dist/js/modules/fields/file-upload.d.ts.map +1 -1
- package/dist/js/modules/fields/phone-country.d.ts.map +1 -1
- package/dist/js/modules/fields/rich-text.d.ts.map +1 -1
- package/dist/js/modules/fields/summary.d.ts.map +1 -1
- package/dist/js/modules/fields/text-limit.d.ts.map +1 -1
- package/dist/js/modules/payments/factories.d.ts.map +1 -1
- package/dist/js/modules/payments/opayo.d.ts.map +1 -1
- package/dist/js/submit/pipeline.d.ts +2 -0
- package/dist/js/submit/pipeline.d.ts.map +1 -1
- package/dist/js/utils/form-started-at.d.ts +1 -0
- package/dist/js/utils/form-started-at.d.ts.map +1 -1
- package/dist/js/utils/unload-warning.d.ts +4 -0
- package/dist/js/utils/unload-warning.d.ts.map +1 -1
- package/dist/js/validation/rules/required.d.ts.map +1 -1
- package/dist/js/validation/submit-readiness.d.ts.map +1 -1
- package/dist/js/validation/validator.d.ts +1 -0
- package/dist/js/validation/validator.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/js/core/create-formie-client.ts +20 -18
- package/src/js/core/dom-events.ts +30 -1
- package/src/js/core/page-client-event.ts +5 -7
- package/src/js/core/submit-result-state.ts +13 -2
- package/src/js/core/submit-result-ui.ts +21 -0
- package/src/js/core/validation-focus.ts +17 -3
- package/src/js/modules/captchas/factories.ts +241 -101
- package/src/js/modules/captchas/host.ts +16 -0
- package/src/js/modules/captchas/recaptcha-enterprise.ts +1 -1
- package/src/js/modules/captchas/recaptcha-shared.ts +23 -5
- package/src/js/modules/captchas/recaptcha-v3.ts +23 -14
- package/src/js/modules/fields/address-state.ts +6 -4
- package/src/js/modules/fields/combobox.ts +19 -1
- package/src/js/modules/fields/conditions.ts +3 -0
- package/src/js/modules/fields/file-upload.ts +11 -4
- package/src/js/modules/fields/phone-country.ts +23 -0
- package/src/js/modules/fields/rich-text.ts +33 -0
- package/src/js/modules/fields/summary.ts +63 -10
- package/src/js/modules/fields/text-limit.ts +11 -0
- package/src/js/modules/payments/factories.ts +87 -54
- package/src/js/modules/payments/opayo.ts +7 -0
- package/src/js/submit/pipeline.ts +16 -9
- package/src/js/utils/form-started-at.ts +19 -4
- package/src/js/utils/unload-warning.ts +63 -7
- package/src/js/validation/rules/required.ts +6 -0
- package/src/js/validation/submit-readiness.ts +2 -0
- package/src/js/validation/validator.ts +15 -4
- package/src/vendor.d.ts +2 -0
- package/dist/chunks/opayo-BwWdInEP.js +0 -188
- package/dist/chunks/recaptcha-shared-DTbTw-MF.js +0 -27
- package/dist/chunks/recaptcha-v3-CflUHeZD.js +0 -28
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { n as e } from "./chunks/request-profile-DhwkeCpS.js";
|
|
2
|
-
import { i as t, m as n, t as r } from "./chunks/dist-
|
|
2
|
+
import { i as t, m as n, t as r } from "./chunks/dist-CJReDlDK.js";
|
|
3
3
|
import { c as i, d as a, l as o, o as s, r as c, t as l, u } from "./chunks/event-names-BCI2FLD8.js";
|
|
4
|
-
import {
|
|
5
|
-
import { a as
|
|
6
|
-
import { i as
|
|
7
|
-
import { n as
|
|
8
|
-
import { i as
|
|
9
|
-
import { n as
|
|
10
|
-
import { i as
|
|
11
|
-
import { a as
|
|
12
|
-
import { n as
|
|
13
|
-
import { n as
|
|
14
|
-
import { i as
|
|
15
|
-
import { t as
|
|
4
|
+
import { _ as d, a as f, c as p, d as m, f as h, g, h as _, i as v, l as y, m as ee, o as b, p as x, r as S, s as C, t as w, u as T } from "./chunks/api-BR2Gqy37.js";
|
|
5
|
+
import { a as te, i as ne, n as E, r as D, t as O } from "./chunks/debug-rhzqP1j2.js";
|
|
6
|
+
import { i as k, r as re, t as A } from "./chunks/theme-classes-DAQuEqdP.js";
|
|
7
|
+
import { n as j } from "./chunks/skip-CEW89ExY.js";
|
|
8
|
+
import { i as ie, t as ae } from "./chunks/csrf-DxHg_ZYt.js";
|
|
9
|
+
import { n as M, t as oe } from "./chunks/http-Dj_skqaa.js";
|
|
10
|
+
import { i as se } from "./chunks/async-2GdXNFCE.js";
|
|
11
|
+
import { a as ce, i as le, n as ue, r as de, t as fe } from "./chunks/i18n-BY1ds1BL.js";
|
|
12
|
+
import { n as pe, t as me } from "./chunks/api-BPtH5RBA.js";
|
|
13
|
+
import { n as he, r as ge, t as _e } from "./chunks/field-references.keys-58ZSTrCW.js";
|
|
14
|
+
import { i as ve, n as ye, r as be, t as xe } from "./chunks/field-references.resolver-uSHf5-NP.js";
|
|
15
|
+
import { t as Se } from "./chunks/api-CmuOZ0i3.js";
|
|
16
16
|
//#region src/js/compatibility/event-map.ts
|
|
17
|
-
var
|
|
17
|
+
var Ce = [
|
|
18
18
|
{
|
|
19
19
|
legacyEvent: "onFormieLoaded",
|
|
20
20
|
canonicalEvent: "formie:mount:after",
|
|
@@ -67,7 +67,7 @@ var Se = [
|
|
|
67
67
|
canonicalEvent: "formie:submit:after",
|
|
68
68
|
disposition: "approximate"
|
|
69
69
|
}
|
|
70
|
-
],
|
|
70
|
+
], we = [
|
|
71
71
|
{
|
|
72
72
|
legacyEvent: "formieValidatorInitialized",
|
|
73
73
|
canonicalEvent: "formie:validator:ready",
|
|
@@ -89,7 +89,7 @@ var Se = [
|
|
|
89
89
|
disposition: "safe"
|
|
90
90
|
}
|
|
91
91
|
];
|
|
92
|
-
function
|
|
92
|
+
function Te(e) {
|
|
93
93
|
if (!e) return {
|
|
94
94
|
enabled: !1,
|
|
95
95
|
legacyDomEvents: !1,
|
|
@@ -109,18 +109,18 @@ function we(e) {
|
|
|
109
109
|
}
|
|
110
110
|
//#endregion
|
|
111
111
|
//#region src/js/compatibility/dom-adapter.ts
|
|
112
|
-
function
|
|
112
|
+
function Ee(e, t, n) {
|
|
113
113
|
e.dispatchEvent(new CustomEvent(t, {
|
|
114
114
|
bubbles: !0,
|
|
115
115
|
detail: n
|
|
116
116
|
}));
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function De(e, t) {
|
|
119
119
|
if (e.canonicalEvent !== "formie:submit:result") return !0;
|
|
120
120
|
let n = t;
|
|
121
121
|
return e.legacyEvent === "onAfterFormieSubmit" ? !!n?.ok : e.legacyEvent !== "onFormieSubmitError" || n?.ok === !1;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function Oe(e, t) {
|
|
124
124
|
let n = t && typeof t == "object" ? t : {}, r = typeof n.pageId == "string" ? n.pageId : "", i = Array.from(e.querySelectorAll("[data-formie-page-id]"));
|
|
125
125
|
return { data: {
|
|
126
126
|
nextPageId: r,
|
|
@@ -128,7 +128,7 @@ function De(e, t) {
|
|
|
128
128
|
totalPages: i.length
|
|
129
129
|
} };
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function ke(e, t, n, r, i) {
|
|
132
132
|
let a = globalThis.Formie || i;
|
|
133
133
|
return e.legacyEvent === "onFormieLoaded" ? { formie: a } : e.legacyEvent === "onFormieInit" ? {
|
|
134
134
|
formie: a,
|
|
@@ -140,12 +140,12 @@ function Oe(e, t, n, r, i) {
|
|
|
140
140
|
form: r,
|
|
141
141
|
target: n,
|
|
142
142
|
instance: i
|
|
143
|
-
} : e.legacyEvent === "onFormiePageToggle" ?
|
|
143
|
+
} : e.legacyEvent === "onFormiePageToggle" ? Oe(r, t) : t;
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
r.legacyDomEvents &&
|
|
145
|
+
function Ae({ target: e, form: t, instance: n, options: r, unbinds: i }) {
|
|
146
|
+
r.legacyDomEvents && Ce.forEach((r) => {
|
|
147
147
|
let o = (i) => {
|
|
148
|
-
i instanceof CustomEvent &&
|
|
148
|
+
i instanceof CustomEvent && De(r, i.detail) && Ee(r.target === "document" ? document : t, r.legacyEvent, ke(r, i.detail, e, t, n));
|
|
149
149
|
};
|
|
150
150
|
e.addEventListener(a(r.canonicalEvent), o), i.push(() => {
|
|
151
151
|
e.removeEventListener(a(r.canonicalEvent), o);
|
|
@@ -154,30 +154,30 @@ function ke({ target: e, form: t, instance: n, options: r, unbinds: i }) {
|
|
|
154
154
|
}
|
|
155
155
|
//#endregion
|
|
156
156
|
//#region src/js/compatibility/validator-adapter.ts
|
|
157
|
-
function
|
|
157
|
+
function N(e, t, n) {
|
|
158
158
|
e.dispatchEvent(new CustomEvent(t, {
|
|
159
159
|
bubbles: !0,
|
|
160
160
|
detail: n
|
|
161
161
|
}));
|
|
162
162
|
}
|
|
163
|
-
function
|
|
163
|
+
function je(e, t) {
|
|
164
164
|
return !!e && typeof e == "object" && e.validator === t;
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function Me({ target: e, form: t, validatorDetail: n, options: r, unbinds: i }) {
|
|
167
167
|
if (!r.legacyValidatorEvents || !n) return;
|
|
168
168
|
let { validator: a, addValidator: o, removeValidator: s } = n, c = {
|
|
169
169
|
...n,
|
|
170
170
|
form: t,
|
|
171
171
|
target: e
|
|
172
172
|
};
|
|
173
|
-
|
|
173
|
+
N(document, "formieValidatorInitialized", c);
|
|
174
174
|
let l = (e) => {
|
|
175
|
-
e instanceof CustomEvent &&
|
|
175
|
+
e instanceof CustomEvent && je(e.detail, a) && N(document, "formieValidatorDestroyed", {
|
|
176
176
|
...c,
|
|
177
177
|
...e.detail
|
|
178
178
|
});
|
|
179
179
|
}, u = (n) => {
|
|
180
|
-
n instanceof CustomEvent &&
|
|
180
|
+
n instanceof CustomEvent && je(n.detail, a) && n.target instanceof Element && t.contains(n.target) && N(n.target, "formieValidatorShowError", {
|
|
181
181
|
...n.detail,
|
|
182
182
|
addValidator: o,
|
|
183
183
|
removeValidator: s,
|
|
@@ -185,7 +185,7 @@ function je({ target: e, form: t, validatorDetail: n, options: r, unbinds: i })
|
|
|
185
185
|
target: e
|
|
186
186
|
});
|
|
187
187
|
}, d = (n) => {
|
|
188
|
-
n instanceof CustomEvent &&
|
|
188
|
+
n instanceof CustomEvent && je(n.detail, a) && n.target instanceof Element && t.contains(n.target) && N(n.target, "formieValidatorClearError", {
|
|
189
189
|
...n.detail,
|
|
190
190
|
addValidator: o,
|
|
191
191
|
removeValidator: s,
|
|
@@ -199,80 +199,82 @@ function je({ target: e, form: t, validatorDetail: n, options: r, unbinds: i })
|
|
|
199
199
|
}
|
|
200
200
|
//#endregion
|
|
201
201
|
//#region src/js/core/error-aria-live.ts
|
|
202
|
-
function
|
|
202
|
+
function Ne(e) {
|
|
203
203
|
let t = (e.dataset.formieErrorAriaLive || "polite").trim().toLowerCase();
|
|
204
204
|
return t === "assertive" || t === "off" ? t : "polite";
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function Pe(e, t) {
|
|
207
207
|
return e === "off" ? null : t ? e : "polite";
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function Fe(e) {
|
|
210
210
|
return e === "off" ? null : e;
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
|
|
214
|
-
e.setAttribute("aria-live", t), e.setAttribute("aria-atomic", "true");
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
e.removeAttribute("aria-live"), e.removeAttribute("aria-atomic");
|
|
212
|
+
function Ie(e, t) {
|
|
213
|
+
t ? (e.setAttribute("aria-live", t), e.setAttribute("aria-atomic", "true")) : (e.removeAttribute("aria-live"), e.removeAttribute("aria-atomic"));
|
|
218
214
|
}
|
|
219
215
|
//#endregion
|
|
220
216
|
//#region src/js/core/field-error-aria.ts
|
|
221
|
-
function
|
|
217
|
+
function Le(e, t) {
|
|
222
218
|
let n = (e.getAttribute("aria-describedby") || "").trim(), r = n ? n.split(/\s+/) : [];
|
|
223
219
|
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
224
220
|
}
|
|
225
|
-
function
|
|
221
|
+
function Re(e, t = document) {
|
|
226
222
|
let n = (e.getAttribute("aria-describedby") || "").trim();
|
|
227
223
|
if (!n) return;
|
|
228
224
|
let r = n.split(/\s+/).filter((e) => !!e && !!t.getElementById(e));
|
|
229
|
-
|
|
230
|
-
e.setAttribute("aria-describedby", r.join(" "));
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
e.removeAttribute("aria-describedby");
|
|
225
|
+
r.length ? e.setAttribute("aria-describedby", r.join(" ")) : e.removeAttribute("aria-describedby");
|
|
234
226
|
}
|
|
235
|
-
function
|
|
236
|
-
e.setAttribute("aria-errormessage", t),
|
|
227
|
+
function P(e, t) {
|
|
228
|
+
e.setAttribute("aria-errormessage", t), Le(e, t);
|
|
237
229
|
}
|
|
238
|
-
function
|
|
230
|
+
function ze(e, t = []) {
|
|
239
231
|
t.forEach((t) => {
|
|
240
232
|
e.getAttribute("aria-errormessage") === t && e.removeAttribute("aria-errormessage");
|
|
241
|
-
}), !t.length && e.hasAttribute("aria-errormessage") && e.removeAttribute("aria-errormessage"),
|
|
233
|
+
}), !t.length && e.hasAttribute("aria-errormessage") && e.removeAttribute("aria-errormessage"), Re(e);
|
|
242
234
|
}
|
|
243
235
|
//#endregion
|
|
244
236
|
//#region src/js/core/validation-focus.ts
|
|
245
|
-
function ze(e) {
|
|
246
|
-
return Array.from(e.querySelectorAll("[data-formie-field-handle]")).find((e) => e.getAttribute("data-formie-field-has-error") === "true" || e.querySelector("[data-formie-field-error]") !== null) || null;
|
|
247
|
-
}
|
|
248
237
|
function Be(e) {
|
|
249
|
-
return Array.from(e.querySelectorAll("[
|
|
238
|
+
return Array.from(e.querySelectorAll("[data-formie-field-handle]")).find((e) => e.getAttribute("data-formie-field-has-error") === "true" || e.querySelector("[data-formie-field-error]") !== null) || null;
|
|
250
239
|
}
|
|
251
240
|
function Ve(e) {
|
|
252
|
-
|
|
241
|
+
if (e instanceof HTMLTextAreaElement) {
|
|
242
|
+
let t = e.richText;
|
|
243
|
+
if (t) return t.content;
|
|
244
|
+
}
|
|
245
|
+
return e;
|
|
253
246
|
}
|
|
254
247
|
function He(e) {
|
|
248
|
+
let t = Array.from(e.querySelectorAll("[aria-invalid=\"true\"]")).find((e) => !j(e));
|
|
249
|
+
if (t) return Ve(t);
|
|
250
|
+
let n = Array.from(e.querySelectorAll("input:not([type=\"hidden\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])")).find((e) => !j(e));
|
|
251
|
+
return n ? Ve(n) : null;
|
|
252
|
+
}
|
|
253
|
+
function Ue(e) {
|
|
254
|
+
return e.querySelector("[data-formie-message-error], [data-formie-error-container], [data-formie-errors]");
|
|
255
|
+
}
|
|
256
|
+
function We(e) {
|
|
255
257
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
256
258
|
let n = t;
|
|
257
259
|
if (n.getAttribute("data-formie-field-has-error") !== "true" && n.querySelector("[data-formie-field-error]") === null) return;
|
|
258
|
-
n.setAttribute("data-formie-field-has-error", "true"),
|
|
260
|
+
n.setAttribute("data-formie-field-has-error", "true"), A(n, e, "fieldLayoutError");
|
|
259
261
|
let r = n.querySelector("[data-formie-field-error]")?.id || "";
|
|
260
262
|
n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
261
263
|
let i = t;
|
|
262
|
-
if (
|
|
263
|
-
i.setAttribute("aria-invalid", "true"),
|
|
264
|
+
if (j(i)) return;
|
|
265
|
+
i.setAttribute("aria-invalid", "true"), A(i, e, "fieldControlError"), i.setAttribute("data-formie-input-has-error", "true"), r && P(i, r);
|
|
264
266
|
let a = n.querySelector("[data-formie-instructions]");
|
|
265
|
-
a?.id &&
|
|
267
|
+
a?.id && Le(i, a.id);
|
|
266
268
|
});
|
|
267
269
|
});
|
|
268
270
|
}
|
|
269
|
-
function
|
|
270
|
-
return !!
|
|
271
|
+
function Ge(e) {
|
|
272
|
+
return !!Be(e) || !!Ue(e);
|
|
271
273
|
}
|
|
272
|
-
function
|
|
273
|
-
let t =
|
|
274
|
+
function F(e) {
|
|
275
|
+
let t = Be(e);
|
|
274
276
|
if (t) {
|
|
275
|
-
let e =
|
|
277
|
+
let e = He(t);
|
|
276
278
|
if (e) {
|
|
277
279
|
if (e.scrollIntoView({
|
|
278
280
|
behavior: "smooth",
|
|
@@ -289,7 +291,7 @@ function We(e) {
|
|
|
289
291
|
block: "center"
|
|
290
292
|
}), !0;
|
|
291
293
|
}
|
|
292
|
-
let n =
|
|
294
|
+
let n = Ue(e);
|
|
293
295
|
return n ? (n.scrollIntoView({
|
|
294
296
|
behavior: "smooth",
|
|
295
297
|
block: "center"
|
|
@@ -297,8 +299,8 @@ function We(e) {
|
|
|
297
299
|
}
|
|
298
300
|
//#endregion
|
|
299
301
|
//#region src/js/transport/forms-api.ts
|
|
300
|
-
var
|
|
301
|
-
function
|
|
302
|
+
var I = O("general", "transport");
|
|
303
|
+
function Ke(e) {
|
|
302
304
|
let t = {};
|
|
303
305
|
return [
|
|
304
306
|
"theme",
|
|
@@ -309,7 +311,7 @@ function Ge(e) {
|
|
|
309
311
|
e[n] !== void 0 && (t[n] = e[n]);
|
|
310
312
|
}), t;
|
|
311
313
|
}
|
|
312
|
-
function
|
|
314
|
+
function qe(e, t) {
|
|
313
315
|
let n = e.success === !0, r = e.completion && typeof e.completion == "object" ? e.completion : null, i = e.payment && typeof e.payment == "object" ? e.payment : null, a = [
|
|
314
316
|
"requiresAction",
|
|
315
317
|
"pending",
|
|
@@ -350,36 +352,36 @@ function Ke(e, t) {
|
|
|
350
352
|
meta: e
|
|
351
353
|
};
|
|
352
354
|
}
|
|
353
|
-
async function
|
|
355
|
+
async function Je(e, t, n = {}, r = {}) {
|
|
354
356
|
let i = JSON.stringify({
|
|
355
357
|
handle: t,
|
|
356
358
|
renderOptions: n
|
|
357
359
|
});
|
|
358
|
-
|
|
360
|
+
I.log("requestRender start.", {
|
|
359
361
|
endpoint: e,
|
|
360
362
|
handle: t
|
|
361
363
|
});
|
|
362
|
-
let a = await
|
|
364
|
+
let a = await M(e, {
|
|
363
365
|
...r,
|
|
364
366
|
method: "POST",
|
|
365
367
|
body: i,
|
|
366
368
|
headers: { "Content-Type": "application/json" }
|
|
367
369
|
});
|
|
368
|
-
return
|
|
370
|
+
return I.log("requestRender complete.", { hasHtml: !!a.html }), a;
|
|
369
371
|
}
|
|
370
|
-
async function
|
|
372
|
+
async function Ye(e, t, n = {}, r = {}) {
|
|
371
373
|
let i = JSON.stringify({
|
|
372
374
|
query: "\nquery FormieHtmlForm($handle: String!, $input: ServerRenderPayloadInput) {\n formieHtmlForm(handle: $handle, input: $input) {\n html\n }\n}",
|
|
373
375
|
variables: {
|
|
374
376
|
handle: t,
|
|
375
|
-
input:
|
|
377
|
+
input: Ke(n)
|
|
376
378
|
}
|
|
377
379
|
});
|
|
378
|
-
|
|
380
|
+
I.log("requestGraphqlRender start.", {
|
|
379
381
|
endpoint: e,
|
|
380
382
|
handle: t
|
|
381
383
|
});
|
|
382
|
-
let a = await
|
|
384
|
+
let a = await M(e, {
|
|
383
385
|
...r,
|
|
384
386
|
method: "POST",
|
|
385
387
|
body: i,
|
|
@@ -388,19 +390,19 @@ async function Je(e, t, n = {}, r = {}) {
|
|
|
388
390
|
if (Array.isArray(a.errors) && a.errors.length > 0) throw Error(a.errors.map((e) => e.message || "Unknown GraphQL error").join("; "));
|
|
389
391
|
if (!a.data?.formieHtmlForm) throw Error(`Form not found for handle "${t}".`);
|
|
390
392
|
let o = a.data.formieHtmlForm;
|
|
391
|
-
return
|
|
393
|
+
return I.log("requestGraphqlRender complete.", { hasHtml: !!o.html }), o;
|
|
392
394
|
}
|
|
393
|
-
async function
|
|
395
|
+
async function Xe(e, t, n, r = {}, i) {
|
|
394
396
|
let a = new URL(e, window.location.origin);
|
|
395
|
-
a.searchParams.set("handle", t), n && a.searchParams.set("renderId", n), i && a.searchParams.set("requestToken", i),
|
|
397
|
+
a.searchParams.set("handle", t), n && a.searchParams.set("renderId", n), i && a.searchParams.set("requestToken", i), I.log("requestRefreshTokens start.", {
|
|
396
398
|
endpoint: a.toString(),
|
|
397
399
|
handle: t,
|
|
398
400
|
hasRenderId: !!n
|
|
399
401
|
});
|
|
400
|
-
let o = await
|
|
401
|
-
return
|
|
402
|
+
let o = await M(a.toString(), r);
|
|
403
|
+
return I.log("requestRefreshTokens complete.", { hasRefreshTokens: !!o.refreshTokens }), o.refreshTokens || o;
|
|
402
404
|
}
|
|
403
|
-
async function
|
|
405
|
+
async function Ze(e, t, n) {
|
|
404
406
|
let r = new URL(e, window.location.origin), i = new FormData();
|
|
405
407
|
if (n && i.append("pageId", n), t) {
|
|
406
408
|
[
|
|
@@ -414,14 +416,14 @@ async function Ye(e, t, n) {
|
|
|
414
416
|
].forEach((e) => {
|
|
415
417
|
let n = t.querySelector(`input[name="${e}"]`)?.value?.trim();
|
|
416
418
|
n && i.append(e, n);
|
|
417
|
-
}),
|
|
419
|
+
}), ae(i, t);
|
|
418
420
|
for (let [e, n] of new FormData(t)) e.startsWith("fields[") && i.append(e, n);
|
|
419
421
|
}
|
|
420
|
-
|
|
422
|
+
I.log("requestSetPage start.", {
|
|
421
423
|
requestUrl: r.toString(),
|
|
422
424
|
pageId: n || null
|
|
423
425
|
});
|
|
424
|
-
let a = await (await
|
|
426
|
+
let a = await (await oe(r.toString(), {
|
|
425
427
|
method: "POST",
|
|
426
428
|
body: i,
|
|
427
429
|
profile: t?.dataset.formieRequestProfile
|
|
@@ -430,9 +432,9 @@ async function Ye(e, t, n) {
|
|
|
430
432
|
let e = a.session, n = t.querySelector("input[name=\"expectedVersion\"]"), r = t.querySelector("input[name=\"requestToken\"]");
|
|
431
433
|
n && (n.value = String(e.version)), r && e.tokens?.request && (r.value = e.tokens.request);
|
|
432
434
|
}
|
|
433
|
-
return
|
|
435
|
+
return I.log("requestSetPage complete.", a), a;
|
|
434
436
|
}
|
|
435
|
-
function
|
|
437
|
+
function Qe(e, t) {
|
|
436
438
|
let n = new URL(e, window.location.origin), i = new FormData();
|
|
437
439
|
[
|
|
438
440
|
"handle",
|
|
@@ -442,7 +444,7 @@ function Xe(e, t) {
|
|
|
442
444
|
].forEach((e) => {
|
|
443
445
|
let n = t.querySelector(`input[name="${e}"]`)?.value?.trim();
|
|
444
446
|
n && i.append(e, n);
|
|
445
|
-
}),
|
|
447
|
+
}), ae(i, t), I.log("clearSubmissionOnUnload start.", { requestUrl: n.toString() });
|
|
446
448
|
try {
|
|
447
449
|
if (t.dataset.formieRequestProfile !== "cross-origin-public" && typeof navigator.sendBeacon == "function" && navigator.sendBeacon(n.toString(), i)) return;
|
|
448
450
|
} catch {}
|
|
@@ -453,9 +455,9 @@ function Xe(e, t) {
|
|
|
453
455
|
headers: { Accept: "application/json" }
|
|
454
456
|
}, { profile: t.dataset.formieRequestProfile });
|
|
455
457
|
}
|
|
456
|
-
async function
|
|
458
|
+
async function $e(e, t) {
|
|
457
459
|
let n = (e.getAttribute("method") || "POST").toUpperCase(), i = e.getAttribute("action") || window.location.href, a = e.dataset.formieErrorMessage?.trim() || "Submission failed.";
|
|
458
|
-
|
|
460
|
+
I.log("submitForm start.", {
|
|
459
461
|
method: n,
|
|
460
462
|
action: i,
|
|
461
463
|
submitAction: t.get("submitAction")
|
|
@@ -465,13 +467,13 @@ async function Ze(e, t) {
|
|
|
465
467
|
body: t,
|
|
466
468
|
headers: { Accept: "application/json" }
|
|
467
469
|
}, { profile: e.dataset.formieRequestProfile }), s = o.headers.get("content-type") || "";
|
|
468
|
-
if (!s.includes("application/json")) return o.ok ? (
|
|
470
|
+
if (!s.includes("application/json")) return o.ok ? (I.log("submitForm non-JSON success response.", {
|
|
469
471
|
status: o.status,
|
|
470
472
|
contentType: s
|
|
471
473
|
}), {
|
|
472
474
|
ok: !0,
|
|
473
475
|
message: "Submission completed."
|
|
474
|
-
}) : (
|
|
476
|
+
}) : (I.warn("submitForm non-JSON HTTP error.", {
|
|
475
477
|
status: o.status,
|
|
476
478
|
contentType: s
|
|
477
479
|
}), {
|
|
@@ -480,8 +482,8 @@ async function Ze(e, t) {
|
|
|
480
482
|
message: `Request failed (${o.status}).`,
|
|
481
483
|
formErrors: [`Request failed (${o.status}).`]
|
|
482
484
|
});
|
|
483
|
-
let c =
|
|
484
|
-
return
|
|
485
|
+
let c = qe(await o.json(), a);
|
|
486
|
+
return I.log("submitForm JSON response normalized.", {
|
|
485
487
|
ok: c.ok,
|
|
486
488
|
code: c.code,
|
|
487
489
|
hasRedirect: !!c.redirect?.url,
|
|
@@ -490,20 +492,20 @@ async function Ze(e, t) {
|
|
|
490
492
|
}
|
|
491
493
|
//#endregion
|
|
492
494
|
//#region src/js/submit/pipeline.ts
|
|
493
|
-
var
|
|
495
|
+
var et = [
|
|
494
496
|
"prepare",
|
|
495
497
|
"validate",
|
|
496
498
|
"challenge",
|
|
497
499
|
"payment",
|
|
498
500
|
"send",
|
|
499
501
|
"result"
|
|
500
|
-
],
|
|
502
|
+
], tt = [
|
|
501
503
|
"prepare",
|
|
502
504
|
"validate",
|
|
503
505
|
"challenge",
|
|
504
506
|
"payment"
|
|
505
|
-
],
|
|
506
|
-
function
|
|
507
|
+
], L = O("general", "pipeline");
|
|
508
|
+
function nt(e, t) {
|
|
507
509
|
return {
|
|
508
510
|
ok: !1,
|
|
509
511
|
stage: e,
|
|
@@ -512,13 +514,13 @@ function I(e, t) {
|
|
|
512
514
|
formErrors: [t || "Submission aborted."]
|
|
513
515
|
};
|
|
514
516
|
}
|
|
515
|
-
function
|
|
517
|
+
function rt(e) {
|
|
516
518
|
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
|
|
517
519
|
}
|
|
518
|
-
function
|
|
520
|
+
function it(e) {
|
|
519
521
|
return !(!e.name || e.disabled || e instanceof HTMLInputElement && (e.type === "submit" || e.type === "button" || e.type === "reset" || e.type === "image" || (e.type === "checkbox" || e.type === "radio") && !e.checked || e.type === "file" && (!e.files || e.files.length === 0)));
|
|
520
522
|
}
|
|
521
|
-
function
|
|
523
|
+
function at(e, t) {
|
|
522
524
|
if (t instanceof HTMLInputElement) {
|
|
523
525
|
if (t.type === "file") {
|
|
524
526
|
Array.from(t.files || []).forEach((n) => {
|
|
@@ -527,63 +529,57 @@ function nt(e, t) {
|
|
|
527
529
|
return;
|
|
528
530
|
}
|
|
529
531
|
e.append(t.name, t.value);
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
Array.from(t.selectedOptions).forEach((n) => {
|
|
534
|
-
e.append(t.name, n.value);
|
|
535
|
-
});
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
e.append(t.name, t.value);
|
|
532
|
+
} else t instanceof HTMLSelectElement && t.multiple ? Array.from(t.selectedOptions).forEach((n) => {
|
|
533
|
+
e.append(t.name, n.value);
|
|
534
|
+
}) : e.append(t.name, t.value);
|
|
539
535
|
}
|
|
540
|
-
function
|
|
536
|
+
function ot(e, t) {
|
|
541
537
|
t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
542
|
-
let n =
|
|
543
|
-
n && !n.closest("[data-formie-page]") &&
|
|
538
|
+
let n = rt(t) ? t : null;
|
|
539
|
+
n && !n.closest("[data-formie-page]") && it(n) && at(e, n);
|
|
544
540
|
});
|
|
545
541
|
}
|
|
546
|
-
function
|
|
542
|
+
function st(e, t) {
|
|
547
543
|
let n = /* @__PURE__ */ new Set();
|
|
548
544
|
return t.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
549
|
-
let r =
|
|
550
|
-
r && r.name && !r.disabled && (r instanceof HTMLInputElement && (r.type === "submit" || r.type === "button" || r.type === "reset" || r.type === "image") || (r.name.startsWith("fields[") && n.add(r.name),
|
|
545
|
+
let r = rt(t) ? t : null;
|
|
546
|
+
r && r.name && !r.disabled && (r instanceof HTMLInputElement && (r.type === "submit" || r.type === "button" || r.type === "reset" || r.type === "image") || (r.name.startsWith("fields[") && n.add(r.name), it(r) && at(e, r)));
|
|
551
547
|
}), n;
|
|
552
548
|
}
|
|
553
|
-
function
|
|
549
|
+
function ct(e, t) {
|
|
554
550
|
t.forEach((t) => {
|
|
555
551
|
e.has(t) || e.append(t, "");
|
|
556
552
|
});
|
|
557
553
|
}
|
|
558
|
-
function
|
|
559
|
-
let n =
|
|
554
|
+
function lt(e, t) {
|
|
555
|
+
let n = T(e), r = n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || null;
|
|
560
556
|
if (!n.length || !r) {
|
|
561
557
|
let n = new FormData(e);
|
|
562
558
|
return n.set("submitAction", t), n;
|
|
563
559
|
}
|
|
564
560
|
let i = new FormData();
|
|
565
|
-
return
|
|
561
|
+
return ot(i, e), ct(i, st(i, r)), i.set("submitAction", t), i;
|
|
566
562
|
}
|
|
567
|
-
function
|
|
563
|
+
function ut(e, t) {
|
|
568
564
|
if (t !== "submit") return !1;
|
|
569
|
-
let n =
|
|
565
|
+
let n = T(e);
|
|
570
566
|
return !n.length || (n.find((e) => !e.hasAttribute("data-formie-page-hidden")) || n[n.length - 1]) === n[n.length - 1];
|
|
571
567
|
}
|
|
572
|
-
async function
|
|
573
|
-
|
|
568
|
+
async function dt(e, t, n, r = {}) {
|
|
569
|
+
L.log("Starting submit pipeline.", {
|
|
574
570
|
action: t,
|
|
575
571
|
preflightOnly: r.preflightOnly === !0
|
|
576
572
|
});
|
|
577
|
-
let i = !1, a, o = null, s =
|
|
573
|
+
let i = !1, a, o = null, s = ut(e, t), c = d(e, {
|
|
578
574
|
form: e,
|
|
579
575
|
action: t,
|
|
580
|
-
formData:
|
|
576
|
+
formData: lt(e, t),
|
|
581
577
|
abort: (e) => {
|
|
582
|
-
i = !0, a = e,
|
|
578
|
+
i = !0, a = e, L.warn("Pipeline aborted.", { reason: e });
|
|
583
579
|
},
|
|
584
580
|
isAborted: () => i,
|
|
585
581
|
abortReason: () => a
|
|
586
|
-
}, l = {
|
|
582
|
+
}), l = (t, r) => n.emitSafe(t, d(e, r)), u = {
|
|
587
583
|
prepare: async (e) => {
|
|
588
584
|
let t = e.form.querySelector("input[name=\"submitAction\"]");
|
|
589
585
|
return t && (t.value = e.action), e.formData.set("submitAction", e.action), null;
|
|
@@ -591,7 +587,7 @@ async function ct(e, t, n, r = {}) {
|
|
|
591
587
|
validate: async (e) => {
|
|
592
588
|
if (e.action !== "submit" || r.validateOnSubmit === !1) return null;
|
|
593
589
|
if (r.validator) {
|
|
594
|
-
let { scope: t, final: n } =
|
|
590
|
+
let { scope: t, final: n } = m(e.form), i = r.validator.submit(n ? e.form : t, { final: n });
|
|
595
591
|
if (i.length > 0) {
|
|
596
592
|
let e = i[0]?.input;
|
|
597
593
|
if (e) {
|
|
@@ -627,68 +623,68 @@ async function ct(e, t, n, r = {}) {
|
|
|
627
623
|
challenge: async () => null,
|
|
628
624
|
payment: async () => null,
|
|
629
625
|
send: async (e) => {
|
|
630
|
-
e.formData =
|
|
631
|
-
let t = await
|
|
626
|
+
e.formData = lt(e.form, e.action);
|
|
627
|
+
let t = await $e(e.form, e.formData);
|
|
632
628
|
return o = t, t;
|
|
633
629
|
},
|
|
634
630
|
result: async (e) => (o && o.ok && o.redirect?.url && (o.redirect.target === "new-tab" ? window.open(o.redirect.url, "_blank", "noopener,noreferrer") : (e.form.setAttribute("data-formie-internal-navigation", "redirect"), window.location.href = o.redirect.url)), null)
|
|
635
631
|
};
|
|
636
632
|
{
|
|
637
633
|
let e = await n.emitSafe("formie:submit:before", c);
|
|
638
|
-
e.failed.length > 0 &&
|
|
634
|
+
e.failed.length > 0 && L.warn("Submit before listeners failed.", {
|
|
639
635
|
eventName: e.eventName,
|
|
640
636
|
failed: e.failed.length
|
|
641
637
|
});
|
|
642
638
|
}
|
|
643
639
|
if (s) {
|
|
644
640
|
let e = await n.emitSafe("formie:submit:final:before", c);
|
|
645
|
-
e.failed.length > 0 &&
|
|
641
|
+
e.failed.length > 0 && L.warn("Final submit before listeners failed.", {
|
|
646
642
|
eventName: e.eventName,
|
|
647
643
|
failed: e.failed.length
|
|
648
644
|
});
|
|
649
645
|
}
|
|
650
|
-
let
|
|
651
|
-
for (let e of
|
|
652
|
-
if (
|
|
646
|
+
let f = r.preflightOnly ? tt : et;
|
|
647
|
+
for (let e of f) {
|
|
648
|
+
if (L.log("Stage start.", {
|
|
653
649
|
stage: e,
|
|
654
650
|
action: t
|
|
655
|
-
}), i) return
|
|
651
|
+
}), i) return L.warn("Stage skipped due to abort.", {
|
|
656
652
|
stage: e,
|
|
657
653
|
reason: a
|
|
658
|
-
}),
|
|
654
|
+
}), nt(e, a);
|
|
659
655
|
{
|
|
660
656
|
let t = await n.emitSafe(`formie:stage:${e}:before`, {
|
|
661
657
|
...c,
|
|
662
658
|
stage: e
|
|
663
659
|
});
|
|
664
|
-
t.failed.length > 0 &&
|
|
660
|
+
t.failed.length > 0 && L.warn("Stage before listeners failed.", {
|
|
665
661
|
stage: e,
|
|
666
662
|
failed: t.failed.length
|
|
667
663
|
});
|
|
668
664
|
}
|
|
669
665
|
if (i) {
|
|
670
|
-
let t =
|
|
666
|
+
let t = nt(e, a);
|
|
671
667
|
{
|
|
672
|
-
let
|
|
673
|
-
|
|
668
|
+
let n = await l("formie:submit:after", t);
|
|
669
|
+
n.failed.length > 0 && L.warn("Submit after listeners failed (abort before stage).", {
|
|
674
670
|
stage: e,
|
|
675
|
-
failed:
|
|
671
|
+
failed: n.failed.length
|
|
676
672
|
});
|
|
677
673
|
}
|
|
678
674
|
if (s) {
|
|
679
|
-
let
|
|
680
|
-
|
|
675
|
+
let n = await l("formie:submit:final:after", t);
|
|
676
|
+
n.failed.length > 0 && L.warn("Final submit after listeners failed (abort before stage).", {
|
|
681
677
|
stage: e,
|
|
682
|
-
failed:
|
|
678
|
+
failed: n.failed.length
|
|
683
679
|
});
|
|
684
680
|
}
|
|
685
|
-
return
|
|
681
|
+
return L.warn("Aborted after stage before-hooks.", {
|
|
686
682
|
stage: e,
|
|
687
683
|
reason: a
|
|
688
684
|
}), t;
|
|
689
685
|
}
|
|
690
|
-
let r = await
|
|
691
|
-
|
|
686
|
+
let r = await u[e](c);
|
|
687
|
+
L.log("Stage runner complete.", {
|
|
692
688
|
stage: e,
|
|
693
689
|
hasResult: !!r,
|
|
694
690
|
ok: r ? r.ok : void 0,
|
|
@@ -700,291 +696,302 @@ async function ct(e, t, n, r = {}) {
|
|
|
700
696
|
stage: e,
|
|
701
697
|
result: r
|
|
702
698
|
});
|
|
703
|
-
t.failed.length > 0 &&
|
|
699
|
+
t.failed.length > 0 && L.warn("Stage after listeners failed.", {
|
|
704
700
|
stage: e,
|
|
705
701
|
failed: t.failed.length
|
|
706
702
|
});
|
|
707
703
|
}
|
|
708
704
|
if (i) {
|
|
709
|
-
let t =
|
|
705
|
+
let t = nt(e, a);
|
|
710
706
|
{
|
|
711
|
-
let
|
|
712
|
-
|
|
707
|
+
let n = await l("formie:submit:after", t);
|
|
708
|
+
n.failed.length > 0 && L.warn("Submit after listeners failed (abort after stage).", {
|
|
713
709
|
stage: e,
|
|
714
|
-
failed:
|
|
710
|
+
failed: n.failed.length
|
|
715
711
|
});
|
|
716
712
|
}
|
|
717
713
|
if (s) {
|
|
718
|
-
let
|
|
719
|
-
|
|
714
|
+
let n = await l("formie:submit:final:after", t);
|
|
715
|
+
n.failed.length > 0 && L.warn("Final submit after listeners failed (abort after stage).", {
|
|
720
716
|
stage: e,
|
|
721
|
-
failed:
|
|
717
|
+
failed: n.failed.length
|
|
722
718
|
});
|
|
723
719
|
}
|
|
724
|
-
return
|
|
720
|
+
return L.warn("Aborted after stage after-hooks.", {
|
|
725
721
|
stage: e,
|
|
726
722
|
reason: a
|
|
727
723
|
}), t;
|
|
728
724
|
}
|
|
729
725
|
if (r && !r.ok) {
|
|
730
726
|
{
|
|
731
|
-
let t = await
|
|
732
|
-
t.failed.length > 0 &&
|
|
727
|
+
let t = await l("formie:submit:after", r);
|
|
728
|
+
t.failed.length > 0 && L.warn("Submit after listeners failed (failed stage).", {
|
|
733
729
|
stage: e,
|
|
734
730
|
failed: t.failed.length
|
|
735
731
|
});
|
|
736
732
|
}
|
|
737
733
|
if (s) {
|
|
738
|
-
let t = await
|
|
739
|
-
t.failed.length > 0 &&
|
|
734
|
+
let t = await l("formie:submit:final:after", r);
|
|
735
|
+
t.failed.length > 0 && L.warn("Final submit after listeners failed (failed stage).", {
|
|
740
736
|
stage: e,
|
|
741
737
|
failed: t.failed.length
|
|
742
738
|
});
|
|
743
739
|
}
|
|
744
|
-
return
|
|
740
|
+
return L.warn("Pipeline short-circuited by failed stage.", {
|
|
745
741
|
stage: e,
|
|
746
742
|
code: r.code,
|
|
747
743
|
message: r.message
|
|
748
744
|
}), r;
|
|
749
745
|
}
|
|
750
746
|
}
|
|
751
|
-
let
|
|
747
|
+
let p = o || {
|
|
752
748
|
ok: !0,
|
|
753
749
|
stage: r.preflightOnly ? "payment" : "result",
|
|
754
750
|
code: r.preflightOnly ? "PREFLIGHT_COMPLETE" : void 0,
|
|
755
751
|
message: r.preflightOnly ? "Submission preflight completed." : "Submission completed."
|
|
756
752
|
};
|
|
757
753
|
{
|
|
758
|
-
let e = await
|
|
759
|
-
e.failed.length > 0 &&
|
|
754
|
+
let e = await l("formie:submit:after", p);
|
|
755
|
+
e.failed.length > 0 && L.warn("Submit after listeners failed (success).", { failed: e.failed.length });
|
|
760
756
|
}
|
|
761
757
|
if (s) {
|
|
762
|
-
let e = await
|
|
763
|
-
e.failed.length > 0 &&
|
|
758
|
+
let e = await l("formie:submit:final:after", p);
|
|
759
|
+
e.failed.length > 0 && L.warn("Final submit after listeners failed (success).", { failed: e.failed.length });
|
|
764
760
|
}
|
|
765
|
-
return
|
|
766
|
-
ok:
|
|
767
|
-
stage:
|
|
768
|
-
code:
|
|
769
|
-
}),
|
|
761
|
+
return L.log("Pipeline completed.", {
|
|
762
|
+
ok: p.ok,
|
|
763
|
+
stage: p.stage,
|
|
764
|
+
code: p.code
|
|
765
|
+
}), p;
|
|
770
766
|
}
|
|
771
767
|
//#endregion
|
|
772
768
|
//#region src/js/core/field-error-container.ts
|
|
773
|
-
function
|
|
769
|
+
function ft(e) {
|
|
774
770
|
return e.querySelector("[data-formie-field-layout]")?.getAttribute("data-formie-error-position")?.trim() === "above" ? "above" : "below";
|
|
775
771
|
}
|
|
776
|
-
function
|
|
772
|
+
function pt(e, t) {
|
|
777
773
|
let n = e.querySelector("[data-formie-field-errors]");
|
|
778
774
|
if (n) return n;
|
|
779
|
-
let r = e.querySelector("[data-formie-field-content]"), i = e.querySelector("[data-formie-field-control]"), a =
|
|
775
|
+
let r = e.querySelector("[data-formie-field-content]"), i = e.querySelector("[data-formie-field-control]"), a = ft(e), o = document.createElement("div");
|
|
780
776
|
return o.setAttribute("data-formie-field-errors", "true"), t?.(o), r && i ? a === "above" ? r.insertBefore(o, i) : r.appendChild(o) : e.appendChild(o), o;
|
|
781
777
|
}
|
|
782
778
|
//#endregion
|
|
783
779
|
//#region src/js/core/submit-result-ui.ts
|
|
784
|
-
var
|
|
785
|
-
function
|
|
780
|
+
var R = /* @__PURE__ */ new WeakMap();
|
|
781
|
+
function mt(e) {
|
|
786
782
|
return (e.dataset.formieCompletionBehavior || e.dataset.formieSubmitAction || "").trim();
|
|
787
783
|
}
|
|
788
|
-
function
|
|
784
|
+
function ht(e) {
|
|
789
785
|
return (e.dataset.formieErrorMessagePosition || "top-form").trim() || "top-form";
|
|
790
786
|
}
|
|
791
|
-
function
|
|
787
|
+
function gt(e) {
|
|
792
788
|
return (e.dataset.formieSuccessMessagePosition || e.dataset.formieSubmitActionMessagePosition || "").trim();
|
|
793
789
|
}
|
|
794
|
-
function
|
|
790
|
+
function _t(e) {
|
|
795
791
|
let t = (e.dataset.formieSuccessMessageTimeout || e.dataset.formieSubmitActionMessageTimeout || "").trim();
|
|
796
792
|
if (!t) return null;
|
|
797
793
|
let n = Number.parseFloat(t);
|
|
798
794
|
return !Number.isFinite(n) || n < 0 ? null : Math.round(n * 1e3);
|
|
799
795
|
}
|
|
800
|
-
function
|
|
796
|
+
function vt(e) {
|
|
801
797
|
let t = e.dataset.formieHideFormAfterSubmit ?? e.dataset.formieSubmitActionFormHide;
|
|
802
798
|
if (t === void 0) return !1;
|
|
803
799
|
let n = t.trim().toLowerCase();
|
|
804
800
|
return n === "true" || n === "1" || n === "";
|
|
805
801
|
}
|
|
806
|
-
function
|
|
807
|
-
let t =
|
|
808
|
-
typeof t == "number" && (window.clearTimeout(t),
|
|
802
|
+
function yt(e) {
|
|
803
|
+
let t = R.get(e);
|
|
804
|
+
typeof t == "number" && (window.clearTimeout(t), R.delete(e));
|
|
809
805
|
}
|
|
810
|
-
function
|
|
806
|
+
function bt(e) {
|
|
811
807
|
return e.querySelector("[data-formie-form-messages-top]") || e;
|
|
812
808
|
}
|
|
813
|
-
function
|
|
809
|
+
function xt(e) {
|
|
814
810
|
return e.querySelector("[data-formie-form-messages-bottom]") || e;
|
|
815
811
|
}
|
|
816
|
-
function
|
|
817
|
-
return t === "bottom-form" ?
|
|
812
|
+
function St(e, t) {
|
|
813
|
+
return t === "bottom-form" ? xt(e) : bt(e);
|
|
818
814
|
}
|
|
819
|
-
function
|
|
820
|
-
return t === "top-form" ?
|
|
815
|
+
function Ct(e, t) {
|
|
816
|
+
return t === "top-form" ? bt(e) : t === "bottom-form" && !vt(e) ? xt(e) : e;
|
|
821
817
|
}
|
|
822
|
-
function
|
|
823
|
-
let t =
|
|
824
|
-
return r || (r = document.createElement("div"), r.setAttribute("data-formie-errors", "true"),
|
|
818
|
+
function wt(e) {
|
|
819
|
+
let t = ht(e), n = St(e, t), r = n.querySelector("[data-formie-error-container], [data-formie-errors]");
|
|
820
|
+
return r || (r = document.createElement("div"), r.setAttribute("data-formie-errors", "true"), A(r, e, "errors")), r.setAttribute("data-formie-error-container", "true"), t === "bottom-form" ? n.append(r) : n.prepend(r), r;
|
|
825
821
|
}
|
|
826
|
-
function
|
|
822
|
+
function Tt(e, t) {
|
|
827
823
|
let n = t.querySelector("[data-formie-error-message-container], [data-formie-message][data-formie-message-error]");
|
|
828
|
-
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"),
|
|
824
|
+
return n || (n = document.createElement("div"), n.setAttribute("data-formie-error-message-container", "true"), t.appendChild(n)), n.setAttribute("data-formie-message", "true"), n.setAttribute("data-formie-message-error", "true"), A(n, e, "message", "messageError"), n.setAttribute("role", "alert"), Ie(n, Fe(Ne(e))), n;
|
|
829
825
|
}
|
|
830
|
-
function
|
|
831
|
-
let n = e.querySelector("[data-formie-success-container]"), r =
|
|
832
|
-
return n || (n = document.createElement("div"), n.setAttribute("data-formie-success-container", "true"),
|
|
826
|
+
function Et(e, t) {
|
|
827
|
+
let n = e.querySelector("[data-formie-success-container]"), r = Ct(e, t);
|
|
828
|
+
return n || (n = document.createElement("div"), n.setAttribute("data-formie-success-container", "true"), A(n, e, "successes")), t === "bottom-form" ? r.append(n) : r.prepend(n), n;
|
|
833
829
|
}
|
|
834
|
-
function
|
|
835
|
-
return
|
|
836
|
-
|
|
830
|
+
function Dt(e) {
|
|
831
|
+
return pt(e, (t) => {
|
|
832
|
+
A(t, e, "fieldErrors");
|
|
837
833
|
});
|
|
838
834
|
}
|
|
839
|
-
function
|
|
835
|
+
function Ot(e) {
|
|
840
836
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
841
837
|
let n = t, r = n.querySelector("[data-formie-field-errors]"), i = Array.from(n.querySelectorAll("[data-formie-field-error]")).map((e) => e.id).filter(Boolean);
|
|
842
|
-
|
|
838
|
+
k(n, e, "fieldLayoutError"), n.removeAttribute("data-formie-field-has-error"), n.querySelectorAll("[data-formie-field-error]").forEach((e) => {
|
|
843
839
|
e.remove();
|
|
844
840
|
}), r && !r.querySelector("[data-formie-field-error]") && (r.innerHTML = ""), n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
845
841
|
let n = t;
|
|
846
|
-
n.removeAttribute("aria-invalid"),
|
|
842
|
+
n.removeAttribute("aria-invalid"), k(n, e, "fieldControlError"), n.removeAttribute("data-formie-input-has-error"), ze(n, i);
|
|
847
843
|
});
|
|
848
|
-
}),
|
|
844
|
+
}), h(e);
|
|
849
845
|
}
|
|
850
|
-
function
|
|
846
|
+
function kt(e) {
|
|
851
847
|
e.querySelectorAll("[data-formie-error-container], [data-formie-errors]").forEach((t) => {
|
|
852
848
|
let n = t;
|
|
853
849
|
n.querySelectorAll("[data-formie-error]").forEach((e) => {
|
|
854
850
|
e.remove();
|
|
855
|
-
}),
|
|
851
|
+
}), k(n, e, "message", "messageError"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-error"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-error]") || (n.innerHTML = "");
|
|
856
852
|
});
|
|
857
853
|
}
|
|
858
|
-
function
|
|
859
|
-
|
|
854
|
+
function At(e) {
|
|
855
|
+
yt(e), e.querySelectorAll("[data-formie-message-success]:not([data-formie-success-container])").forEach((e) => {
|
|
860
856
|
e.remove();
|
|
861
857
|
}), e.querySelectorAll("[data-formie-success-container]").forEach((t) => {
|
|
862
858
|
let n = t;
|
|
863
859
|
n.querySelectorAll("[data-formie-success]").forEach((e) => {
|
|
864
860
|
e.remove();
|
|
865
|
-
}),
|
|
866
|
-
}),
|
|
861
|
+
}), k(n, e, "message", "messageSuccess"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-success"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-success]") || (n.innerHTML = "");
|
|
862
|
+
}), mt(e) === "message" && vt(e) || b(e, !1);
|
|
867
863
|
}
|
|
868
|
-
function
|
|
864
|
+
function jt(e) {
|
|
869
865
|
e.querySelectorAll("[aria-invalid=\"true\"]").forEach((e) => {
|
|
870
866
|
e.removeAttribute("aria-invalid");
|
|
871
867
|
});
|
|
872
868
|
}
|
|
873
|
-
function
|
|
874
|
-
let n =
|
|
869
|
+
function Mt(e, t) {
|
|
870
|
+
let n = Fe(Ne(e));
|
|
875
871
|
Object.entries(t).forEach(([t, r]) => {
|
|
876
872
|
let i = `fields[${t.split(".").join("][")}]`, a = e.querySelector(`[name="${CSS.escape(i)}"], [name="${CSS.escape(i + "[]")}"]`)?.closest("[data-formie-field-handle]") || e.querySelector(`[data-formie-field-handle="${CSS.escape(t)}"]`);
|
|
877
873
|
if (!a) return;
|
|
878
|
-
let o =
|
|
879
|
-
o.id = s,
|
|
874
|
+
let o = Dt(a), s = o.id && o.id.trim() ? o.id : `${t}-errors`;
|
|
875
|
+
o.id = s, Ie(o, n), A(a, e, "fieldLayoutError"), a.setAttribute("data-formie-field-has-error", "true"), r.forEach((t, n) => {
|
|
880
876
|
let r = document.createElement("div");
|
|
881
|
-
r.setAttribute("data-formie-field-error", "true"), r.id = `${s}-${n + 1}`,
|
|
877
|
+
r.setAttribute("data-formie-field-error", "true"), r.id = `${s}-${n + 1}`, A(r, e, "fieldError"), r.textContent = t, o.appendChild(r);
|
|
882
878
|
});
|
|
883
879
|
let c = o.querySelector("[data-formie-field-error]")?.id;
|
|
884
880
|
a.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
885
881
|
let n = t;
|
|
886
|
-
n.setAttribute("aria-invalid", "true"),
|
|
882
|
+
n.setAttribute("aria-invalid", "true"), A(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), c && P(n, c);
|
|
887
883
|
let r = a.querySelector("[data-formie-instructions]");
|
|
888
|
-
r?.id &&
|
|
884
|
+
r?.id && Le(n, r.id);
|
|
889
885
|
});
|
|
890
|
-
}),
|
|
886
|
+
}), h(e);
|
|
891
887
|
}
|
|
892
|
-
function
|
|
893
|
-
let n =
|
|
894
|
-
|
|
888
|
+
function Nt(e, t) {
|
|
889
|
+
let n = wt(e), r = Tt(e, n);
|
|
890
|
+
A(n, e, "errors"), t.forEach((t) => {
|
|
895
891
|
let n = document.createElement("div");
|
|
896
|
-
n.setAttribute("data-formie-error", "true"), n.setAttribute("role", "alert"),
|
|
892
|
+
n.setAttribute("data-formie-error", "true"), n.setAttribute("role", "alert"), A(n, e, "error"), n.innerHTML = t, r.appendChild(n);
|
|
897
893
|
});
|
|
898
894
|
}
|
|
899
|
-
function
|
|
895
|
+
function Pt(e) {
|
|
900
896
|
if (e.ok || e.keepSubmitLoading !== !0) return !1;
|
|
901
897
|
let t = e.payment?.status;
|
|
902
898
|
return t === "requiresAction" || t === "pending" || t === "unknown";
|
|
903
899
|
}
|
|
904
|
-
function
|
|
905
|
-
let n =
|
|
906
|
-
|
|
900
|
+
function Ft(e, t) {
|
|
901
|
+
let n = wt(e), r = Tt(e, n);
|
|
902
|
+
A(n, e, "errors");
|
|
907
903
|
let i = document.createElement("div");
|
|
908
|
-
i.setAttribute("data-formie-notice", "true"), i.setAttribute("role", "status"),
|
|
904
|
+
i.setAttribute("data-formie-notice", "true"), i.setAttribute("role", "status"), A(i, e, "message"), i.textContent = t, r.appendChild(i);
|
|
909
905
|
}
|
|
910
|
-
function
|
|
911
|
-
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" ||
|
|
906
|
+
function It(e, t) {
|
|
907
|
+
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" || mt(e) === "message" && gt(e) !== "";
|
|
912
908
|
}
|
|
913
|
-
function
|
|
914
|
-
let r =
|
|
909
|
+
function Lt(e, t, n = {}) {
|
|
910
|
+
let r = gt(e);
|
|
915
911
|
if (!r) return;
|
|
916
|
-
let i =
|
|
917
|
-
|
|
912
|
+
let i = Et(e, r);
|
|
913
|
+
A(i, e, "message", "messageSuccess"), i.setAttribute("data-formie-message", "true"), i.setAttribute("data-formie-message-success", "true"), i.setAttribute("role", "status"), i.setAttribute("aria-live", "polite"), i.setAttribute("aria-atomic", "true");
|
|
918
914
|
let a = document.createElement("div");
|
|
919
|
-
a.setAttribute("data-formie-success", "true"),
|
|
920
|
-
let o =
|
|
921
|
-
|
|
915
|
+
a.setAttribute("data-formie-success", "true"), A(a, e, "success"), a.innerHTML = t, i.appendChild(a), n.hideForm !== !1 && vt(e) && b(e, !0);
|
|
916
|
+
let o = e.dataset.formieScrollToTop?.trim().toLowerCase();
|
|
917
|
+
o !== void 0 && [
|
|
918
|
+
"",
|
|
919
|
+
"true",
|
|
920
|
+
"1"
|
|
921
|
+
].includes(o) && i.scrollIntoView({
|
|
922
|
+
behavior: "smooth",
|
|
923
|
+
block: "start"
|
|
924
|
+
});
|
|
925
|
+
let s = _t(e);
|
|
926
|
+
if (s !== null) {
|
|
922
927
|
let t = window.setTimeout(() => {
|
|
923
|
-
|
|
924
|
-
},
|
|
925
|
-
|
|
928
|
+
R.delete(e), At(e);
|
|
929
|
+
}, s);
|
|
930
|
+
R.set(e, t);
|
|
926
931
|
}
|
|
927
932
|
}
|
|
928
933
|
function z(e, t) {
|
|
929
|
-
if (
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
934
|
+
if (Ot(e), kt(e), At(e), jt(e), t.ok) {
|
|
935
|
+
let n = t.meta?.summaryTokens;
|
|
936
|
+
n && typeof n == "object" && e.querySelectorAll("[data-formie-field-uid]").forEach((e) => {
|
|
937
|
+
let t = n[e.dataset.formieFieldUid || ""];
|
|
938
|
+
typeof t == "string" && t && e.querySelector("[data-formie-summary-container]")?.setAttribute("data-formie-summary-token", t);
|
|
939
|
+
}), It(e, t) && Lt(e, t.message || "", { hideForm: t.action !== "save" });
|
|
940
|
+
} else if (!t.ok) {
|
|
941
|
+
if (Pt(t)) {
|
|
935
942
|
let n = String(t.payment?.message || "").trim();
|
|
936
|
-
n &&
|
|
943
|
+
n && Ft(e, n);
|
|
937
944
|
return;
|
|
938
945
|
}
|
|
939
|
-
t.fieldErrors &&
|
|
946
|
+
t.fieldErrors && Mt(e, t.fieldErrors), t.formErrors?.length ? Nt(e, t.formErrors) : !t.fieldErrors && t.message && Nt(e, [t.message]), F(e);
|
|
940
947
|
}
|
|
941
948
|
}
|
|
942
949
|
//#endregion
|
|
943
950
|
//#region src/js/core/submit-flow.ts
|
|
944
|
-
var
|
|
945
|
-
function
|
|
951
|
+
var Rt = O("general", "submit-flow");
|
|
952
|
+
function zt(e) {
|
|
946
953
|
return !(!e.ok && e.stage === "validate");
|
|
947
954
|
}
|
|
948
|
-
function
|
|
955
|
+
function Bt(e) {
|
|
949
956
|
return e ? !!(e.keepSubmitLoading === !0 || e.ok && e.redirect?.url && e.redirect.target !== "new-tab") : !1;
|
|
950
957
|
}
|
|
951
|
-
function
|
|
952
|
-
|
|
958
|
+
function Vt(e) {
|
|
959
|
+
Ot(e), kt(e), At(e), jt(e);
|
|
953
960
|
}
|
|
954
|
-
async function
|
|
961
|
+
async function Ht(e) {
|
|
955
962
|
let { id: t, target: n, form: r, bus: i, validator: a, validateOnSubmit: o, action: s, submitter: c, waitForSubmitDelay: l, onRefreshTokensAfterSubmit: u, dispatchSubmitResult: d } = e;
|
|
956
|
-
|
|
957
|
-
let
|
|
963
|
+
Vt(r), C(r, c || null);
|
|
964
|
+
let p = {
|
|
958
965
|
ok: !1,
|
|
959
966
|
code: "SUBMIT_ERROR",
|
|
960
967
|
message: "Submission failed.",
|
|
961
968
|
formErrors: ["Submission failed."]
|
|
962
969
|
};
|
|
963
970
|
try {
|
|
964
|
-
await l(r),
|
|
971
|
+
await l(r), p = await dt(r, s, i, {
|
|
965
972
|
validator: a,
|
|
966
973
|
validateOnSubmit: o
|
|
967
|
-
}), z(r,
|
|
974
|
+
}), z(r, p), d(p), v(r, p, s), zt(p) && await u(p);
|
|
968
975
|
} catch (e) {
|
|
969
|
-
|
|
976
|
+
p = {
|
|
970
977
|
ok: !1,
|
|
971
978
|
code: "SUBMIT_ERROR",
|
|
972
979
|
message: e instanceof Error ? e.message : "Submission failed.",
|
|
973
980
|
formErrors: [e instanceof Error ? e.message : "Submission failed."]
|
|
974
|
-
}, z(r,
|
|
981
|
+
}, z(r, p), d(p), Rt.warn("Submit failed with exception.", {
|
|
975
982
|
id: t,
|
|
976
983
|
action: s,
|
|
977
984
|
target: n,
|
|
978
985
|
error: e instanceof Error ? e.message : e
|
|
979
986
|
});
|
|
980
987
|
} finally {
|
|
981
|
-
|
|
988
|
+
Bt(p) || f(r);
|
|
982
989
|
}
|
|
983
|
-
return
|
|
990
|
+
return p;
|
|
984
991
|
}
|
|
985
992
|
//#endregion
|
|
986
993
|
//#region src/js/events/event-bus.ts
|
|
987
|
-
var
|
|
994
|
+
var Ut = class {
|
|
988
995
|
listeners = /* @__PURE__ */ new Map();
|
|
989
996
|
on(e, t) {
|
|
990
997
|
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e)?.add(t), () => {
|
|
@@ -1025,11 +1032,7 @@ var zt = class {
|
|
|
1025
1032
|
failed: []
|
|
1026
1033
|
};
|
|
1027
1034
|
return !n || n.size === 0 || (await Promise.allSettled(Array.from(n).map(async (e) => e(t)))).forEach((e, t) => {
|
|
1028
|
-
|
|
1029
|
-
r.succeeded += 1;
|
|
1030
|
-
return;
|
|
1031
|
-
}
|
|
1032
|
-
r.failed.push({
|
|
1035
|
+
e.status === "fulfilled" ? r.succeeded += 1 : r.failed.push({
|
|
1033
1036
|
index: t,
|
|
1034
1037
|
error: e.reason
|
|
1035
1038
|
});
|
|
@@ -1064,66 +1067,66 @@ var zt = class {
|
|
|
1064
1067
|
getAll() {
|
|
1065
1068
|
return Array.from(this.modules.values());
|
|
1066
1069
|
}
|
|
1067
|
-
},
|
|
1068
|
-
"address-finder": () => import("./chunks/address-finder-
|
|
1069
|
-
"google-address": () => import("./chunks/google-address-
|
|
1070
|
-
loqate: () => import("./chunks/loqate-
|
|
1071
|
-
"place-kit": () => import("./chunks/place-kit-
|
|
1072
|
-
},
|
|
1073
|
-
"captcha-eu": () => import("./chunks/captcha-eu-
|
|
1074
|
-
"friendly-captcha-v1": () => import("./chunks/friendly-captcha-v1-
|
|
1075
|
-
"friendly-captcha-v2": () => import("./chunks/friendly-captcha-v2-
|
|
1076
|
-
hcaptcha: () => import("./chunks/hcaptcha-
|
|
1077
|
-
"recaptcha-enterprise": () => import("./chunks/recaptcha-enterprise-
|
|
1078
|
-
"recaptcha-v2-checkbox": () => import("./chunks/recaptcha-v2-checkbox-
|
|
1079
|
-
"recaptcha-v2-invisible": () => import("./chunks/recaptcha-v2-invisible-
|
|
1080
|
-
"recaptcha-v3": () => import("./chunks/recaptcha-v3-
|
|
1081
|
-
snaptcha: () => import("./chunks/snaptcha-
|
|
1082
|
-
turnstile: () => import("./chunks/turnstile-
|
|
1083
|
-
},
|
|
1084
|
-
calculations: () => import("./chunks/calculations-
|
|
1085
|
-
"checkbox-radio": () => import("./chunks/checkbox-radio-
|
|
1086
|
-
combobox: () => import("./chunks/combobox-
|
|
1087
|
-
conditions: () => import("./chunks/conditions-
|
|
1088
|
-
"custom-google-maps": () => import("./chunks/custom-google-maps-
|
|
1089
|
-
"custom-link": () => import("./chunks/custom-link-
|
|
1090
|
-
"custom-maps": () => import("./chunks/custom-maps-
|
|
1091
|
-
"date-picker": () => import("./chunks/date-picker-
|
|
1092
|
-
"file-upload": () => import("./chunks/file-upload-
|
|
1093
|
-
"upload-manager": () => import("./chunks/upload-manager-
|
|
1094
|
-
hidden: () => import("./chunks/hidden-
|
|
1095
|
-
"phone-country": () => import("./chunks/phone-country-
|
|
1096
|
-
"password-validation": () => import("./chunks/password-validation-
|
|
1097
|
-
"address-country": () => import("./chunks/address-country-
|
|
1098
|
-
"address-state": () => import("./chunks/address-state-
|
|
1099
|
-
repeater: () => import("./chunks/repeater-
|
|
1100
|
-
"rich-text": () => import("./chunks/rich-text-
|
|
1101
|
-
signature: () => import("./chunks/signature-
|
|
1102
|
-
summary: () => import("./chunks/summary-
|
|
1103
|
-
"survey-likert": () => import("./chunks/survey-likert-
|
|
1104
|
-
"survey-rank": () => import("./chunks/survey-rank-
|
|
1105
|
-
"survey-rating": () => import("./chunks/survey-rating-
|
|
1106
|
-
table: () => import("./chunks/table-
|
|
1107
|
-
"text-limit": () => import("./chunks/text-limit-
|
|
1108
|
-
},
|
|
1109
|
-
bpoint: () => import("./chunks/bpoint-
|
|
1110
|
-
eway: () => import("./chunks/eway-
|
|
1111
|
-
"go-cardless": () => import("./chunks/go-cardless-
|
|
1112
|
-
mollie: () => import("./chunks/mollie-
|
|
1113
|
-
moneris: () => import("./chunks/moneris-
|
|
1114
|
-
opayo: () => import("./chunks/opayo-
|
|
1115
|
-
paddle: () => import("./chunks/paddle-
|
|
1116
|
-
paypal: () => import("./chunks/paypal-
|
|
1117
|
-
payway: () => import("./chunks/payway-
|
|
1118
|
-
square: () => import("./chunks/square-
|
|
1119
|
-
stripe: () => import("./chunks/stripe-
|
|
1120
|
-
},
|
|
1121
|
-
...
|
|
1122
|
-
...
|
|
1123
|
-
...
|
|
1124
|
-
...
|
|
1070
|
+
}, Wt = new B(), Gt = {
|
|
1071
|
+
"address-finder": () => import("./chunks/address-finder-QK1m1eyv.js").then((e) => e.addressFinderModule),
|
|
1072
|
+
"google-address": () => import("./chunks/google-address-DQR6rsbh.js").then((e) => e.googleAddressModule),
|
|
1073
|
+
loqate: () => import("./chunks/loqate-ZZClcacr.js").then((e) => e.loqateModule),
|
|
1074
|
+
"place-kit": () => import("./chunks/place-kit-BKk8xDXf.js").then((e) => e.placeKitModule)
|
|
1075
|
+
}, Kt = {
|
|
1076
|
+
"captcha-eu": () => import("./chunks/captcha-eu-eU_M6snp.js").then((e) => e.captchaEuModule),
|
|
1077
|
+
"friendly-captcha-v1": () => import("./chunks/friendly-captcha-v1-C_cF1WD2.js").then((e) => e.friendlyCaptchaV1Module),
|
|
1078
|
+
"friendly-captcha-v2": () => import("./chunks/friendly-captcha-v2-BenESH-n.js").then((e) => e.friendlyCaptchaV2Module),
|
|
1079
|
+
hcaptcha: () => import("./chunks/hcaptcha-COilLmRT.js").then((e) => e.hcaptchaModule),
|
|
1080
|
+
"recaptcha-enterprise": () => import("./chunks/recaptcha-enterprise-Cx6HUpMa.js").then((e) => e.recaptchaEnterpriseModule),
|
|
1081
|
+
"recaptcha-v2-checkbox": () => import("./chunks/recaptcha-v2-checkbox-DQ9BJzcv.js").then((e) => e.recaptchaV2CheckboxModule),
|
|
1082
|
+
"recaptcha-v2-invisible": () => import("./chunks/recaptcha-v2-invisible-BP0T8Pan.js").then((e) => e.recaptchaV2InvisibleModule),
|
|
1083
|
+
"recaptcha-v3": () => import("./chunks/recaptcha-v3-DKMGQ27K.js").then((e) => e.recaptchaV3Module),
|
|
1084
|
+
snaptcha: () => import("./chunks/snaptcha-P3EoSQud.js").then((e) => e.snaptchaModule),
|
|
1085
|
+
turnstile: () => import("./chunks/turnstile-Sp4ubowK.js").then((e) => e.turnstileModule)
|
|
1086
|
+
}, qt = {
|
|
1087
|
+
calculations: () => import("./chunks/calculations-DeEmdUDq.js").then((e) => e.calculationsModule),
|
|
1088
|
+
"checkbox-radio": () => import("./chunks/checkbox-radio-CSXo6svm.js").then((e) => e.checkboxRadioModule),
|
|
1089
|
+
combobox: () => import("./chunks/combobox-CJh2DoSO.js").then((e) => e.comboboxModule),
|
|
1090
|
+
conditions: () => import("./chunks/conditions-Dz3068K0.js").then((e) => e.conditionsModule),
|
|
1091
|
+
"custom-google-maps": () => import("./chunks/custom-google-maps-rNm5VFbb.js").then((e) => e.customGoogleMapsModule),
|
|
1092
|
+
"custom-link": () => import("./chunks/custom-link-CLqFCssQ.js").then((e) => e.customLinkModule),
|
|
1093
|
+
"custom-maps": () => import("./chunks/custom-maps-DgjYQDLj.js").then((e) => e.customMapsModule),
|
|
1094
|
+
"date-picker": () => import("./chunks/date-picker-BVJxJVYT.js").then((e) => e.datePickerModule),
|
|
1095
|
+
"file-upload": () => import("./chunks/file-upload-vEUr_EuP.js").then((e) => e.fileUploadModule),
|
|
1096
|
+
"upload-manager": () => import("./chunks/upload-manager-Ccg3d_4I.js").then((e) => e.uploadManagerModule),
|
|
1097
|
+
hidden: () => import("./chunks/hidden-Bc2TpcgF.js").then((e) => e.hiddenModule),
|
|
1098
|
+
"phone-country": () => import("./chunks/phone-country-Bx9EG50h.js").then((e) => e.phoneCountryModule),
|
|
1099
|
+
"password-validation": () => import("./chunks/password-validation-HGOU9kf3.js").then((e) => e.passwordValidationModule),
|
|
1100
|
+
"address-country": () => import("./chunks/address-country-DLJF-OkC.js").then((e) => e.addressCountryModule),
|
|
1101
|
+
"address-state": () => import("./chunks/address-state-CHKit8AW.js").then((e) => e.addressStateModule),
|
|
1102
|
+
repeater: () => import("./chunks/repeater-BR0RUvTs.js").then((e) => e.repeaterModule),
|
|
1103
|
+
"rich-text": () => import("./chunks/rich-text-H2A6cm1t.js").then((e) => e.richTextModule),
|
|
1104
|
+
signature: () => import("./chunks/signature-CfKA_poI.js").then((e) => e.signatureModule),
|
|
1105
|
+
summary: () => import("./chunks/summary-B3CAebLV.js").then((e) => e.summaryModule),
|
|
1106
|
+
"survey-likert": () => import("./chunks/survey-likert-CEtUceag.js").then((e) => e.surveyLikertModule),
|
|
1107
|
+
"survey-rank": () => import("./chunks/survey-rank-Dtt97y6s.js").then((e) => e.surveyRankModule),
|
|
1108
|
+
"survey-rating": () => import("./chunks/survey-rating-mlDMI0uq.js").then((e) => e.surveyRatingModule),
|
|
1109
|
+
table: () => import("./chunks/table-0k6Md0IO.js").then((e) => e.tableModule),
|
|
1110
|
+
"text-limit": () => import("./chunks/text-limit-CTVML6s7.js").then((e) => e.textLimitModule)
|
|
1111
|
+
}, Jt = {
|
|
1112
|
+
bpoint: () => import("./chunks/bpoint-GvYfyPjD.js").then((e) => e.bpointModule),
|
|
1113
|
+
eway: () => import("./chunks/eway-BZuTBAUW.js").then((e) => e.ewayModule),
|
|
1114
|
+
"go-cardless": () => import("./chunks/go-cardless-DWZeB0Bq.js").then((e) => e.goCardlessModule),
|
|
1115
|
+
mollie: () => import("./chunks/mollie-8OMXIYa8.js").then((e) => e.mollieModule),
|
|
1116
|
+
moneris: () => import("./chunks/moneris-qYHJ9EFy.js").then((e) => e.monerisModule),
|
|
1117
|
+
opayo: () => import("./chunks/opayo-DlWPEnla.js").then((e) => e.opayoModule),
|
|
1118
|
+
paddle: () => import("./chunks/paddle-CArfWih0.js").then((e) => e.paddleModule),
|
|
1119
|
+
paypal: () => import("./chunks/paypal-BcaMCMGY.js").then((e) => e.paypalModule),
|
|
1120
|
+
payway: () => import("./chunks/payway-vxC7_bfR.js").then((e) => e.paywayModule),
|
|
1121
|
+
square: () => import("./chunks/square-Dyz0p_GU.js").then((e) => e.squareModule),
|
|
1122
|
+
stripe: () => import("./chunks/stripe-Bfd_jp_k.js").then((e) => e.stripeModule)
|
|
1123
|
+
}, Yt = {
|
|
1124
|
+
...qt,
|
|
1125
|
+
...Gt,
|
|
1126
|
+
...Kt,
|
|
1127
|
+
...Jt
|
|
1125
1128
|
}, V = /* @__PURE__ */ new Map();
|
|
1126
|
-
function
|
|
1129
|
+
function Xt(e) {
|
|
1127
1130
|
if (e instanceof Error) return {
|
|
1128
1131
|
name: e.name || "Error",
|
|
1129
1132
|
message: e.message || "No error message was provided.",
|
|
@@ -1145,7 +1148,7 @@ function Kt(e) {
|
|
|
1145
1148
|
};
|
|
1146
1149
|
}
|
|
1147
1150
|
}
|
|
1148
|
-
function
|
|
1151
|
+
function Zt(e, t, n) {
|
|
1149
1152
|
let r = [...t].filter((e) => e.required), i = [
|
|
1150
1153
|
"Formie browser module diagnostics",
|
|
1151
1154
|
`Surface: ${e}`,
|
|
@@ -1156,7 +1159,7 @@ function qt(e, t, n) {
|
|
|
1156
1159
|
i.push("", `Failure ${r + 1}`, `Module: ${t.moduleId}`, `Key: ${t.key}`, `Code: ${t.code}`), e === "cp-edit" && a && (i.push(`Error: ${a.name}: ${a.message}`), a.stack && i.push("Stack:", a.stack));
|
|
1157
1160
|
}), i.join("\n");
|
|
1158
1161
|
}
|
|
1159
|
-
async function
|
|
1162
|
+
async function Qt(e) {
|
|
1160
1163
|
if (navigator.clipboard?.writeText) {
|
|
1161
1164
|
await navigator.clipboard.writeText(e);
|
|
1162
1165
|
return;
|
|
@@ -1169,10 +1172,10 @@ async function Jt(e) {
|
|
|
1169
1172
|
t.remove();
|
|
1170
1173
|
}
|
|
1171
1174
|
}
|
|
1172
|
-
async function
|
|
1175
|
+
async function $t(e, t) {
|
|
1173
1176
|
let n = t.get(e);
|
|
1174
1177
|
if (n) return n;
|
|
1175
|
-
let r = e.startsWith("formie:") && Object.prototype.hasOwnProperty.call(
|
|
1178
|
+
let r = e.startsWith("formie:") && Object.prototype.hasOwnProperty.call(Yt, e.slice(7)) ? Yt[e.slice(7)] : void 0;
|
|
1176
1179
|
if (!r) throw Error(`Browser module ${e} is not registered.`);
|
|
1177
1180
|
V.has(e) || V.set(e, r().catch((t) => {
|
|
1178
1181
|
throw V.delete(e), t;
|
|
@@ -1181,14 +1184,14 @@ async function Yt(e, t) {
|
|
|
1181
1184
|
if (i.moduleId !== e) throw Error(`Module definition does not match ${e}.`);
|
|
1182
1185
|
return t.register(i), i;
|
|
1183
1186
|
}
|
|
1184
|
-
function
|
|
1187
|
+
function en(e, t, n) {
|
|
1185
1188
|
return [...new Set(e.targets.flatMap((e) => {
|
|
1186
1189
|
if (e.type === "form") return [n || t];
|
|
1187
1190
|
let r = e.type === "selector" ? e.selector : e.type === "field" ? `[data-formie-field-uid="${CSS.escape(e.uid)}"]` : e.type === "page" ? `[data-formie-page-id="${CSS.escape(e.id)}"]` : `[data-formie-action="${CSS.escape(e.action)}"]`;
|
|
1188
1191
|
return [...t.matches(r) ? [t] : [], ...t.querySelectorAll(r)];
|
|
1189
1192
|
}))].filter((e) => !e.closest("[hidden], [data-formie-hidden=\"true\"], [data-formie-conditionally-hidden], [data-formie-page-hidden]"));
|
|
1190
1193
|
}
|
|
1191
|
-
async function
|
|
1194
|
+
async function tn(e, t) {
|
|
1192
1195
|
n(e);
|
|
1193
1196
|
let r = e.surface;
|
|
1194
1197
|
if (t.matchContext.surface !== r || t.setupContext.surface !== r) throw Error(`Browser module manifest surface ${r} cannot mount as ${t.matchContext.surface}.`);
|
|
@@ -1201,7 +1204,7 @@ async function Zt(e, t) {
|
|
|
1201
1204
|
code: "MODULE_UNAVAILABLE",
|
|
1202
1205
|
message: "A form feature could not start. Reload the page or contact the site administrator."
|
|
1203
1206
|
};
|
|
1204
|
-
s.set(e.key, i), c.set(e.key,
|
|
1207
|
+
s.set(e.key, i), c.set(e.key, Xt(n)), console.error("[formie] Browser module failure", i, n), await t.setupContext.emit("formie:browser:module:error", i);
|
|
1205
1208
|
}, m = async (e) => {
|
|
1206
1209
|
try {
|
|
1207
1210
|
await e.destroy();
|
|
@@ -1243,7 +1246,7 @@ async function Zt(e, t) {
|
|
|
1243
1246
|
let d = document.createElement("span");
|
|
1244
1247
|
d.className = "formie-module-error__copy-status", d.setAttribute("role", "status"), d.setAttribute("aria-live", "polite"), u.addEventListener("click", async () => {
|
|
1245
1248
|
try {
|
|
1246
|
-
await
|
|
1249
|
+
await Qt(n.textContent || ""), d.textContent = "Details copied.";
|
|
1247
1250
|
} catch {
|
|
1248
1251
|
d.textContent = "Copy failed. Select the details above and copy them manually.";
|
|
1249
1252
|
let e = document.createRange();
|
|
@@ -1253,7 +1256,7 @@ async function Zt(e, t) {
|
|
|
1253
1256
|
}
|
|
1254
1257
|
e.dataset.formieModuleError = "true", i !== a && a.contains(i) ? i.before(e) : a.prepend(e);
|
|
1255
1258
|
}
|
|
1256
|
-
let t = e.querySelector("[data-formie-module-error-details]"), n =
|
|
1259
|
+
let t = e.querySelector("[data-formie-module-error-details]"), n = Zt(r, s.values(), c);
|
|
1257
1260
|
t && t.textContent !== n && (t.textContent = n);
|
|
1258
1261
|
}, _ = (e) => {
|
|
1259
1262
|
h() && (e.preventDefault(), e.stopImmediatePropagation(), g());
|
|
@@ -1272,7 +1275,7 @@ async function Zt(e, t) {
|
|
|
1272
1275
|
});
|
|
1273
1276
|
let d;
|
|
1274
1277
|
try {
|
|
1275
|
-
d =
|
|
1278
|
+
d = en(n, i, a);
|
|
1276
1279
|
} catch (e) {
|
|
1277
1280
|
s.has(n.key) || await p(n, e);
|
|
1278
1281
|
continue;
|
|
@@ -1282,7 +1285,7 @@ async function Zt(e, t) {
|
|
|
1282
1285
|
for (let [e, t] of Array.from(f.entries()).reverse()) d.includes(e) || (await m(t.instance), f.delete(e), l.splice(l.indexOf(t.instance), 1));
|
|
1283
1286
|
let h;
|
|
1284
1287
|
try {
|
|
1285
|
-
h = await
|
|
1288
|
+
h = await $t(n.moduleId, t.registry);
|
|
1286
1289
|
} catch (e) {
|
|
1287
1290
|
s.has(n.key) || await p(n, e);
|
|
1288
1291
|
continue;
|
|
@@ -1405,17 +1408,8 @@ async function Zt(e, t) {
|
|
|
1405
1408
|
};
|
|
1406
1409
|
}
|
|
1407
1410
|
//#endregion
|
|
1408
|
-
//#region src/js/utils/form-started-at.ts
|
|
1409
|
-
var Qt = "formie:formStartedAt:";
|
|
1410
|
-
function $t(e) {
|
|
1411
|
-
let t = e.querySelector("input[name=\"formStartedAt\"]");
|
|
1412
|
-
if (!t) return;
|
|
1413
|
-
let n = e.querySelector("input[name=\"renderId\"]")?.value?.trim() ?? "", r = n ? `${Qt}${n}` : null, i = r ? sessionStorage.getItem(r) : null;
|
|
1414
|
-
i || (i = String(Date.now()), r && sessionStorage.setItem(r, i)), t.value = i;
|
|
1415
|
-
}
|
|
1416
|
-
//#endregion
|
|
1417
1411
|
//#region src/js/utils/unload-warning.ts
|
|
1418
|
-
var
|
|
1412
|
+
var nn = /* @__PURE__ */ new Set([
|
|
1419
1413
|
"action",
|
|
1420
1414
|
"redirect",
|
|
1421
1415
|
"requestToken",
|
|
@@ -1428,63 +1422,78 @@ var en = /* @__PURE__ */ new Set([
|
|
|
1428
1422
|
"draftContext",
|
|
1429
1423
|
"progressId"
|
|
1430
1424
|
]);
|
|
1431
|
-
function
|
|
1425
|
+
function rn(e) {
|
|
1426
|
+
let t = /* @__PURE__ */ new Set(), n = !0;
|
|
1427
|
+
return g(e, "formie:unload-warning:collect-exclusions", {
|
|
1428
|
+
form: e,
|
|
1429
|
+
exclude: (...e) => {
|
|
1430
|
+
n && e.forEach((e) => {
|
|
1431
|
+
typeof e == "string" && e !== "" && t.add(e);
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
}), n = !1, t;
|
|
1435
|
+
}
|
|
1436
|
+
function H(e, t) {
|
|
1432
1437
|
if (e == null) return String(e);
|
|
1433
1438
|
if (typeof e == "string") return JSON.stringify(e);
|
|
1434
1439
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1435
1440
|
if (typeof e == "function") return "[function]";
|
|
1436
1441
|
if (typeof File < "u" && e instanceof File) return `[file:${e.name}:${e.size}:${e.type}]`;
|
|
1437
1442
|
if (typeof Blob < "u" && e instanceof Blob) return `[blob:${e.size}:${e.type}]`;
|
|
1438
|
-
if (Array.isArray(e)) return `[${e.map((e) =>
|
|
1443
|
+
if (Array.isArray(e)) return `[${e.map((e) => H(e, t)).join(",")}]`;
|
|
1439
1444
|
if (typeof e == "object") {
|
|
1440
1445
|
if (t.has(e)) return "[circular]";
|
|
1441
1446
|
t.add(e);
|
|
1442
|
-
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${
|
|
1447
|
+
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${H(n, t)}`);
|
|
1443
1448
|
return t.delete(e), `{${n.join(",")}}`;
|
|
1444
1449
|
}
|
|
1445
1450
|
return JSON.stringify(String(e));
|
|
1446
1451
|
}
|
|
1447
|
-
function
|
|
1448
|
-
return
|
|
1452
|
+
function an(e) {
|
|
1453
|
+
return H(e, /* @__PURE__ */ new WeakSet());
|
|
1449
1454
|
}
|
|
1450
|
-
function
|
|
1455
|
+
function on(e, t) {
|
|
1451
1456
|
if (!e) return !1;
|
|
1452
1457
|
let n = e.endsWith("[]") ? e.slice(0, -2) : e;
|
|
1453
|
-
return !
|
|
1454
|
-
}
|
|
1455
|
-
function
|
|
1456
|
-
return
|
|
1457
|
-
}
|
|
1458
|
-
function
|
|
1459
|
-
let n =
|
|
1460
|
-
|
|
1461
|
-
},
|
|
1462
|
-
|
|
1458
|
+
return !ie(n, t) && !nn.has(n);
|
|
1459
|
+
}
|
|
1460
|
+
function sn(e, t, n) {
|
|
1461
|
+
return an(e.filter(([e]) => !n.has(e) && on(String(e || ""), t)));
|
|
1462
|
+
}
|
|
1463
|
+
function cn(e, t = {}) {
|
|
1464
|
+
let n = [], r = !1, i = !1, a = !1, o = null, s = null, c = null, l = () => {
|
|
1465
|
+
o !== null && (window.cancelAnimationFrame(o), o = null), s !== null && (window.clearTimeout(s), s = null), c !== null && (window.clearTimeout(c), c = null);
|
|
1466
|
+
}, u = () => {
|
|
1467
|
+
if (!r) return !1;
|
|
1468
|
+
let t = rn(e);
|
|
1469
|
+
return a = sn(Array.from(new FormData(e).entries()), e, t) !== sn(n, e, t), a;
|
|
1463
1470
|
}, d = () => {
|
|
1464
|
-
|
|
1465
|
-
a = null, s = window.setTimeout(() => {
|
|
1466
|
-
s = null, u();
|
|
1467
|
-
}, 0);
|
|
1468
|
-
});
|
|
1471
|
+
i || (l(), n = Array.from(new FormData(e).entries()), r = !0, a = !1);
|
|
1469
1472
|
}, f = () => {
|
|
1470
|
-
|
|
1471
|
-
o = null,
|
|
1473
|
+
i || (l(), r = !1, o = window.requestAnimationFrame(() => {
|
|
1474
|
+
o = null, c = window.setTimeout(() => {
|
|
1475
|
+
c = null, d();
|
|
1476
|
+
}, 0);
|
|
1477
|
+
}));
|
|
1478
|
+
}, p = () => {
|
|
1479
|
+
s !== null && window.clearTimeout(s), s = window.setTimeout(() => {
|
|
1480
|
+
s = null, u();
|
|
1472
1481
|
}, 120);
|
|
1473
|
-
},
|
|
1474
|
-
(!t.shouldWarn || t.shouldWarn()) &&
|
|
1482
|
+
}, m = (e) => {
|
|
1483
|
+
(!t.shouldWarn || t.shouldWarn()) && u() && (e.preventDefault(), e.returnValue = "");
|
|
1475
1484
|
};
|
|
1476
|
-
return e.addEventListener("input",
|
|
1477
|
-
captureBaseline:
|
|
1478
|
-
scheduleBaselineCapture:
|
|
1479
|
-
refreshDirtyState:
|
|
1485
|
+
return e.addEventListener("input", p), e.addEventListener("change", p), window.addEventListener("beforeunload", m), d(), {
|
|
1486
|
+
captureBaseline: d,
|
|
1487
|
+
scheduleBaselineCapture: f,
|
|
1488
|
+
refreshDirtyState: u,
|
|
1480
1489
|
destroy: () => {
|
|
1481
|
-
|
|
1490
|
+
i = !0, r = !1, n = [], l(), e.removeEventListener("input", p), e.removeEventListener("change", p), window.removeEventListener("beforeunload", m);
|
|
1482
1491
|
}
|
|
1483
1492
|
};
|
|
1484
1493
|
}
|
|
1485
1494
|
//#endregion
|
|
1486
1495
|
//#region src/js/validation/rules/email.ts
|
|
1487
|
-
var
|
|
1496
|
+
var ln = {
|
|
1488
1497
|
rule: ({ input: e, getRule: n }) => {
|
|
1489
1498
|
let r = n("email");
|
|
1490
1499
|
return !r || t(e.value, {
|
|
@@ -1496,23 +1505,23 @@ var sn = {
|
|
|
1496
1505
|
};
|
|
1497
1506
|
//#endregion
|
|
1498
1507
|
//#region src/js/validation/rules/shared.ts
|
|
1499
|
-
function
|
|
1508
|
+
function un(e) {
|
|
1500
1509
|
return e?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() || "";
|
|
1501
1510
|
}
|
|
1502
|
-
function
|
|
1511
|
+
function dn(e) {
|
|
1503
1512
|
let t = e.getRule("match");
|
|
1504
1513
|
if (!t || t === !0 || typeof t != "object" || !e.field) return null;
|
|
1505
1514
|
let n = typeof t.fieldHandle == "string" ? t.fieldHandle.trim() : "";
|
|
1506
1515
|
if (!n) return null;
|
|
1507
1516
|
let r = e.form.querySelector(`[data-formie-field-handle="${n}"]`);
|
|
1508
|
-
return r ? Array.from(r.querySelectorAll(e.config.fieldsSelector)).find((e) => (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement) && !
|
|
1517
|
+
return r ? Array.from(r.querySelectorAll(e.config.fieldsSelector)).find((e) => (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement) && !j(e)) ?? null : null;
|
|
1509
1518
|
}
|
|
1510
1519
|
//#endregion
|
|
1511
1520
|
//#region src/js/validation/rules.ts
|
|
1512
|
-
var
|
|
1521
|
+
var fn = {
|
|
1513
1522
|
required: {
|
|
1514
1523
|
rule: ({ input: e, getRule: n }) => {
|
|
1515
|
-
if (!n("required") || e.type === "hidden") return !0;
|
|
1524
|
+
if (!n("required") || e.type === "hidden" || e.closest("[data-formie-field-handle]")?.getAttribute("data-formie-field-type") === "table") return !0;
|
|
1516
1525
|
if (e instanceof HTMLInputElement && e.type === "file") {
|
|
1517
1526
|
if (e.files?.length) return !0;
|
|
1518
1527
|
let t = e.closest("[data-formie-field-handle]"), n = e.name.replace(/\[\]$/, "");
|
|
@@ -1526,7 +1535,7 @@ var un = {
|
|
|
1526
1535
|
},
|
|
1527
1536
|
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 })
|
|
1528
1537
|
},
|
|
1529
|
-
email:
|
|
1538
|
+
email: ln,
|
|
1530
1539
|
url: {
|
|
1531
1540
|
rule: ({ input: e, getRule: n }) => {
|
|
1532
1541
|
let r = n("url");
|
|
@@ -1555,18 +1564,18 @@ var un = {
|
|
|
1555
1564
|
},
|
|
1556
1565
|
match: {
|
|
1557
1566
|
rule: (e) => {
|
|
1558
|
-
let n =
|
|
1567
|
+
let n = dn(e);
|
|
1559
1568
|
return !n || t(e.input.value, { type: "match" }, { comparison: n.value }) === null;
|
|
1560
1569
|
},
|
|
1561
1570
|
message: (e) => {
|
|
1562
|
-
let t =
|
|
1571
|
+
let t = dn(e)?.closest("[data-formie-field-handle]"), n = un(t);
|
|
1563
1572
|
return e.input.getAttribute("data-formie-validation-match-message") ?? e.t("{label} must match {value}.", {
|
|
1564
1573
|
label: e.label,
|
|
1565
1574
|
value: n
|
|
1566
1575
|
});
|
|
1567
1576
|
}
|
|
1568
1577
|
}
|
|
1569
|
-
},
|
|
1578
|
+
}, pn = {
|
|
1570
1579
|
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,})+$/,
|
|
1571
1580
|
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*)?$/,
|
|
1572
1581
|
number: /^(?:[-+]?[0-9]*[.,]?[0-9]+)$/,
|
|
@@ -1574,14 +1583,14 @@ var un = {
|
|
|
1574
1583
|
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))/,
|
|
1575
1584
|
time: /^(?:(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]))$/,
|
|
1576
1585
|
month: /^(?:(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])))$/
|
|
1577
|
-
},
|
|
1578
|
-
function
|
|
1579
|
-
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement);
|
|
1586
|
+
}, U = O("general", "validator");
|
|
1587
|
+
function W(e) {
|
|
1588
|
+
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement) && !!e.name;
|
|
1580
1589
|
}
|
|
1581
|
-
function
|
|
1590
|
+
function G(e) {
|
|
1582
1591
|
return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
1583
1592
|
}
|
|
1584
|
-
var
|
|
1593
|
+
var mn = class {
|
|
1585
1594
|
form;
|
|
1586
1595
|
errors = [];
|
|
1587
1596
|
validators = {};
|
|
@@ -1603,14 +1612,14 @@ var pn = class {
|
|
|
1603
1612
|
messagesClass: [],
|
|
1604
1613
|
messageClass: [],
|
|
1605
1614
|
fieldsSelector: "input:not([type=\"hidden\"]):not([type=\"submit\"]):not([type=\"button\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])",
|
|
1606
|
-
patterns:
|
|
1615
|
+
patterns: pn,
|
|
1607
1616
|
...t
|
|
1608
|
-
}, Object.entries(
|
|
1617
|
+
}, Object.entries(fn).forEach(([e, t]) => {
|
|
1609
1618
|
this.addValidator(e, t.rule, t.message);
|
|
1610
1619
|
}), this.init();
|
|
1611
1620
|
}
|
|
1612
1621
|
init() {
|
|
1613
|
-
|
|
1622
|
+
U.log("Initializing validator.", {
|
|
1614
1623
|
formId: this.form.id || null,
|
|
1615
1624
|
live: this.config.live
|
|
1616
1625
|
}), this.form.setAttribute("novalidate", "true"), this.inputs().forEach((e) => {
|
|
@@ -1618,9 +1627,9 @@ var pn = class {
|
|
|
1618
1627
|
}), this.config.live && this.addEventListeners(), this.emitEvent(document, o("ready"), { validator: this });
|
|
1619
1628
|
}
|
|
1620
1629
|
inputs(e = null) {
|
|
1621
|
-
if (
|
|
1630
|
+
if (W(e)) return j(e) ? [] : [e];
|
|
1622
1631
|
let t = e || this.form;
|
|
1623
|
-
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) =>
|
|
1632
|
+
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) => W(e) && !j(e));
|
|
1624
1633
|
}
|
|
1625
1634
|
getInputValue(e) {
|
|
1626
1635
|
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 ?? "";
|
|
@@ -1638,29 +1647,29 @@ var pn = class {
|
|
|
1638
1647
|
this.errors = [];
|
|
1639
1648
|
let n = /* @__PURE__ */ new Set();
|
|
1640
1649
|
return this.inputs(e).forEach((e) => {
|
|
1641
|
-
let r = !1;
|
|
1650
|
+
let r = !1, i = t.renderErrors !== !1 && this.shouldShowError(e);
|
|
1642
1651
|
if (!this.isVisible(e, t)) return;
|
|
1643
|
-
let
|
|
1644
|
-
if (
|
|
1645
|
-
if (n.has(
|
|
1646
|
-
n.add(
|
|
1652
|
+
let a = e.closest("[data-formie-field-handle]"), o = e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ? `${a?.getAttribute("data-formie-field-handle") || ""}:${e.name}` : null;
|
|
1653
|
+
if (o) {
|
|
1654
|
+
if (n.has(o)) return;
|
|
1655
|
+
n.add(o);
|
|
1647
1656
|
}
|
|
1648
|
-
|
|
1649
|
-
let
|
|
1657
|
+
i && this.removeError(e);
|
|
1658
|
+
let s = this.getValidatorCallbackOptions(e);
|
|
1650
1659
|
Object.entries(this.validators).forEach(([t, n]) => {
|
|
1651
|
-
if (!n.validate(
|
|
1652
|
-
let
|
|
1653
|
-
|
|
1660
|
+
if (!n.validate(s)) {
|
|
1661
|
+
let a = this.getErrorMessage(e, t, n, s);
|
|
1662
|
+
i && !r && this.showError(e, t, a), this.errors.push({
|
|
1654
1663
|
input: e,
|
|
1655
|
-
field:
|
|
1664
|
+
field: s.field,
|
|
1656
1665
|
validator: t,
|
|
1657
|
-
message:
|
|
1658
|
-
handle:
|
|
1666
|
+
message: a,
|
|
1667
|
+
handle: s.field?.getAttribute("data-formie-field-handle") || null,
|
|
1659
1668
|
result: !1
|
|
1660
1669
|
}), r = !0;
|
|
1661
1670
|
}
|
|
1662
|
-
}), !r &&
|
|
1663
|
-
}),
|
|
1671
|
+
}), !r && i && this.removeError(e);
|
|
1672
|
+
}), U.log("Validation pass complete.", {
|
|
1664
1673
|
errorCount: this.errors.length,
|
|
1665
1674
|
includeHiddenPages: t.includeHiddenPages === !0
|
|
1666
1675
|
}), this.errors;
|
|
@@ -1681,38 +1690,38 @@ var pn = class {
|
|
|
1681
1690
|
e.remove();
|
|
1682
1691
|
}), n && (n.innerHTML = ""), t.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
1683
1692
|
let t = e;
|
|
1684
|
-
t.removeAttribute("aria-invalid"), this.config.inputErrorClass.length && t.classList.remove(...this.config.inputErrorClass), t.removeAttribute("data-formie-input-has-error"),
|
|
1693
|
+
t.removeAttribute("aria-invalid"), this.config.inputErrorClass.length && t.classList.remove(...this.config.inputErrorClass), t.removeAttribute("data-formie-input-has-error"), ze(t, r);
|
|
1685
1694
|
});
|
|
1686
1695
|
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");
|
|
1687
|
-
this.emitEvent(e, o("clear-error"), { validator: this }),
|
|
1696
|
+
this.emitEvent(e, o("clear-error"), { validator: this }), h(this.form);
|
|
1688
1697
|
}
|
|
1689
1698
|
showError(e, t, n) {
|
|
1690
1699
|
let r = e.closest("[data-formie-field-handle]");
|
|
1691
1700
|
if (!r) return;
|
|
1692
1701
|
let i = r.querySelector("[data-formie-field-errors]");
|
|
1693
|
-
i ||=
|
|
1702
|
+
i ||= pt(r, (e) => {
|
|
1694
1703
|
this.config.messagesClass.length && e.classList.add(...this.config.messagesClass);
|
|
1695
1704
|
}), this.config.messagesClass.length && i.classList.add(...this.config.messagesClass), i.innerHTML = "";
|
|
1696
1705
|
let a = r.getAttribute("data-formie-field-handle") || "field";
|
|
1697
1706
|
i.id = i.id || `${e.id || `${this.form.id}-${a}`}-errors`;
|
|
1698
1707
|
let s = `${i.id}-1`;
|
|
1699
|
-
|
|
1708
|
+
Ie(i, Pe(this.config.errorAriaLive, this.submitted));
|
|
1700
1709
|
let c = document.createElement("div");
|
|
1701
1710
|
c.setAttribute("data-formie-field-error", "true"), c.setAttribute(`data-formie-field-error-${t}`, "true"), c.setAttribute("id", s), this.config.messageClass.length && c.classList.add(...this.config.messageClass), c.textContent = n, i.appendChild(c), r.setAttribute("data-formie-field-has-error", "true"), r.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
1702
1711
|
let t = e;
|
|
1703
|
-
|
|
1712
|
+
j(t) || (t.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && t.classList.add(...this.config.inputErrorClass), t.setAttribute("data-formie-input-has-error", "true"), P(t, s));
|
|
1704
1713
|
});
|
|
1705
1714
|
for (let e = r; e; e = e.parentElement?.closest("[data-formie-field-handle]")) this.config.fieldContainerErrorClass.length && e.classList.add(...this.config.fieldContainerErrorClass), e.setAttribute("data-formie-field-has-error", "true");
|
|
1706
1715
|
this.emitEvent(e, o("show-error"), {
|
|
1707
1716
|
validator: this,
|
|
1708
1717
|
validatorName: t,
|
|
1709
1718
|
errorMessage: n
|
|
1710
|
-
}),
|
|
1719
|
+
}), h(this.form);
|
|
1711
1720
|
}
|
|
1712
1721
|
getValidatorCallbackOptions(e) {
|
|
1713
1722
|
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"));
|
|
1714
1723
|
return {
|
|
1715
|
-
t:
|
|
1724
|
+
t: le,
|
|
1716
1725
|
input: e,
|
|
1717
1726
|
label: n,
|
|
1718
1727
|
field: t,
|
|
@@ -1723,7 +1732,7 @@ var pn = class {
|
|
|
1723
1732
|
};
|
|
1724
1733
|
}
|
|
1725
1734
|
getErrorMessage(e, t, n, r) {
|
|
1726
|
-
return (typeof n.errorMessage == "function" ? n.errorMessage(r) : n.errorMessage) ??
|
|
1735
|
+
return (typeof n.errorMessage == "function" ? n.errorMessage(r) : n.errorMessage) ?? le("{label} is invalid.", { label: r.label });
|
|
1727
1736
|
}
|
|
1728
1737
|
getErrors() {
|
|
1729
1738
|
return this.errors;
|
|
@@ -1746,7 +1755,7 @@ var pn = class {
|
|
|
1746
1755
|
try {
|
|
1747
1756
|
n = JSON.parse(e);
|
|
1748
1757
|
} catch {
|
|
1749
|
-
return
|
|
1758
|
+
return U.warn("Invalid validation rules payload.", { formId: this.form.id || null }), t;
|
|
1750
1759
|
}
|
|
1751
1760
|
return Array.isArray(n) && n.forEach((e) => {
|
|
1752
1761
|
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
@@ -1755,45 +1764,39 @@ var pn = class {
|
|
|
1755
1764
|
}), t;
|
|
1756
1765
|
}
|
|
1757
1766
|
destroy() {
|
|
1758
|
-
|
|
1767
|
+
U.log("Destroying validator.", { formId: this.form.id || null }), this.removeEventListeners(), this.form.removeAttribute("novalidate"), this.emitEvent(document, o("destroy"), { validator: this });
|
|
1759
1768
|
}
|
|
1760
1769
|
isVisible(e, t = {}) {
|
|
1761
1770
|
if (e.disabled || e.hasAttribute("data-formie-conditions-disabled") || e.closest("[data-formie-conditions-disabled]") || e.closest("[data-formie-conditionally-hidden]")) return !1;
|
|
1762
1771
|
if (e.closest("[data-formie-page-hidden]")) return !!t.includeHiddenPages;
|
|
1763
|
-
let n = e.closest("[data-formie-field-handle]")?.querySelector("[data-formie-rich-text]");
|
|
1764
|
-
if (
|
|
1772
|
+
let n = e.closest("[data-formie-field-handle]"), r = n?.querySelector("[data-formie-rich-text]");
|
|
1773
|
+
if (r instanceof HTMLElement) return G(r);
|
|
1765
1774
|
if (e instanceof HTMLSelectElement && e.hasAttribute("data-formie-combobox-input")) {
|
|
1766
1775
|
let t = e.nextElementSibling;
|
|
1767
|
-
if (t instanceof HTMLElement && t.classList.contains("formie-combobox")) return
|
|
1776
|
+
if (t instanceof HTMLElement && t.classList.contains("formie-combobox")) return G(t);
|
|
1768
1777
|
}
|
|
1769
|
-
return
|
|
1778
|
+
return e instanceof HTMLSelectElement && n instanceof HTMLElement ? G(e) || G(n) : G(e);
|
|
1770
1779
|
}
|
|
1771
1780
|
blurHandler(e) {
|
|
1772
|
-
e.target instanceof HTMLElement &&
|
|
1781
|
+
e.target instanceof HTMLElement && W(e.target) && !j(e.target) && e.target.form?.isSameNode(this.form) && (e instanceof CustomEvent || e.target instanceof HTMLInputElement && e.target.type === "file" || e.target instanceof HTMLInputElement && (e.target.type === "checkbox" || e.target.type === "radio") || (this.isDirty(e.target) && this.activated.add(e.target), this.shouldShowError(e.target) && this.validate(e.target)));
|
|
1773
1782
|
}
|
|
1774
1783
|
changeHandler(e) {
|
|
1775
|
-
|
|
1776
|
-
if (e.target instanceof HTMLSelectElement) {
|
|
1777
|
-
this.activated.add(e.target), this.validate(e.target);
|
|
1778
|
-
return;
|
|
1779
|
-
}
|
|
1780
|
-
e.target instanceof HTMLInputElement && (e.target.type === "file" || e.target.type === "checkbox" || e.target.type === "radio") && (this.activated.add(e.target), this.validate(e.target));
|
|
1781
|
-
}
|
|
1784
|
+
e.target instanceof HTMLElement && W(e.target) && !j(e.target) && e.target.form?.isSameNode(this.form) && (e instanceof CustomEvent || (e.target instanceof HTMLSelectElement || e.target instanceof HTMLInputElement && (e.target.type === "file" || e.target.type === "checkbox" || e.target.type === "radio")) && (this.activated.add(e.target), this.validate(e.target)));
|
|
1782
1785
|
}
|
|
1783
1786
|
inputHandler(e) {
|
|
1784
|
-
e.target instanceof HTMLElement &&
|
|
1787
|
+
e.target instanceof HTMLElement && W(e.target) && !j(e.target) && e.target.form?.isSameNode(this.form) && (e instanceof CustomEvent || e.target instanceof HTMLInputElement && (e.target.type === "checkbox" || e.target.type === "radio") || this.shouldShowError(e.target) && this.validate(e.target));
|
|
1785
1788
|
}
|
|
1786
1789
|
submit(e = null, { final: t = !1 } = {}) {
|
|
1787
|
-
return this.submitted = !0,
|
|
1790
|
+
return this.submitted = !0, U.log("Submit validation requested.", { final: t }), this.boundListeners || this.addEventListeners(), this.removeAllErrors(), this.validate(e, { includeHiddenPages: t });
|
|
1788
1791
|
}
|
|
1789
1792
|
resetLiveState() {
|
|
1790
1793
|
this.submitted = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.errors = [], this.removeAllErrors();
|
|
1791
1794
|
}
|
|
1792
1795
|
addEventListeners() {
|
|
1793
|
-
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,
|
|
1796
|
+
this.boundListeners || (this.form.addEventListener("blur", this.onBlur, !0), this.form.addEventListener("change", this.onChange, !1), this.form.addEventListener("input", this.onInput, !1), this.boundListeners = !0, U.log("Event listeners attached."));
|
|
1794
1797
|
}
|
|
1795
1798
|
removeEventListeners() {
|
|
1796
|
-
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1,
|
|
1799
|
+
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1, U.log("Event listeners removed.");
|
|
1797
1800
|
}
|
|
1798
1801
|
emitEvent(e, t, n = {}) {
|
|
1799
1802
|
e.dispatchEvent(new CustomEvent(t, {
|
|
@@ -1813,25 +1816,25 @@ var pn = class {
|
|
|
1813
1816
|
};
|
|
1814
1817
|
//#endregion
|
|
1815
1818
|
//#region src/js/validation/enter-key-guard.ts
|
|
1816
|
-
function
|
|
1819
|
+
function hn(e) {
|
|
1817
1820
|
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]");
|
|
1818
1821
|
}
|
|
1819
|
-
function
|
|
1822
|
+
function gn(e, t) {
|
|
1820
1823
|
let n = e.querySelectorAll(`[data-formie-action="${t}"]`);
|
|
1821
|
-
return Array.from(n).some((e) => !
|
|
1822
|
-
}
|
|
1823
|
-
function gn(e) {
|
|
1824
|
-
let { final: t } = g(e);
|
|
1825
|
-
return "submit";
|
|
1824
|
+
return Array.from(n).some((e) => !hn(e));
|
|
1826
1825
|
}
|
|
1827
1826
|
function _n(e) {
|
|
1828
|
-
|
|
1827
|
+
let { final: t } = m(e);
|
|
1828
|
+
return "submit";
|
|
1829
1829
|
}
|
|
1830
1830
|
function vn(e) {
|
|
1831
|
+
return !gn(e, _n(e));
|
|
1832
|
+
}
|
|
1833
|
+
function yn(e) {
|
|
1831
1834
|
let t = (t) => {
|
|
1832
1835
|
if (t.key !== "Enter" || t.defaultPrevented) return;
|
|
1833
1836
|
let n = t.target;
|
|
1834
|
-
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") ||
|
|
1837
|
+
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") || vn(e) && t.preventDefault());
|
|
1835
1838
|
};
|
|
1836
1839
|
return e.addEventListener("keydown", t, !0), () => {
|
|
1837
1840
|
e.removeEventListener("keydown", t, !0);
|
|
@@ -1839,16 +1842,16 @@ function vn(e) {
|
|
|
1839
1842
|
}
|
|
1840
1843
|
//#endregion
|
|
1841
1844
|
//#region src/js/core/create-formie-client.ts
|
|
1842
|
-
var
|
|
1843
|
-
function
|
|
1845
|
+
var K = "[data-formie]:not([data-formie-init=\"false\"]), [data-formie-form]:not([data-formie-init=\"false\"])", bn = 300, xn = "/actions/formie/server/forms/render", Sn = "/api", Cn = "/actions/formie/server/forms/refresh-tokens", wn = "/actions/formie/server/submissions/submit", Tn = "/actions/formie/server/submissions/set-page", En = "/actions/formie/server/submissions/clear-submission", Dn = "/actions/formie/file-upload/hydrate", q = O("general", "client"), On = /* @__PURE__ */ new Set();
|
|
1846
|
+
function J(e, t) {
|
|
1844
1847
|
if (e == null || e === "") return t;
|
|
1845
1848
|
let n = e.toLowerCase();
|
|
1846
1849
|
return n !== "false" && n !== "0" && n !== "off";
|
|
1847
1850
|
}
|
|
1848
|
-
function
|
|
1849
|
-
return e.formieRefreshTokens == null ? e.formieStaticCache != null &&
|
|
1851
|
+
function kn(e) {
|
|
1852
|
+
return e.formieRefreshTokens == null ? e.formieStaticCache != null && J(e.formieStaticCache, !0) : J(e.formieRefreshTokens, !0);
|
|
1850
1853
|
}
|
|
1851
|
-
function
|
|
1854
|
+
function Y(e) {
|
|
1852
1855
|
let t = e instanceof HTMLElement ? e.dataset : {};
|
|
1853
1856
|
return {
|
|
1854
1857
|
mode: "server-rendered",
|
|
@@ -1856,25 +1859,25 @@ function q(e) {
|
|
|
1856
1859
|
profile: t.formieRequestProfile,
|
|
1857
1860
|
formHandle: t.formieHandle,
|
|
1858
1861
|
endpoint: t.formieEndpoint,
|
|
1859
|
-
staticCache:
|
|
1860
|
-
autoVisible:
|
|
1861
|
-
compatibility:
|
|
1862
|
+
staticCache: kn(t),
|
|
1863
|
+
autoVisible: J(t.formieAutoVisible, !0),
|
|
1864
|
+
compatibility: J(t.formieCompatibility, !1)
|
|
1862
1865
|
};
|
|
1863
1866
|
}
|
|
1864
|
-
function
|
|
1867
|
+
function An(e) {
|
|
1865
1868
|
if (e && e !== "server-rendered") throw Error("@verbb/formie-browser enhances server-rendered HTML only. Use @verbb/formie-core for client-rendered forms.");
|
|
1866
1869
|
return "server-rendered";
|
|
1867
1870
|
}
|
|
1868
|
-
function
|
|
1871
|
+
function jn(e) {
|
|
1869
1872
|
return e || "rest";
|
|
1870
1873
|
}
|
|
1871
|
-
function
|
|
1874
|
+
function Mn(e) {
|
|
1872
1875
|
return e instanceof HTMLFormElement ? e : e.querySelector("form");
|
|
1873
1876
|
}
|
|
1874
|
-
function Mn(e, t) {
|
|
1875
|
-
Dn.has(e) || (Dn.add(e), G.warn(t));
|
|
1876
|
-
}
|
|
1877
1877
|
function Nn(e, t) {
|
|
1878
|
+
On.has(e) || (On.add(e), q.warn(t));
|
|
1879
|
+
}
|
|
1880
|
+
function Pn(e, t) {
|
|
1878
1881
|
if (!e) return e;
|
|
1879
1882
|
try {
|
|
1880
1883
|
return new URL(e).toString();
|
|
@@ -1886,21 +1889,21 @@ function Nn(e, t) {
|
|
|
1886
1889
|
return e;
|
|
1887
1890
|
}
|
|
1888
1891
|
}
|
|
1889
|
-
function
|
|
1892
|
+
function X(e, t) {
|
|
1890
1893
|
let n = (e || "").trim();
|
|
1891
|
-
return n ? n.includes(t) ? n :
|
|
1892
|
-
}
|
|
1893
|
-
function Pn(e, t) {
|
|
1894
|
-
return J(e.endpoint || t.dataset.formieEndpoint, bn);
|
|
1894
|
+
return n ? n.includes(t) ? n : Pn(t, n) : t;
|
|
1895
1895
|
}
|
|
1896
1896
|
function Fn(e, t) {
|
|
1897
|
-
|
|
1898
|
-
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n : Nn(xn, n) : xn;
|
|
1897
|
+
return X(e.endpoint || t.dataset.formieEndpoint, xn);
|
|
1899
1898
|
}
|
|
1900
1899
|
function In(e, t) {
|
|
1901
|
-
|
|
1900
|
+
let n = (e.endpoint || t.dataset.formieEndpoint || "").trim();
|
|
1901
|
+
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n : Pn(Sn, n) : Sn;
|
|
1902
1902
|
}
|
|
1903
1903
|
function Ln(e, t) {
|
|
1904
|
+
return X(t.dataset.formieRefreshTokensEndpoint || e.endpoint || t.dataset.formieEndpoint, Cn);
|
|
1905
|
+
}
|
|
1906
|
+
function Rn(e, t) {
|
|
1904
1907
|
if (!e) return t;
|
|
1905
1908
|
try {
|
|
1906
1909
|
let n = new URL(e, window.location.origin), r = new URL(t, window.location.origin);
|
|
@@ -1911,39 +1914,39 @@ function Ln(e, t) {
|
|
|
1911
1914
|
return t;
|
|
1912
1915
|
}
|
|
1913
1916
|
}
|
|
1914
|
-
function
|
|
1915
|
-
let r = n.endpoint || e.dataset.formieEndpoint, i =
|
|
1916
|
-
t.setAttribute("action",
|
|
1917
|
-
let t = e.getAttribute("href"), n =
|
|
1918
|
-
e.setAttribute("href",
|
|
1917
|
+
function zn(e, t, n) {
|
|
1918
|
+
let r = n.endpoint || e.dataset.formieEndpoint, i = X(r, wn), a = t.getAttribute("action");
|
|
1919
|
+
t.setAttribute("action", Rn(a, i)), t.querySelectorAll("[data-formie-tab-link]").forEach((e) => {
|
|
1920
|
+
let t = e.getAttribute("href"), n = X(r, Tn);
|
|
1921
|
+
e.setAttribute("href", Rn(t, n));
|
|
1919
1922
|
}), t.querySelectorAll("[data-formie-file-upload-hydrate-endpoint]").forEach((e) => {
|
|
1920
|
-
e.setAttribute("data-formie-file-upload-hydrate-endpoint",
|
|
1923
|
+
e.setAttribute("data-formie-file-upload-hydrate-endpoint", X(r, Dn));
|
|
1921
1924
|
});
|
|
1922
1925
|
}
|
|
1923
|
-
function
|
|
1926
|
+
function Bn(e) {
|
|
1924
1927
|
if (e == null) return !1;
|
|
1925
1928
|
let t = e.trim().toLowerCase();
|
|
1926
1929
|
return t === "true" || t === "1" || t === "";
|
|
1927
1930
|
}
|
|
1928
|
-
function
|
|
1929
|
-
return
|
|
1931
|
+
function Vn(e) {
|
|
1932
|
+
return J(e.dataset.formieAutomaticSubmissionState, !0);
|
|
1930
1933
|
}
|
|
1931
|
-
function
|
|
1932
|
-
return
|
|
1934
|
+
function Hn(e, t, n) {
|
|
1935
|
+
return X(n.dataset.formieClearSubmissionEndpoint || e.endpoint || t.dataset.formieEndpoint, En);
|
|
1933
1936
|
}
|
|
1934
|
-
function
|
|
1935
|
-
return
|
|
1937
|
+
function Un(e) {
|
|
1938
|
+
return Bn(e.dataset.formieUnloadWarning);
|
|
1936
1939
|
}
|
|
1937
|
-
function
|
|
1940
|
+
function Wn(e, t) {
|
|
1938
1941
|
e.setAttribute("data-formie-internal-navigation", t);
|
|
1939
1942
|
}
|
|
1940
|
-
function
|
|
1943
|
+
function Gn(e) {
|
|
1941
1944
|
e.removeAttribute("data-formie-internal-navigation");
|
|
1942
1945
|
}
|
|
1943
|
-
function
|
|
1946
|
+
function Kn(e) {
|
|
1944
1947
|
return e.getAttribute("data-formie-internal-navigation") !== null;
|
|
1945
1948
|
}
|
|
1946
|
-
function
|
|
1949
|
+
function qn(e, t) {
|
|
1947
1950
|
if (!e) return !1;
|
|
1948
1951
|
try {
|
|
1949
1952
|
return new URL(e, window.location.origin).searchParams.has(t);
|
|
@@ -1951,30 +1954,30 @@ function Gn(e, t) {
|
|
|
1951
1954
|
return !1;
|
|
1952
1955
|
}
|
|
1953
1956
|
}
|
|
1954
|
-
function
|
|
1955
|
-
return
|
|
1957
|
+
function Jn(e) {
|
|
1958
|
+
return qn(window.location.href, "resumeToken") || qn(e.getAttribute("action"), "resumeToken");
|
|
1956
1959
|
}
|
|
1957
|
-
function
|
|
1960
|
+
function Yn(e) {
|
|
1958
1961
|
return e instanceof MouseEvent ? e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey : !0;
|
|
1959
1962
|
}
|
|
1960
|
-
function
|
|
1963
|
+
function Xn(e, t = 0) {
|
|
1961
1964
|
if (!e) return t;
|
|
1962
1965
|
let n = Number.parseInt(e, 10);
|
|
1963
1966
|
return Number.isFinite(n) ? n : t;
|
|
1964
1967
|
}
|
|
1965
|
-
function
|
|
1966
|
-
return Math.max(0,
|
|
1968
|
+
function Zn(e) {
|
|
1969
|
+
return Math.max(0, Xn(e.dataset.formieSubmitDelay, bn));
|
|
1967
1970
|
}
|
|
1968
|
-
function
|
|
1969
|
-
return
|
|
1971
|
+
function Z(e) {
|
|
1972
|
+
return Bn(e.dataset.formieValidationOnSubmit);
|
|
1970
1973
|
}
|
|
1971
|
-
async function
|
|
1972
|
-
let t =
|
|
1973
|
-
|
|
1974
|
+
async function Qn(e) {
|
|
1975
|
+
let t = Zn(e);
|
|
1976
|
+
await new Promise((e) => {
|
|
1974
1977
|
window.setTimeout(e, t);
|
|
1975
1978
|
});
|
|
1976
1979
|
}
|
|
1977
|
-
function
|
|
1980
|
+
function $n(e, t) {
|
|
1978
1981
|
let n = e?.getAttribute(t)?.trim();
|
|
1979
1982
|
if (!n) return null;
|
|
1980
1983
|
try {
|
|
@@ -1984,29 +1987,29 @@ function Zn(e, t) {
|
|
|
1984
1987
|
return console.error(`[formie] Failed to parse ${t}.`, e), null;
|
|
1985
1988
|
}
|
|
1986
1989
|
}
|
|
1987
|
-
function
|
|
1990
|
+
function er(e, t) {
|
|
1988
1991
|
let n = t || (e instanceof HTMLFormElement ? e : null);
|
|
1989
1992
|
if (!n) return null;
|
|
1990
|
-
let r =
|
|
1993
|
+
let r = $n(n, "data-formie-modules"), i = $n(n, "data-formie-theme-classes") || $n(n, "data-formie-theme");
|
|
1991
1994
|
return !r && !i ? null : {
|
|
1992
1995
|
modules: r || void 0,
|
|
1993
1996
|
theme: i || void 0
|
|
1994
1997
|
};
|
|
1995
1998
|
}
|
|
1996
|
-
function
|
|
1999
|
+
function tr(e) {
|
|
1997
2000
|
if (!(e instanceof HTMLElement)) return !0;
|
|
1998
2001
|
if (!e.isConnected || e.hidden || e.closest("[hidden]")) return !1;
|
|
1999
2002
|
let t = window.getComputedStyle(e);
|
|
2000
2003
|
return t.display === "none" || t.visibility === "hidden" ? !1 : e.getClientRects().length > 0;
|
|
2001
2004
|
}
|
|
2002
|
-
function
|
|
2005
|
+
function nr(e, t) {
|
|
2003
2006
|
return t === document ? !0 : t instanceof Element ? t === e || t.contains(e) : !0;
|
|
2004
2007
|
}
|
|
2005
|
-
function
|
|
2008
|
+
function Q(e) {
|
|
2006
2009
|
let t = e, n = t.id ? `#${t.id}` : "", r = t.dataset?.formieHandle ? `[handle="${t.dataset.formieHandle}"]` : "";
|
|
2007
2010
|
return `${t.tagName ? t.tagName.toLowerCase() : "element"}${n}${r}`;
|
|
2008
2011
|
}
|
|
2009
|
-
function
|
|
2012
|
+
function rr(e, t) {
|
|
2010
2013
|
if (t) {
|
|
2011
2014
|
if (t.csrf?.param && t.csrf?.token) {
|
|
2012
2015
|
let n = e.querySelector(`input[name="${t.csrf.param}"]`);
|
|
@@ -2033,11 +2036,11 @@ function tr(e, t) {
|
|
|
2033
2036
|
});
|
|
2034
2037
|
}
|
|
2035
2038
|
}
|
|
2036
|
-
async function
|
|
2037
|
-
let n =
|
|
2039
|
+
async function ir(e, t) {
|
|
2040
|
+
let n = An(t.mode), r = jn(t.transport);
|
|
2038
2041
|
if (n !== "server-rendered") return null;
|
|
2039
2042
|
if (t.payload) return t.payload.html && (e.innerHTML = t.payload.html), t.payload;
|
|
2040
|
-
let i = !!
|
|
2043
|
+
let i = !!Mn(e), a = t.formHandle || e.dataset.formieHandle;
|
|
2041
2044
|
if (i || !a) return null;
|
|
2042
2045
|
let o = {
|
|
2043
2046
|
mode: n,
|
|
@@ -2046,33 +2049,26 @@ async function nr(e, t) {
|
|
|
2046
2049
|
siteId: t.siteId,
|
|
2047
2050
|
theme: t.theme,
|
|
2048
2051
|
themeConfig: t.themeConfig
|
|
2049
|
-
}, s = r === "graphql" ?
|
|
2052
|
+
}, s = r === "graphql" ? In(t, e) : Fn(t, e), c = r === "graphql" ? await Ye(s, a, o, t) : await Je(s, a, {
|
|
2050
2053
|
...o,
|
|
2051
2054
|
endpoint: s
|
|
2052
2055
|
}, t);
|
|
2053
2056
|
return c?.html && (e.innerHTML = c.html), c;
|
|
2054
2057
|
}
|
|
2055
|
-
async function
|
|
2058
|
+
async function ar(e, t, n) {
|
|
2056
2059
|
if (t.refreshTokens === !1) return;
|
|
2057
2060
|
let r = t.formHandle || e.dataset.formieHandle;
|
|
2058
2061
|
if (!r) return;
|
|
2059
|
-
let i = await
|
|
2060
|
-
|
|
2062
|
+
let i = await Xe(Ln(t, e), r, n.querySelector("input[name=\"renderId\"]")?.value || void 0, t, n?.querySelector("input[name=\"requestToken\"]")?.value);
|
|
2063
|
+
rr(n, i), g(e, "formie:refresh-tokens:refreshed", i);
|
|
2061
2064
|
}
|
|
2062
|
-
function
|
|
2063
|
-
let o = () => {};
|
|
2065
|
+
function or(e, t, n, r, i, a) {
|
|
2064
2066
|
t.dataset.formieRequestProfile = n.profile ?? "same-origin-browser", n.profile === "cross-origin-public" && (t.dataset.formieSubmitMethod = "ajax");
|
|
2065
|
-
let
|
|
2066
|
-
|
|
2067
|
-
t.setAttribute("data-formie-pending-action", e);
|
|
2068
|
-
return;
|
|
2069
|
-
}
|
|
2070
|
-
t.removeAttribute("data-formie-pending-action");
|
|
2067
|
+
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s = Hn(n, e, t), c = !1, l = t.querySelectorAll("[data-formie-action]"), u = (e) => {
|
|
2068
|
+
e ? t.setAttribute("data-formie-pending-action", e) : t.removeAttribute("data-formie-pending-action");
|
|
2071
2069
|
};
|
|
2072
|
-
if (
|
|
2073
|
-
let n =
|
|
2074
|
-
o = n.scheduleBaselineCapture;
|
|
2075
|
-
let r = (e) => {
|
|
2070
|
+
if (Un(t)) {
|
|
2071
|
+
let n = cn(t, { shouldWarn: () => !Kn(t) }), r = (e) => {
|
|
2076
2072
|
if (!(e instanceof CustomEvent)) return;
|
|
2077
2073
|
let t = e.detail;
|
|
2078
2074
|
t?.ok && (t.action === "save" || t.outcome === "revised") && n.scheduleBaselineCapture();
|
|
@@ -2083,41 +2079,41 @@ function ir(e, t, n, r, i, a) {
|
|
|
2083
2079
|
e.removeEventListener("formie:submit:result", r), t.removeEventListener("formie:state:reset", i), n.destroy();
|
|
2084
2080
|
});
|
|
2085
2081
|
}
|
|
2086
|
-
if (
|
|
2082
|
+
if (l.forEach((e) => {
|
|
2087
2083
|
let n = (e) => {
|
|
2088
2084
|
let n = e.currentTarget.getAttribute("data-formie-action"), r = t.querySelector("input[name=\"submitAction\"]");
|
|
2089
|
-
|
|
2085
|
+
u(n), n && r && (r.value = n);
|
|
2090
2086
|
};
|
|
2091
2087
|
e.addEventListener("click", n), a.push(() => {
|
|
2092
2088
|
e.removeEventListener("click", n);
|
|
2093
2089
|
});
|
|
2094
2090
|
}), t.querySelectorAll("[data-formie-tab-link]").forEach((n) => {
|
|
2095
2091
|
let r = async (n) => {
|
|
2096
|
-
if (
|
|
2097
|
-
|
|
2092
|
+
if (o !== "ajax") {
|
|
2093
|
+
Yn(n) && Wn(t, "set-page");
|
|
2098
2094
|
return;
|
|
2099
2095
|
}
|
|
2100
2096
|
n.preventDefault();
|
|
2101
2097
|
let r = n.currentTarget, i = r?.getAttribute("data-formie-page-id"), a = r?.getAttribute("href");
|
|
2102
2098
|
if (i && a) {
|
|
2103
|
-
|
|
2099
|
+
g(e, "formie:page:navigate", {
|
|
2104
2100
|
pageId: i,
|
|
2105
2101
|
href: a
|
|
2106
2102
|
});
|
|
2107
2103
|
try {
|
|
2108
|
-
let n = await
|
|
2109
|
-
if (n.pageId &&
|
|
2104
|
+
let n = await Ze(a, t, i);
|
|
2105
|
+
if (n.pageId && S(t, String(n.pageId)), !n.success) {
|
|
2110
2106
|
let { form: e = [], ...r } = n.errors ?? {};
|
|
2111
|
-
|
|
2107
|
+
Vt(t), Mt(t, r), Nt(t, e), F(t);
|
|
2112
2108
|
return;
|
|
2113
2109
|
}
|
|
2114
|
-
|
|
2110
|
+
g(e, "formie:page:navigate:after", {
|
|
2115
2111
|
pageId: i,
|
|
2116
2112
|
href: a,
|
|
2117
2113
|
response: n
|
|
2118
2114
|
});
|
|
2119
2115
|
} catch (t) {
|
|
2120
|
-
console.error("[formie] Failed to persist page navigation state.", t),
|
|
2116
|
+
console.error("[formie] Failed to persist page navigation state.", t), g(e, "formie:page:navigate:error", {
|
|
2121
2117
|
pageId: i,
|
|
2122
2118
|
href: a,
|
|
2123
2119
|
error: t
|
|
@@ -2128,49 +2124,49 @@ function ir(e, t, n, r, i, a) {
|
|
|
2128
2124
|
n.addEventListener("click", r), a.push(() => {
|
|
2129
2125
|
n.removeEventListener("click", r);
|
|
2130
2126
|
});
|
|
2131
|
-
}), !
|
|
2127
|
+
}), !Vn(t)) {
|
|
2132
2128
|
let e = !1, n = () => {
|
|
2133
|
-
e ||
|
|
2129
|
+
e || Kn(t) || Jn(t) || (e = !0, Qe(s, t));
|
|
2134
2130
|
};
|
|
2135
2131
|
window.addEventListener("pagehide", n), window.addEventListener("beforeunload", n), a.push(() => {
|
|
2136
2132
|
window.removeEventListener("pagehide", n), window.removeEventListener("beforeunload", n);
|
|
2137
2133
|
});
|
|
2138
2134
|
}
|
|
2139
|
-
let
|
|
2140
|
-
if (
|
|
2141
|
-
let
|
|
2135
|
+
let d = async (a) => {
|
|
2136
|
+
if (c) return;
|
|
2137
|
+
let s = o === "ajax";
|
|
2142
2138
|
if (a.preventDefault(), t.getAttribute("data-formie-loading") === "true") {
|
|
2143
2139
|
if (t.getAttribute("data-formie-internal-resubmit") !== "true") return;
|
|
2144
2140
|
t.removeAttribute("data-formie-internal-resubmit");
|
|
2145
2141
|
} else t.removeAttribute("data-formie-internal-resubmit");
|
|
2146
|
-
let
|
|
2142
|
+
let l = a.submitter, d = l?.getAttribute("data-formie-action"), p = t.getAttribute("data-formie-pending-action"), h = t.querySelector("input[name=\"submitAction\"]"), _ = d || p || h?.value || "submit", v = null, y = !1;
|
|
2147
2143
|
try {
|
|
2148
|
-
if (
|
|
2144
|
+
if (s) v = await Ht({
|
|
2149
2145
|
target: e,
|
|
2150
2146
|
form: t,
|
|
2151
2147
|
bus: r,
|
|
2152
2148
|
validator: i,
|
|
2153
|
-
validateOnSubmit:
|
|
2149
|
+
validateOnSubmit: Z(t),
|
|
2154
2150
|
action: _,
|
|
2155
|
-
submitter:
|
|
2156
|
-
waitForSubmitDelay:
|
|
2151
|
+
submitter: l,
|
|
2152
|
+
waitForSubmitDelay: Qn,
|
|
2157
2153
|
onRefreshTokensAfterSubmit: async () => {
|
|
2158
|
-
await
|
|
2154
|
+
await ar(e, n, t);
|
|
2159
2155
|
},
|
|
2160
2156
|
dispatchSubmitResult: (t) => {
|
|
2161
|
-
|
|
2157
|
+
g(e, "formie:submit:result", t);
|
|
2162
2158
|
}
|
|
2163
2159
|
});
|
|
2164
2160
|
else {
|
|
2165
|
-
if (
|
|
2161
|
+
if (Vt(t), C(t, l), await Qn(t), v = await dt(t, _, r, {
|
|
2166
2162
|
validator: i,
|
|
2167
|
-
validateOnSubmit:
|
|
2163
|
+
validateOnSubmit: Z(t),
|
|
2168
2164
|
preflightOnly: !0
|
|
2169
|
-
}),
|
|
2170
|
-
|
|
2165
|
+
}), v.ok) {
|
|
2166
|
+
x(t, _), c = !0, Wn(t, "submit"), u(null);
|
|
2171
2167
|
let e = !1, n = () => {
|
|
2172
|
-
if (e = !0,
|
|
2173
|
-
let { scope: e, final: n } =
|
|
2168
|
+
if (e = !0, c = !1, Gn(t), f(t), i && Z(t)) {
|
|
2169
|
+
let { scope: e, final: n } = m(t), r = i.submit(n ? t : e, { final: n });
|
|
2174
2170
|
r.length > 0 && z(t, {
|
|
2175
2171
|
ok: !1,
|
|
2176
2172
|
stage: "validate",
|
|
@@ -2190,34 +2186,34 @@ function ir(e, t, n, r, i, a) {
|
|
|
2190
2186
|
}
|
|
2191
2187
|
} else t.submit();
|
|
2192
2188
|
if (e) return;
|
|
2193
|
-
|
|
2189
|
+
y = !0;
|
|
2194
2190
|
return;
|
|
2195
2191
|
}
|
|
2196
|
-
z(t,
|
|
2192
|
+
z(t, v), g(e, "formie:submit:result", v), Gn(t);
|
|
2197
2193
|
}
|
|
2198
2194
|
} catch (n) {
|
|
2199
|
-
|
|
2195
|
+
c = !1, v = {
|
|
2200
2196
|
ok: !1,
|
|
2201
2197
|
code: "SUBMIT_ERROR",
|
|
2202
2198
|
message: n instanceof Error ? n.message : "Submission failed.",
|
|
2203
2199
|
formErrors: [n instanceof Error ? n.message : "Submission failed."]
|
|
2204
|
-
}, z(t,
|
|
2200
|
+
}, z(t, v), g(e, "formie:submit:result", v), Gn(t);
|
|
2205
2201
|
} finally {
|
|
2206
|
-
|
|
2202
|
+
u(null), !s && !y && !Bt(v) && f(t);
|
|
2207
2203
|
}
|
|
2208
2204
|
};
|
|
2209
|
-
|
|
2210
|
-
t.removeEventListener("submit",
|
|
2211
|
-
})
|
|
2205
|
+
t.addEventListener("submit", d), a.push(() => {
|
|
2206
|
+
t.removeEventListener("submit", d);
|
|
2207
|
+
});
|
|
2212
2208
|
}
|
|
2213
|
-
async function
|
|
2209
|
+
async function sr(e, t, n) {
|
|
2214
2210
|
if (t.refreshTokens === !1 || !t.staticCache) return;
|
|
2215
|
-
let r = t.formHandle || e.dataset.formieHandle, i =
|
|
2211
|
+
let r = t.formHandle || e.dataset.formieHandle, i = Ln(t, e), a = n?.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2216
2212
|
if (!r) return;
|
|
2217
|
-
let o = await
|
|
2218
|
-
o && n && (
|
|
2213
|
+
let o = await Xe(i, r, a, t, n?.querySelector("input[name=\"requestToken\"]")?.value);
|
|
2214
|
+
o && n && (rr(n, o), g(e, "formie:refresh-tokens:after", o));
|
|
2219
2215
|
}
|
|
2220
|
-
function
|
|
2216
|
+
function cr() {
|
|
2221
2217
|
let t = /* @__PURE__ */ new Map(), r = new B(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = [
|
|
2222
2218
|
"prepare",
|
|
2223
2219
|
"normalize",
|
|
@@ -2233,161 +2229,157 @@ function or() {
|
|
|
2233
2229
|
return;
|
|
2234
2230
|
}
|
|
2235
2231
|
let r = (async () => {
|
|
2236
|
-
|
|
2232
|
+
q.log("Unmount requested.", { target: Q(e) });
|
|
2237
2233
|
let n = i.get(e);
|
|
2238
2234
|
n && (n(), i.delete(e));
|
|
2239
2235
|
let r = t.get(e);
|
|
2240
|
-
|
|
2241
|
-
G.log("Unmount skipped (no mounted state).", { target: Z(e) });
|
|
2242
|
-
return;
|
|
2243
|
-
}
|
|
2244
|
-
y(e, "formie:unmount:before", { id: r.instance.id }), r.unbinds.forEach((e) => {
|
|
2236
|
+
r ? (g(e, "formie:unmount:before", { id: r.instance.id }), r.unbinds.forEach((e) => {
|
|
2245
2237
|
e();
|
|
2246
|
-
}), r.unbinds = [], r.validator?.destroy(), r.validator = null, await r.modules.destroy(), r.bus.clear(), t.delete(e),
|
|
2238
|
+
}), r.unbinds = [], r.validator?.destroy(), r.validator = null, await r.modules.destroy(), r.bus.clear(), t.delete(e), g(e, "formie:unmount:after", { id: r.instance.id }), r.unbindEventContext(), q.log("Unmount complete.", {
|
|
2247
2239
|
id: r.instance.id,
|
|
2248
|
-
target:
|
|
2249
|
-
});
|
|
2240
|
+
target: Q(e)
|
|
2241
|
+
})) : q.log("Unmount skipped (no mounted state).", { target: Q(e) });
|
|
2250
2242
|
})().finally(() => {
|
|
2251
2243
|
a.delete(e);
|
|
2252
2244
|
});
|
|
2253
2245
|
a.set(e, r), await r;
|
|
2254
2246
|
}, c = async (a, c) => {
|
|
2255
|
-
|
|
2256
|
-
target:
|
|
2247
|
+
q.log("Mount requested.", {
|
|
2248
|
+
target: Q(a),
|
|
2257
2249
|
mode: c.mode,
|
|
2258
2250
|
autoVisible: c.autoVisible
|
|
2259
2251
|
});
|
|
2260
2252
|
let l = i.get(a);
|
|
2261
2253
|
l && (l(), i.delete(a));
|
|
2262
2254
|
let u = t.get(a);
|
|
2263
|
-
if (u) return
|
|
2255
|
+
if (u) return q.log("Mount skipped (already mounted).", {
|
|
2264
2256
|
id: u.instance.id,
|
|
2265
|
-
target:
|
|
2257
|
+
target: Q(a)
|
|
2266
2258
|
}), u.instance;
|
|
2267
|
-
let d = new
|
|
2268
|
-
...
|
|
2259
|
+
let d = new Ut(), f = [], m = a?.id || `formie-${t.size + 1}`, v = Y(a), b = {
|
|
2260
|
+
...v,
|
|
2269
2261
|
...c,
|
|
2270
|
-
mode:
|
|
2271
|
-
transport:
|
|
2272
|
-
},
|
|
2273
|
-
c.compatibility === void 0 &&
|
|
2274
|
-
let
|
|
2275
|
-
|
|
2276
|
-
let
|
|
2262
|
+
mode: An(c.mode ?? v.mode),
|
|
2263
|
+
transport: jn(c.transport ?? v.transport)
|
|
2264
|
+
}, x = await ir(a, b), S = Mn(a);
|
|
2265
|
+
c.compatibility === void 0 && S?.hasAttribute("data-formie-compatibility") && (b.compatibility = Y(S).compatibility);
|
|
2266
|
+
let C = Te(b.compatibility);
|
|
2267
|
+
S && e(S, b), b.staticCache = c.staticCache ?? kn(S ? S.dataset : a.dataset);
|
|
2268
|
+
let w;
|
|
2277
2269
|
try {
|
|
2278
|
-
|
|
2270
|
+
w = er(a, S), x?.modules && n(x.modules), w?.modules && n(w.modules);
|
|
2279
2271
|
} catch (e) {
|
|
2280
|
-
if (
|
|
2281
|
-
|
|
2272
|
+
if (S) {
|
|
2273
|
+
S.addEventListener("submit", (e) => {
|
|
2282
2274
|
e.preventDefault(), e.stopImmediatePropagation();
|
|
2283
2275
|
}, !0);
|
|
2284
2276
|
let e = document.createElement("div");
|
|
2285
|
-
e.setAttribute("role", "alert"), e.textContent = "This form requires a compatible Formie browser package. Update Formie and its browser packages together.",
|
|
2277
|
+
e.setAttribute("role", "alert"), e.textContent = "This form requires a compatible Formie browser package. Update Formie and its browser packages together.", S.prepend(e);
|
|
2286
2278
|
}
|
|
2287
2279
|
throw e;
|
|
2288
2280
|
}
|
|
2289
|
-
let
|
|
2290
|
-
...
|
|
2291
|
-
...
|
|
2292
|
-
} : null, te =
|
|
2281
|
+
let T = x || w ? {
|
|
2282
|
+
...x || {},
|
|
2283
|
+
...w || {}
|
|
2284
|
+
} : null, te = T?.theme, ne = {}, E = T?.modules ?? {
|
|
2293
2285
|
contractVersion: 2,
|
|
2294
2286
|
surface: "server-rendered",
|
|
2295
2287
|
entries: []
|
|
2296
2288
|
};
|
|
2297
|
-
n(
|
|
2298
|
-
target:
|
|
2299
|
-
hasRenderPayload: !!
|
|
2300
|
-
hasEmbeddedPayload: !!
|
|
2301
|
-
moduleCount:
|
|
2289
|
+
n(E), q.log("Resolved mount payload.", {
|
|
2290
|
+
target: Q(a),
|
|
2291
|
+
hasRenderPayload: !!x,
|
|
2292
|
+
hasEmbeddedPayload: !!w,
|
|
2293
|
+
moduleCount: E.entries.length
|
|
2302
2294
|
});
|
|
2303
|
-
let
|
|
2304
|
-
live:
|
|
2305
|
-
errorAriaLive:
|
|
2306
|
-
errorMessage:
|
|
2307
|
-
fieldContainerErrorClass:
|
|
2308
|
-
inputErrorClass:
|
|
2309
|
-
messagesClass:
|
|
2310
|
-
messageClass:
|
|
2295
|
+
let D = re(a, te, S), O = S ? new mn(S, {
|
|
2296
|
+
live: Bn(S.dataset.formieValidationOnFocus),
|
|
2297
|
+
errorAriaLive: Ne(S),
|
|
2298
|
+
errorMessage: S.dataset.formieErrorMessage || "",
|
|
2299
|
+
fieldContainerErrorClass: D.fieldLayoutError || [],
|
|
2300
|
+
inputErrorClass: D.fieldControlError || [],
|
|
2301
|
+
messagesClass: D.fieldErrors || [],
|
|
2302
|
+
messageClass: D.fieldError || []
|
|
2311
2303
|
}) : null;
|
|
2312
|
-
if (
|
|
2313
|
-
let e =
|
|
2314
|
-
e.formieValidation =
|
|
2304
|
+
if (S && O) {
|
|
2305
|
+
let e = S;
|
|
2306
|
+
e.formieValidation = O, ne.validation = O;
|
|
2315
2307
|
let t = {
|
|
2316
|
-
validator:
|
|
2317
|
-
addValidator:
|
|
2318
|
-
removeValidator:
|
|
2308
|
+
validator: O,
|
|
2309
|
+
addValidator: O.addValidator.bind(O),
|
|
2310
|
+
removeValidator: O.removeValidator.bind(O)
|
|
2319
2311
|
};
|
|
2320
|
-
|
|
2312
|
+
g(S, "formie:validator:ready", t), g(a, "formie:validator:ready", t);
|
|
2321
2313
|
}
|
|
2322
|
-
|
|
2323
|
-
let
|
|
2314
|
+
S && (y(S), (x || b.endpoint || a.dataset.formieEndpoint) && zn(a, S, b), b.mode === "server-rendered" && Ge(S) && (We(S), F(S)), h(S)), Object.keys(D).length && g(a, "formie:theme:applied", { hasClasses: !0 }), S?.querySelector("craft-csrf-input") && await se("craft-csrf-input", S);
|
|
2315
|
+
let k = await tn(E, {
|
|
2324
2316
|
registry: r,
|
|
2325
2317
|
matchContext: {
|
|
2326
2318
|
root: a,
|
|
2327
|
-
form:
|
|
2328
|
-
surface:
|
|
2319
|
+
form: S,
|
|
2320
|
+
surface: E.surface
|
|
2329
2321
|
},
|
|
2330
2322
|
setupContext: {
|
|
2331
|
-
formId:
|
|
2323
|
+
formId: m,
|
|
2332
2324
|
root: a,
|
|
2333
|
-
form:
|
|
2325
|
+
form: S,
|
|
2334
2326
|
target: a,
|
|
2335
2327
|
scope: "form",
|
|
2336
|
-
surface:
|
|
2337
|
-
state:
|
|
2328
|
+
surface: E.surface,
|
|
2329
|
+
state: ne,
|
|
2338
2330
|
on: (e, t) => d.on(e, t),
|
|
2339
|
-
emit: (e, t) => (
|
|
2340
|
-
t.failed.length > 0 &&
|
|
2331
|
+
emit: (e, t) => (g(a, e, t), d.emitSafe(e, t).then((t) => {
|
|
2332
|
+
t.failed.length > 0 && q.warn("Lifecycle listeners failed.", {
|
|
2341
2333
|
eventName: e,
|
|
2342
2334
|
failed: t.failed.length
|
|
2343
2335
|
});
|
|
2344
2336
|
}))
|
|
2345
2337
|
}
|
|
2346
2338
|
});
|
|
2347
|
-
|
|
2348
|
-
target:
|
|
2349
|
-
moduleInstances:
|
|
2339
|
+
q.log("Module setup complete.", {
|
|
2340
|
+
target: Q(a),
|
|
2341
|
+
moduleInstances: k.instances.length
|
|
2350
2342
|
});
|
|
2351
|
-
let
|
|
2352
|
-
id:
|
|
2343
|
+
let A = {
|
|
2344
|
+
id: m,
|
|
2353
2345
|
root: a,
|
|
2354
2346
|
submit: async (e = "submit") => {
|
|
2355
|
-
if (
|
|
2356
|
-
id:
|
|
2357
|
-
target:
|
|
2347
|
+
if (q.log("Submit requested.", {
|
|
2348
|
+
id: m,
|
|
2349
|
+
target: Q(a),
|
|
2358
2350
|
action: e
|
|
2359
|
-
}), !
|
|
2351
|
+
}), !S) return {
|
|
2360
2352
|
ok: !1,
|
|
2361
2353
|
code: "FORM_NOT_FOUND",
|
|
2362
2354
|
message: "No form element found for mount target.",
|
|
2363
2355
|
formErrors: ["No form element found for mount target."]
|
|
2364
2356
|
};
|
|
2365
|
-
let t =
|
|
2366
|
-
if (t && (t.value = e),
|
|
2357
|
+
let t = S.querySelector("input[name=\"submitAction\"]");
|
|
2358
|
+
if (t && (t.value = e), S.getAttribute("data-formie-loading") === "true") return {
|
|
2367
2359
|
ok: !1,
|
|
2368
2360
|
code: "SUBMIT_IN_PROGRESS",
|
|
2369
2361
|
message: "Submission already in progress.",
|
|
2370
2362
|
formErrors: []
|
|
2371
2363
|
};
|
|
2372
|
-
let n =
|
|
2373
|
-
id:
|
|
2364
|
+
let n = S.querySelector(`[data-formie-action="${e}"]`), r = await Ht({
|
|
2365
|
+
id: m,
|
|
2374
2366
|
target: a,
|
|
2375
|
-
form:
|
|
2367
|
+
form: S,
|
|
2376
2368
|
bus: d,
|
|
2377
|
-
validator:
|
|
2378
|
-
validateOnSubmit:
|
|
2369
|
+
validator: O,
|
|
2370
|
+
validateOnSubmit: Z(S),
|
|
2379
2371
|
action: e,
|
|
2380
2372
|
submitter: n,
|
|
2381
|
-
waitForSubmitDelay:
|
|
2373
|
+
waitForSubmitDelay: Qn,
|
|
2382
2374
|
onRefreshTokensAfterSubmit: async () => {
|
|
2383
|
-
await
|
|
2375
|
+
await ar(a, b, S);
|
|
2384
2376
|
},
|
|
2385
2377
|
dispatchSubmitResult: (e) => {
|
|
2386
|
-
|
|
2378
|
+
g(a, "formie:submit:result", e);
|
|
2387
2379
|
}
|
|
2388
2380
|
});
|
|
2389
|
-
return
|
|
2390
|
-
id:
|
|
2381
|
+
return q.log("Submit completed.", {
|
|
2382
|
+
id: m,
|
|
2391
2383
|
action: e,
|
|
2392
2384
|
ok: r.ok,
|
|
2393
2385
|
code: r.code,
|
|
@@ -2398,32 +2390,34 @@ function or() {
|
|
|
2398
2390
|
await s(a);
|
|
2399
2391
|
},
|
|
2400
2392
|
on: (e, t) => d.on(e, t)
|
|
2401
|
-
};
|
|
2402
|
-
if (
|
|
2393
|
+
}, j = _(a, S, A);
|
|
2394
|
+
if (S && (Me({
|
|
2403
2395
|
target: a,
|
|
2404
|
-
form:
|
|
2405
|
-
validatorDetail:
|
|
2406
|
-
validator:
|
|
2407
|
-
addValidator:
|
|
2408
|
-
removeValidator:
|
|
2396
|
+
form: S,
|
|
2397
|
+
validatorDetail: O ? {
|
|
2398
|
+
validator: O,
|
|
2399
|
+
addValidator: O.addValidator.bind(O),
|
|
2400
|
+
removeValidator: O.removeValidator.bind(O)
|
|
2409
2401
|
} : null,
|
|
2410
|
-
options:
|
|
2402
|
+
options: C,
|
|
2411
2403
|
unbinds: f
|
|
2412
|
-
}),
|
|
2404
|
+
}), Ae({
|
|
2413
2405
|
target: a,
|
|
2414
|
-
form:
|
|
2415
|
-
instance:
|
|
2416
|
-
options:
|
|
2406
|
+
form: S,
|
|
2407
|
+
instance: A,
|
|
2408
|
+
options: C,
|
|
2417
2409
|
unbinds: f
|
|
2418
|
-
})),
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2410
|
+
})), S) {
|
|
2411
|
+
or(a, S, b, d, O, f), O && (f.push(p(S, O, a)), f.push(yn(S)));
|
|
2412
|
+
try {
|
|
2413
|
+
await sr(a, b, S);
|
|
2414
|
+
} catch (e) {
|
|
2415
|
+
throw j(), e;
|
|
2416
|
+
}
|
|
2423
2417
|
}
|
|
2424
2418
|
o.forEach((e) => {
|
|
2425
2419
|
let t = d.on(`formie:stage:${e}:before`, async (t) => {
|
|
2426
|
-
|
|
2420
|
+
g(a, `formie:stage:${e}:before`, t);
|
|
2427
2421
|
}), n = d.on(`formie:stage:${e}:before`, async (t) => {
|
|
2428
2422
|
let n = {
|
|
2429
2423
|
core: "prepare",
|
|
@@ -2433,12 +2427,12 @@ function or() {
|
|
|
2433
2427
|
payment: "payment"
|
|
2434
2428
|
}, r = t;
|
|
2435
2429
|
if (e === "prepare") try {
|
|
2436
|
-
|
|
2430
|
+
k.assertReady();
|
|
2437
2431
|
} catch {
|
|
2438
2432
|
r.abort("A required form feature could not start. Reload the page or contact the site administrator.");
|
|
2439
2433
|
return;
|
|
2440
2434
|
}
|
|
2441
|
-
for (let t of
|
|
2435
|
+
for (let t of k.instances) if (t.beforeSubmit && n[t.kind ?? "core"] === e) {
|
|
2442
2436
|
let { form: e, action: n, formData: i, abort: a, isAborted: o, abortReason: s } = r;
|
|
2443
2437
|
await t.beforeSubmit({
|
|
2444
2438
|
form: e,
|
|
@@ -2450,56 +2444,58 @@ function or() {
|
|
|
2450
2444
|
});
|
|
2451
2445
|
}
|
|
2452
2446
|
}), r = d.on(`formie:stage:${e}:after`, async (t) => {
|
|
2453
|
-
|
|
2447
|
+
g(a, `formie:stage:${e}:after`, t);
|
|
2454
2448
|
});
|
|
2455
2449
|
f.push(t, n, r);
|
|
2456
2450
|
});
|
|
2457
|
-
let
|
|
2458
|
-
|
|
2459
|
-
}),
|
|
2460
|
-
if (
|
|
2451
|
+
let ie = d.on("formie:submit:before", async (e) => {
|
|
2452
|
+
g(a, "formie:submit:before", e);
|
|
2453
|
+
}), ae = d.on("formie:submit:after", async (e) => {
|
|
2454
|
+
if (g(a, "formie:submit:after", e), !S) return;
|
|
2461
2455
|
let t = e;
|
|
2462
2456
|
if (t.code === "PREFLIGHT_COMPLETE") return;
|
|
2463
2457
|
let n = {
|
|
2464
|
-
form:
|
|
2458
|
+
form: S,
|
|
2465
2459
|
action: t.action ?? "submit",
|
|
2466
|
-
formData: new FormData(
|
|
2460
|
+
formData: new FormData(S)
|
|
2467
2461
|
};
|
|
2468
|
-
for (let e of
|
|
2469
|
-
}),
|
|
2470
|
-
|
|
2471
|
-
}),
|
|
2472
|
-
|
|
2462
|
+
for (let e of k.instances) await e.afterSubmit?.(n, t);
|
|
2463
|
+
}), M = d.on("formie:submit:final:before", async (e) => {
|
|
2464
|
+
g(a, "formie:submit:final:before", e);
|
|
2465
|
+
}), oe = d.on("formie:submit:final:after", async (e) => {
|
|
2466
|
+
g(a, "formie:submit:final:after", e);
|
|
2473
2467
|
});
|
|
2474
|
-
return f.push(
|
|
2475
|
-
options:
|
|
2468
|
+
return f.push(ie, ae, M, oe), t.set(a, {
|
|
2469
|
+
options: b,
|
|
2476
2470
|
bus: d,
|
|
2477
|
-
form:
|
|
2478
|
-
validator:
|
|
2479
|
-
modules:
|
|
2471
|
+
form: S,
|
|
2472
|
+
validator: O,
|
|
2473
|
+
modules: k,
|
|
2480
2474
|
unbinds: f,
|
|
2481
|
-
instance:
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2475
|
+
instance: A,
|
|
2476
|
+
unbindEventContext: j
|
|
2477
|
+
}), g(a, "formie:mount:after", {
|
|
2478
|
+
id: m,
|
|
2479
|
+
mode: b.mode,
|
|
2480
|
+
instance: A
|
|
2481
|
+
}), S instanceof HTMLFormElement && ee(S), q.log("Mount complete.", {
|
|
2482
|
+
id: m,
|
|
2483
|
+
target: Q(a),
|
|
2484
|
+
mode: b.mode
|
|
2485
|
+
}), A;
|
|
2490
2486
|
}, l = (e, n) => {
|
|
2491
|
-
if (!n.autoVisible ||
|
|
2487
|
+
if (!n.autoVisible || tr(e) || typeof IntersectionObserver > "u") return c(e, n);
|
|
2492
2488
|
if (t.has(e)) return Promise.resolve(t.get(e)?.instance || null);
|
|
2493
|
-
if (i.has(e)) return
|
|
2489
|
+
if (i.has(e)) return q.log("Mount deferred (already waiting visibility).", { target: Q(e) }), Promise.resolve(null);
|
|
2494
2490
|
let r = new IntersectionObserver((t) => {
|
|
2495
|
-
t.some((t) => t.target === e && t.isIntersecting) && (r.disconnect(), i.delete(e),
|
|
2491
|
+
t.some((t) => t.target === e && t.isIntersecting) && (r.disconnect(), i.delete(e), q.log("Visibility reached, proceeding mount.", { target: Q(e) }), c(e, {
|
|
2496
2492
|
...n,
|
|
2497
2493
|
autoVisible: !1
|
|
2498
2494
|
}));
|
|
2499
2495
|
}, { threshold: .01 });
|
|
2500
2496
|
return r.observe(e), i.set(e, () => {
|
|
2501
2497
|
r.disconnect();
|
|
2502
|
-
}),
|
|
2498
|
+
}), q.log("Mount deferred until visible.", { target: Q(e) }), Promise.resolve(null);
|
|
2503
2499
|
};
|
|
2504
2500
|
return {
|
|
2505
2501
|
mount: c,
|
|
@@ -2507,7 +2503,7 @@ function or() {
|
|
|
2507
2503
|
update: async (e, n) => {
|
|
2508
2504
|
let r = t.get(e);
|
|
2509
2505
|
if (!r) return c(e, {
|
|
2510
|
-
...
|
|
2506
|
+
...Y(e),
|
|
2511
2507
|
...n,
|
|
2512
2508
|
mode: n.mode || "server-rendered"
|
|
2513
2509
|
});
|
|
@@ -2515,32 +2511,32 @@ function or() {
|
|
|
2515
2511
|
...r.options,
|
|
2516
2512
|
...n
|
|
2517
2513
|
};
|
|
2518
|
-
let i = n.payload?.theme || r.options.payload?.theme ||
|
|
2519
|
-
return r.validator && (r.validator.config.fieldContainerErrorClass = a.fieldLayoutError || [], r.validator.config.inputErrorClass = a.fieldControlError || [], r.validator.config.messagesClass = a.fieldErrors || [], r.validator.config.messageClass = a.fieldError || []), Object.keys(a).length &&
|
|
2514
|
+
let i = n.payload?.theme || r.options.payload?.theme || er(e, r.form)?.theme, a = re(e, i, r.form);
|
|
2515
|
+
return r.validator && (r.validator.config.fieldContainerErrorClass = a.fieldLayoutError || [], r.validator.config.inputErrorClass = a.fieldControlError || [], r.validator.config.messagesClass = a.fieldErrors || [], r.validator.config.messageClass = a.fieldError || []), Object.keys(a).length && g(e, "formie:theme:applied", {
|
|
2520
2516
|
hasClasses: !0,
|
|
2521
2517
|
reason: "update"
|
|
2522
2518
|
}), r.instance;
|
|
2523
2519
|
},
|
|
2524
2520
|
getInstance: (e) => t.get(e)?.instance || null,
|
|
2525
2521
|
refreshForCache: async (e) => {
|
|
2526
|
-
|
|
2522
|
+
Nn("refreshForCache", "Global `Formie.refreshForCache()` has been deprecated. Use built-in static-cache token refresh handling instead.");
|
|
2527
2523
|
let n = null;
|
|
2528
2524
|
if (n = typeof e == "string" ? document.getElementById(e) || document.querySelector(`[data-formie-form-id="${e}"]`) : e, !n) {
|
|
2529
|
-
|
|
2525
|
+
q.warn("refreshForCache target not found.", { targetOrId: e });
|
|
2530
2526
|
return;
|
|
2531
2527
|
}
|
|
2532
|
-
let r = t.get(n), i =
|
|
2528
|
+
let r = t.get(n), i = Mn(n), a = r?.options || Y(n);
|
|
2533
2529
|
if (!i) {
|
|
2534
|
-
|
|
2530
|
+
q.warn("refreshForCache found no form element for target.", { target: Q(n) });
|
|
2535
2531
|
return;
|
|
2536
2532
|
}
|
|
2537
|
-
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s =
|
|
2533
|
+
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s = Ln(a, n), c = i.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2538
2534
|
if (!o) {
|
|
2539
|
-
|
|
2535
|
+
q.warn("refreshForCache found no form handle for target.", { target: Q(n) });
|
|
2540
2536
|
return;
|
|
2541
2537
|
}
|
|
2542
|
-
let l = await
|
|
2543
|
-
l && (
|
|
2538
|
+
let l = await Xe(s, o, c, a, i?.querySelector("input[name=\"requestToken\"]")?.value);
|
|
2539
|
+
l && (rr(i, l), g(n, "formie:refresh-tokens:after", l));
|
|
2544
2540
|
},
|
|
2545
2541
|
registerModule: (e, t) => r.register(e, t),
|
|
2546
2542
|
unregisterModule: (e) => {
|
|
@@ -2548,16 +2544,16 @@ function or() {
|
|
|
2548
2544
|
},
|
|
2549
2545
|
getRegisteredModules: () => r.getAll(),
|
|
2550
2546
|
scan: async (e) => {
|
|
2551
|
-
let t = e || document, n = Array.from(t.querySelectorAll(
|
|
2552
|
-
|
|
2547
|
+
let t = e || document, n = Array.from(t.querySelectorAll(K));
|
|
2548
|
+
q.log("Scan started.", {
|
|
2553
2549
|
scope: t === document ? "document" : t,
|
|
2554
2550
|
targetCount: n.length
|
|
2555
2551
|
});
|
|
2556
2552
|
let r = (await Promise.all(n.map((e) => {
|
|
2557
|
-
let t =
|
|
2553
|
+
let t = Y(e);
|
|
2558
2554
|
return l(e, t);
|
|
2559
2555
|
}))).filter((e) => !!e);
|
|
2560
|
-
return
|
|
2556
|
+
return q.log("Scan finished.", {
|
|
2561
2557
|
mountedCount: r.length,
|
|
2562
2558
|
deferredCount: n.length - r.length
|
|
2563
2559
|
}), r;
|
|
@@ -2565,16 +2561,16 @@ function or() {
|
|
|
2565
2561
|
observe: (e) => {
|
|
2566
2562
|
if (typeof MutationObserver > "u") return () => {};
|
|
2567
2563
|
let n = e || document;
|
|
2568
|
-
|
|
2564
|
+
q.log("Observer started.", { scope: n === document ? "document" : n });
|
|
2569
2565
|
let r = new MutationObserver((e) => {
|
|
2570
2566
|
e.forEach((e) => {
|
|
2571
2567
|
e.addedNodes.forEach((e) => {
|
|
2572
|
-
e instanceof Element && (e.matches(
|
|
2573
|
-
|
|
2568
|
+
e instanceof Element && (e.matches(K) && (q.log("Observer detected new root.", { target: Q(e) }), l(e, Y(e))), e.querySelectorAll(K).forEach((e) => {
|
|
2569
|
+
q.log("Observer detected new nested root.", { target: Q(e) }), l(e, Y(e));
|
|
2574
2570
|
}));
|
|
2575
2571
|
}), e.removedNodes.forEach((e) => {
|
|
2576
|
-
e instanceof Element && (t.has(e) && (
|
|
2577
|
-
t.has(e) && (
|
|
2572
|
+
e instanceof Element && (t.has(e) && (q.log("Observer detected removed root.", { target: Q(e) }), s(e)), e.querySelectorAll(K).forEach((e) => {
|
|
2573
|
+
t.has(e) && (q.log("Observer detected removed nested root.", { target: Q(e) }), s(e));
|
|
2578
2574
|
}));
|
|
2579
2575
|
});
|
|
2580
2576
|
});
|
|
@@ -2583,11 +2579,11 @@ function or() {
|
|
|
2583
2579
|
childList: !0,
|
|
2584
2580
|
subtree: !0
|
|
2585
2581
|
}), () => {
|
|
2586
|
-
r.disconnect(),
|
|
2587
|
-
|
|
2582
|
+
r.disconnect(), q.log("Observer stopped."), i.forEach((e, t) => {
|
|
2583
|
+
nr(t, n) && (e(), i.delete(t));
|
|
2588
2584
|
});
|
|
2589
2585
|
let e = [];
|
|
2590
|
-
n instanceof Element && n.matches(
|
|
2586
|
+
n instanceof Element && n.matches(K) && e.push(n), n.querySelectorAll(K).forEach((t) => {
|
|
2591
2587
|
e.push(t);
|
|
2592
2588
|
}), e.forEach((e) => {
|
|
2593
2589
|
t.has(e) && s(e);
|
|
@@ -2598,13 +2594,13 @@ function or() {
|
|
|
2598
2594
|
}
|
|
2599
2595
|
//#endregion
|
|
2600
2596
|
//#region src/js/core/hydrate-modules.ts
|
|
2601
|
-
var
|
|
2602
|
-
async function
|
|
2597
|
+
var lr = O("general", "module-hydrator");
|
|
2598
|
+
async function ur(e) {
|
|
2603
2599
|
let t = e.root, n = e.form ?? (t instanceof HTMLFormElement ? t : t.closest("form") ?? t.querySelector("form")), r = e.surface ?? "cp-edit", i = e.modules ?? {
|
|
2604
2600
|
contractVersion: 2,
|
|
2605
2601
|
surface: r,
|
|
2606
2602
|
entries: []
|
|
2607
|
-
}, a = e.registry ?? new B(), o = new
|
|
2603
|
+
}, a = e.registry ?? new B(), o = new Ut(), s = await tn(i, {
|
|
2608
2604
|
registry: a,
|
|
2609
2605
|
setupContext: {
|
|
2610
2606
|
formId: n?.id || t.id || "formie-modules",
|
|
@@ -2629,7 +2625,7 @@ async function cr(e) {
|
|
|
2629
2625
|
surface: r
|
|
2630
2626
|
}
|
|
2631
2627
|
});
|
|
2632
|
-
return
|
|
2628
|
+
return lr.log("Hydrated module manifest.", {
|
|
2633
2629
|
moduleCount: i.entries.length,
|
|
2634
2630
|
instanceCount: s.instances.length,
|
|
2635
2631
|
surface: r
|
|
@@ -2696,44 +2692,44 @@ async function cr(e) {
|
|
|
2696
2692
|
}
|
|
2697
2693
|
//#endregion
|
|
2698
2694
|
//#region src/js/core/formie.ts
|
|
2699
|
-
function
|
|
2695
|
+
function $(e) {
|
|
2700
2696
|
return e instanceof Element;
|
|
2701
2697
|
}
|
|
2702
|
-
function
|
|
2698
|
+
function dr(e) {
|
|
2703
2699
|
return e.ok;
|
|
2704
2700
|
}
|
|
2705
|
-
function
|
|
2706
|
-
return typeof e == "string" ? `selector "${e}"` :
|
|
2701
|
+
function fr(e) {
|
|
2702
|
+
return typeof e == "string" ? `selector "${e}"` : $(e) ? `element "${e.tagName.toLowerCase()}"` : "provided element collection";
|
|
2707
2703
|
}
|
|
2708
|
-
function
|
|
2704
|
+
function pr(e) {
|
|
2709
2705
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2710
|
-
for (let r of e)
|
|
2706
|
+
for (let r of e) $(r) && !t.has(r) && (t.add(r), n.push(r));
|
|
2711
2707
|
return n;
|
|
2712
2708
|
}
|
|
2713
|
-
function
|
|
2714
|
-
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) :
|
|
2709
|
+
function mr(e) {
|
|
2710
|
+
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : $(e) ? [e] : pr(e);
|
|
2715
2711
|
}
|
|
2716
|
-
function
|
|
2712
|
+
function hr() {
|
|
2717
2713
|
return document.readyState === "loading" ? new Promise((e) => {
|
|
2718
2714
|
document.addEventListener("DOMContentLoaded", () => e(), { once: !0 });
|
|
2719
2715
|
}) : Promise.resolve();
|
|
2720
2716
|
}
|
|
2721
|
-
async function
|
|
2722
|
-
let t =
|
|
2723
|
-
return t.length > 0 || typeof e != "string" ? t : (await
|
|
2717
|
+
async function gr(e) {
|
|
2718
|
+
let t = mr(e);
|
|
2719
|
+
return t.length > 0 || typeof e != "string" ? t : (await hr(), mr(e));
|
|
2724
2720
|
}
|
|
2725
|
-
function
|
|
2726
|
-
return typeof e == "string" ? document :
|
|
2721
|
+
function _r(e) {
|
|
2722
|
+
return typeof e == "string" ? document : $(e) ? e.getRootNode() : document;
|
|
2727
2723
|
}
|
|
2728
|
-
function
|
|
2724
|
+
function vr(e) {
|
|
2729
2725
|
let { element: t, observe: n, allowEmpty: r, client: i, onReady: a, onResult: o, onSuccess: s, onError: c, onEvent: l, ...u } = e;
|
|
2730
2726
|
return {
|
|
2731
2727
|
mode: "server-rendered",
|
|
2732
2728
|
...u
|
|
2733
2729
|
};
|
|
2734
2730
|
}
|
|
2735
|
-
async function
|
|
2736
|
-
let i = [], a =
|
|
2731
|
+
async function yr(e, t, n, r) {
|
|
2732
|
+
let i = [], a = vr(e);
|
|
2737
2733
|
for (let o of r) {
|
|
2738
2734
|
let r = n.get(o);
|
|
2739
2735
|
if (r) {
|
|
@@ -2743,7 +2739,7 @@ async function gr(e, t, n, r) {
|
|
|
2743
2739
|
let s = await t.mount(o, a), c = [];
|
|
2744
2740
|
if (e.onReady?.(s), c.push(s.on("formie:submit:result", (t) => {
|
|
2745
2741
|
let n = t;
|
|
2746
|
-
e.onResult?.(n, s),
|
|
2742
|
+
e.onResult?.(n, s), dr(n) ? e.onSuccess?.(n, s) : e.onError?.(n, s);
|
|
2747
2743
|
})), e.onEvent) for (let t of l) c.push(s.on(t, (n) => {
|
|
2748
2744
|
e.onEvent?.({
|
|
2749
2745
|
name: t,
|
|
@@ -2757,11 +2753,11 @@ async function gr(e, t, n, r) {
|
|
|
2757
2753
|
}
|
|
2758
2754
|
return i;
|
|
2759
2755
|
}
|
|
2760
|
-
async function
|
|
2761
|
-
let t = e.client ??
|
|
2762
|
-
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${
|
|
2763
|
-
await
|
|
2764
|
-
let i = e.observe ? t.observe(
|
|
2756
|
+
async function br(e) {
|
|
2757
|
+
let t = e.client ?? cr(), n = /* @__PURE__ */ new Map(), r = await gr(e.element);
|
|
2758
|
+
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${fr(e.element)}.`);
|
|
2759
|
+
await yr(e, t, n, r);
|
|
2760
|
+
let i = e.observe ? t.observe(_r(e.element)) : null;
|
|
2765
2761
|
return {
|
|
2766
2762
|
client: t,
|
|
2767
2763
|
get instances() {
|
|
@@ -2772,8 +2768,8 @@ async function _r(e) {
|
|
|
2772
2768
|
return r ? n.get(r)?.instance ?? t.getInstance(r) : null;
|
|
2773
2769
|
},
|
|
2774
2770
|
async rescan() {
|
|
2775
|
-
let r =
|
|
2776
|
-
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) :
|
|
2771
|
+
let r = mr(e.element);
|
|
2772
|
+
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) : yr(e, t, n, r);
|
|
2777
2773
|
},
|
|
2778
2774
|
async destroy() {
|
|
2779
2775
|
i?.();
|
|
@@ -2784,7 +2780,7 @@ async function _r(e) {
|
|
|
2784
2780
|
}
|
|
2785
2781
|
//#endregion
|
|
2786
2782
|
//#region src/js/core/client-rendered-modules.ts
|
|
2787
|
-
var
|
|
2783
|
+
var xr = {
|
|
2788
2784
|
conditions: {
|
|
2789
2785
|
kind: "core",
|
|
2790
2786
|
reason: "Core evaluates structured conditions and the adapter renders visibility."
|
|
@@ -2818,8 +2814,8 @@ var vr = {
|
|
|
2818
2814
|
reason: "The adapter renders the structured date input contract."
|
|
2819
2815
|
}
|
|
2820
2816
|
};
|
|
2821
|
-
async function
|
|
2822
|
-
for (let [e, t] of Object.entries(
|
|
2817
|
+
async function Sr(t, n, r = Wt) {
|
|
2818
|
+
for (let [e, t] of Object.entries(xr)) {
|
|
2823
2819
|
let n = `formie:${e}`;
|
|
2824
2820
|
r.get(n) || r.register({
|
|
2825
2821
|
moduleId: n,
|
|
@@ -2847,7 +2843,7 @@ async function yr(t, n, r = Bt) {
|
|
|
2847
2843
|
}
|
|
2848
2844
|
};
|
|
2849
2845
|
a();
|
|
2850
|
-
let o = n.subscribe(a), s = await
|
|
2846
|
+
let o = n.subscribe(a), s = await ur({
|
|
2851
2847
|
root: t,
|
|
2852
2848
|
modules: n.getState().definition.modules,
|
|
2853
2849
|
surface: "client-rendered",
|
|
@@ -2881,4 +2877,4 @@ async function yr(t, n, r = Bt) {
|
|
|
2881
2877
|
};
|
|
2882
2878
|
}
|
|
2883
2879
|
//#endregion
|
|
2884
|
-
export { l as FORMIE_HTML_EVENT_NAMES,
|
|
2880
|
+
export { l as FORMIE_HTML_EVENT_NAMES, mn as FormieValidator, Ce as LEGACY_FORMIE_DOM_EVENT_BRIDGES, we as LEGACY_FORMIE_VALIDATOR_EVENT_BRIDGES, B as ModuleRegistry, Ae as bindLegacyDomEventCompatibility, Me as bindLegacyValidatorCompatibility, be as buildFieldValueRegistry, Wt as clientRenderedModuleRegistry, O as createDebug, cr as createFormieClient, E as debugLog, D as debugWarn, Se as defineAddressModule, me as defineCaptchaModule, pe as definePassiveCaptchaModule, w as definePaymentModule, _e as fieldKeyToInputName, br as formie, c as getFieldModuleEventName, fe as getFormieTranslations, s as getGlobalModuleLifecycleEventName, i as getScopedModuleLifecycleEventName, ur as hydrateFormieModules, he as inputNameToFieldKey, ne as isFormieDebugEnabled, ue as mergeFormieTranslations, Sr as mountClientRenderedModules, ge as normalizeFieldKey, u as normalizeFormieEventName, ve as parseFieldReference, xe as resolveFieldReferenceFromFormData, ye as resolveFieldReferenceLive, Te as resolveLegacyCompatibilityOptions, te as setFormieDebugEnabled, de as setFormieTranslations, le as t, a as toDomEventName, ce as translate };
|