@verbb/formie-browser 1.0.2 → 1.0.3
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 +8 -0
- package/dist/chunks/{address-finder-CQW81kY0.js → address-finder-BjMuEiwF.js} +2 -2
- package/dist/chunks/{bpoint-D8OjLmsn.js → bpoint-KudsBCo2.js} +1 -1
- package/dist/chunks/{calculations-BqZsENCq.js → calculations-DlGSkQ3W.js} +2 -2
- package/dist/chunks/{captcha-eu-DIa6aUWz.js → captcha-eu-CterYFok.js} +2 -2
- package/dist/chunks/{checkbox-radio-BI-UjgMF.js → checkbox-radio-CBvgk3hR.js} +2 -2
- package/dist/chunks/{conditions-BVl6jTYo.js → conditions-DYy1-Hwt.js} +189 -163
- package/dist/chunks/{date-picker-69TgvErA.js → date-picker-BlD--zfe.js} +2 -2
- package/dist/chunks/{eway-1GPxH6DU.js → eway-qwc-B5Us.js} +2 -2
- package/dist/chunks/file-upload-CIgHrXfp.js +316 -0
- package/dist/chunks/{friendly-captcha-v1-DA2QPKA3.js → friendly-captcha-v1-EDFac33c.js} +1 -1
- package/dist/chunks/{friendly-captcha-v2-BorOWiz_.js → friendly-captcha-v2-BDpSvFGR.js} +1 -1
- package/dist/chunks/{go-cardless-DwBgERcA.js → go-cardless-DuDMVsnz.js} +1 -1
- package/dist/chunks/{google-address-BcTBncyS.js → google-address-Bmjp01pH.js} +77 -58
- package/dist/chunks/{hcaptcha-BchdVCqq.js → hcaptcha-BTQ6An6g.js} +2 -2
- package/dist/chunks/{hidden-D8RqSPt7.js → hidden-DbPdOxKb.js} +1 -1
- package/dist/chunks/{index-C1ZOKiAi.js → index-BcqwpPNE.js} +1261 -1176
- package/dist/chunks/{loqate-nXuTX7In.js → loqate-BdNGv93o.js} +2 -2
- package/dist/chunks/{mollie-qdCynQCd.js → mollie-DFOjTuGX.js} +1 -1
- package/dist/chunks/{moneris-BNEA-laO.js → moneris-BbFfl-EL.js} +1 -1
- package/dist/chunks/{opayo-BJtXOkuK.js → opayo-CmgYa9ya.js} +2 -2
- package/dist/chunks/{paddle-D72Pa8kr.js → paddle-BUi7w1_o.js} +2 -2
- package/dist/chunks/{paypal-Cqt2bned.js → paypal-A-ePfh6k.js} +2 -2
- package/dist/chunks/{payway-BjCqsc0H.js → payway-BqFCbhyo.js} +2 -2
- package/dist/chunks/{phone-country-K9pYAlzM.js → phone-country-DPMiqk4L.js} +2 -2
- package/dist/chunks/{place-kit-Dg6f_UoM.js → place-kit-CX7tamAg.js} +1 -1
- package/dist/chunks/{recaptcha-enterprise--VYAeeqz.js → recaptcha-enterprise-DxF6cW95.js} +2 -2
- package/dist/chunks/{recaptcha-shared-PSIEEEe1.js → recaptcha-shared-DhGcbiaq.js} +2 -2
- package/dist/chunks/{recaptcha-v2-checkbox-atBNe5ml.js → recaptcha-v2-checkbox-R9EfbZ4k.js} +2 -2
- package/dist/chunks/{recaptcha-v2-invisible-DnBufNPT.js → recaptcha-v2-invisible-DV9hswAp.js} +2 -2
- package/dist/chunks/{recaptcha-v3-CF6O8rDj.js → recaptcha-v3-V0xc-Edh.js} +2 -2
- package/dist/chunks/{repeater-CB7Yojvx.js → repeater-DKUT6TGI.js} +2 -2
- package/dist/chunks/{rich-text-nAV_SQZo.js → rich-text-SH7KiaKH.js} +1 -1
- package/dist/chunks/{scripts-BkAAux0i.js → scripts-D9N2d5rN.js} +1 -1
- package/dist/chunks/{shared-DGqeMvcJ.js → shared-BmntPmnW.js} +4 -4
- package/dist/chunks/{signature-BT6CsQ6n.js → signature-BA3tQsGT.js} +1 -1
- package/dist/chunks/{snaptcha-C7qQo02f.js → snaptcha-DV7p6J9k.js} +1 -1
- package/dist/chunks/{square-C5AH3trb.js → square-Bs-ndqYK.js} +2 -2
- package/dist/chunks/{stripe-EJK0RyUv.js → stripe-DkZAHxtn.js} +2 -2
- package/dist/chunks/{summary-DC_ipXCU.js → summary-Dq2i9TQk.js} +2 -2
- package/dist/chunks/{table-BEAI99qo.js → table-Cu4WfVcw.js} +2 -2
- package/dist/chunks/{text-limit-Blgq5G-G.js → text-limit-2ycmB-Ae.js} +1 -1
- package/dist/chunks/{turnstile-_uCRwnU-.js → turnstile-CId90tRr.js} +2 -2
- package/dist/css/theme/forms/_form.css +28 -0
- package/dist/index.js +1 -1
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/submit-result-state.d.ts.map +1 -1
- package/dist/js/modules/address/google-address.d.ts +7 -0
- package/dist/js/modules/address/google-address.d.ts.map +1 -1
- package/dist/js/modules/fields/conditions/effects.d.ts +3 -1
- package/dist/js/modules/fields/conditions/effects.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/submit/pipeline.d.ts.map +1 -1
- package/dist/js/validation/scope.d.ts +6 -0
- package/dist/js/validation/scope.d.ts.map +1 -0
- package/dist/js/validation/submit-readiness.d.ts +4 -0
- package/dist/js/validation/submit-readiness.d.ts.map +1 -0
- package/dist/js/validation/validator.d.ts +1 -0
- package/dist/js/validation/validator.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/css/theme/forms/_form.css +28 -0
- package/src/js/core/create-formie-client.ts +6 -0
- package/src/js/core/submit-result-state.ts +17 -0
- package/src/js/modules/address/google-address.ts +33 -1
- package/src/js/modules/fields/conditions/effects.ts +79 -2
- package/src/js/modules/fields/conditions.ts +53 -11
- package/src/js/modules/fields/file-upload.ts +188 -96
- package/src/js/submit/pipeline.ts +3 -28
- package/src/js/validation/scope.ts +25 -0
- package/src/js/validation/submit-readiness.ts +157 -0
- package/src/js/validation/validator.ts +4 -0
- package/dist/chunks/file-upload-BDZZftgL.js +0 -281
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as st, d as Qn } from "./shared-
|
|
1
|
+
import { g as st, d as Qn } from "./shared-BmntPmnW.js";
|
|
2
2
|
import { e as ft } from "./styles-C3aqgtek.js";
|
|
3
|
-
import { h as ut } from "./index-
|
|
3
|
+
import { h as ut } from "./index-BcqwpPNE.js";
|
|
4
4
|
function ct(a, i) {
|
|
5
5
|
for (var e = 0; e < i.length; e++) {
|
|
6
6
|
const u = i[e];
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { r as K, a as O, d as x } from "./shared-BmntPmnW.js";
|
|
2
|
+
import { e as q } from "./styles-C3aqgtek.js";
|
|
3
|
+
import { k as B, l as j, m as W, o as Y } from "./index-BcqwpPNE.js";
|
|
4
|
+
const $ = "@layer formie-theme{.formie-file-input{padding:var(--formie-space-1);line-height:var(--formie-line-height-base);cursor:pointer}.formie-file-input::file-selector-button,.formie-file-input::-webkit-file-upload-button{appearance:none;-webkit-appearance:none;margin-inline-end:var(--formie-space-2);padding:calc(var(--formie-control-padding-y) - 1px) var(--formie-space-2);min-height:calc(var(--formie-control-height) - (var(--formie-space-1) * 2));border:var(--formie-border-width) solid var(--formie-color-border);border-radius:calc(var(--formie-radius-sm) - 1px);background:var(--formie-color-surface-subtle);color:var(--formie-color-heading);font-weight:var(--formie-font-weight-normal);font-size:var(--formie-font-size-xs);line-height:1.1;white-space:nowrap;cursor:pointer;transition:border-color .15s ease,background-color .15s ease,color .15s ease,box-shadow .15s ease}.formie-file-input:hover::file-selector-button,.formie-file-input:hover::-webkit-file-upload-button{border-color:color-mix(in srgb,var(--formie-color-border) 70%,var(--formie-color-heading) 30%);background:var(--formie-color-surface-muted)}.formie-file-input:focus{outline:0}.formie-file-input:focus-visible::file-selector-button,.formie-file-input:focus-visible::-webkit-file-upload-button{border-color:var(--formie-color-focus-ring)}.formie-field-has-error .formie-file-input::file-selector-button,.formie-field-has-error .formie-file-input::-webkit-file-upload-button{border-color:var(--formie-color-danger)}.formie-file-summary{padding:var(--formie-file-summary-padding);gap:var(--formie-gap-file-summary);border:var(--formie-border-width) solid var(--formie-color-border);border-radius:var(--formie-radius-sm)}.formie-file-summary-container{margin:0;padding-left:var(--formie-list-indent)}}", _ = 'input[type="file"][data-formie-file-input]', F = j("uploaded"), L = W("reset"), J = "data-formie-file-upload-key", G = "data-formie-file-upload-hydrate-endpoint", I = "data-formie-file-upload-anchor", Q = "data-formie-file-upload-asset-id", X = [
|
|
5
|
+
"fileLimit",
|
|
6
|
+
"fileSizeMinLimit",
|
|
7
|
+
"fileSizeMaxLimit"
|
|
8
|
+
], w = "file-upload", E = "file-upload", T = B("repeater", "init-row"), Z = "[data-formie-field-handle]";
|
|
9
|
+
q(E, [$]);
|
|
10
|
+
function h(e) {
|
|
11
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
12
|
+
}
|
|
13
|
+
function b(e) {
|
|
14
|
+
const t = Number(e);
|
|
15
|
+
return Number.isInteger(t) && t > 0 ? t : null;
|
|
16
|
+
}
|
|
17
|
+
function c(e) {
|
|
18
|
+
return typeof e == "string" ? e.trim() : "";
|
|
19
|
+
}
|
|
20
|
+
function M(e) {
|
|
21
|
+
return e.getAttribute("data-formie-field-handle")?.trim() || "";
|
|
22
|
+
}
|
|
23
|
+
function k(e) {
|
|
24
|
+
return e.name.endsWith("[]") ? e.name.slice(0, -2) : e.name;
|
|
25
|
+
}
|
|
26
|
+
function D(e) {
|
|
27
|
+
return `${k(e)}[]`;
|
|
28
|
+
}
|
|
29
|
+
function ee(e) {
|
|
30
|
+
return e.getAttribute(J)?.trim() || e.getAttribute("data-formie-input-id")?.trim() || "";
|
|
31
|
+
}
|
|
32
|
+
function C(e) {
|
|
33
|
+
return Array.from(e.querySelectorAll('input[type="hidden"]')).filter((t) => t instanceof HTMLInputElement);
|
|
34
|
+
}
|
|
35
|
+
function P(e, t) {
|
|
36
|
+
const r = D(t);
|
|
37
|
+
return C(e).filter((n) => n.name === r && n.value.trim() !== "");
|
|
38
|
+
}
|
|
39
|
+
function te(e, t) {
|
|
40
|
+
const r = k(t), n = C(e).find((s) => s.hasAttribute(I) || s.name === r && s.value === "");
|
|
41
|
+
if (n)
|
|
42
|
+
return n.setAttribute(I, "true"), n.name = r, n.value = "", n;
|
|
43
|
+
const i = document.createElement("input");
|
|
44
|
+
return i.type = "hidden", i.name = r, i.value = "", i.setAttribute(I, "true"), t.insertAdjacentElement("afterend", i), i;
|
|
45
|
+
}
|
|
46
|
+
function N(e) {
|
|
47
|
+
if (Array.isArray(e))
|
|
48
|
+
return null;
|
|
49
|
+
const t = b(e);
|
|
50
|
+
if (t)
|
|
51
|
+
return {
|
|
52
|
+
assetId: t,
|
|
53
|
+
filename: ""
|
|
54
|
+
};
|
|
55
|
+
if (!h(e))
|
|
56
|
+
return null;
|
|
57
|
+
const r = b(e.assetId ?? e.id ?? e.value), n = c(e.filename ?? e.title ?? e.label ?? e.name), i = c(e.url) || null;
|
|
58
|
+
return !r && !n ? null : {
|
|
59
|
+
assetId: r,
|
|
60
|
+
filename: n,
|
|
61
|
+
url: i
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function v(e) {
|
|
65
|
+
if (!Array.isArray(e)) {
|
|
66
|
+
const t = N(e);
|
|
67
|
+
return t ? [t] : [];
|
|
68
|
+
}
|
|
69
|
+
return e.flatMap((t) => {
|
|
70
|
+
if (Array.isArray(t))
|
|
71
|
+
return v(t);
|
|
72
|
+
const r = N(t);
|
|
73
|
+
return r ? [r] : [];
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function S(e) {
|
|
77
|
+
return e ? Array.from(e.querySelectorAll("[data-formie-file-summary-item]")).map((t) => ({
|
|
78
|
+
assetId: null,
|
|
79
|
+
filename: t.textContent?.trim() || ""
|
|
80
|
+
})).filter((t) => t.filename !== "") : [];
|
|
81
|
+
}
|
|
82
|
+
function H(e, t) {
|
|
83
|
+
return P(e, t).map((r) => ({
|
|
84
|
+
assetId: b(r.value),
|
|
85
|
+
filename: ""
|
|
86
|
+
})).filter((r) => r.assetId !== null);
|
|
87
|
+
}
|
|
88
|
+
function U(e, t) {
|
|
89
|
+
return e.length ? e.map((r, n) => ({
|
|
90
|
+
assetId: r.assetId,
|
|
91
|
+
filename: t[n]?.filename || ""
|
|
92
|
+
})) : t;
|
|
93
|
+
}
|
|
94
|
+
function z(e) {
|
|
95
|
+
return e.map((t) => t.trim().toLowerCase()).filter(Boolean);
|
|
96
|
+
}
|
|
97
|
+
function re(e, t) {
|
|
98
|
+
const r = z(e.map((i) => i.filename)), n = z(t);
|
|
99
|
+
return !r.length || !n.length ? !1 : r.every((i) => n.includes(i));
|
|
100
|
+
}
|
|
101
|
+
function ne(e) {
|
|
102
|
+
K(e, w, (t) => {
|
|
103
|
+
t.addValidator("fileLimit", ({ input: r }) => {
|
|
104
|
+
const n = parseInt(r.getAttribute("data-formie-file-limit") || "", 10);
|
|
105
|
+
return r.type !== "file" || !n || !("files" in r) || !r.files?.length ? !0 : r.files.length <= n;
|
|
106
|
+
}, ({ input: r, t: n }) => n("Choose up to {files} files.", {
|
|
107
|
+
files: r.getAttribute("data-formie-file-limit") || ""
|
|
108
|
+
})), t.addValidator("fileSizeMinLimit", ({ input: r }) => {
|
|
109
|
+
const i = parseFloat(r.getAttribute("data-formie-size-min-limit") || "") * 1e3 * 1e3;
|
|
110
|
+
return r.type !== "file" || !i || !("files" in r) || !r.files?.length ? !0 : Array.from(r.files).every((s) => s.size >= i);
|
|
111
|
+
}, ({ input: r, t: n }) => n("File must be larger than {filesize} MB.", {
|
|
112
|
+
filesize: r.getAttribute("data-formie-size-min-limit") || ""
|
|
113
|
+
})), t.addValidator("fileSizeMaxLimit", ({ input: r }) => {
|
|
114
|
+
const i = parseFloat(r.getAttribute("data-formie-size-max-limit") || "") * 1e3 * 1e3;
|
|
115
|
+
return r.type !== "file" || !i || !("files" in r) || !r.files?.length ? !0 : Array.from(r.files).every((s) => s.size <= i);
|
|
116
|
+
}, ({ input: r, t: n }) => n("File must be smaller than {filesize} MB.", {
|
|
117
|
+
filesize: r.getAttribute("data-formie-size-max-limit") || ""
|
|
118
|
+
}));
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function ie(e) {
|
|
122
|
+
O(e, w, X);
|
|
123
|
+
}
|
|
124
|
+
function V(e, t) {
|
|
125
|
+
const r = e.querySelector("[data-formie-file-summary]");
|
|
126
|
+
if (r)
|
|
127
|
+
return r;
|
|
128
|
+
const n = document.createElement("div");
|
|
129
|
+
return n.className = "formie-file-summary", n.setAttribute("data-formie-file-summary", "true"), t.insertAdjacentElement("afterend", n), n;
|
|
130
|
+
}
|
|
131
|
+
function y(e) {
|
|
132
|
+
const t = e.pendingFiles.length ? e.pendingFiles : e.uploadedAssets.map((s) => s.filename || (s.assetId ? `Asset #${s.assetId}` : "")).filter(Boolean), r = e.summaryRoot || e.field.querySelector("[data-formie-file-summary]");
|
|
133
|
+
if (!t.length) {
|
|
134
|
+
r && (r.replaceChildren(), r.hidden = !0), e.summaryRoot = r;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const n = r || V(e.field, e.input);
|
|
138
|
+
if (!n)
|
|
139
|
+
return;
|
|
140
|
+
n.hidden = !1, e.summaryRoot = n;
|
|
141
|
+
const i = document.createElement("ul");
|
|
142
|
+
i.className = "formie-file-summary-container", i.setAttribute("data-formie-file-summary-container", "true"), t.forEach((s) => {
|
|
143
|
+
const o = document.createElement("li");
|
|
144
|
+
o.className = "formie-file-summary-item", o.setAttribute("data-formie-file-summary-item", "true"), o.textContent = s, i.appendChild(o);
|
|
145
|
+
}), n.replaceChildren(i);
|
|
146
|
+
}
|
|
147
|
+
function R(e, t, r) {
|
|
148
|
+
let i = te(e, t);
|
|
149
|
+
const s = D(t);
|
|
150
|
+
P(e, t).forEach((o) => {
|
|
151
|
+
o.remove();
|
|
152
|
+
}), r.forEach((o) => {
|
|
153
|
+
if (!o.assetId)
|
|
154
|
+
return;
|
|
155
|
+
const l = document.createElement("input");
|
|
156
|
+
l.type = "hidden", l.name = s, l.value = String(o.assetId), l.setAttribute(Q, "true"), i.insertAdjacentElement("afterend", l), i = l;
|
|
157
|
+
}), t.value = "";
|
|
158
|
+
}
|
|
159
|
+
function oe(e) {
|
|
160
|
+
if (!e)
|
|
161
|
+
return "";
|
|
162
|
+
const t = e.querySelector('input[name="handle"]');
|
|
163
|
+
return t instanceof HTMLInputElement && t.value.trim() ? t.value.trim() : e.getAttribute("data-formie-handle")?.trim() || "";
|
|
164
|
+
}
|
|
165
|
+
function se(e, t, r) {
|
|
166
|
+
const n = t.form, i = new FormData(), s = oe(n), o = M(e);
|
|
167
|
+
s && i.append("handle", s), o && i.append("fieldHandle", o);
|
|
168
|
+
const l = n?.querySelector('input[name="submissionUid"]');
|
|
169
|
+
return l instanceof HTMLInputElement && l.value.trim() && i.append("submissionUid", l.value.trim()), r.forEach((a) => {
|
|
170
|
+
i.append("assetIds[]", String(a));
|
|
171
|
+
}), i;
|
|
172
|
+
}
|
|
173
|
+
async function ae(e, t, r) {
|
|
174
|
+
const n = r.map((a) => a.assetId).filter((a) => a !== null);
|
|
175
|
+
if (!n.length)
|
|
176
|
+
return r;
|
|
177
|
+
const i = t.getAttribute(G)?.trim() || "/actions/formie/file-upload/hydrate", s = await Y(i, {
|
|
178
|
+
method: "POST",
|
|
179
|
+
body: se(e, t, n)
|
|
180
|
+
}), o = v(s.assets);
|
|
181
|
+
if (!o.length)
|
|
182
|
+
return r;
|
|
183
|
+
const l = new Map(o.map((a) => [a.assetId, a]));
|
|
184
|
+
return r.map((a) => {
|
|
185
|
+
if (!a.assetId || !l.has(a.assetId))
|
|
186
|
+
return a;
|
|
187
|
+
const p = l.get(a.assetId);
|
|
188
|
+
return {
|
|
189
|
+
assetId: a.assetId,
|
|
190
|
+
filename: p.filename || a.filename,
|
|
191
|
+
url: p.url ?? a.url
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
function le(e, t) {
|
|
196
|
+
const r = e.detail;
|
|
197
|
+
if (!h(r))
|
|
198
|
+
return [];
|
|
199
|
+
const n = c(r.fieldHandle), i = c(r.inputKey), s = c(r.inputName ?? r.name), o = h(r.data) ? r.data : null, l = c(o?.fieldHandle), a = c(o?.inputKey), p = c(o?.inputName ?? o?.name), d = [];
|
|
200
|
+
let m = !1, u = !1, g = !1;
|
|
201
|
+
if (i !== "" && i === t.inputKey && (m = !0, d.push(r.assets, r.assetIds, r.data)), s !== "" && s === t.inputName && (u = !0, d.push(r.assets, r.assetIds, r.data)), n === t.fieldHandle && (g = !0, d.push(r.assets, r.assetIds, r.data)), o) {
|
|
202
|
+
const f = [
|
|
203
|
+
o.assets,
|
|
204
|
+
o.assetIds,
|
|
205
|
+
o.uploadedAssets,
|
|
206
|
+
o.data
|
|
207
|
+
];
|
|
208
|
+
a !== "" && a === t.inputKey && (m = !0, d.push(...f)), p !== "" && p === t.inputName && (u = !0, d.push(...f)), l === t.fieldHandle && (g = !0, d.push(...f));
|
|
209
|
+
}
|
|
210
|
+
[r.assets, r.assetIds, r.data].forEach((f) => {
|
|
211
|
+
h(f) && (t.inputKey && t.inputKey in f && (m = !0, d.push(f[t.inputKey])), t.inputName in f && (u = !0, d.push(f[t.inputName])), t.fieldHandle in f && d.push(f[t.fieldHandle]));
|
|
212
|
+
});
|
|
213
|
+
for (const f of d) {
|
|
214
|
+
const A = v(f);
|
|
215
|
+
if (A.length && (m || u || g || re(A, t.pendingFiles)))
|
|
216
|
+
return A;
|
|
217
|
+
}
|
|
218
|
+
return [];
|
|
219
|
+
}
|
|
220
|
+
function de(e) {
|
|
221
|
+
const t = e.closest(Z);
|
|
222
|
+
return t instanceof HTMLElement ? t : null;
|
|
223
|
+
}
|
|
224
|
+
function ue(e) {
|
|
225
|
+
return Array.from(e.querySelectorAll(_)).filter((t) => t instanceof HTMLInputElement);
|
|
226
|
+
}
|
|
227
|
+
function fe(e, t, r) {
|
|
228
|
+
const n = {
|
|
229
|
+
field: e,
|
|
230
|
+
input: t,
|
|
231
|
+
summaryRoot: V(e, t),
|
|
232
|
+
uploadedAssets: U(
|
|
233
|
+
H(e, t),
|
|
234
|
+
S(e.querySelector("[data-formie-file-summary]"))
|
|
235
|
+
),
|
|
236
|
+
pendingFiles: [],
|
|
237
|
+
hydrationToken: 0
|
|
238
|
+
}, i = () => {
|
|
239
|
+
n.pendingFiles = Array.from(t.files || []).map((d) => d.name), y(n);
|
|
240
|
+
}, s = async (d) => {
|
|
241
|
+
n.hydrationToken += 1;
|
|
242
|
+
const m = n.hydrationToken;
|
|
243
|
+
n.pendingFiles = [], n.uploadedAssets = d, R(e, t, d), y(n);
|
|
244
|
+
try {
|
|
245
|
+
const u = await ae(e, t, d);
|
|
246
|
+
if (m !== n.hydrationToken)
|
|
247
|
+
return;
|
|
248
|
+
n.uploadedAssets = u, y(n), x(e, E, "uploaded-assets-sync", {
|
|
249
|
+
fileUpload: e,
|
|
250
|
+
assets: u
|
|
251
|
+
});
|
|
252
|
+
} catch (u) {
|
|
253
|
+
console.error("[formie] Failed to hydrate uploaded file details.", u);
|
|
254
|
+
}
|
|
255
|
+
}, o = () => {
|
|
256
|
+
n.hydrationToken += 1, n.pendingFiles = [], n.uploadedAssets = [], R(e, t, []), y(n);
|
|
257
|
+
}, l = (d) => {
|
|
258
|
+
const m = M(e);
|
|
259
|
+
if (!m)
|
|
260
|
+
return;
|
|
261
|
+
const u = le(d, {
|
|
262
|
+
fieldHandle: m,
|
|
263
|
+
inputKey: ee(t),
|
|
264
|
+
inputName: t.name,
|
|
265
|
+
pendingFiles: n.pendingFiles
|
|
266
|
+
});
|
|
267
|
+
u.length && s(u);
|
|
268
|
+
}, a = () => {
|
|
269
|
+
o();
|
|
270
|
+
};
|
|
271
|
+
return t.addEventListener("change", i), r?.addEventListener(F, l), r?.addEventListener(L, a), (() => {
|
|
272
|
+
const d = H(e, t), m = S(n.summaryRoot);
|
|
273
|
+
if (n.uploadedAssets = U(d, m), n.uploadedAssets.some((u) => u.assetId && !u.filename)) {
|
|
274
|
+
s(n.uploadedAssets);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
y(n);
|
|
278
|
+
})(), () => {
|
|
279
|
+
t.removeEventListener("change", i), r?.removeEventListener(F, l), r?.removeEventListener(L, a);
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
const ye = {
|
|
283
|
+
id: E,
|
|
284
|
+
kind: "field",
|
|
285
|
+
match: (e) => !!e.target.querySelector(_),
|
|
286
|
+
setup: async (e) => {
|
|
287
|
+
const t = e.form, r = /* @__PURE__ */ new WeakSet(), n = [], i = (o) => {
|
|
288
|
+
ue(o).forEach((l) => {
|
|
289
|
+
if (r.has(l))
|
|
290
|
+
return;
|
|
291
|
+
const a = de(l);
|
|
292
|
+
a && (r.add(l), n.push(fe(a, l, t)));
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
ne(t), i(e.target);
|
|
296
|
+
const s = (o) => {
|
|
297
|
+
const l = o.detail;
|
|
298
|
+
if (!h(l))
|
|
299
|
+
return;
|
|
300
|
+
const a = l.row;
|
|
301
|
+
a instanceof HTMLElement && i(a);
|
|
302
|
+
};
|
|
303
|
+
return t?.addEventListener(T, s), await e.emit("formie:module:file-upload:init", {
|
|
304
|
+
count: n.length
|
|
305
|
+
}), {
|
|
306
|
+
destroy: () => {
|
|
307
|
+
t?.removeEventListener(T, s), n.forEach((o) => {
|
|
308
|
+
o();
|
|
309
|
+
}), ie(t), e.emit("formie:module:file-upload:destroy", {});
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
export {
|
|
315
|
+
ye as fileUploadModule
|
|
316
|
+
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import { e as
|
|
1
|
+
import { d as x, g as E } from "./index-BcqwpPNE.js";
|
|
2
|
+
import { e as v, a as L } from "./scripts-D9N2d5rN.js";
|
|
3
3
|
const w = "FORMIE_GOOGLE_ADDRESS_SCRIPT", m = "formieGoogleMapsReady";
|
|
4
4
|
let f = null;
|
|
5
|
-
async function
|
|
6
|
-
const e = window,
|
|
7
|
-
if (typeof
|
|
8
|
-
const s =
|
|
5
|
+
async function R(t) {
|
|
6
|
+
const e = window, n = e.google;
|
|
7
|
+
if (typeof n < "u" && n !== null) {
|
|
8
|
+
const s = n.maps;
|
|
9
9
|
if (s?.places?.PlaceAutocompleteElement)
|
|
10
|
-
return
|
|
10
|
+
return n;
|
|
11
11
|
const i = s;
|
|
12
|
-
return typeof i?.importLibrary == "function" && await i.importLibrary("places"),
|
|
12
|
+
return typeof i?.importLibrary == "function" && await i.importLibrary("places"), n;
|
|
13
13
|
}
|
|
14
14
|
if (f)
|
|
15
15
|
return f;
|
|
16
16
|
if (document.getElementById(w)) {
|
|
17
|
-
const s = await
|
|
17
|
+
const s = await v("google", 1e4), i = s?.maps;
|
|
18
18
|
return typeof i?.importLibrary == "function" && await i.importLibrary("places"), s;
|
|
19
19
|
}
|
|
20
20
|
const o = new URL("https://maps.googleapis.com/maps/api/js");
|
|
21
21
|
o.searchParams.set("key", t), o.searchParams.set("loading", "async"), o.searchParams.set("libraries", "places"), o.searchParams.set("callback", m), f = (async () => {
|
|
22
|
-
const s = new Promise((
|
|
22
|
+
const s = new Promise((d, r) => {
|
|
23
23
|
const u = setTimeout(() => {
|
|
24
|
-
e[m] && (delete e[m],
|
|
24
|
+
e[m] && (delete e[m], r(new Error("Google Maps API load timeout")));
|
|
25
25
|
}, 15e3);
|
|
26
26
|
e[m] = () => {
|
|
27
|
-
clearTimeout(u), delete e[m],
|
|
27
|
+
clearTimeout(u), delete e[m], d(e.google);
|
|
28
28
|
};
|
|
29
29
|
});
|
|
30
30
|
await L({
|
|
@@ -33,8 +33,8 @@ async function S(t) {
|
|
|
33
33
|
async: !0,
|
|
34
34
|
defer: !0
|
|
35
35
|
});
|
|
36
|
-
const i = await s,
|
|
37
|
-
return typeof
|
|
36
|
+
const i = await s, l = i?.maps;
|
|
37
|
+
return typeof l?.importLibrary == "function" && await l.importLibrary("places"), i;
|
|
38
38
|
})();
|
|
39
39
|
try {
|
|
40
40
|
return await f;
|
|
@@ -42,10 +42,10 @@ async function S(t) {
|
|
|
42
42
|
throw f = null, s;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function A(t, e) {
|
|
46
46
|
e.formattedAddress && t.input.setValue("autoComplete", e.formattedAddress), e.address1 && t.input.setValue("address1", e.address1), e.city !== void 0 && t.input.setValue("city", e.city), e.state !== void 0 && t.input.setValue("state", e.state), e.zip !== void 0 && t.input.setValue("zip", e.zip), e.country !== void 0 && t.input.setValue("country", e.country);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function S() {
|
|
49
49
|
return {
|
|
50
50
|
subpremise: "shortText",
|
|
51
51
|
street_number: "shortText",
|
|
@@ -57,17 +57,17 @@ function T() {
|
|
|
57
57
|
postal_code: "shortText"
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
const e =
|
|
62
|
-
for (const
|
|
63
|
-
const o =
|
|
60
|
+
function b(t) {
|
|
61
|
+
const e = S(), n = {};
|
|
62
|
+
for (const a of t) {
|
|
63
|
+
const o = a.types?.[0];
|
|
64
64
|
if (!o || !e[o]) continue;
|
|
65
|
-
const s = e[o], i =
|
|
66
|
-
|
|
65
|
+
const s = e[o], i = a[s] ?? a.short_text ?? a.long_text ?? "";
|
|
66
|
+
n[o] = i;
|
|
67
67
|
}
|
|
68
|
-
return
|
|
68
|
+
return n;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function C(t) {
|
|
71
71
|
let e = "";
|
|
72
72
|
return (t.street_number || t.route) && (e = [t.street_number, t.route].filter(Boolean).join(" "), t.subpremise && (e = `${t.subpremise}/${e}`)), {
|
|
73
73
|
address1: e,
|
|
@@ -77,49 +77,67 @@ function P(t) {
|
|
|
77
77
|
country: t.country || ""
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
function T(t) {
|
|
81
|
+
const e = t.componentRestrictions;
|
|
82
|
+
if (e && typeof e == "object") {
|
|
83
|
+
const a = e.country;
|
|
84
|
+
if (Array.isArray(a) ? a.length > 0 : a)
|
|
85
|
+
return !0;
|
|
86
|
+
}
|
|
87
|
+
const n = t.includedRegionCodes;
|
|
88
|
+
return Array.isArray(n) && n.length > 0;
|
|
89
|
+
}
|
|
90
|
+
function G(t) {
|
|
91
|
+
const e = { types: ["geocode"], ...t.options || {} }, n = t.countryDefaultValue?.trim().toLowerCase();
|
|
92
|
+
return !n || T(e) ? e : {
|
|
93
|
+
...e,
|
|
94
|
+
componentRestrictions: { country: n },
|
|
95
|
+
includedRegionCodes: [n.toUpperCase()]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const I = x({
|
|
81
99
|
id: "google-address",
|
|
82
100
|
load: async ({ options: t }) => {
|
|
83
101
|
const e = t.provider.apiKey;
|
|
84
102
|
if (!e)
|
|
85
103
|
throw new Error("Google Places API key is required");
|
|
86
|
-
return
|
|
104
|
+
return R(e);
|
|
87
105
|
},
|
|
88
|
-
mount: async ({ api: t, field: e, services:
|
|
89
|
-
const o =
|
|
106
|
+
mount: async ({ api: t, field: e, services: n, provider: a }) => {
|
|
107
|
+
const o = n.input.getAutocomplete(), s = t?.maps?.places?.PlaceAutocompleteElement;
|
|
90
108
|
if (!o || typeof s != "function")
|
|
91
109
|
return console.warn("[formie] Google Places API not ready; address autocomplete skipped."), null;
|
|
92
|
-
const i =
|
|
93
|
-
|
|
94
|
-
let
|
|
95
|
-
|
|
110
|
+
const i = G(a), l = new s(i), d = window.getComputedStyle(o).height;
|
|
111
|
+
l.style.height = d, l.style.boxSizing = "border-box";
|
|
112
|
+
let r = o.parentElement;
|
|
113
|
+
r?.classList.contains("formie-autocomplete-wrapper") || (r = document.createElement("div"), r.classList.add("formie-autocomplete-wrapper"), o.parentNode?.insertBefore(r, o), r.appendChild(o));
|
|
96
114
|
const u = o.value;
|
|
97
115
|
if (u) {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
position: absolute; left: 0; top: 0; height: ${
|
|
101
|
-
line-height: ${
|
|
116
|
+
const c = document.createElement("div");
|
|
117
|
+
c.classList.add("formie-autocomplete-placeholder"), c.textContent = u, r.style.position = "relative", c.style.cssText = `
|
|
118
|
+
position: absolute; left: 0; top: 0; height: ${d};
|
|
119
|
+
line-height: ${d}; width: 100%; padding: 0 2.5rem;
|
|
102
120
|
pointer-events: none; color: #6B7280; font-size: 14px; z-index: 1;
|
|
103
|
-
`,
|
|
104
|
-
|
|
105
|
-
}),
|
|
106
|
-
o.value && (
|
|
121
|
+
`, r.appendChild(c), l.addEventListener("focusin", () => {
|
|
122
|
+
c.style.display = "none";
|
|
123
|
+
}), l.addEventListener("focusout", () => {
|
|
124
|
+
o.value && (c.style.display = "");
|
|
107
125
|
});
|
|
108
126
|
}
|
|
109
|
-
|
|
110
|
-
const y = async (
|
|
111
|
-
const h =
|
|
127
|
+
r.replaceChild(l, o), o.type = "hidden", o.name = o.getAttribute("name") || "", r.appendChild(o);
|
|
128
|
+
const y = async (c) => {
|
|
129
|
+
const h = c.placePrediction;
|
|
112
130
|
if (!h) return;
|
|
113
131
|
const p = await h.toPlace();
|
|
114
132
|
if (await p.fetchFields({ fields: ["addressComponents", "formattedAddress"] }), !p.addressComponents) return;
|
|
115
|
-
const
|
|
133
|
+
const P = b(
|
|
116
134
|
p.addressComponents
|
|
117
|
-
),
|
|
118
|
-
|
|
119
|
-
...
|
|
135
|
+
), _ = C(P);
|
|
136
|
+
A(n, {
|
|
137
|
+
..._,
|
|
120
138
|
formattedAddress: p.formattedAddress
|
|
121
139
|
}), e.dispatchEvent(
|
|
122
|
-
new CustomEvent(
|
|
140
|
+
new CustomEvent(E("google", "populate"), {
|
|
123
141
|
bubbles: !0,
|
|
124
142
|
detail: {
|
|
125
143
|
addressProvider: "google",
|
|
@@ -130,17 +148,17 @@ const I = v({
|
|
|
130
148
|
})
|
|
131
149
|
);
|
|
132
150
|
};
|
|
133
|
-
return
|
|
151
|
+
return l.addEventListener("gmp-select", y), l;
|
|
134
152
|
},
|
|
135
|
-
onCurrentLocation: async (t, { field: e, services:
|
|
136
|
-
const { latitude:
|
|
137
|
-
if (!(!
|
|
153
|
+
onCurrentLocation: async (t, { field: e, services: n }) => {
|
|
154
|
+
const { latitude: a, longitude: o } = t.coords, s = n.form, i = s?.action || window.location.href, l = e.getAttribute("data-formie-field-handle")?.trim(), d = s?.querySelector('[name="handle"]')?.value?.trim();
|
|
155
|
+
if (!(!d || !l))
|
|
138
156
|
try {
|
|
139
|
-
const
|
|
140
|
-
|
|
157
|
+
const r = new FormData();
|
|
158
|
+
r.append("action", "formie/address/google-places-geocode"), r.append("latlng", `${a},${o}`), r.append("handle", d), r.append("fieldHandle", l);
|
|
141
159
|
const y = await (await fetch(i, {
|
|
142
160
|
method: "POST",
|
|
143
|
-
body:
|
|
161
|
+
body: r,
|
|
144
162
|
credentials: "include",
|
|
145
163
|
headers: {
|
|
146
164
|
"X-Requested-With": "XMLHttpRequest",
|
|
@@ -148,15 +166,16 @@ const I = v({
|
|
|
148
166
|
}
|
|
149
167
|
})).json();
|
|
150
168
|
if (y?.results?.[0]?.address_components) {
|
|
151
|
-
const
|
|
169
|
+
const c = b(
|
|
152
170
|
y.results[0].address_components
|
|
153
|
-
), g =
|
|
154
|
-
|
|
171
|
+
), g = C(c);
|
|
172
|
+
A(n, g);
|
|
155
173
|
}
|
|
156
174
|
} catch {
|
|
157
175
|
}
|
|
158
176
|
}
|
|
159
177
|
});
|
|
160
178
|
export {
|
|
179
|
+
G as buildGoogleAutocompleteOptions,
|
|
161
180
|
I as googleAddressModule
|
|
162
181
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as h, b as i, C as d } from "./index-
|
|
2
|
-
import { a as p, e as m } from "./scripts-
|
|
1
|
+
import { a as h, b as i, C as d } from "./index-BcqwpPNE.js";
|
|
2
|
+
import { a as p, e as m } from "./scripts-D9N2d5rN.js";
|
|
3
3
|
async function u(a) {
|
|
4
4
|
const o = typeof a.language == "string" && a.language.trim() !== "" ? a.language.trim() : "en", { async: t, defer: e } = i(a.loadingMethod), r = "FORMIE_HCAPTCHA_ONLOAD", c = window, l = c.hcaptcha;
|
|
5
5
|
if (l)
|