@invopop/popui 0.1.4-beta.45 → 0.1.4-beta.46
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.
|
@@ -78,6 +78,7 @@ export interface DataTableProps<TData> {
|
|
|
78
78
|
initialSortDirection?: TableSortBy;
|
|
79
79
|
initialFrozenColumns?: string[];
|
|
80
80
|
initialColumnOrder?: string[];
|
|
81
|
+
initialColumnVisibility?: Record<string, boolean>;
|
|
81
82
|
pageSizeOptions?: number[];
|
|
82
83
|
emptyState?: Omit<EmptyStateProps, 'children' | 'check'>;
|
|
83
84
|
onRowClick?: (row: TData) => void;
|
|
@@ -96,6 +97,7 @@ export interface DataTableProps<TData> {
|
|
|
96
97
|
onFreezeChange?: (columnId: string) => void;
|
|
97
98
|
onColumnResize?: (columnSizes: Record<string, number>) => void;
|
|
98
99
|
onColumnOrderChange?: (columnOrder: string[]) => void;
|
|
100
|
+
onColumnVisibilityChange?: (visibility: Record<string, boolean>) => void;
|
|
99
101
|
getRowClassName?: (row: TData) => string;
|
|
100
102
|
getRowState?: (row: TData) => {
|
|
101
103
|
isSuccess?: boolean;
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
initialSortDirection,
|
|
46
46
|
initialFrozenColumns = [],
|
|
47
47
|
initialColumnOrder = [],
|
|
48
|
+
initialColumnVisibility = {},
|
|
48
49
|
emptyState = {
|
|
49
50
|
iconSource: Search,
|
|
50
51
|
title: 'No results',
|
|
@@ -65,6 +66,7 @@
|
|
|
65
66
|
onFreezeChange,
|
|
66
67
|
onColumnResize,
|
|
67
68
|
onColumnOrderChange,
|
|
69
|
+
onColumnVisibilityChange,
|
|
68
70
|
getRowClassName,
|
|
69
71
|
getRowState,
|
|
70
72
|
children
|
|
@@ -74,7 +76,7 @@
|
|
|
74
76
|
const enablePagination = !disablePagination
|
|
75
77
|
|
|
76
78
|
let rowSelection = $state<RowSelectionState>({})
|
|
77
|
-
let columnVisibility = $state<VisibilityState>(
|
|
79
|
+
let columnVisibility = $state<VisibilityState>(initialColumnVisibility)
|
|
78
80
|
let sorting = $state<SortingState>(
|
|
79
81
|
initialSortColumn && initialSortDirection
|
|
80
82
|
? [{ id: initialSortColumn, desc: initialSortDirection === 'desc' }]
|
|
@@ -151,6 +153,13 @@
|
|
|
151
153
|
}
|
|
152
154
|
})
|
|
153
155
|
|
|
156
|
+
// Track column visibility changes
|
|
157
|
+
$effect(() => {
|
|
158
|
+
if (onColumnVisibilityChange && Object.keys(columnVisibility).length > 0) {
|
|
159
|
+
onColumnVisibilityChange(columnVisibility)
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
|
|
154
163
|
const table = setupTable({
|
|
155
164
|
getData: () => data,
|
|
156
165
|
getColumns: () => columns,
|