@forgedevstack/grid-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.
@@ -0,0 +1,999 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, CSSProperties, RefObject, MouseEvent } from 'react';
3
+
4
+ type ThemeMode = 'light' | 'dark';
5
+ type Breakpoint = 'mobile' | 'tablet' | 'desktop';
6
+ type ResponsiveValue<T> = T | Partial<Record<Breakpoint, T>>;
7
+ type SortDirection = 'asc' | 'desc' | null;
8
+ type FilterOperator = 'equals' | 'notEquals' | 'contains' | 'notContains' | 'startsWith' | 'endsWith' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'between' | 'isEmpty' | 'isNotEmpty';
9
+ type Alignment = 'left' | 'center' | 'right';
10
+ interface Dimensions {
11
+ width?: ResponsiveValue<number | string>;
12
+ height?: ResponsiveValue<number | string>;
13
+ minWidth?: ResponsiveValue<number | string>;
14
+ maxWidth?: ResponsiveValue<number | string>;
15
+ minHeight?: ResponsiveValue<number | string>;
16
+ maxHeight?: ResponsiveValue<number | string>;
17
+ }
18
+ interface ThemeColors {
19
+ background: {
20
+ primary: string;
21
+ secondary: string;
22
+ tertiary: string;
23
+ hover: string;
24
+ };
25
+ text: {
26
+ primary: string;
27
+ secondary: string;
28
+ muted: string;
29
+ };
30
+ border: {
31
+ default: string;
32
+ hover: string;
33
+ };
34
+ accent: {
35
+ primary: string;
36
+ success: string;
37
+ warning: string;
38
+ error: string;
39
+ };
40
+ }
41
+ interface Theme {
42
+ mode: ThemeMode;
43
+ colors: ThemeColors;
44
+ }
45
+ interface Translations {
46
+ empty: string;
47
+ loading: string;
48
+ search: string;
49
+ filter: string;
50
+ sort: string;
51
+ sortAsc: string;
52
+ sortDesc: string;
53
+ clearSort: string;
54
+ clearFilter: string;
55
+ clearAll: string;
56
+ apply: string;
57
+ cancel: string;
58
+ columns: string;
59
+ showColumns: string;
60
+ hideColumn: string;
61
+ resetColumns: string;
62
+ rowsPerPage: string;
63
+ of: string;
64
+ page: string;
65
+ first: string;
66
+ previous: string;
67
+ next: string;
68
+ last: string;
69
+ selected: string;
70
+ dragToReorder: string;
71
+ noResults: string;
72
+ errorLoading: string;
73
+ retry: string;
74
+ }
75
+ interface ClassNames {
76
+ root?: string;
77
+ header?: string;
78
+ headerCell?: string;
79
+ body?: string;
80
+ row?: string;
81
+ cell?: string;
82
+ footer?: string;
83
+ pagination?: string;
84
+ filter?: string;
85
+ empty?: string;
86
+ skeleton?: string;
87
+ drawer?: string;
88
+ }
89
+ interface Styles {
90
+ root?: CSSProperties;
91
+ header?: CSSProperties;
92
+ headerCell?: CSSProperties;
93
+ body?: CSSProperties;
94
+ row?: CSSProperties;
95
+ cell?: CSSProperties;
96
+ footer?: CSSProperties;
97
+ pagination?: CSSProperties;
98
+ filter?: CSSProperties;
99
+ empty?: CSSProperties;
100
+ skeleton?: CSSProperties;
101
+ drawer?: CSSProperties;
102
+ }
103
+ type RenderFunction<T = unknown> = (value: T, row: Record<string, unknown>, rowIndex: number) => ReactNode;
104
+
105
+ interface ColumnDefinition<T = unknown> {
106
+ id: string;
107
+ accessor: string | ((row: T) => unknown);
108
+ header: ReactNode | (() => ReactNode);
109
+ width?: ResponsiveValue<number | string>;
110
+ minWidth?: number;
111
+ maxWidth?: number;
112
+ align?: Alignment;
113
+ sortable?: boolean;
114
+ filterable?: boolean;
115
+ resizable?: boolean;
116
+ draggable?: boolean;
117
+ hidden?: boolean;
118
+ hiddenOnMobile?: boolean;
119
+ showLabelOnMobile?: boolean;
120
+ sticky?: 'left' | 'right';
121
+ className?: string;
122
+ headerClassName?: string;
123
+ cellClassName?: string;
124
+ style?: CSSProperties;
125
+ headerStyle?: CSSProperties;
126
+ cellStyle?: CSSProperties;
127
+ render?: RenderFunction<unknown>;
128
+ filterType?: 'text' | 'number' | 'date' | 'select' | 'boolean' | 'custom';
129
+ filterOptions?: FilterOption[];
130
+ filterOperators?: FilterOperator[];
131
+ defaultFilterOperator?: FilterOperator;
132
+ sortFn?: (a: unknown, b: unknown, direction: SortDirection) => number;
133
+ filterFn?: (value: unknown, filterValue: unknown, operator: FilterOperator) => boolean;
134
+ meta?: Record<string, unknown>;
135
+ }
136
+ interface FilterOption {
137
+ value: string | number | boolean;
138
+ label: string;
139
+ }
140
+ interface ColumnState {
141
+ id: string;
142
+ visible: boolean;
143
+ width: number;
144
+ order: number;
145
+ pinned: 'left' | 'right' | null;
146
+ }
147
+ interface ColumnReorderEvent {
148
+ sourceId: string;
149
+ targetId: string;
150
+ sourceIndex: number;
151
+ targetIndex: number;
152
+ }
153
+ interface ColumnResizeEvent {
154
+ columnId: string;
155
+ width: number;
156
+ previousWidth: number;
157
+ }
158
+ interface ColumnVisibilityEvent {
159
+ columnId: string;
160
+ visible: boolean;
161
+ }
162
+
163
+ interface RowData {
164
+ id: string | number;
165
+ [key: string]: unknown;
166
+ }
167
+ interface RowState {
168
+ id: string | number;
169
+ selected: boolean;
170
+ expanded: boolean;
171
+ disabled: boolean;
172
+ }
173
+ interface RowProps<T extends RowData = RowData> {
174
+ data: T;
175
+ index: number;
176
+ isSelected?: boolean;
177
+ isExpanded?: boolean;
178
+ isDisabled?: boolean;
179
+ isHovered?: boolean;
180
+ className?: string;
181
+ style?: CSSProperties;
182
+ onClick?: (row: T, index: number) => void;
183
+ onDoubleClick?: (row: T, index: number) => void;
184
+ onContextMenu?: (row: T, index: number, event: React.MouseEvent) => void;
185
+ onSelect?: (row: T, selected: boolean) => void;
186
+ onExpand?: (row: T, expanded: boolean) => void;
187
+ }
188
+ interface RowSelectionState {
189
+ selectedIds: Set<string | number>;
190
+ allSelected: boolean;
191
+ someSelected: boolean;
192
+ }
193
+ interface RowSelectionActions {
194
+ selectRow: (id: string | number) => void;
195
+ deselectRow: (id: string | number) => void;
196
+ toggleRow: (id: string | number) => void;
197
+ selectAll: () => void;
198
+ deselectAll: () => void;
199
+ toggleAll: () => void;
200
+ isSelected: (id: string | number) => boolean;
201
+ }
202
+ interface RowExpansionState {
203
+ expandedIds: Set<string | number>;
204
+ }
205
+ interface RowExpansionActions {
206
+ expandRow: (id: string | number) => void;
207
+ collapseRow: (id: string | number) => void;
208
+ toggleRow: (id: string | number) => void;
209
+ expandAll: () => void;
210
+ collapseAll: () => void;
211
+ isExpanded: (id: string | number) => boolean;
212
+ }
213
+
214
+ interface FilterValue {
215
+ columnId: string;
216
+ value: unknown;
217
+ operator: FilterOperator;
218
+ }
219
+ interface FilterState {
220
+ filters: FilterValue[];
221
+ globalFilter: string;
222
+ }
223
+ interface FilterActions {
224
+ setFilter: (columnId: string, value: unknown, operator?: FilterOperator) => void;
225
+ removeFilter: (columnId: string) => void;
226
+ clearFilters: () => void;
227
+ setGlobalFilter: (value: string) => void;
228
+ clearGlobalFilter: () => void;
229
+ getFilterValue: (columnId: string) => FilterValue | undefined;
230
+ hasFilter: (columnId: string) => boolean;
231
+ hasAnyFilter: () => boolean;
232
+ }
233
+ interface FilterConfig {
234
+ debounceMs?: number;
235
+ caseSensitive?: boolean;
236
+ globalFilterColumns?: string[];
237
+ persistFilters?: boolean;
238
+ filterStorageKey?: string;
239
+ }
240
+ interface FilterPanelProps {
241
+ columnId: string;
242
+ filterType: 'text' | 'number' | 'date' | 'select' | 'boolean' | 'custom';
243
+ filterValue?: FilterValue;
244
+ filterOptions?: Array<{
245
+ value: string | number | boolean;
246
+ label: string;
247
+ }>;
248
+ operators?: FilterOperator[];
249
+ onApply: (value: unknown, operator: FilterOperator) => void;
250
+ onClear: () => void;
251
+ onClose: () => void;
252
+ }
253
+
254
+ interface SortValue {
255
+ columnId: string;
256
+ direction: SortDirection;
257
+ }
258
+ interface SortState {
259
+ sorting: SortValue[];
260
+ multiSort: boolean;
261
+ }
262
+ interface SortActions {
263
+ setSorting: (columnId: string, direction: SortDirection) => void;
264
+ toggleSorting: (columnId: string) => void;
265
+ clearSorting: () => void;
266
+ clearColumnSorting: (columnId: string) => void;
267
+ getSortDirection: (columnId: string) => SortDirection;
268
+ getSortIndex: (columnId: string) => number;
269
+ isSorted: (columnId: string) => boolean;
270
+ }
271
+ interface SortConfig {
272
+ multiSort?: boolean;
273
+ maxMultiSortColumns?: number;
274
+ sortDescFirst?: boolean;
275
+ nullsFirst?: boolean;
276
+ persistSort?: boolean;
277
+ sortStorageKey?: string;
278
+ }
279
+
280
+ interface PaginationState {
281
+ page: number;
282
+ pageSize: number;
283
+ totalItems: number;
284
+ totalPages: number;
285
+ }
286
+ interface PaginationActions {
287
+ setPage: (page: number) => void;
288
+ setPageSize: (pageSize: number) => void;
289
+ goToFirstPage: () => void;
290
+ goToLastPage: () => void;
291
+ goToNextPage: () => void;
292
+ goToPreviousPage: () => void;
293
+ canGoToNextPage: () => boolean;
294
+ canGoToPreviousPage: () => boolean;
295
+ getPageRange: () => {
296
+ start: number;
297
+ end: number;
298
+ };
299
+ }
300
+ interface PaginationConfig {
301
+ initialPage?: number;
302
+ initialPageSize?: number;
303
+ pageSizeOptions?: readonly number[];
304
+ showFirstLast?: boolean;
305
+ showPageNumbers?: boolean;
306
+ maxPageButtons?: number;
307
+ persistPagination?: boolean;
308
+ paginationStorageKey?: string;
309
+ }
310
+ interface PaginationInfo {
311
+ page: number;
312
+ pageSize: number;
313
+ totalItems: number;
314
+ totalPages: number;
315
+ startIndex: number;
316
+ endIndex: number;
317
+ isFirstPage: boolean;
318
+ isLastPage: boolean;
319
+ }
320
+
321
+ interface GridTableProps<T extends RowData = RowData> {
322
+ data: T[];
323
+ columns: ColumnDefinition<T>[];
324
+ loading?: boolean;
325
+ error?: Error | string | null;
326
+ emptyContent?: ReactNode;
327
+ loadingContent?: ReactNode;
328
+ errorContent?: ReactNode | ((error: Error | string) => ReactNode);
329
+ theme?: Partial<Theme>;
330
+ translations?: Partial<Translations>;
331
+ dimensions?: Dimensions;
332
+ classNames?: ClassNames;
333
+ styles?: Styles;
334
+ mobileBreakpoint?: Breakpoint;
335
+ showMobileLabels?: boolean;
336
+ enableDragDrop?: boolean;
337
+ enableColumnResize?: boolean;
338
+ enableRowSelection?: boolean;
339
+ enableMultiSelect?: boolean;
340
+ enableRowExpansion?: boolean;
341
+ stickyHeader?: boolean;
342
+ showPagination?: boolean;
343
+ showFilter?: boolean;
344
+ showGlobalFilter?: boolean;
345
+ showColumnToggle?: boolean;
346
+ showSortIndicator?: boolean;
347
+ virtualize?: boolean;
348
+ virtualizeThreshold?: number;
349
+ rowHeight?: number;
350
+ headerHeight?: number;
351
+ paginationConfig?: PaginationConfig;
352
+ filterConfig?: FilterConfig;
353
+ sortConfig?: SortConfig;
354
+ initialState?: Partial<TableState<T>>;
355
+ onStateChange?: (state: TableState<T>) => void;
356
+ onRowClick?: (row: T, index: number) => void;
357
+ onRowDoubleClick?: (row: T, index: number) => void;
358
+ onCellClick?: (event: {
359
+ row: T;
360
+ rowIndex: number;
361
+ columnId: string;
362
+ value: unknown;
363
+ }) => void;
364
+ onRowSelect?: (selectedRows: T[]) => void;
365
+ onRowExpand?: (expandedRows: T[]) => void;
366
+ onSort?: (sorting: SortState['sorting']) => void;
367
+ onFilter?: (filters: FilterState) => void;
368
+ onPageChange?: (page: number, pageSize: number) => void;
369
+ onColumnReorder?: (columns: ColumnState[]) => void;
370
+ onColumnResize?: (columnId: string, width: number) => void;
371
+ onColumnVisibilityChange?: (columnId: string, visible: boolean) => void;
372
+ onError?: (error: Error) => void;
373
+ onRetry?: () => void;
374
+ getRowId?: (row: T) => string | number;
375
+ getRowClassName?: (row: T, index: number) => string;
376
+ getRowStyle?: (row: T, index: number) => React.CSSProperties;
377
+ isRowDisabled?: (row: T) => boolean;
378
+ isRowSelectable?: (row: T) => boolean;
379
+ renderRowExpansion?: (row: T) => ReactNode;
380
+ renderHeader?: () => ReactNode;
381
+ renderFooter?: () => ReactNode;
382
+ renderEmpty?: () => ReactNode;
383
+ renderLoading?: () => ReactNode;
384
+ renderError?: (error: Error | string) => ReactNode;
385
+ children?: ReactNode;
386
+ }
387
+ interface TableState<T extends RowData = RowData> {
388
+ data: T[];
389
+ columns: ColumnState[];
390
+ sorting: SortState;
391
+ filtering: FilterState;
392
+ pagination: PaginationState;
393
+ selection: RowSelectionState;
394
+ expansion: RowExpansionState;
395
+ loading: boolean;
396
+ error: Error | string | null;
397
+ }
398
+ interface TableInstance<T extends RowData = RowData> {
399
+ state: TableState<T>;
400
+ data: T[];
401
+ filteredData: T[];
402
+ sortedData: T[];
403
+ paginatedData: T[];
404
+ columns: ColumnDefinition<T>[];
405
+ visibleColumns: ColumnDefinition<T>[];
406
+ setData: (data: T[]) => void;
407
+ refresh: () => void;
408
+ reset: () => void;
409
+ }
410
+ interface GridTableRef<T extends RowData = RowData> {
411
+ getInstance: () => TableInstance<T>;
412
+ scrollToRow: (index: number) => void;
413
+ scrollToTop: () => void;
414
+ scrollToBottom: () => void;
415
+ focusRow: (index: number) => void;
416
+ selectRow: (id: string | number) => void;
417
+ deselectRow: (id: string | number) => void;
418
+ expandRow: (id: string | number) => void;
419
+ collapseRow: (id: string | number) => void;
420
+ setFilter: (columnId: string, value: unknown) => void;
421
+ clearFilters: () => void;
422
+ setSorting: (columnId: string, direction: 'asc' | 'desc' | null) => void;
423
+ clearSorting: () => void;
424
+ goToPage: (page: number) => void;
425
+ exportData: (format: 'json' | 'csv') => void;
426
+ }
427
+
428
+ interface GridTableComponentProps<T extends RowData = RowData> {
429
+ data: T[];
430
+ columns: ColumnDefinition<T>[];
431
+ loading?: boolean;
432
+ error?: Error | string | null;
433
+ emptyContent?: ReactNode;
434
+ loadingContent?: ReactNode;
435
+ errorContent?: ReactNode | ((error: Error | string) => ReactNode);
436
+ theme?: Partial<Theme>;
437
+ translations?: Partial<Translations>;
438
+ dimensions?: Dimensions;
439
+ classNames?: ClassNames;
440
+ styles?: Styles;
441
+ mobileBreakpoint?: Breakpoint;
442
+ showMobileLabels?: boolean;
443
+ enableDragDrop?: boolean;
444
+ enableColumnResize?: boolean;
445
+ enableRowSelection?: boolean;
446
+ enableMultiSelect?: boolean;
447
+ enableRowExpansion?: boolean;
448
+ stickyHeader?: boolean;
449
+ showPagination?: boolean;
450
+ showFilter?: boolean;
451
+ showGlobalFilter?: boolean;
452
+ showColumnToggle?: boolean;
453
+ showSortIndicator?: boolean;
454
+ paginationConfig?: PaginationConfig;
455
+ filterConfig?: FilterConfig;
456
+ sortConfig?: SortConfig;
457
+ onRowClick?: (row: T, index: number) => void;
458
+ onRowDoubleClick?: (row: T, index: number) => void;
459
+ onCellClick?: (event: {
460
+ row: T;
461
+ rowIndex: number;
462
+ columnId: string;
463
+ value: unknown;
464
+ }) => void;
465
+ onRowSelect?: (selectedRows: T[]) => void;
466
+ onSort?: (sorting: Array<{
467
+ columnId: string;
468
+ direction: SortDirection;
469
+ }>) => void;
470
+ onFilter?: (filters: Array<{
471
+ columnId: string;
472
+ value: unknown;
473
+ }>) => void;
474
+ onPageChange?: (page: number, pageSize: number) => void;
475
+ onError?: (error: Error) => void;
476
+ onRetry?: () => void;
477
+ getRowId?: (row: T) => string | number;
478
+ getRowClassName?: (row: T, index: number) => string;
479
+ getRowStyle?: (row: T, index: number) => CSSProperties;
480
+ isRowDisabled?: (row: T) => boolean;
481
+ renderRowExpansion?: (row: T) => ReactNode;
482
+ renderHeader?: () => ReactNode;
483
+ renderFooter?: () => ReactNode;
484
+ tableRef?: RefObject<GridTableRef<T>>;
485
+ className?: string;
486
+ style?: CSSProperties;
487
+ }
488
+
489
+ declare function GridTable<T extends RowData = RowData>({ data, columns, loading, error, theme, translations, mobileBreakpoint, paginationConfig, filterConfig, sortConfig, enableMultiSelect, getRowId, ...props }: GridTableComponentProps<T>): ReactNode;
490
+
491
+ interface GridHeaderProps<T extends RowData = RowData> {
492
+ columns: ColumnDefinition<T>[];
493
+ columnStates: ColumnState[];
494
+ className?: string;
495
+ style?: CSSProperties;
496
+ sticky?: boolean;
497
+ enableSort?: boolean;
498
+ enableFilter?: boolean;
499
+ enableDragDrop?: boolean;
500
+ enableResize?: boolean;
501
+ enableSelection?: boolean;
502
+ allSelected?: boolean;
503
+ someSelected?: boolean;
504
+ onSelectAll?: () => void;
505
+ onSort?: (columnId: string, direction: SortDirection) => void;
506
+ onFilterOpen?: (columnId: string) => void;
507
+ getSortDirection?: (columnId: string) => SortDirection;
508
+ }
509
+
510
+ declare function GridHeader<T extends RowData = RowData>({ columns, columnStates, className, style, sticky, enableSort, enableFilter, enableDragDrop, enableResize, enableSelection, allSelected, someSelected, onSelectAll, onSort, onFilterOpen, getSortDirection, }: GridHeaderProps<T>): ReactNode;
511
+
512
+ interface CellClickEvent<T extends RowData = RowData> {
513
+ row: T;
514
+ rowIndex: number;
515
+ columnId: string;
516
+ value: unknown;
517
+ }
518
+ interface GridCellProps<T extends RowData = RowData> {
519
+ column: ColumnDefinition<T>;
520
+ row: T;
521
+ rowIndex: number;
522
+ value: unknown;
523
+ width?: number | string;
524
+ align?: Alignment;
525
+ className?: string;
526
+ style?: CSSProperties;
527
+ showLabel?: boolean;
528
+ labelText?: string;
529
+ sticky?: 'left' | 'right';
530
+ stickyOffset?: number;
531
+ onClick?: (event: CellClickEvent<T>) => void;
532
+ }
533
+
534
+ interface GridBodyProps<T extends RowData = RowData> {
535
+ data: T[];
536
+ columns: ColumnDefinition<T>[];
537
+ columnStates: ColumnState[];
538
+ className?: string;
539
+ style?: CSSProperties;
540
+ isMobile?: boolean;
541
+ showMobileLabels?: boolean;
542
+ enableSelection?: boolean;
543
+ enableExpansion?: boolean;
544
+ selectedIds?: Set<string | number>;
545
+ expandedIds?: Set<string | number>;
546
+ onRowClick?: (row: T, index: number) => void;
547
+ onRowDoubleClick?: (row: T, index: number) => void;
548
+ onCellClick?: (event: CellClickEvent<T>) => void;
549
+ onRowSelect?: (id: string | number, selected: boolean) => void;
550
+ onRowExpand?: (id: string | number, expanded: boolean) => void;
551
+ getRowId: (row: T) => string | number;
552
+ getRowClassName?: (row: T, index: number) => string;
553
+ getRowStyle?: (row: T, index: number) => CSSProperties;
554
+ isRowDisabled?: (row: T) => boolean;
555
+ renderRowExpansion?: (row: T) => ReactNode;
556
+ }
557
+
558
+ declare function GridBody<T extends RowData = RowData>({ data, columns, columnStates, className, style, isMobile, showMobileLabels, enableSelection, enableExpansion, selectedIds, expandedIds, onRowClick, onRowDoubleClick, onCellClick, onRowSelect, onRowExpand, getRowId, getRowClassName, getRowStyle, isRowDisabled, renderRowExpansion, }: GridBodyProps<T>): ReactNode;
559
+
560
+ interface GridRowProps<T extends RowData = RowData> {
561
+ row: T;
562
+ rowIndex: number;
563
+ columns: ColumnDefinition<T>[];
564
+ columnStates: ColumnState[];
565
+ isSelected?: boolean;
566
+ isExpanded?: boolean;
567
+ isDisabled?: boolean;
568
+ isMobile?: boolean;
569
+ showMobileLabels?: boolean;
570
+ className?: string;
571
+ style?: CSSProperties;
572
+ onClick?: (row: T, index: number) => void;
573
+ onDoubleClick?: (row: T, index: number) => void;
574
+ onContextMenu?: (row: T, index: number, event: MouseEvent) => void;
575
+ onCellClick?: (event: CellClickEvent<T>) => void;
576
+ onSelect?: (selected: boolean) => void;
577
+ onExpand?: (expanded: boolean) => void;
578
+ enableSelection?: boolean;
579
+ enableExpansion?: boolean;
580
+ renderExpansion?: (row: T) => ReactNode;
581
+ getRowId: (row: T) => string | number;
582
+ }
583
+
584
+ declare function GridRow<T extends RowData = RowData>({ row, rowIndex, columns, columnStates, isSelected, isExpanded, isDisabled, isMobile, showMobileLabels, className, style, onClick, onDoubleClick, onContextMenu, onCellClick, onSelect, onExpand, enableSelection, enableExpansion, renderExpansion, getRowId, }: GridRowProps<T>): ReactNode;
585
+
586
+ declare function GridCell<T extends RowData = RowData>({ column, row, rowIndex, value, width, align, className, style, showLabel, labelText, sticky, stickyOffset, onClick, }: GridCellProps<T>): ReactNode;
587
+
588
+ interface PaginationProps {
589
+ page: number;
590
+ pageSize: number;
591
+ totalItems: number;
592
+ totalPages: number;
593
+ pageSizeOptions?: readonly number[];
594
+ showFirstLast?: boolean;
595
+ showPageNumbers?: boolean;
596
+ maxPageButtons?: number;
597
+ className?: string;
598
+ style?: CSSProperties;
599
+ onPageChange: (page: number) => void;
600
+ onPageSizeChange: (pageSize: number) => void;
601
+ }
602
+
603
+ declare function Pagination({ page, pageSize, totalItems, totalPages, pageSizeOptions, showFirstLast, showPageNumbers, maxPageButtons, className, style, onPageChange, onPageSizeChange, }: PaginationProps): ReactNode;
604
+
605
+ interface SkeletonProps {
606
+ rows?: number;
607
+ columns?: number;
608
+ columnWidths?: (number | string)[];
609
+ rowHeight?: number;
610
+ className?: string;
611
+ style?: CSSProperties;
612
+ showHeader?: boolean;
613
+ animate?: boolean;
614
+ }
615
+
616
+ declare function Skeleton({ rows, columns, columnWidths, rowHeight, className, style, showHeader, animate, }: SkeletonProps): ReactNode;
617
+
618
+ interface EmptyStateProps {
619
+ title?: string;
620
+ description?: string;
621
+ icon?: ReactNode;
622
+ action?: ReactNode;
623
+ className?: string;
624
+ style?: CSSProperties;
625
+ }
626
+
627
+ declare function EmptyState({ title, description, icon, action, className, style, }: EmptyStateProps): ReactNode;
628
+
629
+ type DrawerContent = 'filter' | 'sort' | 'columns';
630
+ interface MobileDrawerProps {
631
+ isOpen: boolean;
632
+ content: DrawerContent | null;
633
+ onClose: () => void;
634
+ className?: string;
635
+ style?: CSSProperties;
636
+ children?: ReactNode;
637
+ }
638
+
639
+ declare function MobileDrawer({ isOpen, content, onClose, className, style, }: MobileDrawerProps): ReactNode;
640
+
641
+ interface TableContextState<T extends RowData = RowData> {
642
+ data: T[];
643
+ originalData: T[];
644
+ columns: ColumnDefinition<T>[];
645
+ columnStates: ColumnState[];
646
+ sorting: SortValue[];
647
+ filters: FilterValue[];
648
+ globalFilter: string;
649
+ page: number;
650
+ pageSize: number;
651
+ totalItems: number;
652
+ selectedIds: Set<string | number>;
653
+ expandedIds: Set<string | number>;
654
+ loading: boolean;
655
+ error: Error | string | null;
656
+ theme: Theme;
657
+ translations: Translations;
658
+ currentBreakpoint: Breakpoint;
659
+ mobileBreakpoint: Breakpoint;
660
+ draggingColumnId: string | null;
661
+ resizingColumnId: string | null;
662
+ activeFilterColumnId: string | null;
663
+ showMobileDrawer: boolean;
664
+ mobileDrawerContent: 'filter' | 'sort' | 'columns' | null;
665
+ }
666
+ interface TableContextActions<T extends RowData = RowData> {
667
+ setData: (data: T[]) => void;
668
+ setLoading: (loading: boolean) => void;
669
+ setError: (error: Error | string | null) => void;
670
+ setSorting: (columnId: string, direction: SortDirection) => void;
671
+ toggleSorting: (columnId: string) => void;
672
+ clearSorting: () => void;
673
+ setFilter: (columnId: string, value: unknown, operator?: FilterOperator) => void;
674
+ removeFilter: (columnId: string) => void;
675
+ clearFilters: () => void;
676
+ setGlobalFilter: (value: string) => void;
677
+ setPage: (page: number) => void;
678
+ setPageSize: (pageSize: number) => void;
679
+ selectRow: (id: string | number) => void;
680
+ deselectRow: (id: string | number) => void;
681
+ toggleRow: (id: string | number) => void;
682
+ selectAll: () => void;
683
+ deselectAll: () => void;
684
+ expandRow: (id: string | number) => void;
685
+ collapseRow: (id: string | number) => void;
686
+ toggleRowExpansion: (id: string | number) => void;
687
+ reorderColumn: (sourceId: string, targetId: string) => void;
688
+ resizeColumn: (columnId: string, width: number) => void;
689
+ toggleColumnVisibility: (columnId: string) => void;
690
+ resetColumns: () => void;
691
+ setDraggingColumn: (columnId: string | null) => void;
692
+ setResizingColumn: (columnId: string | null) => void;
693
+ setActiveFilterColumn: (columnId: string | null) => void;
694
+ openMobileDrawer: (content: 'filter' | 'sort' | 'columns') => void;
695
+ closeMobileDrawer: () => void;
696
+ refresh: () => void;
697
+ reset: () => void;
698
+ }
699
+ interface TableContextValue<T extends RowData = RowData> {
700
+ state: TableContextState<T>;
701
+ actions: TableContextActions<T>;
702
+ computed: {
703
+ filteredData: T[];
704
+ sortedData: T[];
705
+ paginatedData: T[];
706
+ visibleColumns: ColumnDefinition<T>[];
707
+ totalPages: number;
708
+ canGoNext: boolean;
709
+ canGoPrevious: boolean;
710
+ allSelected: boolean;
711
+ someSelected: boolean;
712
+ isMobile: boolean;
713
+ isTablet: boolean;
714
+ isDesktop: boolean;
715
+ };
716
+ }
717
+ interface TableProviderProps<T extends RowData = RowData> {
718
+ children: ReactNode;
719
+ data: T[];
720
+ columns: ColumnDefinition<T>[];
721
+ loading?: boolean;
722
+ error?: Error | string | null;
723
+ theme?: Partial<Theme>;
724
+ translations?: Partial<Translations>;
725
+ mobileBreakpoint?: Breakpoint;
726
+ paginationConfig?: PaginationConfig;
727
+ filterConfig?: FilterConfig;
728
+ sortConfig?: SortConfig;
729
+ enableMultiSort?: boolean;
730
+ enableRowSelection?: boolean;
731
+ enableMultiSelect?: boolean;
732
+ getRowId?: (row: T) => string | number;
733
+ onStateChange?: (state: TableContextState<T>) => void;
734
+ }
735
+
736
+ declare const TableContext: react.Context<TableContextValue<RowData> | null>;
737
+ declare function TableProvider<T extends RowData>({ children, data, columns, loading, error, theme, translations, mobileBreakpoint, paginationConfig, filterConfig: _filterConfig, sortConfig: _sortConfig, enableMultiSort, getRowId, onStateChange, }: TableProviderProps<T>): ReactNode;
738
+ declare function useTableContext<T extends RowData = RowData>(): TableContextValue<T>;
739
+
740
+ interface UseSortReturn {
741
+ sorting: SortState['sorting'];
742
+ getSortDirection: (columnId: string) => SortDirection;
743
+ getSortIndex: (columnId: string) => number;
744
+ isSorted: (columnId: string) => boolean;
745
+ setSorting: SortActions['setSorting'];
746
+ toggleSorting: SortActions['toggleSorting'];
747
+ clearSorting: SortActions['clearSorting'];
748
+ clearColumnSorting: (columnId: string) => void;
749
+ }
750
+ declare function useSort(): UseSortReturn;
751
+
752
+ interface UseFilterReturn {
753
+ filters: FilterValue[];
754
+ globalFilter: string;
755
+ activeFilterColumnId: string | null;
756
+ hasAnyFilter: () => boolean;
757
+ hasFilter: (columnId: string) => boolean;
758
+ getFilterValue: (columnId: string) => FilterValue | undefined;
759
+ setFilter: FilterActions['setFilter'];
760
+ removeFilter: FilterActions['removeFilter'];
761
+ clearFilters: FilterActions['clearFilters'];
762
+ setGlobalFilter: FilterActions['setGlobalFilter'];
763
+ clearGlobalFilter: () => void;
764
+ openFilterPanel: (columnId: string) => void;
765
+ closeFilterPanel: () => void;
766
+ }
767
+ interface UseFilterOptions {
768
+ debounceMs?: number;
769
+ }
770
+ declare function useFilter(options?: UseFilterOptions): UseFilterReturn;
771
+
772
+ interface UsePaginationReturn extends PaginationInfo, PaginationActions {
773
+ pageSizeOptions: readonly number[];
774
+ }
775
+ interface UsePaginationOptions {
776
+ pageSizeOptions?: readonly number[];
777
+ }
778
+ declare function usePagination(options?: UsePaginationOptions): UsePaginationReturn;
779
+
780
+ interface UseDragDropReturn {
781
+ isDragging: boolean;
782
+ draggingColumnId: string | null;
783
+ dragOverColumnId: string | null;
784
+ handleDragStart: (columnId: string) => (event: React.DragEvent) => void;
785
+ handleDragOver: (columnId: string) => (event: React.DragEvent) => void;
786
+ handleDragEnd: () => void;
787
+ handleDrop: (targetColumnId: string) => (event: React.DragEvent) => void;
788
+ handleDragLeave: () => void;
789
+ getDragHandleProps: (columnId: string) => DragHandleProps;
790
+ getDropTargetProps: (columnId: string) => DropTargetProps;
791
+ }
792
+ interface DragHandleProps {
793
+ draggable: boolean;
794
+ onDragStart: (event: React.DragEvent) => void;
795
+ onDragEnd: () => void;
796
+ }
797
+ interface DropTargetProps {
798
+ onDragOver: (event: React.DragEvent) => void;
799
+ onDragLeave: () => void;
800
+ onDrop: (event: React.DragEvent) => void;
801
+ }
802
+ interface UseDragDropOptions {
803
+ onReorder?: (event: ColumnReorderEvent) => void;
804
+ enabled?: boolean;
805
+ }
806
+ declare function useDragDrop(options?: UseDragDropOptions): UseDragDropReturn;
807
+
808
+ declare const DEFAULT_PAGE_SIZE = 10;
809
+ declare const DEFAULT_PAGE_SIZES: readonly [10, 20, 50, 100];
810
+ declare const MIN_COLUMN_WIDTH = 50;
811
+ declare const DEFAULT_COLUMN_WIDTH = 150;
812
+ declare const MAX_COLUMN_WIDTH = 500;
813
+ declare const MOBILE_BREAKPOINT = 640;
814
+ declare const TABLET_BREAKPOINT = 768;
815
+ declare const DESKTOP_BREAKPOINT = 1024;
816
+
817
+ declare const BREAKPOINTS: {
818
+ readonly mobile: 640;
819
+ readonly tablet: 768;
820
+ readonly desktop: 1024;
821
+ };
822
+ declare const BREAKPOINT_KEYS: readonly ["mobile", "tablet", "desktop"];
823
+ declare const RESPONSIVE_MODES: {
824
+ readonly stack: "stack";
825
+ readonly scroll: "scroll";
826
+ readonly hide: "hide";
827
+ };
828
+
829
+ declare const DEFAULT_TRANSLATIONS: {
830
+ readonly empty: "No data available";
831
+ readonly loading: "Loading...";
832
+ readonly search: "Search...";
833
+ readonly filter: "Filter";
834
+ readonly sort: "Sort";
835
+ readonly sortAsc: "Sort ascending";
836
+ readonly sortDesc: "Sort descending";
837
+ readonly clearSort: "Clear sort";
838
+ readonly clearFilter: "Clear filter";
839
+ readonly clearAll: "Clear all";
840
+ readonly apply: "Apply";
841
+ readonly cancel: "Cancel";
842
+ readonly columns: "Columns";
843
+ readonly showColumns: "Show columns";
844
+ readonly hideColumn: "Hide column";
845
+ readonly resetColumns: "Reset columns";
846
+ readonly rowsPerPage: "Rows per page";
847
+ readonly of: "of";
848
+ readonly page: "Page";
849
+ readonly first: "First";
850
+ readonly previous: "Previous";
851
+ readonly next: "Next";
852
+ readonly last: "Last";
853
+ readonly selected: "selected";
854
+ readonly dragToReorder: "Drag to reorder";
855
+ readonly noResults: "No results found";
856
+ readonly errorLoading: "Error loading data";
857
+ readonly retry: "Retry";
858
+ };
859
+ declare const DEFAULT_THEME: {
860
+ mode: "dark";
861
+ colors: {
862
+ background: {
863
+ primary: string;
864
+ secondary: string;
865
+ tertiary: string;
866
+ hover: string;
867
+ };
868
+ text: {
869
+ primary: string;
870
+ secondary: string;
871
+ muted: string;
872
+ };
873
+ border: {
874
+ default: string;
875
+ hover: string;
876
+ };
877
+ accent: {
878
+ primary: string;
879
+ success: string;
880
+ warning: string;
881
+ error: string;
882
+ };
883
+ };
884
+ };
885
+ declare const DEFAULT_LIGHT_THEME: {
886
+ mode: "light";
887
+ colors: {
888
+ background: {
889
+ primary: string;
890
+ secondary: string;
891
+ tertiary: string;
892
+ hover: string;
893
+ };
894
+ text: {
895
+ primary: string;
896
+ secondary: string;
897
+ muted: string;
898
+ };
899
+ border: {
900
+ default: string;
901
+ hover: string;
902
+ };
903
+ accent: {
904
+ primary: string;
905
+ success: string;
906
+ warning: string;
907
+ error: string;
908
+ };
909
+ };
910
+ };
911
+ declare const DEFAULT_TABLE_CONFIG: {
912
+ readonly pageSize: 10;
913
+ readonly pageSizes: readonly [10, 20, 50, 100];
914
+ readonly columnWidth: 150;
915
+ readonly mobileBreakpoint: "tablet";
916
+ readonly stickyHeader: true;
917
+ readonly showPagination: true;
918
+ readonly showFilter: true;
919
+ readonly showSort: true;
920
+ readonly enableDragDrop: true;
921
+ readonly enableColumnResize: true;
922
+ readonly enableRowSelection: false;
923
+ readonly enableMultiSelect: false;
924
+ readonly showColumnToggle: true;
925
+ readonly showEmptyState: true;
926
+ readonly showSkeleton: true;
927
+ readonly skeletonRows: 5;
928
+ readonly virtualize: false;
929
+ readonly virtualizeThreshold: 100;
930
+ };
931
+
932
+ interface UseBreakpointReturn {
933
+ currentBreakpoint: Breakpoint;
934
+ isMobile: boolean;
935
+ isTablet: boolean;
936
+ isDesktop: boolean;
937
+ isMobileOrTablet: boolean;
938
+ isTabletOrDesktop: boolean;
939
+ breakpointValue: <T>(value: ResponsiveValue<T>, fallback: T) => T;
940
+ shouldShowMobileView: boolean;
941
+ }
942
+ declare function useBreakpoint(): UseBreakpointReturn;
943
+
944
+ interface UseTableReturn<T extends RowData = RowData> {
945
+ data: T[];
946
+ filteredData: T[];
947
+ sortedData: T[];
948
+ paginatedData: T[];
949
+ columns: ColumnDefinition<T>[];
950
+ visibleColumns: ColumnDefinition<T>[];
951
+ loading: boolean;
952
+ error: Error | string | null;
953
+ isEmpty: boolean;
954
+ sort: UseSortReturn;
955
+ filter: UseFilterReturn;
956
+ pagination: UsePaginationReturn;
957
+ dragDrop: UseDragDropReturn;
958
+ breakpoint: UseBreakpointReturn;
959
+ selection: {
960
+ selectedIds: Set<string | number>;
961
+ allSelected: boolean;
962
+ someSelected: boolean;
963
+ selectRow: (id: string | number) => void;
964
+ deselectRow: (id: string | number) => void;
965
+ toggleRow: (id: string | number) => void;
966
+ selectAll: () => void;
967
+ deselectAll: () => void;
968
+ isSelected: (id: string | number) => boolean;
969
+ };
970
+ expansion: {
971
+ expandedIds: Set<string | number>;
972
+ expandRow: (id: string | number) => void;
973
+ collapseRow: (id: string | number) => void;
974
+ toggleRow: (id: string | number) => void;
975
+ isExpanded: (id: string | number) => boolean;
976
+ };
977
+ columnApi: {
978
+ states: ColumnState[];
979
+ reorder: (sourceId: string, targetId: string) => void;
980
+ resize: (columnId: string, width: number) => void;
981
+ toggleVisibility: (columnId: string) => void;
982
+ reset: () => void;
983
+ getWidth: (columnId: string) => number;
984
+ isVisible: (columnId: string) => boolean;
985
+ };
986
+ mobile: {
987
+ showDrawer: boolean;
988
+ drawerContent: 'filter' | 'sort' | 'columns' | null;
989
+ openDrawer: (content: 'filter' | 'sort' | 'columns') => void;
990
+ closeDrawer: () => void;
991
+ };
992
+ theme: Theme;
993
+ translations: Translations;
994
+ refresh: () => void;
995
+ reset: () => void;
996
+ }
997
+ declare function useTable<T extends RowData = RowData>(): UseTableReturn<T>;
998
+
999
+ export { type Alignment, BREAKPOINTS, BREAKPOINT_KEYS, type Breakpoint, type ClassNames, type ColumnDefinition, type ColumnReorderEvent, type ColumnResizeEvent, type ColumnState, type ColumnVisibilityEvent, DEFAULT_COLUMN_WIDTH, DEFAULT_LIGHT_THEME, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZES, DEFAULT_TABLE_CONFIG, DEFAULT_THEME, DEFAULT_TRANSLATIONS, DESKTOP_BREAKPOINT, type Dimensions, EmptyState, type EmptyStateProps, type FilterActions, type FilterConfig, type FilterOperator, type FilterOption, type FilterPanelProps, type FilterState, type FilterValue, GridBody, type GridBodyProps, GridCell, type GridCellProps, GridHeader, type GridHeaderProps, GridRow, type GridRowProps, GridTable, type GridTableComponentProps, type GridTableProps, type GridTableRef, MAX_COLUMN_WIDTH, MIN_COLUMN_WIDTH, MOBILE_BREAKPOINT, MobileDrawer, type MobileDrawerProps, Pagination, type PaginationActions, type PaginationConfig, type PaginationInfo, type PaginationProps, type PaginationState, RESPONSIVE_MODES, type RenderFunction, type ResponsiveValue, type RowData, type RowExpansionActions, type RowExpansionState, type RowProps, type RowSelectionActions, type RowSelectionState, type RowState, Skeleton, type SkeletonProps, type SortActions, type SortConfig, type SortDirection, type SortState, type SortValue, type Styles, TABLET_BREAKPOINT, TableContext, type TableContextActions, type TableContextState, type TableContextValue, type TableInstance, TableProvider, type TableProviderProps, type TableState, type Theme, type ThemeColors, type ThemeMode, type Translations, type UseBreakpointReturn, type UseDragDropReturn, type UseFilterReturn, type UsePaginationReturn, type UseSortReturn, type UseTableReturn, useBreakpoint, useDragDrop, useFilter, usePagination, useSort, useTable, useTableContext };