@aleph-alpha/ui-library 6.3.3 → 6.4.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 (105) hide show
  1. package/config.js +2 -1
  2. package/dist/system/components/UiDropdownMenu/UiDropdownMenuSubContent.vue.d.ts +102 -2
  3. package/dist/system/components/UiDropdownMenu/UiDropdownMenuViewport.vue.d.ts +23 -0
  4. package/dist/system/components/UiDropdownMenu/menu-metrics.d.ts +4 -0
  5. package/dist/system/components/UiDropdownMenu/placeMobileSubmenu.d.ts +55 -0
  6. package/dist/system/components/UiDropdownMenu/types.d.ts +3 -0
  7. package/dist/system/components/UiDropdownMenu/useMobileSubmenuPlacement.d.ts +18 -0
  8. package/dist/system/components/UiFileUploadBox/UiFileUploadBox.vue.d.ts +2 -2
  9. package/dist/system/components/UiFileUploadBox/types.d.ts +8 -5
  10. package/dist/system/components/UiResizable/UiResizablePanel.vue.d.ts +2 -2
  11. package/dist/system/components/UiStepper/context.d.ts +8 -0
  12. package/dist/system/components/UiToggle/UiToggle.vue.d.ts +2 -1
  13. package/dist/system/components/UiToggle/types.d.ts +10 -2
  14. package/dist/system/components/UiToggleGroup/UiToggleGroupItem.vue.d.ts +5 -1
  15. package/dist/system/components/UiToggleGroup/types.d.ts +12 -2
  16. package/dist/system/components/core/dropdown-menu/DropdownMenuSubContent.vue.d.ts +2 -6
  17. package/dist/system/components/core/range-calendar/RangeCalendar.vue.d.ts +24 -24
  18. package/dist/system/components/core/resizable/ResizablePanel.vue.d.ts +2 -2
  19. package/dist/system/components/core/toggle/Toggle.vue.d.ts +3 -1
  20. package/dist/system/components/core/toggle/index.d.ts +47 -2
  21. package/dist/system/components/core/toggle-group/ToggleGroup.vue.d.ts +3 -1
  22. package/dist/system/components/core/toggle-group/ToggleGroupItem.vue.d.ts +11 -1
  23. package/dist/system/components/core/toggle-group/context.d.ts +1 -0
  24. package/dist/system/components/core/toggle-group/index.d.ts +10 -2
  25. package/dist/system/icons/story-sidebar-icons.json +7 -0
  26. package/dist/system/lib.js +14114 -13755
  27. package/dist/system/patterns/UiFileUpload/UiFileUpload.vue.d.ts +2 -2
  28. package/dist/system/patterns/UiLayout/layout-shell.d.ts +379 -8
  29. package/dist/system/patterns/UiProfileCard/profile-card.d.ts +51 -1
  30. package/dist/system/patterns/UiTopBar/accessory-dropdown.d.ts +232 -0
  31. package/dist/system/story-sidebar-icons.json +7 -0
  32. package/package.json +2 -2
  33. package/src/components/UiAccordion/UiAccordion.stories.ts +1079 -0
  34. package/src/components/UiCalendar/UiCalendar.stories.ts +734 -0
  35. package/src/components/UiCalendar/__tests__/UiCalendar.test.ts +8 -5
  36. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +819 -31
  37. package/src/components/UiDropdownMenu/UiDropdownMenuContent.vue +4 -1
  38. package/src/components/UiDropdownMenu/UiDropdownMenuSubContent.vue +142 -1
  39. package/src/components/UiDropdownMenu/UiDropdownMenuSubTrigger.vue +28 -0
  40. package/src/components/UiDropdownMenu/UiDropdownMenuTrigger.vue +3 -1
  41. package/src/components/UiDropdownMenu/UiDropdownMenuViewport.vue +171 -0
  42. package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +326 -0
  43. package/src/components/UiDropdownMenu/__tests__/placeMobileSubmenu.test.ts +128 -0
  44. package/src/components/UiDropdownMenu/menu-metrics.ts +5 -0
  45. package/src/components/UiDropdownMenu/placeMobileSubmenu.ts +96 -0
  46. package/src/components/UiDropdownMenu/types.ts +3 -0
  47. package/src/components/UiDropdownMenu/useMobileSubmenuPlacement.ts +163 -0
  48. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +389 -3
  49. package/src/components/UiFileUploadBox/UiFileUploadBox.vue +55 -75
  50. package/src/components/UiFileUploadBox/__tests__/UiFileUploadBox.test.ts +44 -0
  51. package/src/components/UiFileUploadBox/types.ts +8 -5
  52. package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +723 -0
  53. package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +819 -7
  54. package/src/components/UiRangeCalendar/__tests__/UiRangeCalendar.test.ts +8 -3
  55. package/src/components/UiResizable/UiResizable.stories.ts +1215 -5
  56. package/src/components/UiSnackbar/UiSnackbar.stories.ts +1089 -4
  57. package/src/components/UiSnackbar/UiSnackbar.vue +3 -2
  58. package/src/components/UiSnackbar/UiSnackbarContent.vue +1 -1
  59. package/src/components/UiSnackbar/__tests__/UiSnackbar.test.ts +3 -1
  60. package/src/components/UiStepper/UiStepper.stories.ts +566 -2
  61. package/src/components/UiStepper/UiStepper.vue +14 -1
  62. package/src/components/UiStepper/UiStepperItem.vue +22 -4
  63. package/src/components/UiStepper/__tests__/UiStepper.test.ts +66 -0
  64. package/src/components/UiStepper/context.ts +10 -0
  65. package/src/components/UiToggle/UiToggle.stories.ts +386 -261
  66. package/src/components/UiToggle/UiToggle.vue +2 -0
  67. package/src/components/UiToggle/__tests__/UiToggle.test.ts +63 -10
  68. package/src/components/UiToggle/types.ts +10 -2
  69. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +765 -30
  70. package/src/components/UiToggleGroup/UiToggleGroup.vue +2 -0
  71. package/src/components/UiToggleGroup/UiToggleGroupItem.vue +10 -1
  72. package/src/components/UiToggleGroup/__tests__/UiToggleGroup.test.ts +83 -4
  73. package/src/components/UiToggleGroup/types.ts +12 -2
  74. package/src/components/core/calendar/Calendar.vue +234 -2
  75. package/src/components/core/calendar/CalendarCellTrigger.vue +1 -1
  76. package/src/components/core/dropdown-menu/DropdownMenuContent.vue +1 -1
  77. package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
  78. package/src/components/core/dropdown-menu/DropdownMenuSubContent.vue +31 -20
  79. package/src/components/core/navigation-menu/NavigationMenuList.vue +1 -1
  80. package/src/components/core/range-calendar/RangeCalendar.vue +254 -6
  81. package/src/components/core/range-calendar/RangeCalendarCellTrigger.vue +1 -1
  82. package/src/components/core/toggle/Toggle.vue +12 -5
  83. package/src/components/core/toggle/index.ts +47 -19
  84. package/src/components/core/toggle-group/ToggleGroup.vue +20 -4
  85. package/src/components/core/toggle-group/ToggleGroupItem.vue +36 -8
  86. package/src/components/core/toggle-group/context.ts +1 -0
  87. package/src/components/core/toggle-group/index.ts +10 -24
  88. package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +1 -1
  89. package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +1 -1
  90. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +846 -17
  91. package/src/patterns/UiDatePicker/UiDatePicker.vue +9 -0
  92. package/src/patterns/UiDatePicker/__tests__/UiDatePicker.test.ts +13 -8
  93. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +23 -17
  94. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +138 -113
  95. package/src/patterns/UiFileUpload/UiFileUpload.vue +1 -1
  96. package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +2 -2
  97. package/src/patterns/UiLayout/UiLayout.stories.ts +25 -0
  98. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +359 -0
  99. package/src/patterns/UiLayout/UiLayoutContent.vue +45 -23
  100. package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +13 -0
  101. package/src/patterns/UiLayout/layout-shell.ts +159 -13
  102. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +13 -6
  103. package/src/patterns/UiTopBar/UiTopBar.stories.ts +245 -36
  104. package/src/patterns/UiTopBar/UiTopBar.vue +4 -2
  105. package/src/patterns/UiTopBar/accessory-dropdown.ts +99 -0
