@verbb/formie-browser 1.0.3 → 1.0.5
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 +65 -17
- 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-CgVJcQ2P.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-CZ3FU5QO.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-BF5GU3_9.js +2674 -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-Cv8ADyk-.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-CpgqHCEx.js +463 -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-B09elPDB.js +125 -0
- package/dist/chunks/theme-classes-Tv7q7ToE.js +44 -0
- package/dist/chunks/turnstile-D_Pi1CKM.js +58 -0
- package/dist/chunks/utils-Vqp8i_RM.js +49401 -0
- package/dist/css/formie-theme.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/index.js +2447 -39
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/field-error-container.d.ts +4 -0
- package/dist/js/core/field-error-container.d.ts.map +1 -0
- package/dist/js/core/submit-result-state.d.ts.map +1 -1
- package/dist/js/core/submit-result-ui.d.ts.map +1 -1
- package/dist/js/core/validation-focus.d.ts +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/checkbox-radio.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/file-upload.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/text-limit.d.ts.map +1 -1
- 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/dist/js/utils/i18n.d.ts.map +1 -1
- package/dist/js/validation/rules/email.d.ts.map +1 -1
- package/dist/js/validation/rules/number.d.ts.map +1 -1
- package/dist/js/validation/validator.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/css/formie-theme.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/js/core/create-formie-client.ts +27 -0
- package/src/js/core/field-error-container.ts +39 -0
- package/src/js/core/submit-result-state.ts +12 -2
- package/src/js/core/submit-result-ui.ts +7 -13
- 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/checkbox-radio.ts +21 -15
- 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/file-upload.ts +12 -9
- package/src/js/modules/fields/index.ts +6 -0
- package/src/js/modules/fields/phone-country.ts +6 -0
- package/src/js/modules/fields/text-limit.ts +87 -22
- 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/js/utils/i18n.ts +184 -5
- package/src/js/validation/rules/email.ts +3 -2
- package/src/js/validation/rules/match.ts +2 -2
- package/src/js/validation/rules/minmax.ts +4 -4
- package/src/js/validation/rules/number.ts +9 -5
- package/src/js/validation/rules/pattern.ts +4 -4
- package/src/js/validation/rules/required.ts +1 -1
- package/src/js/validation/rules/url.ts +1 -1
- package/src/js/validation/validator.ts +7 -7
- package/dist/chunks/address-finder-BjMuEiwF.js +0 -37
- package/dist/chunks/bpoint-KudsBCo2.js +0 -26
- package/dist/chunks/calculations-DlGSkQ3W.js +0 -147
- package/dist/chunks/captcha-eu-CterYFok.js +0 -34
- package/dist/chunks/checkbox-radio-CBvgk3hR.js +0 -136
- package/dist/chunks/conditions-DYy1-Hwt.js +0 -459
- package/dist/chunks/date-picker-BlD--zfe.js +0 -4994
- package/dist/chunks/eway-qwc-B5Us.js +0 -74
- package/dist/chunks/file-upload-CIgHrXfp.js +0 -316
- package/dist/chunks/friendly-captcha-v1-EDFac33c.js +0 -33
- package/dist/chunks/friendly-captcha-v2-BDpSvFGR.js +0 -38
- package/dist/chunks/go-cardless-DuDMVsnz.js +0 -24
- package/dist/chunks/google-address-Bmjp01pH.js +0 -181
- package/dist/chunks/hcaptcha-BTQ6An6g.js +0 -56
- package/dist/chunks/hidden-DbPdOxKb.js +0 -31
- package/dist/chunks/index-BEsfee-D.js +0 -1839
- package/dist/chunks/index-BP7Unm5Y.js +0 -863
- package/dist/chunks/index-BcqwpPNE.js +0 -4314
- package/dist/chunks/loqate-BdNGv93o.js +0 -55
- package/dist/chunks/mollie-DFOjTuGX.js +0 -24
- package/dist/chunks/moneris-BbFfl-EL.js +0 -101
- package/dist/chunks/opayo-CmgYa9ya.js +0 -122
- package/dist/chunks/paddle-BUi7w1_o.js +0 -60
- package/dist/chunks/paypal-A-ePfh6k.js +0 -100
- package/dist/chunks/payway-BqFCbhyo.js +0 -56
- package/dist/chunks/phone-country-DPMiqk4L.js +0 -3765
- package/dist/chunks/place-kit-CX7tamAg.js +0 -42
- package/dist/chunks/placekit-autocomplete.esm-LAwfbPZl.js +0 -1299
- package/dist/chunks/recaptcha-enterprise-DxF6cW95.js +0 -71
- package/dist/chunks/recaptcha-shared-DhGcbiaq.js +0 -15
- package/dist/chunks/recaptcha-v2-checkbox-R9EfbZ4k.js +0 -41
- package/dist/chunks/recaptcha-v2-invisible-DV9hswAp.js +0 -59
- package/dist/chunks/recaptcha-v3-V0xc-Edh.js +0 -28
- package/dist/chunks/repeater-DKUT6TGI.js +0 -124
- package/dist/chunks/rich-text-SH7KiaKH.js +0 -304
- package/dist/chunks/scripts-D9N2d5rN.js +0 -36
- package/dist/chunks/sdk-3SicTWby.js +0 -1559
- package/dist/chunks/shared-BmntPmnW.js +0 -80
- package/dist/chunks/signature-BA3tQsGT.js +0 -550
- package/dist/chunks/snaptcha-DV7p6J9k.js +0 -8
- package/dist/chunks/square-Bs-ndqYK.js +0 -46
- package/dist/chunks/stripe-DkZAHxtn.js +0 -202
- package/dist/chunks/styles-C3aqgtek.js +0 -21
- package/dist/chunks/summary-Dq2i9TQk.js +0 -126
- package/dist/chunks/table-Cu4WfVcw.js +0 -95
- package/dist/chunks/text-limit-2ycmB-Ae.js +0 -135
- package/dist/chunks/turnstile-CId90tRr.js +0 -59
- package/dist/chunks/utils-BntI3W4S.js +0 -6149
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { s as e } from "./event-names-BCI2FLD8.js";
|
|
2
|
+
import { t } from "./api-CmwLRq_n.js";
|
|
3
|
+
import { r as n, t as r } from "./theme-classes-Tv7q7ToE.js";
|
|
4
|
+
import { r as i } from "./scripts-6CYSUGKQ.js";
|
|
5
|
+
import { t as a } from "./styles-BfoIZwJp.js";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/js/modules/payments/stripe.ts
|
|
8
|
+
a("stripe", ["@layer formie-theme{.formie-stripe-placeholder{justify-content:center;align-items:center;gap:var(--formie-space-2);width:100%;min-height:12rem;padding:var(--formie-space-4);border:var(--formie-border-width) solid var(--formie-color-border);border-radius:var(--formie-radius-sm);background:var(--formie-color-surface);color:var(--formie-color-text-muted);text-align:center;box-sizing:border-box;flex-direction:column;display:flex}.formie-stripe-placeholder[hidden]{display:none}}"]);
|
|
9
|
+
var o = "FORMIE_STRIPE_SCRIPT", s = e("stripe", "confirm"), c = "[data-formie-stripe-elements-placeholder]", l = new Set([
|
|
10
|
+
"BIF",
|
|
11
|
+
"CLP",
|
|
12
|
+
"DJF",
|
|
13
|
+
"GNF",
|
|
14
|
+
"JPY",
|
|
15
|
+
"KMF",
|
|
16
|
+
"KRW",
|
|
17
|
+
"MGA",
|
|
18
|
+
"PYG",
|
|
19
|
+
"RWF",
|
|
20
|
+
"UGX",
|
|
21
|
+
"VND",
|
|
22
|
+
"VUV",
|
|
23
|
+
"XAF",
|
|
24
|
+
"XOF",
|
|
25
|
+
"XPF"
|
|
26
|
+
]);
|
|
27
|
+
function u(e, t) {
|
|
28
|
+
return l.has(t.toUpperCase()) ? Math.ceil(e) : Math.ceil(e * 100);
|
|
29
|
+
}
|
|
30
|
+
function d(e, t) {
|
|
31
|
+
e && (n(e, t, "fieldErrors", "fieldError"), e.querySelectorAll("[data-payment-placeholder-error]").forEach((e) => {
|
|
32
|
+
n(e, t, "fieldError");
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
function f(e, t, n = "Loading payment options...") {
|
|
36
|
+
if (!e) return;
|
|
37
|
+
d(e, t), e.removeAttribute("hidden"), e.innerHTML = "";
|
|
38
|
+
let r = document.createElement("div");
|
|
39
|
+
r.className = "formie-loading";
|
|
40
|
+
let i = document.createElement("div");
|
|
41
|
+
i.textContent = n, e.append(r, i);
|
|
42
|
+
}
|
|
43
|
+
function p(e, t, n) {
|
|
44
|
+
if (!e) return;
|
|
45
|
+
d(e, t), e.removeAttribute("hidden"), r(e, t, "fieldErrors"), e.innerHTML = "";
|
|
46
|
+
let i = document.createElement("div");
|
|
47
|
+
i.setAttribute("data-payment-placeholder-error", ""), i.textContent = n, r(i, t, "fieldError"), e.appendChild(i);
|
|
48
|
+
}
|
|
49
|
+
var m = t({
|
|
50
|
+
id: "stripe",
|
|
51
|
+
defaultRequiredInputSuffixes: ["stripePaymentIntentId"],
|
|
52
|
+
load: async (e) => {
|
|
53
|
+
let { provider: t } = e.options, n = t.publishableKey;
|
|
54
|
+
return n?.trim() ? (await i("Stripe", {
|
|
55
|
+
id: o,
|
|
56
|
+
src: "https://js.stripe.com/v3"
|
|
57
|
+
}))(n) : (console.error("[formie] Missing publishableKey for Stripe."), null);
|
|
58
|
+
},
|
|
59
|
+
mount: async (e) => {
|
|
60
|
+
let { api: t, field: n, services: r, provider: i } = e, a = n.querySelector("[data-formie-stripe-elements]"), o = n.querySelector(c), s = n, l = r.form || r.root;
|
|
61
|
+
if (!a || !t) return null;
|
|
62
|
+
let m = i.initialPaymentInformation || {}, h = [m.amount, m.currency].map((e) => String(e ?? "").trim()).filter((e, t) => (t === 0 ? i.amountType : i.currencyType) === "dynamic" && e !== ""), g = () => {
|
|
63
|
+
let e = r.resolveAmount({ value: m.amount });
|
|
64
|
+
if (!e.ok) return {
|
|
65
|
+
ok: !1,
|
|
66
|
+
error: "error" in e ? e.error : "Provide a payment amount to proceed."
|
|
67
|
+
};
|
|
68
|
+
let t = r.resolveCurrency({ value: m.currency });
|
|
69
|
+
if (!t.ok) return {
|
|
70
|
+
ok: !1,
|
|
71
|
+
error: "error" in t ? t.error : "Provide a payment currency to proceed."
|
|
72
|
+
};
|
|
73
|
+
let n = t.value.toLowerCase(), a = i.amountType === "dynamic" ? u(e.value, n) : e.value;
|
|
74
|
+
return {
|
|
75
|
+
ok: !0,
|
|
76
|
+
value: {
|
|
77
|
+
...m,
|
|
78
|
+
capture_method: "automatic",
|
|
79
|
+
mode: i.paymentType === "subscription" ? "subscription" : "payment",
|
|
80
|
+
appearance: {},
|
|
81
|
+
amount: a,
|
|
82
|
+
currency: n
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}, _ = () => {
|
|
86
|
+
try {
|
|
87
|
+
s.__formieStripeWidget?.paymentElement?.destroy?.();
|
|
88
|
+
} catch {}
|
|
89
|
+
s.__formieStripeWidget = null, s.__formieStripeElements = void 0, a.innerHTML = "";
|
|
90
|
+
}, v = () => {
|
|
91
|
+
let e = g();
|
|
92
|
+
if (!e.ok) {
|
|
93
|
+
_(), p(o, l, "error" in e ? e.error : "Unable to resolve payment details.");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
if (s.__formieStripeWidget && s.__formieStripeElements) {
|
|
98
|
+
s.__formieStripeElements.update(e.value), d(o, l), o?.setAttribute("hidden", "hidden");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
f(o, l);
|
|
102
|
+
let n = t.elements(e.value), r = n.create("payment", {});
|
|
103
|
+
r.mount(a), r.on?.("loaderror", (e) => {
|
|
104
|
+
let t = e?.error?.message || "Unable to load payment options.";
|
|
105
|
+
_(), p(o, l, t);
|
|
106
|
+
}), r.on?.("ready", () => {
|
|
107
|
+
d(o, l), o?.setAttribute("hidden", "hidden");
|
|
108
|
+
}), s.__formieStripeElements = n, s.__formieStripeInstance = t, s.__formieStripeWidget = {
|
|
109
|
+
elements: n,
|
|
110
|
+
paymentElement: r
|
|
111
|
+
}, r.on || (d(o, l), o?.setAttribute("hidden", "hidden"));
|
|
112
|
+
} catch (e) {
|
|
113
|
+
_(), p(o, l, e instanceof Error ? e.message : "Unable to initialize Stripe payment element.");
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
return s.__formieStripeEvaluateAndRender = v, s.__formieStripeDynamicUnbind?.(), h.length > 0 && (s.__formieStripeDynamicUnbind = r.watchFieldValueChanges(h, () => {
|
|
117
|
+
v();
|
|
118
|
+
}, 600)), v(), s.__formieStripeWidget || null;
|
|
119
|
+
},
|
|
120
|
+
unmount: async (e) => {
|
|
121
|
+
e.widget?.paymentElement?.destroy();
|
|
122
|
+
let t = e.field;
|
|
123
|
+
t.__formieStripeWidget = null, t.__formieStripeElements = void 0, t.__formieStripeInstance = null, t.__formieStripeLastClientSecret = void 0, t.__formieStripeEvaluateAndRender = null, t.__formieStripeDynamicUnbind?.(), t.__formieStripeDynamicUnbind = null;
|
|
124
|
+
},
|
|
125
|
+
onBeforeAuthorize: async (e) => {
|
|
126
|
+
let { widget: t, services: n, field: r } = e, i = r, a = t;
|
|
127
|
+
if (a?.elements || (i.__formieStripeEvaluateAndRender?.(), a = i.__formieStripeWidget || null), !a?.elements) return !1;
|
|
128
|
+
let o = await a.elements.submit();
|
|
129
|
+
return o?.error ? (n.addError(o.error.message), !1) : !0;
|
|
130
|
+
},
|
|
131
|
+
setup: async (e) => {
|
|
132
|
+
let { services: t, options: n } = e, r = n.provider, i = e.target;
|
|
133
|
+
return i.__formieStripeConfirmUnbind?.(), i.__formieStripeConfirmUnbind = t.events.onForm(s, async (e) => {
|
|
134
|
+
try {
|
|
135
|
+
let n = e.detail?.data;
|
|
136
|
+
if (!n?.clientSecret || i.__formieStripeConfirming || i.__formieStripeLastClientSecret === n.clientSecret) return;
|
|
137
|
+
let a = i.__formieStripeElements;
|
|
138
|
+
if (!a) {
|
|
139
|
+
t.addError("Stripe elements not ready for 3DS.");
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
let o = i.__formieStripeInstance, s = r.publishableKey;
|
|
143
|
+
if (!o || !s) {
|
|
144
|
+
t.addError("Stripe is not initialized.");
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
i.__formieStripeConfirming = !0;
|
|
148
|
+
let c = new URL(n.returnUrl || window.location.href);
|
|
149
|
+
c.searchParams.set("origin", window.location.href);
|
|
150
|
+
let l = await (n.type === "setup" ? o.confirmSetup : o.confirmPayment)({
|
|
151
|
+
elements: a,
|
|
152
|
+
clientSecret: n.clientSecret,
|
|
153
|
+
redirect: "if_required",
|
|
154
|
+
confirmParams: { return_url: c.toString() }
|
|
155
|
+
});
|
|
156
|
+
if (l?.error) {
|
|
157
|
+
t.releaseSubmitLoading(), t.addError(l.error.message);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
n.subscriptionId && t.updateInputs("stripeSubscriptionId", n.subscriptionId);
|
|
161
|
+
let u = l && "paymentIntent" in l ? l.paymentIntent : null, d = l && "setupIntent" in l ? l.setupIntent : null;
|
|
162
|
+
if (u?.id) t.updateInputs("stripePaymentIntentId", u.id);
|
|
163
|
+
else if (d?.id) t.updateInputs("stripePaymentIntentId", d.id);
|
|
164
|
+
else {
|
|
165
|
+
t.releaseSubmitLoading(), t.addError("Stripe confirmation did not return an intent ID.");
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
i.__formieStripeLastClientSecret = n.clientSecret, t.triggerSubmit();
|
|
169
|
+
} catch (e) {
|
|
170
|
+
t.releaseSubmitLoading(), t.addError(e instanceof Error ? e.message : "Unable to confirm Stripe payment.");
|
|
171
|
+
} finally {
|
|
172
|
+
i.__formieStripeConfirming = !1;
|
|
173
|
+
}
|
|
174
|
+
}), { destroy: () => {
|
|
175
|
+
i.__formieStripeConfirmUnbind?.(), i.__formieStripeConfirmUnbind = null;
|
|
176
|
+
} };
|
|
177
|
+
},
|
|
178
|
+
onAfterSubmit: async (e) => {
|
|
179
|
+
let t = e.field;
|
|
180
|
+
e.result?.ok && !e.result?.nextPage && (t.__formieStripeWidget?.paymentElement?.destroy?.(), t.__formieStripeWidget = null, t.__formieStripeElements = void 0, e.services.updateInputs(["stripePaymentIntentId", "stripeSubscriptionId"], ""), t.__formieStripeLastClientSecret = void 0);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
//#endregion
|
|
184
|
+
export { m as stripeModule };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/js/modules/styles.ts
|
|
2
|
+
var e = /* @__PURE__ */ new Set();
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
if (typeof document > "u") return;
|
|
5
|
+
let r = `formie-module-style:${t}`;
|
|
6
|
+
if (e.has(r) || document.querySelector(`style[data-formie-module-style="${t}"]`)) {
|
|
7
|
+
e.add(r);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
let i = n.filter((e) => typeof e == "string" && e.trim().length > 0).join("\n");
|
|
11
|
+
if (!i) {
|
|
12
|
+
e.add(r);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let a = document.createElement("style");
|
|
16
|
+
a.setAttribute("data-formie-module-style", t), a.textContent = i, document.head.appendChild(a), e.add(r);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { t };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { t as e } from "./debug-BV0DvdHx.js";
|
|
2
|
+
import { i as t } from "./theme-classes-Tv7q7ToE.js";
|
|
3
|
+
import { n } from "./http-D-JExro7.js";
|
|
4
|
+
import { t as r } from "./async-nPFRNQ06.js";
|
|
5
|
+
import { t as i } from "./styles-BfoIZwJp.js";
|
|
6
|
+
import { r as a, t as o } from "./shared-Bx9s0i0P.js";
|
|
7
|
+
//#region src/css/theme/fields/_summary.css?inline
|
|
8
|
+
var s = "@layer formie-theme{.formie-summary-container{padding:var(--formie-summary-padding);border:var(--formie-border-width) solid var(--formie-color-border);border-radius:var(--formie-radius-sm)}.formie-summary-heading{color:var(--formie-color-heading)}.formie-summary-blocks{gap:var(--formie-gap-summary);display:grid}.formie-summary-blocks[data-formie-loading=true]{min-height:calc(var(--formie-loading-size) + var(--formie-space-4));position:relative}.formie-summary-blocks[data-formie-loading=true]>*{opacity:0;pointer-events:none}.formie-summary-blocks[data-formie-loading=true]:before{content:\"\";background:var(--formie-color-bg);border-radius:inherit;z-index:1;display:block;position:absolute;inset:0}.formie-summary-blocks[data-formie-loading=true]:after{width:var(--formie-loading-size);height:var(--formie-loading-size);content:\"\";border:var(--formie-loading-border-width) solid var(--formie-loading-color);border-radius:var(--formie-radius-full);z-index:2;animation:formie-loading-spin var(--formie-loading-speed) linear infinite;border-top-color:#0000;border-right-color:#0000;display:block;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}}", c = "[data-formie-summary-blocks]", l = "[data-formie-summary-container]", u = "formie/fields/get-summary-html", d = "summary", f = e("fields", "summary");
|
|
9
|
+
i(d, [s]);
|
|
10
|
+
function p() {
|
|
11
|
+
let e = new URL(window.location.href);
|
|
12
|
+
return e.hash = "", e.toString();
|
|
13
|
+
}
|
|
14
|
+
function m(e) {
|
|
15
|
+
return { accessToken: e.querySelector("[data-formie-summary-token]")?.value?.trim() || null };
|
|
16
|
+
}
|
|
17
|
+
async function h(e, t, r) {
|
|
18
|
+
if (!t.accessToken) throw Error("Summary field requires an access token.");
|
|
19
|
+
let i = new FormData(e);
|
|
20
|
+
return i.set("action", u), i.set("accessToken", t.accessToken), n(p(), {
|
|
21
|
+
method: "POST",
|
|
22
|
+
body: i,
|
|
23
|
+
signal: r,
|
|
24
|
+
headers: { Accept: "text/html" }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function g(e, n) {
|
|
28
|
+
let i = e.closest("form");
|
|
29
|
+
if (!(i instanceof HTMLFormElement)) return f.warn("Missing form ancestor; skipping field."), () => {};
|
|
30
|
+
let a = !1, s = !0, u = !1, p = 0, g = 0, _ = null, v = () => {
|
|
31
|
+
let t = e.querySelector(c);
|
|
32
|
+
return t instanceof HTMLElement ? t : null;
|
|
33
|
+
}, y = () => {
|
|
34
|
+
let t = e.querySelector(l);
|
|
35
|
+
return t instanceof HTMLElement ? t : null;
|
|
36
|
+
}, b = (e) => {
|
|
37
|
+
let n = v();
|
|
38
|
+
if (n) {
|
|
39
|
+
if (e) {
|
|
40
|
+
n.setAttribute("data-formie-loading", "true"), n.setAttribute("aria-busy", "true"), t(n, i, "loading", !0);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
n.removeAttribute("data-formie-loading"), n.removeAttribute("aria-busy"), t(n, i, "loading", !1);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
b(!!m(e).accessToken);
|
|
47
|
+
let x = () => {
|
|
48
|
+
!u || a && !s || (f.log("Queueing fetch."), S());
|
|
49
|
+
}, S = r(async () => {
|
|
50
|
+
let t = m(e);
|
|
51
|
+
if (!v() || !t.accessToken) {
|
|
52
|
+
f.warn("Missing state for fetch.", t), b(!1);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
g += 1;
|
|
56
|
+
let n = g, r = p;
|
|
57
|
+
_?.abort(), _ = new AbortController(), b(!0);
|
|
58
|
+
try {
|
|
59
|
+
let c = await h(i, t, _.signal);
|
|
60
|
+
if (n !== g) return;
|
|
61
|
+
let u = y(), m = document.createElement("template");
|
|
62
|
+
m.innerHTML = c.trim();
|
|
63
|
+
let v = m.content.querySelector(l);
|
|
64
|
+
u && v instanceof HTMLElement ? u.replaceWith(v) : u && (u.innerHTML = c), a = !0, s = p !== r, f.log("Fetch complete.", {
|
|
65
|
+
isDirty: s,
|
|
66
|
+
dirtyVersion: p,
|
|
67
|
+
requestVersion: n
|
|
68
|
+
}), o(e, d, "fetch-summary", {
|
|
69
|
+
summary: e,
|
|
70
|
+
html: c
|
|
71
|
+
});
|
|
72
|
+
} catch (e) {
|
|
73
|
+
if (e instanceof DOMException && e.name === "AbortError") {
|
|
74
|
+
f.log("Fetch aborted.");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
console.error("[formie] Failed to load summary field HTML.", e);
|
|
78
|
+
} finally {
|
|
79
|
+
n === g && (b(!1), _ = null, s && x());
|
|
80
|
+
}
|
|
81
|
+
}, 300), C = (t) => {
|
|
82
|
+
let n = t?.target;
|
|
83
|
+
n instanceof Node && e.contains(n) || (s = !0, p += 1, f.log("Marked dirty.", { dirtyVersion: p }));
|
|
84
|
+
}, w = (e) => {
|
|
85
|
+
C(e), x();
|
|
86
|
+
}, T = () => {
|
|
87
|
+
s = !0, f.log("Submit result received; refreshing."), x();
|
|
88
|
+
}, E = () => {
|
|
89
|
+
s = !0, f.log("Page navigation received; refreshing."), x();
|
|
90
|
+
}, D = new IntersectionObserver((t) => {
|
|
91
|
+
u = !!t[0]?.isIntersecting, u && (f.log("Field became visible."), o(e, d, "field-visible", { summary: e }), x());
|
|
92
|
+
}, {
|
|
93
|
+
root: i,
|
|
94
|
+
rootMargin: "50px"
|
|
95
|
+
});
|
|
96
|
+
return D.observe(e), i.addEventListener("input", w), i.addEventListener("change", w), n.addEventListener("formie:page:navigate:after", E), n.addEventListener("formie:submit:result", T), () => {
|
|
97
|
+
_?.abort(), D.disconnect(), i.removeEventListener("input", w), i.removeEventListener("change", w), n.removeEventListener("formie:page:navigate:after", E), n.removeEventListener("formie:submit:result", T), f.log("Field destroyed.");
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
var _ = {
|
|
101
|
+
id: d,
|
|
102
|
+
kind: "field",
|
|
103
|
+
match: (e) => !!e.target.querySelector(c),
|
|
104
|
+
setup: async (e) => {
|
|
105
|
+
let t = a(e).map((t) => g(t, e.root));
|
|
106
|
+
return f.log("Module setup.", { fieldCount: t.length }), await e.emit("formie:module:summary:init", { count: t.length }), { destroy: () => {
|
|
107
|
+
t.forEach((e) => {
|
|
108
|
+
e();
|
|
109
|
+
}), f.log("Module destroy.", { fieldCount: t.length }), e.emit("formie:module:summary:destroy", {});
|
|
110
|
+
} };
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
//#endregion
|
|
114
|
+
export { _ as summaryModule };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { n as e } from "./async-nPFRNQ06.js";
|
|
2
|
+
import { t } from "./styles-BfoIZwJp.js";
|
|
3
|
+
import { a as n, o as r, t as i } from "./shared-Bx9s0i0P.js";
|
|
4
|
+
//#region src/css/theme/fields/_table.css?inline
|
|
5
|
+
var a = "@layer formie-theme{.formie-table-wrapper{-webkit-overflow-scrolling:touch;max-width:100%;overflow:auto hidden}.formie-table{width:var(--formie-table-width);margin-bottom:var(--formie-table-margin-bottom);border-collapse:var(--formie-table-border-collapse)}.formie-table th{text-align:var(--formie-table-th-text-align);font-size:var(--formie-table-th-font-size);font-weight:var(--formie-table-th-font-weight);color:var(--formie-table-th-color,var(--formie-gray-500))}.formie-table th,.formie-table td{padding:var(--formie-table-row-padding);vertical-align:top}.formie-table th:first-child,.formie-table td:first-child{padding-left:0}.formie-table th:last-child,.formie-table td:last-child{padding-right:0}.formie-table [data-col-remove]{width:calc(var(--formie-button-icon-button-size) + (var(--formie-table-row-padding) * 2));min-width:calc(var(--formie-button-icon-button-size) + (var(--formie-table-row-padding) * 2));white-space:nowrap;text-align:center;vertical-align:middle}.formie-table [data-formie-table-column-type=checkbox]{text-align:center;vertical-align:middle}.formie-table [data-formie-table-column-type=checkbox] .formie-checkbox-option{width:100%;min-height:var(--formie-check-size);justify-content:center;align-items:center;margin:0;display:flex}.formie-table [data-formie-table-column-type=checkbox] .formie-checkbox-option-label{width:var(--formie-check-size);min-width:var(--formie-check-size);height:var(--formie-check-size);margin:0 auto;padding-left:0;font-size:0;line-height:0;display:block}.formie-table [data-formie-table-column-type=checkbox] .formie-checkbox-option-label:before{position:static}.formie-table-color-input{min-width:4rem;padding:var(--formie-space-1)}.formie-table-multiline-input{min-height:calc(var(--formie-control-height) + var(--formie-space-2))}.formie-table-remove-button{vertical-align:middle;display:inline-flex}.formie-button.formie-table-add-button{width:auto;max-width:100%;padding-left:var(--formie-table-add-button-padding-left);justify-content:center;justify-self:start;align-items:center;display:inline-flex;position:relative}.formie-button.formie-table-add-button:before{content:\"\";width:var(--formie-table-add-button-width);height:var(--formie-table-add-button-height);left:var(--formie-table-add-button-left);-webkit-mask-image:var(--formie-table-add-button-icon-mask);-webkit-mask-image:var(--formie-table-add-button-icon-mask);mask-image:var(--formie-table-add-button-icon-mask);background-color:currentColor;display:block;position:absolute;top:50%;transform:translateY(-50%);-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}}", o = "[data-formie-table-field-layout]", s = "[data-formie-table]", c = "[data-formie-table-body]", l = "[data-formie-table-row]", u = "[data-formie-table-add]", d = "[data-formie-table-remove]", f = "data-formie-template-id", p = "data-formie-table-row-id", m = "table";
|
|
6
|
+
t(m, [a]);
|
|
7
|
+
function h(e, t) {
|
|
8
|
+
return n(e, t);
|
|
9
|
+
}
|
|
10
|
+
function g(e) {
|
|
11
|
+
return e.querySelectorAll(l).length;
|
|
12
|
+
}
|
|
13
|
+
function _(e) {
|
|
14
|
+
return Array.from(e.querySelectorAll(l)).reduce((e, t) => {
|
|
15
|
+
let n = parseInt(t.getAttribute(p) || "", 10);
|
|
16
|
+
return Number.isNaN(n) ? e : Math.max(e, n + 1);
|
|
17
|
+
}, 0);
|
|
18
|
+
}
|
|
19
|
+
function v(e, t) {
|
|
20
|
+
if (!e) return;
|
|
21
|
+
let n = parseInt(e.getAttribute("data-formie-max-rows") || "", 10);
|
|
22
|
+
e.disabled = n > 0 && t >= n;
|
|
23
|
+
}
|
|
24
|
+
function y(t, n) {
|
|
25
|
+
let a = t.querySelector(s), o = t.querySelector(c), y = t.querySelector(u);
|
|
26
|
+
if (!(a instanceof HTMLElement) || !(o instanceof HTMLElement)) return () => {};
|
|
27
|
+
let b = /* @__PURE__ */ new Map(), x = _(t), S = () => {
|
|
28
|
+
t.querySelectorAll(d).forEach((e) => {
|
|
29
|
+
if (!(e instanceof HTMLElement) || b.has(e)) return;
|
|
30
|
+
let n = (n) => {
|
|
31
|
+
n.preventDefault();
|
|
32
|
+
let r = e.closest(l);
|
|
33
|
+
if (!(r instanceof HTMLElement)) return;
|
|
34
|
+
let a = parseInt((y instanceof HTMLButtonElement ? y.getAttribute("data-formie-min-rows") : "") || "", 10);
|
|
35
|
+
a > 0 && g(t) <= a || (r.remove(), v(y instanceof HTMLButtonElement ? y : null, g(t)), i(t, m, "remove", {
|
|
36
|
+
table: t,
|
|
37
|
+
row: r
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
e.addEventListener("click", n), b.set(e, n);
|
|
41
|
+
});
|
|
42
|
+
}, C = async () => {
|
|
43
|
+
if (n.static || !(y instanceof HTMLButtonElement) || !y.getAttribute("data-formie-table-add")) return;
|
|
44
|
+
let a = y.getAttribute(f) || t.getAttribute(f), s = parseInt(y.getAttribute("data-formie-max-rows") || "", 10);
|
|
45
|
+
if (s > 0 && g(t) >= s) return;
|
|
46
|
+
let c = h(t, a);
|
|
47
|
+
if (!c) return;
|
|
48
|
+
let l = r(c).replaceAll("__ROW__", String(x++)), u = document.createElement("tr");
|
|
49
|
+
u.setAttribute("data-formie-table-row", "true"), u.setAttribute(p, String(x - 1)), u.innerHTML = l, o.appendChild(u), await e(50), S(), v(y, g(t)), i(t, m, "append", {
|
|
50
|
+
table: t,
|
|
51
|
+
row: u
|
|
52
|
+
});
|
|
53
|
+
}, w = (e) => {
|
|
54
|
+
e.preventDefault(), C();
|
|
55
|
+
};
|
|
56
|
+
return y instanceof HTMLButtonElement && !n.static && y.addEventListener("click", w), S(), v(y instanceof HTMLButtonElement ? y : null, g(t)), i(t, m, "init", { table: t }), () => {
|
|
57
|
+
y instanceof HTMLButtonElement && y.removeEventListener("click", w), b.forEach((e, t) => {
|
|
58
|
+
t.removeEventListener("click", e);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
var b = {
|
|
63
|
+
id: m,
|
|
64
|
+
kind: "field",
|
|
65
|
+
match: (e) => e.target instanceof HTMLElement && (e.target.matches(o) || !!e.target.querySelector(o)),
|
|
66
|
+
setup: async (e) => {
|
|
67
|
+
let t = e.options || {};
|
|
68
|
+
if (!(e.target instanceof HTMLElement)) return;
|
|
69
|
+
let n = e.target.matches(o) ? [e.target] : Array.from(e.target.querySelectorAll(o)).filter((e) => e instanceof HTMLElement), r = n.map((e) => y(e, t));
|
|
70
|
+
return await e.emit("formie:module:table:init", { count: n.length }), { destroy: () => {
|
|
71
|
+
r.forEach((e) => {
|
|
72
|
+
e();
|
|
73
|
+
}), e.emit("formie:module:table:destroy", {});
|
|
74
|
+
} };
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { b as tableModule };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { i as e } from "./i18n-BY1ds1BL.js";
|
|
2
|
+
import { t } from "./styles-BfoIZwJp.js";
|
|
3
|
+
import { c as n, i as r, l as i } from "./shared-Bx9s0i0P.js";
|
|
4
|
+
import { c as a } from "./dist-BF5GU3_9.js";
|
|
5
|
+
//#region src/css/theme/fields/_text-limit.css?inline
|
|
6
|
+
var o = "@layer formie-theme{.formie-limit-number{font-weight:var(--formie-font-weight-semibold);color:var(--formie-color-text)}.formie-limit-number-error{color:var(--formie-color-danger)}}", s = "input[data-formie-single-line-text-input], textarea[data-formie-multi-line-text-input]", c = [
|
|
7
|
+
"textMinCharacterLimit",
|
|
8
|
+
"textMaxCharacterLimit",
|
|
9
|
+
"textMinWordLimit",
|
|
10
|
+
"textMaxWordLimit"
|
|
11
|
+
], l = "text-limit", u = "data-formie-text-limit-allow-overtype", d = "{count, plural, one{character allowed} other{characters allowed}}", f = "{count, plural, one{character left} other{characters left}}", p = "{count, plural, one{character over limit} other{characters over limit}}", m = "{count, plural, one{word allowed} other{words allowed}}", h = "{count, plural, one{word left} other{words left}}", g = "{count, plural, one{word over limit} other{words over limit}}", _ = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
t("text-limit", [o]);
|
|
13
|
+
function v(e) {
|
|
14
|
+
return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement;
|
|
15
|
+
}
|
|
16
|
+
function y(e, t) {
|
|
17
|
+
return parseInt(e.getAttribute(t) || "", 10) || 0;
|
|
18
|
+
}
|
|
19
|
+
function b(e) {
|
|
20
|
+
return e.hasAttribute("data-formie-min-chars") || e.hasAttribute("data-formie-max-chars") || e.hasAttribute("data-formie-min-words") || e.hasAttribute("data-formie-max-words");
|
|
21
|
+
}
|
|
22
|
+
function x(e) {
|
|
23
|
+
return e.hasAttribute("data-formie-max-chars") || e.hasAttribute("data-formie-max-words");
|
|
24
|
+
}
|
|
25
|
+
function S(e) {
|
|
26
|
+
return e.hasAttribute(u);
|
|
27
|
+
}
|
|
28
|
+
function C(e) {
|
|
29
|
+
return e.value === "";
|
|
30
|
+
}
|
|
31
|
+
function w(e) {
|
|
32
|
+
i(e, l, (e) => {
|
|
33
|
+
e.addValidator("textMinCharacterLimit", ({ input: e }) => {
|
|
34
|
+
if (!v(e)) return !0;
|
|
35
|
+
let t = y(e, "data-formie-min-chars");
|
|
36
|
+
return !t || C(e) ? !0 : a(e.value).graphemeCount >= t;
|
|
37
|
+
}, ({ label: e, input: t, t: n }) => t.getAttribute("data-formie-validation-min-characters-message") || n("{label} must be no less than {min} characters.", {
|
|
38
|
+
label: e,
|
|
39
|
+
min: t.getAttribute("data-formie-min-chars") || ""
|
|
40
|
+
})), e.addValidator("textMaxCharacterLimit", ({ input: e }) => {
|
|
41
|
+
if (!v(e) || S(e)) return !0;
|
|
42
|
+
let t = y(e, "data-formie-max-chars");
|
|
43
|
+
return !t || C(e) ? !0 : a(e.value).graphemeCount <= t;
|
|
44
|
+
}, ({ label: e, input: t, t: n }) => t.getAttribute("data-formie-validation-max-characters-message") || n("{label} must be no greater than {max} characters.", {
|
|
45
|
+
label: e,
|
|
46
|
+
max: t.getAttribute("data-formie-max-chars") || ""
|
|
47
|
+
})), e.addValidator("textMinWordLimit", ({ input: e }) => {
|
|
48
|
+
if (!v(e)) return !0;
|
|
49
|
+
let t = y(e, "data-formie-min-words");
|
|
50
|
+
return !t || e.value.trim() === "" ? !0 : a(e.value).wordCount >= t;
|
|
51
|
+
}, ({ label: e, input: t, t: n }) => t.getAttribute("data-formie-validation-min-words-message") || n("{label} must be no less than {min} words.", {
|
|
52
|
+
label: e,
|
|
53
|
+
min: t.getAttribute("data-formie-min-words") || ""
|
|
54
|
+
})), e.addValidator("textMaxWordLimit", ({ input: e }) => {
|
|
55
|
+
if (!v(e) || S(e)) return !0;
|
|
56
|
+
let t = y(e, "data-formie-max-words");
|
|
57
|
+
return !t || e.value.trim() === "" ? !0 : a(e.value).wordCount <= t;
|
|
58
|
+
}, ({ label: e, input: t, t: n }) => t.getAttribute("data-formie-validation-max-words-message") || n("{label} must be no greater than {max} words.", {
|
|
59
|
+
label: e,
|
|
60
|
+
max: t.getAttribute("data-formie-max-words") || ""
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function T(e) {
|
|
65
|
+
n(e, l, c);
|
|
66
|
+
}
|
|
67
|
+
function E(e) {
|
|
68
|
+
if (_.has(e)) return _.get(e) || null;
|
|
69
|
+
let t = e.closest("[data-formie-field-handle]");
|
|
70
|
+
if (!t) return _.set(e, null), null;
|
|
71
|
+
let n = t.querySelector("[data-formie-limit-text]");
|
|
72
|
+
if (n) return _.set(e, n), n;
|
|
73
|
+
let r = t.querySelector("[data-formie-field-control]"), i = document.createElement("div");
|
|
74
|
+
return i.className = "formie-field-limit formie-limit-text", i.setAttribute("data-formie-field-limit", "true"), i.setAttribute("data-formie-limit-text", "true"), r?.parentElement ? (r.insertAdjacentElement("afterend", i), _.set(e, i), i) : (t.appendChild(i), _.set(e, i), i);
|
|
75
|
+
}
|
|
76
|
+
function D(e, t, n) {
|
|
77
|
+
return (n === "character" ? e.value === "" : e.value.trim() === "") ? "allowed" : t < 0 ? "over" : "left";
|
|
78
|
+
}
|
|
79
|
+
function O(e, t) {
|
|
80
|
+
return e === "character" ? t === "allowed" ? d : t === "over" ? p : f : t === "allowed" ? m : t === "over" ? g : h;
|
|
81
|
+
}
|
|
82
|
+
function k(t, n, r, i, a) {
|
|
83
|
+
let o = D(n, r, a), s = o === "allowed" ? i : Math.abs(r), c = document.createElement("span");
|
|
84
|
+
c.className = o === "over" ? "formie-limit-number formie-limit-number-error" : "formie-limit-number", c.textContent = String(s);
|
|
85
|
+
let l = O(a, o);
|
|
86
|
+
t.replaceChildren(c, document.createTextNode(` ${e(l, { count: s })}`));
|
|
87
|
+
}
|
|
88
|
+
function A(e) {
|
|
89
|
+
let t = y(e, "data-formie-max-chars"), n = y(e, "data-formie-max-words"), r = E(e);
|
|
90
|
+
if (!r) return;
|
|
91
|
+
let i = a(e.value);
|
|
92
|
+
if (t > 0) {
|
|
93
|
+
k(r, e, t - i.graphemeCount, t, "character");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
n > 0 && k(r, e, n - i.wordCount, n, "word");
|
|
97
|
+
}
|
|
98
|
+
var j = {
|
|
99
|
+
id: "text-limit",
|
|
100
|
+
kind: "field",
|
|
101
|
+
match: (e) => !!e.target.querySelector(s),
|
|
102
|
+
setup: async (e) => {
|
|
103
|
+
let t = e.options || {}, n = r(e), i = Array.from((n || e.target).querySelectorAll(s)).filter((e) => (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement) && b(e)), a = i.filter((e) => x(e));
|
|
104
|
+
t.allowOvertype && i.forEach((e) => {
|
|
105
|
+
e.setAttribute(u, "true");
|
|
106
|
+
}), w(e.form);
|
|
107
|
+
let o = a.map((e) => {
|
|
108
|
+
let t = () => {
|
|
109
|
+
A(e);
|
|
110
|
+
};
|
|
111
|
+
return e.addEventListener("input", t), e.addEventListener("change", t), A(e), () => {
|
|
112
|
+
e.removeEventListener("input", t), e.removeEventListener("change", t);
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
return await e.emit("formie:module:text-limit:init", { count: i.length }), { destroy: () => {
|
|
116
|
+
o.forEach((e) => {
|
|
117
|
+
e();
|
|
118
|
+
}), t.allowOvertype && i.forEach((e) => {
|
|
119
|
+
e.removeAttribute(u);
|
|
120
|
+
}), T(e.form), e.emit("formie:module:text-limit:destroy", {});
|
|
121
|
+
} };
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
export { j as textLimitModule };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/js/theme/theme-classes.ts
|
|
2
|
+
var e = /* @__PURE__ */ new WeakMap(), t = "[data-formie-form], [data-formie], form";
|
|
3
|
+
function n(e) {
|
|
4
|
+
return e ? (Array.isArray(e) ? e : [e]).flatMap((e) => String(e).split(/\s+/)).map((e) => e.trim()).filter(Boolean) : [];
|
|
5
|
+
}
|
|
6
|
+
function r(e) {
|
|
7
|
+
return Array.from(new Set(e));
|
|
8
|
+
}
|
|
9
|
+
function i(n) {
|
|
10
|
+
if (!n) return {};
|
|
11
|
+
let r = e.get(n);
|
|
12
|
+
if (r) return r;
|
|
13
|
+
let i = n.closest(t);
|
|
14
|
+
return i && e.get(i) || {};
|
|
15
|
+
}
|
|
16
|
+
function a(e) {
|
|
17
|
+
let t = {};
|
|
18
|
+
return Object.entries(e || {}).forEach(([e, i]) => {
|
|
19
|
+
let a = r(n(i));
|
|
20
|
+
a.length && (t[e] = a);
|
|
21
|
+
}), t;
|
|
22
|
+
}
|
|
23
|
+
function o(t, n, r) {
|
|
24
|
+
let i = a(n), o = r || (t instanceof HTMLFormElement ? t : t.querySelector("form"));
|
|
25
|
+
return e.set(t, i), o && e.set(o, i), i;
|
|
26
|
+
}
|
|
27
|
+
function s(e, t) {
|
|
28
|
+
return i(e)[t] || [];
|
|
29
|
+
}
|
|
30
|
+
function c(e, t, ...n) {
|
|
31
|
+
let i = r(n.flatMap((e) => s(t, e)));
|
|
32
|
+
i.length && e.classList.add(...i);
|
|
33
|
+
}
|
|
34
|
+
function l(e, t, ...n) {
|
|
35
|
+
let i = r(n.flatMap((e) => s(t, e)));
|
|
36
|
+
i.length && e.classList.remove(...i);
|
|
37
|
+
}
|
|
38
|
+
function u(e, t, n, r) {
|
|
39
|
+
s(t, n).forEach((t) => {
|
|
40
|
+
e.classList.toggle(t, r);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { u as i, o as n, l as r, c as t };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { a as e, i as t, o as n, r, t as i } from "./api-DMK8NSUI.js";
|
|
2
|
+
import { r as a } from "./scripts-6CYSUGKQ.js";
|
|
3
|
+
//#region src/js/modules/captchas/turnstile.ts
|
|
4
|
+
function o(e) {
|
|
5
|
+
let r = e.appearance || "always";
|
|
6
|
+
return (e.execution || (r === "execute" ? "execute" : "render")) === "execute" ? t : n;
|
|
7
|
+
}
|
|
8
|
+
async function s(t) {
|
|
9
|
+
let { async: n, defer: i } = r(t.loadingMethod);
|
|
10
|
+
return a("turnstile", {
|
|
11
|
+
id: "FORMIE_TURNSTILE_SCRIPT",
|
|
12
|
+
src: "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",
|
|
13
|
+
async: n,
|
|
14
|
+
defer: i,
|
|
15
|
+
timeoutMs: e
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
var c = i({
|
|
19
|
+
id: "turnstile",
|
|
20
|
+
defaultPlaceholderSelector: "[data-turnstile-placeholder]",
|
|
21
|
+
defaultTokenFieldNames: ["cf-turnstile-response"],
|
|
22
|
+
load: ({ options: e }) => s(e.provider),
|
|
23
|
+
mount: ({ api: e, container: t, provider: n, services: r }) => {
|
|
24
|
+
let i = n.appearance || "always", a = n.execution || (i === "execute" ? "execute" : "render");
|
|
25
|
+
return e.render(t, {
|
|
26
|
+
sitekey: n.siteKey || "",
|
|
27
|
+
theme: n.theme || "auto",
|
|
28
|
+
size: n.size || "normal",
|
|
29
|
+
appearance: i,
|
|
30
|
+
execution: a,
|
|
31
|
+
callback: (e) => {
|
|
32
|
+
typeof e == "string" && e.trim() !== "" && r.tokens.write(e.trim()), r.errors.clear();
|
|
33
|
+
},
|
|
34
|
+
"expired-callback": () => {
|
|
35
|
+
r.tokens.clear(), r.errors.clear();
|
|
36
|
+
},
|
|
37
|
+
"timeout-callback": () => {
|
|
38
|
+
r.tokens.clear(), r.errors.clear();
|
|
39
|
+
},
|
|
40
|
+
"error-callback": () => {
|
|
41
|
+
r.tokens.clear();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
screen: ({ api: e, widget: t, placeholder: n, services: r, provider: i, stageCtx: a }) => {
|
|
46
|
+
if (!r.tokens.has()) return e.execute(t), r.tokens.wait(o(i)).then((e) => {
|
|
47
|
+
if (!e) {
|
|
48
|
+
let e = r.errors.getDefaultMessage();
|
|
49
|
+
r.errors.show(e, n), a.abort(e);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
unmount: ({ api: e, widget: t, services: n }) => {
|
|
54
|
+
e.reset(t), n.tokens.clear();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
//#endregion
|
|
58
|
+
export { c as turnstileModule };
|