@verbb/formie-browser 1.0.4 → 1.0.6
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 +76 -22
- package/dist/chunks/address-country-Rx6GQTND.js +68 -0
- package/dist/chunks/address-finder-yXU5yMjG.js +30 -0
- package/dist/chunks/address-state-BQ0xGV9n.js +344 -0
- package/dist/chunks/api-CmwLRq_n.js +780 -0
- package/dist/chunks/api-DMK8NSUI.js +407 -0
- package/dist/chunks/api-sPqGbOww.js +125 -0
- package/dist/chunks/async-nPFRNQ06.js +25 -0
- package/dist/chunks/bpoint-DSjqRv63.js +24 -0
- package/dist/chunks/calculations-CeDgB9jt.js +299 -0
- package/dist/chunks/captcha-eu-CWJb64_j.js +31 -0
- package/dist/chunks/checkbox-radio-DQ0H67Tj.js +125 -0
- package/dist/chunks/chunk-3b4jIN3o.js +13 -0
- package/dist/chunks/combobox-D-2b42wn.js +1954 -0
- package/dist/chunks/conditions-DjZOtHfS.js +412 -0
- package/dist/chunks/constants-DVcJAvc5.js +38 -0
- package/dist/chunks/country-from-ip-BwxKaBuJ.js +26 -0
- package/dist/chunks/custom-google-maps-BsaSirEZ.js +194 -0
- package/dist/chunks/custom-link-CJ1-FjEM.js +46 -0
- package/dist/chunks/custom-maps-DYW_pBid.js +161 -0
- package/dist/chunks/date-picker-5CA_-zGb.js +5311 -0
- package/dist/chunks/debug-BV0DvdHx.js +41 -0
- package/dist/chunks/dist-BQ4a9hmy.js +2659 -0
- package/dist/chunks/event-names-BCI2FLD8.js +51 -0
- package/dist/chunks/eway-D3ctTbEk.js +70 -0
- package/dist/chunks/field-references.keys-58ZSTrCW.js +21 -0
- package/dist/chunks/field-references.resolver-CHwn0G0L.js +145 -0
- package/dist/chunks/file-upload-D49m8-DR.js +287 -0
- package/dist/chunks/friendly-captcha-v1-ByXzENYZ.js +31 -0
- package/dist/chunks/friendly-captcha-v2-BPdlmhQu.js +36 -0
- package/dist/chunks/friendly-challenge-8uPatWqk.js +832 -0
- package/dist/chunks/go-cardless-BwASSYSK.js +23 -0
- package/dist/chunks/google-address-OhKilPWE.js +161 -0
- package/dist/chunks/hcaptcha-CdCd9oEi.js +54 -0
- package/dist/chunks/hidden-D7_Ch-QN.js +26 -0
- package/dist/chunks/http-D-JExro7.js +27 -0
- package/dist/chunks/i18n-BY1ds1BL.js +121 -0
- package/dist/chunks/leaflet-src-j-lHNmhR.js +4585 -0
- package/dist/chunks/loqate-Cp2zvwpE.js +76 -0
- package/dist/chunks/mollie-COG-ko2D.js +23 -0
- package/dist/chunks/moneris-CMH8PlRc.js +117 -0
- package/dist/chunks/opayo-D2jsR5vh.js +113 -0
- package/dist/chunks/paddle-DxF88RfC.js +55 -0
- package/dist/chunks/paypal-b5pnwrA2.js +95 -0
- package/dist/chunks/payway-BJYu9DIR.js +55 -0
- package/dist/chunks/phone-country-D3ayr60L.js +2645 -0
- package/dist/chunks/place-kit-BGHklIZ-.js +48 -0
- package/dist/chunks/placekit-autocomplete.esm-DWVabQlq.js +1236 -0
- package/dist/chunks/recaptcha-enterprise-BSwi8IVX.js +65 -0
- package/dist/chunks/recaptcha-shared-B4zAescW.js +15 -0
- package/dist/chunks/recaptcha-v2-checkbox-CnDQmsKa.js +40 -0
- package/dist/chunks/recaptcha-v2-invisible-Cz5uIlp-.js +53 -0
- package/dist/chunks/recaptcha-v3-BtbbP111.js +27 -0
- package/dist/chunks/repeater-B5leVxZU.js +102 -0
- package/dist/chunks/rich-text-D0sb8bmX.js +349 -0
- package/dist/chunks/scripts-6CYSUGKQ.js +24 -0
- package/dist/chunks/sdk-BhHAYgga.js +1397 -0
- package/dist/chunks/shared-Bx9s0i0P.js +100 -0
- package/dist/chunks/signature-xz4QO7CR.js +536 -0
- package/dist/chunks/snaptcha-vz1RnZ15.js +8 -0
- package/dist/chunks/square-BP8RWAKB.js +40 -0
- package/dist/chunks/stripe-MihN63uC.js +184 -0
- package/dist/chunks/styles-BfoIZwJp.js +19 -0
- package/dist/chunks/summary-D3AjxpYN.js +114 -0
- package/dist/chunks/table-C-lkQN6I.js +78 -0
- package/dist/chunks/text-limit-DbgEFHLO.js +125 -0
- package/dist/chunks/theme-classes-Tv7q7ToE.js +44 -0
- package/dist/chunks/turnstile-D_Pi1CKM.js +58 -0
- package/dist/chunks/upload-manager-BpqWSHmU.js +2558 -0
- package/dist/chunks/utils-Vqp8i_RM.js +49401 -0
- package/dist/css/formie-theme.css +2 -0
- package/dist/css/theme/_buttons.css +16 -0
- package/dist/css/theme/_tokens.css +2 -0
- package/dist/css/theme/fields/_address-state.css +94 -0
- package/dist/css/theme/fields/_combobox.css +246 -0
- package/dist/css/theme/fields/_select.css +13 -0
- package/dist/css/theme/fields/_signature.css +19 -0
- package/dist/css/theme/fields/_upload-manager.css +279 -0
- package/dist/index.js +2448 -39
- 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/core/validation-focus.d.ts +4 -0
- package/dist/js/core/validation-focus.d.ts.map +1 -0
- package/dist/js/modules/address/api.d.ts +1 -0
- package/dist/js/modules/address/api.d.ts.map +1 -1
- package/dist/js/modules/address/constants.d.ts +22 -1
- package/dist/js/modules/address/constants.d.ts.map +1 -1
- package/dist/js/modules/address/host.d.ts +2 -2
- package/dist/js/modules/address/host.d.ts.map +1 -1
- package/dist/js/modules/address/loqate.d.ts.map +1 -1
- package/dist/js/modules/fields/address-country.d.ts +3 -0
- package/dist/js/modules/fields/address-country.d.ts.map +1 -0
- package/dist/js/modules/fields/address-state.d.ts +3 -0
- package/dist/js/modules/fields/address-state.d.ts.map +1 -0
- package/dist/js/modules/fields/calculations.d.ts.map +1 -1
- package/dist/js/modules/fields/combobox.d.ts +17 -0
- package/dist/js/modules/fields/combobox.d.ts.map +1 -0
- package/dist/js/modules/fields/custom-google-maps.d.ts +64 -0
- package/dist/js/modules/fields/custom-google-maps.d.ts.map +1 -0
- package/dist/js/modules/fields/custom-link.d.ts +3 -0
- package/dist/js/modules/fields/custom-link.d.ts.map +1 -0
- package/dist/js/modules/fields/custom-maps.d.ts +3 -0
- package/dist/js/modules/fields/custom-maps.d.ts.map +1 -0
- package/dist/js/modules/fields/date-picker.d.ts.map +1 -1
- package/dist/js/modules/fields/index.d.ts.map +1 -1
- package/dist/js/modules/fields/phone-country.d.ts.map +1 -1
- package/dist/js/modules/fields/signature.d.ts.map +1 -1
- package/dist/js/modules/fields/upload-manager.d.ts +3 -0
- package/dist/js/modules/fields/upload-manager.d.ts.map +1 -0
- package/dist/js/submit/pipeline.d.ts.map +1 -1
- package/dist/js/utils/country-from-ip.d.ts +7 -0
- package/dist/js/utils/country-from-ip.d.ts.map +1 -0
- package/dist/js/utils/field-references.d.ts +1 -0
- package/dist/js/utils/field-references.d.ts.map +1 -1
- package/dist/js/utils/field-references.row-scope.d.ts +11 -0
- package/dist/js/utils/field-references.row-scope.d.ts.map +1 -0
- package/package.json +8 -3
- package/src/css/formie-theme.css +2 -0
- package/src/css/theme/_buttons.css +16 -0
- package/src/css/theme/_tokens.css +2 -0
- package/src/css/theme/fields/_address-state.css +94 -0
- package/src/css/theme/fields/_combobox.css +246 -0
- package/src/css/theme/fields/_select.css +13 -0
- package/src/css/theme/fields/_signature.css +19 -0
- package/src/css/theme/fields/_upload-manager.css +279 -0
- package/src/js/core/create-formie-client.ts +27 -0
- package/src/js/core/submit-result-ui.ts +4 -4
- package/src/js/core/validation-focus.ts +117 -0
- package/src/js/modules/address/api.ts +7 -0
- package/src/js/modules/address/constants.ts +82 -2
- package/src/js/modules/address/host.ts +16 -6
- package/src/js/modules/address/loqate.ts +3 -17
- package/src/js/modules/fields/address-country.ts +156 -0
- package/src/js/modules/fields/address-state.ts +946 -0
- package/src/js/modules/fields/calculations.ts +32 -0
- package/src/js/modules/fields/combobox.ts +188 -0
- package/src/js/modules/fields/custom-google-maps.ts +416 -0
- package/src/js/modules/fields/custom-link.ts +95 -0
- package/src/js/modules/fields/custom-maps.ts +339 -0
- package/src/js/modules/fields/date-picker.ts +96 -3
- package/src/js/modules/fields/index.ts +7 -0
- package/src/js/modules/fields/phone-country.ts +6 -0
- package/src/js/modules/fields/signature.ts +199 -15
- package/src/js/modules/fields/upload-manager.ts +1277 -0
- package/src/js/submit/pipeline.ts +11 -1
- package/src/js/utils/country-from-ip.ts +54 -0
- package/src/js/utils/field-references.row-scope.ts +303 -0
- package/src/js/utils/field-references.ts +1 -0
- package/src/vendor.d.ts +1 -1
- package/dist/chunks/address-finder-BU4roxT6.js +0 -37
- package/dist/chunks/bpoint-uNg5j6rt.js +0 -26
- package/dist/chunks/calculations-C9t6Zop9.js +0 -147
- package/dist/chunks/captcha-eu-BAPzHNts.js +0 -34
- package/dist/chunks/checkbox-radio-CHeLNVIK.js +0 -141
- package/dist/chunks/conditions-DKxVCsjD.js +0 -459
- package/dist/chunks/date-picker-B3iQ797Z.js +0 -4994
- package/dist/chunks/eway-DCielIML.js +0 -74
- package/dist/chunks/file-upload-DP2TOUYV.js +0 -316
- package/dist/chunks/friendly-captcha-v1-DdlcGiFY.js +0 -33
- package/dist/chunks/friendly-captcha-v2-76w-YnFm.js +0 -38
- package/dist/chunks/go-cardless-rwCkzbNK.js +0 -24
- package/dist/chunks/google-address-BD8IZ86V.js +0 -181
- package/dist/chunks/hcaptcha-BNNTL6uf.js +0 -56
- package/dist/chunks/hidden-CW6Rcf1N.js +0 -31
- package/dist/chunks/index-BEsfee-D.js +0 -1839
- package/dist/chunks/index-BP7Unm5Y.js +0 -863
- package/dist/chunks/index-D6npYxvr.js +0 -4423
- package/dist/chunks/loqate-B-ZNS65B.js +0 -55
- package/dist/chunks/mollie-BDAZ-1X4.js +0 -24
- package/dist/chunks/moneris-B1b0uEtY.js +0 -101
- package/dist/chunks/opayo-CC5hraHo.js +0 -122
- package/dist/chunks/paddle-B4GmrDsq.js +0 -60
- package/dist/chunks/paypal-BFS6XsIS.js +0 -100
- package/dist/chunks/payway-DekoJead.js +0 -56
- package/dist/chunks/phone-country-Cm5YUeXI.js +0 -3765
- package/dist/chunks/place-kit-DizZWV_e.js +0 -42
- package/dist/chunks/placekit-autocomplete.esm-LAwfbPZl.js +0 -1299
- package/dist/chunks/recaptcha-enterprise-BbOvO7JZ.js +0 -71
- package/dist/chunks/recaptcha-shared-Dwg1eVFS.js +0 -15
- package/dist/chunks/recaptcha-v2-checkbox-SY3ti5iQ.js +0 -41
- package/dist/chunks/recaptcha-v2-invisible-DSmQnn6c.js +0 -59
- package/dist/chunks/recaptcha-v3-DNh7YCnR.js +0 -28
- package/dist/chunks/repeater-DM0vuFNQ.js +0 -124
- package/dist/chunks/rich-text-C8aGYp70.js +0 -304
- package/dist/chunks/scripts-CKTFtxPO.js +0 -36
- package/dist/chunks/sdk-3SicTWby.js +0 -1559
- package/dist/chunks/shared--BU5CFoL.js +0 -80
- package/dist/chunks/signature-pFhZfH7d.js +0 -550
- package/dist/chunks/snaptcha-VuOUOaLj.js +0 -8
- package/dist/chunks/square-BR9pvToy.js +0 -46
- package/dist/chunks/stripe-OHUwoV9g.js +0 -202
- package/dist/chunks/styles-C3aqgtek.js +0 -21
- package/dist/chunks/summary-Da7Ktg3N.js +0 -126
- package/dist/chunks/table-C0PmR9bI.js +0 -95
- package/dist/chunks/text-limit-mLEwZDIa.js +0 -144
- package/dist/chunks/turnstile-9tM7q_LK.js +0 -59
- package/dist/chunks/utils-BntI3W4S.js +0 -6149
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { v as f, w } from "./index-D6npYxvr.js";
|
|
2
|
-
import { l as m } from "./scripts-CKTFtxPO.js";
|
|
3
|
-
const s = [
|
|
4
|
-
{
|
|
5
|
-
id: "FORMIE_EWAY_SCRIPT_MIN",
|
|
6
|
-
src: "https://secure.ewaypayments.com/scripts/eCrypt.min.js"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
id: "FORMIE_EWAY_SCRIPT",
|
|
10
|
-
src: "https://secure.ewaypayments.com/scripts/eCrypt.js"
|
|
11
|
-
}
|
|
12
|
-
];
|
|
13
|
-
async function i() {
|
|
14
|
-
let t = null;
|
|
15
|
-
for (const r of s) {
|
|
16
|
-
try {
|
|
17
|
-
return await m("eCrypt", {
|
|
18
|
-
id: r.id,
|
|
19
|
-
src: r.src,
|
|
20
|
-
timeoutMs: 1e4
|
|
21
|
-
}), await w(() => {
|
|
22
|
-
const o = window.eCrypt;
|
|
23
|
-
return o && typeof o.encryptValue == "function" ? o : null;
|
|
24
|
-
}, {
|
|
25
|
-
timeoutMs: 1e4,
|
|
26
|
-
intervalMs: 50
|
|
27
|
-
});
|
|
28
|
-
} catch (e) {
|
|
29
|
-
t = e instanceof Error ? e : new Error("Unknown eWay script load error.");
|
|
30
|
-
}
|
|
31
|
-
s.forEach(({ id: e }) => {
|
|
32
|
-
document.getElementById(e)?.remove();
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
throw t || new Error("Eway encryption script failed to load.");
|
|
36
|
-
}
|
|
37
|
-
const C = f({
|
|
38
|
-
id: "eway",
|
|
39
|
-
defaultRequiredInputSuffixes: ["ewayTokenData"],
|
|
40
|
-
load: async (t) => {
|
|
41
|
-
const { provider: r } = t.options;
|
|
42
|
-
return r.cseKey?.trim() ? i() : (console.error("[formie] Missing cseKey for Eway."), null);
|
|
43
|
-
},
|
|
44
|
-
onBeforeAuthorize: async (t) => {
|
|
45
|
-
const { field: r, services: e, provider: o, api: y } = t, n = o.cseKey;
|
|
46
|
-
if (!n?.trim())
|
|
47
|
-
return e.addError("Missing cseKey for Eway."), !1;
|
|
48
|
-
let c = y;
|
|
49
|
-
if (!c?.encryptValue)
|
|
50
|
-
try {
|
|
51
|
-
c = await i();
|
|
52
|
-
} catch (a) {
|
|
53
|
-
return e.addError(a instanceof Error ? a.message : "Eway encryption script failed to load."), !1;
|
|
54
|
-
}
|
|
55
|
-
const d = r.querySelector('[data-eway-card="cardholder-name"]')?.value ?? "", u = r.querySelector('[data-eway-card="card-number"]')?.value ?? "", l = r.querySelector('[data-eway-card="expiry-date"]')?.value ?? "", p = r.querySelector('[data-eway-card="security-code"]')?.value ?? "";
|
|
56
|
-
try {
|
|
57
|
-
const a = {
|
|
58
|
-
cardholderName: d,
|
|
59
|
-
cardNumber: c.encryptValue(u, n),
|
|
60
|
-
expiryDate: l,
|
|
61
|
-
securityCode: c.encryptValue(p, n)
|
|
62
|
-
};
|
|
63
|
-
return e.updateInputs("ewayTokenData", JSON.stringify(a)), !0;
|
|
64
|
-
} catch (a) {
|
|
65
|
-
return e.addError(a instanceof Error ? a.message : "Failed to encrypt card details."), !1;
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
onAfterSubmit: async ({ services: t }) => {
|
|
69
|
-
t.updateInputs("ewayTokenData", "");
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
export {
|
|
73
|
-
C as ewayModule
|
|
74
|
-
};
|
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
import { r as V, a as K, d as O } from "./shared--BU5CFoL.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-D6npYxvr.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", b = "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 g(e) {
|
|
11
|
-
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
12
|
-
}
|
|
13
|
-
function I(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 x(e) {
|
|
33
|
-
return Array.from(e.querySelectorAll('input[type="hidden"]')).filter((t) => t instanceof HTMLInputElement);
|
|
34
|
-
}
|
|
35
|
-
function C(e, t) {
|
|
36
|
-
const r = D(t);
|
|
37
|
-
return x(e).filter((n) => n.name === r && n.value.trim() !== "");
|
|
38
|
-
}
|
|
39
|
-
function te(e, t) {
|
|
40
|
-
const r = k(t), n = x(e).find((s) => s.hasAttribute(b) || s.name === r && s.value === "");
|
|
41
|
-
if (n)
|
|
42
|
-
return n.setAttribute(b, "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(b, "true"), t.insertAdjacentElement("afterend", i), i;
|
|
45
|
-
}
|
|
46
|
-
function N(e) {
|
|
47
|
-
if (Array.isArray(e))
|
|
48
|
-
return null;
|
|
49
|
-
const t = I(e);
|
|
50
|
-
if (t)
|
|
51
|
-
return {
|
|
52
|
-
assetId: t,
|
|
53
|
-
filename: ""
|
|
54
|
-
};
|
|
55
|
-
if (!g(e))
|
|
56
|
-
return null;
|
|
57
|
-
const r = I(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 C(e, t).map((r) => ({
|
|
84
|
-
assetId: I(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
|
-
V(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 }) => r.getAttribute("data-formie-validation-max-files-message") ?? 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 }) => r.getAttribute("data-formie-validation-min-file-size-message") ?? 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 }) => r.getAttribute("data-formie-validation-max-file-size-message") ?? 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
|
-
K(e, w, X);
|
|
123
|
-
}
|
|
124
|
-
function P(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 || P(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
|
-
C(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 (!g(r))
|
|
198
|
-
return [];
|
|
199
|
-
const n = c(r.fieldHandle), i = c(r.inputKey), s = c(r.inputName ?? r.name), o = g(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, h = !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 && (h = !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 && (h = !0, d.push(...f));
|
|
209
|
-
}
|
|
210
|
-
[r.assets, r.assetIds, r.data].forEach((f) => {
|
|
211
|
-
g(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 || h || 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: P(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), O(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 (!g(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,33 +0,0 @@
|
|
|
1
|
-
import { a as l } from "./index-D6npYxvr.js";
|
|
2
|
-
const c = l({
|
|
3
|
-
id: "friendly-captcha-v1",
|
|
4
|
-
defaultPlaceholderSelector: "[data-friendly-captcha-placeholder]",
|
|
5
|
-
defaultTokenFieldNames: ["frc-captcha-solution"],
|
|
6
|
-
load: async () => import("./index-BP7Unm5Y.js"),
|
|
7
|
-
mount: ({ api: e, container: t, provider: a, services: o }) => new e.WidgetInstance(t, {
|
|
8
|
-
sitekey: a.siteKey || "",
|
|
9
|
-
startMode: a.startMode || "none",
|
|
10
|
-
language: a.language || "en",
|
|
11
|
-
solutionFieldName: "frc-captcha-solution",
|
|
12
|
-
doneCallback: (n) => {
|
|
13
|
-
typeof n == "string" && n.trim() !== "" && o.tokens.write(n.trim()), o.errors.clear();
|
|
14
|
-
},
|
|
15
|
-
errorCallback: () => {
|
|
16
|
-
o.tokens.clear();
|
|
17
|
-
}
|
|
18
|
-
}),
|
|
19
|
-
screen: async ({ widget: e, placeholder: t, services: a, stageCtx: o }) => {
|
|
20
|
-
if (a.tokens.has())
|
|
21
|
-
return;
|
|
22
|
-
if (await e.start(), !await a.tokens.wait()) {
|
|
23
|
-
const r = a.errors.getDefaultMessage();
|
|
24
|
-
a.errors.show(r, t), o.abort(r);
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
unmount: ({ widget: e, services: t }) => {
|
|
28
|
-
e.destroy(), t.tokens.clear();
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
export {
|
|
32
|
-
c as friendlyCaptchaV1Module
|
|
33
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { a as l } from "./index-D6npYxvr.js";
|
|
2
|
-
const i = l({
|
|
3
|
-
id: "friendly-captcha-v2",
|
|
4
|
-
defaultPlaceholderSelector: "[data-friendly-captcha-placeholder]",
|
|
5
|
-
defaultTokenFieldNames: ["frc-captcha-response"],
|
|
6
|
-
load: async () => import("./sdk-3SicTWby.js"),
|
|
7
|
-
mount: ({ api: r, container: n, provider: e, services: t }) => {
|
|
8
|
-
const a = new r.FriendlyCaptchaSDK().createWidget({
|
|
9
|
-
element: n,
|
|
10
|
-
sitekey: e.siteKey || "",
|
|
11
|
-
formFieldName: "frc-captcha-response",
|
|
12
|
-
language: e.language,
|
|
13
|
-
startMode: e.startMode || "none"
|
|
14
|
-
});
|
|
15
|
-
return a.addEventListener("frc:widget.complete", (s) => {
|
|
16
|
-
const o = s.detail;
|
|
17
|
-
typeof o?.response == "string" && o.response.trim() !== "" && t.tokens.write(o.response.trim()), t.errors.clear();
|
|
18
|
-
}), a.addEventListener("frc:widget.expire", () => {
|
|
19
|
-
t.tokens.clear(), t.errors.clear();
|
|
20
|
-
}), a.addEventListener("frc:widget.error", (s) => {
|
|
21
|
-
s.detail?.error && t.tokens.clear();
|
|
22
|
-
}), a;
|
|
23
|
-
},
|
|
24
|
-
screen: async ({ widget: r, placeholder: n, services: e, stageCtx: t }) => {
|
|
25
|
-
if (e.tokens.has())
|
|
26
|
-
return;
|
|
27
|
-
if (r.start(), !await e.tokens.wait()) {
|
|
28
|
-
const a = e.errors.getDefaultMessage();
|
|
29
|
-
e.errors.show(a, n), t.abort(a);
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
unmount: ({ widget: r, services: n }) => {
|
|
33
|
-
r.destroy(), n.tokens.clear();
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
export {
|
|
37
|
-
i as friendlyCaptchaV2Module
|
|
38
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { v as a, x as o } from "./index-D6npYxvr.js";
|
|
2
|
-
const d = o("go-cardless", "redirect"), l = a({
|
|
3
|
-
id: "go-cardless",
|
|
4
|
-
defaultRequiredInputSuffixes: [],
|
|
5
|
-
load: async () => null,
|
|
6
|
-
setup: async ({ services: n, root: e }) => {
|
|
7
|
-
const r = (s) => {
|
|
8
|
-
const t = s.detail?.data;
|
|
9
|
-
if (!t?.redirectUrl) {
|
|
10
|
-
n.addError("Missing GoCardless redirect URL.");
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
window.location.href = t.redirectUrl;
|
|
14
|
-
};
|
|
15
|
-
return e.addEventListener(d, r), {
|
|
16
|
-
destroy: () => {
|
|
17
|
-
e.removeEventListener(d, r);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
export {
|
|
23
|
-
l as goCardlessModule
|
|
24
|
-
};
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { d as x, g as E } from "./index-D6npYxvr.js";
|
|
2
|
-
import { e as v, a as L } from "./scripts-CKTFtxPO.js";
|
|
3
|
-
const w = "FORMIE_GOOGLE_ADDRESS_SCRIPT", m = "formieGoogleMapsReady";
|
|
4
|
-
let f = null;
|
|
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
|
-
if (s?.places?.PlaceAutocompleteElement)
|
|
10
|
-
return n;
|
|
11
|
-
const i = s;
|
|
12
|
-
return typeof i?.importLibrary == "function" && await i.importLibrary("places"), n;
|
|
13
|
-
}
|
|
14
|
-
if (f)
|
|
15
|
-
return f;
|
|
16
|
-
if (document.getElementById(w)) {
|
|
17
|
-
const s = await v("google", 1e4), i = s?.maps;
|
|
18
|
-
return typeof i?.importLibrary == "function" && await i.importLibrary("places"), s;
|
|
19
|
-
}
|
|
20
|
-
const o = new URL("https://maps.googleapis.com/maps/api/js");
|
|
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((d, r) => {
|
|
23
|
-
const u = setTimeout(() => {
|
|
24
|
-
e[m] && (delete e[m], r(new Error("Google Maps API load timeout")));
|
|
25
|
-
}, 15e3);
|
|
26
|
-
e[m] = () => {
|
|
27
|
-
clearTimeout(u), delete e[m], d(e.google);
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
await L({
|
|
31
|
-
id: w,
|
|
32
|
-
src: o.toString(),
|
|
33
|
-
async: !0,
|
|
34
|
-
defer: !0
|
|
35
|
-
});
|
|
36
|
-
const i = await s, l = i?.maps;
|
|
37
|
-
return typeof l?.importLibrary == "function" && await l.importLibrary("places"), i;
|
|
38
|
-
})();
|
|
39
|
-
try {
|
|
40
|
-
return await f;
|
|
41
|
-
} catch (s) {
|
|
42
|
-
throw f = null, s;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function A(t, e) {
|
|
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
|
-
}
|
|
48
|
-
function S() {
|
|
49
|
-
return {
|
|
50
|
-
subpremise: "shortText",
|
|
51
|
-
street_number: "shortText",
|
|
52
|
-
route: "longText",
|
|
53
|
-
postal_town: "longText",
|
|
54
|
-
locality: "longText",
|
|
55
|
-
administrative_area_level_1: "shortText",
|
|
56
|
-
country: "shortText",
|
|
57
|
-
postal_code: "shortText"
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function b(t) {
|
|
61
|
-
const e = S(), n = {};
|
|
62
|
-
for (const a of t) {
|
|
63
|
-
const o = a.types?.[0];
|
|
64
|
-
if (!o || !e[o]) continue;
|
|
65
|
-
const s = e[o], i = a[s] ?? a.short_text ?? a.long_text ?? "";
|
|
66
|
-
n[o] = i;
|
|
67
|
-
}
|
|
68
|
-
return n;
|
|
69
|
-
}
|
|
70
|
-
function C(t) {
|
|
71
|
-
let e = "";
|
|
72
|
-
return (t.street_number || t.route) && (e = [t.street_number, t.route].filter(Boolean).join(" "), t.subpremise && (e = `${t.subpremise}/${e}`)), {
|
|
73
|
-
address1: e,
|
|
74
|
-
city: t.locality || t.postal_town || "",
|
|
75
|
-
state: t.administrative_area_level_1 || "",
|
|
76
|
-
zip: t.postal_code || "",
|
|
77
|
-
country: t.country || ""
|
|
78
|
-
};
|
|
79
|
-
}
|
|
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({
|
|
99
|
-
id: "google-address",
|
|
100
|
-
load: async ({ options: t }) => {
|
|
101
|
-
const e = t.provider.apiKey;
|
|
102
|
-
if (!e)
|
|
103
|
-
throw new Error("Google Places API key is required");
|
|
104
|
-
return R(e);
|
|
105
|
-
},
|
|
106
|
-
mount: async ({ api: t, field: e, services: n, provider: a }) => {
|
|
107
|
-
const o = n.input.getAutocomplete(), s = t?.maps?.places?.PlaceAutocompleteElement;
|
|
108
|
-
if (!o || typeof s != "function")
|
|
109
|
-
return console.warn("[formie] Google Places API not ready; address autocomplete skipped."), null;
|
|
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));
|
|
114
|
-
const u = o.value;
|
|
115
|
-
if (u) {
|
|
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;
|
|
120
|
-
pointer-events: none; color: #6B7280; font-size: 14px; z-index: 1;
|
|
121
|
-
`, r.appendChild(c), l.addEventListener("focusin", () => {
|
|
122
|
-
c.style.display = "none";
|
|
123
|
-
}), l.addEventListener("focusout", () => {
|
|
124
|
-
o.value && (c.style.display = "");
|
|
125
|
-
});
|
|
126
|
-
}
|
|
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;
|
|
130
|
-
if (!h) return;
|
|
131
|
-
const p = await h.toPlace();
|
|
132
|
-
if (await p.fetchFields({ fields: ["addressComponents", "formattedAddress"] }), !p.addressComponents) return;
|
|
133
|
-
const P = b(
|
|
134
|
-
p.addressComponents
|
|
135
|
-
), _ = C(P);
|
|
136
|
-
A(n, {
|
|
137
|
-
..._,
|
|
138
|
-
formattedAddress: p.formattedAddress
|
|
139
|
-
}), e.dispatchEvent(
|
|
140
|
-
new CustomEvent(E("google", "populate"), {
|
|
141
|
-
bubbles: !0,
|
|
142
|
-
detail: {
|
|
143
|
-
addressProvider: "google",
|
|
144
|
-
place: p,
|
|
145
|
-
formattedAddress: p.formattedAddress,
|
|
146
|
-
addressComponents: p.addressComponents
|
|
147
|
-
}
|
|
148
|
-
})
|
|
149
|
-
);
|
|
150
|
-
};
|
|
151
|
-
return l.addEventListener("gmp-select", y), l;
|
|
152
|
-
},
|
|
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))
|
|
156
|
-
try {
|
|
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);
|
|
159
|
-
const y = await (await fetch(i, {
|
|
160
|
-
method: "POST",
|
|
161
|
-
body: r,
|
|
162
|
-
credentials: "include",
|
|
163
|
-
headers: {
|
|
164
|
-
"X-Requested-With": "XMLHttpRequest",
|
|
165
|
-
Accept: "application/json"
|
|
166
|
-
}
|
|
167
|
-
})).json();
|
|
168
|
-
if (y?.results?.[0]?.address_components) {
|
|
169
|
-
const c = b(
|
|
170
|
-
y.results[0].address_components
|
|
171
|
-
), g = C(c);
|
|
172
|
-
A(n, g);
|
|
173
|
-
}
|
|
174
|
-
} catch {
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
export {
|
|
179
|
-
G as buildGoogleAutocompleteOptions,
|
|
180
|
-
I as googleAddressModule
|
|
181
|
-
};
|