@shotleybuilder/svelte-table-kit 0.12.0 → 0.13.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/README.md +4 -0
- package/dist/TableKit.svelte +16 -0
- package/dist/stores/persistence.d.ts +17 -1
- package/dist/stores/persistence.js +26 -0
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,6 +160,8 @@ Customize initial table state programmatically:
|
|
|
160
160
|
defaultSorting: [
|
|
161
161
|
{ columnId: 'name', direction: 'asc' }
|
|
162
162
|
],
|
|
163
|
+
defaultGrouping: ['role'],
|
|
164
|
+
defaultExpanded: true,
|
|
163
165
|
filterLogic: 'and'
|
|
164
166
|
}}
|
|
165
167
|
features={{
|
|
@@ -361,6 +363,8 @@ interface TableConfig {
|
|
|
361
363
|
defaultVisibleColumns?: string[]; // Visible column IDs (others hidden)
|
|
362
364
|
defaultFilters?: FilterCondition[]; // Initial filter conditions
|
|
363
365
|
defaultSorting?: SortConfig[]; // Initial sort configuration
|
|
366
|
+
defaultGrouping?: string[]; // Initial grouping column IDs (up to 3)
|
|
367
|
+
defaultExpanded?: boolean; // Initial expanded state for groups (default: true)
|
|
364
368
|
filterLogic?: 'and' | 'or'; // Filter combination logic
|
|
365
369
|
pagination?: {
|
|
366
370
|
pageSize: number;
|
package/dist/TableKit.svelte
CHANGED
|
@@ -18,6 +18,10 @@ import {
|
|
|
18
18
|
saveColumnFilters,
|
|
19
19
|
loadColumnOrder,
|
|
20
20
|
saveColumnOrder,
|
|
21
|
+
loadGrouping,
|
|
22
|
+
saveGrouping,
|
|
23
|
+
loadExpanded,
|
|
24
|
+
saveExpanded,
|
|
21
25
|
isBrowser
|
|
22
26
|
} from "./stores/persistence";
|
|
23
27
|
import { applyFilters } from "./utils/filters";
|
|
@@ -105,6 +109,12 @@ $: {
|
|
|
105
109
|
if (config.defaultColumnSizing) {
|
|
106
110
|
columnSizing.set(config.defaultColumnSizing);
|
|
107
111
|
}
|
|
112
|
+
if (config.defaultGrouping) {
|
|
113
|
+
grouping.set(config.defaultGrouping);
|
|
114
|
+
}
|
|
115
|
+
if (config.defaultExpanded !== void 0) {
|
|
116
|
+
expanded.set(config.defaultExpanded);
|
|
117
|
+
}
|
|
108
118
|
previousConfigId = config.id;
|
|
109
119
|
configInitialized = true;
|
|
110
120
|
} else if (!hasConfig && persistState && storageKey && !configInitialized) {
|
|
@@ -112,6 +122,8 @@ $: {
|
|
|
112
122
|
columnVisibility.set(loadColumnVisibility(storageKey) || {});
|
|
113
123
|
columnSizing.set(loadColumnSizing(storageKey) || {});
|
|
114
124
|
columnFilters.set(loadColumnFilters(storageKey) || []);
|
|
125
|
+
grouping.set(loadGrouping(storageKey) || []);
|
|
126
|
+
expanded.set(loadExpanded(storageKey) ?? true);
|
|
115
127
|
configInitialized = true;
|
|
116
128
|
} else if (!hasConfig && !configInitialized) {
|
|
117
129
|
configInitialized = true;
|
|
@@ -128,6 +140,8 @@ $: {
|
|
|
128
140
|
saveColumnSizing(storageKey, $columnSizing);
|
|
129
141
|
saveColumnFilters(storageKey, $columnFilters);
|
|
130
142
|
saveColumnOrder(storageKey, $columnOrder);
|
|
143
|
+
saveGrouping(storageKey, $grouping);
|
|
144
|
+
saveExpanded(storageKey, $expanded);
|
|
131
145
|
}
|
|
132
146
|
}
|
|
133
147
|
let showColumnPicker = false;
|
|
@@ -810,6 +824,8 @@ $: if (onStateChange) {
|
|
|
810
824
|
</slot>
|
|
811
825
|
{:else if cell.getIsPlaceholder()}
|
|
812
826
|
<!-- Placeholder cell - empty -->
|
|
827
|
+
{:else if row.getIsGrouped()}
|
|
828
|
+
<!-- Non-grouped column on a group row - render empty -->
|
|
813
829
|
{:else}
|
|
814
830
|
<!-- Normal cell -->
|
|
815
831
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisibilityState, ColumnSizingState, ColumnFiltersState, ColumnOrderState, SortingState, PaginationState } from '@tanstack/svelte-table';
|
|
1
|
+
import type { VisibilityState, ColumnSizingState, ColumnFiltersState, ColumnOrderState, SortingState, PaginationState, GroupingState, ExpandedState } from '@tanstack/svelte-table';
|
|
2
2
|
import type { ColumnOrderMode } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Check if we're in a browser environment
|
|
@@ -53,6 +53,22 @@ export declare function loadPagination(storageKey: string, defaultPageSize?: num
|
|
|
53
53
|
* Save pagination state to localStorage
|
|
54
54
|
*/
|
|
55
55
|
export declare function savePagination(storageKey: string, state: PaginationState): void;
|
|
56
|
+
/**
|
|
57
|
+
* Load grouping state from localStorage
|
|
58
|
+
*/
|
|
59
|
+
export declare function loadGrouping(storageKey: string): GroupingState;
|
|
60
|
+
/**
|
|
61
|
+
* Save grouping state to localStorage
|
|
62
|
+
*/
|
|
63
|
+
export declare function saveGrouping(storageKey: string, state: GroupingState): void;
|
|
64
|
+
/**
|
|
65
|
+
* Load expanded state from localStorage
|
|
66
|
+
*/
|
|
67
|
+
export declare function loadExpanded(storageKey: string): ExpandedState;
|
|
68
|
+
/**
|
|
69
|
+
* Save expanded state to localStorage
|
|
70
|
+
*/
|
|
71
|
+
export declare function saveExpanded(storageKey: string, state: ExpandedState): void;
|
|
56
72
|
/**
|
|
57
73
|
* Load filter column order mode from localStorage
|
|
58
74
|
*/
|
|
@@ -107,6 +107,30 @@ export function loadPagination(storageKey, defaultPageSize = 10) {
|
|
|
107
107
|
export function savePagination(storageKey, state) {
|
|
108
108
|
saveToStorage(`${storageKey}_pagination`, state);
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Load grouping state from localStorage
|
|
112
|
+
*/
|
|
113
|
+
export function loadGrouping(storageKey) {
|
|
114
|
+
return loadFromStorage(`${storageKey}_grouping`, []);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Save grouping state to localStorage
|
|
118
|
+
*/
|
|
119
|
+
export function saveGrouping(storageKey, state) {
|
|
120
|
+
saveToStorage(`${storageKey}_grouping`, state);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Load expanded state from localStorage
|
|
124
|
+
*/
|
|
125
|
+
export function loadExpanded(storageKey) {
|
|
126
|
+
return loadFromStorage(`${storageKey}_expanded`, true);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Save expanded state to localStorage
|
|
130
|
+
*/
|
|
131
|
+
export function saveExpanded(storageKey, state) {
|
|
132
|
+
saveToStorage(`${storageKey}_expanded`, state);
|
|
133
|
+
}
|
|
110
134
|
/**
|
|
111
135
|
* Load filter column order mode from localStorage
|
|
112
136
|
*/
|
|
@@ -132,6 +156,8 @@ export function clearTableState(storageKey) {
|
|
|
132
156
|
localStorage.removeItem(`${storageKey}_column_order`);
|
|
133
157
|
localStorage.removeItem(`${storageKey}_sorting`);
|
|
134
158
|
localStorage.removeItem(`${storageKey}_pagination`);
|
|
159
|
+
localStorage.removeItem(`${storageKey}_grouping`);
|
|
160
|
+
localStorage.removeItem(`${storageKey}_expanded`);
|
|
135
161
|
localStorage.removeItem(`${storageKey}_filter_column_order_mode`);
|
|
136
162
|
}
|
|
137
163
|
catch (error) {
|
package/dist/types.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export interface TableConfig {
|
|
|
40
40
|
defaultFilters?: FilterCondition[];
|
|
41
41
|
filterLogic?: FilterLogic;
|
|
42
42
|
defaultSorting?: SortConfig[];
|
|
43
|
+
defaultGrouping?: string[];
|
|
44
|
+
defaultExpanded?: boolean;
|
|
43
45
|
pagination?: {
|
|
44
46
|
pageSize: number;
|
|
45
47
|
pageSizeOptions?: number[];
|
package/package.json
CHANGED