@aleph-alpha/ui-library 2.0.0 → 2.3.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 +0 -19
- package/config.js +65 -81
- package/dist/system/components/UiSnackbar/UiSnackbar.vue.d.ts +5 -0
- package/dist/system/components/UiSnackbar/index.d.ts +3 -0
- package/dist/system/components/UiSnackbar/types.d.ts +96 -0
- package/dist/system/components/UiToggle/UiToggle.vue.d.ts +5 -0
- package/dist/system/components/UiToggle/types.d.ts +13 -0
- package/dist/system/components/core/sonner/Sonner.vue.d.ts +3 -0
- package/dist/system/components/core/sonner/index.d.ts +1 -0
- package/dist/system/components/index.d.ts +1 -1
- package/dist/system/index.d.ts +3 -4
- package/dist/system/lib/heightTransition.d.ts +5 -0
- package/dist/system/lib/useDrag.d.ts +52 -0
- package/dist/system/lib.js +22130 -20210
- package/dist/system/patterns/UiDataTable/UiDataTable.vue.d.ts +22 -3
- package/dist/system/patterns/UiDataTable/UiDataTableColumnFilter.vue.d.ts +14 -0
- package/dist/system/patterns/UiDataTable/constants.d.ts +13 -0
- package/dist/system/patterns/UiDataTable/index.d.ts +2 -0
- package/dist/system/patterns/UiDataTable/types.d.ts +32 -1
- package/dist/system/patterns/UiSidebar/UiSidebarGroupLabel.vue.d.ts +6 -6
- package/dist/system/patterns/UiSidebar/activeIndicator.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/index.d.ts +1 -3
- package/dist/system/patterns/UiSidebar/types.d.ts +1 -95
- package/docs/public-docs/foundations.md +48 -38
- package/hover-mix.d.ts +8 -11
- package/hover-mix.js +7 -15
- package/package.json +6 -4
- package/src/components/UiAccordion/UiAccordion.stories.ts +2 -2
- package/src/components/UiAlert/UiAlert.stories.ts +4 -4
- package/src/components/UiAvatar/UiAvatar.stories.ts +2 -2
- package/src/components/UiButton/UiButton.stories.ts +1 -1
- package/src/components/UiCalendar/UiCalendar.stories.ts +1 -24
- package/src/components/UiCalendar/UiCalendar.vue +16 -0
- package/src/components/UiCard/UiCard.stories.ts +4 -4
- package/src/components/UiChip/UiChip.vue +1 -1
- package/src/components/UiDrawer/UiDrawer.stories.ts +6 -6
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +4 -4
- package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +70 -3
- package/src/components/UiEmpty/UiEmpty.stories.ts +1 -0
- package/src/components/UiFileItem/UiFileItem.vue +1 -1
- package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +4 -1
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +2 -2
- package/src/components/UiIcon/UiIcon.stories.ts +90 -18
- package/src/components/UiInput/UiInput.stories.ts +2 -2
- package/src/components/UiKbd/UiKbd.stories.ts +10 -10
- package/src/components/UiLabel/UiLabel.stories.ts +2 -2
- package/src/components/UiListbox/UiListbox.stories.ts +14 -14
- package/src/components/UiListbox/UiListbox.vue +16 -0
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +24 -13
- package/src/components/UiPopover/UiPopover.stories.ts +6 -6
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +22 -22
- package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +11 -22
- package/src/components/UiRangeCalendar/UiRangeCalendar.vue +16 -0
- package/src/components/UiSelect/UiSelectItem.vue +1 -1
- package/src/components/UiSeparator/UiSeparator.stories.ts +8 -8
- package/src/components/UiSheet/UiSheet.stories.ts +12 -12
- package/src/components/UiSkeleton/UiSkeleton.stories.ts +20 -20
- package/src/components/UiSlider/UiSlider.stories.ts +6 -6
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +508 -0
- package/src/components/UiSnackbar/UiSnackbar.vue +286 -0
- package/src/components/UiSnackbar/__tests__/UiSnackbar.test.ts +17 -0
- package/src/components/UiSnackbar/index.ts +4 -0
- package/src/components/UiSnackbar/types.ts +97 -0
- package/src/components/UiSwitch/UiSwitch.stories.ts +4 -4
- package/src/components/UiSwitch/__tests__/UiSwitch.test.ts +9 -2
- package/src/components/UiTable/__tests__/UiTableRow.test.ts +23 -4
- package/src/components/UiTabs/UiTabs.stories.ts +2 -2
- package/src/components/UiTabs/__tests__/UiTabs.test.ts +25 -0
- package/src/components/UiTagsInput/UiTagsInput.stories.ts +2 -0
- package/src/components/UiToggle/UiToggle.vue +18 -1
- package/src/components/UiToggle/__tests__/UiToggle.test.ts +42 -3
- package/src/components/UiToggle/types.ts +13 -0
- package/src/components/UiToggleGroup/__tests__/UiToggleGroup.test.ts +18 -0
- package/src/components/UiTooltip/UiTooltip.stories.ts +7 -7
- package/src/components/core/accordion/AccordionContent.vue +36 -1
- package/src/components/core/alert/index.ts +3 -2
- package/src/components/core/button/index.ts +5 -6
- package/src/components/core/calendar/CalendarGrid.vue +1 -1
- package/src/components/core/card/Card.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuCheckboxItem.vue +14 -13
- package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuRadioItem.vue +23 -13
- package/src/components/core/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
- package/src/components/core/listbox/ListboxItem.vue +1 -1
- package/src/components/core/popover/PopoverContent.vue +1 -1
- package/src/components/core/range-calendar/RangeCalendarGrid.vue +1 -1
- package/src/components/core/select/SelectItem.vue +1 -1
- package/src/components/core/sidebar/SidebarGroupAction.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuAction.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuSubButton.vue +2 -2
- package/src/components/core/sidebar/SidebarTrigger.vue +4 -4
- package/src/components/core/sidebar/index.ts +4 -3
- package/src/components/core/sonner/Sonner.vue +43 -0
- package/src/components/core/sonner/index.ts +1 -0
- package/src/components/core/switch/Switch.vue +2 -2
- package/src/components/core/table/TableRow.vue +1 -1
- package/src/components/core/tabs/TabsList.vue +1 -1
- package/src/components/core/tabs/TabsTrigger.vue +1 -1
- package/src/components/core/toggle/index.ts +3 -3
- package/src/components/core/toggle-group/index.ts +1 -1
- package/src/components/index.ts +1 -1
- package/src/directives/vHover.stories.ts +1 -1
- package/src/index.ts +3 -0
- package/src/lib/heightTransition.ts +27 -0
- package/src/lib/useDrag.stories.ts +295 -0
- package/src/lib/useDrag.ts +212 -0
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +363 -15
- package/src/patterns/UiDataTable/UiDataTable.vue +558 -22
- package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +83 -0
- package/src/patterns/UiDataTable/UiDataTableColumnHeader.vue +4 -13
- package/src/patterns/UiDataTable/UiDataTablePagination.vue +3 -3
- package/src/patterns/UiDataTable/UiDataTableToolbar.vue +1 -1
- package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +343 -0
- package/src/patterns/UiDataTable/__tests__/UiDataTableColumnFilter.test.ts +194 -0
- package/src/patterns/UiDataTable/__tests__/UiDataTableColumnHeader.test.ts +11 -0
- package/src/patterns/UiDataTable/constants.ts +15 -0
- package/src/patterns/UiDataTable/index.ts +2 -0
- package/src/patterns/UiDataTable/types.ts +33 -0
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +4 -4
- package/src/patterns/UiDatePicker/UiDatePicker.vue +2 -0
- package/src/patterns/UiSidebar/UiSidebar.stories.ts +27 -258
- package/src/patterns/UiSidebar/UiSidebarGroup.stories.ts +6 -8
- package/src/patterns/UiSidebar/UiSidebarGroupContent.vue +13 -36
- package/src/patterns/UiSidebar/UiSidebarGroupLabel.stories.ts +15 -10
- package/src/patterns/UiSidebar/UiSidebarGroupLabel.vue +20 -7
- package/src/patterns/UiSidebar/UiSidebarHeader.vue +0 -1
- package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +29 -40
- package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +9 -6
- package/src/patterns/UiSidebar/UiSidebarMenuItem.stories.ts +11 -13
- package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +8 -5
- package/src/patterns/UiSidebar/UiSidebarPopoverMenu.stories.ts +6 -8
- package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.stories.ts +6 -7
- package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +9 -7
- package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.stories.ts +3 -3
- package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +11 -12
- package/src/patterns/UiSidebar/UiSidebarTrigger.vue +1 -1
- package/src/patterns/UiSidebar/activeIndicator.ts +1 -2
- package/src/patterns/UiSidebar/index.ts +0 -5
- package/src/patterns/UiSidebar/types.ts +1 -111
- package/src/theme/Background.stories.ts +5 -5
- package/src/theme/Border.stories.ts +3 -3
- package/src/theme/Extended.stories.ts +6 -6
- package/src/theme/Flex.stories.ts +10 -10
- package/src/theme/Grid.stories.ts +10 -10
- package/src/theme/HoverLayer.stories.ts +215 -0
- package/src/theme/Overlay.stories.ts +2 -2
- package/src/theme/Shadow.stories.ts +1 -1
- package/src/theme/Theme.stories.ts +4 -4
- package/src/theme/Typography.stories.ts +21 -21
- package/tokens.json +4835 -1369
- package/dist/system/components/UiIconButton/UiIconButton.vue.d.ts +0 -25
- package/dist/system/components/UiIconButton/index.d.ts +0 -7
- package/dist/system/components/UiIconButton/types.d.ts +0 -67
- package/dist/system/patterns/UiSidebar/UiSidebarChatHistory.vue.d.ts +0 -20
- package/dist/system/patterns/UiSidebar/UiSidebarChatHistoryItem.vue.d.ts +0 -34
- package/src/components/UiIconButton/UiIconButton.stories.ts +0 -470
- package/src/components/UiIconButton/UiIconButton.vue +0 -76
- package/src/components/UiIconButton/__tests__/UiIconButton.test.ts +0 -105
- package/src/components/UiIconButton/index.ts +0 -13
- package/src/components/UiIconButton/types.ts +0 -87
- package/src/patterns/UiSidebar/UiSidebarChatHistory.stories.ts +0 -104
- package/src/patterns/UiSidebar/UiSidebarChatHistory.vue +0 -43
- package/src/patterns/UiSidebar/UiSidebarChatHistoryItem.stories.ts +0 -204
- package/src/patterns/UiSidebar/UiSidebarChatHistoryItem.vue +0 -269
- package/src/patterns/UiSidebar/__tests__/UiSidebarChatHistory.test.ts +0 -35
- package/src/patterns/UiSidebar/__tests__/UiSidebarChatHistoryItem.test.ts +0 -49
- package/src/theme/BackgroundHover.stories.ts +0 -182
- package/src/theme/ContentHover.stories.ts +0 -171
|
@@ -3,6 +3,7 @@ import type { ColumnDef } from '@tanstack/vue-table';
|
|
|
3
3
|
import { computed, h, ref } from 'vue';
|
|
4
4
|
import {
|
|
5
5
|
UiDataTable,
|
|
6
|
+
UiDataTableColumnFilter,
|
|
6
7
|
UiDataTableColumnHeader,
|
|
7
8
|
UiDataTablePagination,
|
|
8
9
|
UiDataTableToolbar,
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
import { UiCheckbox } from '@/components/UiCheckbox';
|
|
11
12
|
import { UiButton } from '@/components/UiButton';
|
|
12
13
|
import { UiIcon } from '@/components/UiIcon';
|
|
14
|
+
import { UiInput } from '@/components/UiInput';
|
|
13
15
|
import {
|
|
14
16
|
UiDropdownMenu,
|
|
15
17
|
UiDropdownMenuContent,
|
|
@@ -326,7 +328,7 @@ const table = computed(() => tableRef.value?.table);
|
|
|
326
328
|
</script>
|
|
327
329
|
|
|
328
330
|
<template>
|
|
329
|
-
<div class="
|
|
331
|
+
<div class="gap-y-4">
|
|
330
332
|
<!-- tableMinHeight prevents layout shifts during pagination -->
|
|
331
333
|
<UiDataTable ref="tableRef" :data="data" :columns="columns" table-min-height="500px" />
|
|
332
334
|
<UiDataTablePagination v-if="table" :table="table" />
|
|
@@ -371,7 +373,7 @@ const table = computed(() => tableRef.value?.table);
|
|
|
371
373
|
</script>
|
|
372
374
|
|
|
373
375
|
<template>
|
|
374
|
-
<div class="
|
|
376
|
+
<div class="gap-y-4">
|
|
375
377
|
<!-- filter-column filters a specific column -->
|
|
376
378
|
<UiDataTableToolbar
|
|
377
379
|
v-if="table"
|
|
@@ -383,6 +385,63 @@ const table = computed(() => tableRef.value?.table);
|
|
|
383
385
|
</div>
|
|
384
386
|
</template>`;
|
|
385
387
|
|
|
388
|
+
const WithColumnsFilterTemplateSource = `<script setup lang="ts">
|
|
389
|
+
import { computed, h, ref } from 'vue';
|
|
390
|
+
import { UiDataTable, UiDataTableColumnFilter, UiDataTableColumnHeader, UiInput } from '@aleph-alpha/ui-library';
|
|
391
|
+
import type { ColumnDef } from '@tanstack/vue-table';
|
|
392
|
+
|
|
393
|
+
interface Payment {
|
|
394
|
+
id: string;
|
|
395
|
+
amount: number;
|
|
396
|
+
status: string;
|
|
397
|
+
email: string;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const data: Payment[] = [
|
|
401
|
+
{ id: '1', amount: 316, status: 'success', email: 'ken99@yahoo.com' },
|
|
402
|
+
{ id: '2', amount: 242, status: 'success', email: 'abe45@gmail.com' },
|
|
403
|
+
{ id: '3', amount: 837, status: 'processing', email: 'monserrat44@gmail.com' },
|
|
404
|
+
];
|
|
405
|
+
|
|
406
|
+
const columns: ColumnDef<Payment>[] = [
|
|
407
|
+
{
|
|
408
|
+
accessorKey: 'status',
|
|
409
|
+
header: ({ column }) => h(UiDataTableColumnHeader, { column, title: 'Status' }),
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
accessorKey: 'email',
|
|
413
|
+
header: ({ column }) => h(UiDataTableColumnHeader, { column, title: 'Email' }),
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
accessorKey: 'amount',
|
|
417
|
+
header: ({ column }) => h(UiDataTableColumnHeader, { column, title: 'Amount' }),
|
|
418
|
+
},
|
|
419
|
+
];
|
|
420
|
+
|
|
421
|
+
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
422
|
+
const table = computed(() => tableRef.value?.table);
|
|
423
|
+
const emailFilter = computed({
|
|
424
|
+
get: () => (table.value?.getColumn('email')?.getFilterValue() as string) ?? '',
|
|
425
|
+
set: (value) => table.value?.getColumn('email')?.setFilterValue(value),
|
|
426
|
+
});
|
|
427
|
+
</script>
|
|
428
|
+
|
|
429
|
+
<template>
|
|
430
|
+
<div class="space-y-4">
|
|
431
|
+
<div class="flex items-center justify-between gap-2">
|
|
432
|
+
<UiInput
|
|
433
|
+
v-model="emailFilter"
|
|
434
|
+
name="email-filter"
|
|
435
|
+
placeholder="Filter emails..."
|
|
436
|
+
aria-label="Filter emails"
|
|
437
|
+
class="h-8 max-w-sm"
|
|
438
|
+
/>
|
|
439
|
+
<UiDataTableColumnFilter v-if="table" :table="table" />
|
|
440
|
+
</div>
|
|
441
|
+
<UiDataTable ref="tableRef" :data="data" :columns="columns" />
|
|
442
|
+
</div>
|
|
443
|
+
</template>`;
|
|
444
|
+
|
|
386
445
|
const fullExampleTemplateSource = `<script setup lang="ts">
|
|
387
446
|
import { h, ref, computed } from 'vue';
|
|
388
447
|
import {
|
|
@@ -450,7 +509,7 @@ const table = computed(() => tableRef.value?.table);
|
|
|
450
509
|
</script>
|
|
451
510
|
|
|
452
511
|
<template>
|
|
453
|
-
<div class="
|
|
512
|
+
<div class="gap-y-4">
|
|
454
513
|
<UiDataTableToolbar
|
|
455
514
|
v-if="table"
|
|
456
515
|
:table="table"
|
|
@@ -503,7 +562,7 @@ const table = computed(() => tableRef.value?.table);
|
|
|
503
562
|
</script>
|
|
504
563
|
|
|
505
564
|
<template>
|
|
506
|
-
<div class="
|
|
565
|
+
<div class="gap-y-4">
|
|
507
566
|
<!-- global-filter searches across ALL columns -->
|
|
508
567
|
<UiDataTableToolbar
|
|
509
568
|
v-if="table"
|
|
@@ -576,13 +635,165 @@ const table = computed(() => tableRef.value?.table);
|
|
|
576
635
|
</script>
|
|
577
636
|
|
|
578
637
|
<template>
|
|
579
|
-
<div class="
|
|
638
|
+
<div class="gap-y-4">
|
|
580
639
|
<UiDataTable ref="tableRef" :data="data" :columns="columns" />
|
|
581
640
|
<!-- Pagination shows selection count -->
|
|
582
641
|
<UiDataTablePagination v-if="table" :table="table" />
|
|
583
642
|
</div>
|
|
584
643
|
</template>`;
|
|
585
644
|
|
|
645
|
+
const withDraggableColumnsTemplateSource = `<script setup lang="ts">
|
|
646
|
+
import { h, ref } from 'vue';
|
|
647
|
+
import { UiDataTable, UiDataTableColumnHeader } from '@aleph-alpha/ui-library';
|
|
648
|
+
import type { ColumnDef } from '@tanstack/vue-table';
|
|
649
|
+
|
|
650
|
+
interface Payment {
|
|
651
|
+
id: string;
|
|
652
|
+
amount: number;
|
|
653
|
+
status: string;
|
|
654
|
+
email: string;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
const data: Payment[] = [
|
|
658
|
+
{ id: '1', amount: 316, status: 'success', email: 'ken99@yahoo.com' },
|
|
659
|
+
{ id: '2', amount: 242, status: 'success', email: 'abe45@gmail.com' },
|
|
660
|
+
{ id: '3', amount: 837, status: 'processing', email: 'monserrat44@gmail.com' },
|
|
661
|
+
];
|
|
662
|
+
|
|
663
|
+
const columns: ColumnDef<Payment>[] = [
|
|
664
|
+
{
|
|
665
|
+
accessorKey: 'status',
|
|
666
|
+
header: ({ column }) => h(UiDataTableColumnHeader, { column, title: 'Status' }),
|
|
667
|
+
size: 120,
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
accessorKey: 'email',
|
|
671
|
+
header: ({ column }) => h(UiDataTableColumnHeader, { column, title: 'Email' }),
|
|
672
|
+
size: 250,
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
accessorKey: 'amount',
|
|
676
|
+
header: ({ column }) => h(UiDataTableColumnHeader, { column, title: 'Amount' }),
|
|
677
|
+
size: 120,
|
|
678
|
+
},
|
|
679
|
+
];
|
|
680
|
+
|
|
681
|
+
const columnOrder = ref<string[]>([]);
|
|
682
|
+
|
|
683
|
+
function handleColumnOrderChange(nextOrder: string[]) {
|
|
684
|
+
columnOrder.value = nextOrder;
|
|
685
|
+
}
|
|
686
|
+
</script>
|
|
687
|
+
|
|
688
|
+
<template>
|
|
689
|
+
<div class="space-y-3">
|
|
690
|
+
<UiDataTable
|
|
691
|
+
:data="data"
|
|
692
|
+
:columns="columns"
|
|
693
|
+
draggable-columns
|
|
694
|
+
:on-column-order-change="handleColumnOrderChange"
|
|
695
|
+
/>
|
|
696
|
+
<p class="text-muted-foreground text-sm">
|
|
697
|
+
Drag a column header to reorder columns.
|
|
698
|
+
<span v-if="columnOrder.length">
|
|
699
|
+
Current order: {{ columnOrder.join(', ') }}
|
|
700
|
+
</span>
|
|
701
|
+
</p>
|
|
702
|
+
</div>
|
|
703
|
+
</template>`;
|
|
704
|
+
|
|
705
|
+
const expandableColumns: ColumnDef<Payment>[] = [
|
|
706
|
+
...sortableColumns,
|
|
707
|
+
{
|
|
708
|
+
id: 'expand',
|
|
709
|
+
header: () => h('span', { class: 'sr-only' }, 'Expand row'),
|
|
710
|
+
cell: ({ row }) =>
|
|
711
|
+
h(
|
|
712
|
+
UiButton,
|
|
713
|
+
{
|
|
714
|
+
variant: 'ghost',
|
|
715
|
+
size: 'icon',
|
|
716
|
+
class: 'h-8 w-8',
|
|
717
|
+
'aria-expanded': row.getIsExpanded(),
|
|
718
|
+
'aria-label': row.getIsExpanded() ? 'Collapse row' : 'Expand row',
|
|
719
|
+
onClick: () => row.toggleExpanded(),
|
|
720
|
+
},
|
|
721
|
+
() =>
|
|
722
|
+
h(UiIcon, {
|
|
723
|
+
name: row.getIsExpanded() ? 'chevron-down' : 'chevron-right',
|
|
724
|
+
size: 16,
|
|
725
|
+
'aria-hidden': true,
|
|
726
|
+
}),
|
|
727
|
+
),
|
|
728
|
+
enableSorting: false,
|
|
729
|
+
enableHiding: false,
|
|
730
|
+
size: 48,
|
|
731
|
+
},
|
|
732
|
+
];
|
|
733
|
+
|
|
734
|
+
const withExpandableRowsTemplateSource = `<script setup lang="ts">
|
|
735
|
+
import { h } from 'vue';
|
|
736
|
+
import { UiButton, UiDataTable, UiDataTableColumnHeader, UiIcon } from '@aleph-alpha/ui-library';
|
|
737
|
+
import type { ColumnDef } from '@tanstack/vue-table';
|
|
738
|
+
|
|
739
|
+
interface Payment {
|
|
740
|
+
id: string;
|
|
741
|
+
amount: number;
|
|
742
|
+
status: string;
|
|
743
|
+
email: string;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
const data: Payment[] = [
|
|
747
|
+
{ id: '1', amount: 316, status: 'success', email: 'ken99@yahoo.com' },
|
|
748
|
+
{ id: '2', amount: 242, status: 'success', email: 'abe45@gmail.com' },
|
|
749
|
+
{ id: '3', amount: 837, status: 'processing', email: 'monserrat44@gmail.com' },
|
|
750
|
+
];
|
|
751
|
+
|
|
752
|
+
const columns: ColumnDef<Payment>[] = [
|
|
753
|
+
{
|
|
754
|
+
accessorKey: 'status',
|
|
755
|
+
header: ({ column }) => h(UiDataTableColumnHeader, { column, title: 'Status' }),
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
accessorKey: 'email',
|
|
759
|
+
header: ({ column }) => h(UiDataTableColumnHeader, { column, title: 'Email' }),
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
accessorKey: 'amount',
|
|
763
|
+
header: ({ column }) => h(UiDataTableColumnHeader, { column, title: 'Amount' }),
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
id: 'expand',
|
|
767
|
+
header: () => h('span', { class: 'sr-only' }, 'Expand row'),
|
|
768
|
+
cell: ({ row }) => h(UiButton, {
|
|
769
|
+
variant: 'ghost',
|
|
770
|
+
size: 'icon',
|
|
771
|
+
class: 'h-8 w-8',
|
|
772
|
+
'aria-expanded': row.getIsExpanded(),
|
|
773
|
+
'aria-label': row.getIsExpanded() ? 'Collapse row' : 'Expand row',
|
|
774
|
+
onClick: () => row.toggleExpanded(),
|
|
775
|
+
}, () => h(UiIcon, {
|
|
776
|
+
name: row.getIsExpanded() ? 'chevron-down' : 'chevron-right',
|
|
777
|
+
size: 16,
|
|
778
|
+
'aria-hidden': true,
|
|
779
|
+
})),
|
|
780
|
+
enableSorting: false,
|
|
781
|
+
enableHiding: false,
|
|
782
|
+
size: 48,
|
|
783
|
+
},
|
|
784
|
+
];
|
|
785
|
+
</script>
|
|
786
|
+
|
|
787
|
+
<template>
|
|
788
|
+
<UiDataTable :data="data" :columns="columns" :get-row-can-expand="() => true">
|
|
789
|
+
<template #expanded-row="{ row }">
|
|
790
|
+
<div class="rounded-md bg-background-surface-muted p-4 text-sm">
|
|
791
|
+
Payment {{ row.original.id }} belongs to {{ row.original.email }}.
|
|
792
|
+
</div>
|
|
793
|
+
</template>
|
|
794
|
+
</UiDataTable>
|
|
795
|
+
</template>`;
|
|
796
|
+
|
|
586
797
|
const customEmptyStateTemplateSource = `<script setup lang="ts">
|
|
587
798
|
import { UiDataTable } from '@aleph-alpha/ui-library';
|
|
588
799
|
import type { ColumnDef } from '@tanstack/vue-table';
|
|
@@ -653,7 +864,7 @@ const table = computed(() => tableRef.value?.table);
|
|
|
653
864
|
</script>
|
|
654
865
|
|
|
655
866
|
<template>
|
|
656
|
-
<div class="
|
|
867
|
+
<div class="gap-y-4">
|
|
657
868
|
<UiDataTable ref="tableRef" :data="data" :columns="columns" />
|
|
658
869
|
<!-- Customize page sizes and hide selection count -->
|
|
659
870
|
<UiDataTablePagination
|
|
@@ -755,7 +966,7 @@ export const WithPagination: Story = {
|
|
|
755
966
|
return { args, tableRef, table };
|
|
756
967
|
},
|
|
757
968
|
template: `
|
|
758
|
-
<div class="
|
|
969
|
+
<div class="gap-y-4">
|
|
759
970
|
<UiDataTable ref="tableRef" v-bind="args" />
|
|
760
971
|
<UiDataTablePagination v-if="table" :table="table" />
|
|
761
972
|
</div>
|
|
@@ -788,7 +999,7 @@ export const WithToolbar: Story = {
|
|
|
788
999
|
return { args, tableRef, table };
|
|
789
1000
|
},
|
|
790
1001
|
template: `
|
|
791
|
-
<div class="
|
|
1002
|
+
<div class="gap-y-4">
|
|
792
1003
|
<UiDataTableToolbar
|
|
793
1004
|
v-if="table"
|
|
794
1005
|
:table="table"
|
|
@@ -801,6 +1012,55 @@ export const WithToolbar: Story = {
|
|
|
801
1012
|
}),
|
|
802
1013
|
};
|
|
803
1014
|
|
|
1015
|
+
/**
|
|
1016
|
+
* Table header controls with a focused email filter and a column visibility menu.
|
|
1017
|
+
*
|
|
1018
|
+
* Use `UiDataTableColumnFilter` with a table instance to show/hide hideable
|
|
1019
|
+
* columns from a checklist dropdown.
|
|
1020
|
+
*/
|
|
1021
|
+
export const WithColumnsFilter: Story = {
|
|
1022
|
+
args: {
|
|
1023
|
+
data: payments,
|
|
1024
|
+
columns: sortableColumns,
|
|
1025
|
+
},
|
|
1026
|
+
parameters: {
|
|
1027
|
+
docs: {
|
|
1028
|
+
source: {
|
|
1029
|
+
code: WithColumnsFilterTemplateSource,
|
|
1030
|
+
},
|
|
1031
|
+
},
|
|
1032
|
+
},
|
|
1033
|
+
render: (args) => ({
|
|
1034
|
+
components: { UiDataTable, UiDataTableColumnFilter, UiInput },
|
|
1035
|
+
setup() {
|
|
1036
|
+
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
1037
|
+
const table = computed(() => tableRef.value?.table);
|
|
1038
|
+
const emailFilter = computed({
|
|
1039
|
+
get: () =>
|
|
1040
|
+
(table.value?.getColumn('email')?.getFilterValue() as string) ?? '',
|
|
1041
|
+
set: (value) => table.value?.getColumn('email')?.setFilterValue(value),
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
return { args, emailFilter, table, tableRef };
|
|
1045
|
+
},
|
|
1046
|
+
template: `
|
|
1047
|
+
<div class="space-y-4">
|
|
1048
|
+
<div class="flex items-center justify-between gap-2">
|
|
1049
|
+
<UiInput
|
|
1050
|
+
v-model="emailFilter"
|
|
1051
|
+
name="email-filter"
|
|
1052
|
+
placeholder="Filter emails..."
|
|
1053
|
+
aria-label="Filter emails"
|
|
1054
|
+
class="h-8 max-w-sm"
|
|
1055
|
+
/>
|
|
1056
|
+
<UiDataTableColumnFilter v-if="table" :table="table" />
|
|
1057
|
+
</div>
|
|
1058
|
+
<UiDataTable ref="tableRef" v-bind="args" />
|
|
1059
|
+
</div>
|
|
1060
|
+
`,
|
|
1061
|
+
}),
|
|
1062
|
+
};
|
|
1063
|
+
|
|
804
1064
|
/**
|
|
805
1065
|
* Table with global search across all columns.
|
|
806
1066
|
*
|
|
@@ -829,7 +1089,7 @@ export const WithGlobalFilter: Story = {
|
|
|
829
1089
|
return { args, tableRef, table };
|
|
830
1090
|
},
|
|
831
1091
|
template: `
|
|
832
|
-
<div class="
|
|
1092
|
+
<div class="gap-y-4">
|
|
833
1093
|
<UiDataTableToolbar
|
|
834
1094
|
v-if="table"
|
|
835
1095
|
:table="table"
|
|
@@ -871,7 +1131,7 @@ export const WithRowSelection: Story = {
|
|
|
871
1131
|
return { args, tableRef, table };
|
|
872
1132
|
},
|
|
873
1133
|
template: `
|
|
874
|
-
<div class="
|
|
1134
|
+
<div class="gap-y-4">
|
|
875
1135
|
<UiDataTable ref="tableRef" v-bind="args" />
|
|
876
1136
|
<UiDataTablePagination v-if="table" :table="table" />
|
|
877
1137
|
</div>
|
|
@@ -879,6 +1139,94 @@ export const WithRowSelection: Story = {
|
|
|
879
1139
|
}),
|
|
880
1140
|
};
|
|
881
1141
|
|
|
1142
|
+
/**
|
|
1143
|
+
* Table with draggable columns.
|
|
1144
|
+
*
|
|
1145
|
+
* Enable `draggable-columns` to let users reorder columns by dragging header cells.
|
|
1146
|
+
* The drag-and-drop helpers are exported from the UiDataTable module for reuse in
|
|
1147
|
+
* custom table interactions.
|
|
1148
|
+
*/
|
|
1149
|
+
export const WithDraggableColumns: Story = {
|
|
1150
|
+
args: {
|
|
1151
|
+
data: payments,
|
|
1152
|
+
columns: sortableColumns,
|
|
1153
|
+
draggableColumns: true,
|
|
1154
|
+
},
|
|
1155
|
+
parameters: {
|
|
1156
|
+
docs: {
|
|
1157
|
+
source: {
|
|
1158
|
+
code: withDraggableColumnsTemplateSource,
|
|
1159
|
+
},
|
|
1160
|
+
},
|
|
1161
|
+
},
|
|
1162
|
+
render: (args) => ({
|
|
1163
|
+
components: { UiDataTable },
|
|
1164
|
+
setup() {
|
|
1165
|
+
const columnOrder = ref<string[]>([]);
|
|
1166
|
+
return {
|
|
1167
|
+
args,
|
|
1168
|
+
columnOrder,
|
|
1169
|
+
handleColumnOrderChange: (nextOrder: string[]) => {
|
|
1170
|
+
columnOrder.value = nextOrder;
|
|
1171
|
+
},
|
|
1172
|
+
};
|
|
1173
|
+
},
|
|
1174
|
+
template: `
|
|
1175
|
+
<div class="space-y-3">
|
|
1176
|
+
<UiDataTable
|
|
1177
|
+
v-bind="args"
|
|
1178
|
+
:on-column-order-change="handleColumnOrderChange"
|
|
1179
|
+
/>
|
|
1180
|
+
<p class="text-muted-foreground text-sm">
|
|
1181
|
+
Drag a column header to reorder columns.
|
|
1182
|
+
<span v-if="columnOrder.length">
|
|
1183
|
+
Current order: {{ columnOrder.join(', ') }}
|
|
1184
|
+
</span>
|
|
1185
|
+
</p>
|
|
1186
|
+
</div>
|
|
1187
|
+
`,
|
|
1188
|
+
}),
|
|
1189
|
+
};
|
|
1190
|
+
|
|
1191
|
+
/**
|
|
1192
|
+
* Table with expandable rows.
|
|
1193
|
+
*
|
|
1194
|
+
* The expanded content is rendered in its own table row via the `expanded-row`
|
|
1195
|
+
* slot, keeping the table structure valid for screen readers and browsers.
|
|
1196
|
+
*/
|
|
1197
|
+
export const WithExpandableRows: Story = {
|
|
1198
|
+
args: {
|
|
1199
|
+
data: payments,
|
|
1200
|
+
columns: expandableColumns,
|
|
1201
|
+
getRowCanExpand: () => true,
|
|
1202
|
+
},
|
|
1203
|
+
parameters: {
|
|
1204
|
+
docs: {
|
|
1205
|
+
source: {
|
|
1206
|
+
code: withExpandableRowsTemplateSource,
|
|
1207
|
+
},
|
|
1208
|
+
},
|
|
1209
|
+
},
|
|
1210
|
+
render: (args) => ({
|
|
1211
|
+
components: { UiDataTable },
|
|
1212
|
+
setup() {
|
|
1213
|
+
return { args };
|
|
1214
|
+
},
|
|
1215
|
+
template: `
|
|
1216
|
+
<UiDataTable v-bind="args">
|
|
1217
|
+
<template #expanded-row="{ row }">
|
|
1218
|
+
<div class="rounded-md bg-background-surface-muted p-4 text-sm">
|
|
1219
|
+
<p class="font-medium">Payment {{ row.original.id }}</p>
|
|
1220
|
+
<p class="text-muted-foreground">
|
|
1221
|
+
Customer: {{ row.original.email }} - Status: {{ row.original.status }}
|
|
1222
|
+
</p>
|
|
1223
|
+
</div>
|
|
1224
|
+
</template>
|
|
1225
|
+
</UiDataTable>
|
|
1226
|
+
`,
|
|
1227
|
+
}),
|
|
1228
|
+
};
|
|
1229
|
+
|
|
882
1230
|
/**
|
|
883
1231
|
* Complete example combining all DataTable features.
|
|
884
1232
|
*
|
|
@@ -910,7 +1258,7 @@ export const FullExample: Story = {
|
|
|
910
1258
|
return { args, tableRef, table };
|
|
911
1259
|
},
|
|
912
1260
|
template: `
|
|
913
|
-
<div class="
|
|
1261
|
+
<div class="gap-y-4">
|
|
914
1262
|
<UiDataTableToolbar
|
|
915
1263
|
v-if="table"
|
|
916
1264
|
:table="table"
|
|
@@ -1139,7 +1487,7 @@ export const WithColumnHeader: Story = {
|
|
|
1139
1487
|
return { args, tableRef, table };
|
|
1140
1488
|
},
|
|
1141
1489
|
template: `
|
|
1142
|
-
<div class="
|
|
1490
|
+
<div class="gap-y-4">
|
|
1143
1491
|
<UiDataTableToolbar
|
|
1144
1492
|
v-if="table"
|
|
1145
1493
|
:table="table"
|
|
@@ -1180,7 +1528,7 @@ export const WithPageSizeSelector: Story = {
|
|
|
1180
1528
|
return { args, tableRef, table };
|
|
1181
1529
|
},
|
|
1182
1530
|
template: `
|
|
1183
|
-
<div class="
|
|
1531
|
+
<div class="gap-y-4">
|
|
1184
1532
|
<UiDataTable ref="tableRef" v-bind="args" />
|
|
1185
1533
|
<UiDataTablePagination
|
|
1186
1534
|
v-if="table"
|
|
@@ -1250,7 +1598,7 @@ const table = computed(() => tableRef.value?.table);
|
|
|
1250
1598
|
</script>
|
|
1251
1599
|
|
|
1252
1600
|
<template>
|
|
1253
|
-
<div class="
|
|
1601
|
+
<div class="gap-y-4">
|
|
1254
1602
|
<UiDataTable ref="tableRef" :data="data" :columns="columns" table-min-height="500px" />
|
|
1255
1603
|
<UiDataTablePagination v-if="table" :table="table" :show-selection="false" />
|
|
1256
1604
|
</div>
|
|
@@ -1266,7 +1614,7 @@ const table = computed(() => tableRef.value?.table);
|
|
|
1266
1614
|
return { args, tableRef, table };
|
|
1267
1615
|
},
|
|
1268
1616
|
template: `
|
|
1269
|
-
<div class="
|
|
1617
|
+
<div class="gap-y-4">
|
|
1270
1618
|
<UiDataTable ref="tableRef" v-bind="args" />
|
|
1271
1619
|
<UiDataTablePagination v-if="table" :table="table" :show-selection="false" />
|
|
1272
1620
|
</div>
|