@aleph-alpha/ui-library 2.10.0 → 2.12.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.
- package/config.d.ts +8 -2
- package/config.js +85 -73
- package/dist/system/components/UiAutocomplete/UiAutocomplete.vue.d.ts +0 -1
- package/dist/system/components/UiAutocomplete/types.d.ts +0 -3
- package/dist/system/components/UiDialog/UiDialogDescription.vue.d.ts +2 -1
- package/dist/system/components/UiDialog/UiDialogFooter.vue.d.ts +1 -2
- package/dist/system/components/UiDialog/UiDialogHeader.vue.d.ts +1 -2
- package/dist/system/components/UiDialog/UiDialogTitle.vue.d.ts +2 -1
- package/dist/system/components/UiDialog/types.d.ts +10 -4
- package/dist/system/components/UiDropdownMenu/UiDropdownMenuSub.vue.d.ts +3 -1
- package/dist/system/components/UiField/UiFieldError.vue.d.ts +8 -1
- package/dist/system/components/UiInput/UiInput.vue.d.ts +16 -1
- package/dist/system/components/UiSelect/UiSelect.vue.d.ts +4 -5
- package/dist/system/components/UiSelect/UiSelectContent.vue.d.ts +0 -1
- package/dist/system/components/UiSelect/UiSelectItem.vue.d.ts +2 -9
- package/dist/system/components/UiSelect/UiSelectTrigger.vue.d.ts +0 -2
- package/dist/system/components/UiSelect/UiSelectValue.vue.d.ts +0 -3
- package/dist/system/components/UiSelect/types.d.ts +26 -6
- package/dist/system/components/UiStepper/UiStepperDescription.vue.d.ts +3 -1
- package/dist/system/components/UiStepper/UiStepperIndicator.vue.d.ts +3 -1
- package/dist/system/components/UiStepper/UiStepperItem.vue.d.ts +3 -1
- package/dist/system/components/UiTagsInput/types.d.ts +1 -2
- package/dist/system/components/core/accordion/AccordionItem.vue.d.ts +3 -1
- package/dist/system/components/core/calendar/CalendarHeading.vue.d.ts +2 -2
- package/dist/system/components/core/dropdown-menu/DropdownMenuSub.vue.d.ts +3 -1
- package/dist/system/components/core/range-calendar/RangeCalendarHeading.vue.d.ts +2 -2
- package/dist/system/components/core/stepper/StepperDescription.vue.d.ts +3 -1
- package/dist/system/components/core/stepper/StepperIndicator.vue.d.ts +3 -1
- package/dist/system/components/core/stepper/StepperItem.vue.d.ts +3 -1
- package/dist/system/index.d.ts +2 -1
- package/dist/system/lib/utils.d.ts +6 -0
- package/dist/system/lib.js +9685 -9895
- package/dist/system/patterns/UiSidebar/UiSidebarContent.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarFooter.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarGroupContent.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarInset.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarMenu.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarMenuItem.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarProvider.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarRail.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/__tests__/sidebar-test-helpers.d.ts +9 -9
- package/dist/system/patterns/UiSidebar/types.d.ts +8 -16
- package/dist/system/story-sidebar-icons.json +10 -0
- package/package.json +5 -2
- package/src/@types/shims-vue.d.ts +1 -1
- package/src/__tests__/test-utils.ts +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogAction.vue +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogCancel.vue +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogContent.vue +4 -1
- package/src/components/UiAlertDialog/UiAlertDialogDescription.vue +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogTitle.vue +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogTrigger.vue +1 -1
- package/src/components/UiAutocomplete/UiAutocomplete.vue +9 -9
- package/src/components/UiAutocomplete/__tests__/UiAutocomplete.test.ts +76 -5
- package/src/components/UiAutocomplete/types.ts +0 -3
- package/src/components/UiBadge/UiBadge.vue +1 -1
- package/src/components/UiBadge/constants.ts +1 -1
- package/src/components/UiBadge/types.ts +1 -1
- package/src/components/UiButton/UiButton.stories.ts +286 -198
- package/src/components/UiButton/mcp-docs.json +49 -0
- package/src/components/UiCalendar/UiCalendar.vue +2 -5
- package/src/components/UiCalendar/__tests__/UiCalendar.test.ts +4 -2
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +176 -2
- package/src/components/UiCheckbox/mcp-docs.json +36 -0
- package/src/components/UiChip/types.ts +1 -1
- package/src/components/UiDialog/UiDialogFooter.vue +0 -3
- package/src/components/UiDialog/UiDialogHeader.vue +0 -3
- package/src/components/UiDialog/types.ts +10 -4
- package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +1 -1
- package/src/components/UiField/UiField.stories.ts +265 -3
- package/src/components/UiField/UiField.vue +9 -2
- package/src/components/UiField/UiFieldError.vue +3 -3
- package/src/components/UiField/mcp-docs.json +72 -0
- package/src/components/UiFileItem/UiFileItem.stories.ts +11 -11
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +1 -1
- package/src/components/UiIcon/UiIcon.vue +3 -2
- package/src/components/UiInput/UiInput.vue +19 -3
- package/src/components/UiInput/mcp-docs.json +51 -0
- package/src/components/UiItem/UiItem.stories.ts +118 -2
- package/src/components/UiItem/__tests__/UiItem.test.ts +3 -5
- package/src/components/UiItem/mcp-docs.json +25 -0
- package/src/components/UiLabel/UiLabel.vue +1 -1
- package/src/components/UiListbox/UiListbox.vue +3 -6
- package/src/components/UiListbox/UiListboxFilter.vue +1 -1
- package/src/components/UiListbox/UiListboxItem.vue +1 -1
- package/src/components/UiProgress/UiProgress.vue +1 -1
- package/src/components/UiRadioGroup/UiRadioGroup.vue +1 -1
- package/src/components/UiRadioGroup/UiRadioGroupItem.vue +2 -2
- package/src/components/UiRadioGroup/__tests__/UiRadioGroup.test.ts +2 -2
- package/src/components/UiRangeCalendar/UiRangeCalendar.vue +2 -5
- package/src/components/UiRangeCalendar/__tests__/UiRangeCalendar.test.ts +9 -6
- package/src/components/UiSelect/UiSelect.stories.ts +4 -90
- package/src/components/UiSelect/UiSelect.vue +66 -144
- package/src/components/UiSelect/UiSelectContent.vue +8 -21
- package/src/components/UiSelect/UiSelectItem.vue +0 -82
- package/src/components/UiSelect/UiSelectTrigger.vue +1 -62
- package/src/components/UiSelect/UiSelectValue.vue +1 -47
- package/src/components/UiSelect/__tests__/UiSelect.test.ts +47 -98
- package/src/components/UiSelect/__tests__/UiSelectContent.test.ts +36 -3
- package/src/components/UiSelect/__tests__/UiSelectItem.test.ts +1 -1
- package/src/components/UiSelect/__tests__/UiSelectTrigger.test.ts +2 -2
- package/src/components/UiSelect/types.ts +29 -6
- package/src/components/UiSwitch/UiSwitch.vue +1 -1
- package/src/components/UiTagsInput/UiTagsInput.vue +1 -1
- package/src/components/UiTagsInput/UiTagsInputInput.vue +1 -1
- package/src/components/UiTagsInput/UiTagsInputItem.vue +1 -1
- package/src/components/UiTagsInput/types.ts +1 -4
- package/src/components/UiTooltip/UiTooltip.stories.ts +0 -8
- package/src/components/core/accordion/AccordionItem.vue +1 -1
- package/src/components/core/alert-dialog/AlertDialogContent.vue +1 -1
- package/src/components/core/badge/Badge.vue +2 -5
- package/src/components/core/calendar/CalendarHeading.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuSub.vue +1 -1
- package/src/components/core/item/index.ts +1 -1
- package/src/components/core/listbox/Listbox.vue +2 -5
- package/src/components/core/listbox/ListboxContent.vue +2 -5
- package/src/components/core/listbox/ListboxFilter.vue +2 -5
- package/src/components/core/listbox/ListboxGroup.vue +2 -5
- package/src/components/core/listbox/ListboxGroupLabel.vue +2 -5
- package/src/components/core/listbox/ListboxItem.vue +2 -5
- package/src/components/core/listbox/ListboxItemIndicator.vue +2 -5
- package/src/components/core/range-calendar/RangeCalendarHeading.vue +1 -1
- package/src/components/core/sidebar/SidebarContent.vue +4 -5
- package/src/components/core/sidebar/SidebarFooter.vue +4 -5
- package/src/components/core/sidebar/SidebarGroup.vue +4 -5
- package/src/components/core/sidebar/SidebarHeader.vue +4 -5
- package/src/components/core/sidebar/SidebarMenu.vue +4 -5
- package/src/components/core/sidebar/SidebarMenuAction.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuButtonChild.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuSkeleton.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuSubButton.vue +1 -1
- package/src/components/core/sidebar/SidebarSeparator.vue +4 -5
- package/src/components/core/stepper/StepperDescription.vue +1 -1
- package/src/components/core/stepper/StepperIndicator.vue +1 -1
- package/src/components/core/stepper/StepperItem.vue +1 -1
- package/src/components/core/tags-input/TagsInput.vue +2 -5
- package/src/components/core/tags-input/TagsInputInput.vue +2 -5
- package/src/components/core/tags-input/TagsInputItem.vue +2 -5
- package/src/components/core/tags-input/TagsInputItemDelete.vue +2 -5
- package/src/components/core/tags-input/TagsInputItemText.vue +2 -5
- package/src/components/core/toggle/Toggle.vue +1 -1
- package/src/index.ts +30 -5
- package/src/lib/useDrag.ts +1 -0
- package/src/lib/utils.ts +12 -0
- package/src/patterns/UiDataTable/UiDataTable.mock.ts +13 -4
- package/src/patterns/UiDataTable/UiDataTable.vue +1 -0
- package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +11 -2
- package/src/patterns/UiDatePicker/__tests__/UiDatePicker.test.ts +28 -39
- package/src/patterns/UiSidebar/UiSidebarContent.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarFooter.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarGroup.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarGroupContent.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarHeader.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarInset.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarMenu.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarMenuItem.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarMenuSub.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarPopoverMenu.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarProvider.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarRail.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarSub.vue +4 -5
- package/src/patterns/UiSidebar/__tests__/UiSidebar.test.ts +21 -17
- package/src/patterns/UiSidebar/__tests__/UiSidebarMenuButton.test.ts +12 -10
- package/src/patterns/UiSidebar/types.ts +8 -8
- package/src/theme/Typography.stories.ts +3 -2
- package/dist/system/components/UiSelect/context.d.ts +0 -28
- package/src/components/UiSelect/context.ts +0 -42
|
@@ -5,6 +5,22 @@ import type { DateRange } from 'reka-ui';
|
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
6
|
import UiDatePicker from '../UiDatePicker.vue';
|
|
7
7
|
|
|
8
|
+
function getEnabledDateButton(
|
|
9
|
+
cells: HTMLElement[],
|
|
10
|
+
index = 0,
|
|
11
|
+
): HTMLButtonElement {
|
|
12
|
+
const enabledCells = cells.filter(
|
|
13
|
+
(cell) => !cell.querySelector('button')?.hasAttribute('data-disabled'),
|
|
14
|
+
);
|
|
15
|
+
const button = enabledCells[index]?.querySelector('button');
|
|
16
|
+
|
|
17
|
+
if (!button) {
|
|
18
|
+
throw new Error(`Expected enabled date button at index ${index}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return button;
|
|
22
|
+
}
|
|
23
|
+
|
|
8
24
|
describe('UiDatePicker', () => {
|
|
9
25
|
const testDate = new CalendarDate(2025, 1, 15);
|
|
10
26
|
|
|
@@ -47,13 +63,9 @@ describe('UiDatePicker', () => {
|
|
|
47
63
|
|
|
48
64
|
// Find and click a date cell (use findAllByRole to wait for async component)
|
|
49
65
|
const cells = await findAllByRole('gridcell');
|
|
50
|
-
const
|
|
51
|
-
(cell) => !cell.querySelector('button')?.hasAttribute('data-disabled'),
|
|
52
|
-
);
|
|
53
|
-
const dateButton = clickableCell?.querySelector('button');
|
|
54
|
-
expect(dateButton).toBeInTheDocument();
|
|
66
|
+
const dateButton = getEnabledDateButton(cells);
|
|
55
67
|
|
|
56
|
-
await userEvent.click(dateButton
|
|
68
|
+
await userEvent.click(dateButton);
|
|
57
69
|
|
|
58
70
|
const emittedEvents = emitted('update:modelValue');
|
|
59
71
|
expect(emittedEvents).toHaveLength(1);
|
|
@@ -82,10 +94,7 @@ describe('UiDatePicker', () => {
|
|
|
82
94
|
// Open and select a different date (use findAllByRole to wait for async component)
|
|
83
95
|
await userEvent.click(getByRole('button'));
|
|
84
96
|
const cells = await findAllByRole('gridcell');
|
|
85
|
-
|
|
86
|
-
(cell) => !cell.querySelector('button')?.hasAttribute('data-disabled'),
|
|
87
|
-
);
|
|
88
|
-
await userEvent.click(clickableCell!.querySelector('button')!);
|
|
97
|
+
await userEvent.click(getEnabledDateButton(cells));
|
|
89
98
|
|
|
90
99
|
// Display should update to show the newly selected date (not the placeholder)
|
|
91
100
|
const buttonText = getByRole('button').textContent;
|
|
@@ -107,10 +116,7 @@ describe('UiDatePicker', () => {
|
|
|
107
116
|
|
|
108
117
|
// Select a date (use findAllByRole to wait for async component)
|
|
109
118
|
const cells = await findAllByRole('gridcell');
|
|
110
|
-
|
|
111
|
-
(cell) => !cell.querySelector('button')?.hasAttribute('data-disabled'),
|
|
112
|
-
);
|
|
113
|
-
await userEvent.click(clickableCell!.querySelector('button')!);
|
|
119
|
+
await userEvent.click(getEnabledDateButton(cells));
|
|
114
120
|
|
|
115
121
|
// Popover should be closed
|
|
116
122
|
expect(queryByRole('dialog')).not.toBeInTheDocument();
|
|
@@ -127,10 +133,7 @@ describe('UiDatePicker', () => {
|
|
|
127
133
|
|
|
128
134
|
// Select a date (use findAllByRole to wait for async component)
|
|
129
135
|
const cells = await findAllByRole('gridcell');
|
|
130
|
-
|
|
131
|
-
(cell) => !cell.querySelector('button')?.hasAttribute('data-disabled'),
|
|
132
|
-
);
|
|
133
|
-
await userEvent.click(clickableCell!.querySelector('button')!);
|
|
136
|
+
await userEvent.click(getEnabledDateButton(cells));
|
|
134
137
|
|
|
135
138
|
// Popover should remain open
|
|
136
139
|
expect(queryByRole('dialog')).toBeInTheDocument();
|
|
@@ -200,15 +203,11 @@ describe('UiDatePicker', () => {
|
|
|
200
203
|
|
|
201
204
|
// Find and click two date cells (use findAllByRole to wait for async component)
|
|
202
205
|
const cells = await findAllByRole('gridcell');
|
|
203
|
-
const clickableCells = cells.filter(
|
|
204
|
-
(cell) => !cell.querySelector('button')?.hasAttribute('data-disabled'),
|
|
205
|
-
);
|
|
206
|
-
|
|
207
206
|
// Click first date (start)
|
|
208
|
-
await userEvent.click(
|
|
207
|
+
await userEvent.click(getEnabledDateButton(cells, 5));
|
|
209
208
|
|
|
210
209
|
// Click second date (end)
|
|
211
|
-
await userEvent.click(
|
|
210
|
+
await userEvent.click(getEnabledDateButton(cells, 10));
|
|
212
211
|
|
|
213
212
|
const emittedEvents = emitted('update:modelValue');
|
|
214
213
|
expect(emittedEvents.length).toBeGreaterThanOrEqual(1);
|
|
@@ -230,16 +229,13 @@ describe('UiDatePicker', () => {
|
|
|
230
229
|
|
|
231
230
|
// Select first date (use findAllByRole to wait for async component)
|
|
232
231
|
const cells = await findAllByRole('gridcell');
|
|
233
|
-
|
|
234
|
-
(cell) => !cell.querySelector('button')?.hasAttribute('data-disabled'),
|
|
235
|
-
);
|
|
236
|
-
await userEvent.click(clickableCells[5]?.querySelector('button')!);
|
|
232
|
+
await userEvent.click(getEnabledDateButton(cells, 5));
|
|
237
233
|
|
|
238
234
|
// Popover should still be open (only start date selected)
|
|
239
235
|
expect(queryByRole('dialog')).toBeInTheDocument();
|
|
240
236
|
|
|
241
237
|
// Select second date
|
|
242
|
-
await userEvent.click(
|
|
238
|
+
await userEvent.click(getEnabledDateButton(cells, 10));
|
|
243
239
|
|
|
244
240
|
// Now popover should close (both dates selected)
|
|
245
241
|
expect(queryByRole('dialog')).not.toBeInTheDocument();
|
|
@@ -296,10 +292,7 @@ describe('UiDatePicker', () => {
|
|
|
296
292
|
|
|
297
293
|
// Wait for calendar grid cells to load (findAllByRole waits for elements)
|
|
298
294
|
const cells = await findAllByRole('gridcell');
|
|
299
|
-
|
|
300
|
-
(cell) => !cell.querySelector('button')?.hasAttribute('data-disabled'),
|
|
301
|
-
);
|
|
302
|
-
await userEvent.click(clickableCell!.querySelector('button')!);
|
|
295
|
+
await userEvent.click(getEnabledDateButton(cells));
|
|
303
296
|
|
|
304
297
|
// Should emit the selected date
|
|
305
298
|
const emittedEvents = emitted('update:modelValue');
|
|
@@ -317,12 +310,8 @@ describe('UiDatePicker', () => {
|
|
|
317
310
|
|
|
318
311
|
// Wait for calendar grid cells to load (findAllByRole waits for elements)
|
|
319
312
|
const cells = await findAllByRole('gridcell');
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
);
|
|
323
|
-
|
|
324
|
-
await userEvent.click(clickableCells[5]?.querySelector('button')!);
|
|
325
|
-
await userEvent.click(clickableCells[10]?.querySelector('button')!);
|
|
313
|
+
await userEvent.click(getEnabledDateButton(cells, 5));
|
|
314
|
+
await userEvent.click(getEnabledDateButton(cells, 10));
|
|
326
315
|
|
|
327
316
|
// Should emit the date range
|
|
328
317
|
const emittedEvents = emitted('update:modelValue');
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { SidebarContent } from '@/components/core/sidebar';
|
|
3
|
-
import type { UiSidebarContentProps } from './types';
|
|
4
3
|
|
|
5
4
|
defineOptions({ name: 'UiSidebarContent' });
|
|
6
|
-
|
|
7
|
-
defineProps<UiSidebarContentProps>();
|
|
8
5
|
</script>
|
|
9
6
|
|
|
10
7
|
<template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, provide, ref, useAttrs } from 'vue';
|
|
3
3
|
import { SidebarGroup } from '@/components/core/sidebar';
|
|
4
|
-
import { cn } from '@/lib/utils';
|
|
4
|
+
import { cn, omitClass } from '@/lib/utils';
|
|
5
5
|
import { uiSidebarGroupContextKey } from './groupContext';
|
|
6
6
|
import type { UiSidebarGroupProps } from './types';
|
|
7
7
|
|
|
@@ -26,10 +26,9 @@ const groupClass = computed(() =>
|
|
|
26
26
|
cn('!p-2', attrs.class as string | undefined),
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
-
const passthroughAttrs = computed(() =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
29
|
+
const passthroughAttrs = computed(() =>
|
|
30
|
+
omitClass(attrs as Record<string, unknown>),
|
|
31
|
+
);
|
|
33
32
|
|
|
34
33
|
provide(uiSidebarGroupContextKey, {
|
|
35
34
|
open,
|
|
@@ -9,12 +9,9 @@ import {
|
|
|
9
9
|
onHeightTransitionLeave,
|
|
10
10
|
} from '@/lib/heightTransition';
|
|
11
11
|
import { uiSidebarGroupContextKey } from './groupContext';
|
|
12
|
-
import type { UiSidebarGroupContentProps } from './types';
|
|
13
12
|
|
|
14
13
|
defineOptions({ name: 'UiSidebarGroupContent' });
|
|
15
14
|
|
|
16
|
-
defineProps<UiSidebarGroupContentProps>();
|
|
17
|
-
|
|
18
15
|
const group = inject(uiSidebarGroupContextKey, null);
|
|
19
16
|
</script>
|
|
20
17
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, useAttrs } from 'vue';
|
|
3
3
|
import { SidebarHeader } from '@/components/core/sidebar';
|
|
4
|
-
import { cn } from '@/lib/utils';
|
|
4
|
+
import { cn, omitClass } from '@/lib/utils';
|
|
5
5
|
import UiSidebarTrigger from './UiSidebarTrigger.vue';
|
|
6
6
|
import type { UiSidebarHeaderProps } from './types';
|
|
7
7
|
|
|
@@ -19,10 +19,9 @@ const attrs = useAttrs();
|
|
|
19
19
|
|
|
20
20
|
const headerClass = computed(() => cn(attrs.class as string | undefined));
|
|
21
21
|
|
|
22
|
-
const passthroughAttrs = computed(() =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
22
|
+
const passthroughAttrs = computed(() =>
|
|
23
|
+
omitClass(attrs as Record<string, unknown>),
|
|
24
|
+
);
|
|
26
25
|
</script>
|
|
27
26
|
|
|
28
27
|
<template>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { computed, useAttrs, useSlots } from 'vue';
|
|
3
3
|
import { SidebarMenuButton } from '@/components/core/sidebar';
|
|
4
4
|
import { ACTIVE_INDICATOR_CLASS } from '@/lib/activeIndicator';
|
|
5
|
-
import { cn } from '@/lib/utils';
|
|
5
|
+
import { cn, omitClass } from '@/lib/utils';
|
|
6
6
|
import type {
|
|
7
7
|
UiSidebarMenuButtonEmits,
|
|
8
8
|
UiSidebarMenuButtonProps,
|
|
@@ -67,10 +67,9 @@ const endIconClass = computed(() =>
|
|
|
67
67
|
),
|
|
68
68
|
);
|
|
69
69
|
|
|
70
|
-
const passthroughAttrs = computed(() =>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
70
|
+
const passthroughAttrs = computed(() =>
|
|
71
|
+
omitClass(attrs as Record<string, unknown>),
|
|
72
|
+
);
|
|
74
73
|
|
|
75
74
|
function onEndIconClick(event: MouseEvent) {
|
|
76
75
|
event.stopPropagation();
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { SidebarMenuItem } from '@/components/core/sidebar';
|
|
3
|
-
import type { UiSidebarMenuItemProps } from './types';
|
|
4
3
|
|
|
5
4
|
defineOptions({ name: 'UiSidebarMenuItem' });
|
|
6
|
-
|
|
7
|
-
defineProps<UiSidebarMenuItemProps>();
|
|
8
5
|
</script>
|
|
9
6
|
|
|
10
7
|
<template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, useAttrs } from 'vue';
|
|
3
3
|
import { SidebarMenuSub } from '@/components/core/sidebar';
|
|
4
|
-
import { cn } from '@/lib/utils';
|
|
4
|
+
import { cn, omitClass } from '@/lib/utils';
|
|
5
5
|
import type { UiSidebarMenuSubProps } from './types';
|
|
6
6
|
|
|
7
7
|
defineOptions({
|
|
@@ -27,10 +27,9 @@ const subClass = computed(() =>
|
|
|
27
27
|
),
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
-
const passthroughAttrs = computed(() =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
30
|
+
const passthroughAttrs = computed(() =>
|
|
31
|
+
omitClass(attrs as Record<string, unknown>),
|
|
32
|
+
);
|
|
34
33
|
</script>
|
|
35
34
|
|
|
36
35
|
<template>
|
|
@@ -3,7 +3,7 @@ import { computed, useAttrs } from 'vue';
|
|
|
3
3
|
import { Primitive } from 'reka-ui';
|
|
4
4
|
import { SidebarMenuSubItem as UiSidebarMenuItem } from '@/components/core/sidebar';
|
|
5
5
|
import { ACTIVE_INDICATOR_CLASS } from '@/lib/activeIndicator';
|
|
6
|
-
import { cn } from '@/lib/utils';
|
|
6
|
+
import { cn, omitClass } from '@/lib/utils';
|
|
7
7
|
import type { UiSidebarMenuSubItemProps } from './types';
|
|
8
8
|
|
|
9
9
|
defineOptions({
|
|
@@ -42,10 +42,9 @@ const itemClass = computed(() =>
|
|
|
42
42
|
),
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
const passthroughAttrs = computed(() =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
45
|
+
const passthroughAttrs = computed(() =>
|
|
46
|
+
omitClass(attrs as Record<string, unknown>),
|
|
47
|
+
);
|
|
49
48
|
</script>
|
|
50
49
|
|
|
51
50
|
<template>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, useAttrs } from 'vue';
|
|
3
|
-
import { cn } from '@/lib/utils';
|
|
3
|
+
import { cn, omitClass } from '@/lib/utils';
|
|
4
4
|
import type { UiSidebarPopoverMenuProps } from './types';
|
|
5
5
|
|
|
6
6
|
defineOptions({
|
|
@@ -22,10 +22,9 @@ const menuClass = computed(() =>
|
|
|
22
22
|
),
|
|
23
23
|
);
|
|
24
24
|
|
|
25
|
-
const passthroughAttrs = computed(() =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
25
|
+
const passthroughAttrs = computed(() =>
|
|
26
|
+
omitClass(attrs as Record<string, unknown>),
|
|
27
|
+
);
|
|
29
28
|
</script>
|
|
30
29
|
|
|
31
30
|
<template>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { computed, useAttrs } from 'vue';
|
|
3
3
|
import { Primitive } from 'reka-ui';
|
|
4
4
|
import { ACTIVE_INDICATOR_CLASS } from '@/lib/activeIndicator';
|
|
5
|
-
import { cn } from '@/lib/utils';
|
|
5
|
+
import { cn, omitClass } from '@/lib/utils';
|
|
6
6
|
import type { UiSidebarPopoverMenuItemProps } from './types';
|
|
7
7
|
|
|
8
8
|
defineOptions({
|
|
@@ -39,10 +39,9 @@ const itemClass = computed(() =>
|
|
|
39
39
|
),
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
const passthroughAttrs = computed(() =>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
42
|
+
const passthroughAttrs = computed(() =>
|
|
43
|
+
omitClass(attrs as Record<string, unknown>),
|
|
44
|
+
);
|
|
46
45
|
</script>
|
|
47
46
|
|
|
48
47
|
<template>
|
|
@@ -3,7 +3,7 @@ import { computed, useAttrs } from 'vue';
|
|
|
3
3
|
import { SidebarMenuButton } from '@/components/core/sidebar';
|
|
4
4
|
import { UiIcon } from '@/components/UiIcon';
|
|
5
5
|
import { ACTIVE_INDICATOR_CLASS } from '@/lib/activeIndicator';
|
|
6
|
-
import { cn } from '@/lib/utils';
|
|
6
|
+
import { cn, omitClass } from '@/lib/utils';
|
|
7
7
|
import type { UiSidebarPopoverTriggerProps } from './types';
|
|
8
8
|
|
|
9
9
|
defineOptions({
|
|
@@ -42,10 +42,9 @@ const rootClass = computed(() =>
|
|
|
42
42
|
),
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
const passthroughAttrs = computed(() =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
45
|
+
const passthroughAttrs = computed(() =>
|
|
46
|
+
omitClass(attrs as Record<string, unknown>),
|
|
47
|
+
);
|
|
49
48
|
</script>
|
|
50
49
|
|
|
51
50
|
<template>
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { SidebarProvider } from '@/components/core/sidebar';
|
|
3
|
-
import type { UiSidebarProviderProps } from './types';
|
|
4
3
|
|
|
5
4
|
defineOptions({ name: 'UiSidebarProvider' });
|
|
6
|
-
|
|
7
|
-
defineProps<UiSidebarProviderProps>();
|
|
8
5
|
</script>
|
|
9
6
|
|
|
10
7
|
<template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, useAttrs } from 'vue';
|
|
3
3
|
import { SidebarMenuSub } from '@/components/core/sidebar';
|
|
4
|
-
import { cn } from '@/lib/utils';
|
|
4
|
+
import { cn, omitClass } from '@/lib/utils';
|
|
5
5
|
import type { UiSidebarSubProps } from './types';
|
|
6
6
|
|
|
7
7
|
defineOptions({
|
|
@@ -46,10 +46,9 @@ const rootClass = computed(() =>
|
|
|
46
46
|
),
|
|
47
47
|
);
|
|
48
48
|
|
|
49
|
-
const passthroughAttrs = computed(() =>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
49
|
+
const passthroughAttrs = computed(() =>
|
|
50
|
+
omitClass(attrs as Record<string, unknown>),
|
|
51
|
+
);
|
|
53
52
|
</script>
|
|
54
53
|
|
|
55
54
|
<template>
|
|
@@ -13,6 +13,18 @@ beforeEach(() => {
|
|
|
13
13
|
});
|
|
14
14
|
afterEach(() => vi.restoreAllMocks());
|
|
15
15
|
|
|
16
|
+
function getResizeHandle(container: HTMLElement): HTMLElement {
|
|
17
|
+
const resizeHandle = container.querySelector<HTMLElement>(
|
|
18
|
+
'[data-slot="sidebar-resize-handle"]',
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
if (!resizeHandle) {
|
|
22
|
+
throw new Error('Expected sidebar resize handle to be rendered');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return resizeHandle;
|
|
26
|
+
}
|
|
27
|
+
|
|
16
28
|
describe('UiSidebar', () => {
|
|
17
29
|
test('renders core sidebar region (collapsible none uses data-slot)', () => {
|
|
18
30
|
const { container } = render(createSidebarShell('<span>Main</span>'));
|
|
@@ -102,11 +114,9 @@ describe('UiSidebar', () => {
|
|
|
102
114
|
const sidebar = container.querySelector<HTMLElement>(
|
|
103
115
|
'[data-slot="sidebar"]',
|
|
104
116
|
);
|
|
105
|
-
const resizeHandle = container
|
|
106
|
-
'[data-slot="sidebar-resize-handle"]',
|
|
107
|
-
);
|
|
117
|
+
const resizeHandle = getResizeHandle(container);
|
|
108
118
|
|
|
109
|
-
await fireEvent.keyDown(resizeHandle
|
|
119
|
+
await fireEvent.keyDown(resizeHandle, { key: 'ArrowRight' });
|
|
110
120
|
|
|
111
121
|
expect(sidebar?.style.getPropertyValue('--sidebar-width')).toBe('304px');
|
|
112
122
|
});
|
|
@@ -133,13 +143,11 @@ describe('UiSidebar', () => {
|
|
|
133
143
|
const sidebar = container.querySelector<HTMLElement>(
|
|
134
144
|
'[data-slot="sidebar"]',
|
|
135
145
|
);
|
|
136
|
-
const resizeHandle = container
|
|
137
|
-
'[data-slot="sidebar-resize-handle"]',
|
|
138
|
-
);
|
|
146
|
+
const resizeHandle = getResizeHandle(container);
|
|
139
147
|
|
|
140
148
|
expect(resizeHandle).toHaveAttribute('aria-label', 'Resize with options');
|
|
141
149
|
|
|
142
|
-
await fireEvent.keyDown(resizeHandle
|
|
150
|
+
await fireEvent.keyDown(resizeHandle, { key: 'ArrowRight' });
|
|
143
151
|
expect(sidebar?.style.getPropertyValue('--sidebar-width')).toBe('304px');
|
|
144
152
|
});
|
|
145
153
|
|
|
@@ -184,11 +192,9 @@ describe('UiSidebar', () => {
|
|
|
184
192
|
const sidebar = container.querySelector<HTMLElement>(
|
|
185
193
|
'[data-slot="sidebar"]',
|
|
186
194
|
);
|
|
187
|
-
const resizeHandle = container
|
|
188
|
-
'[data-slot="sidebar-resize-handle"]',
|
|
189
|
-
);
|
|
195
|
+
const resizeHandle = getResizeHandle(container);
|
|
190
196
|
|
|
191
|
-
await fireEvent.keyDown(resizeHandle
|
|
197
|
+
await fireEvent.keyDown(resizeHandle, { key: 'ArrowRight' });
|
|
192
198
|
expect(sidebar?.style.getPropertyValue('--sidebar-width')).toBe('310px');
|
|
193
199
|
});
|
|
194
200
|
|
|
@@ -214,20 +220,18 @@ describe('UiSidebar', () => {
|
|
|
214
220
|
const sidebar = container.querySelector<HTMLElement>(
|
|
215
221
|
'[data-slot="sidebar"]',
|
|
216
222
|
);
|
|
217
|
-
const resizeHandle = container
|
|
218
|
-
'[data-slot="sidebar-resize-handle"]',
|
|
219
|
-
);
|
|
223
|
+
const resizeHandle = getResizeHandle(container);
|
|
220
224
|
|
|
221
225
|
expect(resizeHandle).toBeTruthy();
|
|
222
226
|
|
|
223
|
-
await fireEvent.pointerDown(resizeHandle
|
|
227
|
+
await fireEvent.pointerDown(resizeHandle, { clientX: 0 });
|
|
224
228
|
await fireEvent.pointerMove(window, { clientX: 500 });
|
|
225
229
|
await fireEvent.pointerUp(window);
|
|
226
230
|
|
|
227
231
|
expect(sidebar?.style.getPropertyValue('--sidebar-width')).toBe('480px');
|
|
228
232
|
expect(localStorage.getItem('test-sidebar-width')).toBe('480');
|
|
229
233
|
|
|
230
|
-
await fireEvent.pointerDown(resizeHandle
|
|
234
|
+
await fireEvent.pointerDown(resizeHandle, { clientX: 500 });
|
|
231
235
|
await fireEvent.pointerMove(window, { clientX: -500 });
|
|
232
236
|
await fireEvent.pointerUp(window);
|
|
233
237
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { render } from '@testing-library/vue';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
|
-
import { defineComponent } from 'vue';
|
|
4
3
|
import { describe, expect, test, beforeEach, afterEach, vi } from 'vitest';
|
|
5
4
|
import UiSidebar from '../UiSidebar.vue';
|
|
6
5
|
import UiSidebarContent from '../UiSidebarContent.vue';
|
|
@@ -15,7 +14,7 @@ afterEach(() => vi.restoreAllMocks());
|
|
|
15
14
|
|
|
16
15
|
describe('UiSidebarMenuButton', () => {
|
|
17
16
|
test('renders only one button when tooltip is not provided', () => {
|
|
18
|
-
const Harness =
|
|
17
|
+
const Harness = {
|
|
19
18
|
components: {
|
|
20
19
|
UiSidebarProvider,
|
|
21
20
|
UiSidebar,
|
|
@@ -39,14 +38,14 @@ describe('UiSidebarMenuButton', () => {
|
|
|
39
38
|
</UiSidebar>
|
|
40
39
|
</UiSidebarProvider>
|
|
41
40
|
`,
|
|
42
|
-
}
|
|
41
|
+
};
|
|
43
42
|
const { getAllByRole } = render(Harness);
|
|
44
43
|
|
|
45
44
|
expect(getAllByRole('button', { name: 'Item' })).toHaveLength(1);
|
|
46
45
|
});
|
|
47
46
|
|
|
48
47
|
test('uses the shared active indicator class', () => {
|
|
49
|
-
const Harness =
|
|
48
|
+
const Harness = {
|
|
50
49
|
components: {
|
|
51
50
|
UiSidebarProvider,
|
|
52
51
|
UiSidebar,
|
|
@@ -70,7 +69,7 @@ describe('UiSidebarMenuButton', () => {
|
|
|
70
69
|
</UiSidebar>
|
|
71
70
|
</UiSidebarProvider>
|
|
72
71
|
`,
|
|
73
|
-
}
|
|
72
|
+
};
|
|
74
73
|
const { container } = render(Harness);
|
|
75
74
|
|
|
76
75
|
const activeIndicator = container.querySelector('.ui-active-indicator');
|
|
@@ -81,7 +80,7 @@ describe('UiSidebarMenuButton', () => {
|
|
|
81
80
|
test('renders label and emits end-icon-click when endIconClickable', async () => {
|
|
82
81
|
const user = userEvent.setup();
|
|
83
82
|
const onEndIconClick = vi.fn();
|
|
84
|
-
const Harness =
|
|
83
|
+
const Harness = {
|
|
85
84
|
components: {
|
|
86
85
|
UiSidebarProvider,
|
|
87
86
|
UiSidebar,
|
|
@@ -115,11 +114,14 @@ describe('UiSidebarMenuButton', () => {
|
|
|
115
114
|
</UiSidebar>
|
|
116
115
|
</UiSidebarProvider>
|
|
117
116
|
`,
|
|
118
|
-
}
|
|
117
|
+
};
|
|
119
118
|
const { getAllByRole } = render(Harness);
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
const endButton = getAllByRole('button', { name: 'Open tree' }).at(0);
|
|
120
|
+
if (!endButton) {
|
|
121
|
+
throw new Error('Expected end icon button to be rendered');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
await user.click(endButton);
|
|
123
125
|
expect(onEndIconClick).toHaveBeenCalledTimes(1);
|
|
124
126
|
});
|
|
125
127
|
});
|
|
@@ -323,39 +323,39 @@ export type UiSidebarPopoverMenuItemEmits = Record<string, never>;
|
|
|
323
323
|
/**
|
|
324
324
|
* Pass-through pattern shells: no pattern-level props; attributes are forwarded to the core sidebar component.
|
|
325
325
|
*/
|
|
326
|
-
export
|
|
326
|
+
export type UiSidebarContentProps = Record<string, never>;
|
|
327
327
|
|
|
328
328
|
/**
|
|
329
329
|
* @see UiSidebarContentProps
|
|
330
330
|
*/
|
|
331
|
-
export
|
|
331
|
+
export type UiSidebarFooterProps = Record<string, never>;
|
|
332
332
|
|
|
333
333
|
/**
|
|
334
334
|
* @see UiSidebarContentProps
|
|
335
335
|
*/
|
|
336
|
-
export
|
|
336
|
+
export type UiSidebarGroupContentProps = Record<string, never>;
|
|
337
337
|
|
|
338
338
|
/**
|
|
339
339
|
* @see UiSidebarContentProps
|
|
340
340
|
*/
|
|
341
|
-
export
|
|
341
|
+
export type UiSidebarInsetProps = Record<string, never>;
|
|
342
342
|
|
|
343
343
|
/**
|
|
344
344
|
* @see UiSidebarContentProps
|
|
345
345
|
*/
|
|
346
|
-
export
|
|
346
|
+
export type UiSidebarMenuProps = Record<string, never>;
|
|
347
347
|
|
|
348
348
|
/**
|
|
349
349
|
* @see UiSidebarContentProps
|
|
350
350
|
*/
|
|
351
|
-
export
|
|
351
|
+
export type UiSidebarMenuItemProps = Record<string, never>;
|
|
352
352
|
|
|
353
353
|
/**
|
|
354
354
|
* @see UiSidebarContentProps
|
|
355
355
|
*/
|
|
356
|
-
export
|
|
356
|
+
export type UiSidebarProviderProps = Record<string, never>;
|
|
357
357
|
|
|
358
358
|
/**
|
|
359
359
|
* @see UiSidebarContentProps
|
|
360
360
|
*/
|
|
361
|
-
export
|
|
361
|
+
export type UiSidebarRailProps = Record<string, never>;
|