akar 2.0.12 → 2.0.14

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 (152) hide show
  1. package/dist/AlertDialog/AlertDialogContent.cjs +2 -1
  2. package/dist/AlertDialog/AlertDialogContent.cjs.map +1 -1
  3. package/dist/AlertDialog/AlertDialogContent.js +2 -1
  4. package/dist/AlertDialog/AlertDialogContent.js.map +1 -1
  5. package/dist/Calendar/CalendarCellTrigger.cjs +3 -2
  6. package/dist/Calendar/CalendarCellTrigger.cjs.map +1 -1
  7. package/dist/Calendar/CalendarCellTrigger.js +4 -3
  8. package/dist/Calendar/CalendarCellTrigger.js.map +1 -1
  9. package/dist/Checkbox/CheckboxRoot.cjs +27 -18
  10. package/dist/Checkbox/CheckboxRoot.cjs.map +1 -1
  11. package/dist/Checkbox/CheckboxRoot.js +28 -19
  12. package/dist/Checkbox/CheckboxRoot.js.map +1 -1
  13. package/dist/ConfigProvider/ConfigProvider.cjs +6 -1
  14. package/dist/ConfigProvider/ConfigProvider.cjs.map +1 -1
  15. package/dist/ConfigProvider/ConfigProvider.js +6 -1
  16. package/dist/ConfigProvider/ConfigProvider.js.map +1 -1
  17. package/dist/FocusScope/FocusScope.cjs +2 -1
  18. package/dist/FocusScope/FocusScope.cjs.map +1 -1
  19. package/dist/FocusScope/FocusScope.js +2 -1
  20. package/dist/FocusScope/FocusScope.js.map +1 -1
  21. package/dist/Listbox/ListboxRoot.cjs +1 -0
  22. package/dist/Listbox/ListboxRoot.cjs.map +1 -1
  23. package/dist/Listbox/ListboxRoot.js +1 -0
  24. package/dist/Listbox/ListboxRoot.js.map +1 -1
  25. package/dist/Menu/MenuContentImpl.cjs +2 -1
  26. package/dist/Menu/MenuContentImpl.cjs.map +1 -1
  27. package/dist/Menu/MenuContentImpl.js +2 -1
  28. package/dist/Menu/MenuContentImpl.js.map +1 -1
  29. package/dist/MonthPicker/MonthPickerCellTrigger.cjs +3 -2
  30. package/dist/MonthPicker/MonthPickerCellTrigger.cjs.map +1 -1
  31. package/dist/MonthPicker/MonthPickerCellTrigger.js +4 -3
  32. package/dist/MonthPicker/MonthPickerCellTrigger.js.map +1 -1
  33. package/dist/MonthRangePicker/MonthRangePickerCellTrigger.cjs +3 -2
  34. package/dist/MonthRangePicker/MonthRangePickerCellTrigger.cjs.map +1 -1
  35. package/dist/MonthRangePicker/MonthRangePickerCellTrigger.js +4 -3
  36. package/dist/MonthRangePicker/MonthRangePickerCellTrigger.js.map +1 -1
  37. package/dist/NumberField/NumberFieldRoot.cjs +27 -5
  38. package/dist/NumberField/NumberFieldRoot.cjs.map +1 -1
  39. package/dist/NumberField/NumberFieldRoot.js +27 -5
  40. package/dist/NumberField/NumberFieldRoot.js.map +1 -1
  41. package/dist/Presence/usePresence.cjs +6 -0
  42. package/dist/Presence/usePresence.cjs.map +1 -1
  43. package/dist/Presence/usePresence.js +6 -0
  44. package/dist/Presence/usePresence.js.map +1 -1
  45. package/dist/RadioGroup/Radio.cjs +27 -22
  46. package/dist/RadioGroup/Radio.cjs.map +1 -1
  47. package/dist/RadioGroup/Radio.js +28 -23
  48. package/dist/RadioGroup/Radio.js.map +1 -1
  49. package/dist/RadioGroup/RadioGroupItem.cjs +3 -0
  50. package/dist/RadioGroup/RadioGroupItem.cjs.map +1 -1
  51. package/dist/RadioGroup/RadioGroupItem.js +3 -0
  52. package/dist/RadioGroup/RadioGroupItem.js.map +1 -1
  53. package/dist/RangeCalendar/RangeCalendarCellTrigger.cjs +1 -0
  54. package/dist/RangeCalendar/RangeCalendarCellTrigger.cjs.map +1 -1
  55. package/dist/RangeCalendar/RangeCalendarCellTrigger.js +1 -0
  56. package/dist/RangeCalendar/RangeCalendarCellTrigger.js.map +1 -1
  57. package/dist/RovingFocus/RovingFocusItem.cjs +5 -0
  58. package/dist/RovingFocus/RovingFocusItem.cjs.map +1 -1
  59. package/dist/RovingFocus/RovingFocusItem.js +6 -1
  60. package/dist/RovingFocus/RovingFocusItem.js.map +1 -1
  61. package/dist/ScrollArea/ScrollAreaThumb.cjs +2 -2
  62. package/dist/ScrollArea/ScrollAreaThumb.cjs.map +1 -1
  63. package/dist/ScrollArea/ScrollAreaThumb.js +2 -2
  64. package/dist/ScrollArea/ScrollAreaThumb.js.map +1 -1
  65. package/dist/Splitter/SplitterGroup.cjs +2 -2
  66. package/dist/Splitter/SplitterGroup.cjs.map +1 -1
  67. package/dist/Splitter/SplitterGroup.js +2 -2
  68. package/dist/Splitter/SplitterGroup.js.map +1 -1
  69. package/dist/Switch/SwitchRoot.cjs +25 -18
  70. package/dist/Switch/SwitchRoot.cjs.map +1 -1
  71. package/dist/Switch/SwitchRoot.js +26 -19
  72. package/dist/Switch/SwitchRoot.js.map +1 -1
  73. package/dist/Teleport/Teleport.cjs +6 -3
  74. package/dist/Teleport/Teleport.cjs.map +1 -1
  75. package/dist/Teleport/Teleport.js +7 -4
  76. package/dist/Teleport/Teleport.js.map +1 -1
  77. package/dist/Toggle/Toggle.cjs +21 -16
  78. package/dist/Toggle/Toggle.cjs.map +1 -1
  79. package/dist/Toggle/Toggle.js +22 -17
  80. package/dist/Toggle/Toggle.js.map +1 -1
  81. package/dist/ToggleGroup/ToggleGroupItem.cjs +6 -1
  82. package/dist/ToggleGroup/ToggleGroupItem.cjs.map +1 -1
  83. package/dist/ToggleGroup/ToggleGroupItem.js +6 -1
  84. package/dist/ToggleGroup/ToggleGroupItem.js.map +1 -1
  85. package/dist/Toolbar/ToolbarToggleItem.cjs +5 -2
  86. package/dist/Toolbar/ToolbarToggleItem.cjs.map +1 -1
  87. package/dist/Toolbar/ToolbarToggleItem.js +5 -2
  88. package/dist/Toolbar/ToolbarToggleItem.js.map +1 -1
  89. package/dist/VisuallyHidden/VisuallyHidden.cjs +1 -1
  90. package/dist/VisuallyHidden/VisuallyHidden.cjs.map +1 -1
  91. package/dist/VisuallyHidden/VisuallyHidden.js +1 -1
  92. package/dist/VisuallyHidden/VisuallyHidden.js.map +1 -1
  93. package/dist/YearPicker/YearPickerCellTrigger.cjs +3 -2
  94. package/dist/YearPicker/YearPickerCellTrigger.cjs.map +1 -1
  95. package/dist/YearPicker/YearPickerCellTrigger.js +4 -3
  96. package/dist/YearPicker/YearPickerCellTrigger.js.map +1 -1
  97. package/dist/YearRangePicker/YearRangePickerCellTrigger.cjs +3 -2
  98. package/dist/YearRangePicker/YearRangePickerCellTrigger.cjs.map +1 -1
  99. package/dist/YearRangePicker/YearRangePickerCellTrigger.js +4 -3
  100. package/dist/YearRangePicker/YearRangePickerCellTrigger.js.map +1 -1
  101. package/dist/constant.d.cts.map +1 -1
  102. package/dist/index.cjs +1 -0
  103. package/dist/index.js +1 -0
  104. package/dist/index3.d.cts +38 -16
  105. package/dist/index3.d.cts.map +1 -1
  106. package/dist/index3.d.ts +34 -12
  107. package/dist/index3.d.ts.map +1 -1
  108. package/dist/index4.d.cts +689 -681
  109. package/dist/index4.d.cts.map +1 -1
  110. package/dist/index4.d.ts +675 -667
  111. package/dist/index4.d.ts.map +1 -1
  112. package/dist/internal.cjs +1 -0
  113. package/dist/internal.d.cts +2 -2
  114. package/dist/internal.d.cts.map +1 -1
  115. package/dist/internal.d.ts +2 -2
  116. package/dist/internal.js +1 -0
  117. package/dist/shared/useForwardScopeId.cjs +34 -0
  118. package/dist/shared/useForwardScopeId.cjs.map +1 -0
  119. package/dist/shared/useForwardScopeId.js +28 -0
  120. package/dist/shared/useForwardScopeId.js.map +1 -0
  121. package/dist/shared.cjs +2 -0
  122. package/dist/shared.d.cts +2 -2
  123. package/dist/shared.d.ts +2 -2
  124. package/dist/shared.js +2 -1
  125. package/package.json +1 -1
  126. package/src/AlertDialog/AlertDialogContent.vue +9 -1
  127. package/src/Calendar/CalendarCellTrigger.vue +5 -1
  128. package/src/Checkbox/CheckboxRoot.vue +30 -16
  129. package/src/ConfigProvider/ConfigProvider.vue +10 -1
  130. package/src/FocusScope/FocusScope.vue +16 -5
  131. package/src/Listbox/ListboxRoot.vue +6 -0
  132. package/src/Menu/MenuContentImpl.vue +8 -1
  133. package/src/MonthPicker/MonthPickerCellTrigger.vue +5 -1
  134. package/src/MonthRangePicker/MonthRangePickerCellTrigger.vue +6 -1
  135. package/src/NumberField/NumberFieldRoot.vue +51 -23
  136. package/src/Presence/usePresence.ts +8 -0
  137. package/src/RadioGroup/Radio.vue +29 -18
  138. package/src/RadioGroup/RadioGroupItem.vue +15 -6
  139. package/src/RangeCalendar/RangeCalendarCellTrigger.vue +6 -0
  140. package/src/RovingFocus/RovingFocusItem.vue +16 -1
  141. package/src/ScrollArea/ScrollAreaThumb.vue +2 -2
  142. package/src/Splitter/SplitterGroup.vue +4 -2
  143. package/src/Switch/SwitchRoot.vue +29 -18
  144. package/src/Teleport/Teleport.vue +8 -4
  145. package/src/Toggle/Toggle.vue +25 -13
  146. package/src/ToggleGroup/ToggleGroupItem.vue +5 -2
  147. package/src/Toolbar/ToolbarToggleItem.vue +4 -1
  148. package/src/VisuallyHidden/VisuallyHidden.vue +1 -1
  149. package/src/YearPicker/YearPickerCellTrigger.vue +7 -1
  150. package/src/YearRangePicker/YearRangePickerCellTrigger.vue +5 -1
  151. package/src/shared/index.ts +1 -0
  152. package/src/shared/useForwardScopeId.ts +26 -0
