@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.
Files changed (197) hide show
  1. package/CHANGELOG.md +76 -22
  2. package/dist/chunks/address-country-Rx6GQTND.js +68 -0
  3. package/dist/chunks/address-finder-yXU5yMjG.js +30 -0
  4. package/dist/chunks/address-state-BQ0xGV9n.js +344 -0
  5. package/dist/chunks/api-CmwLRq_n.js +780 -0
  6. package/dist/chunks/api-DMK8NSUI.js +407 -0
  7. package/dist/chunks/api-sPqGbOww.js +125 -0
  8. package/dist/chunks/async-nPFRNQ06.js +25 -0
  9. package/dist/chunks/bpoint-DSjqRv63.js +24 -0
  10. package/dist/chunks/calculations-CeDgB9jt.js +299 -0
  11. package/dist/chunks/captcha-eu-CWJb64_j.js +31 -0
  12. package/dist/chunks/checkbox-radio-DQ0H67Tj.js +125 -0
  13. package/dist/chunks/chunk-3b4jIN3o.js +13 -0
  14. package/dist/chunks/combobox-D-2b42wn.js +1954 -0
  15. package/dist/chunks/conditions-DjZOtHfS.js +412 -0
  16. package/dist/chunks/constants-DVcJAvc5.js +38 -0
  17. package/dist/chunks/country-from-ip-BwxKaBuJ.js +26 -0
  18. package/dist/chunks/custom-google-maps-BsaSirEZ.js +194 -0
  19. package/dist/chunks/custom-link-CJ1-FjEM.js +46 -0
  20. package/dist/chunks/custom-maps-DYW_pBid.js +161 -0
  21. package/dist/chunks/date-picker-5CA_-zGb.js +5311 -0
  22. package/dist/chunks/debug-BV0DvdHx.js +41 -0
  23. package/dist/chunks/dist-BQ4a9hmy.js +2659 -0
  24. package/dist/chunks/event-names-BCI2FLD8.js +51 -0
  25. package/dist/chunks/eway-D3ctTbEk.js +70 -0
  26. package/dist/chunks/field-references.keys-58ZSTrCW.js +21 -0
  27. package/dist/chunks/field-references.resolver-CHwn0G0L.js +145 -0
  28. package/dist/chunks/file-upload-D49m8-DR.js +287 -0
  29. package/dist/chunks/friendly-captcha-v1-ByXzENYZ.js +31 -0
  30. package/dist/chunks/friendly-captcha-v2-BPdlmhQu.js +36 -0
  31. package/dist/chunks/friendly-challenge-8uPatWqk.js +832 -0
  32. package/dist/chunks/go-cardless-BwASSYSK.js +23 -0
  33. package/dist/chunks/google-address-OhKilPWE.js +161 -0
  34. package/dist/chunks/hcaptcha-CdCd9oEi.js +54 -0
  35. package/dist/chunks/hidden-D7_Ch-QN.js +26 -0
  36. package/dist/chunks/http-D-JExro7.js +27 -0
  37. package/dist/chunks/i18n-BY1ds1BL.js +121 -0
  38. package/dist/chunks/leaflet-src-j-lHNmhR.js +4585 -0
  39. package/dist/chunks/loqate-Cp2zvwpE.js +76 -0
  40. package/dist/chunks/mollie-COG-ko2D.js +23 -0
  41. package/dist/chunks/moneris-CMH8PlRc.js +117 -0
  42. package/dist/chunks/opayo-D2jsR5vh.js +113 -0
  43. package/dist/chunks/paddle-DxF88RfC.js +55 -0
  44. package/dist/chunks/paypal-b5pnwrA2.js +95 -0
  45. package/dist/chunks/payway-BJYu9DIR.js +55 -0
  46. package/dist/chunks/phone-country-D3ayr60L.js +2645 -0
  47. package/dist/chunks/place-kit-BGHklIZ-.js +48 -0
  48. package/dist/chunks/placekit-autocomplete.esm-DWVabQlq.js +1236 -0
  49. package/dist/chunks/recaptcha-enterprise-BSwi8IVX.js +65 -0
  50. package/dist/chunks/recaptcha-shared-B4zAescW.js +15 -0
  51. package/dist/chunks/recaptcha-v2-checkbox-CnDQmsKa.js +40 -0
  52. package/dist/chunks/recaptcha-v2-invisible-Cz5uIlp-.js +53 -0
  53. package/dist/chunks/recaptcha-v3-BtbbP111.js +27 -0
  54. package/dist/chunks/repeater-B5leVxZU.js +102 -0
  55. package/dist/chunks/rich-text-D0sb8bmX.js +349 -0
  56. package/dist/chunks/scripts-6CYSUGKQ.js +24 -0
  57. package/dist/chunks/sdk-BhHAYgga.js +1397 -0
  58. package/dist/chunks/shared-Bx9s0i0P.js +100 -0
  59. package/dist/chunks/signature-xz4QO7CR.js +536 -0
  60. package/dist/chunks/snaptcha-vz1RnZ15.js +8 -0
  61. package/dist/chunks/square-BP8RWAKB.js +40 -0
  62. package/dist/chunks/stripe-MihN63uC.js +184 -0
  63. package/dist/chunks/styles-BfoIZwJp.js +19 -0
  64. package/dist/chunks/summary-D3AjxpYN.js +114 -0
  65. package/dist/chunks/table-C-lkQN6I.js +78 -0
  66. package/dist/chunks/text-limit-DbgEFHLO.js +125 -0
  67. package/dist/chunks/theme-classes-Tv7q7ToE.js +44 -0
  68. package/dist/chunks/turnstile-D_Pi1CKM.js +58 -0
  69. package/dist/chunks/upload-manager-BpqWSHmU.js +2558 -0
  70. package/dist/chunks/utils-Vqp8i_RM.js +49401 -0
  71. package/dist/css/formie-theme.css +2 -0
  72. package/dist/css/theme/_buttons.css +16 -0
  73. package/dist/css/theme/_tokens.css +2 -0
  74. package/dist/css/theme/fields/_address-state.css +94 -0
  75. package/dist/css/theme/fields/_combobox.css +246 -0
  76. package/dist/css/theme/fields/_select.css +13 -0
  77. package/dist/css/theme/fields/_signature.css +19 -0
  78. package/dist/css/theme/fields/_upload-manager.css +279 -0
  79. package/dist/index.js +2448 -39
  80. package/dist/js/core/create-formie-client.d.ts.map +1 -1
  81. package/dist/js/core/submit-result-ui.d.ts.map +1 -1
  82. package/dist/js/core/validation-focus.d.ts +4 -0
  83. package/dist/js/core/validation-focus.d.ts.map +1 -0
  84. package/dist/js/modules/address/api.d.ts +1 -0
  85. package/dist/js/modules/address/api.d.ts.map +1 -1
  86. package/dist/js/modules/address/constants.d.ts +22 -1
  87. package/dist/js/modules/address/constants.d.ts.map +1 -1
  88. package/dist/js/modules/address/host.d.ts +2 -2
  89. package/dist/js/modules/address/host.d.ts.map +1 -1
  90. package/dist/js/modules/address/loqate.d.ts.map +1 -1
  91. package/dist/js/modules/fields/address-country.d.ts +3 -0
  92. package/dist/js/modules/fields/address-country.d.ts.map +1 -0
  93. package/dist/js/modules/fields/address-state.d.ts +3 -0
  94. package/dist/js/modules/fields/address-state.d.ts.map +1 -0
  95. package/dist/js/modules/fields/calculations.d.ts.map +1 -1
  96. package/dist/js/modules/fields/combobox.d.ts +17 -0
  97. package/dist/js/modules/fields/combobox.d.ts.map +1 -0
  98. package/dist/js/modules/fields/custom-google-maps.d.ts +64 -0
  99. package/dist/js/modules/fields/custom-google-maps.d.ts.map +1 -0
  100. package/dist/js/modules/fields/custom-link.d.ts +3 -0
  101. package/dist/js/modules/fields/custom-link.d.ts.map +1 -0
  102. package/dist/js/modules/fields/custom-maps.d.ts +3 -0
  103. package/dist/js/modules/fields/custom-maps.d.ts.map +1 -0
  104. package/dist/js/modules/fields/date-picker.d.ts.map +1 -1
  105. package/dist/js/modules/fields/index.d.ts.map +1 -1
  106. package/dist/js/modules/fields/phone-country.d.ts.map +1 -1
  107. package/dist/js/modules/fields/signature.d.ts.map +1 -1
  108. package/dist/js/modules/fields/upload-manager.d.ts +3 -0
  109. package/dist/js/modules/fields/upload-manager.d.ts.map +1 -0
  110. package/dist/js/submit/pipeline.d.ts.map +1 -1
  111. package/dist/js/utils/country-from-ip.d.ts +7 -0
  112. package/dist/js/utils/country-from-ip.d.ts.map +1 -0
  113. package/dist/js/utils/field-references.d.ts +1 -0
  114. package/dist/js/utils/field-references.d.ts.map +1 -1
  115. package/dist/js/utils/field-references.row-scope.d.ts +11 -0
  116. package/dist/js/utils/field-references.row-scope.d.ts.map +1 -0
  117. package/package.json +8 -3
  118. package/src/css/formie-theme.css +2 -0
  119. package/src/css/theme/_buttons.css +16 -0
  120. package/src/css/theme/_tokens.css +2 -0
  121. package/src/css/theme/fields/_address-state.css +94 -0
  122. package/src/css/theme/fields/_combobox.css +246 -0
  123. package/src/css/theme/fields/_select.css +13 -0
  124. package/src/css/theme/fields/_signature.css +19 -0
  125. package/src/css/theme/fields/_upload-manager.css +279 -0
  126. package/src/js/core/create-formie-client.ts +27 -0
  127. package/src/js/core/submit-result-ui.ts +4 -4
  128. package/src/js/core/validation-focus.ts +117 -0
  129. package/src/js/modules/address/api.ts +7 -0
  130. package/src/js/modules/address/constants.ts +82 -2
  131. package/src/js/modules/address/host.ts +16 -6
  132. package/src/js/modules/address/loqate.ts +3 -17
  133. package/src/js/modules/fields/address-country.ts +156 -0
  134. package/src/js/modules/fields/address-state.ts +946 -0
  135. package/src/js/modules/fields/calculations.ts +32 -0
  136. package/src/js/modules/fields/combobox.ts +188 -0
  137. package/src/js/modules/fields/custom-google-maps.ts +416 -0
  138. package/src/js/modules/fields/custom-link.ts +95 -0
  139. package/src/js/modules/fields/custom-maps.ts +339 -0
  140. package/src/js/modules/fields/date-picker.ts +96 -3
  141. package/src/js/modules/fields/index.ts +7 -0
  142. package/src/js/modules/fields/phone-country.ts +6 -0
  143. package/src/js/modules/fields/signature.ts +199 -15
  144. package/src/js/modules/fields/upload-manager.ts +1277 -0
  145. package/src/js/submit/pipeline.ts +11 -1
  146. package/src/js/utils/country-from-ip.ts +54 -0
  147. package/src/js/utils/field-references.row-scope.ts +303 -0
  148. package/src/js/utils/field-references.ts +1 -0
  149. package/src/vendor.d.ts +1 -1
  150. package/dist/chunks/address-finder-BU4roxT6.js +0 -37
  151. package/dist/chunks/bpoint-uNg5j6rt.js +0 -26
  152. package/dist/chunks/calculations-C9t6Zop9.js +0 -147
  153. package/dist/chunks/captcha-eu-BAPzHNts.js +0 -34
  154. package/dist/chunks/checkbox-radio-CHeLNVIK.js +0 -141
  155. package/dist/chunks/conditions-DKxVCsjD.js +0 -459
  156. package/dist/chunks/date-picker-B3iQ797Z.js +0 -4994
  157. package/dist/chunks/eway-DCielIML.js +0 -74
  158. package/dist/chunks/file-upload-DP2TOUYV.js +0 -316
  159. package/dist/chunks/friendly-captcha-v1-DdlcGiFY.js +0 -33
  160. package/dist/chunks/friendly-captcha-v2-76w-YnFm.js +0 -38
  161. package/dist/chunks/go-cardless-rwCkzbNK.js +0 -24
  162. package/dist/chunks/google-address-BD8IZ86V.js +0 -181
  163. package/dist/chunks/hcaptcha-BNNTL6uf.js +0 -56
  164. package/dist/chunks/hidden-CW6Rcf1N.js +0 -31
  165. package/dist/chunks/index-BEsfee-D.js +0 -1839
  166. package/dist/chunks/index-BP7Unm5Y.js +0 -863
  167. package/dist/chunks/index-D6npYxvr.js +0 -4423
  168. package/dist/chunks/loqate-B-ZNS65B.js +0 -55
  169. package/dist/chunks/mollie-BDAZ-1X4.js +0 -24
  170. package/dist/chunks/moneris-B1b0uEtY.js +0 -101
  171. package/dist/chunks/opayo-CC5hraHo.js +0 -122
  172. package/dist/chunks/paddle-B4GmrDsq.js +0 -60
  173. package/dist/chunks/paypal-BFS6XsIS.js +0 -100
  174. package/dist/chunks/payway-DekoJead.js +0 -56
  175. package/dist/chunks/phone-country-Cm5YUeXI.js +0 -3765
  176. package/dist/chunks/place-kit-DizZWV_e.js +0 -42
  177. package/dist/chunks/placekit-autocomplete.esm-LAwfbPZl.js +0 -1299
  178. package/dist/chunks/recaptcha-enterprise-BbOvO7JZ.js +0 -71
  179. package/dist/chunks/recaptcha-shared-Dwg1eVFS.js +0 -15
  180. package/dist/chunks/recaptcha-v2-checkbox-SY3ti5iQ.js +0 -41
  181. package/dist/chunks/recaptcha-v2-invisible-DSmQnn6c.js +0 -59
  182. package/dist/chunks/recaptcha-v3-DNh7YCnR.js +0 -28
  183. package/dist/chunks/repeater-DM0vuFNQ.js +0 -124
  184. package/dist/chunks/rich-text-C8aGYp70.js +0 -304
  185. package/dist/chunks/scripts-CKTFtxPO.js +0 -36
  186. package/dist/chunks/sdk-3SicTWby.js +0 -1559
  187. package/dist/chunks/shared--BU5CFoL.js +0 -80
  188. package/dist/chunks/signature-pFhZfH7d.js +0 -550
  189. package/dist/chunks/snaptcha-VuOUOaLj.js +0 -8
  190. package/dist/chunks/square-BR9pvToy.js +0 -46
  191. package/dist/chunks/stripe-OHUwoV9g.js +0 -202
  192. package/dist/chunks/styles-C3aqgtek.js +0 -21
  193. package/dist/chunks/summary-Da7Ktg3N.js +0 -126
  194. package/dist/chunks/table-C0PmR9bI.js +0 -95
  195. package/dist/chunks/text-limit-mLEwZDIa.js +0 -144
  196. package/dist/chunks/turnstile-9tM7q_LK.js +0 -59
  197. package/dist/chunks/utils-BntI3W4S.js +0 -6149
