@aleph-alpha/ui-library 2.2.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.
Files changed (32) hide show
  1. package/dist/system/components/UiToggle/UiToggle.vue.d.ts +5 -0
  2. package/dist/system/components/UiToggle/types.d.ts +13 -0
  3. package/dist/system/lib/heightTransition.d.ts +5 -0
  4. package/dist/system/lib/useDrag.d.ts +52 -0
  5. package/dist/system/lib.js +16727 -16225
  6. package/dist/system/patterns/UiDataTable/UiDataTable.vue.d.ts +22 -3
  7. package/dist/system/patterns/UiDataTable/UiDataTableColumnFilter.vue.d.ts +14 -0
  8. package/dist/system/patterns/UiDataTable/constants.d.ts +13 -0
  9. package/dist/system/patterns/UiDataTable/index.d.ts +2 -0
  10. package/dist/system/patterns/UiDataTable/types.d.ts +32 -1
  11. package/package.json +1 -1
  12. package/src/components/UiTable/__tests__/UiTableRow.test.ts +14 -5
  13. package/src/components/UiToggle/UiToggle.vue +18 -1
  14. package/src/components/UiToggle/__tests__/UiToggle.test.ts +33 -3
  15. package/src/components/UiToggle/types.ts +13 -0
  16. package/src/components/core/accordion/AccordionContent.vue +36 -1
  17. package/src/components/core/table/TableRow.vue +1 -1
  18. package/src/components/core/toggle/index.ts +2 -2
  19. package/src/lib/heightTransition.ts +27 -0
  20. package/src/lib/useDrag.stories.ts +295 -0
  21. package/src/lib/useDrag.ts +212 -0
  22. package/src/patterns/UiDataTable/UiDataTable.stories.ts +348 -0
  23. package/src/patterns/UiDataTable/UiDataTable.vue +558 -22
  24. package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +83 -0
  25. package/src/patterns/UiDataTable/UiDataTableColumnHeader.vue +4 -13
  26. package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +329 -0
  27. package/src/patterns/UiDataTable/__tests__/UiDataTableColumnFilter.test.ts +194 -0
  28. package/src/patterns/UiDataTable/__tests__/UiDataTableColumnHeader.test.ts +11 -0
  29. package/src/patterns/UiDataTable/constants.ts +15 -0
  30. package/src/patterns/UiDataTable/index.ts +2 -0
  31. package/src/patterns/UiDataTable/types.ts +33 -0
  32. package/src/patterns/UiSidebar/UiSidebarGroupContent.vue +13 -36
@@ -31,6 +31,11 @@ export const DATA_TABLE_LABELS = {
31
31
  filterPlaceholder: 'Search...',
32
32
  searchAllColumns: 'Search all columns',
33
33
  filterByColumn: (column: string) => `Filter by ${column}`,
34
+
35
+ /** UiDataTableColumnFilter */
36
+ columns: 'Columns',
37
+ toggleColumns: 'Toggle columns',
38
+ columnVisibility: 'Column visibility',
34
39
  } as const;
35
40
 
36
41
  export type DataTableLabels = typeof DATA_TABLE_LABELS;
@@ -76,3 +81,13 @@ export interface ToolbarLabels {
76
81
  /** Function to generate aria label for column filter */
77
82
  filterByColumn?: (column: string) => string;
78
83
  }
84
+
85
+ /** Labels for UiDataTableColumnFilter */
86
+ export interface ColumnFilterLabels {
87
+ /** Visible label for the trigger button. */
88
+ columns?: string;
89
+ /** Accessible label for the trigger button. */
90
+ toggleColumns?: string;
91
+ /** Dropdown section label. */
92
+ columnVisibility?: string;
93
+ }
@@ -1,6 +1,8 @@
1
1
  export { default as UiDataTable } from './UiDataTable.vue';
2
+ export { default as UiDataTableColumnFilter } from './UiDataTableColumnFilter.vue';
2
3
  export { default as UiDataTableColumnHeader } from './UiDataTableColumnHeader.vue';
3
4
  export { default as UiDataTablePagination } from './UiDataTablePagination.vue';
4
5
  export { default as UiDataTableToolbar } from './UiDataTableToolbar.vue';
5
6
  export * from './types';
6
7
  export * from './constants';
8
+ export * from '../../lib/useDrag';
@@ -1,6 +1,7 @@
1
1
  import type { Column, ColumnDef, Row, Table } from '@tanstack/vue-table';
2
2
  import type {
3
3
  ColumnHeaderLabels,
4
+ ColumnFilterLabels,
4
5
  PaginationLabels,
5
6
  ToolbarLabels,
6
7
  } from './constants';
