base-ui-vue 0.1.0 → 0.2.0

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 (204) hide show
  1. package/README.md +41 -1
  2. package/dist/button/Button.cjs +53 -12
  3. package/dist/button/Button.cjs.map +1 -1
  4. package/dist/button/Button.js +26 -15
  5. package/dist/button/Button.js.map +1 -1
  6. package/dist/button/ToolbarButton.cjs +367 -0
  7. package/dist/button/ToolbarButton.cjs.map +1 -0
  8. package/dist/button/ToolbarButton.js +320 -0
  9. package/dist/button/ToolbarButton.js.map +1 -0
  10. package/dist/button/ToolbarButtonDataAttributes.cjs +27 -0
  11. package/dist/button/ToolbarButtonDataAttributes.cjs.map +1 -0
  12. package/dist/button/ToolbarButtonDataAttributes.js +21 -0
  13. package/dist/button/ToolbarButtonDataAttributes.js.map +1 -0
  14. package/dist/checkbox/index.cjs +1173 -0
  15. package/dist/checkbox/index.cjs.map +1 -0
  16. package/dist/checkbox/index.js +1048 -0
  17. package/dist/checkbox/index.js.map +1 -0
  18. package/dist/checkbox-group/CheckboxGroup.cjs +629 -0
  19. package/dist/checkbox-group/CheckboxGroup.cjs.map +1 -0
  20. package/dist/checkbox-group/CheckboxGroup.js +540 -0
  21. package/dist/checkbox-group/CheckboxGroup.js.map +1 -0
  22. package/dist/checkbox-group/CheckboxGroupDataAttributes.cjs +18 -0
  23. package/dist/checkbox-group/CheckboxGroupDataAttributes.cjs.map +1 -0
  24. package/dist/checkbox-group/CheckboxGroupDataAttributes.js +12 -0
  25. package/dist/checkbox-group/CheckboxGroupDataAttributes.js.map +1 -0
  26. package/dist/composite/composite.cjs +167 -0
  27. package/dist/composite/composite.cjs.map +1 -1
  28. package/dist/composite/composite.js +96 -1
  29. package/dist/composite/composite.js.map +1 -1
  30. package/dist/composite/constants.cjs +12 -0
  31. package/dist/composite/constants.cjs.map +1 -0
  32. package/dist/composite/constants.js +6 -0
  33. package/dist/composite/constants.js.map +1 -0
  34. package/dist/control/FieldControl.cjs +18 -343
  35. package/dist/control/FieldControl.cjs.map +1 -1
  36. package/dist/control/FieldControl.js +14 -285
  37. package/dist/control/FieldControl.js.map +1 -1
  38. package/dist/control/SliderControl.cjs +636 -0
  39. package/dist/control/SliderControl.cjs.map +1 -0
  40. package/dist/control/SliderControl.js +553 -0
  41. package/dist/control/SliderControl.js.map +1 -0
  42. package/dist/control/SliderControlDataAttributes.cjs +47 -0
  43. package/dist/control/SliderControlDataAttributes.cjs.map +1 -0
  44. package/dist/control/SliderControlDataAttributes.js +41 -0
  45. package/dist/control/SliderControlDataAttributes.js.map +1 -0
  46. package/dist/csp-provider/CSPContext.cjs +32 -0
  47. package/dist/csp-provider/CSPContext.cjs.map +1 -0
  48. package/dist/csp-provider/CSPContext.js +21 -0
  49. package/dist/csp-provider/CSPContext.js.map +1 -0
  50. package/dist/csp-provider/CSPProvider.cjs +46 -0
  51. package/dist/csp-provider/CSPProvider.cjs.map +1 -0
  52. package/dist/csp-provider/CSPProvider.js +41 -0
  53. package/dist/csp-provider/CSPProvider.js.map +1 -0
  54. package/dist/description/FieldDescription.cjs +5 -5
  55. package/dist/description/FieldDescription.cjs.map +1 -1
  56. package/dist/description/FieldDescription.js +1 -1
  57. package/dist/direction-provider/DirectionProvider.cjs +2 -2
  58. package/dist/direction-provider/DirectionProvider.cjs.map +1 -1
  59. package/dist/direction-provider/DirectionProvider.js +1 -1
  60. package/dist/error/FieldError.cjs +10 -288
  61. package/dist/error/FieldError.cjs.map +1 -1
  62. package/dist/error/FieldError.js +4 -246
  63. package/dist/error/FieldError.js.map +1 -1
  64. package/dist/form/Form.cjs +5 -4
  65. package/dist/form/Form.cjs.map +1 -1
  66. package/dist/form/Form.js +5 -4
  67. package/dist/form/Form.js.map +1 -1
  68. package/dist/group/ToolbarGroup.cjs +92 -0
  69. package/dist/group/ToolbarGroup.cjs.map +1 -0
  70. package/dist/group/ToolbarGroup.js +87 -0
  71. package/dist/group/ToolbarGroup.js.map +1 -0
  72. package/dist/group/ToolbarGroupDataAttributes.cjs +23 -0
  73. package/dist/group/ToolbarGroupDataAttributes.cjs.map +1 -0
  74. package/dist/group/ToolbarGroupDataAttributes.js +17 -0
  75. package/dist/group/ToolbarGroupDataAttributes.js.map +1 -0
  76. package/dist/header/AccordionHeader.cjs +2 -2
  77. package/dist/header/AccordionHeader.js +1 -1
  78. package/dist/image/AvatarImage.cjs +4 -4
  79. package/dist/image/AvatarImage.cjs.map +1 -1
  80. package/dist/image/AvatarImage.js +1 -1
  81. package/dist/index.cjs +80 -10
  82. package/dist/index.d.cts +2751 -612
  83. package/dist/index.d.cts.map +1 -1
  84. package/dist/index.d.ts +2751 -612
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +15 -5
  87. package/dist/index2.cjs +3651 -370
  88. package/dist/index2.cjs.map +1 -1
  89. package/dist/index2.js +3365 -270
  90. package/dist/index2.js.map +1 -1
  91. package/package.json +8 -4
  92. package/src/accordion/root/AccordionRoot.vue +2 -1
  93. package/src/checkbox/index.ts +23 -0
  94. package/src/checkbox/indicator/CheckboxIndicator.vue +102 -0
  95. package/src/checkbox/indicator/CheckboxIndicatorDataAttributes.ts +61 -0
  96. package/src/checkbox/root/CheckboxRoot.vue +632 -0
  97. package/src/checkbox/root/CheckboxRootContext.ts +22 -0
  98. package/src/checkbox/root/CheckboxRootDataAttributes.ts +54 -0
  99. package/src/checkbox/utils/useStateAttributesMapping.ts +30 -0
  100. package/src/checkbox-group/CheckboxGroup.vue +241 -0
  101. package/src/checkbox-group/CheckboxGroupContext.ts +39 -0
  102. package/src/checkbox-group/CheckboxGroupDataAttributes.ts +6 -0
  103. package/src/checkbox-group/index.ts +11 -0
  104. package/src/checkbox-group/useCheckboxGroupParent.ts +173 -0
  105. package/src/collapsible/panel/useCollapsiblePanel.ts +2 -1
  106. package/src/collapsible/root/useCollapsibleRoot.ts +3 -1
  107. package/src/composite/composite.ts +2 -0
  108. package/src/composite/item/CompositeItem.vue +7 -8
  109. package/src/composite/root/CompositeRoot.vue +12 -1
  110. package/src/csp-provider/CSPContext.ts +26 -0
  111. package/src/csp-provider/CSPProvider.vue +40 -0
  112. package/src/csp-provider/index.ts +5 -0
  113. package/src/field/item/FieldItem.vue +6 -1
  114. package/src/field/label/FieldLabel.vue +10 -51
  115. package/src/field/root/FieldRoot.vue +16 -3
  116. package/src/floating-ui-vue/types.ts +1 -4
  117. package/src/floating-ui-vue/utils/element.ts +12 -0
  118. package/src/floating-ui-vue/utils/shadowDom.ts +44 -0
  119. package/src/floating-ui-vue/utils.ts +3 -0
  120. package/src/form/Form.vue +5 -3
  121. package/src/index.ts +9 -0
  122. package/src/labelable-provider/LabelableContext.ts +2 -2
  123. package/src/labelable-provider/LabelableProvider.vue +21 -4
  124. package/src/labelable-provider/index.ts +2 -0
  125. package/src/labelable-provider/useAriaLabelledBy.ts +9 -9
  126. package/src/labelable-provider/useLabel.ts +115 -0
  127. package/src/labelable-provider/useLabelableId.ts +12 -10
  128. package/src/separator/Separator.vue +65 -0
  129. package/src/separator/SeparatorDataAttributes.ts +7 -0
  130. package/src/separator/index.ts +3 -0
  131. package/src/slider/control/SliderControl.vue +497 -0
  132. package/src/slider/control/SliderControlDataAttributes.ts +35 -0
  133. package/src/slider/index.ts +35 -0
  134. package/src/slider/indicator/SliderIndicator.vue +144 -0
  135. package/src/slider/indicator/SliderIndicatorDataAttributes.ts +35 -0
  136. package/src/slider/label/SliderLabel.vue +75 -0
  137. package/src/slider/root/SliderRoot.vue +557 -0
  138. package/src/slider/root/SliderRootContext.ts +126 -0
  139. package/src/slider/root/SliderRootDataAttributes.ts +35 -0
  140. package/src/slider/root/stateAttributesMapping.ts +13 -0
  141. package/src/slider/thumb/SliderThumb.vue +601 -0
  142. package/src/slider/thumb/SliderThumbDataAttributes.ts +39 -0
  143. package/src/slider/thumb/prehydrationScript.min.ts +5 -0
  144. package/src/slider/thumb/prehydrationScript.template.js +69 -0
  145. package/src/slider/track/SliderTrack.vue +48 -0
  146. package/src/slider/track/SliderTrackDataAttributes.ts +10 -0
  147. package/src/slider/utils/asc.ts +3 -0
  148. package/src/slider/utils/getMidpoint.ts +9 -0
  149. package/src/slider/utils/getPushedThumbValues.ts +68 -0
  150. package/src/slider/utils/getSliderValue.ts +25 -0
  151. package/src/slider/utils/replaceArrayItemAtIndex.ts +15 -0
  152. package/src/slider/utils/resolveThumbCollision.ts +177 -0
  153. package/src/slider/utils/roundValueToStep.ts +19 -0
  154. package/src/slider/utils/test-utils.ts +25 -0
  155. package/src/slider/utils/validateMinimumDistance.ts +20 -0
  156. package/src/slider/utils/valueArrayToPercentages.ts +10 -0
  157. package/src/slider/value/SliderValue.vue +90 -0
  158. package/src/slider/value/SliderValueDataAttributes.ts +35 -0
  159. package/src/switch/index.ts +14 -0
  160. package/src/switch/root/SwitchRoot.vue +448 -0
  161. package/src/switch/root/SwitchRootContext.ts +22 -0
  162. package/src/switch/root/SwitchRootDataAttributes.ts +46 -0
  163. package/src/switch/stateAttributesMapping.ts +23 -0
  164. package/src/switch/thumb/SwitchThumb.vue +59 -0
  165. package/src/switch/thumb/SwitchThumbDataAttributes.ts +46 -0
  166. package/src/toggle/Toggle.vue +211 -0
  167. package/src/toggle/ToggleDataAttributes.ts +6 -0
  168. package/src/toggle/index.ts +3 -0
  169. package/src/toggle-group/ToggleGroup.vue +224 -0
  170. package/src/toggle-group/ToggleGroupContext.ts +45 -0
  171. package/src/toggle-group/ToggleGroupDataAttributes.ts +15 -0
  172. package/src/toggle-group/index.ts +5 -0
  173. package/src/toolbar/button/ToolbarButton.vue +99 -0
  174. package/src/toolbar/button/ToolbarButtonDataAttributes.ts +15 -0
  175. package/src/toolbar/group/ToolbarGroup.vue +70 -0
  176. package/src/toolbar/group/ToolbarGroupContext.ts +23 -0
  177. package/src/toolbar/group/ToolbarGroupDataAttributes.ts +11 -0
  178. package/src/toolbar/index.ts +27 -0
  179. package/src/toolbar/input/ToolbarInput.vue +114 -0
  180. package/src/toolbar/input/ToolbarInputDataAttributes.ts +15 -0
  181. package/src/toolbar/link/ToolbarLink.vue +54 -0
  182. package/src/toolbar/link/ToolbarLinkDataAttributes.ts +7 -0
  183. package/src/toolbar/root/ToolbarRoot.vue +144 -0
  184. package/src/toolbar/root/ToolbarRootContext.ts +29 -0
  185. package/src/toolbar/root/ToolbarRootDataAttributes.ts +11 -0
  186. package/src/toolbar/separator/ToolbarSeparator.vue +41 -0
  187. package/src/toolbar/separator/ToolbarSeparatorDataAttributes.ts +7 -0
  188. package/src/use-button/useButton.ts +2 -1
  189. package/src/utils/areArraysEqual.ts +12 -0
  190. package/src/utils/clamp.ts +7 -0
  191. package/src/utils/createBaseUIEventDetails.ts +9 -0
  192. package/src/utils/formatNumber.ts +7 -0
  193. package/src/utils/owner.ts +5 -0
  194. package/src/utils/resolveAriaLabelledBy.ts +10 -0
  195. package/src/utils/useControllableState.ts +78 -14
  196. package/src/utils/useFocusableWhenDisabled.ts +6 -1
  197. package/src/utils/useMergedRefs.ts +26 -2
  198. package/src/utils/useRegisteredLabelId.ts +21 -0
  199. package/src/utils/valueToPercent.ts +7 -0
  200. package/src/utils/visuallyHidden.ts +24 -0
  201. package/dist/direction-provider/DirectionContext.cjs +0 -26
  202. package/dist/direction-provider/DirectionContext.cjs.map +0 -1
  203. package/dist/direction-provider/DirectionContext.js +0 -15
  204. package/dist/direction-provider/DirectionContext.js.map +0 -1
