@snowpact/react-tanstack-query-table 1.0.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.
- package/LICENSE +21 -0
- package/README.md +461 -0
- package/dist/index.cjs +57 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +469 -0
- package/dist/index.js +6425 -0
- package/dist/index.js.map +1 -0
- package/package.json +77 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import { Column } from '@tanstack/react-table';
|
|
2
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
3
|
+
import { ColumnMeta } from '@tanstack/react-table';
|
|
4
|
+
import { ComponentType } from 'react';
|
|
5
|
+
import { JSX } from 'react/jsx-runtime';
|
|
6
|
+
import { MouseEvent as MouseEvent_2 } from 'react';
|
|
7
|
+
import { OnChangeFn } from '@tanstack/react-table';
|
|
8
|
+
import { PaginationState } from '@tanstack/react-table';
|
|
9
|
+
import { ReactNode } from 'react';
|
|
10
|
+
import { SortingState } from '@tanstack/react-table';
|
|
11
|
+
import { SVGProps } from 'react';
|
|
12
|
+
import { Table } from '@tanstack/react-table';
|
|
13
|
+
import { VisibilityState } from '@tanstack/react-table';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Button variants supported by actions
|
|
17
|
+
*/
|
|
18
|
+
export declare type ActionButtonVariant = 'default' | 'warning' | 'danger' | 'info' | 'success';
|
|
19
|
+
|
|
20
|
+
export declare function ActionCell<T, K>({ item, actions, onAction }: ActionCellProps<T, K>): JSX.Element;
|
|
21
|
+
|
|
22
|
+
declare interface ActionCellProps<T, K> {
|
|
23
|
+
item: T;
|
|
24
|
+
actions: TableAction<T, K>[];
|
|
25
|
+
onAction: (action: TableAction<T, K>, item: T) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Confirm content can be static or a function receiving close helper
|
|
30
|
+
*/
|
|
31
|
+
export declare type ActionConfirmContent = ReactNode | ((helpers: ConfirmCloseHelper) => ReactNode);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Action Hover Registry
|
|
35
|
+
*
|
|
36
|
+
* Allows consumers to provide custom tooltip behavior for action buttons.
|
|
37
|
+
* The consumer handles all tooltip UI - SnowTable just notifies on hover/unhover.
|
|
38
|
+
*/
|
|
39
|
+
export declare interface ActionHoverInfo {
|
|
40
|
+
label: string;
|
|
41
|
+
element: HTMLElement;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare type BaseAction = {
|
|
45
|
+
icon: IconComponent;
|
|
46
|
+
label: string;
|
|
47
|
+
variant?: ActionButtonVariant;
|
|
48
|
+
display?: 'button' | 'dropdown';
|
|
49
|
+
hidden?: boolean;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
showLabel?: boolean;
|
|
52
|
+
confirm?: {
|
|
53
|
+
title: string;
|
|
54
|
+
content: ActionConfirmContent;
|
|
55
|
+
subtitle?: string;
|
|
56
|
+
confirmText?: string;
|
|
57
|
+
cancelText?: string;
|
|
58
|
+
hideButtons?: boolean;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Base props shared between SnowClientTable and SnowServerTable
|
|
64
|
+
*/
|
|
65
|
+
export declare interface BaseSnowTableProps<T extends Record<string, unknown>, K> extends DataTableUIOptions<T> {
|
|
66
|
+
queryKey: string[];
|
|
67
|
+
columnConfig: SnowColumnConfig<T>[];
|
|
68
|
+
actions?: TableAction<T, K>[];
|
|
69
|
+
filters?: FilterConfig<T>[];
|
|
70
|
+
prefilters?: PreFilter[];
|
|
71
|
+
defaultSortBy?: string;
|
|
72
|
+
defaultSortOrder?: 'asc' | 'desc';
|
|
73
|
+
defaultPageSize?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Persist table state (prefilter, pagination, search, filters, sorting) in URL query params.
|
|
76
|
+
*/
|
|
77
|
+
persistState?: boolean;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Styles Registry
|
|
82
|
+
*
|
|
83
|
+
* ONLY visual styles are customizable (colors, borders, shadows, rounded).
|
|
84
|
+
* Structural styles (layout, sizing, positioning) are fixed in the components.
|
|
85
|
+
*/
|
|
86
|
+
declare interface ButtonStyles {
|
|
87
|
+
visual: string;
|
|
88
|
+
hover: string;
|
|
89
|
+
disabled: string;
|
|
90
|
+
danger: string;
|
|
91
|
+
warning: string;
|
|
92
|
+
info: string;
|
|
93
|
+
success: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export declare type ClickAction<T> = BaseAction & {
|
|
97
|
+
type: 'click';
|
|
98
|
+
onClick: (item: T) => void;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export declare function ColumnConfiguration<T extends object>({ table }: ColumnConfigurationProps<T>): JSX.Element;
|
|
102
|
+
|
|
103
|
+
export declare type ColumnConfigurationProps<T extends object> = {
|
|
104
|
+
table: Table<T>;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export declare interface ConfirmCloseHelper {
|
|
108
|
+
close: () => void;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export declare type ConfirmContent = ReactNode | ((helpers: ConfirmCloseHelper) => ReactNode);
|
|
112
|
+
|
|
113
|
+
declare interface ConfirmOptions {
|
|
114
|
+
title: string;
|
|
115
|
+
subtitle?: string;
|
|
116
|
+
content: ConfirmContent;
|
|
117
|
+
confirmText?: string;
|
|
118
|
+
cancelText?: string;
|
|
119
|
+
hideButtons?: boolean;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export declare function DataTable<Data extends object>({ data, columns, isLoading, isFetching, mode, pagination: externalPagination, onPaginationChange: externalOnPaginationChange, totalCount: externalTotalCount, globalFilter: externalGlobalFilter, onGlobalFilterChange: externalOnGlobalFilterChange, enableGlobalSearch, filters, columnFilters: externalColumnFilters, onColumnFiltersChange: externalOnColumnFiltersChange, prefilters, activePrefilter, onPrefilterChange, sorting: externalSorting, onSortingChange: externalOnSortingChange, enableSorting, columnVisibility: externalColumnVisibility, onColumnVisibilityChange: externalOnColumnVisibilityChange, enableColumnConfiguration, onRowClick, activeRowId, displayTotalNumber, enableElementLabel, enablePagination, enableResponsive, texts, onResetFilters, enableResetFilters, }: DataTableProps<Data>): JSX.Element;
|
|
123
|
+
|
|
124
|
+
export declare type DataTableProps<T extends object> = {
|
|
125
|
+
data: T[];
|
|
126
|
+
columns: ColumnDef<T, any>[];
|
|
127
|
+
isLoading?: boolean;
|
|
128
|
+
isFetching?: boolean;
|
|
129
|
+
mode?: 'client' | 'server';
|
|
130
|
+
pagination?: PaginationState;
|
|
131
|
+
onPaginationChange?: OnChangeFn<PaginationState>;
|
|
132
|
+
totalCount?: number;
|
|
133
|
+
globalFilter?: string;
|
|
134
|
+
onGlobalFilterChange?: (value: string) => void;
|
|
135
|
+
enableGlobalSearch?: boolean;
|
|
136
|
+
filters?: FilterConfig<T>[];
|
|
137
|
+
columnFilters?: Record<string, string[]>;
|
|
138
|
+
onColumnFiltersChange?: (filters: Record<string, string[]>) => void;
|
|
139
|
+
prefilters?: PreFilter[];
|
|
140
|
+
activePrefilter?: string;
|
|
141
|
+
onPrefilterChange?: (key: string) => void;
|
|
142
|
+
sorting?: SortingState;
|
|
143
|
+
onSortingChange?: OnChangeFn<SortingState>;
|
|
144
|
+
enableSorting?: boolean;
|
|
145
|
+
columnVisibility?: VisibilityState;
|
|
146
|
+
onColumnVisibilityChange?: OnChangeFn<VisibilityState>;
|
|
147
|
+
enableColumnConfiguration?: boolean;
|
|
148
|
+
onRowClick?: (data: T) => void;
|
|
149
|
+
activeRowId?: string | number;
|
|
150
|
+
displayTotalNumber?: boolean;
|
|
151
|
+
enableElementLabel?: boolean;
|
|
152
|
+
enablePagination?: boolean;
|
|
153
|
+
enableResponsive?: boolean;
|
|
154
|
+
texts?: {
|
|
155
|
+
searchPlaceholder?: string;
|
|
156
|
+
emptyTitle?: string;
|
|
157
|
+
};
|
|
158
|
+
onResetFilters?: () => void;
|
|
159
|
+
enableResetFilters?: boolean;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
declare interface DataTableStyles {
|
|
163
|
+
container: string;
|
|
164
|
+
header: string;
|
|
165
|
+
headerCell: string;
|
|
166
|
+
row: string;
|
|
167
|
+
rowHover: string;
|
|
168
|
+
rowAlternate: string;
|
|
169
|
+
rowActive: string;
|
|
170
|
+
divider: string;
|
|
171
|
+
empty: string;
|
|
172
|
+
loadingOverlay: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* UI options that can be passed through to the underlying DataTable
|
|
177
|
+
*/
|
|
178
|
+
export declare interface DataTableUIOptions<T extends object> {
|
|
179
|
+
onRowClick?: (data: T) => void;
|
|
180
|
+
activeRowId?: string | number;
|
|
181
|
+
displayTotalNumber?: boolean;
|
|
182
|
+
enableElementLabel?: boolean;
|
|
183
|
+
enableGlobalSearch?: boolean;
|
|
184
|
+
enableSorting?: boolean;
|
|
185
|
+
enableColumnConfiguration?: boolean;
|
|
186
|
+
enablePagination?: boolean;
|
|
187
|
+
enableResetFilters?: boolean;
|
|
188
|
+
texts?: {
|
|
189
|
+
searchPlaceholder?: string;
|
|
190
|
+
emptyTitle?: string;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
declare type DeepPartial<T> = {
|
|
195
|
+
[P in keyof T]?: T[P] extends object ? Partial<T[P]> : T[P];
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export declare const DEFAULT_PAGE_SIZES: number[];
|
|
199
|
+
|
|
200
|
+
declare interface DropdownStyles {
|
|
201
|
+
content: string;
|
|
202
|
+
item: string;
|
|
203
|
+
checkboxItem: string;
|
|
204
|
+
separator: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export declare type EndpointAction<T, K> = BaseAction & {
|
|
208
|
+
type: 'endpoint';
|
|
209
|
+
endpoint: (item: T) => Promise<K>;
|
|
210
|
+
onSuccess?: (data: K, variables: T, context: unknown) => void;
|
|
211
|
+
onError?: (error: ErrorResponse, variables: T, context: unknown) => void;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export declare type ErrorResponse = {
|
|
215
|
+
message: string;
|
|
216
|
+
status: number;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export declare type FilterConfig<T extends object> = {
|
|
220
|
+
key: keyof T;
|
|
221
|
+
label: string;
|
|
222
|
+
options: FilterOption[];
|
|
223
|
+
multipleSelection?: boolean;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Single filter dropdown with multi-select support
|
|
228
|
+
*/
|
|
229
|
+
export declare type FilterOption = {
|
|
230
|
+
label: string;
|
|
231
|
+
value: string;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Icon component type - compatible with IconComponent
|
|
236
|
+
* Users can use lucide-react icons or any SVG component with this signature
|
|
237
|
+
*/
|
|
238
|
+
export declare type IconComponent = ComponentType<SVGProps<SVGSVGElement>>;
|
|
239
|
+
|
|
240
|
+
export declare const isSnowTableSetup: () => boolean;
|
|
241
|
+
|
|
242
|
+
export declare type LinkAction<T> = BaseAction & {
|
|
243
|
+
type: 'link';
|
|
244
|
+
href: (item: T) => string;
|
|
245
|
+
external?: boolean;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
declare interface LinkProps {
|
|
249
|
+
to: string;
|
|
250
|
+
children: ReactNode;
|
|
251
|
+
className?: string;
|
|
252
|
+
target?: string;
|
|
253
|
+
rel?: string;
|
|
254
|
+
'aria-disabled'?: boolean;
|
|
255
|
+
onMouseEnter?: (e: MouseEvent_2<HTMLAnchorElement>) => void;
|
|
256
|
+
onMouseLeave?: () => void;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export declare function PageSizeSelector<Data extends object>({ table, paginationSizes, enableElementLabel, }: PageSizeSelectorProps<Data>): JSX.Element;
|
|
260
|
+
|
|
261
|
+
export declare type PageSizeSelectorProps<Data extends object> = {
|
|
262
|
+
table: Table<Data>;
|
|
263
|
+
paginationSizes?: number[];
|
|
264
|
+
enableElementLabel?: boolean;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export declare function Pagination<Data extends object>({ table, isLoading }: PaginationProps<Data>): JSX.Element;
|
|
268
|
+
|
|
269
|
+
export declare type PaginationProps<Data extends object> = {
|
|
270
|
+
table: Table<Data>;
|
|
271
|
+
isLoading?: boolean;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Prefilter tabs component (tabs or select based on viewport/count)
|
|
276
|
+
*/
|
|
277
|
+
export declare type PreFilter = {
|
|
278
|
+
id: string;
|
|
279
|
+
label: string;
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
export declare function PrefilterTabs({ prefilters, activePrefilter, onPrefilterChange }: PrefilterTabsProps): JSX.Element;
|
|
283
|
+
|
|
284
|
+
export declare interface PrefilterTabsProps {
|
|
285
|
+
prefilters: PreFilter[];
|
|
286
|
+
activePrefilter: string;
|
|
287
|
+
onPrefilterChange: (id: string) => void;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export declare function SearchBar({ value, onDebouncedChange, placeholder }: SearchBarProps): JSX.Element;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Search bar component with debounce
|
|
294
|
+
*/
|
|
295
|
+
export declare interface SearchBarProps {
|
|
296
|
+
/** Current value (controlled from parent) */
|
|
297
|
+
value?: string;
|
|
298
|
+
/** Callback with debounced value */
|
|
299
|
+
onDebouncedChange?: (value: string) => void;
|
|
300
|
+
/** Placeholder text */
|
|
301
|
+
placeholder?: string;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
declare interface SelectStyles {
|
|
305
|
+
trigger: string;
|
|
306
|
+
content: string;
|
|
307
|
+
item: string;
|
|
308
|
+
itemSelected: string;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Parameters sent to the server for pagination, search, and filtering
|
|
313
|
+
*/
|
|
314
|
+
export declare interface ServerFetchParams {
|
|
315
|
+
limit: number;
|
|
316
|
+
offset: number;
|
|
317
|
+
search?: string;
|
|
318
|
+
prefilter?: string;
|
|
319
|
+
filters?: Record<string, string[]>;
|
|
320
|
+
sortBy?: string;
|
|
321
|
+
sortOrder?: 'ASC' | 'DESC';
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Response structure for server-side paginated endpoints
|
|
326
|
+
*/
|
|
327
|
+
export declare interface ServerPaginatedResponse<T> {
|
|
328
|
+
items: T[];
|
|
329
|
+
totalItemCount: number;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export declare const setupSnowTable: (options: SetupSnowTableOptions) => void;
|
|
333
|
+
|
|
334
|
+
export declare interface SetupSnowTableOptions {
|
|
335
|
+
useTranslation: () => {
|
|
336
|
+
t: (key: string, options?: Record<string, unknown>) => string;
|
|
337
|
+
};
|
|
338
|
+
LinkComponent: ComponentType<LinkProps>;
|
|
339
|
+
useConfirm: () => UseConfirmReturn;
|
|
340
|
+
styles?: DeepPartial<SnowTableStyles>;
|
|
341
|
+
onActionHover?: (info: ActionHoverInfo) => void;
|
|
342
|
+
onActionUnhover?: () => void;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export declare function SingleFilterDropdown<T extends object>({ filter, selectedValues, onFilterChange, }: SingleFilterDropdownProps<T>): JSX.Element | null;
|
|
346
|
+
|
|
347
|
+
export declare interface SingleFilterDropdownProps<T extends object> {
|
|
348
|
+
filter: FilterConfig<T>;
|
|
349
|
+
selectedValues?: string[];
|
|
350
|
+
onFilterChange: (key: keyof T, selectedValues: string[]) => void;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export declare const SnowClientTable: <T extends Record<string, unknown>, K>({ queryKey, columnConfig, actions, filters, prefilters, prefilterFn, defaultSortBy, defaultSortOrder, defaultPageSize, persistState, fetchAllItemsEndpoint, ...restProps }: SnowClientTableProps<T, K>) => JSX.Element;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Props for SnowClientTable component (client-side filtering/sorting)
|
|
357
|
+
*/
|
|
358
|
+
export declare interface SnowClientTableProps<T extends Record<string, unknown>, K> extends BaseSnowTableProps<T, K> {
|
|
359
|
+
fetchAllItemsEndpoint: () => Promise<T[]>;
|
|
360
|
+
/** Optional function to filter items based on active prefilter */
|
|
361
|
+
prefilterFn?: (item: T, prefilterId: string) => boolean;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export declare type SnowColumnConfig<T extends object> = {
|
|
365
|
+
key: keyof T | '_extra' | '_extra_' | `_extra_${string}`;
|
|
366
|
+
label?: string;
|
|
367
|
+
hidden?: boolean;
|
|
368
|
+
sortable?: boolean;
|
|
369
|
+
render?: (item: T) => ReactNode;
|
|
370
|
+
searchableValue?: (item: T) => string;
|
|
371
|
+
meta?: ColumnMeta<T, unknown>;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
export declare const SnowServerTable: <T extends Record<string, unknown>, K>({ queryKey, columnConfig, actions, filters, prefilters, defaultSortBy, defaultSortOrder, defaultPageSize, persistState, fetchServerEndpoint, ...restProps }: SnowServerTableProps<T, K>) => JSX.Element;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Props for SnowServerTable component (server-side pagination/filtering/sorting)
|
|
378
|
+
*/
|
|
379
|
+
export declare interface SnowServerTableProps<T extends Record<string, unknown>, K> extends BaseSnowTableProps<T, K> {
|
|
380
|
+
fetchServerEndpoint: (params: ServerFetchParams) => Promise<ServerPaginatedResponse<T>>;
|
|
381
|
+
filters?: FilterConfig<Record<string, unknown>>[];
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
declare interface SnowTableStyles {
|
|
385
|
+
state: StateStyles;
|
|
386
|
+
button: ButtonStyles;
|
|
387
|
+
input: string;
|
|
388
|
+
skeleton: string;
|
|
389
|
+
dropdown: DropdownStyles;
|
|
390
|
+
select: SelectStyles;
|
|
391
|
+
tabs: TabsStyles;
|
|
392
|
+
table: DataTableStyles;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export declare function SortButton({ column }: SortButtonProps): JSX.Element | null;
|
|
396
|
+
|
|
397
|
+
export declare interface SortButtonProps {
|
|
398
|
+
column: Column<any, any>;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
declare interface StateStyles {
|
|
402
|
+
active: string;
|
|
403
|
+
activeText: string;
|
|
404
|
+
focus: string;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export declare type TableAction<T, K> = EndpointAction<T, K> | ClickAction<T> | LinkAction<T> | ((item: T) => EndpointAction<T, K>) | ((item: T) => ClickAction<T>) | ((item: T) => LinkAction<T>);
|
|
408
|
+
|
|
409
|
+
declare interface TabsStyles {
|
|
410
|
+
list: string;
|
|
411
|
+
trigger: string;
|
|
412
|
+
triggerActive: string;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
declare interface UseConfirmReturn {
|
|
416
|
+
confirm: (options: ConfirmOptions) => Promise<boolean>;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Shared hook for building columns and handling actions in SnowClientTable and SnowServerTable.
|
|
421
|
+
*
|
|
422
|
+
* Extracts the common logic for:
|
|
423
|
+
* - Transforming SnowColumnConfig into TanStack Table ColumnDef
|
|
424
|
+
* - Adding action column with ActionCell
|
|
425
|
+
* - Handling action execution with confirmation dialogs and mutations
|
|
426
|
+
*/
|
|
427
|
+
export declare const useSnowColumns: <T extends Record<string, unknown>, K>({ columnConfig, actions, filters, mode, }: UseSnowColumnsOptions<T, K>) => UseSnowColumnsReturn<T, K>;
|
|
428
|
+
|
|
429
|
+
export declare interface UseSnowColumnsOptions<T extends Record<string, unknown>, K> {
|
|
430
|
+
columnConfig: SnowColumnConfig<T>[];
|
|
431
|
+
actions?: TableAction<T, K>[];
|
|
432
|
+
filters?: FilterConfig<T>[];
|
|
433
|
+
/**
|
|
434
|
+
* Mode determines how global filter behaves:
|
|
435
|
+
* - 'client': enableGlobalFilter based on searchableValue
|
|
436
|
+
* - 'server': enableGlobalFilter always false (server handles search)
|
|
437
|
+
*/
|
|
438
|
+
mode: 'client' | 'server';
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export declare interface UseSnowColumnsReturn<T extends Record<string, unknown>, K> {
|
|
442
|
+
columns: ColumnDef<T, unknown>[];
|
|
443
|
+
handleAction: (action: TableAction<T, K>, item: T) => Promise<void>;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export declare const useTableStatePersist: ({ enabled, defaultPrefilter, defaultPageSize, defaultSortBy, defaultSortOrder, }: UseTableStatePersistOptions) => {
|
|
447
|
+
activePrefilter: string | undefined;
|
|
448
|
+
setActivePrefilter: (value: string | undefined) => void;
|
|
449
|
+
globalFilter: string;
|
|
450
|
+
setGlobalFilter: (value: string) => void;
|
|
451
|
+
pagination: PaginationState;
|
|
452
|
+
setPagination: (value: PaginationState | ((prev: PaginationState) => PaginationState)) => void;
|
|
453
|
+
columnFilters: Record<string, string[]>;
|
|
454
|
+
setColumnFilters: (value: Record<string, string[]>) => void;
|
|
455
|
+
sorting: SortingState;
|
|
456
|
+
setSorting: (value: SortingState | ((prev: SortingState) => SortingState)) => void;
|
|
457
|
+
resetToDefaults: () => void;
|
|
458
|
+
hasActiveFilters: boolean;
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
declare interface UseTableStatePersistOptions {
|
|
462
|
+
enabled: boolean;
|
|
463
|
+
defaultPrefilter?: string;
|
|
464
|
+
defaultPageSize: number;
|
|
465
|
+
defaultSortBy?: string;
|
|
466
|
+
defaultSortOrder?: 'asc' | 'desc';
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export { }
|