@@ -45,6 +46,22 @@ export type UiDataTableProps<TData, TValue> = {
45
46
  * @example (item) => router.push(`/details/${item.id}`)
46
47
  */
47
48
  onRowClick?: (item: TData) => void;
49
+ /**
50
+ * Enables drag-and-drop reordering for table columns.
51
+ * @default false
52
+ */
53
+ draggableColumns?: boolean;
54
+ /**
55
+ * Callback when column order changes through drag-and-drop.
56
+ * Receives TanStack column IDs in their new order.
57
+ */
58
+ onColumnOrderChange?: (columnOrder: string[]) => void;
59
+ /**
60
+ * Function that determines whether a row can be expanded.
61
+ * Provide an `expanded-row` slot and toggle `row.toggleExpanded()` from a cell.
62
+ * @example (row) => row.original.children.length > 0
63
+ */
64
+ getRowCanExpand?: (row: Row<TData>) => boolean;
48
65
  };
49
66
 
50
67
  /**
@@ -123,3 +140,19 @@ export type UiDataTableToolbarProps<TData> = {
123
140
  */
124
141
  labels?: ToolbarLabels;
125
142
  };
143
+
144
+ /**
145
+ * Props for the UiDataTableColumnFilter component.
146
+ */
147
+ export type UiDataTableColumnFilterProps<TData> = {
148
+ /**
149
+ * The TanStack Table instance.
150
+ * @internal
151
+ */
152
+ table: Table<TData>;
153
+ /**
154
+ * Custom labels for i18n support.
155
+ * Partial object that merges with defaults.
156
+ */
157
+ labels?: ColumnFilterLabels;
158
+ };
@@ -1,6 +1,13 @@
1
1
  <script setup lang="ts">
2
2
  import { inject } from 'vue';
3
3
  import { SidebarGroupContent } from '@/components/core/sidebar';
4
+ import {
5
+ heightTransitionClass,
6
+ onHeightTransitionAfterEnter,
7
+ onHeightTransitionBeforeLeave,
8
+ onHeightTransitionEnter,
9
+ onHeightTransitionLeave,
10
+ } from '@/lib/heightTransition';
4
11
  import { uiSidebarGroupContextKey } from './groupContext';
5
12
  import type { UiSidebarGroupContentProps } from './types';
6
13
 
@@ -9,46 +16,16 @@ defineOptions({ name: 'UiSidebarGroupContent' });
9
16
  defineProps<UiSidebarGroupContentProps>();
10
17
 
11
18
  const group = inject(uiSidebarGroupContextKey, null);
12
-
13
- /**
14
- * Height-based collapse/expand transition that mirrors the sidebar's own
15
- * `transition-[width] duration-200 ease-linear` motion. We animate from
16
- * `0 → scrollHeight → auto` (and back) so a variable amount of nested menu
17
- * items inside the group animates together with the same timing curve.
18
- * @param el
19
- */
20
- function onEnter(el: Element) {
21
- const node = el as HTMLElement;
22
- node.style.height = '0px';
23
- // Force reflow so the browser registers the starting height before we
24
- // change it to the target on the next frame.
25
- node.style.height = `${node.scrollHeight}px`;
26
- }
27
-
28
- function onAfterEnter(el: Element) {
29
- // Drop the inline height so the group can grow/shrink with its children
30
- // after the open transition completes (adding/removing items, text reflow).
31
- (el as HTMLElement).style.height = '';
32
- }
33
-
34
- function onBeforeLeave(el: Element) {
35
- const node = el as HTMLElement;
36
- node.style.height = `${node.scrollHeight}px`;
37
- }
38
-
39
- function onLeave(el: Element) {
40
- (el as HTMLElement).style.height = '0px';
41
- }
42
19
  </script>
43
20
 
44
21
  <template>
45
22
  <Transition
46
- enter-active-class="transition-[height] duration-200 ease-linear overflow-hidden"
47
- leave-active-class="transition-[height] duration-200 ease-linear overflow-hidden"
48
- @enter="onEnter"
49
- @after-enter="onAfterEnter"
50
- @before-leave="onBeforeLeave"
51
- @leave="onLeave"
23
+ :enter-active-class="heightTransitionClass"
24
+ :leave-active-class="heightTransitionClass"
25
+ @enter="onHeightTransitionEnter"
26
+ @after-enter="onHeightTransitionAfterEnter"
27
+ @before-leave="onHeightTransitionBeforeLeave"
28
+ @leave="onHeightTransitionLeave"
52
29
  >
53
30
  <SidebarGroupContent v-if="!group || group.open.value" v-bind="$attrs">
54
31
  <slot />