@@ -0,0 +1,1173 @@
1
+ const require_button_Button = require('../button/Button.cjs');
2
+ const require_checkbox_group_CheckboxGroup = require('../checkbox-group/CheckboxGroup.cjs');
3
+ let vue = require("vue");
4
+
5
+ //#region src/utils/stateAttributesMapping.ts
6
+ let TransitionStatusDataAttributes = /* @__PURE__ */ function(TransitionStatusDataAttributes) {
7
+ /**
8
+ * Present when the component is animating in.
9
+ */
10
+ TransitionStatusDataAttributes["startingStyle"] = "data-starting-style";
11
+ /**
12
+ * Present when the component is animating out.
13
+ */
14
+ TransitionStatusDataAttributes["endingStyle"] = "data-ending-style";
15
+ return TransitionStatusDataAttributes;
16
+ }({});
17
+ const STARTING_HOOK = { [TransitionStatusDataAttributes.startingStyle]: "" };
18
+ const ENDING_HOOK = { [TransitionStatusDataAttributes.endingStyle]: "" };
19
+ const transitionStatusMapping = { transitionStatus(value) {
20
+ if (value === "starting") return STARTING_HOOK;
21
+ if (value === "ending") return ENDING_HOOK;
22
+ return null;
23
+ } };
24
+
25
+ //#endregion
26
+ //#region src/utils/createBaseUIEventDetails.ts
27
+ /**
28
+ * Creates a Base UI event details object with the given reason and utilities
29
+ * for preventing Base UI's internal event handling.
30
+ */
31
+ function createChangeEventDetails(reason, event, trigger, customProperties) {
32
+ let canceled = false;
33
+ let propagationAllowed = false;
34
+ const custom = customProperties ?? require_button_Button.EMPTY_OBJECT;
35
+ return {
36
+ reason,
37
+ event: event ?? new Event("base-ui"),
38
+ cancel() {
39
+ canceled = true;
40
+ },
41
+ allowPropagation() {
42
+ propagationAllowed = true;
43
+ },
44
+ get isCanceled() {
45
+ return canceled;
46
+ },
47
+ get isPropagationAllowed() {
48
+ return propagationAllowed;
49
+ },
50
+ trigger,
51
+ ...custom
52
+ };
53
+ }
54
+ function createGenericEventDetails(reason, event, trigger) {
55
+ return createChangeEventDetails(reason, event, trigger);
56
+ }
57
+
58
+ //#endregion
59
+ //#region src/utils/reasons.ts
60
+ const none = "none";
61
+ const triggerPress = "trigger-press";
62
+ const triggerHover = "trigger-hover";
63
+ const triggerFocus = "trigger-focus";
64
+ const outsidePress = "outside-press";
65
+ const itemPress = "item-press";
66
+ const closePress = "close-press";
67
+ const linkPress = "link-press";
68
+ const clearPress = "clear-press";
69
+ const chipRemovePress = "chip-remove-press";
70
+ const trackPress = "track-press";
71
+ const incrementPress = "increment-press";
72
+ const decrementPress = "decrement-press";
73
+ const inputChange = "input-change";
74
+ const inputClear = "input-clear";
75
+ const inputBlur = "input-blur";
76
+ const inputPaste = "input-paste";
77
+ const inputPress = "input-press";
78
+ const focusOut = "focus-out";
79
+ const escapeKey = "escape-key";
80
+ const closeWatcher = "close-watcher";
81
+ const listNavigation = "list-navigation";
82
+ const keyboard = "keyboard";
83
+ const pointer = "pointer";
84
+ const drag = "drag";
85
+ const swipe = "swipe";
86
+ const wheel = "wheel";
87
+ const scrub = "scrub";
88
+ const cancelOpen = "cancel-open";
89
+ const siblingOpen = "sibling-open";
90
+ const disabled = "disabled";
91
+ const imperativeAction = "imperative-action";
92
+ const windowResize = "window-resize";
93
+ const REASONS = {
94
+ none,
95
+ triggerPress,
96
+ triggerHover,
97
+ triggerFocus,
98
+ outsidePress,
99
+ itemPress,
100
+ closePress,
101
+ linkPress,
102
+ clearPress,
103
+ chipRemovePress,
104
+ trackPress,
105
+ incrementPress,
106
+ decrementPress,
107
+ inputChange,
108
+ inputClear,
109
+ inputBlur,
110
+ inputPaste,
111
+ inputPress,
112
+ focusOut,
113
+ escapeKey,
114
+ closeWatcher,
115
+ listNavigation,
116
+ keyboard,
117
+ pointer,
118
+ drag,
119
+ swipe,
120
+ wheel,
121
+ scrub,
122
+ cancelOpen,
123
+ siblingOpen,
124
+ disabled,
125
+ imperativeAction,
126
+ windowResize
127
+ };
128
+
129
+ //#endregion
130
+ //#region src/utils/resolveRef.ts
131
+ function resolveRef(refOrElement) {
132
+ const element = (0, vue.unref)(refOrElement);
133
+ if (element && "$el" in element) return element.$el;
134
+ return element;
135
+ }
136
+
137
+ //#endregion
138
+ //#region src/utils/useAnimationFrame.ts
139
+ /**
140
+ * Unlike `setTimeout`, rAF doesn't guarantee a positive integer return value, so we can't have
141
+ * a monomorphic `uint` type with `0` meaning empty.
142
+ * See warning note at:
143
+ * https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame#return_value
144
+ */
145
+ const EMPTY = null;
146
+ let LAST_RAF = typeof window !== "undefined" ? window.requestAnimationFrame : void 0;
147
+ var Scheduler = class {
148
+ callbacks = [];
149
+ callbacksCount = 0;
150
+ nextId = 1;
151
+ startId = 1;
152
+ isScheduled = false;
153
+ tick = (timestamp) => {
154
+ this.isScheduled = false;
155
+ const currentCallbacks = this.callbacks;
156
+ const currentCallbacksCount = this.callbacksCount;
157
+ this.callbacks = [];
158
+ this.callbacksCount = 0;
159
+ this.startId = this.nextId;
160
+ if (currentCallbacksCount > 0) for (let i = 0; i < currentCallbacks.length; i += 1) currentCallbacks[i]?.(timestamp);
161
+ };
162
+ request(fn) {
163
+ if (typeof window === "undefined") return 0;
164
+ const id = this.nextId;
165
+ this.nextId += 1;
166
+ this.callbacks.push(fn);
167
+ this.callbacksCount += 1;
168
+ const didRAFChange = process.env.NODE_ENV !== "production" && LAST_RAF !== window.requestAnimationFrame && (LAST_RAF = window.requestAnimationFrame, true);
169
+ if (!this.isScheduled || didRAFChange) {
170
+ window.requestAnimationFrame(this.tick);
171
+ this.isScheduled = true;
172
+ }
173
+ return id;
174
+ }
175
+ cancel(id) {
176
+ const index = id - this.startId;
177
+ if (index < 0 || index >= this.callbacks.length) return;
178
+ this.callbacks[index] = null;
179
+ this.callbacksCount -= 1;
180
+ }
181
+ };
182
+ const scheduler = new Scheduler();
183
+ var AnimationFrame = class AnimationFrame {
184
+ static create() {
185
+ return new AnimationFrame();
186
+ }
187
+ static request(fn) {
188
+ return scheduler.request(fn);
189
+ }
190
+ static cancel(id) {
191
+ return scheduler.cancel(id);
192
+ }
193
+ currentId = EMPTY;
194
+ request(fn) {
195
+ this.cancel();
196
+ this.currentId = scheduler.request((timestamp) => {
197
+ this.currentId = EMPTY;
198
+ fn(timestamp);
199
+ });
200
+ }
201
+ cancel = () => {
202
+ if (this.currentId !== EMPTY) {
203
+ scheduler.cancel(this.currentId);
204
+ this.currentId = EMPTY;
205
+ }
206
+ };
207
+ disposeEffect = () => {
208
+ return this.cancel;
209
+ };
210
+ };
211
+ /**
212
+ * A `requestAnimationFrame` with automatic cleanup and guard.
213
+ */
214
+ function useAnimationFrame() {
215
+ const animationFrame = AnimationFrame.create();
216
+ (0, vue.onUnmounted)(animationFrame.disposeEffect());
217
+ return animationFrame;
218
+ }
219
+
220
+ //#endregion
221
+ //#region src/utils/useAnimationsFinished.ts
222
+ function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
223
+ const frame = useAnimationFrame();
224
+ return (fnToExecute, signal = null) => {
225
+ frame.cancel();
226
+ function done() {
227
+ (0, vue.nextTick)(() => {
228
+ fnToExecute();
229
+ });
230
+ }
231
+ const resolvedElement = resolveRef(elementOrRef);
232
+ if (resolvedElement == null) return;
233
+ if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) fnToExecute();
234
+ else {
235
+ function execWaitForStartingStyleRemoved() {
236
+ const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
237
+ if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
238
+ frame.request(exec);
239
+ return;
240
+ }
241
+ const attributeObserver = new MutationObserver(() => {
242
+ if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
243
+ attributeObserver.disconnect();
244
+ exec();
245
+ }
246
+ });
247
+ attributeObserver.observe(resolvedElement, {
248
+ attributes: true,
249
+ attributeFilter: [startingStyleAttribute]
250
+ });
251
+ signal?.addEventListener("abort", () => attributeObserver.disconnect(), { once: true });
252
+ }
253
+ function exec() {
254
+ Promise.all(resolvedElement.getAnimations().map((anim) => anim.finished)).then(() => {
255
+ if (signal?.aborted) return;
256
+ done();
257
+ }).catch(() => {
258
+ const currentAnimations = resolvedElement.getAnimations();
259
+ if (treatAbortedAsFinished) {
260
+ if (signal?.aborted) return;
261
+ done();
262
+ } else if (currentAnimations.length > 0 && currentAnimations.some((anim) => anim.pending || anim.playState !== "finished")) exec();
263
+ });
264
+ }
265
+ if ((0, vue.toValue)(waitForStartingStyleRemoved)) {
266
+ execWaitForStartingStyleRemoved();
267
+ return;
268
+ }
269
+ frame.request(exec);
270
+ }
271
+ };
272
+ }
273
+
274
+ //#endregion
275
+ //#region src/utils/useTransitionStatus.ts
276
+ /**
277
+ * Provides a status string for CSS animations.
278
+ * @param openRef - a boolean that determines if the element is open.
279
+ * @param enableIdleStateRef - a boolean that enables the `'idle'` state between `'starting'` and `'ending'`
280
+ * @param deferEndingStateRef - a boolean that defers the `'ending'` state.
281
+ */
282
+ function useTransitionStatus(openRef, enableIdleStateRef = false, deferEndingStateRef = false) {
283
+ const open = (0, vue.computed)(() => (0, vue.toValue)(openRef));
284
+ const enableIdleState = (0, vue.computed)(() => (0, vue.toValue)(enableIdleStateRef));
285
+ const deferEndingState = (0, vue.computed)(() => (0, vue.toValue)(deferEndingStateRef));
286
+ const transitionStatus = (0, vue.ref)(open.value && enableIdleState.value ? "idle" : void 0);
287
+ const mounted = (0, vue.ref)(open.value);
288
+ (0, vue.watchEffect)(() => {
289
+ if (open.value && !mounted.value) {
290
+ mounted.value = true;
291
+ transitionStatus.value = "starting";
292
+ }
293
+ if (!open.value && mounted.value && transitionStatus.value !== "ending" && !deferEndingState.value) transitionStatus.value = "ending";
294
+ if (!open.value && !mounted.value && transitionStatus.value === "ending") transitionStatus.value = void 0;
295
+ });
296
+ (0, vue.watchEffect)((onCleanup) => {
297
+ if (!open.value && mounted.value && transitionStatus.value !== "ending" && deferEndingState.value) {
298
+ const frame = AnimationFrame.request(() => {
299
+ transitionStatus.value = "ending";
300
+ });
301
+ onCleanup(() => {
302
+ AnimationFrame.cancel(frame);
303
+ });
304
+ }
305
+ });
306
+ (0, vue.watchEffect)((onCleanup) => {
307
+ if (!open.value || enableIdleState.value) return;
308
+ const frame = AnimationFrame.request(() => {
309
+ transitionStatus.value = void 0;
310
+ });
311
+ onCleanup(() => {
312
+ AnimationFrame.cancel(frame);
313
+ });
314
+ });
315
+ (0, vue.watchEffect)((onCleanup) => {
316
+ if (!open.value || !enableIdleState.value) return;
317
+ if (open.value && mounted.value && transitionStatus.value !== "idle") transitionStatus.value = "starting";
318
+ const frame = AnimationFrame.request(() => {
319
+ transitionStatus.value = "idle";
320
+ });
321
+ onCleanup(() => {
322
+ AnimationFrame.cancel(frame);
323
+ });
324
+ });
325
+ return {
326
+ mounted,
327
+ setMounted(value) {
328
+ mounted.value = value;
329
+ },
330
+ transitionStatus
331
+ };
332
+ }
333
+
334
+ //#endregion
335
+ //#region src/utils/useOpenChangeComplete.ts
336
+ /**
337
+ * Calls the provided function when the CSS open/close animation or transition completes.
338
+ */
339
+ function useOpenChangeComplete(parameters) {
340
+ const runOnceAnimationsFinish = useAnimationsFinished(parameters.ref, parameters.open, false);
341
+ (0, vue.watchEffect)((onCleanup) => {
342
+ if (!((0, vue.toValue)(parameters.enabled) ?? true)) return;
343
+ const abortController = new AbortController();
344
+ runOnceAnimationsFinish(parameters.onComplete, abortController.signal);
345
+ onCleanup(() => {
346
+ abortController.abort();
347
+ });
348
+ });
349
+ }
350
+
351
+ //#endregion
352
+ //#region src/checkbox/root/CheckboxRootContext.ts
353
+ const checkboxRootContextKey = Symbol("CheckboxRootContext");
354
+ function useCheckboxRootContext(optional = false) {
355
+ const context = (0, vue.inject)(checkboxRootContextKey, void 0);
356
+ if (!context && !optional) throw new Error("Base UI Vue: CheckboxRootContext is missing. Checkbox parts must be placed within <CheckboxRoot>.");
357
+ return context;
358
+ }
359
+
360
+ //#endregion
361
+ //#region src/checkbox/root/CheckboxRootDataAttributes.ts
362
+ let CheckboxRootDataAttributes = /* @__PURE__ */ function(CheckboxRootDataAttributes) {
363
+ /**
364
+ * Present when the checkbox is checked.
365
+ */
366
+ CheckboxRootDataAttributes["checked"] = "data-checked";
367
+ /**
368
+ * Present when the checkbox is not checked.
369
+ */
370
+ CheckboxRootDataAttributes["unchecked"] = "data-unchecked";
371
+ /**
372
+ * Present when the checkbox is in an indeterminate state.
373
+ */
374
+ CheckboxRootDataAttributes["indeterminate"] = "data-indeterminate";
375
+ /**
376
+ * Present when the checkbox is disabled.
377
+ */
378
+ CheckboxRootDataAttributes["disabled"] = "data-disabled";
379
+ /**
380
+ * Present when the checkbox is readonly.
381
+ */
382
+ CheckboxRootDataAttributes["readonly"] = "data-readonly";
383
+ /**
384
+ * Present when the checkbox is required.
385
+ */
386
+ CheckboxRootDataAttributes["required"] = "data-required";
387
+ /**
388
+ * Present when the checkbox is in valid state (when wrapped in FieldRoot).
389
+ */
390
+ CheckboxRootDataAttributes["valid"] = "data-valid";
391
+ /**
392
+ * Present when the checkbox is in invalid state (when wrapped in FieldRoot).
393
+ */
394
+ CheckboxRootDataAttributes["invalid"] = "data-invalid";
395
+ /**
396
+ * Present when the checkbox has been touched (when wrapped in FieldRoot).
397
+ */
398
+ CheckboxRootDataAttributes["touched"] = "data-touched";
399
+ /**
400
+ * Present when the checkbox's value has changed (when wrapped in FieldRoot).
401
+ */
402
+ CheckboxRootDataAttributes["dirty"] = "data-dirty";
403
+ /**
404
+ * Present when the checkbox is checked (when wrapped in FieldRoot).
405
+ */
406
+ CheckboxRootDataAttributes["filled"] = "data-filled";
407
+ /**
408
+ * Present when the checkbox is focused (when wrapped in FieldRoot).
409
+ */
410
+ CheckboxRootDataAttributes["focused"] = "data-focused";
411
+ /**
412
+ * Present when the checkbox is acting as the parent checkbox for a group.
413
+ */
414
+ CheckboxRootDataAttributes["parent"] = "data-parent";
415
+ return CheckboxRootDataAttributes;
416
+ }({});
417
+
418
+ //#endregion
419
+ //#region src/checkbox/utils/useStateAttributesMapping.ts
420
+ const CHECKED_ATTRS = { [CheckboxRootDataAttributes.checked]: "" };
421
+ const UNCHECKED_ATTRS = { [CheckboxRootDataAttributes.unchecked]: "" };
422
+ function useCheckboxStateAttributesMapping(state) {
423
+ return {
424
+ checked(value) {
425
+ if (state.value.indeterminate) return null;
426
+ if (value) return CHECKED_ATTRS;
427
+ return UNCHECKED_ATTRS;
428
+ },
429
+ ...require_checkbox_group_CheckboxGroup.fieldValidityMapping
430
+ };
431
+ }
432
+
433
+ //#endregion
434
+ //#region src/checkbox/indicator/CheckboxIndicator.vue?vue&type=script&setup=true&lang.ts
435
+ /**
436
+ * Indicates whether the checkbox is ticked.
437
+ * Renders a `<span>` element.
438
+ *
439
+ * Documentation: [Base UI Vue Checkbox](https://baseui-vue.com/docs/components/checkbox)
440
+ */
441
+ var CheckboxIndicator_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
442
+ name: "CheckboxIndicator",
443
+ inheritAttrs: false,
444
+ __name: "CheckboxIndicator",
445
+ props: {
446
+ keepMounted: {
447
+ type: Boolean,
448
+ required: false,
449
+ default: false
450
+ },
451
+ as: {
452
+ type: null,
453
+ required: false,
454
+ default: "span"
455
+ },
456
+ class: {
457
+ type: Function,
458
+ required: false,
459
+ skipCheck: true
460
+ },
461
+ style: {
462
+ type: [
463
+ Boolean,
464
+ null,
465
+ String,
466
+ Object,
467
+ Array,
468
+ Function
469
+ ],
470
+ required: false,
471
+ skipCheck: true
472
+ }
473
+ },
474
+ setup(__props) {
475
+ const props = __props;
476
+ const attrsObject = (0, vue.useAttrs)();
477
+ const rootState = useCheckboxRootContext();
478
+ const rendered = (0, vue.computed)(() => rootState.value.checked || rootState.value.indeterminate);
479
+ const { mounted, transitionStatus, setMounted } = useTransitionStatus(rendered);
480
+ const localIndicatorRef = (0, vue.ref)(null);
481
+ const state = (0, vue.computed)(() => ({
482
+ ...rootState.value,
483
+ transitionStatus: transitionStatus.value
484
+ }));
485
+ useOpenChangeComplete({
486
+ open: rendered,
487
+ ref: localIndicatorRef,
488
+ onComplete() {
489
+ if (!rendered.value) setMounted(false);
490
+ }
491
+ });
492
+ const stateAttributesMapping = {
493
+ ...useCheckboxStateAttributesMapping(rootState),
494
+ ...transitionStatusMapping,
495
+ ...require_checkbox_group_CheckboxGroup.fieldValidityMapping
496
+ };
497
+ const shouldRender = (0, vue.computed)(() => props.keepMounted || mounted.value);
498
+ const { tag, mergedProps, renderless, ref: renderRef } = require_button_Button.useRenderElement({
499
+ componentProps: props,
500
+ state,
501
+ props: (0, vue.computed)(() => attrsObject),
502
+ stateAttributesMapping,
503
+ defaultTagName: "span",
504
+ ref: localIndicatorRef
505
+ });
506
+ return (_ctx, _cache) => {
507
+ return shouldRender.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 0 }, [(0, vue.unref)(renderless) ? (0, vue.renderSlot)(_ctx.$slots, "default", {
508
+ key: 0,
509
+ ref: (0, vue.unref)(renderRef),
510
+ props: (0, vue.unref)(mergedProps),
511
+ state: state.value
512
+ }) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)((0, vue.unref)(tag)), (0, vue.mergeProps)({
513
+ key: 1,
514
+ ref: (0, vue.unref)(renderRef)
515
+ }, (0, vue.unref)(mergedProps)), {
516
+ default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default", { state: state.value })]),
517
+ _: 3
518
+ }, 16))], 64)) : (0, vue.createCommentVNode)("v-if", true);
519
+ };
520
+ }
521
+ });
522
+
523
+ //#endregion
524
+ //#region src/checkbox/indicator/CheckboxIndicator.vue
525
+ var CheckboxIndicator_default = CheckboxIndicator_vue_vue_type_script_setup_true_lang_default;
526
+
527
+ //#endregion
528
+ //#region src/field/item/FieldItemContext.ts
529
+ const defaultContext = { disabled: (0, vue.ref)(false) };
530
+ const fieldItemContextKey = Symbol("FieldItemContext");
531
+ function useFieldItemContext() {
532
+ return (0, vue.inject)(fieldItemContextKey, defaultContext);
533
+ }
534
+
535
+ //#endregion
536
+ //#region src/labelable-provider/useAriaLabelledBy.ts
537
+ function useAriaLabelledBy(params) {
538
+ const { ariaLabelledBy, labelId, labelSourceRef, enableFallback = true, labelSourceId } = params;
539
+ const fallbackAriaLabelledBy = (0, vue.ref)(void 0);
540
+ const generatedLabelId = (0, vue.computed)(() => {
541
+ const sourceId = (0, vue.toValue)(labelSourceId);
542
+ return sourceId ? `${sourceId}-label` : void 0;
543
+ });
544
+ const resolvedAriaLabelledBy = (0, vue.computed)(() => {
545
+ const explicit = ariaLabelledBy?.value;
546
+ const fromContext = labelId?.value;
547
+ return explicit ?? fromContext ?? fallbackAriaLabelledBy.value;
548
+ });
549
+ (0, vue.watchPostEffect)(() => {
550
+ if (ariaLabelledBy?.value || labelId?.value || !enableFallback) {
551
+ fallbackAriaLabelledBy.value = void 0;
552
+ return;
553
+ }
554
+ const next = getAriaLabelledBy(labelSourceRef.value, generatedLabelId.value);
555
+ if (fallbackAriaLabelledBy.value !== next) fallbackAriaLabelledBy.value = next;
556
+ });
557
+ return resolvedAriaLabelledBy;
558
+ }
559
+ function getAriaLabelledBy(labelSource, generatedLabelId) {
560
+ const label = findAssociatedLabel(labelSource);
561
+ if (!label) return;
562
+ if (!label.id && generatedLabelId) label.id = generatedLabelId;
563
+ return label.id || void 0;
564
+ }
565
+ function findAssociatedLabel(labelSource) {
566
+ if (!labelSource) return;
567
+ const parent = labelSource.parentElement;
568
+ if (parent && parent.tagName === "LABEL") return parent;
569
+ const controlId = labelSource.id;
570
+ if (controlId) {
571
+ const nextSibling = labelSource.nextElementSibling;
572
+ if (nextSibling && nextSibling.htmlFor === controlId) return nextSibling;
573
+ }
574
+ const labels = labelSource.labels;
575
+ return labels && labels[0] ? labels[0] : void 0;
576
+ }
577
+
578
+ //#endregion
579
+ //#region src/utils/visuallyHidden.ts
580
+ const visuallyHiddenBase = {
581
+ clipPath: "inset(50%)",
582
+ overflow: "hidden",
583
+ whiteSpace: "nowrap",
584
+ border: 0,
585
+ padding: 0,
586
+ width: 1,
587
+ height: 1,
588
+ margin: -1
589
+ };
590
+ const visuallyHidden = {
591
+ ...visuallyHiddenBase,
592
+ position: "fixed",
593
+ top: 0,
594
+ left: 0
595
+ };
596
+ const visuallyHiddenInput = {
597
+ ...visuallyHiddenBase,
598
+ position: "absolute"
599
+ };
600
+
601
+ //#endregion
602
+ //#region src/checkbox/root/CheckboxRoot.vue?vue&type=script&setup=true&lang.ts
603
+ const _hoisted_1 = [
604
+ "form",
605
+ "name",
606
+ "value"
607
+ ];
608
+ /**
609
+ * Represents the checkbox itself.
610
+ * Renders a `<span>` element and a hidden `<input>` beside.
611
+ *
612
+ * Documentation: [Base UI Vue Checkbox](https://baseui-vue.com/docs/components/checkbox)
613
+ */
614
+ var CheckboxRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
615
+ name: "CheckboxRoot",
616
+ inheritAttrs: false,
617
+ __name: "CheckboxRoot",
618
+ props: {
619
+ id: {
620
+ type: String,
621
+ required: false
622
+ },
623
+ name: {
624
+ type: String,
625
+ required: false
626
+ },
627
+ form: {
628
+ type: String,
629
+ required: false
630
+ },
631
+ checked: {
632
+ type: Boolean,
633
+ required: false
634
+ },
635
+ defaultChecked: {
636
+ type: Boolean,
637
+ required: false,
638
+ default: false
639
+ },
640
+ disabled: {
641
+ type: Boolean,
642
+ required: false,
643
+ default: false
644
+ },
645
+ readOnly: {
646
+ type: Boolean,
647
+ required: false,
648
+ default: false
649
+ },
650
+ required: {
651
+ type: Boolean,
652
+ required: false,
653
+ default: false
654
+ },
655
+ indeterminate: {
656
+ type: Boolean,
657
+ required: false,
658
+ default: false
659
+ },
660
+ inputRef: {
661
+ type: null,
662
+ required: false
663
+ },
664
+ parent: {
665
+ type: Boolean,
666
+ required: false,
667
+ default: false
668
+ },
669
+ uncheckedValue: {
670
+ type: String,
671
+ required: false
672
+ },
673
+ value: {
674
+ type: String,
675
+ required: false
676
+ },
677
+ "aria-labelledby": {
678
+ type: String,
679
+ required: false
680
+ },
681
+ nativeButton: {
682
+ type: Boolean,
683
+ required: false,
684
+ default: false
685
+ },
686
+ as: {
687
+ type: null,
688
+ required: false,
689
+ default: "span"
690
+ },
691
+ class: {
692
+ type: Function,
693
+ required: false,
694
+ skipCheck: true
695
+ },
696
+ style: {
697
+ type: [
698
+ Boolean,
699
+ null,
700
+ String,
701
+ Object,
702
+ Array,
703
+ Function
704
+ ],
705
+ required: false,
706
+ skipCheck: true
707
+ }
708
+ },
709
+ emits: ["checkedChange"],
710
+ setup(__props, { emit: __emit }) {
711
+ const props = __props;
712
+ const emit = __emit;
713
+ const attrsObject = (0, vue.useAttrs)();
714
+ const instance = (0, vue.getCurrentInstance)();
715
+ const controlSource = Symbol("checkbox-control");
716
+ const { clearErrors } = require_checkbox_group_CheckboxGroup.useFormContext();
717
+ const { disabled: rootDisabled, name: fieldName, setDirty, setFilled, setFocused, setTouched, state: fieldState, validationMode, validityData, shouldValidateOnChange, validation: localValidation } = require_checkbox_group_CheckboxGroup.useFieldRootContext();
718
+ const fieldItemContext = useFieldItemContext();
719
+ const labelableContext = require_checkbox_group_CheckboxGroup.useLabelableContext();
720
+ const groupContext = require_checkbox_group_CheckboxGroup.useCheckboxGroupContext(true);
721
+ const parentContext = (0, vue.computed)(() => groupContext?.parent);
722
+ const isGroupedWithParent = (0, vue.computed)(() => Boolean(parentContext.value && groupContext && groupContext.allValues.value !== void 0));
723
+ const disabled = (0, vue.computed)(() => rootDisabled.value || fieldItemContext.disabled.value || groupContext?.disabled.value || props.disabled);
724
+ const name = (0, vue.computed)(() => fieldName.value ?? props.name);
725
+ const checkboxValue = (0, vue.computed)(() => props.value !== void 0 ? props.value : name.value);
726
+ const rootElementId = require_checkbox_group_CheckboxGroup.useBaseUiId();
727
+ const generatedInputId = require_checkbox_group_CheckboxGroup.useBaseUiId();
728
+ const groupParentId = require_checkbox_group_CheckboxGroup.useBaseUiId();
729
+ const inputId = (0, vue.computed)(() => {
730
+ if (isGroupedWithParent.value && parentContext.value) {
731
+ if (props.parent) return parentContext.value.id ?? groupParentId;
732
+ }
733
+ if (props.id) return props.id;
734
+ return labelableContext.controlId.value ?? generatedInputId;
735
+ });
736
+ (0, vue.watchEffect)((onCleanup) => {
737
+ labelableContext.registerControlId(controlSource, inputId.value);
738
+ onCleanup(() => {
739
+ labelableContext.registerControlId(controlSource, void 0);
740
+ });
741
+ });
742
+ (0, vue.watch)(() => ({
743
+ groupedWithParent: isGroupedWithParent.value,
744
+ checkboxValue: checkboxValue.value,
745
+ inputId: inputId.value,
746
+ isParent: props.parent
747
+ }), (nextState, _prevState, onCleanup) => {
748
+ if (!nextState.groupedWithParent || !groupContext || nextState.isParent || nextState.checkboxValue === void 0) return;
749
+ groupContext.parent.registerChildControlId(nextState.checkboxValue, nextState.inputId);
750
+ onCleanup(() => {
751
+ groupContext.parent.registerChildControlId(nextState.checkboxValue, void 0);
752
+ });
753
+ }, { immediate: true });
754
+ const groupProps = (0, vue.computed)(() => {
755
+ if (!isGroupedWithParent.value || !groupContext) return {};
756
+ if (props.parent) return groupContext.parent.getParentProps();
757
+ if (checkboxValue.value !== void 0) return groupContext.parent.getChildProps(checkboxValue.value);
758
+ return {};
759
+ });
760
+ const hasCheckedProp = (0, vue.computed)(() => Boolean(instance?.vnode.props && Object.prototype.hasOwnProperty.call(instance.vnode.props, "checked")));
761
+ const groupChecked = (0, vue.computed)(() => {
762
+ const checked = groupProps.value.checked;
763
+ return checked === void 0 ? hasCheckedProp.value ? props.checked : void 0 : checked;
764
+ });
765
+ const groupIndeterminate = (0, vue.computed)(() => {
766
+ const indeterminate = groupProps.value.indeterminate;
767
+ return indeterminate === void 0 ? props.indeterminate : indeterminate;
768
+ });
769
+ const validation = groupContext?.validation ?? localValidation;
770
+ const { value: checked, setValue: setCheckedState } = require_checkbox_group_CheckboxGroup.useControllableState({
771
+ controlled: () => {
772
+ if (groupContext && !props.parent && checkboxValue.value !== void 0) return groupContext.value.value.includes(checkboxValue.value);
773
+ return groupChecked.value;
774
+ },
775
+ default: () => groupContext && !props.parent && checkboxValue.value !== void 0 ? groupContext.defaultValue.value.includes(checkboxValue.value) : props.defaultChecked,
776
+ name: "CheckboxRoot",
777
+ state: "checked"
778
+ });
779
+ const computedChecked = (0, vue.computed)(() => isGroupedWithParent.value ? Boolean(groupChecked.value) : checked.value);
780
+ const computedIndeterminate = (0, vue.computed)(() => isGroupedWithParent.value ? Boolean(groupIndeterminate.value || props.indeterminate) : props.indeterminate);
781
+ const controlRef = (0, vue.ref)(null);
782
+ const inputElementRef = (0, vue.ref)(null);
783
+ require_checkbox_group_CheckboxGroup.useField({
784
+ enabled: (0, vue.computed)(() => !groupContext),
785
+ id: (0, vue.computed)(() => rootElementId),
786
+ commit: (value) => validation.commit(value),
787
+ value: checked,
788
+ controlRef,
789
+ name,
790
+ getValue: () => checked.value
791
+ });
792
+ const ariaLabelledBy = useAriaLabelledBy({
793
+ ariaLabelledBy: (0, vue.computed)(() => props["aria-labelledby"]),
794
+ labelId: labelableContext.labelId,
795
+ labelSourceRef: inputElementRef,
796
+ enableFallback: !props.nativeButton,
797
+ labelSourceId: inputId
798
+ });
799
+ (0, vue.watchEffect)(() => {
800
+ if (inputElementRef.value) inputElementRef.value.indeterminate = computedIndeterminate.value;
801
+ });
802
+ (0, vue.watchEffect)(() => {
803
+ if (computedChecked.value) setFilled(true);
804
+ });
805
+ (0, vue.watchEffect)(() => {
806
+ if (!inputElementRef.value) return;
807
+ validation.setInputRef(inputElementRef.value);
808
+ });
809
+ (0, vue.watch)(() => checked.value, (nextChecked) => {
810
+ if (groupContext) return;
811
+ clearErrors(name.value);
812
+ setFilled(nextChecked);
813
+ setDirty(nextChecked !== validityData.value.initialValue);
814
+ if (shouldValidateOnChange()) validation.commit(nextChecked);
815
+ else validation.commit(nextChecked, true);
816
+ }, { flush: "sync" });
817
+ (0, vue.watch)(() => ({
818
+ parentContext: parentContext.value,
819
+ checkboxValue: checkboxValue.value,
820
+ disabled: disabled.value
821
+ }), (nextState, _prevState, onCleanup) => {
822
+ if (!nextState.parentContext || nextState.checkboxValue === void 0) return;
823
+ const checkboxKey = nextState.checkboxValue;
824
+ const nextDisabledStates = new Map(nextState.parentContext.disabledStatesRef.value);
825
+ nextDisabledStates.set(checkboxKey, nextState.disabled);
826
+ nextState.parentContext.disabledStatesRef.value = nextDisabledStates;
827
+ onCleanup(() => {
828
+ if (!nextState.parentContext) return;
829
+ const cleanupDisabledStates = new Map(nextState.parentContext.disabledStatesRef.value);
830
+ cleanupDisabledStates.delete(checkboxKey);
831
+ nextState.parentContext.disabledStatesRef.value = cleanupDisabledStates;
832
+ });
833
+ }, { immediate: true });
834
+ const { getButtonProps, buttonRef } = require_button_Button.useButton({
835
+ disabled,
836
+ native: (0, vue.computed)(() => props.nativeButton)
837
+ });
838
+ function combineDescriptionProps(localProps, validationProps) {
839
+ const localDescribedBy = localProps["aria-describedby"];
840
+ const validationDescribedBy = validationProps["aria-describedby"];
841
+ const describedBy = Array.from(new Set([localDescribedBy, validationDescribedBy].filter(Boolean).flatMap((value) => String(value).split(/\s+/).filter(Boolean)))).join(" ") || void 0;
842
+ return {
843
+ ...localProps,
844
+ ...validationProps,
845
+ "aria-describedby": describedBy
846
+ };
847
+ }
848
+ function applyCheckedChange(nextChecked, event, onApplied) {
849
+ const details = createChangeEventDetails(REASONS.none, event);
850
+ emit("checkedChange", nextChecked, details);
851
+ if (details.isCanceled) return false;
852
+ groupProps.value.onCheckedChange?.(nextChecked, details);
853
+ onApplied?.();
854
+ setCheckedState(nextChecked);
855
+ if (groupContext && !isGroupedWithParent.value && !props.parent && checkboxValue.value !== void 0) {
856
+ const currentValue = groupContext.value.value.slice();
857
+ const nextValue = nextChecked ? Array.from(new Set([...currentValue, checkboxValue.value])) : currentValue.filter((item) => item !== checkboxValue.value);
858
+ groupContext.setValue(nextValue, details);
859
+ }
860
+ return true;
861
+ }
862
+ function handleInputChange(event) {
863
+ const target = event.currentTarget;
864
+ if (props.readOnly || disabled.value || !props.parent && props.indeterminate && !groupContext) {
865
+ event.preventDefault();
866
+ event.stopPropagation();
867
+ target.checked = computedChecked.value;
868
+ target.indeterminate = computedIndeterminate.value;
869
+ return;
870
+ }
871
+ if (!applyCheckedChange(target.checked, event)) {
872
+ target.checked = computedChecked.value;
873
+ target.indeterminate = computedIndeterminate.value;
874
+ }
875
+ }
876
+ function handleRootClick(event) {
877
+ if (props.readOnly || disabled.value || !props.parent && props.indeterminate) return;
878
+ event.preventDefault();
879
+ const nextChecked = !computedChecked.value;
880
+ applyCheckedChange(nextChecked, event, () => {
881
+ if (inputElementRef.value) inputElementRef.value.checked = nextChecked;
882
+ });
883
+ }
884
+ function handleFocus() {
885
+ setFocused(true);
886
+ }
887
+ function handleBlur() {
888
+ setTouched(true);
889
+ setFocused(false);
890
+ if (validationMode.value === "onBlur") validation.commit(groupContext ? groupContext.value.value : checked.value);
891
+ }
892
+ const state = (0, vue.computed)(() => ({
893
+ ...fieldState.value,
894
+ checked: computedChecked.value,
895
+ disabled: disabled.value,
896
+ readOnly: props.readOnly,
897
+ required: props.required,
898
+ indeterminate: computedIndeterminate.value
899
+ }));
900
+ (0, vue.provide)(checkboxRootContextKey, state);
901
+ const stateAttributesMapping = useCheckboxStateAttributesMapping(state);
902
+ const mergedRootRef = require_button_Button.useMergedRefs(buttonRef, controlRef, groupContext?.registerControlRef);
903
+ const { tag, mergedProps, renderless, ref: renderRef } = require_button_Button.useRenderElement({
904
+ componentProps: props,
905
+ state,
906
+ props: (0, vue.computed)(() => {
907
+ const localDescriptionProps = labelableContext.getDescriptionProps();
908
+ const validationProps = validation.getValidationProps();
909
+ return require_button_Button.mergeProps(getButtonProps({ onClick: handleRootClick }), combineDescriptionProps(localDescriptionProps, validationProps), groupProps.value["aria-controls"] ? { "aria-controls": groupProps.value["aria-controls"] } : require_button_Button.EMPTY_OBJECT, {
910
+ "id": groupProps.value.id ?? (props.nativeButton ? inputId.value : rootElementId),
911
+ "role": "checkbox",
912
+ "aria-checked": computedIndeterminate.value ? "mixed" : computedChecked.value,
913
+ "aria-readonly": props.readOnly || void 0,
914
+ "aria-required": props.required || void 0,
915
+ "aria-labelledby": ariaLabelledBy.value,
916
+ "data-parent": props.parent ? "" : void 0,
917
+ "onFocus": handleFocus,
918
+ "onBlur": handleBlur
919
+ }, attrsObject);
920
+ }),
921
+ stateAttributesMapping,
922
+ defaultTagName: "span",
923
+ ref: mergedRootRef
924
+ });
925
+ const inputProps = (0, vue.computed)(() => {
926
+ const localDescriptionProps = labelableContext.getDescriptionProps();
927
+ const validationProps = groupContext ? validation.getValidationProps() : validation.getInputValidationProps();
928
+ return require_button_Button.mergeProps({
929
+ "checked": computedChecked.value,
930
+ "disabled": disabled.value,
931
+ "form": props.form,
932
+ "name": props.parent ? void 0 : name.value,
933
+ "id": props.nativeButton ? void 0 : inputId.value,
934
+ "required": props.required,
935
+ "ref": require_button_Button.useMergedRefs(inputElementRef, props.inputRef),
936
+ "type": "checkbox",
937
+ "aria-hidden": true,
938
+ "tabindex": -1,
939
+ "style": name.value ? visuallyHiddenInput : visuallyHidden,
940
+ "onChange": handleInputChange,
941
+ onFocus() {
942
+ controlRef.value?.focus();
943
+ }
944
+ }, checkboxValue.value !== void 0 ? { value: groupContext ? computedChecked.value ? checkboxValue.value : "" : checkboxValue.value } : require_button_Button.EMPTY_OBJECT, combineDescriptionProps(localDescriptionProps, validationProps));
945
+ });
946
+ return (_ctx, _cache) => {
947
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, null, [
948
+ (0, vue.unref)(renderless) ? (0, vue.renderSlot)(_ctx.$slots, "default", {
949
+ key: 0,
950
+ ref: (0, vue.unref)(renderRef),
951
+ props: (0, vue.unref)(mergedProps),
952
+ state: state.value
953
+ }) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)((0, vue.unref)(tag)), (0, vue.mergeProps)({
954
+ key: 1,
955
+ ref: (0, vue.unref)(renderRef)
956
+ }, (0, vue.unref)(mergedProps)), {
957
+ default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default", { state: state.value })]),
958
+ _: 3
959
+ }, 16)),
960
+ !computedChecked.value && !(0, vue.unref)(groupContext) && name.value && !__props.parent && __props.uncheckedValue !== void 0 ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("input", {
961
+ key: 2,
962
+ type: "hidden",
963
+ form: __props.form,
964
+ name: name.value,
965
+ value: __props.uncheckedValue
966
+ }, null, 8, _hoisted_1)) : (0, vue.createCommentVNode)("v-if", true),
967
+ (0, vue.createElementVNode)("input", (0, vue.normalizeProps)((0, vue.guardReactiveProps)(inputProps.value)), null, 16)
968
+ ], 64);
969
+ };
970
+ }
971
+ });
972
+
973
+ //#endregion
974
+ //#region src/checkbox/root/CheckboxRoot.vue
975
+ var CheckboxRoot_default = CheckboxRoot_vue_vue_type_script_setup_true_lang_default;
976
+
977
+ //#endregion
978
+ //#region src/checkbox/indicator/CheckboxIndicatorDataAttributes.ts
979
+ let CheckboxIndicatorDataAttributes = /* @__PURE__ */ function(CheckboxIndicatorDataAttributes) {
980
+ /**
981
+ * Present when the checkbox is checked.
982
+ */
983
+ CheckboxIndicatorDataAttributes["checked"] = "data-checked";
984
+ /**
985
+ * Present when the checkbox is not checked.
986
+ */
987
+ CheckboxIndicatorDataAttributes["unchecked"] = "data-unchecked";
988
+ /**
989
+ * Present when the checkbox is in an indeterminate state.
990
+ */
991
+ CheckboxIndicatorDataAttributes["indeterminate"] = "data-indeterminate";
992
+ /**
993
+ * Present when the checkbox is disabled.
994
+ */
995
+ CheckboxIndicatorDataAttributes["disabled"] = "data-disabled";
996
+ /**
997
+ * Present when the checkbox is readonly.
998
+ */
999
+ CheckboxIndicatorDataAttributes["readonly"] = "data-readonly";
1000
+ /**
1001
+ * Present when the checkbox is required.
1002
+ */
1003
+ CheckboxIndicatorDataAttributes["required"] = "data-required";
1004
+ /**
1005
+ * Present when the checkbox indicator is animating in.
1006
+ */
1007
+ CheckboxIndicatorDataAttributes[CheckboxIndicatorDataAttributes["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
1008
+ /**
1009
+ * Present when the checkbox indicator is animating out.
1010
+ */
1011
+ CheckboxIndicatorDataAttributes[CheckboxIndicatorDataAttributes["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
1012
+ /**
1013
+ * Present when the checkbox is in valid state (when wrapped in FieldRoot).
1014
+ */
1015
+ CheckboxIndicatorDataAttributes["valid"] = "data-valid";
1016
+ /**
1017
+ * Present when the checkbox is in invalid state (when wrapped in FieldRoot).
1018
+ */
1019
+ CheckboxIndicatorDataAttributes["invalid"] = "data-invalid";
1020
+ /**
1021
+ * Present when the checkbox has been touched (when wrapped in FieldRoot).
1022
+ */
1023
+ CheckboxIndicatorDataAttributes["touched"] = "data-touched";
1024
+ /**
1025
+ * Present when the checkbox's value has changed (when wrapped in FieldRoot).
1026
+ */
1027
+ CheckboxIndicatorDataAttributes["dirty"] = "data-dirty";
1028
+ /**
1029
+ * Present when the checkbox is checked (when wrapped in FieldRoot).
1030
+ */
1031
+ CheckboxIndicatorDataAttributes["filled"] = "data-filled";
1032
+ /**
1033
+ * Present when the checkbox is focused (when wrapped in FieldRoot).
1034
+ */
1035
+ CheckboxIndicatorDataAttributes["focused"] = "data-focused";
1036
+ return CheckboxIndicatorDataAttributes;
1037
+ }({});
1038
+
1039
+ //#endregion
1040
+ //#region src/checkbox/index.ts
1041
+ const Checkbox = {
1042
+ Root: CheckboxRoot_default,
1043
+ Indicator: CheckboxIndicator_default
1044
+ };
1045
+
1046
+ //#endregion
1047
+ Object.defineProperty(exports, 'AnimationFrame', {
1048
+ enumerable: true,
1049
+ get: function () {
1050
+ return AnimationFrame;
1051
+ }
1052
+ });
1053
+ Object.defineProperty(exports, 'Checkbox', {
1054
+ enumerable: true,
1055
+ get: function () {
1056
+ return Checkbox;
1057
+ }
1058
+ });
1059
+ Object.defineProperty(exports, 'CheckboxIndicatorDataAttributes', {
1060
+ enumerable: true,
1061
+ get: function () {
1062
+ return CheckboxIndicatorDataAttributes;
1063
+ }
1064
+ });
1065
+ Object.defineProperty(exports, 'CheckboxIndicator_default', {
1066
+ enumerable: true,
1067
+ get: function () {
1068
+ return CheckboxIndicator_default;
1069
+ }
1070
+ });
1071
+ Object.defineProperty(exports, 'CheckboxRootDataAttributes', {
1072
+ enumerable: true,
1073
+ get: function () {
1074
+ return CheckboxRootDataAttributes;
1075
+ }
1076
+ });
1077
+ Object.defineProperty(exports, 'CheckboxRoot_default', {
1078
+ enumerable: true,
1079
+ get: function () {
1080
+ return CheckboxRoot_default;
1081
+ }
1082
+ });
1083
+ Object.defineProperty(exports, 'REASONS', {
1084
+ enumerable: true,
1085
+ get: function () {
1086
+ return REASONS;
1087
+ }
1088
+ });
1089
+ Object.defineProperty(exports, 'checkboxRootContextKey', {
1090
+ enumerable: true,
1091
+ get: function () {
1092
+ return checkboxRootContextKey;
1093
+ }
1094
+ });
1095
+ Object.defineProperty(exports, 'createChangeEventDetails', {
1096
+ enumerable: true,
1097
+ get: function () {
1098
+ return createChangeEventDetails;
1099
+ }
1100
+ });
1101
+ Object.defineProperty(exports, 'createGenericEventDetails', {
1102
+ enumerable: true,
1103
+ get: function () {
1104
+ return createGenericEventDetails;
1105
+ }
1106
+ });
1107
+ Object.defineProperty(exports, 'fieldItemContextKey', {
1108
+ enumerable: true,
1109
+ get: function () {
1110
+ return fieldItemContextKey;
1111
+ }
1112
+ });
1113
+ Object.defineProperty(exports, 'transitionStatusMapping', {
1114
+ enumerable: true,
1115
+ get: function () {
1116
+ return transitionStatusMapping;
1117
+ }
1118
+ });
1119
+ Object.defineProperty(exports, 'useAnimationFrame', {
1120
+ enumerable: true,
1121
+ get: function () {
1122
+ return useAnimationFrame;
1123
+ }
1124
+ });
1125
+ Object.defineProperty(exports, 'useAnimationsFinished', {
1126
+ enumerable: true,
1127
+ get: function () {
1128
+ return useAnimationsFinished;
1129
+ }
1130
+ });
1131
+ Object.defineProperty(exports, 'useAriaLabelledBy', {
1132
+ enumerable: true,
1133
+ get: function () {
1134
+ return useAriaLabelledBy;
1135
+ }
1136
+ });
1137
+ Object.defineProperty(exports, 'useCheckboxRootContext', {
1138
+ enumerable: true,
1139
+ get: function () {
1140
+ return useCheckboxRootContext;
1141
+ }
1142
+ });
1143
+ Object.defineProperty(exports, 'useFieldItemContext', {
1144
+ enumerable: true,
1145
+ get: function () {
1146
+ return useFieldItemContext;
1147
+ }
1148
+ });
1149
+ Object.defineProperty(exports, 'useOpenChangeComplete', {
1150
+ enumerable: true,
1151
+ get: function () {
1152
+ return useOpenChangeComplete;
1153
+ }
1154
+ });
1155
+ Object.defineProperty(exports, 'useTransitionStatus', {
1156
+ enumerable: true,
1157
+ get: function () {
1158
+ return useTransitionStatus;
1159
+ }
1160
+ });
1161
+ Object.defineProperty(exports, 'visuallyHidden', {
1162
+ enumerable: true,
1163
+ get: function () {
1164
+ return visuallyHidden;
1165
+ }
1166
+ });
1167
+ Object.defineProperty(exports, 'visuallyHiddenInput', {
1168
+ enumerable: true,
1169
+ get: function () {
1170
+ return visuallyHiddenInput;
1171
+ }
1172
+ });
1173
+ //# sourceMappingURL=index.cjs.map