@verbb/formie-browser 1.0.16 → 1.0.17-next.6.ge714580bc362
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 +4 -0
- package/dist/chunks/{hcaptcha-COilLmRT.js → hcaptcha-lseqzFTP.js} +14 -14
- package/dist/index.js +361 -344
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/submit-result-ui.d.ts.map +1 -1
- package/dist/js/modules/captchas/hcaptcha.d.ts.map +1 -1
- package/dist/js/theme/message-attributes.d.ts +4 -0
- package/dist/js/theme/message-attributes.d.ts.map +1 -0
- package/dist/js/transport/forms-api.d.ts +1 -1
- package/dist/js/transport/forms-api.d.ts.map +1 -1
- package/package.json +6 -4
- package/src/js/core/create-formie-client.ts +15 -3
- package/src/js/core/submit-result-ui.ts +4 -1
- package/src/js/modules/captchas/hcaptcha.ts +3 -2
- package/src/js/theme/message-attributes.ts +54 -0
- package/src/js/transport/forms-api.ts +6 -1
package/dist/index.js
CHANGED
|
@@ -160,10 +160,10 @@ function N(e, t, n) {
|
|
|
160
160
|
detail: n
|
|
161
161
|
}));
|
|
162
162
|
}
|
|
163
|
-
function
|
|
163
|
+
function P(e, t) {
|
|
164
164
|
return !!e && typeof e == "object" && e.validator === t;
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function je({ 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,
|
|
@@ -172,12 +172,12 @@ function Me({ target: e, form: t, validatorDetail: n, options: r, unbinds: i })
|
|
|
172
172
|
};
|
|
173
173
|
N(document, "formieValidatorInitialized", c);
|
|
174
174
|
let l = (e) => {
|
|
175
|
-
e instanceof CustomEvent &&
|
|
175
|
+
e instanceof CustomEvent && P(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 && P(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 Me({ 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 && P(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,38 +199,38 @@ function Me({ 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 Me(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 Ne(e, t) {
|
|
207
207
|
return e === "off" ? null : t ? e : "polite";
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function Pe(e) {
|
|
210
210
|
return e === "off" ? null : e;
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function Fe(e, t) {
|
|
213
213
|
t ? (e.setAttribute("aria-live", t), e.setAttribute("aria-atomic", "true")) : (e.removeAttribute("aria-live"), e.removeAttribute("aria-atomic"));
|
|
214
214
|
}
|
|
215
215
|
//#endregion
|
|
216
216
|
//#region src/js/core/field-error-aria.ts
|
|
217
|
-
function
|
|
217
|
+
function Ie(e, t) {
|
|
218
218
|
let n = (e.getAttribute("aria-describedby") || "").trim(), r = n ? n.split(/\s+/) : [];
|
|
219
219
|
r.includes(t) || r.push(t), e.setAttribute("aria-describedby", r.join(" ").trim());
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function Le(e, t = document) {
|
|
222
222
|
let n = (e.getAttribute("aria-describedby") || "").trim();
|
|
223
223
|
if (!n) return;
|
|
224
224
|
let r = n.split(/\s+/).filter((e) => !!e && !!t.getElementById(e));
|
|
225
225
|
r.length ? e.setAttribute("aria-describedby", r.join(" ")) : e.removeAttribute("aria-describedby");
|
|
226
226
|
}
|
|
227
|
-
function
|
|
228
|
-
e.setAttribute("aria-errormessage", t),
|
|
227
|
+
function Re(e, t) {
|
|
228
|
+
e.setAttribute("aria-errormessage", t), Ie(e, t);
|
|
229
229
|
}
|
|
230
230
|
function ze(e, t = []) {
|
|
231
231
|
t.forEach((t) => {
|
|
232
232
|
e.getAttribute("aria-errormessage") === t && e.removeAttribute("aria-errormessage");
|
|
233
|
-
}), !t.length && e.hasAttribute("aria-errormessage") && e.removeAttribute("aria-errormessage"),
|
|
233
|
+
}), !t.length && e.hasAttribute("aria-errormessage") && e.removeAttribute("aria-errormessage"), Le(e);
|
|
234
234
|
}
|
|
235
235
|
//#endregion
|
|
236
236
|
//#region src/js/core/validation-focus.ts
|
|
@@ -262,9 +262,9 @@ function We(e) {
|
|
|
262
262
|
n.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
263
263
|
let i = t;
|
|
264
264
|
if (j(i)) return;
|
|
265
|
-
i.setAttribute("aria-invalid", "true"), A(i, e, "fieldControlError"), i.setAttribute("data-formie-input-has-error", "true"), r &&
|
|
265
|
+
i.setAttribute("aria-invalid", "true"), A(i, e, "fieldControlError"), i.setAttribute("data-formie-input-has-error", "true"), r && Re(i, r);
|
|
266
266
|
let a = n.querySelector("[data-formie-instructions]");
|
|
267
|
-
a?.id &&
|
|
267
|
+
a?.id && Ie(i, a.id);
|
|
268
268
|
});
|
|
269
269
|
});
|
|
270
270
|
}
|
|
@@ -392,15 +392,15 @@ async function Ye(e, t, n = {}, r = {}) {
|
|
|
392
392
|
let o = a.data.formieHtmlForm;
|
|
393
393
|
return I.log("requestGraphqlRender complete.", { hasHtml: !!o.html }), o;
|
|
394
394
|
}
|
|
395
|
-
async function Xe(e, t, n, r = {}, i) {
|
|
396
|
-
let
|
|
397
|
-
|
|
398
|
-
endpoint:
|
|
395
|
+
async function Xe(e, t, n, r = {}, i, a) {
|
|
396
|
+
let o = new URL(e, window.location.origin);
|
|
397
|
+
o.searchParams.set("handle", t), a !== void 0 && a !== "" && o.searchParams.set("siteId", String(a)), n && o.searchParams.set("renderId", n), i && o.searchParams.set("requestToken", i), I.log("requestRefreshTokens start.", {
|
|
398
|
+
endpoint: o.toString(),
|
|
399
399
|
handle: t,
|
|
400
400
|
hasRenderId: !!n
|
|
401
401
|
});
|
|
402
|
-
let
|
|
403
|
-
return I.log("requestRefreshTokens complete.", { hasRefreshTokens: !!
|
|
402
|
+
let s = await M(o.toString(), r);
|
|
403
|
+
return I.log("requestRefreshTokens complete.", { hasRefreshTokens: !!s.refreshTokens }), s.refreshTokens || s;
|
|
404
404
|
}
|
|
405
405
|
async function Ze(e, t, n) {
|
|
406
406
|
let r = new URL(e, window.location.origin), i = new FormData();
|
|
@@ -776,63 +776,80 @@ function pt(e, t) {
|
|
|
776
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;
|
|
777
777
|
}
|
|
778
778
|
//#endregion
|
|
779
|
+
//#region src/js/theme/message-attributes.ts
|
|
780
|
+
function mt(e, t, n, r = !1) {
|
|
781
|
+
let i = t.getAttribute("data-formie-message-attributes");
|
|
782
|
+
if (!i) return;
|
|
783
|
+
let a;
|
|
784
|
+
try {
|
|
785
|
+
a = JSON.parse(i);
|
|
786
|
+
} catch {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
if (!a || typeof a != "object" || Array.isArray(a)) return;
|
|
790
|
+
let o = a[n];
|
|
791
|
+
o && typeof o == "object" && !Array.isArray(o) && Object.entries(o).forEach(([t, n]) => {
|
|
792
|
+
t === "class" || !/^[^\s"'<>/=]+$/.test(t) || typeof n != "string" && n !== !0 || (r ? e.removeAttribute(t) : e.setAttribute(t, n === !0 ? "" : n));
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
//#endregion
|
|
779
796
|
//#region src/js/core/submit-result-ui.ts
|
|
780
797
|
var R = /* @__PURE__ */ new WeakMap();
|
|
781
|
-
function
|
|
798
|
+
function ht(e) {
|
|
782
799
|
return (e.dataset.formieCompletionBehavior || e.dataset.formieSubmitAction || "").trim();
|
|
783
800
|
}
|
|
784
|
-
function
|
|
801
|
+
function gt(e) {
|
|
785
802
|
return (e.dataset.formieErrorMessagePosition || "top-form").trim() || "top-form";
|
|
786
803
|
}
|
|
787
|
-
function
|
|
804
|
+
function _t(e) {
|
|
788
805
|
return (e.dataset.formieSuccessMessagePosition || e.dataset.formieSubmitActionMessagePosition || "").trim();
|
|
789
806
|
}
|
|
790
|
-
function
|
|
807
|
+
function vt(e) {
|
|
791
808
|
let t = (e.dataset.formieSuccessMessageTimeout || e.dataset.formieSubmitActionMessageTimeout || "").trim();
|
|
792
809
|
if (!t) return null;
|
|
793
810
|
let n = Number.parseFloat(t);
|
|
794
811
|
return !Number.isFinite(n) || n < 0 ? null : Math.round(n * 1e3);
|
|
795
812
|
}
|
|
796
|
-
function
|
|
813
|
+
function yt(e) {
|
|
797
814
|
let t = e.dataset.formieHideFormAfterSubmit ?? e.dataset.formieSubmitActionFormHide;
|
|
798
815
|
if (t === void 0) return !1;
|
|
799
816
|
let n = t.trim().toLowerCase();
|
|
800
817
|
return n === "true" || n === "1" || n === "";
|
|
801
818
|
}
|
|
802
|
-
function
|
|
819
|
+
function bt(e) {
|
|
803
820
|
let t = R.get(e);
|
|
804
821
|
typeof t == "number" && (window.clearTimeout(t), R.delete(e));
|
|
805
822
|
}
|
|
806
|
-
function
|
|
823
|
+
function xt(e) {
|
|
807
824
|
return e.querySelector("[data-formie-form-messages-top]") || e;
|
|
808
825
|
}
|
|
809
|
-
function
|
|
826
|
+
function St(e) {
|
|
810
827
|
return e.querySelector("[data-formie-form-messages-bottom]") || e;
|
|
811
828
|
}
|
|
812
|
-
function St(e, t) {
|
|
813
|
-
return t === "bottom-form" ? xt(e) : bt(e);
|
|
814
|
-
}
|
|
815
829
|
function Ct(e, t) {
|
|
816
|
-
return t === "
|
|
830
|
+
return t === "bottom-form" ? St(e) : xt(e);
|
|
831
|
+
}
|
|
832
|
+
function wt(e, t) {
|
|
833
|
+
return t === "top-form" ? xt(e) : t === "bottom-form" && !yt(e) ? St(e) : e;
|
|
817
834
|
}
|
|
818
|
-
function
|
|
819
|
-
let t =
|
|
835
|
+
function Tt(e) {
|
|
836
|
+
let t = gt(e), n = Ct(e, t), r = n.querySelector("[data-formie-error-container], [data-formie-errors]");
|
|
820
837
|
return r || (r = document.createElement("div"), r.setAttribute("data-formie-errors", "true"), A(r, e, "errors")), r.setAttribute("data-formie-error-container", "true"), t === "bottom-form" ? n.append(r) : n.prepend(r), r;
|
|
821
838
|
}
|
|
822
|
-
function
|
|
839
|
+
function Et(e, t) {
|
|
823
840
|
let n = t.querySelector("[data-formie-error-message-container], [data-formie-message][data-formie-message-error]");
|
|
824
|
-
return n || (n = document.createElement("div"), n.setAttribute("data-formie-error-message-container", "true"), t.appendChild(n)), n.setAttribute("data-formie-message", "true"), n.setAttribute("data-formie-message-error", "true"), A(n, e, "message", "messageError"), n.setAttribute("role", "alert"),
|
|
841
|
+
return n || (n = document.createElement("div"), n.setAttribute("data-formie-error-message-container", "true"), t.appendChild(n)), mt(n, e, "messageError"), n.setAttribute("data-formie-message", "true"), n.setAttribute("data-formie-message-error", "true"), A(n, e, "message", "messageError"), n.setAttribute("role", "alert"), Fe(n, Pe(Me(e))), n;
|
|
825
842
|
}
|
|
826
|
-
function
|
|
827
|
-
let n = e.querySelector("[data-formie-success-container]"), r =
|
|
843
|
+
function Dt(e, t) {
|
|
844
|
+
let n = e.querySelector("[data-formie-success-container]"), r = wt(e, t);
|
|
828
845
|
return n || (n = document.createElement("div"), n.setAttribute("data-formie-success-container", "true"), A(n, e, "successes")), t === "bottom-form" ? r.append(n) : r.prepend(n), n;
|
|
829
846
|
}
|
|
830
|
-
function
|
|
847
|
+
function Ot(e) {
|
|
831
848
|
return pt(e, (t) => {
|
|
832
849
|
A(t, e, "fieldErrors");
|
|
833
850
|
});
|
|
834
851
|
}
|
|
835
|
-
function
|
|
852
|
+
function kt(e) {
|
|
836
853
|
e.querySelectorAll("[data-formie-field-handle]").forEach((t) => {
|
|
837
854
|
let n = t, r = n.querySelector("[data-formie-field-errors]"), i = Array.from(n.querySelectorAll("[data-formie-field-error]")).map((e) => e.id).filter(Boolean);
|
|
838
855
|
k(n, e, "fieldLayoutError"), n.removeAttribute("data-formie-field-has-error"), n.querySelectorAll("[data-formie-field-error]").forEach((e) => {
|
|
@@ -843,7 +860,7 @@ function Ot(e) {
|
|
|
843
860
|
});
|
|
844
861
|
}), h(e);
|
|
845
862
|
}
|
|
846
|
-
function
|
|
863
|
+
function At(e) {
|
|
847
864
|
e.querySelectorAll("[data-formie-error-container], [data-formie-errors]").forEach((t) => {
|
|
848
865
|
let n = t;
|
|
849
866
|
n.querySelectorAll("[data-formie-error]").forEach((e) => {
|
|
@@ -851,68 +868,68 @@ function kt(e) {
|
|
|
851
868
|
}), k(n, e, "message", "messageError"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-error"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-error]") || (n.innerHTML = "");
|
|
852
869
|
});
|
|
853
870
|
}
|
|
854
|
-
function
|
|
855
|
-
|
|
871
|
+
function jt(e) {
|
|
872
|
+
bt(e), e.querySelectorAll("[data-formie-message-success]:not([data-formie-success-container])").forEach((e) => {
|
|
856
873
|
e.remove();
|
|
857
874
|
}), e.querySelectorAll("[data-formie-success-container]").forEach((t) => {
|
|
858
875
|
let n = t;
|
|
859
876
|
n.querySelectorAll("[data-formie-success]").forEach((e) => {
|
|
860
877
|
e.remove();
|
|
861
|
-
}), k(n, e, "message", "messageSuccess"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-success"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-success]") || (n.innerHTML = "");
|
|
862
|
-
}),
|
|
878
|
+
}), mt(n, e, "messageSuccess", !0), k(n, e, "message", "messageSuccess"), n.removeAttribute("data-formie-message"), n.removeAttribute("data-formie-message-success"), n.removeAttribute("role"), n.removeAttribute("aria-live"), n.removeAttribute("aria-atomic"), n.querySelector("[data-formie-success]") || (n.innerHTML = "");
|
|
879
|
+
}), ht(e) === "message" && yt(e) || b(e, !1);
|
|
863
880
|
}
|
|
864
|
-
function
|
|
881
|
+
function Mt(e) {
|
|
865
882
|
e.querySelectorAll("[aria-invalid=\"true\"]").forEach((e) => {
|
|
866
883
|
e.removeAttribute("aria-invalid");
|
|
867
884
|
});
|
|
868
885
|
}
|
|
869
|
-
function
|
|
870
|
-
let n =
|
|
886
|
+
function Nt(e, t) {
|
|
887
|
+
let n = Pe(Me(e));
|
|
871
888
|
Object.entries(t).forEach(([t, r]) => {
|
|
872
889
|
let i = `fields[${t.split(".").join("][")}]`, a = e.querySelector(`[name="${CSS.escape(i)}"], [name="${CSS.escape(i + "[]")}"]`)?.closest("[data-formie-field-handle]") || e.querySelector(`[data-formie-field-handle="${CSS.escape(t)}"]`);
|
|
873
890
|
if (!a) return;
|
|
874
|
-
let o =
|
|
875
|
-
o.id = s,
|
|
891
|
+
let o = Ot(a), s = o.id && o.id.trim() ? o.id : `${t}-errors`;
|
|
892
|
+
o.id = s, Fe(o, n), A(a, e, "fieldLayoutError"), a.setAttribute("data-formie-field-has-error", "true"), r.forEach((t, n) => {
|
|
876
893
|
let r = document.createElement("div");
|
|
877
894
|
r.setAttribute("data-formie-field-error", "true"), r.id = `${s}-${n + 1}`, A(r, e, "fieldError"), r.textContent = t, o.appendChild(r);
|
|
878
895
|
});
|
|
879
896
|
let c = o.querySelector("[data-formie-field-error]")?.id;
|
|
880
897
|
a.querySelectorAll("input, select, textarea").forEach((t) => {
|
|
881
898
|
let n = t;
|
|
882
|
-
n.setAttribute("aria-invalid", "true"), A(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), c &&
|
|
899
|
+
n.setAttribute("aria-invalid", "true"), A(n, e, "fieldControlError"), n.setAttribute("data-formie-input-has-error", "true"), c && Re(n, c);
|
|
883
900
|
let r = a.querySelector("[data-formie-instructions]");
|
|
884
|
-
r?.id &&
|
|
901
|
+
r?.id && Ie(n, r.id);
|
|
885
902
|
});
|
|
886
903
|
}), h(e);
|
|
887
904
|
}
|
|
888
|
-
function
|
|
889
|
-
let n =
|
|
905
|
+
function Pt(e, t) {
|
|
906
|
+
let n = Tt(e), r = Et(e, n);
|
|
890
907
|
A(n, e, "errors"), t.forEach((t) => {
|
|
891
908
|
let n = document.createElement("div");
|
|
892
|
-
n.setAttribute("data-formie-error", "true"),
|
|
909
|
+
n.setAttribute("data-formie-error", "true"), A(n, e, "error"), n.innerHTML = t, r.appendChild(n);
|
|
893
910
|
});
|
|
894
911
|
}
|
|
895
|
-
function
|
|
912
|
+
function Ft(e) {
|
|
896
913
|
if (e.ok || e.keepSubmitLoading !== !0) return !1;
|
|
897
914
|
let t = e.payment?.status;
|
|
898
915
|
return t === "requiresAction" || t === "pending" || t === "unknown";
|
|
899
916
|
}
|
|
900
|
-
function
|
|
901
|
-
let n =
|
|
917
|
+
function It(e, t) {
|
|
918
|
+
let n = Tt(e), r = Et(e, n);
|
|
902
919
|
A(n, e, "errors");
|
|
903
920
|
let i = document.createElement("div");
|
|
904
921
|
i.setAttribute("data-formie-notice", "true"), i.setAttribute("role", "status"), A(i, e, "message"), i.textContent = t, r.appendChild(i);
|
|
905
922
|
}
|
|
906
|
-
function
|
|
907
|
-
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" ||
|
|
923
|
+
function Lt(e, t) {
|
|
924
|
+
return !t.message || t.nextPage || t.redirect ? !1 : t.action === "save" || ht(e) === "message" && _t(e) !== "";
|
|
908
925
|
}
|
|
909
|
-
function
|
|
910
|
-
let r =
|
|
926
|
+
function Rt(e, t, n = {}) {
|
|
927
|
+
let r = _t(e);
|
|
911
928
|
if (!r) return;
|
|
912
|
-
let i =
|
|
913
|
-
A(i, e, "message", "messageSuccess"), i.setAttribute("data-formie-message", "true"), i.setAttribute("data-formie-message-success", "true"), i.setAttribute("role", "status"), i.setAttribute("aria-live", "polite"), i.setAttribute("aria-atomic", "true");
|
|
929
|
+
let i = Dt(e, r);
|
|
930
|
+
mt(i, e, "messageSuccess"), A(i, e, "message", "messageSuccess"), i.setAttribute("data-formie-message", "true"), i.setAttribute("data-formie-message-success", "true"), i.setAttribute("role", "status"), i.setAttribute("aria-live", "polite"), i.setAttribute("aria-atomic", "true");
|
|
914
931
|
let a = document.createElement("div");
|
|
915
|
-
a.setAttribute("data-formie-success", "true"), A(a, e, "success"), a.innerHTML = t, i.appendChild(a), n.hideForm !== !1 &&
|
|
932
|
+
a.setAttribute("data-formie-success", "true"), A(a, e, "success"), a.innerHTML = t, i.appendChild(a), n.hideForm !== !1 && yt(e) && b(e, !0);
|
|
916
933
|
let o = e.dataset.formieScrollToTop?.trim().toLowerCase();
|
|
917
934
|
o !== void 0 && [
|
|
918
935
|
"",
|
|
@@ -922,45 +939,45 @@ function Lt(e, t, n = {}) {
|
|
|
922
939
|
behavior: "smooth",
|
|
923
940
|
block: "start"
|
|
924
941
|
});
|
|
925
|
-
let s =
|
|
942
|
+
let s = vt(e);
|
|
926
943
|
if (s !== null) {
|
|
927
944
|
let t = window.setTimeout(() => {
|
|
928
|
-
R.delete(e),
|
|
945
|
+
R.delete(e), jt(e);
|
|
929
946
|
}, s);
|
|
930
947
|
R.set(e, t);
|
|
931
948
|
}
|
|
932
949
|
}
|
|
933
950
|
function z(e, t) {
|
|
934
|
-
if (
|
|
951
|
+
if (kt(e), At(e), jt(e), Mt(e), t.ok) {
|
|
935
952
|
let n = t.meta?.summaryTokens;
|
|
936
953
|
n && typeof n == "object" && e.querySelectorAll("[data-formie-field-uid]").forEach((e) => {
|
|
937
954
|
let t = n[e.dataset.formieFieldUid || ""];
|
|
938
955
|
typeof t == "string" && t && e.querySelector("[data-formie-summary-container]")?.setAttribute("data-formie-summary-token", t);
|
|
939
|
-
}),
|
|
956
|
+
}), Lt(e, t) && Rt(e, t.message || "", { hideForm: t.action !== "save" });
|
|
940
957
|
} else if (!t.ok) {
|
|
941
|
-
if (
|
|
958
|
+
if (Ft(t)) {
|
|
942
959
|
let n = String(t.payment?.message || "").trim();
|
|
943
|
-
n &&
|
|
960
|
+
n && It(e, n);
|
|
944
961
|
return;
|
|
945
962
|
}
|
|
946
|
-
t.fieldErrors &&
|
|
963
|
+
t.fieldErrors && Nt(e, t.fieldErrors), t.formErrors?.length ? Pt(e, t.formErrors) : !t.fieldErrors && t.message && Pt(e, [t.message]), F(e);
|
|
947
964
|
}
|
|
948
965
|
}
|
|
949
966
|
//#endregion
|
|
950
967
|
//#region src/js/core/submit-flow.ts
|
|
951
|
-
var
|
|
952
|
-
function
|
|
968
|
+
var zt = O("general", "submit-flow");
|
|
969
|
+
function Bt(e) {
|
|
953
970
|
return !(!e.ok && e.stage === "validate");
|
|
954
971
|
}
|
|
955
|
-
function
|
|
972
|
+
function Vt(e) {
|
|
956
973
|
return e ? !!(e.keepSubmitLoading === !0 || e.ok && e.redirect?.url && e.redirect.target !== "new-tab") : !1;
|
|
957
974
|
}
|
|
958
|
-
function
|
|
959
|
-
|
|
975
|
+
function Ht(e) {
|
|
976
|
+
kt(e), At(e), jt(e), Mt(e);
|
|
960
977
|
}
|
|
961
|
-
async function
|
|
978
|
+
async function Ut(e) {
|
|
962
979
|
let { id: t, target: n, form: r, bus: i, validator: a, validateOnSubmit: o, action: s, submitter: c, waitForSubmitDelay: l, onRefreshTokensAfterSubmit: u, dispatchSubmitResult: d } = e;
|
|
963
|
-
|
|
980
|
+
Ht(r), C(r, c || null);
|
|
964
981
|
let p = {
|
|
965
982
|
ok: !1,
|
|
966
983
|
code: "SUBMIT_ERROR",
|
|
@@ -971,27 +988,27 @@ async function Ht(e) {
|
|
|
971
988
|
await l(r), p = await dt(r, s, i, {
|
|
972
989
|
validator: a,
|
|
973
990
|
validateOnSubmit: o
|
|
974
|
-
}), z(r, p), d(p), v(r, p, s),
|
|
991
|
+
}), z(r, p), d(p), v(r, p, s), Bt(p) && await u(p);
|
|
975
992
|
} catch (e) {
|
|
976
993
|
p = {
|
|
977
994
|
ok: !1,
|
|
978
995
|
code: "SUBMIT_ERROR",
|
|
979
996
|
message: e instanceof Error ? e.message : "Submission failed.",
|
|
980
997
|
formErrors: [e instanceof Error ? e.message : "Submission failed."]
|
|
981
|
-
}, z(r, p), d(p),
|
|
998
|
+
}, z(r, p), d(p), zt.warn("Submit failed with exception.", {
|
|
982
999
|
id: t,
|
|
983
1000
|
action: s,
|
|
984
1001
|
target: n,
|
|
985
1002
|
error: e instanceof Error ? e.message : e
|
|
986
1003
|
});
|
|
987
1004
|
} finally {
|
|
988
|
-
|
|
1005
|
+
Vt(p) || f(r);
|
|
989
1006
|
}
|
|
990
1007
|
return p;
|
|
991
1008
|
}
|
|
992
1009
|
//#endregion
|
|
993
1010
|
//#region src/js/events/event-bus.ts
|
|
994
|
-
var
|
|
1011
|
+
var Wt = class {
|
|
995
1012
|
listeners = /* @__PURE__ */ new Map();
|
|
996
1013
|
on(e, t) {
|
|
997
1014
|
return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e)?.add(t), () => {
|
|
@@ -1067,23 +1084,23 @@ var Ut = class {
|
|
|
1067
1084
|
getAll() {
|
|
1068
1085
|
return Array.from(this.modules.values());
|
|
1069
1086
|
}
|
|
1070
|
-
},
|
|
1087
|
+
}, Gt = new B(), Kt = {
|
|
1071
1088
|
"address-finder": () => import("./chunks/address-finder-QK1m1eyv.js").then((e) => e.addressFinderModule),
|
|
1072
1089
|
"google-address": () => import("./chunks/google-address-DQR6rsbh.js").then((e) => e.googleAddressModule),
|
|
1073
1090
|
loqate: () => import("./chunks/loqate-ZZClcacr.js").then((e) => e.loqateModule),
|
|
1074
1091
|
"place-kit": () => import("./chunks/place-kit-BKk8xDXf.js").then((e) => e.placeKitModule)
|
|
1075
|
-
},
|
|
1092
|
+
}, qt = {
|
|
1076
1093
|
"captcha-eu": () => import("./chunks/captcha-eu-eU_M6snp.js").then((e) => e.captchaEuModule),
|
|
1077
1094
|
"friendly-captcha-v1": () => import("./chunks/friendly-captcha-v1-C_cF1WD2.js").then((e) => e.friendlyCaptchaV1Module),
|
|
1078
1095
|
"friendly-captcha-v2": () => import("./chunks/friendly-captcha-v2-BenESH-n.js").then((e) => e.friendlyCaptchaV2Module),
|
|
1079
|
-
hcaptcha: () => import("./chunks/hcaptcha-
|
|
1096
|
+
hcaptcha: () => import("./chunks/hcaptcha-lseqzFTP.js").then((e) => e.hcaptchaModule),
|
|
1080
1097
|
"recaptcha-enterprise": () => import("./chunks/recaptcha-enterprise-Cx6HUpMa.js").then((e) => e.recaptchaEnterpriseModule),
|
|
1081
1098
|
"recaptcha-v2-checkbox": () => import("./chunks/recaptcha-v2-checkbox-DQ9BJzcv.js").then((e) => e.recaptchaV2CheckboxModule),
|
|
1082
1099
|
"recaptcha-v2-invisible": () => import("./chunks/recaptcha-v2-invisible-BP0T8Pan.js").then((e) => e.recaptchaV2InvisibleModule),
|
|
1083
1100
|
"recaptcha-v3": () => import("./chunks/recaptcha-v3-DKMGQ27K.js").then((e) => e.recaptchaV3Module),
|
|
1084
1101
|
snaptcha: () => import("./chunks/snaptcha-P3EoSQud.js").then((e) => e.snaptchaModule),
|
|
1085
1102
|
turnstile: () => import("./chunks/turnstile-Sp4ubowK.js").then((e) => e.turnstileModule)
|
|
1086
|
-
},
|
|
1103
|
+
}, Jt = {
|
|
1087
1104
|
calculations: () => import("./chunks/calculations-DeEmdUDq.js").then((e) => e.calculationsModule),
|
|
1088
1105
|
"checkbox-radio": () => import("./chunks/checkbox-radio-CSXo6svm.js").then((e) => e.checkboxRadioModule),
|
|
1089
1106
|
combobox: () => import("./chunks/combobox-CJh2DoSO.js").then((e) => e.comboboxModule),
|
|
@@ -1108,7 +1125,7 @@ var Ut = class {
|
|
|
1108
1125
|
"survey-rating": () => import("./chunks/survey-rating-mlDMI0uq.js").then((e) => e.surveyRatingModule),
|
|
1109
1126
|
table: () => import("./chunks/table-0k6Md0IO.js").then((e) => e.tableModule),
|
|
1110
1127
|
"text-limit": () => import("./chunks/text-limit-CTVML6s7.js").then((e) => e.textLimitModule)
|
|
1111
|
-
},
|
|
1128
|
+
}, Yt = {
|
|
1112
1129
|
bpoint: () => import("./chunks/bpoint-GvYfyPjD.js").then((e) => e.bpointModule),
|
|
1113
1130
|
eway: () => import("./chunks/eway-BZuTBAUW.js").then((e) => e.ewayModule),
|
|
1114
1131
|
"go-cardless": () => import("./chunks/go-cardless-DWZeB0Bq.js").then((e) => e.goCardlessModule),
|
|
@@ -1120,13 +1137,13 @@ var Ut = class {
|
|
|
1120
1137
|
payway: () => import("./chunks/payway-vxC7_bfR.js").then((e) => e.paywayModule),
|
|
1121
1138
|
square: () => import("./chunks/square-Dyz0p_GU.js").then((e) => e.squareModule),
|
|
1122
1139
|
stripe: () => import("./chunks/stripe-Bfd_jp_k.js").then((e) => e.stripeModule)
|
|
1123
|
-
},
|
|
1124
|
-
...
|
|
1125
|
-
...Gt,
|
|
1140
|
+
}, Xt = {
|
|
1141
|
+
...Jt,
|
|
1126
1142
|
...Kt,
|
|
1127
|
-
...
|
|
1143
|
+
...qt,
|
|
1144
|
+
...Yt
|
|
1128
1145
|
}, V = /* @__PURE__ */ new Map();
|
|
1129
|
-
function
|
|
1146
|
+
function Zt(e) {
|
|
1130
1147
|
if (e instanceof Error) return {
|
|
1131
1148
|
name: e.name || "Error",
|
|
1132
1149
|
message: e.message || "No error message was provided.",
|
|
@@ -1148,7 +1165,7 @@ function Xt(e) {
|
|
|
1148
1165
|
};
|
|
1149
1166
|
}
|
|
1150
1167
|
}
|
|
1151
|
-
function
|
|
1168
|
+
function Qt(e, t, n) {
|
|
1152
1169
|
let r = [...t].filter((e) => e.required), i = [
|
|
1153
1170
|
"Formie browser module diagnostics",
|
|
1154
1171
|
`Surface: ${e}`,
|
|
@@ -1159,7 +1176,7 @@ function Zt(e, t, n) {
|
|
|
1159
1176
|
i.push("", `Failure ${r + 1}`, `Module: ${t.moduleId}`, `Key: ${t.key}`, `Code: ${t.code}`), e === "cp-edit" && a && (i.push(`Error: ${a.name}: ${a.message}`), a.stack && i.push("Stack:", a.stack));
|
|
1160
1177
|
}), i.join("\n");
|
|
1161
1178
|
}
|
|
1162
|
-
async function
|
|
1179
|
+
async function $t(e) {
|
|
1163
1180
|
if (navigator.clipboard?.writeText) {
|
|
1164
1181
|
await navigator.clipboard.writeText(e);
|
|
1165
1182
|
return;
|
|
@@ -1172,10 +1189,10 @@ async function Qt(e) {
|
|
|
1172
1189
|
t.remove();
|
|
1173
1190
|
}
|
|
1174
1191
|
}
|
|
1175
|
-
async function
|
|
1192
|
+
async function en(e, t) {
|
|
1176
1193
|
let n = t.get(e);
|
|
1177
1194
|
if (n) return n;
|
|
1178
|
-
let r = e.startsWith("formie:") && Object.prototype.hasOwnProperty.call(
|
|
1195
|
+
let r = e.startsWith("formie:") && Object.prototype.hasOwnProperty.call(Xt, e.slice(7)) ? Xt[e.slice(7)] : void 0;
|
|
1179
1196
|
if (!r) throw Error(`Browser module ${e} is not registered.`);
|
|
1180
1197
|
V.has(e) || V.set(e, r().catch((t) => {
|
|
1181
1198
|
throw V.delete(e), t;
|
|
@@ -1184,14 +1201,14 @@ async function $t(e, t) {
|
|
|
1184
1201
|
if (i.moduleId !== e) throw Error(`Module definition does not match ${e}.`);
|
|
1185
1202
|
return t.register(i), i;
|
|
1186
1203
|
}
|
|
1187
|
-
function
|
|
1204
|
+
function tn(e, t, n) {
|
|
1188
1205
|
return [...new Set(e.targets.flatMap((e) => {
|
|
1189
1206
|
if (e.type === "form") return [n || t];
|
|
1190
1207
|
let r = e.type === "selector" ? e.selector : e.type === "field" ? `[data-formie-field-uid="${CSS.escape(e.uid)}"]` : e.type === "page" ? `[data-formie-page-id="${CSS.escape(e.id)}"]` : `[data-formie-action="${CSS.escape(e.action)}"]`;
|
|
1191
1208
|
return [...t.matches(r) ? [t] : [], ...t.querySelectorAll(r)];
|
|
1192
1209
|
}))].filter((e) => !e.closest("[hidden], [data-formie-hidden=\"true\"], [data-formie-conditionally-hidden], [data-formie-page-hidden]"));
|
|
1193
1210
|
}
|
|
1194
|
-
async function
|
|
1211
|
+
async function nn(e, t) {
|
|
1195
1212
|
n(e);
|
|
1196
1213
|
let r = e.surface;
|
|
1197
1214
|
if (t.matchContext.surface !== r || t.setupContext.surface !== r) throw Error(`Browser module manifest surface ${r} cannot mount as ${t.matchContext.surface}.`);
|
|
@@ -1204,7 +1221,7 @@ async function tn(e, t) {
|
|
|
1204
1221
|
code: "MODULE_UNAVAILABLE",
|
|
1205
1222
|
message: "A form feature could not start. Reload the page or contact the site administrator."
|
|
1206
1223
|
};
|
|
1207
|
-
s.set(e.key, i), c.set(e.key,
|
|
1224
|
+
s.set(e.key, i), c.set(e.key, Zt(n)), console.error("[formie] Browser module failure", i, n), await t.setupContext.emit("formie:browser:module:error", i);
|
|
1208
1225
|
}, m = async (e) => {
|
|
1209
1226
|
try {
|
|
1210
1227
|
await e.destroy();
|
|
@@ -1246,7 +1263,7 @@ async function tn(e, t) {
|
|
|
1246
1263
|
let d = document.createElement("span");
|
|
1247
1264
|
d.className = "formie-module-error__copy-status", d.setAttribute("role", "status"), d.setAttribute("aria-live", "polite"), u.addEventListener("click", async () => {
|
|
1248
1265
|
try {
|
|
1249
|
-
await
|
|
1266
|
+
await $t(n.textContent || ""), d.textContent = "Details copied.";
|
|
1250
1267
|
} catch {
|
|
1251
1268
|
d.textContent = "Copy failed. Select the details above and copy them manually.";
|
|
1252
1269
|
let e = document.createRange();
|
|
@@ -1256,7 +1273,7 @@ async function tn(e, t) {
|
|
|
1256
1273
|
}
|
|
1257
1274
|
e.dataset.formieModuleError = "true", i !== a && a.contains(i) ? i.before(e) : a.prepend(e);
|
|
1258
1275
|
}
|
|
1259
|
-
let t = e.querySelector("[data-formie-module-error-details]"), n =
|
|
1276
|
+
let t = e.querySelector("[data-formie-module-error-details]"), n = Qt(r, s.values(), c);
|
|
1260
1277
|
t && t.textContent !== n && (t.textContent = n);
|
|
1261
1278
|
}, _ = (e) => {
|
|
1262
1279
|
h() && (e.preventDefault(), e.stopImmediatePropagation(), g());
|
|
@@ -1275,7 +1292,7 @@ async function tn(e, t) {
|
|
|
1275
1292
|
});
|
|
1276
1293
|
let d;
|
|
1277
1294
|
try {
|
|
1278
|
-
d =
|
|
1295
|
+
d = tn(n, i, a);
|
|
1279
1296
|
} catch (e) {
|
|
1280
1297
|
s.has(n.key) || await p(n, e);
|
|
1281
1298
|
continue;
|
|
@@ -1285,7 +1302,7 @@ async function tn(e, t) {
|
|
|
1285
1302
|
for (let [e, t] of Array.from(f.entries()).reverse()) d.includes(e) || (await m(t.instance), f.delete(e), l.splice(l.indexOf(t.instance), 1));
|
|
1286
1303
|
let h;
|
|
1287
1304
|
try {
|
|
1288
|
-
h = await
|
|
1305
|
+
h = await en(n.moduleId, t.registry);
|
|
1289
1306
|
} catch (e) {
|
|
1290
1307
|
s.has(n.key) || await p(n, e);
|
|
1291
1308
|
continue;
|
|
@@ -1409,7 +1426,7 @@ async function tn(e, t) {
|
|
|
1409
1426
|
}
|
|
1410
1427
|
//#endregion
|
|
1411
1428
|
//#region src/js/utils/unload-warning.ts
|
|
1412
|
-
var
|
|
1429
|
+
var rn = /* @__PURE__ */ new Set([
|
|
1413
1430
|
"action",
|
|
1414
1431
|
"redirect",
|
|
1415
1432
|
"requestToken",
|
|
@@ -1422,7 +1439,7 @@ var nn = /* @__PURE__ */ new Set([
|
|
|
1422
1439
|
"draftContext",
|
|
1423
1440
|
"progressId"
|
|
1424
1441
|
]);
|
|
1425
|
-
function
|
|
1442
|
+
function an(e) {
|
|
1426
1443
|
let t = /* @__PURE__ */ new Set(), n = !0;
|
|
1427
1444
|
return g(e, "formie:unload-warning:collect-exclusions", {
|
|
1428
1445
|
form: e,
|
|
@@ -1433,40 +1450,40 @@ function rn(e) {
|
|
|
1433
1450
|
}
|
|
1434
1451
|
}), n = !1, t;
|
|
1435
1452
|
}
|
|
1436
|
-
function
|
|
1453
|
+
function on(e, t) {
|
|
1437
1454
|
if (e == null) return String(e);
|
|
1438
1455
|
if (typeof e == "string") return JSON.stringify(e);
|
|
1439
1456
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1440
1457
|
if (typeof e == "function") return "[function]";
|
|
1441
1458
|
if (typeof File < "u" && e instanceof File) return `[file:${e.name}:${e.size}:${e.type}]`;
|
|
1442
1459
|
if (typeof Blob < "u" && e instanceof Blob) return `[blob:${e.size}:${e.type}]`;
|
|
1443
|
-
if (Array.isArray(e)) return `[${e.map((e) =>
|
|
1460
|
+
if (Array.isArray(e)) return `[${e.map((e) => on(e, t)).join(",")}]`;
|
|
1444
1461
|
if (typeof e == "object") {
|
|
1445
1462
|
if (t.has(e)) return "[circular]";
|
|
1446
1463
|
t.add(e);
|
|
1447
|
-
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${
|
|
1464
|
+
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${on(n, t)}`);
|
|
1448
1465
|
return t.delete(e), `{${n.join(",")}}`;
|
|
1449
1466
|
}
|
|
1450
1467
|
return JSON.stringify(String(e));
|
|
1451
1468
|
}
|
|
1452
|
-
function
|
|
1453
|
-
return
|
|
1469
|
+
function sn(e) {
|
|
1470
|
+
return on(e, /* @__PURE__ */ new WeakSet());
|
|
1454
1471
|
}
|
|
1455
|
-
function
|
|
1472
|
+
function cn(e, t) {
|
|
1456
1473
|
if (!e) return !1;
|
|
1457
1474
|
let n = e.endsWith("[]") ? e.slice(0, -2) : e;
|
|
1458
|
-
return !ie(n, t) && !
|
|
1475
|
+
return !ie(n, t) && !rn.has(n);
|
|
1459
1476
|
}
|
|
1460
|
-
function
|
|
1461
|
-
return
|
|
1477
|
+
function ln(e, t, n) {
|
|
1478
|
+
return sn(e.filter(([e]) => !n.has(e) && cn(String(e || ""), t)));
|
|
1462
1479
|
}
|
|
1463
|
-
function
|
|
1480
|
+
function un(e, t = {}) {
|
|
1464
1481
|
let n = [], r = !1, i = !1, a = !1, o = null, s = null, c = null, l = () => {
|
|
1465
1482
|
o !== null && (window.cancelAnimationFrame(o), o = null), s !== null && (window.clearTimeout(s), s = null), c !== null && (window.clearTimeout(c), c = null);
|
|
1466
1483
|
}, u = () => {
|
|
1467
1484
|
if (!r) return !1;
|
|
1468
|
-
let t =
|
|
1469
|
-
return a =
|
|
1485
|
+
let t = an(e);
|
|
1486
|
+
return a = ln(Array.from(new FormData(e).entries()), e, t) !== ln(n, e, t), a;
|
|
1470
1487
|
}, d = () => {
|
|
1471
1488
|
i || (l(), n = Array.from(new FormData(e).entries()), r = !0, a = !1);
|
|
1472
1489
|
}, f = () => {
|
|
@@ -1493,7 +1510,7 @@ function cn(e, t = {}) {
|
|
|
1493
1510
|
}
|
|
1494
1511
|
//#endregion
|
|
1495
1512
|
//#region src/js/validation/rules/email.ts
|
|
1496
|
-
var
|
|
1513
|
+
var dn = {
|
|
1497
1514
|
rule: ({ input: e, getRule: n }) => {
|
|
1498
1515
|
let r = n("email");
|
|
1499
1516
|
return !r || t(e.value, {
|
|
@@ -1505,10 +1522,10 @@ var ln = {
|
|
|
1505
1522
|
};
|
|
1506
1523
|
//#endregion
|
|
1507
1524
|
//#region src/js/validation/rules/shared.ts
|
|
1508
|
-
function
|
|
1525
|
+
function fn(e) {
|
|
1509
1526
|
return e?.querySelector("[data-formie-field-label]")?.childNodes[0]?.textContent?.trim() || "";
|
|
1510
1527
|
}
|
|
1511
|
-
function
|
|
1528
|
+
function pn(e) {
|
|
1512
1529
|
let t = e.getRule("match");
|
|
1513
1530
|
if (!t || t === !0 || typeof t != "object" || !e.field) return null;
|
|
1514
1531
|
let n = typeof t.fieldHandle == "string" ? t.fieldHandle.trim() : "";
|
|
@@ -1518,7 +1535,7 @@ function dn(e) {
|
|
|
1518
1535
|
}
|
|
1519
1536
|
//#endregion
|
|
1520
1537
|
//#region src/js/validation/rules.ts
|
|
1521
|
-
var
|
|
1538
|
+
var mn = {
|
|
1522
1539
|
required: {
|
|
1523
1540
|
rule: ({ input: e, getRule: n }) => {
|
|
1524
1541
|
if (!n("required") || e.type === "hidden" || e.closest("[data-formie-field-handle]")?.getAttribute("data-formie-field-type") === "table") return !0;
|
|
@@ -1535,7 +1552,7 @@ var fn = {
|
|
|
1535
1552
|
},
|
|
1536
1553
|
message: ({ input: e, label: t, t: n }) => e.getAttribute("data-formie-required-message") ?? e.getAttribute("data-required-message") ?? n("{label} cannot be blank.", { label: t })
|
|
1537
1554
|
},
|
|
1538
|
-
email:
|
|
1555
|
+
email: dn,
|
|
1539
1556
|
url: {
|
|
1540
1557
|
rule: ({ input: e, getRule: n }) => {
|
|
1541
1558
|
let r = n("url");
|
|
@@ -1564,18 +1581,18 @@ var fn = {
|
|
|
1564
1581
|
},
|
|
1565
1582
|
match: {
|
|
1566
1583
|
rule: (e) => {
|
|
1567
|
-
let n =
|
|
1584
|
+
let n = pn(e);
|
|
1568
1585
|
return !n || t(e.input.value, { type: "match" }, { comparison: n.value }) === null;
|
|
1569
1586
|
},
|
|
1570
1587
|
message: (e) => {
|
|
1571
|
-
let t =
|
|
1588
|
+
let t = pn(e)?.closest("[data-formie-field-handle]"), n = fn(t);
|
|
1572
1589
|
return e.input.getAttribute("data-formie-validation-match-message") ?? e.t("{label} must match {value}.", {
|
|
1573
1590
|
label: e.label,
|
|
1574
1591
|
value: n
|
|
1575
1592
|
});
|
|
1576
1593
|
}
|
|
1577
1594
|
}
|
|
1578
|
-
},
|
|
1595
|
+
}, hn = {
|
|
1579
1596
|
email: /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*(\.\w{2,})+$/,
|
|
1580
1597
|
url: /^(?:(?:https?|HTTPS?|ftp|FTP):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)(?:\.(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)*(?:\.(?:[a-zA-Z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/,
|
|
1581
1598
|
number: /^(?:[-+]?[0-9]*[.,]?[0-9]+)$/,
|
|
@@ -1583,14 +1600,14 @@ var fn = {
|
|
|
1583
1600
|
date: /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))/,
|
|
1584
1601
|
time: /^(?:(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]))$/,
|
|
1585
1602
|
month: /^(?:(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])))$/
|
|
1586
|
-
},
|
|
1587
|
-
function
|
|
1603
|
+
}, H = O("general", "validator");
|
|
1604
|
+
function U(e) {
|
|
1588
1605
|
return !!e && (e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement) && !!e.name;
|
|
1589
1606
|
}
|
|
1590
|
-
function
|
|
1607
|
+
function W(e) {
|
|
1591
1608
|
return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
|
|
1592
1609
|
}
|
|
1593
|
-
var
|
|
1610
|
+
var gn = class {
|
|
1594
1611
|
form;
|
|
1595
1612
|
errors = [];
|
|
1596
1613
|
validators = {};
|
|
@@ -1612,14 +1629,14 @@ var mn = class {
|
|
|
1612
1629
|
messagesClass: [],
|
|
1613
1630
|
messageClass: [],
|
|
1614
1631
|
fieldsSelector: "input:not([type=\"hidden\"]):not([type=\"submit\"]):not([type=\"button\"]):not([disabled]), select:not([disabled]), textarea:not([disabled])",
|
|
1615
|
-
patterns:
|
|
1632
|
+
patterns: hn,
|
|
1616
1633
|
...t
|
|
1617
|
-
}, Object.entries(
|
|
1634
|
+
}, Object.entries(mn).forEach(([e, t]) => {
|
|
1618
1635
|
this.addValidator(e, t.rule, t.message);
|
|
1619
1636
|
}), this.init();
|
|
1620
1637
|
}
|
|
1621
1638
|
init() {
|
|
1622
|
-
|
|
1639
|
+
H.log("Initializing validator.", {
|
|
1623
1640
|
formId: this.form.id || null,
|
|
1624
1641
|
live: this.config.live
|
|
1625
1642
|
}), this.form.setAttribute("novalidate", "true"), this.inputs().forEach((e) => {
|
|
@@ -1627,9 +1644,9 @@ var mn = class {
|
|
|
1627
1644
|
}), this.config.live && this.addEventListeners(), this.emitEvent(document, o("ready"), { validator: this });
|
|
1628
1645
|
}
|
|
1629
1646
|
inputs(e = null) {
|
|
1630
|
-
if (
|
|
1647
|
+
if (U(e)) return j(e) ? [] : [e];
|
|
1631
1648
|
let t = e || this.form;
|
|
1632
|
-
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) =>
|
|
1649
|
+
return Array.from(t.querySelectorAll(this.config.fieldsSelector)).filter((e) => U(e) && !j(e));
|
|
1633
1650
|
}
|
|
1634
1651
|
getInputValue(e) {
|
|
1635
1652
|
return e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ? e.checked : e instanceof HTMLInputElement && e.type === "file" ? e.files?.length ? Array.from(e.files).map((e) => e.name).join("|") : "" : e.value ?? "";
|
|
@@ -1669,7 +1686,7 @@ var mn = class {
|
|
|
1669
1686
|
}), r = !0;
|
|
1670
1687
|
}
|
|
1671
1688
|
}), !r && i && this.removeError(e);
|
|
1672
|
-
}),
|
|
1689
|
+
}), H.log("Validation pass complete.", {
|
|
1673
1690
|
errorCount: this.errors.length,
|
|
1674
1691
|
includeHiddenPages: t.includeHiddenPages === !0
|
|
1675
1692
|
}), this.errors;
|
|
@@ -1705,11 +1722,11 @@ var mn = class {
|
|
|
1705
1722
|
let a = r.getAttribute("data-formie-field-handle") || "field";
|
|
1706
1723
|
i.id = i.id || `${e.id || `${this.form.id}-${a}`}-errors`;
|
|
1707
1724
|
let s = `${i.id}-1`;
|
|
1708
|
-
|
|
1725
|
+
Fe(i, Ne(this.config.errorAriaLive, this.submitted));
|
|
1709
1726
|
let c = document.createElement("div");
|
|
1710
1727
|
c.setAttribute("data-formie-field-error", "true"), c.setAttribute(`data-formie-field-error-${t}`, "true"), c.setAttribute("id", s), this.config.messageClass.length && c.classList.add(...this.config.messageClass), c.textContent = n, i.appendChild(c), r.setAttribute("data-formie-field-has-error", "true"), r.querySelectorAll("input, select, textarea").forEach((e) => {
|
|
1711
1728
|
let t = e;
|
|
1712
|
-
j(t) || (t.setAttribute("aria-invalid", "true"), this.config.inputErrorClass.length && t.classList.add(...this.config.inputErrorClass), t.setAttribute("data-formie-input-has-error", "true"),
|
|
1729
|
+
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"), Re(t, s));
|
|
1713
1730
|
});
|
|
1714
1731
|
for (let e = r; e; e = e.parentElement?.closest("[data-formie-field-handle]")) this.config.fieldContainerErrorClass.length && e.classList.add(...this.config.fieldContainerErrorClass), e.setAttribute("data-formie-field-has-error", "true");
|
|
1715
1732
|
this.emitEvent(e, o("show-error"), {
|
|
@@ -1755,7 +1772,7 @@ var mn = class {
|
|
|
1755
1772
|
try {
|
|
1756
1773
|
n = JSON.parse(e);
|
|
1757
1774
|
} catch {
|
|
1758
|
-
return
|
|
1775
|
+
return H.warn("Invalid validation rules payload.", { formId: this.form.id || null }), t;
|
|
1759
1776
|
}
|
|
1760
1777
|
return Array.isArray(n) && n.forEach((e) => {
|
|
1761
1778
|
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
@@ -1764,39 +1781,39 @@ var mn = class {
|
|
|
1764
1781
|
}), t;
|
|
1765
1782
|
}
|
|
1766
1783
|
destroy() {
|
|
1767
|
-
|
|
1784
|
+
H.log("Destroying validator.", { formId: this.form.id || null }), this.removeEventListeners(), this.form.removeAttribute("novalidate"), this.emitEvent(document, o("destroy"), { validator: this });
|
|
1768
1785
|
}
|
|
1769
1786
|
isVisible(e, t = {}) {
|
|
1770
1787
|
if (e.disabled || e.hasAttribute("data-formie-conditions-disabled") || e.closest("[data-formie-conditions-disabled]") || e.closest("[data-formie-conditionally-hidden]")) return !1;
|
|
1771
1788
|
if (e.closest("[data-formie-page-hidden]")) return !!t.includeHiddenPages;
|
|
1772
1789
|
let n = e.closest("[data-formie-field-handle]"), r = n?.querySelector("[data-formie-rich-text]");
|
|
1773
|
-
if (r instanceof HTMLElement) return
|
|
1790
|
+
if (r instanceof HTMLElement) return W(r);
|
|
1774
1791
|
if (e instanceof HTMLSelectElement && e.hasAttribute("data-formie-combobox-input")) {
|
|
1775
1792
|
let t = e.nextElementSibling;
|
|
1776
|
-
if (t instanceof HTMLElement && t.classList.contains("formie-combobox")) return
|
|
1793
|
+
if (t instanceof HTMLElement && t.classList.contains("formie-combobox")) return W(t);
|
|
1777
1794
|
}
|
|
1778
|
-
return e instanceof HTMLSelectElement && n instanceof HTMLElement ?
|
|
1795
|
+
return e instanceof HTMLSelectElement && n instanceof HTMLElement ? W(e) || W(n) : W(e);
|
|
1779
1796
|
}
|
|
1780
1797
|
blurHandler(e) {
|
|
1781
|
-
e.target instanceof HTMLElement &&
|
|
1798
|
+
e.target instanceof HTMLElement && U(e.target) && !j(e.target) && e.target.form?.isSameNode(this.form) && (e instanceof CustomEvent || e.target instanceof HTMLInputElement && e.target.type === "file" || e.target instanceof HTMLInputElement && (e.target.type === "checkbox" || e.target.type === "radio") || (this.isDirty(e.target) && this.activated.add(e.target), this.shouldShowError(e.target) && this.validate(e.target)));
|
|
1782
1799
|
}
|
|
1783
1800
|
changeHandler(e) {
|
|
1784
|
-
e.target instanceof HTMLElement &&
|
|
1801
|
+
e.target instanceof HTMLElement && U(e.target) && !j(e.target) && e.target.form?.isSameNode(this.form) && (e instanceof CustomEvent || (e.target instanceof HTMLSelectElement || e.target instanceof HTMLInputElement && (e.target.type === "file" || e.target.type === "checkbox" || e.target.type === "radio")) && (this.activated.add(e.target), this.validate(e.target)));
|
|
1785
1802
|
}
|
|
1786
1803
|
inputHandler(e) {
|
|
1787
|
-
e.target instanceof HTMLElement &&
|
|
1804
|
+
e.target instanceof HTMLElement && U(e.target) && !j(e.target) && e.target.form?.isSameNode(this.form) && (e instanceof CustomEvent || e.target instanceof HTMLInputElement && (e.target.type === "checkbox" || e.target.type === "radio") || this.shouldShowError(e.target) && this.validate(e.target));
|
|
1788
1805
|
}
|
|
1789
1806
|
submit(e = null, { final: t = !1 } = {}) {
|
|
1790
|
-
return this.submitted = !0,
|
|
1807
|
+
return this.submitted = !0, H.log("Submit validation requested.", { final: t }), this.boundListeners || this.addEventListeners(), this.removeAllErrors(), this.validate(e, { includeHiddenPages: t });
|
|
1791
1808
|
}
|
|
1792
1809
|
resetLiveState() {
|
|
1793
1810
|
this.submitted = !1, this.activated = /* @__PURE__ */ new WeakSet(), this.errors = [], this.removeAllErrors();
|
|
1794
1811
|
}
|
|
1795
1812
|
addEventListeners() {
|
|
1796
|
-
this.boundListeners || (this.form.addEventListener("blur", this.onBlur, !0), this.form.addEventListener("change", this.onChange, !1), this.form.addEventListener("input", this.onInput, !1), this.boundListeners = !0,
|
|
1813
|
+
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, H.log("Event listeners attached."));
|
|
1797
1814
|
}
|
|
1798
1815
|
removeEventListeners() {
|
|
1799
|
-
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1,
|
|
1816
|
+
this.form.removeEventListener("blur", this.onBlur, !0), this.form.removeEventListener("change", this.onChange, !1), this.form.removeEventListener("input", this.onInput, !1), this.boundListeners = !1, H.log("Event listeners removed.");
|
|
1800
1817
|
}
|
|
1801
1818
|
emitEvent(e, t, n = {}) {
|
|
1802
1819
|
e.dispatchEvent(new CustomEvent(t, {
|
|
@@ -1816,25 +1833,25 @@ var mn = class {
|
|
|
1816
1833
|
};
|
|
1817
1834
|
//#endregion
|
|
1818
1835
|
//#region src/js/validation/enter-key-guard.ts
|
|
1819
|
-
function
|
|
1836
|
+
function _n(e) {
|
|
1820
1837
|
return e.hasAttribute("data-formie-conditionally-hidden") || !!e.closest("[data-formie-conditionally-hidden]") || e.hasAttribute("data-formie-page-hidden") || !!e.closest("[data-formie-page-hidden]");
|
|
1821
1838
|
}
|
|
1822
|
-
function
|
|
1839
|
+
function vn(e, t) {
|
|
1823
1840
|
let n = e.querySelectorAll(`[data-formie-action="${t}"]`);
|
|
1824
|
-
return Array.from(n).some((e) => !
|
|
1841
|
+
return Array.from(n).some((e) => !_n(e));
|
|
1825
1842
|
}
|
|
1826
|
-
function
|
|
1843
|
+
function yn(e) {
|
|
1827
1844
|
let { final: t } = m(e);
|
|
1828
1845
|
return "submit";
|
|
1829
1846
|
}
|
|
1830
|
-
function
|
|
1831
|
-
return !
|
|
1847
|
+
function bn(e) {
|
|
1848
|
+
return !vn(e, yn(e));
|
|
1832
1849
|
}
|
|
1833
|
-
function
|
|
1850
|
+
function xn(e) {
|
|
1834
1851
|
let t = (t) => {
|
|
1835
1852
|
if (t.key !== "Enter" || t.defaultPrevented) return;
|
|
1836
1853
|
let n = t.target;
|
|
1837
|
-
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") ||
|
|
1854
|
+
(n instanceof HTMLInputElement || n instanceof HTMLSelectElement) && (n instanceof HTMLInputElement && (n.type === "button" || n.type === "submit" || n.type === "reset" || n.type === "file") || bn(e) && t.preventDefault());
|
|
1838
1855
|
};
|
|
1839
1856
|
return e.addEventListener("keydown", t, !0), () => {
|
|
1840
1857
|
e.removeEventListener("keydown", t, !0);
|
|
@@ -1842,16 +1859,16 @@ function yn(e) {
|
|
|
1842
1859
|
}
|
|
1843
1860
|
//#endregion
|
|
1844
1861
|
//#region src/js/core/create-formie-client.ts
|
|
1845
|
-
var
|
|
1846
|
-
function
|
|
1862
|
+
var G = "[data-formie]:not([data-formie-init=\"false\"]), [data-formie-form]:not([data-formie-init=\"false\"])", Sn = 300, Cn = "/actions/formie/server/forms/render", wn = "/api", Tn = "/actions/formie/server/forms/refresh-tokens", En = "/actions/formie/server/submissions/submit", Dn = "/actions/formie/server/submissions/set-page", On = "/actions/formie/server/submissions/clear-submission", kn = "/actions/formie/file-upload/hydrate", K = O("general", "client"), An = /* @__PURE__ */ new Set();
|
|
1863
|
+
function q(e, t) {
|
|
1847
1864
|
if (e == null || e === "") return t;
|
|
1848
1865
|
let n = e.toLowerCase();
|
|
1849
1866
|
return n !== "false" && n !== "0" && n !== "off";
|
|
1850
1867
|
}
|
|
1851
|
-
function
|
|
1852
|
-
return e.formieRefreshTokens == null ? e.formieStaticCache != null &&
|
|
1868
|
+
function jn(e) {
|
|
1869
|
+
return e.formieRefreshTokens == null ? e.formieStaticCache != null && q(e.formieStaticCache, !0) : q(e.formieRefreshTokens, !0);
|
|
1853
1870
|
}
|
|
1854
|
-
function
|
|
1871
|
+
function J(e) {
|
|
1855
1872
|
let t = e instanceof HTMLElement ? e.dataset : {};
|
|
1856
1873
|
return {
|
|
1857
1874
|
mode: "server-rendered",
|
|
@@ -1859,25 +1876,25 @@ function Y(e) {
|
|
|
1859
1876
|
profile: t.formieRequestProfile,
|
|
1860
1877
|
formHandle: t.formieHandle,
|
|
1861
1878
|
endpoint: t.formieEndpoint,
|
|
1862
|
-
staticCache:
|
|
1863
|
-
autoVisible:
|
|
1864
|
-
compatibility:
|
|
1879
|
+
staticCache: jn(t),
|
|
1880
|
+
autoVisible: q(t.formieAutoVisible, !0),
|
|
1881
|
+
compatibility: q(t.formieCompatibility, !1)
|
|
1865
1882
|
};
|
|
1866
1883
|
}
|
|
1867
|
-
function
|
|
1884
|
+
function Mn(e) {
|
|
1868
1885
|
if (e && e !== "server-rendered") throw Error("@verbb/formie-browser enhances server-rendered HTML only. Use @verbb/formie-core for client-rendered forms.");
|
|
1869
1886
|
return "server-rendered";
|
|
1870
1887
|
}
|
|
1871
|
-
function
|
|
1888
|
+
function Nn(e) {
|
|
1872
1889
|
return e || "rest";
|
|
1873
1890
|
}
|
|
1874
|
-
function
|
|
1891
|
+
function Pn(e) {
|
|
1875
1892
|
return e instanceof HTMLFormElement ? e : e.querySelector("form");
|
|
1876
1893
|
}
|
|
1877
|
-
function
|
|
1878
|
-
|
|
1894
|
+
function Fn(e, t) {
|
|
1895
|
+
An.has(e) || (An.add(e), K.warn(t));
|
|
1879
1896
|
}
|
|
1880
|
-
function
|
|
1897
|
+
function In(e, t) {
|
|
1881
1898
|
if (!e) return e;
|
|
1882
1899
|
try {
|
|
1883
1900
|
return new URL(e).toString();
|
|
@@ -1889,21 +1906,21 @@ function Pn(e, t) {
|
|
|
1889
1906
|
return e;
|
|
1890
1907
|
}
|
|
1891
1908
|
}
|
|
1892
|
-
function
|
|
1909
|
+
function Y(e, t) {
|
|
1893
1910
|
let n = (e || "").trim();
|
|
1894
|
-
return n ? n.includes(t) ? n :
|
|
1911
|
+
return n ? n.includes(t) ? n : In(t, n) : t;
|
|
1895
1912
|
}
|
|
1896
|
-
function
|
|
1897
|
-
return
|
|
1913
|
+
function Ln(e, t) {
|
|
1914
|
+
return Y(e.endpoint || t.dataset.formieEndpoint, Cn);
|
|
1898
1915
|
}
|
|
1899
|
-
function
|
|
1916
|
+
function Rn(e, t) {
|
|
1900
1917
|
let n = (e.endpoint || t.dataset.formieEndpoint || "").trim();
|
|
1901
|
-
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n :
|
|
1918
|
+
return n ? n.includes("/graphql") || n.endsWith("/api") || n.includes("/actions/graphql/") ? n : In(wn, n) : wn;
|
|
1902
1919
|
}
|
|
1903
|
-
function
|
|
1904
|
-
return
|
|
1920
|
+
function zn(e, t) {
|
|
1921
|
+
return Y(t.dataset.formieRefreshTokensEndpoint || e.endpoint || t.dataset.formieEndpoint, Tn);
|
|
1905
1922
|
}
|
|
1906
|
-
function
|
|
1923
|
+
function Bn(e, t) {
|
|
1907
1924
|
if (!e) return t;
|
|
1908
1925
|
try {
|
|
1909
1926
|
let n = new URL(e, window.location.origin), r = new URL(t, window.location.origin);
|
|
@@ -1914,39 +1931,39 @@ function Rn(e, t) {
|
|
|
1914
1931
|
return t;
|
|
1915
1932
|
}
|
|
1916
1933
|
}
|
|
1917
|
-
function
|
|
1918
|
-
let r = n.endpoint || e.dataset.formieEndpoint, i =
|
|
1919
|
-
t.setAttribute("action",
|
|
1920
|
-
let t = e.getAttribute("href"), n =
|
|
1921
|
-
e.setAttribute("href",
|
|
1934
|
+
function Vn(e, t, n) {
|
|
1935
|
+
let r = n.endpoint || e.dataset.formieEndpoint, i = Y(r, En), a = t.getAttribute("action");
|
|
1936
|
+
t.setAttribute("action", Bn(a, i)), t.querySelectorAll("[data-formie-tab-link]").forEach((e) => {
|
|
1937
|
+
let t = e.getAttribute("href"), n = Y(r, Dn);
|
|
1938
|
+
e.setAttribute("href", Bn(t, n));
|
|
1922
1939
|
}), t.querySelectorAll("[data-formie-file-upload-hydrate-endpoint]").forEach((e) => {
|
|
1923
|
-
e.setAttribute("data-formie-file-upload-hydrate-endpoint",
|
|
1940
|
+
e.setAttribute("data-formie-file-upload-hydrate-endpoint", Y(r, kn));
|
|
1924
1941
|
});
|
|
1925
1942
|
}
|
|
1926
|
-
function
|
|
1943
|
+
function Hn(e) {
|
|
1927
1944
|
if (e == null) return !1;
|
|
1928
1945
|
let t = e.trim().toLowerCase();
|
|
1929
1946
|
return t === "true" || t === "1" || t === "";
|
|
1930
1947
|
}
|
|
1931
|
-
function
|
|
1932
|
-
return
|
|
1948
|
+
function Un(e) {
|
|
1949
|
+
return q(e.dataset.formieAutomaticSubmissionState, !0);
|
|
1933
1950
|
}
|
|
1934
|
-
function
|
|
1935
|
-
return
|
|
1951
|
+
function Wn(e, t, n) {
|
|
1952
|
+
return Y(n.dataset.formieClearSubmissionEndpoint || e.endpoint || t.dataset.formieEndpoint, On);
|
|
1936
1953
|
}
|
|
1937
|
-
function
|
|
1938
|
-
return
|
|
1954
|
+
function Gn(e) {
|
|
1955
|
+
return Hn(e.dataset.formieUnloadWarning);
|
|
1939
1956
|
}
|
|
1940
|
-
function
|
|
1957
|
+
function Kn(e, t) {
|
|
1941
1958
|
e.setAttribute("data-formie-internal-navigation", t);
|
|
1942
1959
|
}
|
|
1943
|
-
function
|
|
1960
|
+
function qn(e) {
|
|
1944
1961
|
e.removeAttribute("data-formie-internal-navigation");
|
|
1945
1962
|
}
|
|
1946
|
-
function
|
|
1963
|
+
function Jn(e) {
|
|
1947
1964
|
return e.getAttribute("data-formie-internal-navigation") !== null;
|
|
1948
1965
|
}
|
|
1949
|
-
function
|
|
1966
|
+
function Yn(e, t) {
|
|
1950
1967
|
if (!e) return !1;
|
|
1951
1968
|
try {
|
|
1952
1969
|
return new URL(e, window.location.origin).searchParams.has(t);
|
|
@@ -1954,30 +1971,30 @@ function qn(e, t) {
|
|
|
1954
1971
|
return !1;
|
|
1955
1972
|
}
|
|
1956
1973
|
}
|
|
1957
|
-
function
|
|
1958
|
-
return
|
|
1974
|
+
function Xn(e) {
|
|
1975
|
+
return Yn(window.location.href, "resumeToken") || Yn(e.getAttribute("action"), "resumeToken");
|
|
1959
1976
|
}
|
|
1960
|
-
function
|
|
1977
|
+
function Zn(e) {
|
|
1961
1978
|
return e instanceof MouseEvent ? e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey : !0;
|
|
1962
1979
|
}
|
|
1963
|
-
function
|
|
1980
|
+
function Qn(e, t = 0) {
|
|
1964
1981
|
if (!e) return t;
|
|
1965
1982
|
let n = Number.parseInt(e, 10);
|
|
1966
1983
|
return Number.isFinite(n) ? n : t;
|
|
1967
1984
|
}
|
|
1968
|
-
function
|
|
1969
|
-
return Math.max(0,
|
|
1985
|
+
function $n(e) {
|
|
1986
|
+
return Math.max(0, Qn(e.dataset.formieSubmitDelay, Sn));
|
|
1970
1987
|
}
|
|
1971
|
-
function
|
|
1972
|
-
return
|
|
1988
|
+
function X(e) {
|
|
1989
|
+
return Hn(e.dataset.formieValidationOnSubmit);
|
|
1973
1990
|
}
|
|
1974
|
-
async function
|
|
1975
|
-
let t =
|
|
1991
|
+
async function er(e) {
|
|
1992
|
+
let t = $n(e);
|
|
1976
1993
|
await new Promise((e) => {
|
|
1977
1994
|
window.setTimeout(e, t);
|
|
1978
1995
|
});
|
|
1979
1996
|
}
|
|
1980
|
-
function
|
|
1997
|
+
function tr(e, t) {
|
|
1981
1998
|
let n = e?.getAttribute(t)?.trim();
|
|
1982
1999
|
if (!n) return null;
|
|
1983
2000
|
try {
|
|
@@ -1987,29 +2004,29 @@ function $n(e, t) {
|
|
|
1987
2004
|
return console.error(`[formie] Failed to parse ${t}.`, e), null;
|
|
1988
2005
|
}
|
|
1989
2006
|
}
|
|
1990
|
-
function
|
|
2007
|
+
function nr(e, t) {
|
|
1991
2008
|
let n = t || (e instanceof HTMLFormElement ? e : null);
|
|
1992
2009
|
if (!n) return null;
|
|
1993
|
-
let r =
|
|
2010
|
+
let r = tr(n, "data-formie-modules"), i = tr(n, "data-formie-theme-classes") || tr(n, "data-formie-theme");
|
|
1994
2011
|
return !r && !i ? null : {
|
|
1995
2012
|
modules: r || void 0,
|
|
1996
2013
|
theme: i || void 0
|
|
1997
2014
|
};
|
|
1998
2015
|
}
|
|
1999
|
-
function
|
|
2016
|
+
function rr(e) {
|
|
2000
2017
|
if (!(e instanceof HTMLElement)) return !0;
|
|
2001
2018
|
if (!e.isConnected || e.hidden || e.closest("[hidden]")) return !1;
|
|
2002
2019
|
let t = window.getComputedStyle(e);
|
|
2003
2020
|
return t.display === "none" || t.visibility === "hidden" ? !1 : e.getClientRects().length > 0;
|
|
2004
2021
|
}
|
|
2005
|
-
function
|
|
2022
|
+
function ir(e, t) {
|
|
2006
2023
|
return t === document ? !0 : t instanceof Element ? t === e || t.contains(e) : !0;
|
|
2007
2024
|
}
|
|
2008
|
-
function
|
|
2025
|
+
function Z(e) {
|
|
2009
2026
|
let t = e, n = t.id ? `#${t.id}` : "", r = t.dataset?.formieHandle ? `[handle="${t.dataset.formieHandle}"]` : "";
|
|
2010
2027
|
return `${t.tagName ? t.tagName.toLowerCase() : "element"}${n}${r}`;
|
|
2011
2028
|
}
|
|
2012
|
-
function
|
|
2029
|
+
function ar(e, t) {
|
|
2013
2030
|
if (t) {
|
|
2014
2031
|
if (t.csrf?.param && t.csrf?.token) {
|
|
2015
2032
|
let n = e.querySelector(`input[name="${t.csrf.param}"]`);
|
|
@@ -2036,11 +2053,11 @@ function rr(e, t) {
|
|
|
2036
2053
|
});
|
|
2037
2054
|
}
|
|
2038
2055
|
}
|
|
2039
|
-
async function
|
|
2040
|
-
let n =
|
|
2056
|
+
async function or(e, t) {
|
|
2057
|
+
let n = Mn(t.mode), r = Nn(t.transport);
|
|
2041
2058
|
if (n !== "server-rendered") return null;
|
|
2042
2059
|
if (t.payload) return t.payload.html && (e.innerHTML = t.payload.html), t.payload;
|
|
2043
|
-
let i = !!
|
|
2060
|
+
let i = !!Pn(e), a = t.formHandle || e.dataset.formieHandle;
|
|
2044
2061
|
if (i || !a) return null;
|
|
2045
2062
|
let o = {
|
|
2046
2063
|
mode: n,
|
|
@@ -2049,26 +2066,26 @@ async function ir(e, t) {
|
|
|
2049
2066
|
siteId: t.siteId,
|
|
2050
2067
|
theme: t.theme,
|
|
2051
2068
|
themeConfig: t.themeConfig
|
|
2052
|
-
}, s = r === "graphql" ?
|
|
2069
|
+
}, s = r === "graphql" ? Rn(t, e) : Ln(t, e), c = r === "graphql" ? await Ye(s, a, o, t) : await Je(s, a, {
|
|
2053
2070
|
...o,
|
|
2054
2071
|
endpoint: s
|
|
2055
2072
|
}, t);
|
|
2056
2073
|
return c?.html && (e.innerHTML = c.html), c;
|
|
2057
2074
|
}
|
|
2058
|
-
async function
|
|
2075
|
+
async function sr(e, t, n) {
|
|
2059
2076
|
if (t.refreshTokens === !1) return;
|
|
2060
2077
|
let r = t.formHandle || e.dataset.formieHandle;
|
|
2061
2078
|
if (!r) return;
|
|
2062
|
-
let i = await Xe(
|
|
2063
|
-
|
|
2079
|
+
let i = await Xe(zn(t, e), r, n.querySelector("input[name=\"renderId\"]")?.value || void 0, t, n.querySelector("input[name=\"requestToken\"]")?.value, n.querySelector("input[name=\"siteId\"]")?.value || t.siteId);
|
|
2080
|
+
ar(n, i), g(e, "formie:refresh-tokens:refreshed", i);
|
|
2064
2081
|
}
|
|
2065
|
-
function
|
|
2082
|
+
function cr(e, t, n, r, i, a) {
|
|
2066
2083
|
t.dataset.formieRequestProfile = n.profile ?? "same-origin-browser", n.profile === "cross-origin-public" && (t.dataset.formieSubmitMethod = "ajax");
|
|
2067
|
-
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s =
|
|
2084
|
+
let o = String(t.dataset.formieSubmitMethod || "").trim().toLowerCase(), s = Wn(n, e, t), c = !1, l = t.querySelectorAll("[data-formie-action]"), u = (e) => {
|
|
2068
2085
|
e ? t.setAttribute("data-formie-pending-action", e) : t.removeAttribute("data-formie-pending-action");
|
|
2069
2086
|
};
|
|
2070
|
-
if (
|
|
2071
|
-
let n =
|
|
2087
|
+
if (Gn(t)) {
|
|
2088
|
+
let n = un(t, { shouldWarn: () => !Jn(t) }), r = (e) => {
|
|
2072
2089
|
if (!(e instanceof CustomEvent)) return;
|
|
2073
2090
|
let t = e.detail;
|
|
2074
2091
|
t?.ok && (t.action === "save" || t.outcome === "revised") && n.scheduleBaselineCapture();
|
|
@@ -2090,7 +2107,7 @@ function or(e, t, n, r, i, a) {
|
|
|
2090
2107
|
}), t.querySelectorAll("[data-formie-tab-link]").forEach((n) => {
|
|
2091
2108
|
let r = async (n) => {
|
|
2092
2109
|
if (o !== "ajax") {
|
|
2093
|
-
|
|
2110
|
+
Zn(n) && Kn(t, "set-page");
|
|
2094
2111
|
return;
|
|
2095
2112
|
}
|
|
2096
2113
|
n.preventDefault();
|
|
@@ -2104,7 +2121,7 @@ function or(e, t, n, r, i, a) {
|
|
|
2104
2121
|
let n = await Ze(a, t, i);
|
|
2105
2122
|
if (n.pageId && S(t, String(n.pageId)), !n.success) {
|
|
2106
2123
|
let { form: e = [], ...r } = n.errors ?? {};
|
|
2107
|
-
|
|
2124
|
+
Ht(t), Nt(t, r), Pt(t, e), F(t);
|
|
2108
2125
|
return;
|
|
2109
2126
|
}
|
|
2110
2127
|
g(e, "formie:page:navigate:after", {
|
|
@@ -2124,9 +2141,9 @@ function or(e, t, n, r, i, a) {
|
|
|
2124
2141
|
n.addEventListener("click", r), a.push(() => {
|
|
2125
2142
|
n.removeEventListener("click", r);
|
|
2126
2143
|
});
|
|
2127
|
-
}), !
|
|
2144
|
+
}), !Un(t)) {
|
|
2128
2145
|
let e = !1, n = () => {
|
|
2129
|
-
e ||
|
|
2146
|
+
e || Jn(t) || Xn(t) || (e = !0, Qe(s, t));
|
|
2130
2147
|
};
|
|
2131
2148
|
window.addEventListener("pagehide", n), window.addEventListener("beforeunload", n), a.push(() => {
|
|
2132
2149
|
window.removeEventListener("pagehide", n), window.removeEventListener("beforeunload", n);
|
|
@@ -2141,31 +2158,31 @@ function or(e, t, n, r, i, a) {
|
|
|
2141
2158
|
} else t.removeAttribute("data-formie-internal-resubmit");
|
|
2142
2159
|
let l = a.submitter, d = l?.getAttribute("data-formie-action"), p = t.getAttribute("data-formie-pending-action"), h = t.querySelector("input[name=\"submitAction\"]"), _ = d || p || h?.value || "submit", v = null, y = !1;
|
|
2143
2160
|
try {
|
|
2144
|
-
if (s) v = await
|
|
2161
|
+
if (s) v = await Ut({
|
|
2145
2162
|
target: e,
|
|
2146
2163
|
form: t,
|
|
2147
2164
|
bus: r,
|
|
2148
2165
|
validator: i,
|
|
2149
|
-
validateOnSubmit:
|
|
2166
|
+
validateOnSubmit: X(t),
|
|
2150
2167
|
action: _,
|
|
2151
2168
|
submitter: l,
|
|
2152
|
-
waitForSubmitDelay:
|
|
2169
|
+
waitForSubmitDelay: er,
|
|
2153
2170
|
onRefreshTokensAfterSubmit: async () => {
|
|
2154
|
-
await
|
|
2171
|
+
await sr(e, n, t);
|
|
2155
2172
|
},
|
|
2156
2173
|
dispatchSubmitResult: (t) => {
|
|
2157
2174
|
g(e, "formie:submit:result", t);
|
|
2158
2175
|
}
|
|
2159
2176
|
});
|
|
2160
2177
|
else {
|
|
2161
|
-
if (
|
|
2178
|
+
if (Ht(t), C(t, l), await er(t), v = await dt(t, _, r, {
|
|
2162
2179
|
validator: i,
|
|
2163
|
-
validateOnSubmit:
|
|
2180
|
+
validateOnSubmit: X(t),
|
|
2164
2181
|
preflightOnly: !0
|
|
2165
2182
|
}), v.ok) {
|
|
2166
|
-
x(t, _), c = !0,
|
|
2183
|
+
x(t, _), c = !0, Kn(t, "submit"), u(null);
|
|
2167
2184
|
let e = !1, n = () => {
|
|
2168
|
-
if (e = !0, c = !1,
|
|
2185
|
+
if (e = !0, c = !1, qn(t), f(t), i && X(t)) {
|
|
2169
2186
|
let { scope: e, final: n } = m(t), r = i.submit(n ? t : e, { final: n });
|
|
2170
2187
|
r.length > 0 && z(t, {
|
|
2171
2188
|
ok: !1,
|
|
@@ -2189,7 +2206,7 @@ function or(e, t, n, r, i, a) {
|
|
|
2189
2206
|
y = !0;
|
|
2190
2207
|
return;
|
|
2191
2208
|
}
|
|
2192
|
-
z(t, v), g(e, "formie:submit:result", v),
|
|
2209
|
+
z(t, v), g(e, "formie:submit:result", v), qn(t);
|
|
2193
2210
|
}
|
|
2194
2211
|
} catch (n) {
|
|
2195
2212
|
c = !1, v = {
|
|
@@ -2197,23 +2214,23 @@ function or(e, t, n, r, i, a) {
|
|
|
2197
2214
|
code: "SUBMIT_ERROR",
|
|
2198
2215
|
message: n instanceof Error ? n.message : "Submission failed.",
|
|
2199
2216
|
formErrors: [n instanceof Error ? n.message : "Submission failed."]
|
|
2200
|
-
}, z(t, v), g(e, "formie:submit:result", v),
|
|
2217
|
+
}, z(t, v), g(e, "formie:submit:result", v), qn(t);
|
|
2201
2218
|
} finally {
|
|
2202
|
-
u(null), !s && !y && !
|
|
2219
|
+
u(null), !s && !y && !Vt(v) && f(t);
|
|
2203
2220
|
}
|
|
2204
2221
|
};
|
|
2205
2222
|
t.addEventListener("submit", d), a.push(() => {
|
|
2206
2223
|
t.removeEventListener("submit", d);
|
|
2207
2224
|
});
|
|
2208
2225
|
}
|
|
2209
|
-
async function
|
|
2226
|
+
async function lr(e, t, n) {
|
|
2210
2227
|
if (t.refreshTokens === !1 || !t.staticCache) return;
|
|
2211
|
-
let r = t.formHandle || e.dataset.formieHandle, i =
|
|
2228
|
+
let r = t.formHandle || e.dataset.formieHandle, i = zn(t, e), a = n?.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2212
2229
|
if (!r) return;
|
|
2213
|
-
let o = await Xe(i, r, a, t, n?.querySelector("input[name=\"requestToken\"]")?.value);
|
|
2214
|
-
o && n && (
|
|
2230
|
+
let o = await Xe(i, r, a, t, n?.querySelector("input[name=\"requestToken\"]")?.value, n?.querySelector("input[name=\"siteId\"]")?.value || t.siteId);
|
|
2231
|
+
o && n && (ar(n, o), g(e, "formie:refresh-tokens:after", o));
|
|
2215
2232
|
}
|
|
2216
|
-
function
|
|
2233
|
+
function ur() {
|
|
2217
2234
|
let t = /* @__PURE__ */ new Map(), r = new B(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = [
|
|
2218
2235
|
"prepare",
|
|
2219
2236
|
"normalize",
|
|
@@ -2229,45 +2246,45 @@ function cr() {
|
|
|
2229
2246
|
return;
|
|
2230
2247
|
}
|
|
2231
2248
|
let r = (async () => {
|
|
2232
|
-
|
|
2249
|
+
K.log("Unmount requested.", { target: Z(e) });
|
|
2233
2250
|
let n = i.get(e);
|
|
2234
2251
|
n && (n(), i.delete(e));
|
|
2235
2252
|
let r = t.get(e);
|
|
2236
2253
|
r ? (g(e, "formie:unmount:before", { id: r.instance.id }), r.unbinds.forEach((e) => {
|
|
2237
2254
|
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(),
|
|
2255
|
+
}), 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(), K.log("Unmount complete.", {
|
|
2239
2256
|
id: r.instance.id,
|
|
2240
|
-
target:
|
|
2241
|
-
})) :
|
|
2257
|
+
target: Z(e)
|
|
2258
|
+
})) : K.log("Unmount skipped (no mounted state).", { target: Z(e) });
|
|
2242
2259
|
})().finally(() => {
|
|
2243
2260
|
a.delete(e);
|
|
2244
2261
|
});
|
|
2245
2262
|
a.set(e, r), await r;
|
|
2246
2263
|
}, c = async (a, c) => {
|
|
2247
|
-
|
|
2248
|
-
target:
|
|
2264
|
+
K.log("Mount requested.", {
|
|
2265
|
+
target: Z(a),
|
|
2249
2266
|
mode: c.mode,
|
|
2250
2267
|
autoVisible: c.autoVisible
|
|
2251
2268
|
});
|
|
2252
2269
|
let l = i.get(a);
|
|
2253
2270
|
l && (l(), i.delete(a));
|
|
2254
2271
|
let u = t.get(a);
|
|
2255
|
-
if (u) return
|
|
2272
|
+
if (u) return K.log("Mount skipped (already mounted).", {
|
|
2256
2273
|
id: u.instance.id,
|
|
2257
|
-
target:
|
|
2274
|
+
target: Z(a)
|
|
2258
2275
|
}), u.instance;
|
|
2259
|
-
let d = new
|
|
2276
|
+
let d = new Wt(), f = [], m = a?.id || `formie-${t.size + 1}`, v = J(a), b = {
|
|
2260
2277
|
...v,
|
|
2261
2278
|
...c,
|
|
2262
|
-
mode:
|
|
2263
|
-
transport:
|
|
2264
|
-
}, x = await
|
|
2265
|
-
c.compatibility === void 0 && S?.hasAttribute("data-formie-compatibility") && (b.compatibility =
|
|
2279
|
+
mode: Mn(c.mode ?? v.mode),
|
|
2280
|
+
transport: Nn(c.transport ?? v.transport)
|
|
2281
|
+
}, x = await or(a, b), S = Pn(a);
|
|
2282
|
+
c.compatibility === void 0 && S?.hasAttribute("data-formie-compatibility") && (b.compatibility = J(S).compatibility);
|
|
2266
2283
|
let C = Te(b.compatibility);
|
|
2267
|
-
S && e(S, b), b.staticCache = c.staticCache ??
|
|
2284
|
+
S && e(S, b), b.staticCache = c.staticCache ?? jn(S ? S.dataset : a.dataset);
|
|
2268
2285
|
let w;
|
|
2269
2286
|
try {
|
|
2270
|
-
w =
|
|
2287
|
+
w = nr(a, S), x?.modules && n(x.modules), w?.modules && n(w.modules);
|
|
2271
2288
|
} catch (e) {
|
|
2272
2289
|
if (S) {
|
|
2273
2290
|
S.addEventListener("submit", (e) => {
|
|
@@ -2286,15 +2303,15 @@ function cr() {
|
|
|
2286
2303
|
surface: "server-rendered",
|
|
2287
2304
|
entries: []
|
|
2288
2305
|
};
|
|
2289
|
-
n(E),
|
|
2290
|
-
target:
|
|
2306
|
+
n(E), K.log("Resolved mount payload.", {
|
|
2307
|
+
target: Z(a),
|
|
2291
2308
|
hasRenderPayload: !!x,
|
|
2292
2309
|
hasEmbeddedPayload: !!w,
|
|
2293
2310
|
moduleCount: E.entries.length
|
|
2294
2311
|
});
|
|
2295
|
-
let D = re(a, te, S), O = S ? new
|
|
2296
|
-
live:
|
|
2297
|
-
errorAriaLive:
|
|
2312
|
+
let D = re(a, te, S), O = S ? new gn(S, {
|
|
2313
|
+
live: Hn(S.dataset.formieValidationOnFocus),
|
|
2314
|
+
errorAriaLive: Me(S),
|
|
2298
2315
|
errorMessage: S.dataset.formieErrorMessage || "",
|
|
2299
2316
|
fieldContainerErrorClass: D.fieldLayoutError || [],
|
|
2300
2317
|
inputErrorClass: D.fieldControlError || [],
|
|
@@ -2311,8 +2328,8 @@ function cr() {
|
|
|
2311
2328
|
};
|
|
2312
2329
|
g(S, "formie:validator:ready", t), g(a, "formie:validator:ready", t);
|
|
2313
2330
|
}
|
|
2314
|
-
S && (y(S), (x || b.endpoint || a.dataset.formieEndpoint) &&
|
|
2315
|
-
let k = await
|
|
2331
|
+
S && (y(S), (x || b.endpoint || a.dataset.formieEndpoint) && Vn(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);
|
|
2332
|
+
let k = await nn(E, {
|
|
2316
2333
|
registry: r,
|
|
2317
2334
|
matchContext: {
|
|
2318
2335
|
root: a,
|
|
@@ -2329,24 +2346,24 @@ function cr() {
|
|
|
2329
2346
|
state: ne,
|
|
2330
2347
|
on: (e, t) => d.on(e, t),
|
|
2331
2348
|
emit: (e, t) => (g(a, e, t), d.emitSafe(e, t).then((t) => {
|
|
2332
|
-
t.failed.length > 0 &&
|
|
2349
|
+
t.failed.length > 0 && K.warn("Lifecycle listeners failed.", {
|
|
2333
2350
|
eventName: e,
|
|
2334
2351
|
failed: t.failed.length
|
|
2335
2352
|
});
|
|
2336
2353
|
}))
|
|
2337
2354
|
}
|
|
2338
2355
|
});
|
|
2339
|
-
|
|
2340
|
-
target:
|
|
2356
|
+
K.log("Module setup complete.", {
|
|
2357
|
+
target: Z(a),
|
|
2341
2358
|
moduleInstances: k.instances.length
|
|
2342
2359
|
});
|
|
2343
2360
|
let A = {
|
|
2344
2361
|
id: m,
|
|
2345
2362
|
root: a,
|
|
2346
2363
|
submit: async (e = "submit") => {
|
|
2347
|
-
if (
|
|
2364
|
+
if (K.log("Submit requested.", {
|
|
2348
2365
|
id: m,
|
|
2349
|
-
target:
|
|
2366
|
+
target: Z(a),
|
|
2350
2367
|
action: e
|
|
2351
2368
|
}), !S) return {
|
|
2352
2369
|
ok: !1,
|
|
@@ -2361,24 +2378,24 @@ function cr() {
|
|
|
2361
2378
|
message: "Submission already in progress.",
|
|
2362
2379
|
formErrors: []
|
|
2363
2380
|
};
|
|
2364
|
-
let n = S.querySelector(`[data-formie-action="${e}"]`), r = await
|
|
2381
|
+
let n = S.querySelector(`[data-formie-action="${e}"]`), r = await Ut({
|
|
2365
2382
|
id: m,
|
|
2366
2383
|
target: a,
|
|
2367
2384
|
form: S,
|
|
2368
2385
|
bus: d,
|
|
2369
2386
|
validator: O,
|
|
2370
|
-
validateOnSubmit:
|
|
2387
|
+
validateOnSubmit: X(S),
|
|
2371
2388
|
action: e,
|
|
2372
2389
|
submitter: n,
|
|
2373
|
-
waitForSubmitDelay:
|
|
2390
|
+
waitForSubmitDelay: er,
|
|
2374
2391
|
onRefreshTokensAfterSubmit: async () => {
|
|
2375
|
-
await
|
|
2392
|
+
await sr(a, b, S);
|
|
2376
2393
|
},
|
|
2377
2394
|
dispatchSubmitResult: (e) => {
|
|
2378
2395
|
g(a, "formie:submit:result", e);
|
|
2379
2396
|
}
|
|
2380
2397
|
});
|
|
2381
|
-
return
|
|
2398
|
+
return K.log("Submit completed.", {
|
|
2382
2399
|
id: m,
|
|
2383
2400
|
action: e,
|
|
2384
2401
|
ok: r.ok,
|
|
@@ -2391,7 +2408,7 @@ function cr() {
|
|
|
2391
2408
|
},
|
|
2392
2409
|
on: (e, t) => d.on(e, t)
|
|
2393
2410
|
}, j = _(a, S, A);
|
|
2394
|
-
if (S && (
|
|
2411
|
+
if (S && (je({
|
|
2395
2412
|
target: a,
|
|
2396
2413
|
form: S,
|
|
2397
2414
|
validatorDetail: O ? {
|
|
@@ -2408,9 +2425,9 @@ function cr() {
|
|
|
2408
2425
|
options: C,
|
|
2409
2426
|
unbinds: f
|
|
2410
2427
|
})), S) {
|
|
2411
|
-
|
|
2428
|
+
cr(a, S, b, d, O, f), O && (f.push(p(S, O, a)), f.push(xn(S)));
|
|
2412
2429
|
try {
|
|
2413
|
-
await
|
|
2430
|
+
await lr(a, b, S);
|
|
2414
2431
|
} catch (e) {
|
|
2415
2432
|
throw j(), e;
|
|
2416
2433
|
}
|
|
@@ -2478,24 +2495,24 @@ function cr() {
|
|
|
2478
2495
|
id: m,
|
|
2479
2496
|
mode: b.mode,
|
|
2480
2497
|
instance: A
|
|
2481
|
-
}), S instanceof HTMLFormElement && ee(S),
|
|
2498
|
+
}), S instanceof HTMLFormElement && ee(S), K.log("Mount complete.", {
|
|
2482
2499
|
id: m,
|
|
2483
|
-
target:
|
|
2500
|
+
target: Z(a),
|
|
2484
2501
|
mode: b.mode
|
|
2485
2502
|
}), A;
|
|
2486
2503
|
}, l = (e, n) => {
|
|
2487
|
-
if (!n.autoVisible ||
|
|
2504
|
+
if (!n.autoVisible || rr(e) || typeof IntersectionObserver > "u") return c(e, n);
|
|
2488
2505
|
if (t.has(e)) return Promise.resolve(t.get(e)?.instance || null);
|
|
2489
|
-
if (i.has(e)) return
|
|
2506
|
+
if (i.has(e)) return K.log("Mount deferred (already waiting visibility).", { target: Z(e) }), Promise.resolve(null);
|
|
2490
2507
|
let r = new IntersectionObserver((t) => {
|
|
2491
|
-
t.some((t) => t.target === e && t.isIntersecting) && (r.disconnect(), i.delete(e),
|
|
2508
|
+
t.some((t) => t.target === e && t.isIntersecting) && (r.disconnect(), i.delete(e), K.log("Visibility reached, proceeding mount.", { target: Z(e) }), c(e, {
|
|
2492
2509
|
...n,
|
|
2493
2510
|
autoVisible: !1
|
|
2494
2511
|
}));
|
|
2495
2512
|
}, { threshold: .01 });
|
|
2496
2513
|
return r.observe(e), i.set(e, () => {
|
|
2497
2514
|
r.disconnect();
|
|
2498
|
-
}),
|
|
2515
|
+
}), K.log("Mount deferred until visible.", { target: Z(e) }), Promise.resolve(null);
|
|
2499
2516
|
};
|
|
2500
2517
|
return {
|
|
2501
2518
|
mount: c,
|
|
@@ -2503,7 +2520,7 @@ function cr() {
|
|
|
2503
2520
|
update: async (e, n) => {
|
|
2504
2521
|
let r = t.get(e);
|
|
2505
2522
|
if (!r) return c(e, {
|
|
2506
|
-
...
|
|
2523
|
+
...J(e),
|
|
2507
2524
|
...n,
|
|
2508
2525
|
mode: n.mode || "server-rendered"
|
|
2509
2526
|
});
|
|
@@ -2511,7 +2528,7 @@ function cr() {
|
|
|
2511
2528
|
...r.options,
|
|
2512
2529
|
...n
|
|
2513
2530
|
};
|
|
2514
|
-
let i = n.payload?.theme || r.options.payload?.theme ||
|
|
2531
|
+
let i = n.payload?.theme || r.options.payload?.theme || nr(e, r.form)?.theme, a = re(e, i, r.form);
|
|
2515
2532
|
return r.validator && (r.validator.config.fieldContainerErrorClass = a.fieldLayoutError || [], r.validator.config.inputErrorClass = a.fieldControlError || [], r.validator.config.messagesClass = a.fieldErrors || [], r.validator.config.messageClass = a.fieldError || []), Object.keys(a).length && g(e, "formie:theme:applied", {
|
|
2516
2533
|
hasClasses: !0,
|
|
2517
2534
|
reason: "update"
|
|
@@ -2519,24 +2536,24 @@ function cr() {
|
|
|
2519
2536
|
},
|
|
2520
2537
|
getInstance: (e) => t.get(e)?.instance || null,
|
|
2521
2538
|
refreshForCache: async (e) => {
|
|
2522
|
-
|
|
2539
|
+
Fn("refreshForCache", "Global `Formie.refreshForCache()` has been deprecated. Use built-in static-cache token refresh handling instead.");
|
|
2523
2540
|
let n = null;
|
|
2524
2541
|
if (n = typeof e == "string" ? document.getElementById(e) || document.querySelector(`[data-formie-form-id="${e}"]`) : e, !n) {
|
|
2525
|
-
|
|
2542
|
+
K.warn("refreshForCache target not found.", { targetOrId: e });
|
|
2526
2543
|
return;
|
|
2527
2544
|
}
|
|
2528
|
-
let r = t.get(n), i =
|
|
2545
|
+
let r = t.get(n), i = Pn(n), a = r?.options || J(n);
|
|
2529
2546
|
if (!i) {
|
|
2530
|
-
|
|
2547
|
+
K.warn("refreshForCache found no form element for target.", { target: Z(n) });
|
|
2531
2548
|
return;
|
|
2532
2549
|
}
|
|
2533
|
-
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s =
|
|
2550
|
+
let o = a.formHandle || n.dataset.formieHandle || i.dataset.formieHandle, s = zn(a, n), c = i.querySelector("input[name=\"renderId\"]")?.value || void 0;
|
|
2534
2551
|
if (!o) {
|
|
2535
|
-
|
|
2552
|
+
K.warn("refreshForCache found no form handle for target.", { target: Z(n) });
|
|
2536
2553
|
return;
|
|
2537
2554
|
}
|
|
2538
|
-
let l = await Xe(s, o, c, a, i
|
|
2539
|
-
l && (
|
|
2555
|
+
let l = await Xe(s, o, c, a, i.querySelector("input[name=\"requestToken\"]")?.value, i.querySelector("input[name=\"siteId\"]")?.value || a.siteId);
|
|
2556
|
+
l && (ar(i, l), g(n, "formie:refresh-tokens:after", l));
|
|
2540
2557
|
},
|
|
2541
2558
|
registerModule: (e, t) => r.register(e, t),
|
|
2542
2559
|
unregisterModule: (e) => {
|
|
@@ -2544,16 +2561,16 @@ function cr() {
|
|
|
2544
2561
|
},
|
|
2545
2562
|
getRegisteredModules: () => r.getAll(),
|
|
2546
2563
|
scan: async (e) => {
|
|
2547
|
-
let t = e || document, n = Array.from(t.querySelectorAll(
|
|
2548
|
-
|
|
2564
|
+
let t = e || document, n = Array.from(t.querySelectorAll(G));
|
|
2565
|
+
K.log("Scan started.", {
|
|
2549
2566
|
scope: t === document ? "document" : t,
|
|
2550
2567
|
targetCount: n.length
|
|
2551
2568
|
});
|
|
2552
2569
|
let r = (await Promise.all(n.map((e) => {
|
|
2553
|
-
let t =
|
|
2570
|
+
let t = J(e);
|
|
2554
2571
|
return l(e, t);
|
|
2555
2572
|
}))).filter((e) => !!e);
|
|
2556
|
-
return
|
|
2573
|
+
return K.log("Scan finished.", {
|
|
2557
2574
|
mountedCount: r.length,
|
|
2558
2575
|
deferredCount: n.length - r.length
|
|
2559
2576
|
}), r;
|
|
@@ -2561,16 +2578,16 @@ function cr() {
|
|
|
2561
2578
|
observe: (e) => {
|
|
2562
2579
|
if (typeof MutationObserver > "u") return () => {};
|
|
2563
2580
|
let n = e || document;
|
|
2564
|
-
|
|
2581
|
+
K.log("Observer started.", { scope: n === document ? "document" : n });
|
|
2565
2582
|
let r = new MutationObserver((e) => {
|
|
2566
2583
|
e.forEach((e) => {
|
|
2567
2584
|
e.addedNodes.forEach((e) => {
|
|
2568
|
-
e instanceof Element && (e.matches(
|
|
2569
|
-
|
|
2585
|
+
e instanceof Element && (e.matches(G) && (K.log("Observer detected new root.", { target: Z(e) }), l(e, J(e))), e.querySelectorAll(G).forEach((e) => {
|
|
2586
|
+
K.log("Observer detected new nested root.", { target: Z(e) }), l(e, J(e));
|
|
2570
2587
|
}));
|
|
2571
2588
|
}), e.removedNodes.forEach((e) => {
|
|
2572
|
-
e instanceof Element && (t.has(e) && (
|
|
2573
|
-
t.has(e) && (
|
|
2589
|
+
e instanceof Element && (t.has(e) && (K.log("Observer detected removed root.", { target: Z(e) }), s(e)), e.querySelectorAll(G).forEach((e) => {
|
|
2590
|
+
t.has(e) && (K.log("Observer detected removed nested root.", { target: Z(e) }), s(e));
|
|
2574
2591
|
}));
|
|
2575
2592
|
});
|
|
2576
2593
|
});
|
|
@@ -2579,11 +2596,11 @@ function cr() {
|
|
|
2579
2596
|
childList: !0,
|
|
2580
2597
|
subtree: !0
|
|
2581
2598
|
}), () => {
|
|
2582
|
-
r.disconnect(),
|
|
2583
|
-
|
|
2599
|
+
r.disconnect(), K.log("Observer stopped."), i.forEach((e, t) => {
|
|
2600
|
+
ir(t, n) && (e(), i.delete(t));
|
|
2584
2601
|
});
|
|
2585
2602
|
let e = [];
|
|
2586
|
-
n instanceof Element && n.matches(
|
|
2603
|
+
n instanceof Element && n.matches(G) && e.push(n), n.querySelectorAll(G).forEach((t) => {
|
|
2587
2604
|
e.push(t);
|
|
2588
2605
|
}), e.forEach((e) => {
|
|
2589
2606
|
t.has(e) && s(e);
|
|
@@ -2594,13 +2611,13 @@ function cr() {
|
|
|
2594
2611
|
}
|
|
2595
2612
|
//#endregion
|
|
2596
2613
|
//#region src/js/core/hydrate-modules.ts
|
|
2597
|
-
var
|
|
2598
|
-
async function
|
|
2614
|
+
var dr = O("general", "module-hydrator");
|
|
2615
|
+
async function fr(e) {
|
|
2599
2616
|
let t = e.root, n = e.form ?? (t instanceof HTMLFormElement ? t : t.closest("form") ?? t.querySelector("form")), r = e.surface ?? "cp-edit", i = e.modules ?? {
|
|
2600
2617
|
contractVersion: 2,
|
|
2601
2618
|
surface: r,
|
|
2602
2619
|
entries: []
|
|
2603
|
-
}, a = e.registry ?? new B(), o = new
|
|
2620
|
+
}, a = e.registry ?? new B(), o = new Wt(), s = await nn(i, {
|
|
2604
2621
|
registry: a,
|
|
2605
2622
|
setupContext: {
|
|
2606
2623
|
formId: n?.id || t.id || "formie-modules",
|
|
@@ -2625,7 +2642,7 @@ async function ur(e) {
|
|
|
2625
2642
|
surface: r
|
|
2626
2643
|
}
|
|
2627
2644
|
});
|
|
2628
|
-
return
|
|
2645
|
+
return dr.log("Hydrated module manifest.", {
|
|
2629
2646
|
moduleCount: i.entries.length,
|
|
2630
2647
|
instanceCount: s.instances.length,
|
|
2631
2648
|
surface: r
|
|
@@ -2692,44 +2709,44 @@ async function ur(e) {
|
|
|
2692
2709
|
}
|
|
2693
2710
|
//#endregion
|
|
2694
2711
|
//#region src/js/core/formie.ts
|
|
2695
|
-
function
|
|
2712
|
+
function Q(e) {
|
|
2696
2713
|
return e instanceof Element;
|
|
2697
2714
|
}
|
|
2698
|
-
function
|
|
2715
|
+
function pr(e) {
|
|
2699
2716
|
return e.ok;
|
|
2700
2717
|
}
|
|
2701
|
-
function
|
|
2702
|
-
return typeof e == "string" ? `selector "${e}"` :
|
|
2718
|
+
function mr(e) {
|
|
2719
|
+
return typeof e == "string" ? `selector "${e}"` : Q(e) ? `element "${e.tagName.toLowerCase()}"` : "provided element collection";
|
|
2703
2720
|
}
|
|
2704
|
-
function
|
|
2721
|
+
function hr(e) {
|
|
2705
2722
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2706
|
-
for (let r of e)
|
|
2723
|
+
for (let r of e) Q(r) && !t.has(r) && (t.add(r), n.push(r));
|
|
2707
2724
|
return n;
|
|
2708
2725
|
}
|
|
2709
|
-
function
|
|
2710
|
-
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) :
|
|
2726
|
+
function $(e) {
|
|
2727
|
+
return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : Q(e) ? [e] : hr(e);
|
|
2711
2728
|
}
|
|
2712
|
-
function
|
|
2729
|
+
function gr() {
|
|
2713
2730
|
return document.readyState === "loading" ? new Promise((e) => {
|
|
2714
2731
|
document.addEventListener("DOMContentLoaded", () => e(), { once: !0 });
|
|
2715
2732
|
}) : Promise.resolve();
|
|
2716
2733
|
}
|
|
2717
|
-
async function
|
|
2718
|
-
let t =
|
|
2719
|
-
return t.length > 0 || typeof e != "string" ? t : (await
|
|
2720
|
-
}
|
|
2721
|
-
function _r(e) {
|
|
2722
|
-
return typeof e == "string" ? document : $(e) ? e.getRootNode() : document;
|
|
2734
|
+
async function _r(e) {
|
|
2735
|
+
let t = $(e);
|
|
2736
|
+
return t.length > 0 || typeof e != "string" ? t : (await gr(), $(e));
|
|
2723
2737
|
}
|
|
2724
2738
|
function vr(e) {
|
|
2739
|
+
return typeof e == "string" ? document : Q(e) ? e.getRootNode() : document;
|
|
2740
|
+
}
|
|
2741
|
+
function yr(e) {
|
|
2725
2742
|
let { element: t, observe: n, allowEmpty: r, client: i, onReady: a, onResult: o, onSuccess: s, onError: c, onEvent: l, ...u } = e;
|
|
2726
2743
|
return {
|
|
2727
2744
|
mode: "server-rendered",
|
|
2728
2745
|
...u
|
|
2729
2746
|
};
|
|
2730
2747
|
}
|
|
2731
|
-
async function
|
|
2732
|
-
let i = [], a =
|
|
2748
|
+
async function br(e, t, n, r) {
|
|
2749
|
+
let i = [], a = yr(e);
|
|
2733
2750
|
for (let o of r) {
|
|
2734
2751
|
let r = n.get(o);
|
|
2735
2752
|
if (r) {
|
|
@@ -2739,7 +2756,7 @@ async function yr(e, t, n, r) {
|
|
|
2739
2756
|
let s = await t.mount(o, a), c = [];
|
|
2740
2757
|
if (e.onReady?.(s), c.push(s.on("formie:submit:result", (t) => {
|
|
2741
2758
|
let n = t;
|
|
2742
|
-
e.onResult?.(n, s),
|
|
2759
|
+
e.onResult?.(n, s), pr(n) ? e.onSuccess?.(n, s) : e.onError?.(n, s);
|
|
2743
2760
|
})), e.onEvent) for (let t of l) c.push(s.on(t, (n) => {
|
|
2744
2761
|
e.onEvent?.({
|
|
2745
2762
|
name: t,
|
|
@@ -2753,11 +2770,11 @@ async function yr(e, t, n, r) {
|
|
|
2753
2770
|
}
|
|
2754
2771
|
return i;
|
|
2755
2772
|
}
|
|
2756
|
-
async function
|
|
2757
|
-
let t = e.client ??
|
|
2758
|
-
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${
|
|
2759
|
-
await
|
|
2760
|
-
let i = e.observe ? t.observe(
|
|
2773
|
+
async function xr(e) {
|
|
2774
|
+
let t = e.client ?? ur(), n = /* @__PURE__ */ new Map(), r = await _r(e.element);
|
|
2775
|
+
if (r.length === 0 && !e.allowEmpty) throw Error(`Formie could not find any elements for ${mr(e.element)}.`);
|
|
2776
|
+
await br(e, t, n, r);
|
|
2777
|
+
let i = e.observe ? t.observe(vr(e.element)) : null;
|
|
2761
2778
|
return {
|
|
2762
2779
|
client: t,
|
|
2763
2780
|
get instances() {
|
|
@@ -2768,8 +2785,8 @@ async function br(e) {
|
|
|
2768
2785
|
return r ? n.get(r)?.instance ?? t.getInstance(r) : null;
|
|
2769
2786
|
},
|
|
2770
2787
|
async rescan() {
|
|
2771
|
-
let r =
|
|
2772
|
-
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) :
|
|
2788
|
+
let r = $(e.element);
|
|
2789
|
+
return r.length === 0 ? Array.from(n.values()).map(({ instance: e }) => e) : br(e, t, n, r);
|
|
2773
2790
|
},
|
|
2774
2791
|
async destroy() {
|
|
2775
2792
|
i?.();
|
|
@@ -2780,7 +2797,7 @@ async function br(e) {
|
|
|
2780
2797
|
}
|
|
2781
2798
|
//#endregion
|
|
2782
2799
|
//#region src/js/core/client-rendered-modules.ts
|
|
2783
|
-
var
|
|
2800
|
+
var Sr = {
|
|
2784
2801
|
conditions: {
|
|
2785
2802
|
kind: "core",
|
|
2786
2803
|
reason: "Core evaluates structured conditions and the adapter renders visibility."
|
|
@@ -2814,8 +2831,8 @@ var xr = {
|
|
|
2814
2831
|
reason: "The adapter renders the structured date input contract."
|
|
2815
2832
|
}
|
|
2816
2833
|
};
|
|
2817
|
-
async function
|
|
2818
|
-
for (let [e, t] of Object.entries(
|
|
2834
|
+
async function Cr(t, n, r = Gt) {
|
|
2835
|
+
for (let [e, t] of Object.entries(Sr)) {
|
|
2819
2836
|
let n = `formie:${e}`;
|
|
2820
2837
|
r.get(n) || r.register({
|
|
2821
2838
|
moduleId: n,
|
|
@@ -2843,7 +2860,7 @@ async function Sr(t, n, r = Wt) {
|
|
|
2843
2860
|
}
|
|
2844
2861
|
};
|
|
2845
2862
|
a();
|
|
2846
|
-
let o = n.subscribe(a), s = await
|
|
2863
|
+
let o = n.subscribe(a), s = await fr({
|
|
2847
2864
|
root: t,
|
|
2848
2865
|
modules: n.getState().definition.modules,
|
|
2849
2866
|
surface: "client-rendered",
|
|
@@ -2877,4 +2894,4 @@ async function Sr(t, n, r = Wt) {
|
|
|
2877
2894
|
};
|
|
2878
2895
|
}
|
|
2879
2896
|
//#endregion
|
|
2880
|
-
export { l as FORMIE_HTML_EVENT_NAMES,
|
|
2897
|
+
export { l as FORMIE_HTML_EVENT_NAMES, gn as FormieValidator, Ce as LEGACY_FORMIE_DOM_EVENT_BRIDGES, we as LEGACY_FORMIE_VALIDATOR_EVENT_BRIDGES, B as ModuleRegistry, Ae as bindLegacyDomEventCompatibility, je as bindLegacyValidatorCompatibility, be as buildFieldValueRegistry, Gt as clientRenderedModuleRegistry, O as createDebug, ur as createFormieClient, E as debugLog, D as debugWarn, Se as defineAddressModule, me as defineCaptchaModule, pe as definePassiveCaptchaModule, w as definePaymentModule, _e as fieldKeyToInputName, xr as formie, c as getFieldModuleEventName, fe as getFormieTranslations, s as getGlobalModuleLifecycleEventName, i as getScopedModuleLifecycleEventName, fr as hydrateFormieModules, he as inputNameToFieldKey, ne as isFormieDebugEnabled, ue as mergeFormieTranslations, Cr 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 };
|