@forgedevstack/grid-table 1.0.1 → 1.0.3
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/CHANGELOG.md +37 -0
- package/README.md +33 -5
- package/dist/grid-table.css +1 -0
- package/dist/index.d.mts +134 -103
- package/dist/index.d.ts +134 -103
- package/dist/index.js +881 -415
- package/dist/index.mjs +882 -414
- package/package.json +14 -6
- package/src/grid-table.scss +26 -0
package/dist/index.d.ts
CHANGED
|
@@ -132,6 +132,9 @@ interface ColumnDefinition<T = unknown> {
|
|
|
132
132
|
sortFn?: (a: unknown, b: unknown, direction: SortDirection) => number;
|
|
133
133
|
filterFn?: (value: unknown, filterValue: unknown, operator: FilterOperator) => boolean;
|
|
134
134
|
meta?: Record<string, unknown>;
|
|
135
|
+
showOverflowTooltip?: boolean;
|
|
136
|
+
renderSubCell?: (row: T) => ReactNode;
|
|
137
|
+
subCellExpandTrigger?: 'doubleClick' | 'arrow' | 'both';
|
|
135
138
|
}
|
|
136
139
|
interface FilterOption {
|
|
137
140
|
value: string | number | boolean;
|
|
@@ -376,7 +379,7 @@ interface GridTableProps<T extends RowData = RowData> {
|
|
|
376
379
|
getRowStyle?: (row: T, index: number) => React.CSSProperties;
|
|
377
380
|
isRowDisabled?: (row: T) => boolean;
|
|
378
381
|
isRowSelectable?: (row: T) => boolean;
|
|
379
|
-
renderRowExpansion?: (row: T) => ReactNode;
|
|
382
|
+
renderRowExpansion?: (row: T, rowId: string | number) => ReactNode;
|
|
380
383
|
renderHeader?: () => ReactNode;
|
|
381
384
|
renderFooter?: () => ReactNode;
|
|
382
385
|
renderEmpty?: () => ReactNode;
|
|
@@ -425,6 +428,119 @@ interface GridTableRef<T extends RowData = RowData> {
|
|
|
425
428
|
exportData: (format: 'json' | 'csv') => void;
|
|
426
429
|
}
|
|
427
430
|
|
|
431
|
+
interface TableContextState<T extends RowData = RowData> {
|
|
432
|
+
data: T[];
|
|
433
|
+
originalData: T[];
|
|
434
|
+
columns: ColumnDefinition<T>[];
|
|
435
|
+
columnStates: ColumnState[];
|
|
436
|
+
sorting: SortValue[];
|
|
437
|
+
filters: FilterValue[];
|
|
438
|
+
globalFilter: string;
|
|
439
|
+
page: number;
|
|
440
|
+
pageSize: number;
|
|
441
|
+
totalItems: number;
|
|
442
|
+
selectedIds: Set<string | number>;
|
|
443
|
+
expandedIds: Set<string | number>;
|
|
444
|
+
expandedCellIds: Set<string>;
|
|
445
|
+
autoSizedColumnIds: Set<string>;
|
|
446
|
+
loading: boolean;
|
|
447
|
+
error: Error | string | null;
|
|
448
|
+
theme: Theme;
|
|
449
|
+
translations: Translations;
|
|
450
|
+
currentBreakpoint: Breakpoint;
|
|
451
|
+
mobileBreakpoint: Breakpoint;
|
|
452
|
+
draggingColumnId: string | null;
|
|
453
|
+
resizingColumnId: string | null;
|
|
454
|
+
activeFilterColumnId: string | null;
|
|
455
|
+
showMobileDrawer: boolean;
|
|
456
|
+
mobileDrawerContent: 'filter' | 'sort' | 'columns' | null;
|
|
457
|
+
}
|
|
458
|
+
interface TableContextActions<T extends RowData = RowData> {
|
|
459
|
+
setData: (data: T[]) => void;
|
|
460
|
+
setLoading: (loading: boolean) => void;
|
|
461
|
+
setError: (error: Error | string | null) => void;
|
|
462
|
+
setSorting: (columnId: string, direction: SortDirection) => void;
|
|
463
|
+
toggleSorting: (columnId: string) => void;
|
|
464
|
+
clearSorting: () => void;
|
|
465
|
+
setFilter: (columnId: string, value: unknown, operator?: FilterOperator) => void;
|
|
466
|
+
removeFilter: (columnId: string) => void;
|
|
467
|
+
clearFilters: () => void;
|
|
468
|
+
setGlobalFilter: (value: string) => void;
|
|
469
|
+
setPage: (page: number) => void;
|
|
470
|
+
setPageSize: (pageSize: number) => void;
|
|
471
|
+
selectRow: (id: string | number) => void;
|
|
472
|
+
deselectRow: (id: string | number) => void;
|
|
473
|
+
toggleRow: (id: string | number) => void;
|
|
474
|
+
selectAll: () => void;
|
|
475
|
+
deselectAll: () => void;
|
|
476
|
+
expandRow: (id: string | number) => void;
|
|
477
|
+
collapseRow: (id: string | number) => void;
|
|
478
|
+
toggleRowExpansion: (id: string | number) => void;
|
|
479
|
+
toggleCellExpansion: (rowId: string | number, columnId: string) => void;
|
|
480
|
+
toggleColumnAutoSize: (columnId: string) => void;
|
|
481
|
+
reorderColumn: (sourceId: string, targetId: string) => void;
|
|
482
|
+
resizeColumn: (columnId: string, width: number) => void;
|
|
483
|
+
toggleColumnVisibility: (columnId: string) => void;
|
|
484
|
+
resetColumns: () => void;
|
|
485
|
+
setDraggingColumn: (columnId: string | null) => void;
|
|
486
|
+
setResizingColumn: (columnId: string | null) => void;
|
|
487
|
+
setActiveFilterColumn: (columnId: string | null) => void;
|
|
488
|
+
openMobileDrawer: (content: 'filter' | 'sort' | 'columns') => void;
|
|
489
|
+
closeMobileDrawer: () => void;
|
|
490
|
+
refresh: () => void;
|
|
491
|
+
reset: () => void;
|
|
492
|
+
}
|
|
493
|
+
type SubCellExpandTrigger = 'doubleClick' | 'arrow' | 'both';
|
|
494
|
+
interface TableOptions {
|
|
495
|
+
showOverflowTooltip?: boolean;
|
|
496
|
+
enableCellAutoSizeOnDoubleClick?: boolean;
|
|
497
|
+
subCellExpandTrigger?: SubCellExpandTrigger;
|
|
498
|
+
expandRowOnDoubleClick?: boolean;
|
|
499
|
+
globalFilterColumns?: string[];
|
|
500
|
+
}
|
|
501
|
+
interface TableContextValue<T extends RowData = RowData> {
|
|
502
|
+
state: TableContextState<T>;
|
|
503
|
+
actions: TableContextActions<T>;
|
|
504
|
+
tableOptions: TableOptions;
|
|
505
|
+
computed: {
|
|
506
|
+
filteredData: T[];
|
|
507
|
+
sortedData: T[];
|
|
508
|
+
paginatedData: T[];
|
|
509
|
+
visibleColumns: ColumnDefinition<T>[];
|
|
510
|
+
totalPages: number;
|
|
511
|
+
canGoNext: boolean;
|
|
512
|
+
canGoPrevious: boolean;
|
|
513
|
+
allSelected: boolean;
|
|
514
|
+
someSelected: boolean;
|
|
515
|
+
isMobile: boolean;
|
|
516
|
+
isTablet: boolean;
|
|
517
|
+
isDesktop: boolean;
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
interface TableProviderProps<T extends RowData = RowData> {
|
|
521
|
+
children: ReactNode;
|
|
522
|
+
data: T[];
|
|
523
|
+
columns: ColumnDefinition<T>[];
|
|
524
|
+
loading?: boolean;
|
|
525
|
+
error?: Error | string | null;
|
|
526
|
+
theme?: Partial<Theme>;
|
|
527
|
+
translations?: Partial<Translations>;
|
|
528
|
+
mobileBreakpoint?: Breakpoint;
|
|
529
|
+
paginationConfig?: PaginationConfig;
|
|
530
|
+
filterConfig?: FilterConfig;
|
|
531
|
+
sortConfig?: SortConfig;
|
|
532
|
+
enableMultiSort?: boolean;
|
|
533
|
+
enableRowSelection?: boolean;
|
|
534
|
+
enableMultiSelect?: boolean;
|
|
535
|
+
getRowId?: (row: T) => string | number;
|
|
536
|
+
onStateChange?: (state: TableContextState<T>) => void;
|
|
537
|
+
showOverflowTooltip?: boolean;
|
|
538
|
+
enableCellAutoSizeOnDoubleClick?: boolean;
|
|
539
|
+
subCellExpandTrigger?: SubCellExpandTrigger;
|
|
540
|
+
expandRowOnDoubleClick?: boolean;
|
|
541
|
+
globalFilterColumns?: string[];
|
|
542
|
+
}
|
|
543
|
+
|
|
428
544
|
interface GridTableComponentProps<T extends RowData = RowData> {
|
|
429
545
|
data: T[];
|
|
430
546
|
columns: ColumnDefinition<T>[];
|
|
@@ -478,15 +594,23 @@ interface GridTableComponentProps<T extends RowData = RowData> {
|
|
|
478
594
|
getRowClassName?: (row: T, index: number) => string;
|
|
479
595
|
getRowStyle?: (row: T, index: number) => CSSProperties;
|
|
480
596
|
isRowDisabled?: (row: T) => boolean;
|
|
481
|
-
renderRowExpansion?: (row: T) => ReactNode;
|
|
597
|
+
renderRowExpansion?: (row: T, rowId: string | number) => ReactNode;
|
|
598
|
+
themeMode?: 'light' | 'dark' | 'system';
|
|
482
599
|
renderHeader?: () => ReactNode;
|
|
483
600
|
renderFooter?: () => ReactNode;
|
|
484
601
|
tableRef?: RefObject<GridTableRef<T>>;
|
|
485
602
|
className?: string;
|
|
486
603
|
style?: CSSProperties;
|
|
604
|
+
showOverflowTooltip?: boolean;
|
|
605
|
+
enableCellAutoSizeOnDoubleClick?: boolean;
|
|
606
|
+
subCellExpandTrigger?: SubCellExpandTrigger;
|
|
607
|
+
expandRowOnDoubleClick?: boolean;
|
|
608
|
+
globalFilterColumns?: string[];
|
|
609
|
+
themeOverride?: Record<string, unknown>;
|
|
610
|
+
studio?: boolean;
|
|
487
611
|
}
|
|
488
612
|
|
|
489
|
-
declare function GridTable<T extends RowData = RowData>({ data, columns, loading, error, theme, translations, mobileBreakpoint, paginationConfig, filterConfig, sortConfig, enableMultiSelect, getRowId, ...props }: GridTableComponentProps<T>): ReactNode;
|
|
613
|
+
declare function GridTable<T extends RowData = RowData>({ data, columns, loading, error, theme, translations, mobileBreakpoint, paginationConfig, filterConfig, sortConfig, enableMultiSelect, getRowId, showOverflowTooltip, enableCellAutoSizeOnDoubleClick, subCellExpandTrigger, expandRowOnDoubleClick, themeMode, themeOverride, studio, ...props }: GridTableComponentProps<T>): ReactNode;
|
|
490
614
|
|
|
491
615
|
interface GridHeaderProps<T extends RowData = RowData> {
|
|
492
616
|
columns: ColumnDefinition<T>[];
|
|
@@ -499,6 +623,7 @@ interface GridHeaderProps<T extends RowData = RowData> {
|
|
|
499
623
|
enableDragDrop?: boolean;
|
|
500
624
|
enableResize?: boolean;
|
|
501
625
|
enableSelection?: boolean;
|
|
626
|
+
enableExpansion?: boolean;
|
|
502
627
|
allSelected?: boolean;
|
|
503
628
|
someSelected?: boolean;
|
|
504
629
|
onSelectAll?: () => void;
|
|
@@ -507,7 +632,7 @@ interface GridHeaderProps<T extends RowData = RowData> {
|
|
|
507
632
|
getSortDirection?: (columnId: string) => SortDirection;
|
|
508
633
|
}
|
|
509
634
|
|
|
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;
|
|
635
|
+
declare function GridHeader<T extends RowData = RowData>({ columns, columnStates, className, style, sticky, enableSort, enableFilter, enableDragDrop, enableResize, enableSelection, enableExpansion, allSelected, someSelected, onSelectAll, onSort, onFilterOpen, getSortDirection, }: GridHeaderProps<T>): ReactNode;
|
|
511
636
|
|
|
512
637
|
interface CellClickEvent<T extends RowData = RowData> {
|
|
513
638
|
row: T;
|
|
@@ -519,6 +644,7 @@ interface GridCellProps<T extends RowData = RowData> {
|
|
|
519
644
|
column: ColumnDefinition<T>;
|
|
520
645
|
row: T;
|
|
521
646
|
rowIndex: number;
|
|
647
|
+
rowId: string | number;
|
|
522
648
|
value: unknown;
|
|
523
649
|
width?: number | string;
|
|
524
650
|
align?: Alignment;
|
|
@@ -552,7 +678,7 @@ interface GridBodyProps<T extends RowData = RowData> {
|
|
|
552
678
|
getRowClassName?: (row: T, index: number) => string;
|
|
553
679
|
getRowStyle?: (row: T, index: number) => CSSProperties;
|
|
554
680
|
isRowDisabled?: (row: T) => boolean;
|
|
555
|
-
renderRowExpansion?: (row: T) => ReactNode;
|
|
681
|
+
renderRowExpansion?: (row: T, rowId: string | number) => ReactNode;
|
|
556
682
|
}
|
|
557
683
|
|
|
558
684
|
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;
|
|
@@ -577,13 +703,13 @@ interface GridRowProps<T extends RowData = RowData> {
|
|
|
577
703
|
onExpand?: (expanded: boolean) => void;
|
|
578
704
|
enableSelection?: boolean;
|
|
579
705
|
enableExpansion?: boolean;
|
|
580
|
-
renderExpansion?: (row: T) => ReactNode;
|
|
706
|
+
renderExpansion?: (row: T, rowId: string | number) => ReactNode;
|
|
581
707
|
getRowId: (row: T) => string | number;
|
|
582
708
|
}
|
|
583
709
|
|
|
584
710
|
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
711
|
|
|
586
|
-
declare function GridCell<T extends RowData = RowData>({ column, row, rowIndex, value, width, align, className, style, showLabel, labelText, sticky, stickyOffset, onClick, }: GridCellProps<T>): ReactNode;
|
|
712
|
+
declare function GridCell<T extends RowData = RowData>({ column, row, rowIndex, rowId, value, width, align, className, style, showLabel, labelText, sticky, stickyOffset, onClick, }: GridCellProps<T>): ReactNode;
|
|
587
713
|
|
|
588
714
|
interface PaginationProps {
|
|
589
715
|
page: number;
|
|
@@ -638,103 +764,8 @@ interface MobileDrawerProps {
|
|
|
638
764
|
|
|
639
765
|
declare function MobileDrawer({ isOpen, content, onClose, className, style, }: MobileDrawerProps): ReactNode;
|
|
640
766
|
|
|
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
767
|
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;
|
|
768
|
+
declare function TableProvider<T extends RowData>({ children, data, columns, loading, error, theme, translations, mobileBreakpoint, paginationConfig, filterConfig: _filterConfig, sortConfig: _sortConfig, enableMultiSort, getRowId, onStateChange, showOverflowTooltip, enableCellAutoSizeOnDoubleClick, subCellExpandTrigger, expandRowOnDoubleClick, globalFilterColumns, }: TableProviderProps<T>): ReactNode;
|
|
738
769
|
declare function useTableContext<T extends RowData = RowData>(): TableContextValue<T>;
|
|
739
770
|
|
|
740
771
|
interface UseSortReturn {
|