@@ -1,141 +0,0 @@
1
- import { r as p, d as E, a as M, e as v } from "./shared--BU5CFoL.js";
2
- import { h as L } from "./index-D6npYxvr.js";
3
- const l = "[data-formie-checkboxes-field-layout], [data-formie-radio-field-layout]", u = "minmaxOptions", h = "data-formie-checkbox-radio-max-disabled", A = "checkbox-radio", x = "checkbox-radio", d = L("fields", "checkbox-radio");
4
- function m(t) {
5
- return t.hasAttribute("data-checkbox-toggle") || t.hasAttribute("data-formie-checkbox-toggle");
6
- }
7
- function b(t) {
8
- const r = t(u);
9
- if (!r || r === !0 || typeof r != "object")
10
- return {
11
- min: null,
12
- max: null
13
- };
14
- const o = r;
15
- return {
16
- min: typeof o.min == "number" ? o.min : null,
17
- max: typeof o.max == "number" ? o.max : null
18
- };
19
- }
20
- function k(t) {
21
- return Array.from(t.querySelectorAll('input[type="checkbox"]')).filter((r) => r instanceof HTMLInputElement && !m(r)).filter((r) => r.checked).length;
22
- }
23
- function T(t) {
24
- p(t, x, (r) => {
25
- r.addValidator(
26
- u,
27
- ({ field: o, getRule: e }) => {
28
- if (!o || !e(u))
29
- return !0;
30
- const a = k(o), { min: n, max: c } = b(e);
31
- return !(n !== null && a < n || c !== null && a > c);
32
- },
33
- ({ field: o, label: e, t: a, getRule: n }) => {
34
- if (!o)
35
- return a("{label} has an invalid value.", { label: e });
36
- const c = k(o), { min: i, max: f } = b(n);
37
- return i !== null && c < i ? o.getAttribute("data-formie-validation-min-options-message") ?? a("{label} should contain at least {min, number} {min, plural, one{option} other{options}}.", { label: e, min: i }) : f !== null && c > f ? o.getAttribute("data-formie-validation-max-options-message") ?? a("{label} should contain at most {max, number} {max, plural, one{option} other{options}}.", { label: e, max: f }) : a("{label} has an invalid value.", { label: e });
38
- }
39
- );
40
- });
41
- }
42
- function q(t) {
43
- M(t, x, [u]);
44
- }
45
- function s(t) {
46
- t.checked ? t.setAttribute("checked", "") : t.removeAttribute("checked");
47
- }
48
- function y(t) {
49
- const r = Array.from(t.querySelectorAll('input[type="checkbox"][required][data-formie-checkbox-input]')).filter((e) => e instanceof HTMLInputElement);
50
- if (!r.length)
51
- return;
52
- const o = r.some((e) => e.checked);
53
- r.forEach((e) => {
54
- if (o) {
55
- e.removeAttribute("required"), e.setAttribute("aria-required", "false");
56
- return;
57
- }
58
- e.setAttribute("required", "true"), e.setAttribute("aria-required", "true");
59
- });
60
- }
61
- function g(t) {
62
- const r = parseInt(t.closest("[data-formie-field-handle]")?.getAttribute("data-formie-max-options") || "", 10);
63
- if (!(r > 0))
64
- return;
65
- const o = Array.from(t.querySelectorAll('input[type="checkbox"]')).filter((n) => n instanceof HTMLInputElement && !m(n)), a = o.filter((n) => n.checked).length >= r;
66
- o.forEach((n) => {
67
- const c = a && !n.checked, i = n.hasAttribute(h);
68
- if (c) {
69
- n.disabled || (n.disabled = !0, n.setAttribute(h, "true"));
70
- return;
71
- }
72
- i && (n.disabled = !1, n.removeAttribute(h));
73
- });
74
- }
75
- function I(t, r) {
76
- Array.from(t.querySelectorAll('input[type="checkbox"]')).filter((e) => e instanceof HTMLInputElement && e !== r && !m(e)).forEach((e) => {
77
- e.disabled && !e.checked || (e.checked = r.checked, s(e), e.dispatchEvent(new Event("change", { bubbles: !0 })), e.dispatchEvent(new Event("input", { bubbles: !0 })));
78
- });
79
- }
80
- function C(t, r) {
81
- if (!t.checked || !t.name) {
82
- s(t);
83
- return;
84
- }
85
- Array.from(r.querySelectorAll(`input[type="radio"][name="${v(t.name)}"]`)).filter((e) => e instanceof HTMLInputElement).forEach((e) => {
86
- s(e);
87
- });
88
- }
89
- function S(t) {
90
- const r = Array.from(t.querySelectorAll('input[type="checkbox"], input[type="radio"]')).filter((e) => e instanceof HTMLInputElement);
91
- if (!r.length)
92
- return d.log("No checkbox/radio inputs found for field."), () => {
93
- };
94
- const o = r.map((e) => {
95
- const a = e.type === "radio" ? "change" : "click", n = () => {
96
- s(e), e.type === "checkbox" && m(e) && I(t, e), e.type === "radio" && C(e, t), y(t), g(t), d.log("Input interaction processed.", {
97
- inputName: e.name,
98
- inputType: e.type,
99
- checked: e.checked
100
- });
101
- };
102
- return e.addEventListener(a, n), s(e), () => {
103
- e.removeEventListener(a, n);
104
- };
105
- });
106
- return y(t), g(t), E(t, A, "init", {
107
- checkboxRadio: t
108
- }), () => {
109
- o.forEach((e) => {
110
- e();
111
- });
112
- };
113
- }
114
- const O = {
115
- id: A,
116
- kind: "field",
117
- match: (t) => t.target instanceof HTMLElement && (t.target.matches(l) || !!t.target.querySelector(l)),
118
- setup: async (t) => {
119
- if (!(t.target instanceof HTMLElement))
120
- return;
121
- const r = t.target.matches(l) ? [t.target] : Array.from(t.target.querySelectorAll(l)).filter((e) => e instanceof HTMLElement);
122
- T(t.form), d.log("Module setup.", {
123
- fieldCount: r.length
124
- });
125
- const o = r.map((e) => S(e));
126
- return await t.emit("formie:module:checkbox-radio:init", {
127
- count: r.length
128
- }), {
129
- destroy: () => {
130
- o.forEach((e) => {
131
- e();
132
- }), q(t.form), d.log("Module destroy.", {
133
- fieldCount: r.length
134
- }), t.emit("formie:module:checkbox-radio:destroy", {});
135
- }
136
- };
137
- }
138
- };
139
- export {
140
- O as checkboxRadioModule
141
- };
@@ -1,459 +0,0 @@
1
- import { S as te, A as re } from "./index-BEsfee-D.js";
2
- import { e as V } from "./shared--BU5CFoL.js";
3
- import { j as F, h as ne } from "./index-D6npYxvr.js";
4
- const D = "[data-formie-conditions]";
5
- function ie(e) {
6
- if (!e || typeof e != "object")
7
- return null;
8
- const t = e, r = t.transformerParams;
9
- return {
10
- raw: typeof t.raw == "string" ? t.raw : "",
11
- target: typeof t.target == "string" ? t.target : "",
12
- handle: typeof t.handle == "string" ? t.handle : "",
13
- selector: typeof t.selector == "string" ? t.selector : "",
14
- defaultValue: typeof t.defaultValue == "string" ? t.defaultValue : "",
15
- transformerId: typeof t.transformerId == "string" ? t.transformerId : "",
16
- transformerParams: r && typeof r == "object" ? Object.fromEntries(Object.entries(r).map(([n, i]) => [n, String(i ?? "")])) : {},
17
- isValid: t.isValid !== !1
18
- };
19
- }
20
- function $(e) {
21
- const t = Array.from(e.querySelectorAll(D));
22
- return e.matches(D) ? [e, ...t] : t;
23
- }
24
- function se(e) {
25
- const t = e.getAttribute("data-formie-conditions");
26
- if (!t)
27
- return null;
28
- try {
29
- const r = JSON.parse(t), n = Array.isArray(r.conditions) ? r.conditions.filter((i) => {
30
- if (!i || typeof i != "object")
31
- return !1;
32
- const s = i;
33
- return typeof s.field == "string" && typeof s.condition == "string";
34
- }).map((i) => {
35
- const s = i;
36
- return {
37
- field: i.field,
38
- source: ie(s.source),
39
- condition: i.condition,
40
- value: i.value
41
- };
42
- }) : [];
43
- return {
44
- showRule: r.showRule === "hide" ? "hide" : "show",
45
- conditionRule: r.conditionRule === "any" ? "any" : "all",
46
- clearOnHide: r.clearOnHide !== !1,
47
- isNested: !!r.isNested,
48
- conditions: n
49
- };
50
- } catch (r) {
51
- return console.error("[formie] Invalid condition JSON.", r), null;
52
- }
53
- }
54
- const M = "data-formie-conditions-disabled", v = "data-formie-preserve-disabled", T = "data-formie-conditionally-hidden", C = "data-formie-page-hidden", O = "formie-conditionally-hidden", L = "fui-cp-muted-conditional-field", x = "fui-cp-muted-conditional-field--expanded", I = "data-formie-cp-muted", w = "formie-page-hidden", E = "data-formie-row-hidden", R = "formie-row-hidden", H = "data-formie-field-count", U = "[data-formie-row], [data-formie-subfield-row], [data-formie-nested-field-row]", oe = ":scope > [data-formie-field]";
55
- function ae(e) {
56
- e.querySelectorAll("input, select, textarea").forEach((t) => {
57
- !(t instanceof HTMLInputElement) && !(t instanceof HTMLSelectElement) && !(t instanceof HTMLTextAreaElement) || (t instanceof HTMLInputElement && (t.type === "checkbox" || t.type === "radio" ? t.checked = !1 : t.type !== "hidden" && (t.value = "")), t instanceof HTMLSelectElement && (t.multiple ? Array.from(t.options).forEach((r) => {
58
- r.selected = !1;
59
- }) : t.selectedIndex = 0), t instanceof HTMLTextAreaElement && (t.value = ""));
60
- });
61
- }
62
- function ue(e, t) {
63
- const r = e.hasAttribute("data-formie-page"), n = r ? C : T, i = r ? w : O, s = e.hasAttribute(n);
64
- return t ? (s || e.setAttribute(n, "true"), e.classList.contains(i) || e.classList.add(i)) : (s && e.removeAttribute(n), e.classList.contains(i) && e.classList.remove(i)), s !== t;
65
- }
66
- function le(e, t) {
67
- e.querySelectorAll("input, textarea, select").forEach((r) => {
68
- if (t) {
69
- r.hasAttribute(M) || (r.hasAttribute("disabled") && r.setAttribute(v, "true"), r.setAttribute(M, "true")), r.setAttribute("disabled", "true");
70
- return;
71
- }
72
- r.hasAttribute(M) && (r.hasAttribute(v) ? (r.setAttribute("disabled", "true"), r.removeAttribute(v)) : r.removeAttribute("disabled"), r.removeAttribute(M));
73
- });
74
- }
75
- function ce(e) {
76
- return !e.hasAttribute(T) && !e.hasAttribute(C) && !e.hasAttribute(E) && !e.hasAttribute("hidden");
77
- }
78
- function fe(e) {
79
- const r = Array.from(e.querySelectorAll(oe)).filter((n) => ce(n)).length;
80
- if (r > 0) {
81
- const n = String(r);
82
- e.getAttribute(H) !== n && e.setAttribute(H, n), e.hasAttribute(E) && e.removeAttribute(E), e.classList.contains(R) && e.classList.remove(R);
83
- return;
84
- }
85
- e.hasAttribute(H) && e.removeAttribute(H), e.hasAttribute(E) || e.setAttribute(E, "true"), e.classList.contains(R) || e.classList.add(R);
86
- }
87
- function K(e) {
88
- e.removeAttribute(I), e.classList.remove(L), e.classList.remove(x);
89
- }
90
- function B(e) {
91
- e.removeAttribute(T), e.removeAttribute(C), e.classList.remove(O), e.classList.remove(w);
92
- }
93
- function Q(e) {
94
- let t = e.closest(U);
95
- for (; t; )
96
- fe(t), t = t.parentElement?.closest(U) || null;
97
- }
98
- function de(e, t, r, n = {}) {
99
- if (n.displayMode === "muted")
100
- return me(e, t);
101
- let i = !1;
102
- return (e.hasAttribute(I) || e.classList.contains(L) || e.classList.contains(x)) && (K(e), i = !0), i = ue(e, t) || i, le(e, t), Q(e), t && r && i && ae(e), i;
103
- }
104
- function me(e, t) {
105
- let r = !1;
106
- return t ? ((e.hasAttribute(T) || e.hasAttribute(C) || e.classList.contains(O) || e.classList.contains(w)) && (B(e), r = !0), e.hasAttribute(I) || (e.setAttribute(I, "true"), r = !0), e.classList.contains(L) || (e.classList.add(L), r = !0)) : ((e.hasAttribute(I) || e.classList.contains(L) || e.classList.contains(x)) && (K(e), r = !0), (e.hasAttribute(T) || e.hasAttribute(C) || e.classList.contains(O) || e.classList.contains(w)) && (B(e), r = !0)), Q(e), r;
107
- }
108
- const X = "input, select, textarea", he = "[data-formie-repeater-item], [data-formie-table-row]";
109
- function A(e) {
110
- return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
111
- }
112
- function pe(e) {
113
- const t = e.querySelector(X);
114
- if (!t)
115
- return null;
116
- const r = t.getAttribute("name") || "", n = Array.from(r.matchAll(/\[(\d+)\]/g));
117
- return n.length && n[n.length - 1]?.[1] || null;
118
- }
119
- function Y(e) {
120
- return e.closest(he);
121
- }
122
- function ge(e) {
123
- return Array.from(e.querySelectorAll(X)).filter((t) => A(t));
124
- }
125
- function Ae(e) {
126
- const t = e.getAttribute("name") || "";
127
- return Array.from(t.matchAll(/\[([^\]]+)\]/g)).map((r) => r[1] || "").filter(Boolean);
128
- }
129
- function be(e, t) {
130
- if (!t)
131
- return !0;
132
- const r = t.split(/[.:]/).filter(Boolean);
133
- if (!r.length)
134
- return !0;
135
- const n = Ae(e);
136
- return n.length < r.length ? !1 : r.every((i, s) => n[n.length - r.length + s] === i);
137
- }
138
- function ye(e, t) {
139
- if (!t)
140
- return e;
141
- const r = e.filter((n) => be(n, t));
142
- return r.length ? r : e;
143
- }
144
- function j(e, t) {
145
- const r = Y(e);
146
- if (!r)
147
- return t;
148
- const n = t.filter((i) => Y(i) === r);
149
- return n.length ? n : t;
150
- }
151
- function Z(e) {
152
- return e.source?.target === "field" && e.source.handle ? e.source : null;
153
- }
154
- function W(e, t, r) {
155
- const n = Z(r);
156
- if (!n || n.target !== "field" || !n.handle)
157
- return [];
158
- const i = V(n.handle), s = Array.from(e.querySelectorAll(`[data-formie-field-handle="${i}"]`));
159
- if (s.length)
160
- return j(t, s).flatMap((f) => ye(ge(f), n.selector));
161
- const l = F(n.handle), c = V(l), h = Array.from(e.querySelectorAll(`[name="${c}"]`)).filter((f) => A(f)), d = Array.from(e.querySelectorAll(`[name="${c}[]"]`)).filter((f) => A(f));
162
- if (h.length || d.length)
163
- return j(t, [...h, ...d]);
164
- if (!n.handle.includes("__ROW__"))
165
- return [];
166
- const _ = pe(t);
167
- if (_) {
168
- const f = F(n.handle.replace(/__ROW__/g, _)), b = V(f), N = Array.from(e.querySelectorAll(`[name="${b}"]`)).filter((o) => A(o)), y = Array.from(e.querySelectorAll(`[name="${b}[]"]`)).filter((o) => A(o));
169
- if (N.length || y.length)
170
- return [...N, ...y];
171
- }
172
- const P = F(n.handle).replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/__ROW__/g, "\\d+"), p = new RegExp(P);
173
- return Array.from(e.querySelectorAll("[name]")).filter((f) => A(f) && p.test(f.getAttribute("name") || ""));
174
- }
175
- function Se(e) {
176
- return e == null ? "" : String(e);
177
- }
178
- function Ee(e) {
179
- if (typeof e == "boolean")
180
- return e;
181
- if (typeof e == "number")
182
- return e !== 0;
183
- const t = Se(e).trim().toLowerCase();
184
- return !(!t || ["0", "false", "no", "off"].includes(t));
185
- }
186
- function Le(e) {
187
- return e.toLowerCase().replace(/\b\w/g, (t) => t.toUpperCase());
188
- }
189
- function Ie(e, t) {
190
- const r = Number.isFinite(Number(t.decimals)) ? Number(t.decimals) : 0, n = t.decimalPoint ?? ".", i = t.thousandsSeparator ?? ",", s = e.toFixed(r), [l, c = ""] = s.split("."), h = l.replace(/\B(?=(\d{3})+(?!\d))/g, i);
191
- return r === 0 ? h : `${h}${n}${c}`;
192
- }
193
- function S(e) {
194
- return String(e).padStart(2, "0");
195
- }
196
- function Te(e, t) {
197
- return [
198
- ["Y", String(e.getFullYear())],
199
- ["m", S(e.getMonth() + 1)],
200
- ["d", S(e.getDate())],
201
- ["j", String(e.getDate())],
202
- ["H", S(e.getHours())],
203
- ["h", S((e.getHours() + 11) % 12 + 1)],
204
- ["i", S(e.getMinutes())],
205
- ["A", e.getHours() >= 12 ? "PM" : "AM"],
206
- ["F", e.toLocaleString(void 0, { month: "long" })]
207
- ].reduce((n, [i, s]) => n.replaceAll(i, s), t);
208
- }
209
- function Ce(e) {
210
- switch (e) {
211
- case "datetimeUs12":
212
- return "m/d/Y h:i A";
213
- case "datetimeEu12":
214
- return "d/m/Y h:i A";
215
- case "datetimeEu24":
216
- return "d/m/Y H:i";
217
- case "datetimeIso24":
218
- return "Y-m-d H:i";
219
- case "dateUs":
220
- return "m/d/Y";
221
- case "dateEu":
222
- return "d/m/Y";
223
- case "isoDate":
224
- return "Y-m-d";
225
- case "dateLong":
226
- return "F j, Y";
227
- case "time12":
228
- return "h:i A";
229
- case "time24":
230
- return "H:i";
231
- default:
232
- return "";
233
- }
234
- }
235
- function _e(e, t) {
236
- const r = t.transformerId, n = t.transformerParams;
237
- switch (r) {
238
- case "round":
239
- case "floor":
240
- case "ceil": {
241
- const i = Number(e);
242
- return Number.isFinite(i) ? String(r === "round" ? Math.round(i) : r === "floor" ? Math.floor(i) : Math.ceil(i)) : e;
243
- }
244
- case "format": {
245
- const i = Number(e);
246
- if (Number.isFinite(i) && e.trim() !== "")
247
- return Ie(i, n);
248
- const s = n.preset || "", l = s === "custom" ? n.pattern || "" : Ce(s);
249
- if (!l)
250
- return e;
251
- const c = new Date(e);
252
- return Number.isNaN(c.getTime()) ? e : Te(c, l);
253
- }
254
- case "lower":
255
- return e.toLowerCase();
256
- case "upper":
257
- return e.toUpperCase();
258
- case "title":
259
- return Le(e);
260
- case "capitalize":
261
- return e && e.charAt(0).toUpperCase() + e.slice(1);
262
- case "replace": {
263
- const i = n.search || "";
264
- return i ? e.split(i).join(n.replace || "") : e;
265
- }
266
- case "truncate": {
267
- const i = Math.max(1, Number.parseInt(n.length || "50", 10) || 50), s = n.suffix || "...";
268
- return e.length <= i ? e : `${e.slice(0, Math.max(0, i - s.length))}${s}`;
269
- }
270
- case "map":
271
- return Ee(e) ? n.trueLabel || "Yes" : n.falseLabel || "No";
272
- default:
273
- return e;
274
- }
275
- }
276
- function Ne(e, t) {
277
- if (!t)
278
- return e;
279
- const r = t.transformerId ? e.map((n) => _e(n, t)) : e;
280
- return (r.length === 0 || r.every((n) => n.trim() === "")) && t.defaultValue ? [t.defaultValue] : r;
281
- }
282
- function Me(e, t) {
283
- return e.name || `__condition_input_${t}`;
284
- }
285
- function G(e) {
286
- const t = e.id ? e.ownerDocument.querySelector(`label[for="${e.id}"]`)?.textContent?.trim() : "";
287
- return t || e.closest("label")?.textContent?.trim() || "";
288
- }
289
- function Re(e, t = "") {
290
- const r = e[0];
291
- if (!r)
292
- return [];
293
- if (r instanceof HTMLInputElement) {
294
- if (r.type === "checkbox") {
295
- const n = e.filter((i) => i instanceof HTMLInputElement && i.checked);
296
- return t === "label" ? n.map((i) => G(i)).filter(Boolean) : n.map((i) => i.value);
297
- }
298
- if (r.type === "radio") {
299
- const n = e.filter((i) => i instanceof HTMLInputElement && i.checked);
300
- return t === "label" ? n.map((i) => G(i)).filter(Boolean) : n.map((i) => i.value);
301
- }
302
- if (r.type === "file")
303
- return Array.from(r.files || []).map((n) => n.name);
304
- }
305
- return r instanceof HTMLSelectElement && r.multiple ? t === "label" ? Array.from(r.selectedOptions).map((n) => n.label || n.text) : Array.from(r.selectedOptions).map((n) => n.value) : r instanceof HTMLSelectElement && t === "label" ? Array.from(r.selectedOptions).map((n) => n.label || n.text) : e.map((n) => n.value);
306
- }
307
- function z(e) {
308
- return ["input", "change"];
309
- }
310
- function He(e, t = null) {
311
- const r = /* @__PURE__ */ new Map();
312
- e.forEach((i, s) => {
313
- const l = Me(i, s), c = r.get(l) || [];
314
- c.push(i), r.set(l, c);
315
- });
316
- const n = Array.from(r.values()).flatMap((i) => Re(i, t?.selector || ""));
317
- return Ne(n, t);
318
- }
319
- function De(e) {
320
- return e.closest("[data-formie-conditionally-hidden]") || e.closest("[data-formie-page-hidden]") || e.closest("[hidden]") || e.closest('[aria-hidden="true"]') ? !1 : !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
321
- }
322
- function Oe(e) {
323
- return e.length ? e.some((t) => De(t)) : null;
324
- }
325
- function we(e, t) {
326
- const r = e.conditions.map((n) => {
327
- const i = t(n), s = Z(n);
328
- return te(n, He(i, s), {
329
- visibility: Oe(i)
330
- });
331
- });
332
- return re(e, r);
333
- }
334
- const q = 4, g = ne("conditions");
335
- function J(e) {
336
- const t = /* @__PURE__ */ new Set();
337
- return e.filter((r) => t.has(r) ? !1 : (t.add(r), !0));
338
- }
339
- const ve = {
340
- id: "conditions",
341
- kind: "field",
342
- match: (e) => e.target instanceof HTMLElement && (e.target.matches(D) || !!e.target.querySelector(D)),
343
- setup: async (e) => {
344
- const t = e.target instanceof HTMLElement ? e.target : e.root;
345
- if (!$(t).length) {
346
- g.log("No condition nodes in scope.");
347
- return;
348
- }
349
- const r = [];
350
- let n = [], i = !1, s = !1;
351
- const l = () => {
352
- r.forEach((o) => {
353
- o();
354
- }), r.length = 0;
355
- }, c = () => $(t).flatMap((o) => {
356
- const a = se(o);
357
- if (!a || !a.conditions.length)
358
- return [];
359
- const u = J(a.conditions.flatMap((m) => W(t, o, m)));
360
- return [{
361
- node: o,
362
- settings: a,
363
- sourceInputs: u
364
- }];
365
- }), h = e.options?.cpDisplayMode === "muted" ? "muted" : "hide";
366
- let d = !1;
367
- const _ = () => {
368
- let o = !1;
369
- return n.forEach((a) => {
370
- const u = we(a.settings, (ee) => W(t, a.node, ee)), m = a.node.hasAttribute("data-formie-page") ? "hide" : h, k = de(
371
- a.node,
372
- u.shouldHide,
373
- a.settings.clearOnHide,
374
- { displayMode: m }
375
- );
376
- o = o || k, g.log("Condition evaluated.", {
377
- shouldHide: u.shouldHide,
378
- finalResult: u.finalResult,
379
- stateChanged: k
380
- }), e.emit("formie:conditions:evaluated", {
381
- node: a.node,
382
- shouldHide: u.shouldHide,
383
- finalResult: u.finalResult,
384
- clearOnHide: a.settings.clearOnHide
385
- });
386
- }), o;
387
- }, P = () => {
388
- if (!d) {
389
- d = !0;
390
- try {
391
- for (let o = 0; o < q && _(); o += 1)
392
- o === q - 1 && g.warn("Reached max evaluation passes.", { maxPasses: q });
393
- } finally {
394
- d = !1;
395
- }
396
- }
397
- }, p = () => {
398
- d || i || (i = !0, requestAnimationFrame(() => {
399
- i = !1, !d && P();
400
- }));
401
- }, f = () => {
402
- if (J(n.flatMap((o) => o.sourceInputs)).forEach((o) => {
403
- const a = () => {
404
- p();
405
- };
406
- z().forEach((u) => {
407
- o.addEventListener(u, a);
408
- }), r.push(() => {
409
- z().forEach((u) => {
410
- o.removeEventListener(u, a);
411
- });
412
- });
413
- }), e.form) {
414
- const o = () => {
415
- window.setTimeout(() => {
416
- p();
417
- }, 0);
418
- };
419
- e.form.addEventListener("reset", o), r.push(() => {
420
- e.form?.removeEventListener("reset", o);
421
- });
422
- }
423
- }, b = () => {
424
- l(), n = c(), f(), g.log("Rebuilt condition graph.", {
425
- entryCount: n.length
426
- }), p();
427
- }, N = () => {
428
- d || s || (s = !0, requestAnimationFrame(() => {
429
- s = !1, !d && b();
430
- }));
431
- }, y = new MutationObserver((o) => {
432
- if (d)
433
- return;
434
- const a = o.some((m) => m.type === "childList" && (m.addedNodes.length > 0 || m.removedNodes.length > 0)), u = o.some((m) => m.type === "attributes");
435
- a ? N() : u && p();
436
- });
437
- return y.observe(t, {
438
- childList: !0,
439
- subtree: !0,
440
- attributes: !0,
441
- attributeFilter: [
442
- "hidden",
443
- "aria-hidden",
444
- "data-formie-conditionally-hidden",
445
- "data-formie-page-hidden",
446
- "data-formie-row-hidden"
447
- ]
448
- }), b(), await e.emit("formie:module:conditions:init", {
449
- count: n.length
450
- }), g.log("Module setup complete.", { entryCount: n.length }), {
451
- destroy: () => {
452
- l(), y.disconnect(), g.log("Module destroy."), e.emit("formie:module:conditions:destroy", {});
453
- }
454
- };
455
- }
456
- };
457
- export {
458
- ve as conditionsModule
459
- };