@@ -25,6 +25,7 @@ const props = withDefaults(
25
25
  defaultValue: undefined,
26
26
  disabled: false,
27
27
  variant: 'default',
28
+ soft: false,
28
29
  size: 'default',
29
30
  loop: true,
30
31
  rovingFocus: true,
@@ -44,6 +45,7 @@ const modelValue = defineModel<UiToggleGroupModelValue<T>>();
44
45
  :default-value="props.defaultValue"
45
46
  :disabled="props.disabled"
46
47
  :variant="props.variant"
48
+ :soft="props.soft"
47
49
  :size="props.size"
48
50
  :loop="props.loop"
49
51
  :roving-focus="props.rovingFocus"
@@ -6,7 +6,15 @@ defineOptions({
6
6
  name: 'UiToggleGroupItem',
7
7
  });
8
8
 
9
- const props = defineProps<UiToggleGroupItemProps>();
9
+ /**
10
+ * `soft` stays `undefined` unless it is set, so an item without it inherits the
11
+ * group's fill instead of Vue casting the absent boolean to `false`.
12
+ */
13
+ const props = withDefaults(defineProps<UiToggleGroupItemProps>(), {
14
+ variant: undefined,
15
+ size: undefined,
16
+ soft: undefined,
17
+ });
10
18
  </script>
11
19
 
12
20
  <template>
@@ -14,6 +22,7 @@ const props = defineProps<UiToggleGroupItemProps>();
14
22
  :value="props.value"
15
23
  :disabled="props.disabled"
16
24
  :variant="props.variant"
25
+ :soft="props.soft"
17
26
  :size="props.size"
18
27
  >
19
28
  <slot />
@@ -180,7 +180,7 @@ describe('UiToggleGroup', () => {
180
180
  describe('Styling', () => {
181
181
  test('maps the group variant onto its items', () => {
182
182
  const { container } = render(UiToggleGroup, {
183
- props: { type: 'single', variant: 'soft' },
183
+ props: { type: 'single', variant: 'outline' },
184
184
  slots: {
185
185
  default: {
186
186
  components: { UiToggleGroupItem },
@@ -191,7 +191,62 @@ describe('UiToggleGroup', () => {
191
191
  });
192
192
  expect(
193
193
  container.querySelector('[data-slot="toggle-group-item"]'),
194
- ).toHaveClass('data-[state=on]:bg-accent');
194
+ ).toHaveClass('border-input');
195
+ });
196
+
197
+ // `soft` only swaps the selected fill, so it has to reach the items the
198
+ // same way the variant does.
199
+ test('maps the group soft flag onto the selected fill of its items', () => {
200
+ const { container } = render(UiToggleGroup, {
201
+ props: { type: 'single', soft: true },
202
+ slots: {
203
+ default: {
204
+ components: { UiToggleGroupItem },
205
+ template: '<UiToggleGroupItem value="a">A</UiToggleGroupItem>',
206
+ },
207
+ },
208
+ global: { components: { UiToggleGroupItem } },
209
+ });
210
+ const item = container.querySelector('[data-slot="toggle-group-item"]');
211
+ expect(item).toHaveClass('aria-pressed:bg-overlay-hover-subtle');
212
+ expect(item).not.toHaveClass(
213
+ 'aria-pressed:bg-background-surface-muted-subtle',
214
+ );
215
+ });
216
+
217
+ test('lets an item override the group soft flag', () => {
218
+ const { container } = render(UiToggleGroup, {
219
+ props: { type: 'single', soft: true },
220
+ slots: {
221
+ default: {
222
+ components: { UiToggleGroupItem },
223
+ template:
224
+ '<UiToggleGroupItem value="a" :soft="false">A</UiToggleGroupItem>',
225
+ },
226
+ },
227
+ global: { components: { UiToggleGroupItem } },
228
+ });
229
+ expect(
230
+ container.querySelector('[data-slot="toggle-group-item"]'),
231
+ ).toHaveClass('aria-pressed:bg-background-surface-muted-subtle');
232
+ });
233
+
234
+ // The styling props are consumed by cva, so they must not reach the DOM.
235
+ test('keeps styling props off the rendered items', () => {
236
+ const { container } = render(UiToggleGroup, {
237
+ props: { type: 'single', variant: 'outline', size: 'sm', soft: true },
238
+ slots: {
239
+ default: {
240
+ components: { UiToggleGroupItem },
241
+ template: '<UiToggleGroupItem value="a">A</UiToggleGroupItem>',
242
+ },
243
+ },
244
+ global: { components: { UiToggleGroupItem } },
245
+ });
246
+ const item = container.querySelector('[data-slot="toggle-group-item"]');
247
+ expect(item).not.toHaveAttribute('variant');
248
+ expect(item).not.toHaveAttribute('size');
249
+ expect(item).not.toHaveAttribute('soft');
195
250
  });
196
251
 
197
252
  test('maps the group size onto its items', () => {
@@ -207,7 +262,7 @@ describe('UiToggleGroup', () => {
207
262
  });
208
263
  expect(
209
264
  container.querySelector('[data-slot="toggle-group-item"]'),
210
- ).toHaveClass('h-10');
265
+ ).toHaveClass('py-3');
211
266
  });
212
267
 
213
268
  test('lets an item override the group size', () => {
@@ -224,7 +279,31 @@ describe('UiToggleGroup', () => {
224
279
  });
225
280
  expect(
226
281
  container.querySelector('[data-slot="toggle-group-item"]'),
227
- ).toHaveClass('h-8');
282
+ ).toHaveClass('py-1');
283
+ });
284
+
285
+ // An item is a `UiToggle` in group format, so it has to carry the shared
286
+ // hover overlay and square off only the corners facing its neighbours.
287
+ test('renders items as flush toggles sharing the toggle base', () => {
288
+ const { container } = render(UiToggleGroup, {
289
+ props: { type: 'single' },
290
+ slots: {
291
+ default: {
292
+ components: { UiToggleGroupItem },
293
+ template: '<UiToggleGroupItem value="a">A</UiToggleGroupItem>',
294
+ },
295
+ },
296
+ global: { components: { UiToggleGroupItem } },
297
+ });
298
+ expect(
299
+ container.querySelector('[data-slot="toggle-group-item"]'),
300
+ ).toHaveClass(
301
+ 'hover-layer',
302
+ 'hover-layer-subtle',
303
+ 'rounded-none',
304
+ 'first:rounded-l-md',
305
+ 'last:rounded-r-md',
306
+ );
228
307
  });
229
308
  });
230
309
  });
@@ -11,7 +11,13 @@ export interface UiToggleGroupBaseProps {
11
11
  * The visual style variant applied to all items.
12
12
  * @default 'default'
13
13
  */
14
- variant?: 'default' | 'outline' | 'soft';
14
+ variant?: 'default' | 'ghost' | 'outline';
15
+ /**
16
+ * Fills the selected items with the subtle hover overlay instead of a muted
17
+ * surface. Affects the selected state only; every other state is unchanged.
18
+ * @default false
19
+ */
20
+ soft?: boolean;
15
21
  /**
16
22
  * The size applied to all items.
17
23
  * @default 'default'
@@ -118,7 +124,11 @@ export interface UiToggleGroupItemProps {
118
124
  /**
119
125
  * Override the variant for this specific item.
120
126
  */
121
- variant?: 'default' | 'outline' | 'soft';
127
+ variant?: 'default' | 'ghost' | 'outline';
128
+ /**
129
+ * Override the selected fill for this specific item.
130
+ */
131
+ soft?: boolean;
122
132
  /**
123
133
  * Override the size for this specific item.
124
134
  */
@@ -2,7 +2,12 @@
2
2
  import type { CalendarRootEmits, CalendarRootProps, DateValue } from 'reka-ui';
3
3
  import type { HTMLAttributes, Ref } from 'vue';
4
4
  import type { LayoutTypes } from '.';
5
- import { getLocalTimeZone, today } from '@internationalized/date';
5
+ import {
6
+ getLocalTimeZone,
7
+ parseDate,
8
+ toCalendar,
9
+ today,
10
+ } from '@internationalized/date';
6
11
  import { createReusableTemplate, reactiveOmit, useVModel } from '@vueuse/core';
7
12
  import { CalendarRoot, useDateFormatter, useForwardPropsEmits } from 'reka-ui';
8
13
  import { createYear, createYearRange, toDate } from 'reka-ui/date';
@@ -95,7 +100,233 @@ function removeUnsupportedReadonlyAttributes() {
95
100
  }
96
101
 
97
102
  onMounted(removeUnsupportedReadonlyAttributes);
98
- watch(() => props.readonly, removeUnsupportedReadonlyAttributes);
103
+ watch([() => props.readonly, placeholder], removeUnsupportedReadonlyAttributes);
104
+
105
+ const GRID_NAV_KEYS = ['Home', 'End', 'PageUp', 'PageDown'];
106
+
107
+ /**
108
+ * Converts a cell's Gregorian ISO `data-value` into the placeholder's
109
+ * calendar system. `data-value` strings are always Gregorian (that is what
110
+ * `DateValue.toString()` emits), but placeholder fields and month arithmetic
111
+ * must be interpreted in the placeholder's own calendar (e.g. Hebrew).
112
+ * @param value ISO date string carried by the cell's `data-value` attribute.
113
+ */
114
+ function parseCellValue(value: string): DateValue {
115
+ return toCalendar(parseDate(value), placeholder.value.calendar);
116
+ }
117
+
118
+ /**
119
+ * Moves the placeholder to the given day while preserving the placeholder's
120
+ * date type, calendar system, and era. reka-ui's roving tabindex follows the
121
+ * placeholder, so this keeps the single tab stop in sync with the day we
122
+ * focus.
123
+ * @param date Target day.
124
+ */
125
+ function setPlaceholderDay(date: DateValue) {
126
+ const target = toCalendar(date, placeholder.value.calendar);
127
+ placeholder.value = placeholder.value.set({
128
+ era: target.era,
129
+ year: target.year,
130
+ month: target.month,
131
+ day: target.day,
132
+ });
133
+ }
134
+
135
+ /**
136
+ * Focuses a day cell trigger and syncs the placeholder to it.
137
+ * @param cell The day cell trigger element to focus.
138
+ */
139
+ function focusDay(cell: HTMLElement | null | undefined) {
140
+ const value = cell?.getAttribute('data-value');
141
+ if (!cell || !value) return;
142
+ setPlaceholderDay(parseCellValue(value));
143
+ cell.focus();
144
+ }
145
+
146
+ /**
147
+ * Finds the in-view (not outside-view) day cell trigger for a date value in
148
+ * the currently rendered view.
149
+ * @param value ISO date string carried by the cell's `data-value` attribute.
150
+ * @returns The matching trigger element, or null when not rendered.
151
+ */
152
+ function queryInViewDay(value: string): HTMLElement | null {
153
+ const root = calendarRootRef.value?.$el as HTMLElement | undefined;
154
+ return (
155
+ root?.querySelector<HTMLElement>(
156
+ `[data-value='${value}']:not([data-outside-view])`,
157
+ ) ?? null
158
+ );
159
+ }
160
+
161
+ /**
162
+ * Whether a day cannot take keyboard focus — disabled by the `isDateDisabled`
163
+ * matcher or outside the min/max bounds.
164
+ * @param date Candidate day.
165
+ */
166
+ function isDayDisabled(date: DateValue): boolean {
167
+ return Boolean(
168
+ props.isDateDisabled?.(date) ||
169
+ (props.minValue && date.compare(props.minValue) < 0) ||
170
+ (props.maxValue && date.compare(props.maxValue) > 0),
171
+ );
172
+ }
173
+
174
+ /**
175
+ * Resolves an enabled landing day within the candidate's month, stepping past
176
+ * disabled dates in the given direction.
177
+ * @param candidate First-choice landing day.
178
+ * @param direction 1 to step forwards, -1 to step backwards.
179
+ * @returns The first enabled day, or null when the whole stretch is disabled
180
+ * (e.g. a fully disabled target month).
181
+ */
182
+ function resolveEnabledLandingDay(
183
+ candidate: DateValue,
184
+ direction: number,
185
+ ): DateValue | null {
186
+ const targetMonth = candidate.month;
187
+ let day = candidate;
188
+ while (day.month === targetMonth && isDayDisabled(day)) {
189
+ day = day.add({ days: direction });
190
+ }
191
+ return day.month === targetMonth ? day : null;
192
+ }
193
+
194
+ /**
195
+ * Home/End move to the first/last enabled day of the focused row.
196
+ * Outside-view days stay included: with the default
197
+ * `disableDaysOutsideCurrentView: false` they are visible and selectable, so
198
+ * row navigation must reach them too. When that prop is true, reka-ui marks
199
+ * them `data-disabled`, and the filter excludes them consistently.
200
+ * @param trigger The focused day cell trigger.
201
+ * @param key The pressed key, 'Home' or 'End'.
202
+ */
203
+ function handleHomeEndKey(trigger: HTMLElement, key: string) {
204
+ const week = Array.from(
205
+ trigger
206
+ .closest('tr')
207
+ ?.querySelectorAll<HTMLElement>(
208
+ '[data-reka-calendar-cell-trigger]:not([data-disabled])',
209
+ ) ?? [],
210
+ );
211
+ const target = key === 'Home' ? week[0] : week[week.length - 1];
212
+ const targetValue = target?.getAttribute('data-value');
213
+ if (!target || !targetValue) return;
214
+
215
+ if (!target.hasAttribute('data-outside-view')) {
216
+ focusDay(target);
217
+ return;
218
+ }
219
+
220
+ // The row's first/last day belongs to the adjacent month. Mirror reka-ui's
221
+ // arrow navigation, which never focuses outside-view cells: flip the view
222
+ // to that month, then focus the same date as an in-view cell.
223
+ setPlaceholderDay(parseCellValue(targetValue));
224
+ nextTick(() => focusDay(queryInViewDay(targetValue)));
225
+ }
226
+
227
+ /**
228
+ * Clamps a landing day into the min/max bounds so paging stays possible when
229
+ * only part of the target month is allowed (e.g. PageUp from June 10 with
230
+ * minValue May 15 lands on May 15 instead of being rejected).
231
+ * @param target Unclamped landing day (same day in the target month/year).
232
+ * @param direction 1 when paging forwards, -1 backwards.
233
+ * @returns The clamped landing day plus the direction to search for an
234
+ * enabled day (away from the clamped bound, into the month), or null when the
235
+ * whole target month lies outside the bounds.
236
+ */
237
+ function clampLandingDay(
238
+ target: DateValue,
239
+ direction: number,
240
+ ): { day: DateValue; searchDirection: number } | null {
241
+ let day = target;
242
+ let searchDirection = direction;
243
+ if (props.minValue && day.compare(props.minValue) < 0) {
244
+ day = toCalendar(props.minValue, placeholder.value.calendar);
245
+ searchDirection = 1;
246
+ } else if (props.maxValue && day.compare(props.maxValue) > 0) {
247
+ day = toCalendar(props.maxValue, placeholder.value.calendar);
248
+ searchDirection = -1;
249
+ }
250
+ const sameMonth =
251
+ day.era === target.era &&
252
+ day.year === target.year &&
253
+ day.month === target.month;
254
+ return sameMonth ? { day, searchDirection } : null;
255
+ }
256
+
257
+ /**
258
+ * PageUp/PageDown move to the same day in the previous/next month;
259
+ * Shift+PageUp/Shift+PageDown move by a year per the WAI-ARIA calendar
260
+ * pattern. The month/year arithmetic runs in the placeholder's calendar
261
+ * system, landing days are clamped into the min/max bounds, and the enabled
262
+ * landing day is resolved *before* flipping the view, so bailing out (e.g. a
263
+ * fully disabled or out-of-bounds target month) keeps the current view and
264
+ * focus intact instead of stranding keyboard focus.
265
+ * @param trigger The focused day cell trigger.
266
+ * @param e The keydown event.
267
+ */
268
+ function handlePageKey(trigger: HTMLElement, e: KeyboardEvent) {
269
+ const currentValue = trigger.getAttribute('data-value');
270
+ if (!currentValue) return;
271
+ const direction = e.key === 'PageDown' ? 1 : -1;
272
+ const target = parseCellValue(currentValue).add(
273
+ e.shiftKey ? { years: direction } : { months: direction },
274
+ );
275
+ const clamped = clampLandingDay(target, direction);
276
+ if (!clamped) return;
277
+ const candidate = resolveEnabledLandingDay(
278
+ clamped.day,
279
+ clamped.searchDirection,
280
+ );
281
+ if (!candidate) return;
282
+
283
+ setPlaceholderDay(candidate);
284
+ nextTick(() => focusLandingDay(candidate, currentValue));
285
+ }
286
+
287
+ /**
288
+ * Focuses the resolved landing day after the view flipped. Defensive: if the
289
+ * landing cell is unexpectedly missing or disabled in the new view, restores
290
+ * the previous view and focus instead of leaving keyboard focus lost.
291
+ * @param candidate The resolved landing day.
292
+ * @param originValue `data-value` of the day the navigation started from.
293
+ */
294
+ function focusLandingDay(candidate: DateValue, originValue: string) {
295
+ const cell = queryInViewDay(candidate.toString());
296
+ if (cell && !cell.hasAttribute('data-disabled')) {
297
+ focusDay(cell);
298
+ return;
299
+ }
300
+ setPlaceholderDay(parseCellValue(originValue));
301
+ nextTick(() => focusDay(queryInViewDay(originValue)));
302
+ }
303
+
304
+ /**
305
+ * reka-ui's CalendarCellTrigger only implements arrow-key navigation plus
306
+ * Enter/Space selection. The WAI-ARIA date-grid pattern also expects Home/End
307
+ * (first/last day of the visible week), PageUp/PageDown (same day in the
308
+ * previous/next month), and Shift+PageUp/Shift+PageDown (same day in the
309
+ * previous/next year), so we add those here on the calendar root.
310
+ * @param e The keydown event bubbling up from a day cell trigger.
311
+ */
312
+ function handleGridKeydown(e: KeyboardEvent) {
313
+ if (!GRID_NAV_KEYS.includes(e.key)) return;
314
+ const trigger = e.target as HTMLElement | null;
315
+ if (
316
+ !trigger?.hasAttribute('data-reka-calendar-cell-trigger') ||
317
+ trigger.hasAttribute('data-disabled')
318
+ ) {
319
+ return;
320
+ }
321
+ e.preventDefault();
322
+ e.stopPropagation();
323
+
324
+ if (e.key === 'Home' || e.key === 'End') {
325
+ handleHomeEndKey(trigger, e.key);
326
+ } else {
327
+ handlePageKey(trigger, e);
328
+ }
329
+ }
99
330
  </script>
100
331
 
101
332
  <template>
@@ -168,6 +399,7 @@ watch(() => props.readonly, removeUnsupportedReadonlyAttributes);
168
399
  v-model:placeholder="placeholder"
169
400
  data-slot="calendar"
170
401
  :class="cn('p-3', props.class)"
402
+ @keydown="handleGridKeydown"
171
403
  >
172
404
  <CalendarHeader class="pt-0">
173
405
  <nav
@@ -9,7 +9,7 @@ import { buttonVariants } from '@/components/core/button';
9
9
  const props = withDefaults(
10
10
  defineProps<CalendarCellTriggerProps & { class?: HTMLAttributes['class'] }>(),
11
11
  {
12
- as: 'button',
12
+ as: 'div',
13
13
  },
14
14
  );
15
15
 
@@ -36,7 +36,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
36
36
  v-bind="{ ...$attrs, ...forwarded }"
37
37
  :class="
38
38
  cn(
39
- 'bg-background-surface-floating text-content-on-surface-primary data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--reka-dropdown-menu-content-available-height) min-w-[8rem] origin-(--reka-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-surface-default p-1 shadow-xs',
39
+ 'bg-background-surface-floating text-content-on-surface-primary data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-[var(--reka-dropdown-menu-content-available-height)] max-sm:flex max-sm:flex-col max-sm:max-w-[18rem] sm:min-w-[8rem] origin-(--reka-dropdown-menu-content-transform-origin) overflow-x-hidden max-sm:overflow-y-hidden sm:overflow-y-auto rounded-md border border-border-surface-default p-2 shadow-md',
40
40
  props.class,
41
41
  )
42
42
  "
@@ -31,7 +31,7 @@ const forwardedProps = useForwardProps(delegatedProps);
31
31
  v-bind="forwardedProps"
32
32
  :class="
33
33
  cn(
34
- 'hover:bg-background-surface-muted-subtle data-[highlighted]:bg-background-surface-muted-subtle focus:text-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*=\'text-\'])]:text-content-on-surface-muted relative h-9 flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 body-14-regular outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4',
34
+ 'hover:bg-background-surface-muted-subtle data-[highlighted]:bg-background-surface-muted-subtle focus:text-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*=\'text-\'])]:text-content-on-surface-muted relative h-9 flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 body-s-regular outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4',
35
35
  props.class,
36
36
  )
37
37
  "
@@ -4,31 +4,42 @@ import type {
4
4
  DropdownMenuSubContentProps,
5
5
  } from 'reka-ui';
6
6
  import type { HTMLAttributes } from 'vue';
7
- import { reactiveOmit } from '@vueuse/core';
8
- import { DropdownMenuSubContent, useForwardPropsEmits } from 'reka-ui';
7
+ import {
8
+ DropdownMenuPortal,
9
+ DropdownMenuSubContent,
10
+ useForwardPropsEmits,
11
+ } from 'reka-ui';
9
12
  import { cn } from '@/lib/utils';
10
13
 
11
- const props = defineProps<
12
- DropdownMenuSubContentProps & { class?: HTMLAttributes['class'] }
13
- >();
14
- const emits = defineEmits<DropdownMenuSubContentEmits>();
14
+ defineOptions({
15
+ inheritAttrs: false,
16
+ });
15
17
 
16
- const delegatedProps = reactiveOmit(props, 'class');
18
+ const props = defineProps<DropdownMenuSubContentProps>();
19
+ const emits = defineEmits<DropdownMenuSubContentEmits>();
17
20
 
18
- const forwarded = useForwardPropsEmits(delegatedProps, emits);
21
+ const forwarded = useForwardPropsEmits(props, emits);
19
22
  </script>
20
23
 
21
24
  <template>
22
- <DropdownMenuSubContent
23
- data-slot="dropdown-menu-sub-content"
24
- v-bind="forwarded"
25
- :class="
26
- cn(
27
- 'bg-background-surface-floating text-content-on-surface-primary data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--reka-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border border-border-surface-default p-1 shadow-xs',
28
- props.class,
29
- )
30
- "
31
- >
32
- <slot />
33
- </DropdownMenuSubContent>
25
+ <!--
26
+ Portaled so the submenu is a sibling of the parent panel rather than a
27
+ child of it. The parent clips its overflow, and on a narrow screen the
28
+ submenu is pinned in viewport coordinates, which only hold outside the
29
+ transformed wrapper the parent sits in.
30
+ -->
31
+ <DropdownMenuPortal>
32
+ <DropdownMenuSubContent
33
+ data-slot="dropdown-menu-sub-content"
34
+ v-bind="forwarded"
35
+ :class="
36
+ cn(
37
+ 'bg-background-surface-floating text-content-on-surface-primary data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 min-w-[8rem] max-sm:min-w-0 origin-(--reka-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border border-border-surface-default p-1 shadow-xs',
38
+ $attrs.class as HTMLAttributes['class'],
39
+ )
40
+ "
41
+ >
42
+ <slot />
43
+ </DropdownMenuSubContent>
44
+ </DropdownMenuPortal>
34
45
  </template>
@@ -16,7 +16,7 @@ const forwardedProps = useForwardProps(props);
16
16
  v-bind="{ ...forwardedProps, ...$attrs }"
17
17
  :class="
18
18
  cn(
19
- 'group flex flex-1 list-none items-center justify-center gap-1',
19
+ 'group flex flex-1 list-none flex-wrap items-center justify-center gap-1',
20
20
  $attrs.class ?? '',
21
21
  )
22
22
  "