@verbb/formie-browser 1.0.0 → 1.0.2

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 (120) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/chunks/address-finder-CQW81kY0.js +37 -0
  3. package/dist/chunks/bpoint-D8OjLmsn.js +26 -0
  4. package/dist/chunks/calculations-BqZsENCq.js +147 -0
  5. package/dist/chunks/captcha-eu-DIa6aUWz.js +34 -0
  6. package/dist/chunks/checkbox-radio-BI-UjgMF.js +136 -0
  7. package/dist/chunks/conditions-BVl6jTYo.js +433 -0
  8. package/dist/chunks/date-picker-69TgvErA.js +4994 -0
  9. package/dist/chunks/eway-1GPxH6DU.js +74 -0
  10. package/dist/chunks/file-upload-BDZZftgL.js +281 -0
  11. package/dist/chunks/friendly-captcha-v1-DA2QPKA3.js +33 -0
  12. package/dist/chunks/friendly-captcha-v2-BorOWiz_.js +38 -0
  13. package/dist/chunks/go-cardless-DwBgERcA.js +24 -0
  14. package/dist/chunks/google-address-BcTBncyS.js +162 -0
  15. package/dist/chunks/hcaptcha-BchdVCqq.js +56 -0
  16. package/dist/chunks/hidden-D8RqSPt7.js +31 -0
  17. package/dist/chunks/index-BEsfee-D.js +1839 -0
  18. package/dist/chunks/index-BP7Unm5Y.js +863 -0
  19. package/dist/chunks/index-C1ZOKiAi.js +4229 -0
  20. package/dist/chunks/loqate-nXuTX7In.js +55 -0
  21. package/dist/chunks/mollie-qdCynQCd.js +24 -0
  22. package/dist/chunks/moneris-BNEA-laO.js +101 -0
  23. package/dist/chunks/opayo-BJtXOkuK.js +122 -0
  24. package/dist/chunks/paddle-D72Pa8kr.js +60 -0
  25. package/dist/chunks/paypal-Cqt2bned.js +100 -0
  26. package/dist/chunks/payway-BjCqsc0H.js +56 -0
  27. package/dist/chunks/phone-country-K9pYAlzM.js +3765 -0
  28. package/dist/chunks/place-kit-Dg6f_UoM.js +42 -0
  29. package/dist/chunks/placekit-autocomplete.esm-LAwfbPZl.js +1299 -0
  30. package/dist/chunks/recaptcha-enterprise--VYAeeqz.js +71 -0
  31. package/dist/chunks/recaptcha-shared-PSIEEEe1.js +15 -0
  32. package/dist/chunks/recaptcha-v2-checkbox-atBNe5ml.js +41 -0
  33. package/dist/chunks/recaptcha-v2-invisible-DnBufNPT.js +59 -0
  34. package/dist/chunks/recaptcha-v3-CF6O8rDj.js +28 -0
  35. package/dist/chunks/repeater-CB7Yojvx.js +124 -0
  36. package/dist/chunks/rich-text-nAV_SQZo.js +304 -0
  37. package/dist/chunks/scripts-BkAAux0i.js +36 -0
  38. package/dist/chunks/sdk-3SicTWby.js +1559 -0
  39. package/dist/chunks/shared-DGqeMvcJ.js +80 -0
  40. package/dist/chunks/signature-BT6CsQ6n.js +550 -0
  41. package/dist/chunks/snaptcha-C7qQo02f.js +8 -0
  42. package/dist/chunks/square-C5AH3trb.js +46 -0
  43. package/dist/chunks/stripe-EJK0RyUv.js +202 -0
  44. package/dist/chunks/styles-C3aqgtek.js +21 -0
  45. package/dist/chunks/summary-DC_ipXCU.js +126 -0
  46. package/dist/chunks/table-BEAI99qo.js +95 -0
  47. package/dist/chunks/text-limit-Blgq5G-G.js +135 -0
  48. package/dist/chunks/turnstile-_uCRwnU-.js +59 -0
  49. package/dist/chunks/utils-BntI3W4S.js +6149 -0
  50. package/dist/index.js +39 -3205
  51. package/package.json +5 -5
  52. package/src/js/modules/fields/file-upload.ts +1 -1
  53. package/src/js/modules/fields/repeater.ts +1 -1
  54. package/src/js/modules/fields/rich-text.ts +2 -2
  55. package/src/js/modules/fields/signature.ts +1 -1
  56. package/src/js/modules/fields/summary.ts +1 -1
  57. package/src/js/modules/fields/table.ts +1 -1
  58. package/src/js/modules/fields/text-limit.ts +1 -1
  59. package/src/js/modules/payments/paypal.ts +1 -1
  60. package/src/js/modules/payments/payway.ts +1 -1
  61. package/src/js/modules/payments/stripe.ts +1 -1
  62. package/dist/chunks/address-finder-DfMCiW89.js +0 -47
  63. package/dist/chunks/api-CbqEMQT5.js +0 -181
  64. package/dist/chunks/api-DE7LfK-R.js +0 -960
  65. package/dist/chunks/api-DOfDzYC_.js +0 -538
  66. package/dist/chunks/async-B3DUf1GZ.js +0 -26
  67. package/dist/chunks/bpoint-Ciy3yY9Q.js +0 -34
  68. package/dist/chunks/calculations-CkYAqO_-.js +0 -197
  69. package/dist/chunks/captcha-eu-DnOWhMwr.js +0 -43
  70. package/dist/chunks/checkbox-radio-0x7Tc0br.js +0 -197
  71. package/dist/chunks/chunk-K6L4z4UQ.js +0 -24
  72. package/dist/chunks/conditions-4fXKhEJS.js +0 -609
  73. package/dist/chunks/date-picker-B6iZkjHS.js +0 -6204
  74. package/dist/chunks/debug-KnZeKYBI.js +0 -39
  75. package/dist/chunks/dist-D09GnXMW.js +0 -2663
  76. package/dist/chunks/event-names-DamGPtXR.js +0 -51
  77. package/dist/chunks/eway-DEAYcwT0.js +0 -86
  78. package/dist/chunks/field-references.keys-BpBZ_quS.js +0 -24
  79. package/dist/chunks/field-references.resolver-Ba6xhiJC.js +0 -183
  80. package/dist/chunks/file-upload-Bh63PQSE.js +0 -430
  81. package/dist/chunks/friendly-captcha-v1-CqO4WVre.js +0 -40
  82. package/dist/chunks/friendly-captcha-v2-CyykcJcM.js +0 -47
  83. package/dist/chunks/friendly-challenge-Dg8XkStd.js +0 -1101
  84. package/dist/chunks/go-cardless-CuND59rR.js +0 -26
  85. package/dist/chunks/google-address--uR8WDSm.js +0 -208
  86. package/dist/chunks/hcaptcha-CmaFUesv.js +0 -72
  87. package/dist/chunks/hidden-CYnZYple.js +0 -36
  88. package/dist/chunks/http-18nn97DZ.js +0 -29
  89. package/dist/chunks/i18n-vUh-KGiH.js +0 -55
  90. package/dist/chunks/loqate-BICNJlVK.js +0 -97
  91. package/dist/chunks/mollie-DwlsgHZ1.js +0 -26
  92. package/dist/chunks/moneris-B_IFZFTx.js +0 -159
  93. package/dist/chunks/opayo-U2x_TOII.js +0 -192
  94. package/dist/chunks/paddle-BqXFrc79.js +0 -75
  95. package/dist/chunks/paypal-Cn_DYGDb.js +0 -121
  96. package/dist/chunks/payway-Rnq796eC.js +0 -75
  97. package/dist/chunks/phone-country-B6Me4lK0.js +0 -3317
  98. package/dist/chunks/place-kit-ldUl-u9w.js +0 -56
  99. package/dist/chunks/placekit-autocomplete.esm-D-lGeaZl.js +0 -1771
  100. package/dist/chunks/recaptcha-enterprise-DPJNyv1X.js +0 -72
  101. package/dist/chunks/recaptcha-shared-DTI4qWVR.js +0 -22
  102. package/dist/chunks/recaptcha-v2-checkbox-zFjpvJ5c.js +0 -49
  103. package/dist/chunks/recaptcha-v2-invisible-CnYtkNvz.js +0 -62
  104. package/dist/chunks/recaptcha-v3-EAlWhnkX.js +0 -33
  105. package/dist/chunks/repeater-CXD1eLSn.js +0 -151
  106. package/dist/chunks/rich-text-DkmZRhGj.js +0 -442
  107. package/dist/chunks/scripts-BGD_iU_6.js +0 -41
  108. package/dist/chunks/sdk-B7u9fTlP.js +0 -2103
  109. package/dist/chunks/shared-DC6_1u8X.js +0 -85
  110. package/dist/chunks/signature-E9KyYXS1.js +0 -765
  111. package/dist/chunks/snaptcha-CCDunGeb.js +0 -8
  112. package/dist/chunks/square-BLqK51rS.js +0 -61
  113. package/dist/chunks/stripe-B8gHpZNC.js +0 -273
  114. package/dist/chunks/styles-BIh6g7V_.js +0 -22
  115. package/dist/chunks/summary-EcNE0cvg.js +0 -191
  116. package/dist/chunks/table-yxEDL6kA.js +0 -124
  117. package/dist/chunks/text-limit-D0H_Ca2c.js +0 -179
  118. package/dist/chunks/theme-classes-vSHpdCUO.js +0 -59
  119. package/dist/chunks/turnstile-DP0bdR7T.js +0 -68
  120. package/dist/chunks/utils-ByrEVYrJ.js +0 -49584
