@aleph-alpha/ui-library 2.5.2 → 2.6.1
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/dist/system/components/UiFileItem/index.d.ts +1 -1
- package/dist/system/components/UiFileType/UiFileType.vue.d.ts +1 -0
- package/dist/system/components/UiFileType/types.d.ts +5 -0
- package/dist/system/lib.js +2430 -2441
- package/dist/system/patterns/UiDataTable/UiDataTableToolbar.vue.d.ts +23 -12
- package/dist/system/patterns/UiDataTable/constants.d.ts +0 -13
- package/dist/system/patterns/UiDataTable/index.d.ts +1 -0
- package/dist/system/patterns/UiDataTable/types.d.ts +1 -28
- package/package.json +5 -5
- package/src/components/UiCodeBlock/UiCodeBlock.vue +17 -3
- package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +21 -0
- package/src/components/UiFileItem/UiFileItem.stories.ts +16 -13
- package/src/components/UiFileItem/UiFileItem.vue +1 -0
- package/src/components/UiFileItem/index.ts +5 -1
- package/src/components/UiFileType/UiFileType.vue +2 -5
- package/src/components/UiFileType/__tests__/UiFileType.test.ts +9 -0
- package/src/components/UiFileType/types.ts +5 -0
- package/src/components/UiItem/UiItem.stories.ts +7 -10
- package/src/components/UiSelect/UiSelect.stories.ts +20 -20
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +186 -118
- package/src/patterns/UiDataTable/UiDataTablePagination.vue +1 -1
- package/src/patterns/UiDataTable/UiDataTableToolbar.vue +17 -58
- package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +1 -1
- package/src/patterns/UiDataTable/__tests__/UiDataTableColumnFilter.test.ts +1 -1
- package/src/patterns/UiDataTable/__tests__/UiDataTableToolbar.test.ts +26 -201
- package/src/patterns/UiDataTable/constants.ts +0 -15
- package/src/patterns/UiDataTable/index.ts +1 -0
- package/src/patterns/UiDataTable/types.ts +0 -29
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
-
import type { ColumnDef } from '@
|
|
2
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
3
3
|
import { computed, h, ref } from 'vue';
|
|
4
4
|
import {
|
|
5
5
|
UiDataTable,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
UiDataTablePagination,
|
|
9
9
|
UiDataTableToolbar,
|
|
10
10
|
} from './index';
|
|
11
|
+
import { UiBadge } from '@/components/UiBadge';
|
|
11
12
|
import { UiCheckbox } from '@/components/UiCheckbox';
|
|
12
13
|
import { UiButton } from '@/components/UiButton';
|
|
13
14
|
import { UiIcon } from '@/components/UiIcon';
|
|
@@ -210,7 +211,7 @@ type Story = StoryObj<typeof meta>;
|
|
|
210
211
|
// Templates for source code display
|
|
211
212
|
const basicTemplateSource = `<script setup lang="ts">
|
|
212
213
|
import { UiDataTable } from '@aleph-alpha/ui-library';
|
|
213
|
-
import type { ColumnDef } from '@
|
|
214
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
214
215
|
|
|
215
216
|
interface Payment {
|
|
216
217
|
id: string;
|
|
@@ -239,7 +240,7 @@ const columns: ColumnDef<Payment>[] = [
|
|
|
239
240
|
const withSortingTemplateSource = `<script setup lang="ts">
|
|
240
241
|
import { h } from 'vue';
|
|
241
242
|
import { UiDataTable, UiDataTableColumnHeader } from '@aleph-alpha/ui-library';
|
|
242
|
-
import type { ColumnDef } from '@
|
|
243
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
243
244
|
|
|
244
245
|
interface Payment {
|
|
245
246
|
id: string;
|
|
@@ -292,7 +293,7 @@ const columns: ColumnDef<Payment>[] = [
|
|
|
292
293
|
const withPaginationTemplateSource = `<script setup lang="ts">
|
|
293
294
|
import { h, ref, computed } from 'vue';
|
|
294
295
|
import { UiDataTable, UiDataTableColumnHeader, UiDataTablePagination } from '@aleph-alpha/ui-library';
|
|
295
|
-
import type { ColumnDef } from '@
|
|
296
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
296
297
|
|
|
297
298
|
interface Payment {
|
|
298
299
|
id: string;
|
|
@@ -337,8 +338,8 @@ const table = computed(() => tableRef.value?.table);
|
|
|
337
338
|
|
|
338
339
|
const withToolbarTemplateSource = `<script setup lang="ts">
|
|
339
340
|
import { h, ref, computed } from 'vue';
|
|
340
|
-
import { UiDataTable, UiDataTableColumnHeader, UiDataTableToolbar } from '@aleph-alpha/ui-library';
|
|
341
|
-
import type { ColumnDef } from '@
|
|
341
|
+
import { UiDataTable, UiDataTableColumnHeader, UiDataTableToolbar, UiInput } from '@aleph-alpha/ui-library';
|
|
342
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
342
343
|
|
|
343
344
|
interface Payment {
|
|
344
345
|
id: string;
|
|
@@ -370,25 +371,34 @@ const columns: ColumnDef<Payment>[] = [
|
|
|
370
371
|
|
|
371
372
|
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
372
373
|
const table = computed(() => tableRef.value?.table);
|
|
374
|
+
const emailFilter = computed({
|
|
375
|
+
get: () => (table.value?.getColumn('email')?.getFilterValue() as string) ?? '',
|
|
376
|
+
set: (value) => table.value?.getColumn('email')?.setFilterValue(value),
|
|
377
|
+
});
|
|
373
378
|
</script>
|
|
374
379
|
|
|
375
380
|
<template>
|
|
376
381
|
<div class="gap-y-4">
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
382
|
+
<UiDataTableToolbar>
|
|
383
|
+
<UiInput
|
|
384
|
+
v-model="emailFilter"
|
|
385
|
+
name="email-filter"
|
|
386
|
+
placeholder="Filter emails..."
|
|
387
|
+
aria-label="Filter emails"
|
|
388
|
+
class="h-8 w-full sm:w-[250px]"
|
|
389
|
+
/>
|
|
390
|
+
<template #actions>
|
|
391
|
+
<UiDataTableColumnFilter v-if="table" :table="table" />
|
|
392
|
+
</template>
|
|
393
|
+
</UiDataTableToolbar>
|
|
384
394
|
<UiDataTable ref="tableRef" :data="data" :columns="columns" />
|
|
385
395
|
</div>
|
|
386
396
|
</template>`;
|
|
387
397
|
|
|
388
398
|
const WithColumnsFilterTemplateSource = `<script setup lang="ts">
|
|
389
399
|
import { computed, h, ref } from 'vue';
|
|
390
|
-
import { UiDataTable, UiDataTableColumnFilter, UiDataTableColumnHeader, UiInput } from '@aleph-alpha/ui-library';
|
|
391
|
-
import type { ColumnDef } from '@
|
|
400
|
+
import { UiDataTable, UiDataTableColumnFilter, UiDataTableColumnHeader, UiDataTableToolbar, UiInput } from '@aleph-alpha/ui-library';
|
|
401
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
392
402
|
|
|
393
403
|
interface Payment {
|
|
394
404
|
id: string;
|
|
@@ -428,7 +438,7 @@ const emailFilter = computed({
|
|
|
428
438
|
|
|
429
439
|
<template>
|
|
430
440
|
<div class="space-y-4">
|
|
431
|
-
<
|
|
441
|
+
<UiDataTableToolbar>
|
|
432
442
|
<UiInput
|
|
433
443
|
v-model="emailFilter"
|
|
434
444
|
name="email-filter"
|
|
@@ -437,7 +447,7 @@ const emailFilter = computed({
|
|
|
437
447
|
class="h-8 max-w-sm"
|
|
438
448
|
/>
|
|
439
449
|
<UiDataTableColumnFilter v-if="table" :table="table" />
|
|
440
|
-
</
|
|
450
|
+
</UiDataTableToolbar>
|
|
441
451
|
<UiDataTable ref="tableRef" :data="data" :columns="columns" />
|
|
442
452
|
</div>
|
|
443
453
|
</template>`;
|
|
@@ -448,10 +458,11 @@ import {
|
|
|
448
458
|
UiDataTable,
|
|
449
459
|
UiDataTableColumnHeader,
|
|
450
460
|
UiDataTableToolbar,
|
|
451
|
-
UiDataTablePagination
|
|
461
|
+
UiDataTablePagination,
|
|
462
|
+
UiInput
|
|
452
463
|
} from '@aleph-alpha/ui-library';
|
|
453
464
|
import { UiCheckbox } from '@aleph-alpha/ui-library';
|
|
454
|
-
import type { ColumnDef } from '@
|
|
465
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
455
466
|
|
|
456
467
|
interface Payment {
|
|
457
468
|
id: string;
|
|
@@ -506,16 +517,23 @@ const columns: ColumnDef<Payment>[] = [
|
|
|
506
517
|
|
|
507
518
|
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
508
519
|
const table = computed(() => tableRef.value?.table);
|
|
520
|
+
const globalSearch = computed({
|
|
521
|
+
get: () => (table.value?.getState().globalFilter as string) ?? '',
|
|
522
|
+
set: (value) => table.value?.setGlobalFilter(value),
|
|
523
|
+
});
|
|
509
524
|
</script>
|
|
510
525
|
|
|
511
526
|
<template>
|
|
512
527
|
<div class="gap-y-4">
|
|
513
|
-
<UiDataTableToolbar
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
528
|
+
<UiDataTableToolbar>
|
|
529
|
+
<UiInput
|
|
530
|
+
v-model="globalSearch"
|
|
531
|
+
name="global-search"
|
|
532
|
+
placeholder="Search..."
|
|
533
|
+
aria-label="Search all columns"
|
|
534
|
+
class="h-8 w-full sm:w-[250px]"
|
|
535
|
+
/>
|
|
536
|
+
</UiDataTableToolbar>
|
|
519
537
|
<UiDataTable ref="tableRef" :data="data" :columns="columns" />
|
|
520
538
|
<UiDataTablePagination v-if="table" :table="table" />
|
|
521
539
|
</div>
|
|
@@ -523,8 +541,8 @@ const table = computed(() => tableRef.value?.table);
|
|
|
523
541
|
|
|
524
542
|
const withGlobalFilterTemplateSource = `<script setup lang="ts">
|
|
525
543
|
import { h, ref, computed } from 'vue';
|
|
526
|
-
import { UiDataTable, UiDataTableColumnHeader, UiDataTableToolbar } from '@aleph-alpha/ui-library';
|
|
527
|
-
import type { ColumnDef } from '@
|
|
544
|
+
import { UiDataTable, UiDataTableColumnHeader, UiDataTableToolbar, UiInput } from '@aleph-alpha/ui-library';
|
|
545
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
528
546
|
|
|
529
547
|
interface Payment {
|
|
530
548
|
id: string;
|
|
@@ -559,17 +577,23 @@ const columns: ColumnDef<Payment>[] = [
|
|
|
559
577
|
|
|
560
578
|
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
561
579
|
const table = computed(() => tableRef.value?.table);
|
|
580
|
+
const globalSearch = computed({
|
|
581
|
+
get: () => (table.value?.getState().globalFilter as string) ?? '',
|
|
582
|
+
set: (value) => table.value?.setGlobalFilter(value),
|
|
583
|
+
});
|
|
562
584
|
</script>
|
|
563
585
|
|
|
564
586
|
<template>
|
|
565
587
|
<div class="gap-y-4">
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
588
|
+
<UiDataTableToolbar>
|
|
589
|
+
<UiInput
|
|
590
|
+
v-model="globalSearch"
|
|
591
|
+
name="global-search"
|
|
592
|
+
placeholder="Search all columns..."
|
|
593
|
+
aria-label="Search all columns"
|
|
594
|
+
class="h-8 w-full sm:w-[250px]"
|
|
595
|
+
/>
|
|
596
|
+
</UiDataTableToolbar>
|
|
573
597
|
<UiDataTable ref="tableRef" :data="data" :columns="columns" />
|
|
574
598
|
</div>
|
|
575
599
|
</template>`;
|
|
@@ -578,7 +602,7 @@ const withRowSelectionTemplateSource = `<script setup lang="ts">
|
|
|
578
602
|
import { h, ref, computed } from 'vue';
|
|
579
603
|
import { UiDataTable, UiDataTableColumnHeader, UiDataTablePagination } from '@aleph-alpha/ui-library';
|
|
580
604
|
import { UiCheckbox } from '@aleph-alpha/ui-library';
|
|
581
|
-
import type { ColumnDef } from '@
|
|
605
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
582
606
|
|
|
583
607
|
interface Payment {
|
|
584
608
|
id: string;
|
|
@@ -645,7 +669,7 @@ const table = computed(() => tableRef.value?.table);
|
|
|
645
669
|
const withDraggableColumnsTemplateSource = `<script setup lang="ts">
|
|
646
670
|
import { h, ref } from 'vue';
|
|
647
671
|
import { UiDataTable, UiDataTableColumnHeader } from '@aleph-alpha/ui-library';
|
|
648
|
-
import type { ColumnDef } from '@
|
|
672
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
649
673
|
|
|
650
674
|
interface Payment {
|
|
651
675
|
id: string;
|
|
@@ -693,7 +717,7 @@ function handleColumnOrderChange(nextOrder: string[]) {
|
|
|
693
717
|
draggable-columns
|
|
694
718
|
:on-column-order-change="handleColumnOrderChange"
|
|
695
719
|
/>
|
|
696
|
-
<p class="text-muted-foreground
|
|
720
|
+
<p class="body-14-regular text-muted-foreground">
|
|
697
721
|
Drag a column header to reorder columns.
|
|
698
722
|
<span v-if="columnOrder.length">
|
|
699
723
|
Current order: {{ columnOrder.join(', ') }}
|
|
@@ -734,7 +758,7 @@ const expandableColumns: ColumnDef<Payment>[] = [
|
|
|
734
758
|
const withExpandableRowsTemplateSource = `<script setup lang="ts">
|
|
735
759
|
import { h } from 'vue';
|
|
736
760
|
import { UiButton, UiDataTable, UiDataTableColumnHeader, UiIcon } from '@aleph-alpha/ui-library';
|
|
737
|
-
import type { ColumnDef } from '@
|
|
761
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
738
762
|
|
|
739
763
|
interface Payment {
|
|
740
764
|
id: string;
|
|
@@ -787,7 +811,7 @@ const columns: ColumnDef<Payment>[] = [
|
|
|
787
811
|
<template>
|
|
788
812
|
<UiDataTable :data="data" :columns="columns" :get-row-can-expand="() => true">
|
|
789
813
|
<template #expanded-row="{ row }">
|
|
790
|
-
<div class="rounded-md bg-background-surface-muted p-4
|
|
814
|
+
<div class="body-14-regular rounded-md bg-background-surface-muted p-4">
|
|
791
815
|
Payment {{ row.original.id }} belongs to {{ row.original.email }}.
|
|
792
816
|
</div>
|
|
793
817
|
</template>
|
|
@@ -796,7 +820,7 @@ const columns: ColumnDef<Payment>[] = [
|
|
|
796
820
|
|
|
797
821
|
const customEmptyStateTemplateSource = `<script setup lang="ts">
|
|
798
822
|
import { UiDataTable } from '@aleph-alpha/ui-library';
|
|
799
|
-
import type { ColumnDef } from '@
|
|
823
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
800
824
|
|
|
801
825
|
interface Payment {
|
|
802
826
|
id: string;
|
|
@@ -826,7 +850,7 @@ const columns: ColumnDef<Payment>[] = [
|
|
|
826
850
|
const withPageSizeTemplateSource = `<script setup lang="ts">
|
|
827
851
|
import { h, ref, computed } from 'vue';
|
|
828
852
|
import { UiDataTable, UiDataTableColumnHeader, UiDataTablePagination } from '@aleph-alpha/ui-library';
|
|
829
|
-
import type { ColumnDef } from '@
|
|
853
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
830
854
|
|
|
831
855
|
interface Payment {
|
|
832
856
|
id: string;
|
|
@@ -977,7 +1001,7 @@ export const WithPagination: Story = {
|
|
|
977
1001
|
/**
|
|
978
1002
|
* Table with column-specific filtering.
|
|
979
1003
|
*
|
|
980
|
-
* Use `UiDataTableToolbar`
|
|
1004
|
+
* Use `UiDataTableToolbar` as a wrapper for table filter controls.
|
|
981
1005
|
*/
|
|
982
1006
|
export const WithToolbar: Story = {
|
|
983
1007
|
args: {
|
|
@@ -992,20 +1016,28 @@ export const WithToolbar: Story = {
|
|
|
992
1016
|
},
|
|
993
1017
|
},
|
|
994
1018
|
render: (args) => ({
|
|
995
|
-
components: { UiDataTable, UiDataTableToolbar },
|
|
1019
|
+
components: { UiDataTable, UiDataTableToolbar, UiInput },
|
|
996
1020
|
setup() {
|
|
997
1021
|
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
998
1022
|
const table = computed(() => tableRef.value?.table);
|
|
999
|
-
|
|
1023
|
+
const emailFilter = computed({
|
|
1024
|
+
get: () =>
|
|
1025
|
+
(table.value?.getColumn('email')?.getFilterValue() as string) ?? '',
|
|
1026
|
+
set: (value) => table.value?.getColumn('email')?.setFilterValue(value),
|
|
1027
|
+
});
|
|
1028
|
+
return { args, emailFilter, tableRef, table };
|
|
1000
1029
|
},
|
|
1001
1030
|
template: `
|
|
1002
1031
|
<div class="gap-y-4">
|
|
1003
|
-
<UiDataTableToolbar
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1032
|
+
<UiDataTableToolbar>
|
|
1033
|
+
<UiInput
|
|
1034
|
+
v-model="emailFilter"
|
|
1035
|
+
name="email-filter"
|
|
1036
|
+
placeholder="Filter emails..."
|
|
1037
|
+
aria-label="Filter emails"
|
|
1038
|
+
class="h-8 w-full sm:w-[250px]"
|
|
1039
|
+
/>
|
|
1040
|
+
</UiDataTableToolbar>
|
|
1009
1041
|
<UiDataTable ref="tableRef" v-bind="args" />
|
|
1010
1042
|
</div>
|
|
1011
1043
|
`,
|
|
@@ -1015,8 +1047,8 @@ export const WithToolbar: Story = {
|
|
|
1015
1047
|
/**
|
|
1016
1048
|
* Table header controls with a focused email filter and a column visibility menu.
|
|
1017
1049
|
*
|
|
1018
|
-
*
|
|
1019
|
-
* columns from a checklist dropdown.
|
|
1050
|
+
* Put `UiDataTableColumnFilter` inside `UiDataTableToolbar` to show/hide
|
|
1051
|
+
* hideable columns from a checklist dropdown.
|
|
1020
1052
|
*/
|
|
1021
1053
|
export const WithColumnsFilter: Story = {
|
|
1022
1054
|
args: {
|
|
@@ -1031,7 +1063,12 @@ export const WithColumnsFilter: Story = {
|
|
|
1031
1063
|
},
|
|
1032
1064
|
},
|
|
1033
1065
|
render: (args) => ({
|
|
1034
|
-
components: {
|
|
1066
|
+
components: {
|
|
1067
|
+
UiDataTable,
|
|
1068
|
+
UiDataTableColumnFilter,
|
|
1069
|
+
UiDataTableToolbar,
|
|
1070
|
+
UiInput,
|
|
1071
|
+
},
|
|
1035
1072
|
setup() {
|
|
1036
1073
|
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
1037
1074
|
const table = computed(() => tableRef.value?.table);
|
|
@@ -1045,7 +1082,7 @@ export const WithColumnsFilter: Story = {
|
|
|
1045
1082
|
},
|
|
1046
1083
|
template: `
|
|
1047
1084
|
<div class="space-y-4">
|
|
1048
|
-
<
|
|
1085
|
+
<UiDataTableToolbar>
|
|
1049
1086
|
<UiInput
|
|
1050
1087
|
v-model="emailFilter"
|
|
1051
1088
|
name="email-filter"
|
|
@@ -1054,7 +1091,7 @@ export const WithColumnsFilter: Story = {
|
|
|
1054
1091
|
class="h-8 max-w-sm"
|
|
1055
1092
|
/>
|
|
1056
1093
|
<UiDataTableColumnFilter v-if="table" :table="table" />
|
|
1057
|
-
</
|
|
1094
|
+
</UiDataTableToolbar>
|
|
1058
1095
|
<UiDataTable ref="tableRef" v-bind="args" />
|
|
1059
1096
|
</div>
|
|
1060
1097
|
`,
|
|
@@ -1064,7 +1101,7 @@ export const WithColumnsFilter: Story = {
|
|
|
1064
1101
|
/**
|
|
1065
1102
|
* Table with global search across all columns.
|
|
1066
1103
|
*
|
|
1067
|
-
* Use
|
|
1104
|
+
* Use a table-bound `UiInput` inside `UiDataTableToolbar` to search across all columns.
|
|
1068
1105
|
* Matches any value in status, email, amount, or ID.
|
|
1069
1106
|
*
|
|
1070
1107
|
* Try typing "success", "gmail", or "316" to see it match different columns.
|
|
@@ -1082,20 +1119,27 @@ export const WithGlobalFilter: Story = {
|
|
|
1082
1119
|
},
|
|
1083
1120
|
},
|
|
1084
1121
|
render: (args) => ({
|
|
1085
|
-
components: { UiDataTable, UiDataTableToolbar },
|
|
1122
|
+
components: { UiDataTable, UiDataTableToolbar, UiInput },
|
|
1086
1123
|
setup() {
|
|
1087
1124
|
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
1088
1125
|
const table = computed(() => tableRef.value?.table);
|
|
1089
|
-
|
|
1126
|
+
const globalSearch = computed({
|
|
1127
|
+
get: () => (table.value?.getState().globalFilter as string) ?? '',
|
|
1128
|
+
set: (value) => table.value?.setGlobalFilter(value),
|
|
1129
|
+
});
|
|
1130
|
+
return { args, globalSearch, tableRef, table };
|
|
1090
1131
|
},
|
|
1091
1132
|
template: `
|
|
1092
1133
|
<div class="gap-y-4">
|
|
1093
|
-
<UiDataTableToolbar
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1134
|
+
<UiDataTableToolbar>
|
|
1135
|
+
<UiInput
|
|
1136
|
+
v-model="globalSearch"
|
|
1137
|
+
name="global-search"
|
|
1138
|
+
placeholder="Search all columns..."
|
|
1139
|
+
aria-label="Search all columns"
|
|
1140
|
+
class="h-8 w-full sm:w-[250px]"
|
|
1141
|
+
/>
|
|
1142
|
+
</UiDataTableToolbar>
|
|
1099
1143
|
<UiDataTable ref="tableRef" v-bind="args" />
|
|
1100
1144
|
</div>
|
|
1101
1145
|
`,
|
|
@@ -1177,7 +1221,7 @@ export const WithDraggableColumns: Story = {
|
|
|
1177
1221
|
v-bind="args"
|
|
1178
1222
|
:on-column-order-change="handleColumnOrderChange"
|
|
1179
1223
|
/>
|
|
1180
|
-
<p class="text-muted-foreground
|
|
1224
|
+
<p class="body-14-regular text-muted-foreground">
|
|
1181
1225
|
Drag a column header to reorder columns.
|
|
1182
1226
|
<span v-if="columnOrder.length">
|
|
1183
1227
|
Current order: {{ columnOrder.join(', ') }}
|
|
@@ -1215,7 +1259,7 @@ export const WithExpandableRows: Story = {
|
|
|
1215
1259
|
template: `
|
|
1216
1260
|
<UiDataTable v-bind="args">
|
|
1217
1261
|
<template #expanded-row="{ row }">
|
|
1218
|
-
<div class="rounded-md bg-background-surface-muted p-4
|
|
1262
|
+
<div class="body-14-regular rounded-md bg-background-surface-muted p-4">
|
|
1219
1263
|
<p class="font-medium">Payment {{ row.original.id }}</p>
|
|
1220
1264
|
<p class="text-muted-foreground">
|
|
1221
1265
|
Customer: {{ row.original.email }} - Status: {{ row.original.status }}
|
|
@@ -1251,20 +1295,32 @@ export const FullExample: Story = {
|
|
|
1251
1295
|
},
|
|
1252
1296
|
},
|
|
1253
1297
|
render: (args) => ({
|
|
1254
|
-
components: {
|
|
1298
|
+
components: {
|
|
1299
|
+
UiDataTable,
|
|
1300
|
+
UiDataTableToolbar,
|
|
1301
|
+
UiDataTablePagination,
|
|
1302
|
+
UiInput,
|
|
1303
|
+
},
|
|
1255
1304
|
setup() {
|
|
1256
1305
|
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
1257
1306
|
const table = computed(() => tableRef.value?.table);
|
|
1258
|
-
|
|
1307
|
+
const globalSearch = computed({
|
|
1308
|
+
get: () => (table.value?.getState().globalFilter as string) ?? '',
|
|
1309
|
+
set: (value) => table.value?.setGlobalFilter(value),
|
|
1310
|
+
});
|
|
1311
|
+
return { args, globalSearch, tableRef, table };
|
|
1259
1312
|
},
|
|
1260
1313
|
template: `
|
|
1261
1314
|
<div class="gap-y-4">
|
|
1262
|
-
<UiDataTableToolbar
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1315
|
+
<UiDataTableToolbar>
|
|
1316
|
+
<UiInput
|
|
1317
|
+
v-model="globalSearch"
|
|
1318
|
+
name="global-search"
|
|
1319
|
+
placeholder="Search..."
|
|
1320
|
+
aria-label="Search all columns"
|
|
1321
|
+
class="h-8 w-full sm:w-[250px]"
|
|
1322
|
+
/>
|
|
1323
|
+
</UiDataTableToolbar>
|
|
1268
1324
|
<UiDataTable ref="tableRef" v-bind="args" />
|
|
1269
1325
|
<UiDataTablePagination v-if="table" :table="table" />
|
|
1270
1326
|
</div>
|
|
@@ -1302,7 +1358,7 @@ export const WithCustomEmptyText: Story = {
|
|
|
1302
1358
|
|
|
1303
1359
|
const withCustomEmptySlotTemplateSource = `<script setup lang="ts">
|
|
1304
1360
|
import { UiDataTable, UiIcon } from '@aleph-alpha/ui-library';
|
|
1305
|
-
import type { ColumnDef } from '@
|
|
1361
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
1306
1362
|
|
|
1307
1363
|
interface Payment {
|
|
1308
1364
|
id: string;
|
|
@@ -1408,7 +1464,7 @@ const columnHeaderColumns: ColumnDef<Payment>[] = [
|
|
|
1408
1464
|
const withColumnHeaderTemplateSource = `<script setup lang="ts">
|
|
1409
1465
|
import { h } from 'vue';
|
|
1410
1466
|
import { UiDataTable, UiDataTableColumnHeader } from '@aleph-alpha/ui-library';
|
|
1411
|
-
import type { ColumnDef } from '@
|
|
1467
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
1412
1468
|
|
|
1413
1469
|
interface Payment {
|
|
1414
1470
|
id: string;
|
|
@@ -1480,20 +1536,27 @@ export const WithColumnHeader: Story = {
|
|
|
1480
1536
|
},
|
|
1481
1537
|
},
|
|
1482
1538
|
render: (args) => ({
|
|
1483
|
-
components: { UiDataTable, UiDataTableToolbar },
|
|
1539
|
+
components: { UiDataTable, UiDataTableToolbar, UiInput },
|
|
1484
1540
|
setup() {
|
|
1485
1541
|
const tableRef = ref<InstanceType<typeof UiDataTable>>();
|
|
1486
1542
|
const table = computed(() => tableRef.value?.table);
|
|
1487
|
-
|
|
1543
|
+
const globalSearch = computed({
|
|
1544
|
+
get: () => (table.value?.getState().globalFilter as string) ?? '',
|
|
1545
|
+
set: (value) => table.value?.setGlobalFilter(value),
|
|
1546
|
+
});
|
|
1547
|
+
return { args, globalSearch, tableRef, table };
|
|
1488
1548
|
},
|
|
1489
1549
|
template: `
|
|
1490
1550
|
<div class="gap-y-4">
|
|
1491
|
-
<UiDataTableToolbar
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1551
|
+
<UiDataTableToolbar>
|
|
1552
|
+
<UiInput
|
|
1553
|
+
v-model="globalSearch"
|
|
1554
|
+
name="global-search"
|
|
1555
|
+
placeholder="Search..."
|
|
1556
|
+
aria-label="Search all columns"
|
|
1557
|
+
class="h-8 w-full sm:w-[250px]"
|
|
1558
|
+
/>
|
|
1559
|
+
</UiDataTableToolbar>
|
|
1497
1560
|
<UiDataTable ref="tableRef" v-bind="args" />
|
|
1498
1561
|
</div>
|
|
1499
1562
|
`,
|
|
@@ -1565,7 +1628,7 @@ export const WithMinHeightSmallDataset: Story = {
|
|
|
1565
1628
|
code: `<script setup lang="ts">
|
|
1566
1629
|
import { h, ref, computed } from 'vue';
|
|
1567
1630
|
import { UiDataTable, UiDataTableColumnHeader, UiDataTablePagination } from '@aleph-alpha/ui-library';
|
|
1568
|
-
import type { ColumnDef } from '@
|
|
1631
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
1569
1632
|
|
|
1570
1633
|
interface Payment { id: string; amount: number; status: string; email: string; }
|
|
1571
1634
|
|
|
@@ -1710,7 +1773,7 @@ import {
|
|
|
1710
1773
|
UiDropdownMenuTrigger,
|
|
1711
1774
|
} from '@aleph-alpha/ui-library';
|
|
1712
1775
|
import { UiButton } from '@aleph-alpha/ui-library';
|
|
1713
|
-
import type { ColumnDef } from '@
|
|
1776
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
1714
1777
|
|
|
1715
1778
|
interface Payment {
|
|
1716
1779
|
id: string;
|
|
@@ -1822,22 +1885,21 @@ const cellFormattingColumns: ColumnDef<Payment>[] = [
|
|
|
1822
1885
|
accessorKey: 'status',
|
|
1823
1886
|
header: 'Status',
|
|
1824
1887
|
cell: ({ row }) => {
|
|
1825
|
-
const status = row.getValue('status') as
|
|
1826
|
-
const
|
|
1827
|
-
success:
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300',
|
|
1833
|
-
failed: 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300',
|
|
1834
|
-
};
|
|
1888
|
+
const status = row.getValue('status') as Payment['status'];
|
|
1889
|
+
const statusVariants = {
|
|
1890
|
+
success: 'success',
|
|
1891
|
+
processing: 'secondary',
|
|
1892
|
+
pending: 'warning',
|
|
1893
|
+
failed: 'destructive',
|
|
1894
|
+
} as const;
|
|
1835
1895
|
return h(
|
|
1836
|
-
|
|
1896
|
+
UiBadge,
|
|
1837
1897
|
{
|
|
1838
|
-
|
|
1898
|
+
variant: statusVariants[status],
|
|
1899
|
+
size: 'small',
|
|
1900
|
+
class: 'capitalize',
|
|
1839
1901
|
},
|
|
1840
|
-
status,
|
|
1902
|
+
() => status,
|
|
1841
1903
|
);
|
|
1842
1904
|
},
|
|
1843
1905
|
size: 120,
|
|
@@ -1846,7 +1908,11 @@ const cellFormattingColumns: ColumnDef<Payment>[] = [
|
|
|
1846
1908
|
accessorKey: 'email',
|
|
1847
1909
|
header: 'Email',
|
|
1848
1910
|
cell: ({ row }) =>
|
|
1849
|
-
h(
|
|
1911
|
+
h(
|
|
1912
|
+
'div',
|
|
1913
|
+
{ class: 'body-14-regular font-mono lowercase' },
|
|
1914
|
+
row.getValue('email'),
|
|
1915
|
+
),
|
|
1850
1916
|
size: 250,
|
|
1851
1917
|
},
|
|
1852
1918
|
{
|
|
@@ -1872,8 +1938,8 @@ const cellFormattingColumns: ColumnDef<Payment>[] = [
|
|
|
1872
1938
|
|
|
1873
1939
|
const withCellFormattingTemplateSource = `<script setup lang="ts">
|
|
1874
1940
|
import { h } from 'vue';
|
|
1875
|
-
import { UiDataTable } from '@aleph-alpha/ui-library';
|
|
1876
|
-
import type { ColumnDef } from '@
|
|
1941
|
+
import { UiBadge, UiDataTable } from '@aleph-alpha/ui-library';
|
|
1942
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
1877
1943
|
|
|
1878
1944
|
interface Payment {
|
|
1879
1945
|
id: string;
|
|
@@ -1893,18 +1959,20 @@ const columns: ColumnDef<Payment>[] = [
|
|
|
1893
1959
|
{
|
|
1894
1960
|
accessorKey: 'status',
|
|
1895
1961
|
header: 'Status',
|
|
1896
|
-
//
|
|
1962
|
+
// Status badge with built-in UiBadge variants
|
|
1897
1963
|
cell: ({ row }) => {
|
|
1898
|
-
const status = row.getValue('status') as
|
|
1899
|
-
const
|
|
1900
|
-
success: '
|
|
1901
|
-
processing: '
|
|
1902
|
-
pending: '
|
|
1903
|
-
failed: '
|
|
1904
|
-
};
|
|
1905
|
-
return h(
|
|
1906
|
-
|
|
1907
|
-
|
|
1964
|
+
const status = row.getValue('status') as Payment['status'];
|
|
1965
|
+
const statusVariants = {
|
|
1966
|
+
success: 'success',
|
|
1967
|
+
processing: 'secondary',
|
|
1968
|
+
pending: 'warning',
|
|
1969
|
+
failed: 'destructive',
|
|
1970
|
+
} as const;
|
|
1971
|
+
return h(UiBadge, {
|
|
1972
|
+
variant: statusVariants[status],
|
|
1973
|
+
size: 'small',
|
|
1974
|
+
class: 'capitalize',
|
|
1975
|
+
}, () => status);
|
|
1908
1976
|
},
|
|
1909
1977
|
},
|
|
1910
1978
|
{
|
|
@@ -1912,7 +1980,7 @@ const columns: ColumnDef<Payment>[] = [
|
|
|
1912
1980
|
header: 'Email',
|
|
1913
1981
|
// Monospace font for emails
|
|
1914
1982
|
cell: ({ row }) => h('div', {
|
|
1915
|
-
class: '
|
|
1983
|
+
class: 'body-14-regular font-mono lowercase'
|
|
1916
1984
|
}, row.getValue('email')),
|
|
1917
1985
|
},
|
|
1918
1986
|
{
|
|
@@ -1972,7 +2040,7 @@ export const WithCellFormatting: Story = {
|
|
|
1972
2040
|
const withRowClickTemplateSource = `<script setup lang="ts">
|
|
1973
2041
|
import { ref, h } from 'vue';
|
|
1974
2042
|
import { UiDataTable, UiDataTableColumnHeader } from '@aleph-alpha/ui-library';
|
|
1975
|
-
import type { ColumnDef } from '@
|
|
2043
|
+
import type { ColumnDef } from '@aleph-alpha/ui-library';
|
|
1976
2044
|
|
|
1977
2045
|
interface Payment {
|
|
1978
2046
|
id: string;
|
|
@@ -2025,7 +2093,7 @@ const clickedRow = ref<Payment | null>(null);
|
|
|
2025
2093
|
:columns="columns"
|
|
2026
2094
|
:on-row-click="(row) => (clickedRow = row)"
|
|
2027
2095
|
/>
|
|
2028
|
-
<div v-if="clickedRow" class="mt-4 rounded border p-3
|
|
2096
|
+
<div v-if="clickedRow" class="body-14-regular mt-4 rounded border p-3">
|
|
2029
2097
|
Clicked: {{ clickedRow.email }} - {{ clickedRow.status }}
|
|
2030
2098
|
</div>
|
|
2031
2099
|
</template>`;
|
|
@@ -2057,10 +2125,10 @@ export const WithRowClick: Story = {
|
|
|
2057
2125
|
template: `
|
|
2058
2126
|
<div>
|
|
2059
2127
|
<UiDataTable v-bind="args" :on-row-click="handleRowClick" />
|
|
2060
|
-
<div v-if="clickedRow" class="mt-4 rounded border p-3
|
|
2128
|
+
<div v-if="clickedRow" class="body-14-regular mt-4 rounded border p-3">
|
|
2061
2129
|
Clicked: <strong>{{ clickedRow.email }}</strong> - {{ clickedRow.status }} - {{ new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(clickedRow.amount) }}
|
|
2062
2130
|
</div>
|
|
2063
|
-
<div v-else class="text-muted-foreground mt-4
|
|
2131
|
+
<div v-else class="body-14-regular text-muted-foreground mt-4">Click a row to see its data</div>
|
|
2064
2132
|
</div>
|
|
2065
2133
|
`,
|
|
2066
2134
|
}),
|
|
@@ -35,7 +35,7 @@ const labels = computed(() => ({
|
|
|
35
35
|
</script>
|
|
36
36
|
|
|
37
37
|
<template>
|
|
38
|
-
<div class="flex items-center justify-between px-2">
|
|
38
|
+
<div class="flex items-center gap-2 justify-between px-2">
|
|
39
39
|
<div
|
|
40
40
|
v-if="showSelection"
|
|
41
41
|
class="flex-1 body-14-regular text-muted-foreground"
|