@loykin/gridkit 0.0.1-beta.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 +316 -0
- package/dist/index.cjs +2485 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +266 -0
- package/dist/index.d.ts +266 -0
- package/dist/index.js +2454 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/styles.d.ts +1 -0
- package/package.json +72 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Row, ColumnDef, SortingState, ColumnFiltersState, Table, VisibilityState, ColumnPinningState, ColumnSizingState } from '@tanstack/react-table';
|
|
3
|
+
import React$1, { ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
interface Transaction<T> {
|
|
6
|
+
add?: T[];
|
|
7
|
+
update?: Array<{
|
|
8
|
+
id: string;
|
|
9
|
+
data: Partial<T>;
|
|
10
|
+
}>;
|
|
11
|
+
remove?: string[];
|
|
12
|
+
}
|
|
13
|
+
interface DataStore<T> {
|
|
14
|
+
get(id: string): T | undefined;
|
|
15
|
+
/** Returns a stable array reference — same reference until the next transaction */
|
|
16
|
+
getSnapshot(): T[];
|
|
17
|
+
/** Monotonically increasing integer — increments on every transaction */
|
|
18
|
+
getVersion(): number;
|
|
19
|
+
applyTransaction(tx: Transaction<T>): void;
|
|
20
|
+
/** useSyncExternalStore compatible subscribe */
|
|
21
|
+
subscribe(listener: () => void): () => void;
|
|
22
|
+
}
|
|
23
|
+
declare function createDataStore<T>(getRowId: (item: T, index: number) => string): DataStore<T>;
|
|
24
|
+
|
|
25
|
+
type DataGridColumnDef<T extends object> = ColumnDef<T, unknown>;
|
|
26
|
+
type ColumnSizingMode = 'auto' | 'flex' | 'fixed';
|
|
27
|
+
/**
|
|
28
|
+
* Table width handling strategy:
|
|
29
|
+
* - 'spacer': Each column independent px + spacer cell fills remaining space (default)
|
|
30
|
+
* - 'fill-last': Last visible column stretches to fill remaining space
|
|
31
|
+
* - 'independent': Each column independent px, no fill — right gap when columns are narrow
|
|
32
|
+
*/
|
|
33
|
+
type TableWidthMode = 'spacer' | 'fill-last' | 'independent';
|
|
34
|
+
interface CheckboxConfig<T extends object> {
|
|
35
|
+
getRowId: (row: T) => string;
|
|
36
|
+
selectedIds: Set<string>;
|
|
37
|
+
onSelectAll: (rows: Row<T>[], checked: boolean) => void;
|
|
38
|
+
onSelectOne: (rowId: string, checked: boolean) => void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Rendering props owned by DataGridTableView.
|
|
42
|
+
* DataGridBaseProps and DataGridTableViewProps both extend this
|
|
43
|
+
* so these are declared exactly once.
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Slot-based class injection for DataGrid elements.
|
|
47
|
+
* Each key targets a specific part of the table structure.
|
|
48
|
+
* User-supplied classes are merged after library defaults via cn(),
|
|
49
|
+
* so Tailwind classes here will take precedence over library defaults.
|
|
50
|
+
*/
|
|
51
|
+
interface DataGridClassNames {
|
|
52
|
+
/** Outermost wrapper div (border, rounded-md) */
|
|
53
|
+
container?: string;
|
|
54
|
+
/** Header panel div (bg-muted, overflow:hidden) */
|
|
55
|
+
header?: string;
|
|
56
|
+
/** Individual header cell div */
|
|
57
|
+
headerCell?: string;
|
|
58
|
+
/** Body row div */
|
|
59
|
+
row?: string;
|
|
60
|
+
/** Body cell div */
|
|
61
|
+
cell?: string;
|
|
62
|
+
}
|
|
63
|
+
interface TableViewConfig<T extends object> {
|
|
64
|
+
isLoading?: boolean;
|
|
65
|
+
emptyMessage?: string;
|
|
66
|
+
/**
|
|
67
|
+
* No data일 때 body 영역에 표시할 커스텀 UI.
|
|
68
|
+
* 제공 시 emptyMessage보다 우선 적용됨.
|
|
69
|
+
*/
|
|
70
|
+
emptyContent?: ReactNode;
|
|
71
|
+
/** 테이블 헤더 표시 여부. 기본값 true. */
|
|
72
|
+
showHeader?: boolean;
|
|
73
|
+
onRowClick?: (row: T) => void;
|
|
74
|
+
rowCursor?: boolean;
|
|
75
|
+
enableColumnResizing?: boolean;
|
|
76
|
+
/** Show per-column filter row below the header (AG Grid style) */
|
|
77
|
+
enableColumnFilters?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Controls how column filters are displayed when enableColumnFilters=true.
|
|
80
|
+
* - 'row' (default): dedicated filter row below the header
|
|
81
|
+
* - 'icon': filter icon inside each header cell that opens a popover
|
|
82
|
+
*/
|
|
83
|
+
filterDisplay?: 'row' | 'icon';
|
|
84
|
+
tableHeight?: string | number | 'auto';
|
|
85
|
+
/** Show vertical dividers between columns */
|
|
86
|
+
bordered?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Table width handling strategy:
|
|
89
|
+
* - 'spacer': Each column independent px + spacer cell fills remaining space (default)
|
|
90
|
+
* - 'fill-last': Last visible column stretches to fill remaining space
|
|
91
|
+
* - 'independent': Each column independent px, no fill — right gap when columns are narrow
|
|
92
|
+
*/
|
|
93
|
+
tableWidthMode?: TableWidthMode;
|
|
94
|
+
/**
|
|
95
|
+
* Fixed row height in px. Sets both the actual CSS min-height of each row
|
|
96
|
+
* and the virtualizer's estimateSize so they stay in sync. Default: 33.
|
|
97
|
+
* Rows with meta.wrap=true can still grow beyond this height — measureElement
|
|
98
|
+
* will track the actual size for accurate virtual positioning.
|
|
99
|
+
*/
|
|
100
|
+
rowHeight?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Override the virtualizer's estimated row height independently of rowHeight.
|
|
103
|
+
* Only needed for variable-height rows where you want a different estimate.
|
|
104
|
+
*/
|
|
105
|
+
estimateRowHeight?: number;
|
|
106
|
+
/** Rows to render outside the visible area (virtualizer overscan, default: 10) */
|
|
107
|
+
overscan?: number;
|
|
108
|
+
/** Slot-based class injection for individual table elements */
|
|
109
|
+
classNames?: DataGridClassNames;
|
|
110
|
+
}
|
|
111
|
+
interface DataGridBaseProps<T extends object> extends TableViewConfig<T> {
|
|
112
|
+
data?: T[];
|
|
113
|
+
/**
|
|
114
|
+
* Map-based external store for real-time / high-frequency updates.
|
|
115
|
+
* Use with useDataStore() and table.applyTransaction().
|
|
116
|
+
* Mutually exclusive with the `data` prop — set one or the other.
|
|
117
|
+
*/
|
|
118
|
+
dataStore?: DataStore<T>;
|
|
119
|
+
columns: DataGridColumnDef<T>[];
|
|
120
|
+
error?: Error | null;
|
|
121
|
+
enableSorting?: boolean;
|
|
122
|
+
initialSorting?: SortingState;
|
|
123
|
+
onSortingChange?: (sorting: SortingState) => void;
|
|
124
|
+
manualSorting?: boolean;
|
|
125
|
+
columnFilters?: ColumnFiltersState;
|
|
126
|
+
globalFilter?: string;
|
|
127
|
+
onGlobalFilterChange?: (value: string) => void;
|
|
128
|
+
searchableColumns?: string[];
|
|
129
|
+
leftFilters?: (table: Table<T>) => React.ReactNode;
|
|
130
|
+
rightFilters?: (table: Table<T>) => React.ReactNode;
|
|
131
|
+
visibilityState?: VisibilityState;
|
|
132
|
+
/** Initial column pinning — { left: ['id', ...], right: ['id', ...] } */
|
|
133
|
+
initialPinning?: ColumnPinningState;
|
|
134
|
+
columnSizingMode?: ColumnSizingMode;
|
|
135
|
+
/** Enable row expansion (requires subRows in data or getSubRows) */
|
|
136
|
+
enableExpanding?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Extract sub-rows from a row for tree display.
|
|
139
|
+
* If omitted, TanStack Table looks for a 'subRows' key on each data item.
|
|
140
|
+
*/
|
|
141
|
+
getSubRows?: (originalRow: T, index: number) => T[] | undefined;
|
|
142
|
+
checkboxConfig?: CheckboxConfig<T>;
|
|
143
|
+
tableKey?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Sync table state (pagination, search) to the in-memory Zustand store so it
|
|
146
|
+
* survives re-renders within the same session. Requires tableKey to be set.
|
|
147
|
+
* Note: in-memory only — does not persist across page reloads.
|
|
148
|
+
*/
|
|
149
|
+
syncState?: boolean;
|
|
150
|
+
onTableReady?: (table: Table<T>) => void;
|
|
151
|
+
onColumnSizingChange?: (sizing: ColumnSizingState) => void;
|
|
152
|
+
}
|
|
153
|
+
interface DataGridProps<T extends object> extends DataGridBaseProps<T> {
|
|
154
|
+
enablePagination?: boolean;
|
|
155
|
+
paginationConfig?: {
|
|
156
|
+
pageSize?: number;
|
|
157
|
+
initialPageIndex?: number;
|
|
158
|
+
};
|
|
159
|
+
pageSizes?: number[];
|
|
160
|
+
/** Server-side total row count for manual pagination */
|
|
161
|
+
totalCount?: number;
|
|
162
|
+
onPageChange?: (pageIndex: number, pageSize: number) => void;
|
|
163
|
+
}
|
|
164
|
+
interface DataGridDragProps<T extends object> extends DataGridBaseProps<T> {
|
|
165
|
+
/** Required: stable unique id per data item — used to track row identity across reorders */
|
|
166
|
+
getRowId: (originalRow: T, index: number) => string;
|
|
167
|
+
/** Called with the full reordered data array after each drag */
|
|
168
|
+
onRowReorder: (newData: T[]) => void;
|
|
169
|
+
}
|
|
170
|
+
interface DataGridInfinityProps<T extends object> extends DataGridBaseProps<T> {
|
|
171
|
+
hasNextPage?: boolean;
|
|
172
|
+
isFetchingNextPage?: boolean;
|
|
173
|
+
fetchNextPage?: () => void;
|
|
174
|
+
/** IntersectionObserver rootMargin to trigger next page load */
|
|
175
|
+
rootMargin?: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
interface DataGridPropsWithRef<T extends object> extends DataGridProps<T> {
|
|
179
|
+
/** Ref populated with the TanStack Table instance after first render */
|
|
180
|
+
tableRef?: React.RefObject<Table<T> | null>;
|
|
181
|
+
}
|
|
182
|
+
declare function DataGrid<T extends object>(props: DataGridPropsWithRef<T>): react_jsx_runtime.JSX.Element;
|
|
183
|
+
|
|
184
|
+
declare function DataGridInfinity<T extends object>(props: DataGridInfinityProps<T>): react_jsx_runtime.JSX.Element;
|
|
185
|
+
|
|
186
|
+
declare function DataGridDrag<T extends object>(props: DataGridDragProps<T>): react_jsx_runtime.JSX.Element;
|
|
187
|
+
|
|
188
|
+
interface Props$1<T extends object> {
|
|
189
|
+
table: Table<T>;
|
|
190
|
+
}
|
|
191
|
+
declare function ColumnVisibilityDropdown<T extends object>({ table }: Props$1<T>): react_jsx_runtime.JSX.Element;
|
|
192
|
+
|
|
193
|
+
interface Props<T extends object> {
|
|
194
|
+
table: Table<T>;
|
|
195
|
+
placeholder?: string;
|
|
196
|
+
className?: string;
|
|
197
|
+
}
|
|
198
|
+
declare function GlobalSearch<T extends object>({ table, placeholder, className, }: Props<T>): react_jsx_runtime.JSX.Element;
|
|
199
|
+
|
|
200
|
+
interface SelectFilterProps<T extends object> {
|
|
201
|
+
table: Table<T>;
|
|
202
|
+
columnId: string;
|
|
203
|
+
label: string;
|
|
204
|
+
}
|
|
205
|
+
declare function SelectFilter<T extends object>({ table, columnId, label }: SelectFilterProps<T>): react_jsx_runtime.JSX.Element | null;
|
|
206
|
+
interface MultiSelectFilterProps<T extends object> {
|
|
207
|
+
table: Table<T>;
|
|
208
|
+
columnId: string;
|
|
209
|
+
label: string;
|
|
210
|
+
}
|
|
211
|
+
declare function MultiSelectFilter<T extends object>({ table, columnId, label, }: MultiSelectFilterProps<T>): react_jsx_runtime.JSX.Element | null;
|
|
212
|
+
|
|
213
|
+
interface TreeCellProps {
|
|
214
|
+
row: Row<any>;
|
|
215
|
+
/** Indent per depth level in px (default: 16) */
|
|
216
|
+
indentSize?: number;
|
|
217
|
+
children: React$1.ReactNode;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Wraps cell content with a depth-aware indent and expand/collapse toggle.
|
|
221
|
+
* Drop this into whichever column should act as the tree "name" column.
|
|
222
|
+
*
|
|
223
|
+
* Usage:
|
|
224
|
+
* cell: ({ row }) => (
|
|
225
|
+
* <TreeCell row={row} indentSize={20}>
|
|
226
|
+
* <Icon /> <span>{row.original.name}</span>
|
|
227
|
+
* </TreeCell>
|
|
228
|
+
* )
|
|
229
|
+
*/
|
|
230
|
+
declare function TreeCell({ row, indentSize, children }: TreeCellProps): react_jsx_runtime.JSX.Element;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Drag handle cell — place in whichever column should act as the grab handle.
|
|
234
|
+
* Reads listeners/attributes from RowDragContext set by SortableRow.
|
|
235
|
+
* Only works inside DataGridDrag.
|
|
236
|
+
*
|
|
237
|
+
* Usage:
|
|
238
|
+
* { id: 'drag', size: 36, enableResizing: false,
|
|
239
|
+
* cell: () => <DragHandleCell /> }
|
|
240
|
+
*/
|
|
241
|
+
declare function DragHandleCell(): react_jsx_runtime.JSX.Element;
|
|
242
|
+
|
|
243
|
+
interface UseDataStoreOptions<T> {
|
|
244
|
+
getRowId: (item: T, index: number) => string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Creates and memoizes a DataStore instance for use with <DataGrid dataStore={store} />.
|
|
248
|
+
*
|
|
249
|
+
* The store is stable for the lifetime of the component — pass a stable `getRowId`
|
|
250
|
+
* callback (e.g. defined outside render or wrapped in useCallback).
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* const store = useDataStore<Pod>({ getRowId: p => p.name })
|
|
254
|
+
*
|
|
255
|
+
* useEffect(() => {
|
|
256
|
+
* const watcher = watchPods(namespace, {
|
|
257
|
+
* onAdded: pod => store.applyTransaction({ add: [pod] }),
|
|
258
|
+
* onModified: pod => store.applyTransaction({ update: [{ id: pod.name, data: pod }] }),
|
|
259
|
+
* onDeleted: name => store.applyTransaction({ remove: [name] }),
|
|
260
|
+
* })
|
|
261
|
+
* return () => watcher.stop()
|
|
262
|
+
* }, [namespace])
|
|
263
|
+
*/
|
|
264
|
+
declare function useDataStore<T>(options: UseDataStoreOptions<T>): DataStore<T>;
|
|
265
|
+
|
|
266
|
+
export { type CheckboxConfig, type ColumnSizingMode, ColumnVisibilityDropdown, DataGrid, type DataGridBaseProps, type DataGridClassNames, type DataGridColumnDef, DataGridDrag, type DataGridDragProps, DataGridInfinity, type DataGridInfinityProps, type DataGridProps, type DataStore, DragHandleCell, GlobalSearch, MultiSelectFilter, SelectFilter, type TableViewConfig, type TableWidthMode, type Transaction, TreeCell, createDataStore, useDataStore };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Row, ColumnDef, SortingState, ColumnFiltersState, Table, VisibilityState, ColumnPinningState, ColumnSizingState } from '@tanstack/react-table';
|
|
3
|
+
import React$1, { ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
interface Transaction<T> {
|
|
6
|
+
add?: T[];
|
|
7
|
+
update?: Array<{
|
|
8
|
+
id: string;
|
|
9
|
+
data: Partial<T>;
|
|
10
|
+
}>;
|
|
11
|
+
remove?: string[];
|
|
12
|
+
}
|
|
13
|
+
interface DataStore<T> {
|
|
14
|
+
get(id: string): T | undefined;
|
|
15
|
+
/** Returns a stable array reference — same reference until the next transaction */
|
|
16
|
+
getSnapshot(): T[];
|
|
17
|
+
/** Monotonically increasing integer — increments on every transaction */
|
|
18
|
+
getVersion(): number;
|
|
19
|
+
applyTransaction(tx: Transaction<T>): void;
|
|
20
|
+
/** useSyncExternalStore compatible subscribe */
|
|
21
|
+
subscribe(listener: () => void): () => void;
|
|
22
|
+
}
|
|
23
|
+
declare function createDataStore<T>(getRowId: (item: T, index: number) => string): DataStore<T>;
|
|
24
|
+
|
|
25
|
+
type DataGridColumnDef<T extends object> = ColumnDef<T, unknown>;
|
|
26
|
+
type ColumnSizingMode = 'auto' | 'flex' | 'fixed';
|
|
27
|
+
/**
|
|
28
|
+
* Table width handling strategy:
|
|
29
|
+
* - 'spacer': Each column independent px + spacer cell fills remaining space (default)
|
|
30
|
+
* - 'fill-last': Last visible column stretches to fill remaining space
|
|
31
|
+
* - 'independent': Each column independent px, no fill — right gap when columns are narrow
|
|
32
|
+
*/
|
|
33
|
+
type TableWidthMode = 'spacer' | 'fill-last' | 'independent';
|
|
34
|
+
interface CheckboxConfig<T extends object> {
|
|
35
|
+
getRowId: (row: T) => string;
|
|
36
|
+
selectedIds: Set<string>;
|
|
37
|
+
onSelectAll: (rows: Row<T>[], checked: boolean) => void;
|
|
38
|
+
onSelectOne: (rowId: string, checked: boolean) => void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Rendering props owned by DataGridTableView.
|
|
42
|
+
* DataGridBaseProps and DataGridTableViewProps both extend this
|
|
43
|
+
* so these are declared exactly once.
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Slot-based class injection for DataGrid elements.
|
|
47
|
+
* Each key targets a specific part of the table structure.
|
|
48
|
+
* User-supplied classes are merged after library defaults via cn(),
|
|
49
|
+
* so Tailwind classes here will take precedence over library defaults.
|
|
50
|
+
*/
|
|
51
|
+
interface DataGridClassNames {
|
|
52
|
+
/** Outermost wrapper div (border, rounded-md) */
|
|
53
|
+
container?: string;
|
|
54
|
+
/** Header panel div (bg-muted, overflow:hidden) */
|
|
55
|
+
header?: string;
|
|
56
|
+
/** Individual header cell div */
|
|
57
|
+
headerCell?: string;
|
|
58
|
+
/** Body row div */
|
|
59
|
+
row?: string;
|
|
60
|
+
/** Body cell div */
|
|
61
|
+
cell?: string;
|
|
62
|
+
}
|
|
63
|
+
interface TableViewConfig<T extends object> {
|
|
64
|
+
isLoading?: boolean;
|
|
65
|
+
emptyMessage?: string;
|
|
66
|
+
/**
|
|
67
|
+
* No data일 때 body 영역에 표시할 커스텀 UI.
|
|
68
|
+
* 제공 시 emptyMessage보다 우선 적용됨.
|
|
69
|
+
*/
|
|
70
|
+
emptyContent?: ReactNode;
|
|
71
|
+
/** 테이블 헤더 표시 여부. 기본값 true. */
|
|
72
|
+
showHeader?: boolean;
|
|
73
|
+
onRowClick?: (row: T) => void;
|
|
74
|
+
rowCursor?: boolean;
|
|
75
|
+
enableColumnResizing?: boolean;
|
|
76
|
+
/** Show per-column filter row below the header (AG Grid style) */
|
|
77
|
+
enableColumnFilters?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Controls how column filters are displayed when enableColumnFilters=true.
|
|
80
|
+
* - 'row' (default): dedicated filter row below the header
|
|
81
|
+
* - 'icon': filter icon inside each header cell that opens a popover
|
|
82
|
+
*/
|
|
83
|
+
filterDisplay?: 'row' | 'icon';
|
|
84
|
+
tableHeight?: string | number | 'auto';
|
|
85
|
+
/** Show vertical dividers between columns */
|
|
86
|
+
bordered?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Table width handling strategy:
|
|
89
|
+
* - 'spacer': Each column independent px + spacer cell fills remaining space (default)
|
|
90
|
+
* - 'fill-last': Last visible column stretches to fill remaining space
|
|
91
|
+
* - 'independent': Each column independent px, no fill — right gap when columns are narrow
|
|
92
|
+
*/
|
|
93
|
+
tableWidthMode?: TableWidthMode;
|
|
94
|
+
/**
|
|
95
|
+
* Fixed row height in px. Sets both the actual CSS min-height of each row
|
|
96
|
+
* and the virtualizer's estimateSize so they stay in sync. Default: 33.
|
|
97
|
+
* Rows with meta.wrap=true can still grow beyond this height — measureElement
|
|
98
|
+
* will track the actual size for accurate virtual positioning.
|
|
99
|
+
*/
|
|
100
|
+
rowHeight?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Override the virtualizer's estimated row height independently of rowHeight.
|
|
103
|
+
* Only needed for variable-height rows where you want a different estimate.
|
|
104
|
+
*/
|
|
105
|
+
estimateRowHeight?: number;
|
|
106
|
+
/** Rows to render outside the visible area (virtualizer overscan, default: 10) */
|
|
107
|
+
overscan?: number;
|
|
108
|
+
/** Slot-based class injection for individual table elements */
|
|
109
|
+
classNames?: DataGridClassNames;
|
|
110
|
+
}
|
|
111
|
+
interface DataGridBaseProps<T extends object> extends TableViewConfig<T> {
|
|
112
|
+
data?: T[];
|
|
113
|
+
/**
|
|
114
|
+
* Map-based external store for real-time / high-frequency updates.
|
|
115
|
+
* Use with useDataStore() and table.applyTransaction().
|
|
116
|
+
* Mutually exclusive with the `data` prop — set one or the other.
|
|
117
|
+
*/
|
|
118
|
+
dataStore?: DataStore<T>;
|
|
119
|
+
columns: DataGridColumnDef<T>[];
|
|
120
|
+
error?: Error | null;
|
|
121
|
+
enableSorting?: boolean;
|
|
122
|
+
initialSorting?: SortingState;
|
|
123
|
+
onSortingChange?: (sorting: SortingState) => void;
|
|
124
|
+
manualSorting?: boolean;
|
|
125
|
+
columnFilters?: ColumnFiltersState;
|
|
126
|
+
globalFilter?: string;
|
|
127
|
+
onGlobalFilterChange?: (value: string) => void;
|
|
128
|
+
searchableColumns?: string[];
|
|
129
|
+
leftFilters?: (table: Table<T>) => React.ReactNode;
|
|
130
|
+
rightFilters?: (table: Table<T>) => React.ReactNode;
|
|
131
|
+
visibilityState?: VisibilityState;
|
|
132
|
+
/** Initial column pinning — { left: ['id', ...], right: ['id', ...] } */
|
|
133
|
+
initialPinning?: ColumnPinningState;
|
|
134
|
+
columnSizingMode?: ColumnSizingMode;
|
|
135
|
+
/** Enable row expansion (requires subRows in data or getSubRows) */
|
|
136
|
+
enableExpanding?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Extract sub-rows from a row for tree display.
|
|
139
|
+
* If omitted, TanStack Table looks for a 'subRows' key on each data item.
|
|
140
|
+
*/
|
|
141
|
+
getSubRows?: (originalRow: T, index: number) => T[] | undefined;
|
|
142
|
+
checkboxConfig?: CheckboxConfig<T>;
|
|
143
|
+
tableKey?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Sync table state (pagination, search) to the in-memory Zustand store so it
|
|
146
|
+
* survives re-renders within the same session. Requires tableKey to be set.
|
|
147
|
+
* Note: in-memory only — does not persist across page reloads.
|
|
148
|
+
*/
|
|
149
|
+
syncState?: boolean;
|
|
150
|
+
onTableReady?: (table: Table<T>) => void;
|
|
151
|
+
onColumnSizingChange?: (sizing: ColumnSizingState) => void;
|
|
152
|
+
}
|
|
153
|
+
interface DataGridProps<T extends object> extends DataGridBaseProps<T> {
|
|
154
|
+
enablePagination?: boolean;
|
|
155
|
+
paginationConfig?: {
|
|
156
|
+
pageSize?: number;
|
|
157
|
+
initialPageIndex?: number;
|
|
158
|
+
};
|
|
159
|
+
pageSizes?: number[];
|
|
160
|
+
/** Server-side total row count for manual pagination */
|
|
161
|
+
totalCount?: number;
|
|
162
|
+
onPageChange?: (pageIndex: number, pageSize: number) => void;
|
|
163
|
+
}
|
|
164
|
+
interface DataGridDragProps<T extends object> extends DataGridBaseProps<T> {
|
|
165
|
+
/** Required: stable unique id per data item — used to track row identity across reorders */
|
|
166
|
+
getRowId: (originalRow: T, index: number) => string;
|
|
167
|
+
/** Called with the full reordered data array after each drag */
|
|
168
|
+
onRowReorder: (newData: T[]) => void;
|
|
169
|
+
}
|
|
170
|
+
interface DataGridInfinityProps<T extends object> extends DataGridBaseProps<T> {
|
|
171
|
+
hasNextPage?: boolean;
|
|
172
|
+
isFetchingNextPage?: boolean;
|
|
173
|
+
fetchNextPage?: () => void;
|
|
174
|
+
/** IntersectionObserver rootMargin to trigger next page load */
|
|
175
|
+
rootMargin?: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
interface DataGridPropsWithRef<T extends object> extends DataGridProps<T> {
|
|
179
|
+
/** Ref populated with the TanStack Table instance after first render */
|
|
180
|
+
tableRef?: React.RefObject<Table<T> | null>;
|
|
181
|
+
}
|
|
182
|
+
declare function DataGrid<T extends object>(props: DataGridPropsWithRef<T>): react_jsx_runtime.JSX.Element;
|
|
183
|
+
|
|
184
|
+
declare function DataGridInfinity<T extends object>(props: DataGridInfinityProps<T>): react_jsx_runtime.JSX.Element;
|
|
185
|
+
|
|
186
|
+
declare function DataGridDrag<T extends object>(props: DataGridDragProps<T>): react_jsx_runtime.JSX.Element;
|
|
187
|
+
|
|
188
|
+
interface Props$1<T extends object> {
|
|
189
|
+
table: Table<T>;
|
|
190
|
+
}
|
|
191
|
+
declare function ColumnVisibilityDropdown<T extends object>({ table }: Props$1<T>): react_jsx_runtime.JSX.Element;
|
|
192
|
+
|
|
193
|
+
interface Props<T extends object> {
|
|
194
|
+
table: Table<T>;
|
|
195
|
+
placeholder?: string;
|
|
196
|
+
className?: string;
|
|
197
|
+
}
|
|
198
|
+
declare function GlobalSearch<T extends object>({ table, placeholder, className, }: Props<T>): react_jsx_runtime.JSX.Element;
|
|
199
|
+
|
|
200
|
+
interface SelectFilterProps<T extends object> {
|
|
201
|
+
table: Table<T>;
|
|
202
|
+
columnId: string;
|
|
203
|
+
label: string;
|
|
204
|
+
}
|
|
205
|
+
declare function SelectFilter<T extends object>({ table, columnId, label }: SelectFilterProps<T>): react_jsx_runtime.JSX.Element | null;
|
|
206
|
+
interface MultiSelectFilterProps<T extends object> {
|
|
207
|
+
table: Table<T>;
|
|
208
|
+
columnId: string;
|
|
209
|
+
label: string;
|
|
210
|
+
}
|
|
211
|
+
declare function MultiSelectFilter<T extends object>({ table, columnId, label, }: MultiSelectFilterProps<T>): react_jsx_runtime.JSX.Element | null;
|
|
212
|
+
|
|
213
|
+
interface TreeCellProps {
|
|
214
|
+
row: Row<any>;
|
|
215
|
+
/** Indent per depth level in px (default: 16) */
|
|
216
|
+
indentSize?: number;
|
|
217
|
+
children: React$1.ReactNode;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Wraps cell content with a depth-aware indent and expand/collapse toggle.
|
|
221
|
+
* Drop this into whichever column should act as the tree "name" column.
|
|
222
|
+
*
|
|
223
|
+
* Usage:
|
|
224
|
+
* cell: ({ row }) => (
|
|
225
|
+
* <TreeCell row={row} indentSize={20}>
|
|
226
|
+
* <Icon /> <span>{row.original.name}</span>
|
|
227
|
+
* </TreeCell>
|
|
228
|
+
* )
|
|
229
|
+
*/
|
|
230
|
+
declare function TreeCell({ row, indentSize, children }: TreeCellProps): react_jsx_runtime.JSX.Element;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Drag handle cell — place in whichever column should act as the grab handle.
|
|
234
|
+
* Reads listeners/attributes from RowDragContext set by SortableRow.
|
|
235
|
+
* Only works inside DataGridDrag.
|
|
236
|
+
*
|
|
237
|
+
* Usage:
|
|
238
|
+
* { id: 'drag', size: 36, enableResizing: false,
|
|
239
|
+
* cell: () => <DragHandleCell /> }
|
|
240
|
+
*/
|
|
241
|
+
declare function DragHandleCell(): react_jsx_runtime.JSX.Element;
|
|
242
|
+
|
|
243
|
+
interface UseDataStoreOptions<T> {
|
|
244
|
+
getRowId: (item: T, index: number) => string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Creates and memoizes a DataStore instance for use with <DataGrid dataStore={store} />.
|
|
248
|
+
*
|
|
249
|
+
* The store is stable for the lifetime of the component — pass a stable `getRowId`
|
|
250
|
+
* callback (e.g. defined outside render or wrapped in useCallback).
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* const store = useDataStore<Pod>({ getRowId: p => p.name })
|
|
254
|
+
*
|
|
255
|
+
* useEffect(() => {
|
|
256
|
+
* const watcher = watchPods(namespace, {
|
|
257
|
+
* onAdded: pod => store.applyTransaction({ add: [pod] }),
|
|
258
|
+
* onModified: pod => store.applyTransaction({ update: [{ id: pod.name, data: pod }] }),
|
|
259
|
+
* onDeleted: name => store.applyTransaction({ remove: [name] }),
|
|
260
|
+
* })
|
|
261
|
+
* return () => watcher.stop()
|
|
262
|
+
* }, [namespace])
|
|
263
|
+
*/
|
|
264
|
+
declare function useDataStore<T>(options: UseDataStoreOptions<T>): DataStore<T>;
|
|
265
|
+
|
|
266
|
+
export { type CheckboxConfig, type ColumnSizingMode, ColumnVisibilityDropdown, DataGrid, type DataGridBaseProps, type DataGridClassNames, type DataGridColumnDef, DataGridDrag, type DataGridDragProps, DataGridInfinity, type DataGridInfinityProps, type DataGridProps, type DataStore, DragHandleCell, GlobalSearch, MultiSelectFilter, SelectFilter, type TableViewConfig, type TableWidthMode, type Transaction, TreeCell, createDataStore, useDataStore };
|