@aleph-alpha/ui-library 5.3.1 → 5.5.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 +38 -3
- package/config.js +103 -6
- package/dist/system/lib.js +8926 -8768
- package/dist/system/patterns/UiDataTable/UiDataTableFilterMenu.vue.d.ts +24 -0
- package/dist/system/patterns/UiDataTable/constants.d.ts +10 -0
- package/dist/system/patterns/UiDataTable/index.d.ts +1 -0
- package/dist/system/patterns/UiDataTable/types.d.ts +23 -1
- package/dist/system/patterns/UiFloatActions/UiFloatActionItems.vue.d.ts +173 -2
- package/dist/system/patterns/UiFloatActions/floatActionItemContext.d.ts +15 -1
- package/dist/system/patterns/UiFloatActions/types.d.ts +25 -1
- package/dist/system/story-sidebar-icons.json +5 -1
- package/docs/public-docs/getting-started-designers.md +3 -1
- package/package.json +5 -3
- package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +2 -1
- package/src/components/UiAutocomplete/UiAutocomplete.vue +5 -5
- package/src/components/UiButton/UiButton.stories.ts +14 -14
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +260 -9
- package/src/components/UiCheckbox/__tests__/UiCheckbox.test.ts +3 -18
- package/src/components/UiChip/UiChip.vue +1 -1
- package/src/components/UiDrawer/UiDrawer.stories.ts +2 -2
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +4 -4
- package/src/components/UiEmpty/UiEmpty.vue +2 -2
- package/src/components/UiField/UiField.stories.ts +610 -3
- package/src/components/UiField/UiFieldDescription.vue +7 -2
- package/src/components/UiField/UiFieldLabelInfo.vue +1 -1
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +2 -2
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +2 -2
- package/src/components/UiInput/UiInput.stories.ts +336 -2
- package/src/components/UiInput/UiInput.vue +3 -3
- package/src/components/UiInput/__tests__/UiInput.test.ts +20 -28
- package/src/components/UiItem/UiItem.stories.ts +236 -1
- package/src/components/UiItem/__tests__/UiItem.test.ts +11 -72
- package/src/components/UiKbd/UiKbd.stories.ts +14 -14
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +42 -42
- package/src/components/UiPopover/UiPopover.stories.ts +6 -6
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +2 -2
- package/src/components/UiResizable/UiResizable.stories.ts +6 -5
- package/src/components/UiSeparator/UiSeparator.stories.ts +6 -6
- package/src/components/UiSheet/UiSheet.stories.ts +2 -2
- package/src/components/UiSlider/UiSlider.stories.ts +8 -8
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +6 -6
- package/src/components/UiSnackbar/UiSnackbar.vue +4 -4
- package/src/components/UiSnackbar/UiSnackbarContent.vue +4 -4
- package/src/components/UiSpinner/UiSpinner.stories.ts +8 -8
- package/src/components/UiSwitch/UiSwitch.stories.ts +2 -2
- package/src/components/UiTabs/UiTabs.stories.ts +30 -30
- package/src/components/UiToggle/__tests__/UiToggle.test.ts +5 -3
- package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +9 -9
- package/src/components/UiTooltip/UiTooltip.stories.ts +3 -3
- package/src/components/core/accordion/AccordionTrigger.vue +2 -2
- package/src/components/core/alert/AlertDescription.vue +1 -1
- package/src/components/core/badge/index.ts +1 -1
- package/src/components/core/button/index.ts +2 -2
- package/src/components/core/calendar/CalendarCellTrigger.vue +2 -2
- package/src/components/core/calendar/CalendarHeadCell.vue +1 -1
- package/src/components/core/card/CardDescription.vue +1 -1
- package/src/components/core/checkbox/Checkbox.vue +1 -2
- package/src/components/core/drawer/DrawerDescription.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuShortcut.vue +1 -1
- package/src/components/core/field/FieldDescription.vue +1 -1
- package/src/components/core/field/FieldLabel.vue +1 -1
- package/src/components/core/field/FieldSeparator.vue +1 -1
- package/src/components/core/input/Input.vue +2 -2
- package/src/components/core/item/index.ts +1 -1
- package/src/components/core/kbd/Kbd.vue +1 -1
- package/src/components/core/listbox/ListboxFilter.vue +1 -1
- package/src/components/core/listbox/ListboxGroupLabel.vue +4 -1
- package/src/components/core/listbox/ListboxItem.vue +1 -1
- package/src/components/core/native-select/NativeSelect.vue +3 -3
- package/src/components/core/navigation-menu/NavigationMenuLink.vue +1 -1
- package/src/components/core/navigation-menu/index.ts +1 -1
- package/src/components/core/radio-group/RadioGroupItem.vue +1 -1
- package/src/components/core/range-calendar/RangeCalendarCellTrigger.vue +2 -2
- package/src/components/core/range-calendar/RangeCalendarHeadCell.vue +1 -1
- package/src/components/core/select/SelectItem.vue +1 -1
- package/src/components/core/select/SelectLabel.vue +4 -1
- package/src/components/core/select/SelectTrigger.vue +1 -1
- package/src/components/core/sheet/SheetDescription.vue +3 -1
- package/src/components/core/switch/Switch.vue +1 -1
- package/src/components/core/table/TableCaption.vue +3 -1
- package/src/components/core/tabs/TabsList.vue +1 -1
- package/src/components/core/tabs/TabsTrigger.vue +1 -1
- package/src/components/core/tags-input/TagsInput.vue +1 -1
- package/src/components/core/tags-input/TagsInputInput.vue +1 -1
- package/src/components/core/tags-input/TagsInputItemDelete.vue +1 -1
- package/src/components/core/textarea/Textarea.vue +1 -1
- package/src/components/core/toggle/index.ts +3 -3
- package/src/components/core/toggle-group/index.ts +2 -2
- package/src/lib/useDrag.stories.ts +8 -8
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +913 -16
- package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +1 -1
- package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +91 -0
- package/src/patterns/UiDataTable/UiDataTablePagination.vue +1 -1
- package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +7 -184
- package/src/patterns/UiDataTable/constants.ts +12 -0
- package/src/patterns/UiDataTable/index.ts +1 -0
- package/src/patterns/UiDataTable/types.ts +24 -0
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +4 -4
- package/src/patterns/UiDatePicker/UiDatePicker.vue +1 -1
- package/src/patterns/UiFloatActions/UiFloatActionItems.vue +140 -12
- package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +1231 -438
- package/src/patterns/UiFloatActions/UiFloatActions.vue +1 -1
- package/src/patterns/UiFloatActions/__tests__/UiFloatActionItems.test.ts +46 -24
- package/src/patterns/UiFloatActions/floatActionItemContext.ts +16 -1
- package/src/patterns/UiFloatActions/types.ts +28 -1
- package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +2 -2
- package/src/components/UiField/__tests__/UiFieldError.test.ts +0 -39
- package/src/patterns/UiFloatActions/__tests__/UiFloatActions.a11y.test.ts +0 -152
|
@@ -67,7 +67,7 @@ function getColumnLabel(column: (typeof columns.value)[number]) {
|
|
|
67
67
|
</template>
|
|
68
68
|
</UiToggle>
|
|
69
69
|
</UiDropdownMenuTrigger>
|
|
70
|
-
<UiDropdownMenuContent align="
|
|
70
|
+
<UiDropdownMenuContent align="start" class="flex flex-col gap-2 p-2">
|
|
71
71
|
<UiDropdownMenuCheckboxItem
|
|
72
72
|
v-for="column in columns"
|
|
73
73
|
:key="column.id"
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script setup lang="ts" generic="TData">
|
|
2
|
+
/**
|
|
3
|
+
* UiDataTableFilterMenu renders a popover of filter controls for a data table.
|
|
4
|
+
*
|
|
5
|
+
* Place filter fields (inputs, checkbox groups, etc.) in the default slot. The
|
|
6
|
+
* trigger is a soft toggle that shows an optional count badge and stays filled
|
|
7
|
+
* while filters are applied.
|
|
8
|
+
* @component UiDataTableFilterMenu
|
|
9
|
+
* @property {number} [activeCount=0] - Number of applied filters. Shows a count
|
|
10
|
+
* badge and keeps the trigger filled when greater than `0`.
|
|
11
|
+
* @property {FilterMenuLabels} [labels] - i18n label overrides.
|
|
12
|
+
* @slot default - Filter controls (usually a form with inputs and checkbox groups).
|
|
13
|
+
*/
|
|
14
|
+
import { UiToggle } from '@/components';
|
|
15
|
+
import { UiBadge } from '@/components/UiBadge';
|
|
16
|
+
import UiIcon from '@/components/UiIcon/UiIcon.vue';
|
|
17
|
+
import UiPopover from '@/components/UiPopover/UiPopover.vue';
|
|
18
|
+
import UiPopoverContent from '@/components/UiPopover/UiPopoverContent.vue';
|
|
19
|
+
import UiPopoverTrigger from '@/components/UiPopover/UiPopoverTrigger.vue';
|
|
20
|
+
import { computed } from 'vue';
|
|
21
|
+
import { DATA_TABLE_LABELS } from './constants';
|
|
22
|
+
import type { UiDataTableFilterMenuProps } from './types';
|
|
23
|
+
|
|
24
|
+
defineOptions({
|
|
25
|
+
name: 'UiDataTableFilterMenu',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const props = defineProps<UiDataTableFilterMenuProps<TData>>();
|
|
29
|
+
|
|
30
|
+
defineSlots<{
|
|
31
|
+
/** Filter controls, usually a form with inputs and checkbox groups. */
|
|
32
|
+
default(): unknown;
|
|
33
|
+
}>();
|
|
34
|
+
|
|
35
|
+
const open = defineModel<boolean>('open', { default: false });
|
|
36
|
+
|
|
37
|
+
const labels = computed(() => ({
|
|
38
|
+
filters: props.labels?.filters ?? DATA_TABLE_LABELS.filters,
|
|
39
|
+
toggleFilters: props.labels?.toggleFilters ?? DATA_TABLE_LABELS.toggleFilters,
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
const activeCount = computed(() => props.activeCount ?? 0);
|
|
43
|
+
const hasActiveFilters = computed(() => activeCount.value > 0);
|
|
44
|
+
|
|
45
|
+
// Keep the accessible name in sync with the visible label (WCAG 2.5.3) and
|
|
46
|
+
// surface the applied count to assistive tech.
|
|
47
|
+
const triggerAriaLabel = computed(() =>
|
|
48
|
+
hasActiveFilters.value
|
|
49
|
+
? `${labels.value.toggleFilters}, ${activeCount.value} applied`
|
|
50
|
+
: labels.value.toggleFilters,
|
|
51
|
+
);
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<template>
|
|
55
|
+
<UiPopover v-model:open="open">
|
|
56
|
+
<UiPopoverTrigger as-child>
|
|
57
|
+
<UiToggle
|
|
58
|
+
:active="open || hasActiveFilters"
|
|
59
|
+
variant="soft"
|
|
60
|
+
size="sm"
|
|
61
|
+
class="label-14-medium h-8"
|
|
62
|
+
left-icon="list-filter"
|
|
63
|
+
:aria-label="triggerAriaLabel"
|
|
64
|
+
>
|
|
65
|
+
<span class="inline-flex items-center gap-2">
|
|
66
|
+
{{ labels.filters }}
|
|
67
|
+
<UiBadge
|
|
68
|
+
v-if="hasActiveFilters"
|
|
69
|
+
variant="default"
|
|
70
|
+
size="small"
|
|
71
|
+
class="h-5 min-w-5 justify-center px-1 label-12-medium"
|
|
72
|
+
>
|
|
73
|
+
{{ activeCount }}
|
|
74
|
+
</UiBadge>
|
|
75
|
+
</span>
|
|
76
|
+
<template #right-icon>
|
|
77
|
+
<UiIcon
|
|
78
|
+
name="chevron-down"
|
|
79
|
+
:size="16"
|
|
80
|
+
aria-hidden="true"
|
|
81
|
+
class="transition-transform"
|
|
82
|
+
:class="open ? 'rotate-180' : undefined"
|
|
83
|
+
/>
|
|
84
|
+
</template>
|
|
85
|
+
</UiToggle>
|
|
86
|
+
</UiPopoverTrigger>
|
|
87
|
+
<UiPopoverContent align="start" side="bottom" class="min-w-[350px]">
|
|
88
|
+
<slot />
|
|
89
|
+
</UiPopoverContent>
|
|
90
|
+
</UiPopover>
|
|
91
|
+
</template>
|
|
@@ -38,7 +38,7 @@ const labels = computed(() => ({
|
|
|
38
38
|
<div class="flex items-center gap-2 justify-between px-2">
|
|
39
39
|
<div
|
|
40
40
|
v-if="showSelection"
|
|
41
|
-
class="flex-1 body-14-regular text-muted
|
|
41
|
+
class="flex-1 body-14-regular text-content-on-surface-muted"
|
|
42
42
|
>
|
|
43
43
|
{{
|
|
44
44
|
labels.rowsSelected(
|
|
@@ -5,7 +5,6 @@ import { h, ref, nextTick } from 'vue';
|
|
|
5
5
|
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
6
6
|
import UiDataTable from '../UiDataTable.vue';
|
|
7
7
|
import UiDataTableColumnFilter from '../UiDataTableColumnFilter.vue';
|
|
8
|
-
import UiDataTableColumnHeader from '../UiDataTableColumnHeader.vue';
|
|
9
8
|
import { UiCheckbox } from '@/components/UiCheckbox';
|
|
10
9
|
|
|
11
10
|
interface TestData {
|
|
@@ -25,19 +24,6 @@ const basicColumns: ColumnDef<TestData>[] = [
|
|
|
25
24
|
{ accessorKey: 'amount', header: 'Amount' },
|
|
26
25
|
];
|
|
27
26
|
|
|
28
|
-
const sortableColumns: ColumnDef<TestData>[] = [
|
|
29
|
-
{
|
|
30
|
-
accessorKey: 'name',
|
|
31
|
-
header: ({ column }) =>
|
|
32
|
-
h(UiDataTableColumnHeader, { column, title: 'Name' }),
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
accessorKey: 'amount',
|
|
36
|
-
header: ({ column }) =>
|
|
37
|
-
h(UiDataTableColumnHeader, { column, title: 'Amount' }),
|
|
38
|
-
},
|
|
39
|
-
];
|
|
40
|
-
|
|
41
27
|
const sizedColumns: ColumnDef<TestData>[] = [
|
|
42
28
|
{ accessorKey: 'name', header: 'Name', size: 200 },
|
|
43
29
|
{ accessorKey: 'amount', header: 'Amount' },
|
|
@@ -451,58 +437,10 @@ describe('UiDataTable', () => {
|
|
|
451
437
|
});
|
|
452
438
|
});
|
|
453
439
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
props: { columns: sortableColumns, data: testData },
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
// Click the Name column header button to sort ascending
|
|
462
|
-
await user.click(getByRole('button', { name: /Name/i }));
|
|
463
|
-
|
|
464
|
-
const cells = getAllByRole('cell');
|
|
465
|
-
// First data row should be Alice (alphabetically first)
|
|
466
|
-
expect(cells[0]).toHaveTextContent('Alice');
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
test('sorts descending on second click', async () => {
|
|
470
|
-
const user = userEvent.setup();
|
|
471
|
-
const { getByRole, getAllByRole } = render(UiDataTable, {
|
|
472
|
-
props: { columns: sortableColumns, data: testData },
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
// First click: ascending
|
|
476
|
-
await user.click(getByRole('button', { name: /Name/i }));
|
|
477
|
-
// Second click: descending
|
|
478
|
-
await user.click(getByRole('button', { name: /Name/i }));
|
|
479
|
-
|
|
480
|
-
const cells = getAllByRole('cell');
|
|
481
|
-
// First data row should be Charlie (alphabetically last)
|
|
482
|
-
expect(cells[0]).toHaveTextContent('Charlie');
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
test('clears sorting on third click', async () => {
|
|
486
|
-
const user = userEvent.setup();
|
|
487
|
-
const { getByRole, getAllByRole } = render(UiDataTable, {
|
|
488
|
-
props: { columns: sortableColumns, data: testData },
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
const initialCells = getAllByRole('cell');
|
|
492
|
-
const initialFirst = initialCells[0].textContent;
|
|
493
|
-
|
|
494
|
-
const headerButton = getByRole('button', { name: /Name/i });
|
|
495
|
-
// First click: ascending
|
|
496
|
-
await user.click(headerButton);
|
|
497
|
-
// Second click: descending
|
|
498
|
-
await user.click(headerButton);
|
|
499
|
-
// Third click: clear sorting (back to original order)
|
|
500
|
-
await user.click(headerButton);
|
|
501
|
-
|
|
502
|
-
const finalCells = getAllByRole('cell');
|
|
503
|
-
expect(finalCells[0]).toHaveTextContent(initialFirst ?? '');
|
|
504
|
-
});
|
|
505
|
-
});
|
|
440
|
+
// Sorting interactions (click/keyboard to sort ascending, descending, and
|
|
441
|
+
// clear) are covered by the `test - Keyboard Navigation` play function in
|
|
442
|
+
// UiDataTable.stories.ts. The column-header wiring is unit-tested in
|
|
443
|
+
// UiDataTableColumnHeader.test.ts.
|
|
506
444
|
|
|
507
445
|
describe('Row Click', () => {
|
|
508
446
|
test('calls onRowClick with row data when a row is clicked', async () => {
|
|
@@ -657,124 +595,9 @@ describe('UiDataTable', () => {
|
|
|
657
595
|
});
|
|
658
596
|
});
|
|
659
597
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
664
|
-
|
|
665
|
-
const { getByLabelText } = render({
|
|
666
|
-
components: { UiDataTable },
|
|
667
|
-
template:
|
|
668
|
-
'<UiDataTable ref="tableRef" :columns="columns" :data="data" />',
|
|
669
|
-
setup() {
|
|
670
|
-
return { tableRef, columns: selectableColumns, data: testData };
|
|
671
|
-
},
|
|
672
|
-
});
|
|
673
|
-
|
|
674
|
-
await nextTick();
|
|
675
|
-
|
|
676
|
-
// Select row
|
|
677
|
-
const checkbox = getByLabelText('Select row Alice');
|
|
678
|
-
await user.click(checkbox);
|
|
679
|
-
await nextTick();
|
|
680
|
-
|
|
681
|
-
let selectedRows = tableRef.value?.table.getSelectedRowModel().rows;
|
|
682
|
-
expect(selectedRows).toHaveLength(1);
|
|
683
|
-
expect(selectedRows?.[0].original.name).toBe('Alice');
|
|
684
|
-
|
|
685
|
-
// Deselect row
|
|
686
|
-
await user.click(checkbox);
|
|
687
|
-
await nextTick();
|
|
688
|
-
|
|
689
|
-
selectedRows = tableRef.value?.table.getSelectedRowModel().rows;
|
|
690
|
-
expect(selectedRows).toHaveLength(0);
|
|
691
|
-
});
|
|
692
|
-
|
|
693
|
-
test('selects multiple rows independently', async () => {
|
|
694
|
-
const user = userEvent.setup();
|
|
695
|
-
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
696
|
-
|
|
697
|
-
const { getByLabelText } = render({
|
|
698
|
-
components: { UiDataTable },
|
|
699
|
-
template:
|
|
700
|
-
'<UiDataTable ref="tableRef" :columns="columns" :data="data" />',
|
|
701
|
-
setup() {
|
|
702
|
-
return { tableRef, columns: selectableColumns, data: testData };
|
|
703
|
-
},
|
|
704
|
-
});
|
|
705
|
-
|
|
706
|
-
await nextTick();
|
|
707
|
-
|
|
708
|
-
// Select Alice and Charlie
|
|
709
|
-
await user.click(getByLabelText('Select row Alice'));
|
|
710
|
-
await user.click(getByLabelText('Select row Charlie'));
|
|
711
|
-
await nextTick();
|
|
712
|
-
|
|
713
|
-
const selectedRows = tableRef.value?.table.getSelectedRowModel().rows;
|
|
714
|
-
expect(selectedRows).toHaveLength(2);
|
|
715
|
-
expect(selectedRows?.map((r) => r.original.name)).toEqual([
|
|
716
|
-
'Alice',
|
|
717
|
-
'Charlie',
|
|
718
|
-
]);
|
|
719
|
-
});
|
|
720
|
-
|
|
721
|
-
test('toggles all rows when select all checkbox is clicked', async () => {
|
|
722
|
-
const user = userEvent.setup();
|
|
723
|
-
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
724
|
-
|
|
725
|
-
const { getByLabelText } = render({
|
|
726
|
-
components: { UiDataTable },
|
|
727
|
-
template:
|
|
728
|
-
'<UiDataTable ref="tableRef" :columns="columns" :data="data" />',
|
|
729
|
-
setup() {
|
|
730
|
-
return { tableRef, columns: selectableColumns, data: testData };
|
|
731
|
-
},
|
|
732
|
-
});
|
|
733
|
-
|
|
734
|
-
await nextTick();
|
|
735
|
-
|
|
736
|
-
const selectAll = getByLabelText('Select all');
|
|
737
|
-
|
|
738
|
-
// Select all
|
|
739
|
-
await user.click(selectAll);
|
|
740
|
-
await nextTick();
|
|
741
|
-
|
|
742
|
-
let selectedRows = tableRef.value?.table.getSelectedRowModel().rows;
|
|
743
|
-
expect(selectedRows).toHaveLength(3);
|
|
744
|
-
expect(tableRef.value?.table.getIsAllPageRowsSelected()).toBe(true);
|
|
745
|
-
|
|
746
|
-
// Deselect all
|
|
747
|
-
await user.click(selectAll);
|
|
748
|
-
await nextTick();
|
|
749
|
-
|
|
750
|
-
selectedRows = tableRef.value?.table.getSelectedRowModel().rows;
|
|
751
|
-
expect(selectedRows).toHaveLength(0);
|
|
752
|
-
expect(tableRef.value?.table.getIsAllPageRowsSelected()).toBe(false);
|
|
753
|
-
});
|
|
754
|
-
|
|
755
|
-
test('shows indeterminate state when some rows selected', async () => {
|
|
756
|
-
const user = userEvent.setup();
|
|
757
|
-
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
758
|
-
|
|
759
|
-
const { getByLabelText } = render({
|
|
760
|
-
components: { UiDataTable },
|
|
761
|
-
template:
|
|
762
|
-
'<UiDataTable ref="tableRef" :columns="columns" :data="data" />',
|
|
763
|
-
setup() {
|
|
764
|
-
return { tableRef, columns: selectableColumns, data: testData };
|
|
765
|
-
},
|
|
766
|
-
});
|
|
767
|
-
|
|
768
|
-
await nextTick();
|
|
769
|
-
|
|
770
|
-
// Select only one row
|
|
771
|
-
await user.click(getByLabelText('Select row Alice'));
|
|
772
|
-
await nextTick();
|
|
773
|
-
|
|
774
|
-
expect(tableRef.value?.table.getIsSomePageRowsSelected()).toBe(true);
|
|
775
|
-
expect(tableRef.value?.table.getIsAllPageRowsSelected()).toBe(false);
|
|
776
|
-
});
|
|
777
|
-
});
|
|
598
|
+
// Row selection interactions (individual toggle, multiple independent
|
|
599
|
+
// selection, select-all, and the indeterminate/mixed state) are covered by
|
|
600
|
+
// the `test - Row Selection` play function in UiDataTable.stories.ts.
|
|
778
601
|
|
|
779
602
|
describe('Reactivity', () => {
|
|
780
603
|
test('updates table when data prop changes', async () => {
|
|
@@ -27,6 +27,10 @@ export const DATA_TABLE_LABELS = {
|
|
|
27
27
|
rowsSelected: (selected: number, total: number) =>
|
|
28
28
|
`${selected} of ${total} row(s) selected.`,
|
|
29
29
|
|
|
30
|
+
/** UiDataTableFilterMenu */
|
|
31
|
+
filters: 'Filters',
|
|
32
|
+
toggleFilters: 'Toggle Filters',
|
|
33
|
+
|
|
30
34
|
/** UiDataTableColumnFilter */
|
|
31
35
|
columns: 'Columns',
|
|
32
36
|
toggleColumns: 'Toggle columns',
|
|
@@ -76,3 +80,11 @@ export interface ColumnFilterLabels {
|
|
|
76
80
|
/** Dropdown section label. */
|
|
77
81
|
columnVisibility?: string;
|
|
78
82
|
}
|
|
83
|
+
|
|
84
|
+
/** Labels for UiDataTableFilterMenu */
|
|
85
|
+
export interface FilterMenuLabels {
|
|
86
|
+
/** Visible label for the trigger button. */
|
|
87
|
+
filters?: string;
|
|
88
|
+
/** Accessible label for the trigger button. */
|
|
89
|
+
toggleFilters?: string;
|
|
90
|
+
}
|
|
@@ -3,6 +3,7 @@ export { default as UiDataTableColumnFilter } from './UiDataTableColumnFilter.vu
|
|
|
3
3
|
export { default as UiDataTableColumnHeader } from './UiDataTableColumnHeader.vue';
|
|
4
4
|
export { default as UiDataTablePagination } from './UiDataTablePagination.vue';
|
|
5
5
|
export { default as UiDataTableToolbar } from './UiDataTableToolbar.vue';
|
|
6
|
+
export { default as UiDataTableFilterMenu } from './UiDataTableFilterMenu.vue';
|
|
6
7
|
export type { Column, ColumnDef, Row, Table } from '@tanstack/vue-table';
|
|
7
8
|
export * from './types';
|
|
8
9
|
export * from './constants';
|
|
@@ -2,6 +2,7 @@ import type { Column, ColumnDef, Row, Table } from '@tanstack/vue-table';
|
|
|
2
2
|
import type {
|
|
3
3
|
ColumnHeaderLabels,
|
|
4
4
|
ColumnFilterLabels,
|
|
5
|
+
FilterMenuLabels,
|
|
5
6
|
PaginationLabels,
|
|
6
7
|
} from './constants';
|
|
7
8
|
|
|
@@ -127,3 +128,26 @@ export type UiDataTableColumnFilterProps<TData> = {
|
|
|
127
128
|
*/
|
|
128
129
|
labels?: ColumnFilterLabels;
|
|
129
130
|
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Props for the UiDataTableFilterMenu component.
|
|
134
|
+
*/
|
|
135
|
+
export type UiDataTableFilterMenuProps<TData> = {
|
|
136
|
+
/**
|
|
137
|
+
* The TanStack Table instance. Optional — the menu only hosts filter controls
|
|
138
|
+
* passed via the default slot and does not read from the table directly.
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
table?: Table<TData>;
|
|
142
|
+
/**
|
|
143
|
+
* Number of filters currently applied. When greater than `0`, a count badge is
|
|
144
|
+
* shown next to the label and the trigger stays visually filled (active).
|
|
145
|
+
* @default 0
|
|
146
|
+
*/
|
|
147
|
+
activeCount?: number;
|
|
148
|
+
/**
|
|
149
|
+
* Custom labels for i18n support.
|
|
150
|
+
* Partial object that merges with defaults.
|
|
151
|
+
*/
|
|
152
|
+
labels?: FilterMenuLabels;
|
|
153
|
+
};
|
|
@@ -603,7 +603,7 @@ const appointmentDate = ref<DateValue>()
|
|
|
603
603
|
class="w-full"
|
|
604
604
|
aria-label="Select appointment date"
|
|
605
605
|
/>
|
|
606
|
-
<p class="label-12-regular text-muted
|
|
606
|
+
<p class="label-12-regular text-content-on-surface-muted">
|
|
607
607
|
Choose a date for your appointment.
|
|
608
608
|
</p>
|
|
609
609
|
</div>
|
|
@@ -630,7 +630,7 @@ export const FormExample: Story = {
|
|
|
630
630
|
:disabled="args.disabled"
|
|
631
631
|
:locale="args.locale"
|
|
632
632
|
/>
|
|
633
|
-
<p class="label-12-regular text-muted
|
|
633
|
+
<p class="label-12-regular text-content-on-surface-muted">
|
|
634
634
|
Choose a date for your appointment.
|
|
635
635
|
</p>
|
|
636
636
|
</div>`,
|
|
@@ -874,7 +874,7 @@ const travelDates = ref<DateRange>()
|
|
|
874
874
|
placeholder="Select dates"
|
|
875
875
|
aria-label="Select travel dates"
|
|
876
876
|
/>
|
|
877
|
-
<p class="label-12-regular text-muted
|
|
877
|
+
<p class="label-12-regular text-content-on-surface-muted">
|
|
878
878
|
Choose your check-in and check-out dates.
|
|
879
879
|
</p>
|
|
880
880
|
</div>
|
|
@@ -910,7 +910,7 @@ export const RangeFormExample: Story = {
|
|
|
910
910
|
:disabled="args.disabled"
|
|
911
911
|
:locale="args.locale"
|
|
912
912
|
/>
|
|
913
|
-
<p class="label-12-regular text-muted
|
|
913
|
+
<p class="label-12-regular text-content-on-surface-muted">
|
|
914
914
|
Choose your check-in and check-out dates.
|
|
915
915
|
</p>
|
|
916
916
|
</div>`,
|
|
@@ -155,7 +155,7 @@ const handleRangeDateUpdate = (value: DateRange | undefined) => {
|
|
|
155
155
|
cn(
|
|
156
156
|
props.mode === 'range' ? 'w-[300px]' : 'w-[240px]',
|
|
157
157
|
'justify-start text-left font-normal bg-input-background hover:bg-input-background',
|
|
158
|
-
!effectiveValue && 'text-muted
|
|
158
|
+
!effectiveValue && 'text-content-on-surface-muted',
|
|
159
159
|
props.class,
|
|
160
160
|
)
|
|
161
161
|
"
|