@@ -1,197 +0,0 @@
1
- import { t as createDebug } from "./debug-KnZeKYBI.js";
2
- import { r as normalizeFieldKey, t as fieldKeyToInputName } from "./field-references.keys-BpBZ_quS.js";
3
- import { n as resolveFieldReferenceLive, r as buildFieldValueRegistry } from "./field-references.resolver-Ba6xhiJC.js";
4
- import { c as we, i as Te, n as K, s as q, t as Ce } from "./dist-D09GnXMW.js";
5
- import { r as getModuleFieldContainers, t as dispatchFieldEvent } from "./shared-DC6_1u8X.js";
6
- //#region src/js/modules/fields/calculations.ts
7
- var INPUT_SELECTOR = "input[data-formie-calculation-input]";
8
- var MODULE_ID = "calculations";
9
- var debug = createDebug("fields", "calculations");
10
- function resolveVariables(root, variableEntries, options) {
11
- const registry = buildFieldValueRegistry(root);
12
- const variables = {};
13
- variableEntries.forEach(([variableKey, variable]) => {
14
- variables[variableKey] = K(variable, resolveFieldReferenceLive(variable.sourceKey || "", registry).value);
15
- });
16
- return Te(variables, options.formatting);
17
- }
18
- function getWatchNames(root, variableEntries) {
19
- const registry = buildFieldValueRegistry(root);
20
- const watchNames = /* @__PURE__ */ new Set();
21
- variableEntries.forEach(([, variable]) => {
22
- const key = normalizeFieldKey(variable.sourceKey || "");
23
- const entry = registry.get(key);
24
- if (entry?.names?.length) {
25
- entry.names.forEach((name) => {
26
- watchNames.add(name);
27
- });
28
- return;
29
- }
30
- const fallback = fieldKeyToInputName(key);
31
- if (fallback) {
32
- watchNames.add(fallback);
33
- watchNames.add(`${fallback}[]`);
34
- }
35
- });
36
- return watchNames;
37
- }
38
- function bindCalculationsField(root, field, input, options) {
39
- const formula = Ce(options);
40
- const variableEntries = we(options);
41
- const sourceBindings = /* @__PURE__ */ new Map();
42
- let observer = null;
43
- let destroyed = false;
44
- let evaluateQueued = false;
45
- let rebindQueued = false;
46
- const cleanupBindings = () => {
47
- sourceBindings.forEach((listeners, target) => {
48
- listeners.forEach((listener, eventName) => {
49
- target.removeEventListener(eventName, listener);
50
- });
51
- });
52
- sourceBindings.clear();
53
- };
54
- const dispatchCalculatedValueChanged = (valueChanged) => {
55
- if (!valueChanged || destroyed) return;
56
- queueMicrotask(() => {
57
- if (destroyed) return;
58
- input.dispatchEvent(new Event("input", { bubbles: true }));
59
- input.dispatchEvent(new Event("change", { bubbles: true }));
60
- });
61
- };
62
- const evaluate = (isInit = false) => {
63
- const variables = resolveVariables(root, variableEntries, options);
64
- debug.log("Evaluate requested.", {
65
- fieldHandle: field.getAttribute("data-formie-field-handle") || null,
66
- isInit
67
- });
68
- const beforeDetail = {
69
- calculations: input,
70
- init: isInit,
71
- formula,
72
- variables
73
- };
74
- dispatchFieldEvent(field, MODULE_ID, "before-evaluate", beforeDetail);
75
- if (!beforeDetail.formula) {
76
- const valueChanged = input.value !== "";
77
- input.value = "";
78
- dispatchCalculatedValueChanged(valueChanged);
79
- return;
80
- }
81
- try {
82
- const result = q(beforeDetail.formula, beforeDetail.variables, options);
83
- const afterDetail = {
84
- calculations: input,
85
- init: isInit,
86
- formula: beforeDetail.formula,
87
- variables: beforeDetail.variables,
88
- result
89
- };
90
- dispatchFieldEvent(field, MODULE_ID, "after-evaluate", afterDetail);
91
- const nextValue = typeof afterDetail.result === "string" || typeof afterDetail.result === "number" ? String(afterDetail.result) : "";
92
- const valueChanged = input.value !== nextValue;
93
- input.value = nextValue;
94
- debug.log("Evaluate complete.", {
95
- fieldHandle: field.getAttribute("data-formie-field-handle") || null,
96
- valueChanged,
97
- nextValue
98
- });
99
- dispatchCalculatedValueChanged(valueChanged);
100
- } catch (error) {
101
- const valueChanged = input.value !== "";
102
- console.error("[formie] Failed to evaluate calculation.", error);
103
- debug.warn("Evaluate failed.", {
104
- fieldHandle: field.getAttribute("data-formie-field-handle") || null,
105
- error: error instanceof Error ? error.message : error
106
- });
107
- input.value = "";
108
- dispatchCalculatedValueChanged(valueChanged);
109
- }
110
- };
111
- const scheduleEvaluate = (isInit = false) => {
112
- if (evaluateQueued || destroyed) return;
113
- evaluateQueued = true;
114
- queueMicrotask(() => {
115
- evaluateQueued = false;
116
- evaluate(isInit);
117
- });
118
- };
119
- const bindSources = () => {
120
- cleanupBindings();
121
- const watchNames = getWatchNames(root, variableEntries);
122
- debug.log("Binding variable watchers.", {
123
- fieldHandle: field.getAttribute("data-formie-field-handle") || null,
124
- watchCount: watchNames.size
125
- });
126
- if (!watchNames.size) return;
127
- const listener = (event) => {
128
- const name = event.target?.name || "";
129
- if (!name || !watchNames.has(name)) return;
130
- debug.log("Source change detected.", {
131
- fieldHandle: field.getAttribute("data-formie-field-handle") || null,
132
- sourceName: name,
133
- eventType: event.type
134
- });
135
- scheduleEvaluate(false);
136
- };
137
- ["input", "change"].forEach((eventName) => {
138
- root.addEventListener(eventName, listener);
139
- const listeners = sourceBindings.get(root) || /* @__PURE__ */ new Map();
140
- listeners.set(eventName, listener);
141
- sourceBindings.set(root, listeners);
142
- });
143
- };
144
- const scheduleRebind = () => {
145
- if (rebindQueued || destroyed) return;
146
- rebindQueued = true;
147
- queueMicrotask(() => {
148
- rebindQueued = false;
149
- bindSources();
150
- scheduleEvaluate(false);
151
- });
152
- };
153
- bindSources();
154
- observer = new MutationObserver(() => {
155
- scheduleRebind();
156
- });
157
- observer.observe(root, {
158
- childList: true,
159
- subtree: true
160
- });
161
- evaluate(true);
162
- return () => {
163
- destroyed = true;
164
- observer?.disconnect();
165
- cleanupBindings();
166
- };
167
- }
168
- var calculationsModule = {
169
- id: MODULE_ID,
170
- kind: "field",
171
- match: (ctx) => {
172
- return !!ctx.target.querySelector(INPUT_SELECTOR);
173
- },
174
- setup: async (ctx) => {
175
- const options = ctx.options || {};
176
- const fields = getModuleFieldContainers(ctx);
177
- debug.log("Module setup.", {
178
- fieldCount: fields.length,
179
- formatting: options.formatting || null
180
- });
181
- const cleanups = fields.map((field) => {
182
- const input = field.querySelector(INPUT_SELECTOR);
183
- if (!(input instanceof HTMLInputElement)) return () => {};
184
- return bindCalculationsField(ctx.root, field, input, options);
185
- });
186
- await ctx.emit("formie:module:calculations:init", { count: cleanups.length });
187
- return { destroy: () => {
188
- debug.log("Module destroy.", { fieldCount: cleanups.length });
189
- cleanups.forEach((cleanup) => {
190
- cleanup();
191
- });
192
- ctx.emit("formie:module:calculations:destroy", {});
193
- } };
194
- }
195
- };
196
- //#endregion
197
- export { calculationsModule };
@@ -1,43 +0,0 @@
1
- import { a as CAPTCHA_PROVIDER_LOAD_TIMEOUT_MS, t as defineCaptchaModule } from "./api-DOfDzYC_.js";
2
- import { r as loadScriptAndEnsureGlobal } from "./scripts-BGD_iU_6.js";
3
- //#region src/js/modules/captchas/captcha-eu.ts
4
- async function loadCaptchaEuGlobal(options) {
5
- return loadScriptAndEnsureGlobal("KROT", {
6
- id: "FORMIE_CAPTCHA_EU_SCRIPT",
7
- src: `${String(options.endPoint || "https://www.captcha.eu").trim().replace(/\/+$/, "")}/sdk.js`,
8
- async: true,
9
- defer: true,
10
- timeoutMs: CAPTCHA_PROVIDER_LOAD_TIMEOUT_MS
11
- });
12
- }
13
- var captchaEuModule = defineCaptchaModule({
14
- id: "captcha-eu",
15
- defaultPlaceholderSelector: "[data-captcha-eu-placeholder]",
16
- defaultTokenFieldNames: ["captcha-eu-token"],
17
- load: ({ options }) => {
18
- return loadCaptchaEuGlobal(options.provider);
19
- },
20
- mount: ({ api, container, provider, services }) => {
21
- api.init();
22
- api.setup(String(provider.publicKey || ""));
23
- api.WidgetV2.render(container);
24
- api.on("CPT_OK", (event) => {
25
- services.tokens.write(JSON.stringify(event.detail || {}), { container });
26
- services.errors.clear();
27
- }, container);
28
- api.on("CPT_EXPIRED", () => {
29
- services.tokens.clear();
30
- services.errors.clear();
31
- }, container);
32
- return container;
33
- },
34
- screen: async ({ placeholder, services, stageCtx }) => {
35
- if (!await services.tokens.wait()) {
36
- const message = services.errors.getDefaultMessage();
37
- services.errors.show(message, placeholder);
38
- stageCtx.abort(message);
39
- }
40
- }
41
- });
42
- //#endregion
43
- export { captchaEuModule };
@@ -1,197 +0,0 @@
1
- import { t as createDebug } from "./debug-KnZeKYBI.js";
2
- import { c as retainFormValidators, n as escapeSelectorValue, s as releaseFormValidators, t as dispatchFieldEvent } from "./shared-DC6_1u8X.js";
3
- //#region src/js/modules/fields/checkbox-radio.ts
4
- var FIELD_SELECTOR = "[data-formie-checkboxes-field-layout], [data-formie-radio-field-layout]";
5
- var CHECKBOX_MINMAX_VALIDATOR = "minmaxOptions";
6
- var MAX_DISABLED_ATTR = "data-formie-checkbox-radio-max-disabled";
7
- var MODULE_ID = "checkbox-radio";
8
- var VALIDATOR_SCOPE = "checkbox-radio";
9
- var debug = createDebug("fields", "checkbox-radio");
10
- function isToggleCheckbox(input) {
11
- return input.hasAttribute("data-checkbox-toggle") || input.hasAttribute("data-formie-checkbox-toggle");
12
- }
13
- function getMinMaxRule(getRule) {
14
- const rule = getRule(CHECKBOX_MINMAX_VALIDATOR);
15
- if (!rule || rule === true || typeof rule !== "object") return {
16
- min: null,
17
- max: null
18
- };
19
- const candidate = rule;
20
- return {
21
- min: typeof candidate.min === "number" ? candidate.min : null,
22
- max: typeof candidate.max === "number" ? candidate.max : null
23
- };
24
- }
25
- function registerValidators(form) {
26
- retainFormValidators(form, VALIDATOR_SCOPE, (validator) => {
27
- validator.addValidator(CHECKBOX_MINMAX_VALIDATOR, ({ field, getRule }) => {
28
- if (!field || !getRule(CHECKBOX_MINMAX_VALIDATOR)) return true;
29
- const selected = Array.from(field.querySelectorAll("input[type=\"checkbox\"]")).filter((input) => {
30
- return input instanceof HTMLInputElement && !isToggleCheckbox(input);
31
- }).filter((input) => {
32
- return input.checked;
33
- }).length;
34
- const { min, max } = getMinMaxRule(getRule);
35
- if (min !== null && selected < min) return false;
36
- if (max !== null && selected > max) return false;
37
- return true;
38
- }, ({ field, label, t, getRule }) => {
39
- const { min, max } = field ? getMinMaxRule(getRule) : {
40
- min: null,
41
- max: null
42
- };
43
- if (min !== null && max !== null) return t("{attribute} must select between {min} and {max}.", {
44
- attribute: label,
45
- min,
46
- max
47
- });
48
- if (min !== null) return t("{attribute} must select no less than {min}.", {
49
- attribute: label,
50
- min
51
- });
52
- if (max !== null) return t("{attribute} must select no greater than {max}.", {
53
- attribute: label,
54
- max
55
- });
56
- return t("{attribute} has an invalid value.", { attribute: label });
57
- });
58
- });
59
- }
60
- function unregisterValidators(form) {
61
- releaseFormValidators(form, VALIDATOR_SCOPE, [CHECKBOX_MINMAX_VALIDATOR]);
62
- }
63
- function syncCheckedAttribute(input) {
64
- if (input.checked) input.setAttribute("checked", "");
65
- else input.removeAttribute("checked");
66
- }
67
- function syncRequiredCheckboxes(field) {
68
- const requiredCheckboxes = Array.from(field.querySelectorAll("input[type=\"checkbox\"][required][data-formie-checkbox-input]")).filter((input) => {
69
- return input instanceof HTMLInputElement;
70
- });
71
- if (!requiredCheckboxes.length) return;
72
- const hasCheckedValue = requiredCheckboxes.some((input) => {
73
- return input.checked;
74
- });
75
- requiredCheckboxes.forEach((input) => {
76
- if (hasCheckedValue) {
77
- input.removeAttribute("required");
78
- input.setAttribute("aria-required", "false");
79
- return;
80
- }
81
- input.setAttribute("required", "true");
82
- input.setAttribute("aria-required", "true");
83
- });
84
- }
85
- function enforceMaxOptions(field) {
86
- const maxOptions = parseInt(field.closest("[data-formie-field-handle]")?.getAttribute("data-formie-max-options") || "", 10);
87
- if (!(maxOptions > 0)) return;
88
- const checkboxes = Array.from(field.querySelectorAll("input[type=\"checkbox\"]")).filter((input) => {
89
- return input instanceof HTMLInputElement && !isToggleCheckbox(input);
90
- });
91
- const disableUnchecked = checkboxes.filter((input) => {
92
- return input.checked;
93
- }).length >= maxOptions;
94
- checkboxes.forEach((input) => {
95
- const shouldDisableForMax = disableUnchecked && !input.checked;
96
- const wasDisabledForMax = input.hasAttribute(MAX_DISABLED_ATTR);
97
- if (shouldDisableForMax) {
98
- if (!input.disabled) {
99
- input.disabled = true;
100
- input.setAttribute(MAX_DISABLED_ATTR, "true");
101
- }
102
- return;
103
- }
104
- if (wasDisabledForMax) {
105
- input.disabled = false;
106
- input.removeAttribute(MAX_DISABLED_ATTR);
107
- }
108
- });
109
- }
110
- function toggleCheckboxGroup(field, toggle) {
111
- Array.from(field.querySelectorAll("input[type=\"checkbox\"]")).filter((input) => {
112
- return input instanceof HTMLInputElement && input !== toggle && !isToggleCheckbox(input);
113
- }).forEach((input) => {
114
- if (input.disabled && !input.checked) return;
115
- input.checked = toggle.checked;
116
- syncCheckedAttribute(input);
117
- input.dispatchEvent(new Event("change", { bubbles: true }));
118
- input.dispatchEvent(new Event("input", { bubbles: true }));
119
- });
120
- }
121
- function syncRadioGroup(input, field) {
122
- if (!input.checked || !input.name) {
123
- syncCheckedAttribute(input);
124
- return;
125
- }
126
- Array.from(field.querySelectorAll(`input[type="radio"][name="${escapeSelectorValue(input.name)}"]`)).filter((radio) => {
127
- return radio instanceof HTMLInputElement;
128
- }).forEach((radio) => {
129
- syncCheckedAttribute(radio);
130
- });
131
- }
132
- function bindField(field) {
133
- const inputs = Array.from(field.querySelectorAll("input[type=\"checkbox\"], input[type=\"radio\"]")).filter((input) => {
134
- return input instanceof HTMLInputElement;
135
- });
136
- if (!inputs.length) {
137
- debug.log("No checkbox/radio inputs found for field.");
138
- return () => {};
139
- }
140
- const listeners = inputs.map((input) => {
141
- const eventName = input.type === "radio" ? "change" : "click";
142
- const handler = () => {
143
- syncCheckedAttribute(input);
144
- if (input.type === "checkbox" && isToggleCheckbox(input)) toggleCheckboxGroup(field, input);
145
- if (input.type === "radio") syncRadioGroup(input, field);
146
- syncRequiredCheckboxes(field);
147
- enforceMaxOptions(field);
148
- debug.log("Input interaction processed.", {
149
- inputName: input.name,
150
- inputType: input.type,
151
- checked: input.checked
152
- });
153
- };
154
- input.addEventListener(eventName, handler);
155
- syncCheckedAttribute(input);
156
- return () => {
157
- input.removeEventListener(eventName, handler);
158
- };
159
- });
160
- syncRequiredCheckboxes(field);
161
- enforceMaxOptions(field);
162
- dispatchFieldEvent(field, MODULE_ID, "init", { checkboxRadio: field });
163
- return () => {
164
- listeners.forEach((unbind) => {
165
- unbind();
166
- });
167
- };
168
- }
169
- var checkboxRadioModule = {
170
- id: MODULE_ID,
171
- kind: "field",
172
- match: (ctx) => {
173
- return ctx.target instanceof HTMLElement && (ctx.target.matches(FIELD_SELECTOR) || !!ctx.target.querySelector(FIELD_SELECTOR));
174
- },
175
- setup: async (ctx) => {
176
- if (!(ctx.target instanceof HTMLElement)) return;
177
- const fields = ctx.target.matches(FIELD_SELECTOR) ? [ctx.target] : Array.from(ctx.target.querySelectorAll(FIELD_SELECTOR)).filter((field) => {
178
- return field instanceof HTMLElement;
179
- });
180
- registerValidators(ctx.form);
181
- debug.log("Module setup.", { fieldCount: fields.length });
182
- const destroyBindings = fields.map((field) => {
183
- return bindField(field);
184
- });
185
- await ctx.emit("formie:module:checkbox-radio:init", { count: fields.length });
186
- return { destroy: () => {
187
- destroyBindings.forEach((destroyBinding) => {
188
- destroyBinding();
189
- });
190
- unregisterValidators(ctx.form);
191
- debug.log("Module destroy.", { fieldCount: fields.length });
192
- ctx.emit("formie:module:checkbox-radio:destroy", {});
193
- } };
194
- }
195
- };
196
- //#endregion
197
- export { checkboxRadioModule };
@@ -1,24 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
- get: ((k) => from[k]).bind(null, key),
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
- value: mod,
21
- enumerable: true
22
- }) : target, mod));
23
- //#endregion
24
- export { __toESM as n, __commonJSMin as t };