@@ -22,15 +22,22 @@ export interface RadioProps extends PrimitiveProps, FormFieldProps {
22
22
  import { useVModel } from '@vueuse/core';
23
23
  import { computed, toRefs } from 'vue';
24
24
  import { Primitive } from '@/Primitive';
25
- import { useFormControl, useForwardExpose } from '@/shared';
25
+ import { useFormControl, useForwardExpose, useForwardScopeId } from '@/shared';
26
26
  import { VisuallyHiddenInput } from '@/VisuallyHidden';
27
27
  import { handleSelect } from './utils';
28
28
 
29
- const props = withDefaults(defineProps<RadioProps>(), {
30
- disabled: false,
31
- checked: undefined,
32
- as: 'button',
29
+ defineOptions({
30
+ inheritAttrs: false,
33
31
  });
32
+
33
+ const props = withDefaults(
34
+ defineProps<RadioProps>(),
35
+ {
36
+ disabled: false,
37
+ checked: undefined,
38
+ as: 'button',
39
+ },
40
+ );
34
41
  const emits = defineEmits<RadioEmits>();
35
42
 
36
43
  defineSlots<{
@@ -47,6 +54,9 @@ const checked = useVModel(props, 'checked', emits, {
47
54
  const { value } = toRefs(props);
48
55
  const { forwardRef, currentElement: triggerElement } = useForwardExpose();
49
56
  const isFormControl = useFormControl(triggerElement);
57
+ // Hidden form input is a sibling (not nested) of the control to avoid the
58
+ // `nested-interactive` a11y violation; forward the parent scope id for scoped styles.
59
+ const scopeIdAttrs = useForwardScopeId();
50
60
 
51
61
  const ariaLabel = computed(() => props.id && triggerElement.value ? (document.querySelector(`[for="${props.id}"]`) as HTMLLabelElement)?.innerText ?? props.value : undefined);
52
62
 
@@ -74,13 +84,12 @@ function handleClick(event: MouseEvent) {
74
84
 
75
85
  <template>
76
86
  <Primitive
77
- v-bind="$attrs"
78
87
  :id="id"
79
88
  :ref="forwardRef"
80
89
  role="radio"
81
90
  :type="as === 'button' ? 'button' : undefined"
82
91
  :as="as"
83
- :aria-checked="checked"
92
+ :aria-checked="checked ?? false"
84
93
  :aria-label="ariaLabel"
85
94
  :as-child="asChild"
86
95
  :disabled="disabled ? '' : undefined"
@@ -89,19 +98,21 @@ function handleClick(event: MouseEvent) {
89
98
  :value="value"
90
99
  :required="required"
91
100
  :name="name"
101
+ v-bind="{ ...scopeIdAttrs, ...$attrs }"
92
102
  @click.stop="handleClick"
93
103
  >
94
104
  <slot :checked="checked" />
95
-
96
- <VisuallyHiddenInput
97
- v-if="isFormControl && name"
98
- type="radio"
99
- tabindex="-1"
100
- :value="value"
101
- :checked="!!checked"
102
- :name="name"
103
- :disabled="disabled"
104
- :required="required"
105
- />
106
105
  </Primitive>
106
+
107
+ <VisuallyHiddenInput
108
+ v-if="isFormControl && name"
109
+ type="radio"
110
+ tabindex="-1"
111
+ :value="value"
112
+ :checked="!!checked"
113
+ :name="name"
114
+ :disabled="disabled"
115
+ :required="required"
116
+ v-bind="scopeIdAttrs"
117
+ />
107
118
  </template>
@@ -2,7 +2,7 @@
2
2
  import type { ComputedRef } from 'vue';
3
3
  import type { RadioProps } from './Radio.vue';
4
4
  import type { SelectEvent } from './utils';
5
- import { createContext, useForwardExpose } from '@/shared';
5
+ import { createContext, useForwardExpose, useForwardScopeId } from '@/shared';
6
6
 
7
7
  export interface RadioGroupItemProps extends Omit<RadioProps, 'checked'> {}
8
8
  export type RadioGroupItemEmits = {
@@ -30,10 +30,13 @@ defineOptions({
30
30
  inheritAttrs: false,
31
31
  });
32
32
 
33
- const props = withDefaults(defineProps<RadioGroupItemProps>(), {
34
- disabled: false,
35
- as: 'button',
36
- });
33
+ const props = withDefaults(
34
+ defineProps<RadioGroupItemProps>(),
35
+ {
36
+ disabled: false,
37
+ as: 'button',
38
+ },
39
+ );
37
40
 
38
41
  const emits = defineEmits<RadioGroupItemEmits>();
39
42
 
@@ -66,6 +69,7 @@ useEventListener('keydown', (event) => {
66
69
  isArrowKeyPressed.value = true;
67
70
  }
68
71
  });
72
+
69
73
  useEventListener('keyup', () => {
70
74
  isArrowKeyPressed.value = false;
71
75
  });
@@ -82,6 +86,11 @@ function handleFocus() {
82
86
  }
83
87
  }, 0);
84
88
  }
89
+
90
+ // `RadioGroupItem` sets `inheritAttrs: false` and wraps the multi-root `Radio`, so the
91
+ // parent's scoped-style id is not auto-forwarded; pass it through manually so consumer
92
+ // `<style scoped>` keeps working.
93
+ const scopeIdAttrs = useForwardScopeId();
85
94
  </script>
86
95
 
87
96
  <template>
@@ -93,7 +102,7 @@ function handleFocus() {
93
102
  :active="checked"
94
103
  >
95
104
  <Radio
96
- v-bind="{ ...$attrs, ...props }"
105
+ v-bind="{ ...scopeIdAttrs, ...$attrs, ...props }"
97
106
  :ref="forwardRef"
98
107
  :checked="checked"
99
108
  :required="required"
@@ -188,6 +188,12 @@ function handleArrowKey(e: KeyboardEvent) {
188
188
  if (isDisabled.value) {
189
189
  return;
190
190
  }
191
+ // Modifier combos on Enter/Space (e.g. Ctrl+Enter) are not handled by the cell —
192
+ // let them bubble so parent listeners can react (e.g. submit a form).
193
+ if ((e.code === KEY_CODES.ENTER || e.code === KEY_CODES.SPACE) && (e.ctrlKey || e.metaKey || e.altKey)) {
194
+ return;
195
+ }
196
+
191
197
  e.preventDefault();
192
198
  e.stopPropagation();
193
199
  const parentElement = rootContext.parentElement.value!;
@@ -16,7 +16,7 @@ export interface RovingFocusItemProps extends PrimitiveProps {
16
16
  </script>
17
17
 
18
18
  <script setup lang="ts">
19
- import { computed, nextTick, onMounted, onUnmounted } from 'vue';
19
+ import { computed, nextTick, onMounted, onUnmounted, watch } from 'vue';
20
20
  import { useCollection } from '@/Collection';
21
21
  import { Primitive } from '@/Primitive';
22
22
  import { useId } from '@/shared';
@@ -42,12 +42,27 @@ onMounted(() => {
42
42
  context.onFocusableItemAdd();
43
43
  }
44
44
  });
45
+
45
46
  onUnmounted(() => {
46
47
  if (props.focusable) {
47
48
  context.onFocusableItemRemove();
48
49
  }
49
50
  });
50
51
 
52
+ watch(
53
+ () => props.focusable,
54
+ (newVal, oldVal) => {
55
+ if (newVal === oldVal) {
56
+ return;
57
+ }
58
+ if (newVal) {
59
+ context.onFocusableItemAdd();
60
+ } else {
61
+ context.onFocusableItemRemove();
62
+ }
63
+ },
64
+ );
65
+
51
66
  function handleKeydown(event: KeyboardEvent) {
52
67
  if (event.key === 'Tab' && event.shiftKey) {
53
68
  context.onItemShiftTab();
@@ -63,8 +63,8 @@ watchOnce(sizes, () => {
63
63
  });
64
64
 
65
65
  onUnmounted(() => {
66
- viewport.value!.removeEventListener('scroll', handleScroll);
67
- rootContext.viewport.value?.removeEventListener('scroll', handleScroll);
66
+ viewport.value?.removeEventListener('scroll', handleScroll);
67
+ removeUnlinkedScrollListenerRef.value?.();
68
68
  });
69
69
  </script>
70
70
 
@@ -873,7 +873,9 @@ function isPanelCollapsed(panelData: PanelData) {
873
873
  const constraints = panelConstraintsArray?.[panelIndex] ?? panelData.constraints;
874
874
  return constraints.defaultSize === constraints.collapsedSize;
875
875
  } else {
876
- return panelSize === collapsedSize;
876
+ // Fuzzy compare: px sizeUnit converts constraints px→% and renormalizes the
877
+ // layout, so panelSize drifts from collapsedSize by a float epsilon.
878
+ return fuzzyCompareNumbers(panelSize, collapsedSize) <= 0;
877
879
  }
878
880
  }
879
881
 
@@ -898,7 +900,7 @@ function isPanelExpanded(panelData: PanelData) {
898
900
  `Panel size not found for panel "${panelData.id}"`,
899
901
  );
900
902
 
901
- return !collapsible || panelSize > collapsedSize;
903
+ return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
902
904
  }
903
905
 
904
906
  providePanelGroupContext({
@@ -2,7 +2,7 @@
2
2
  import type { ComputedRef, Ref } from 'vue';
3
3
  import type { PrimitiveProps } from '@/Primitive';
4
4
  import type { FormFieldProps } from '@/shared/types';
5
- import { createContext, useFormControl, useForwardExpose } from '@/shared';
5
+ import { createContext, useFormControl, useForwardExpose, useForwardScopeId } from '@/shared';
6
6
 
7
7
  export interface SwitchRootProps<T = boolean> extends PrimitiveProps, FormFieldProps {
8
8
  /** The state of the switch when it is initially rendered. Use when you do not need to control its state. */
@@ -45,13 +45,20 @@ import { computed, toRefs } from 'vue';
45
45
  import { Primitive } from '@/Primitive';
46
46
  import { VisuallyHiddenInput } from '@/VisuallyHidden';
47
47
 
48
- const props = withDefaults(defineProps<SwitchRootProps<T>>(), {
49
- as: 'button',
50
- modelValue: undefined,
51
- value: 'on',
52
- trueValue: (() => true) as unknown as undefined,
53
- falseValue: (() => false) as unknown as undefined,
48
+ defineOptions({
49
+ inheritAttrs: false,
54
50
  });
51
+
52
+ const props = withDefaults(
53
+ defineProps<SwitchRootProps<T>>(),
54
+ {
55
+ as: 'button',
56
+ modelValue: undefined,
57
+ value: 'on',
58
+ trueValue: (() => true) as unknown as undefined,
59
+ falseValue: (() => false) as unknown as undefined,
60
+ },
61
+ );
55
62
  const emit = defineEmits<SwitchRootEmits<T>>();
56
63
 
57
64
  defineSlots<{
@@ -82,6 +89,9 @@ function toggleCheck() {
82
89
 
83
90
  const { forwardRef, currentElement } = useForwardExpose();
84
91
  const isFormControl = useFormControl(currentElement);
92
+ // Hidden form input is a sibling (not nested) of the control to avoid the
93
+ // `nested-interactive` a11y violation; forward the parent scope id for scoped styles.
94
+ const scopeIdAttrs = useForwardScopeId();
85
95
  const ariaLabel = computed(() => props.id && currentElement.value ? (document.querySelector(`[for="${props.id}"]`) as HTMLLabelElement)?.innerText : undefined);
86
96
 
87
97
  provideSwitchRootContext({
@@ -93,7 +103,6 @@ provideSwitchRootContext({
93
103
 
94
104
  <template>
95
105
  <Primitive
96
- v-bind="$attrs"
97
106
  :id="id"
98
107
  :ref="forwardRef"
99
108
  role="switch"
@@ -107,6 +116,7 @@ provideSwitchRootContext({
107
116
  :as-child="asChild"
108
117
  :as="as"
109
118
  :disabled="disabled"
119
+ v-bind="{ ...scopeIdAttrs, ...$attrs }"
110
120
  @click="toggleCheck"
111
121
  @keydown.enter.prevent="toggleCheck"
112
122
  >
@@ -114,15 +124,16 @@ provideSwitchRootContext({
114
124
  :model-value="modelValue"
115
125
  :checked="checked"
116
126
  />
117
-
118
- <VisuallyHiddenInput
119
- v-if="isFormControl && name"
120
- type="checkbox"
121
- :name="name"
122
- :disabled="disabled"
123
- :required="required"
124
- :value="value"
125
- :checked="checked"
126
- />
127
127
  </Primitive>
128
+
129
+ <VisuallyHiddenInput
130
+ v-if="isFormControl && name"
131
+ type="checkbox"
132
+ :name="name"
133
+ :disabled="disabled"
134
+ :required="required"
135
+ :value="value"
136
+ :checked="checked"
137
+ v-bind="scopeIdAttrs"
138
+ />
128
139
  </template>
@@ -29,10 +29,14 @@ export interface TeleportProps {
29
29
 
30
30
  <script setup lang="ts">
31
31
  import { useMounted } from '@vueuse/core';
32
+ import { computed } from 'vue';
33
+ import { injectConfigProviderContext } from '@/ConfigProvider';
32
34
 
33
- withDefaults(defineProps<TeleportProps>(), {
34
- to: 'body',
35
- });
35
+ const props = defineProps<TeleportProps>();
36
+
37
+ const configContext = injectConfigProviderContext({});
38
+
39
+ const target = computed(() => props.to ?? configContext.teleportTo?.value ?? 'body');
36
40
 
37
41
  const isMounted = useMounted();
38
42
  </script>
@@ -40,7 +44,7 @@ const isMounted = useMounted();
40
44
  <template>
41
45
  <Teleport
42
46
  v-if="isMounted || forceMount"
43
- :to="to"
47
+ :to="target"
44
48
  :disabled="disabled"
45
49
  :defer="defer"
46
50
  >
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { PrimitiveProps } from '@/Primitive';
3
3
  import type { FormFieldProps } from '@/shared/types';
4
- import { useFormControl, useForwardExpose } from '@/shared';
4
+ import { useFormControl, useForwardExpose, useForwardScopeId } from '@/shared';
5
5
  import { injectToggleGroupRootContext } from '@/ToggleGroup/ToggleGroupRoot.vue';
6
6
  import VisuallyHiddenInput from '@/VisuallyHidden/VisuallyHiddenInput.vue';
7
7
 
@@ -34,12 +34,19 @@ import { useVModel } from '@vueuse/core';
34
34
  import { computed } from 'vue';
35
35
  import { Primitive } from '@/Primitive';
36
36
 
37
- const props = withDefaults(defineProps<ToggleProps>(), {
38
- modelValue: undefined,
39
- disabled: false,
40
- as: 'button',
37
+ defineOptions({
38
+ inheritAttrs: false,
41
39
  });
42
40
 
41
+ const props = withDefaults(
42
+ defineProps<ToggleProps>(),
43
+ {
44
+ modelValue: undefined,
45
+ disabled: false,
46
+ as: 'button',
47
+ },
48
+ );
49
+
43
50
  const emits = defineEmits<ToggleEmits>();
44
51
 
45
52
  defineSlots<{
@@ -56,6 +63,9 @@ defineSlots<{
56
63
  }>();
57
64
 
58
65
  const { forwardRef, currentElement } = useForwardExpose();
66
+ // Hidden form input is a sibling (not nested) of the control to avoid the
67
+ // `nested-interactive` a11y violation; forward the parent scope id for scoped styles.
68
+ const scopeIdAttrs = useForwardScopeId();
59
69
  const toggleGroupContext = injectToggleGroupRootContext(null);
60
70
 
61
71
  const modelValue = useVModel(props, 'modelValue', emits, {
@@ -84,6 +94,7 @@ const isFormControl = useFormControl(currentElement);
84
94
  :data-state="dataState"
85
95
  :data-disabled="disabled ? '' : undefined"
86
96
  :disabled="disabled"
97
+ v-bind="{ ...scopeIdAttrs, ...$attrs }"
87
98
  @click="togglePressed"
88
99
  >
89
100
  <slot
@@ -92,13 +103,14 @@ const isFormControl = useFormControl(currentElement);
92
103
  :pressed="modelValue"
93
104
  :state="dataState"
94
105
  />
95
-
96
- <VisuallyHiddenInput
97
- v-if="isFormControl && name && !toggleGroupContext"
98
- type="checkbox"
99
- :name="name"
100
- :value="modelValue"
101
- :required="required"
102
- />
103
106
  </Primitive>
107
+
108
+ <VisuallyHiddenInput
109
+ v-if="isFormControl && name && !toggleGroupContext"
110
+ type="checkbox"
111
+ :name="name"
112
+ :value="modelValue"
113
+ :required="required"
114
+ v-bind="scopeIdAttrs"
115
+ />
104
116
  </template>
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { AcceptableValue } from '@/shared/types';
3
3
  import type { ToggleProps } from '@/Toggle';
4
- import { isValueEqualOrExist, useForwardExpose } from '@/shared';
4
+ import { isValueEqualOrExist, useForwardExpose, useForwardScopeId } from '@/shared';
5
5
 
6
6
  export interface ToggleGroupItemProps extends Omit<ToggleProps, 'name' | 'required' | 'modelValue' | 'defaultValue'> {
7
7
  /**
@@ -27,6 +27,9 @@ const disabled = computed(() => rootContext.disabled?.value || props.disabled);
27
27
  const pressed = computed(() => isValueEqualOrExist(rootContext.modelValue.value, props.value));
28
28
 
29
29
  const { forwardRef } = useForwardExpose();
30
+ // `ToggleGroupItem` wraps the multi-root `Toggle`, so the parent's scoped-style id
31
+ // is not auto-forwarded; pass it through manually so consumer `<style scoped>` works.
32
+ const scopeIdAttrs = useForwardScopeId();
30
33
  </script>
31
34
 
32
35
  <template>
@@ -36,7 +39,7 @@ const { forwardRef } = useForwardExpose();
36
39
  v-bind="rootContext.rovingFocus.value ? { focusable: !disabled, active: pressed } : {}"
37
40
  >
38
41
  <Toggle
39
- v-bind="props"
42
+ v-bind="{ ...scopeIdAttrs, ...props }"
40
43
  :ref="forwardRef"
41
44
  v-slot="slotProps"
42
45
  :disabled="disabled"
@@ -14,7 +14,10 @@ const { forwardRef } = useForwardExpose();
14
14
  </script>
15
15
 
16
16
  <template>
17
- <ToolbarButton as-child>
17
+ <ToolbarButton
18
+ as-child
19
+ :disabled="props.disabled"
20
+ >
18
21
  <ToggleGroupItem
19
22
  v-bind="props"
20
23
  :ref="forwardRef"
@@ -16,7 +16,7 @@ withDefaults(defineProps<VisuallyHiddenProps>(), { as: 'span', feature: 'focusab
16
16
  <Primitive
17
17
  :as="as"
18
18
  :as-child="asChild"
19
- :aria-hidden="feature === 'focusable' ? 'true' : undefined"
19
+ :aria-hidden="feature === 'focusable' || feature === 'fully-hidden' ? 'true' : undefined"
20
20
  :data-hidden="feature === 'fully-hidden' ? '' : undefined"
21
21
  :tabindex="feature === 'fully-hidden' ? '-1' : undefined"
22
22
  :style="{
@@ -88,6 +88,13 @@ function handleArrowKey(e: KeyboardEvent) {
88
88
  if (isDisabled.value) {
89
89
  return;
90
90
  }
91
+
92
+ // Modifier combos on Enter/Space (e.g. Ctrl+Enter) are not handled by the cell —
93
+ // let them bubble so parent listeners can react (e.g. submit a form).
94
+ if ((e.code === KEY_CODES.ENTER || e.code === KEY_CODES.SPACE) && (e.ctrlKey || e.metaKey || e.altKey)) {
95
+ return;
96
+ }
97
+
91
98
  e.preventDefault();
92
99
  e.stopPropagation();
93
100
  const parentElement = rootContext.parentElement.value!;
@@ -211,7 +218,6 @@ function handleArrowKey(e: KeyboardEvent) {
211
218
  :tabindex="isFocusedYear ? 0 : isDisabled ? undefined : -1"
212
219
  @click="handleClick"
213
220
  @keydown.up.down.left.right.space.enter.page-up.page-down="handleArrowKey"
214
- @keydown.enter.prevent
215
221
  >
216
222
  <slot
217
223
  :year-value="yearValue"
@@ -163,6 +163,11 @@ function handleArrowKey(e: KeyboardEvent) {
163
163
  if (isDisabled.value) {
164
164
  return;
165
165
  }
166
+ // Modifier combos on Enter/Space (e.g. Ctrl+Enter) are not handled by the cell —
167
+ // let them bubble so parent listeners can react (e.g. submit a form).
168
+ if ((e.code === KEY_CODES.ENTER || e.code === KEY_CODES.SPACE) && (e.ctrlKey || e.metaKey || e.altKey)) {
169
+ return;
170
+ }
166
171
  e.preventDefault();
167
172
  e.stopPropagation();
168
173
  const parentElement = rootContext.parentElement.value!;
@@ -294,7 +299,6 @@ function handleArrowKey(e: KeyboardEvent) {
294
299
  @focusin="handleFocus"
295
300
  @mouseenter="handleFocus"
296
301
  @keydown.up.down.left.right.space.enter.page-up.page-down="handleArrowKey"
297
- @keydown.enter.prevent
298
302
  >
299
303
  <slot
300
304
  :year-value="yearValue"
@@ -21,6 +21,7 @@ export { useForwardExpose } from './useForwardExpose';
21
21
  export { useForwardProps } from './useForwardProps';
22
22
  export { useForwardPropsEmits } from './useForwardPropsEmits';
23
23
  export { useForwardRef } from './useForwardRef';
24
+ export { useForwardScopeId } from './useForwardScopeId';
24
25
  export { useGraceArea } from './useGraceArea';
25
26
  export { useHideOthers } from './useHideOthers';
26
27
  export { useId } from './useId';
@@ -0,0 +1,26 @@
1
+ import { getCurrentInstance } from 'vue';
2
+
3
+ /**
4
+ * Returns the parent component's `<style scoped>` id (e.g. `data-v-xxxxxxx`) as a
5
+ * bindable attribute object, so it can be manually forwarded onto the chosen root
6
+ * element of a multi-root component.
7
+ *
8
+ * Vue only auto-applies the parent's scope id to a **single-root** component's root.
9
+ * When a component renders multiple root nodes (e.g. an interactive control plus a
10
+ * sibling hidden form input), that fallthrough is dropped and the parent's scoped
11
+ * styles can no longer reach the component. Spread the returned object onto the
12
+ * element that should stay styleable by the parent.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const scopeIdAttrs = useForwardScopeId()
17
+ * // <Primitive v-bind="{ ...$attrs, ...scopeIdAttrs }" />
18
+ * ```
19
+ */
20
+ export function useForwardScopeId(): Record<string, string> {
21
+ // `vnode.scopeId` is the scope id the parent set on this component's placeholder
22
+ // vnode for scoped-CSS fallthrough. It is populated during the parent's render,
23
+ // so it is already available by the time `setup()` runs.
24
+ const scopeId = (getCurrentInstance()?.vnode as { scopeId?: string } | undefined)?.scopeId;
25
+ return scopeId ? { [scopeId]: '' } : {};
26
+ }