react-restyle-components 0.4.40 → 0.4.41
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/lib/src/core-components/src/components/Table/Table.js +30 -5
- package/lib/src/core-components/src/components/ag-grid/AgGrid.d.ts +11 -0
- package/lib/src/core-components/src/components/ag-grid/AgGrid.js +733 -0
- package/lib/src/core-components/src/components/ag-grid/elements.d.ts +246 -0
- package/lib/src/core-components/src/components/ag-grid/elements.js +1156 -0
- package/lib/src/core-components/src/components/ag-grid/hooks.d.ts +196 -0
- package/lib/src/core-components/src/components/ag-grid/hooks.js +943 -0
- package/lib/src/core-components/src/components/ag-grid/index.d.ts +9 -0
- package/lib/src/core-components/src/components/ag-grid/index.js +13 -0
- package/lib/src/core-components/src/components/ag-grid/types.d.ts +1367 -0
- package/lib/src/core-components/src/components/ag-grid/types.js +6 -0
- package/lib/src/core-components/src/components/index.d.ts +1 -0
- package/lib/src/core-components/src/components/index.js +1 -0
- package/lib/src/core-components/src/tc.global.css +5 -3
- package/lib/src/core-components/src/tc.module.css +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AG Grid Hooks
|
|
3
|
+
* Custom React hooks for AG Grid-like functionality
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { ColDef, RowNode, SortDirection, Column, ColumnState } from './types';
|
|
7
|
+
export interface SortModel {
|
|
8
|
+
colId: string;
|
|
9
|
+
sort: SortDirection;
|
|
10
|
+
}
|
|
11
|
+
export declare function useSorting<T>(initialSort?: SortModel[], multiSort?: boolean): {
|
|
12
|
+
sortModel: SortModel[];
|
|
13
|
+
setSortModel: React.Dispatch<React.SetStateAction<SortModel[]>>;
|
|
14
|
+
handleSort: (colId: string, multiSortKey?: boolean) => void;
|
|
15
|
+
getSortForColumn: (colId: string) => {
|
|
16
|
+
sort: SortDirection;
|
|
17
|
+
sortIndex?: number;
|
|
18
|
+
};
|
|
19
|
+
clearSort: () => void;
|
|
20
|
+
sortData: (data: T[], columns: ColDef<T>[]) => T[];
|
|
21
|
+
};
|
|
22
|
+
export interface FilterModel {
|
|
23
|
+
[field: string]: {
|
|
24
|
+
filterType: string;
|
|
25
|
+
type?: string;
|
|
26
|
+
filter?: string | number;
|
|
27
|
+
filterTo?: string | number;
|
|
28
|
+
values?: string[];
|
|
29
|
+
dateFrom?: string;
|
|
30
|
+
dateTo?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export declare function useFiltering<T>(initialFilters?: FilterModel): {
|
|
34
|
+
filterModel: FilterModel;
|
|
35
|
+
setFilterModel: React.Dispatch<React.SetStateAction<FilterModel>>;
|
|
36
|
+
quickFilterText: string;
|
|
37
|
+
setQuickFilterText: React.Dispatch<React.SetStateAction<string>>;
|
|
38
|
+
setColumnFilter: (field: string, filter: FilterModel[string] | null) => void;
|
|
39
|
+
clearFilters: () => void;
|
|
40
|
+
isFilterActive: (field: string) => boolean;
|
|
41
|
+
hasActiveFilters: boolean;
|
|
42
|
+
filterData: (data: T[], columns: ColDef<T>[]) => T[];
|
|
43
|
+
};
|
|
44
|
+
export declare function usePagination(totalRows: number, initialPageSize?: number, initialPage?: number): {
|
|
45
|
+
currentPage: number;
|
|
46
|
+
pageSize: number;
|
|
47
|
+
totalPages: number;
|
|
48
|
+
totalRows: number;
|
|
49
|
+
startRow: number;
|
|
50
|
+
endRow: number;
|
|
51
|
+
goToPage: (page: number) => void;
|
|
52
|
+
goToNextPage: () => void;
|
|
53
|
+
goToPreviousPage: () => void;
|
|
54
|
+
goToFirstPage: () => void;
|
|
55
|
+
goToLastPage: () => void;
|
|
56
|
+
changePageSize: (size: number) => void;
|
|
57
|
+
paginateData: <T>(data: T[]) => T[];
|
|
58
|
+
setCurrentPage: React.Dispatch<React.SetStateAction<number>>;
|
|
59
|
+
setPageSize: React.Dispatch<React.SetStateAction<number>>;
|
|
60
|
+
};
|
|
61
|
+
export declare function useRowSelection<T>(data: T[], getRowId: (row: T) => string, mode?: 'single' | 'multiple', isRowSelectable?: (node: RowNode<T>) => boolean): {
|
|
62
|
+
selectedIds: Set<string>;
|
|
63
|
+
setSelectedIds: React.Dispatch<React.SetStateAction<Set<string>>>;
|
|
64
|
+
isSelected: (id: string) => boolean;
|
|
65
|
+
toggleRow: (row: T, index: number) => void;
|
|
66
|
+
selectAll: () => void;
|
|
67
|
+
deselectAll: () => void;
|
|
68
|
+
selectRows: (rows: T[]) => void;
|
|
69
|
+
isAllSelected: boolean;
|
|
70
|
+
isIndeterminate: boolean;
|
|
71
|
+
selectedRows: T[];
|
|
72
|
+
selectedNodes: RowNode<T>[];
|
|
73
|
+
};
|
|
74
|
+
export declare function useRowExpansion<T>(getRowId: (row: T) => string, defaultExpanded?: number): {
|
|
75
|
+
expandedIds: Set<string>;
|
|
76
|
+
setExpandedIds: React.Dispatch<React.SetStateAction<Set<string>>>;
|
|
77
|
+
isExpanded: (id: string) => boolean;
|
|
78
|
+
toggleExpand: (row: T) => void;
|
|
79
|
+
expandAll: (rows: T[]) => void;
|
|
80
|
+
collapseAll: () => void;
|
|
81
|
+
setExpanded: (id: string, expanded: boolean) => void;
|
|
82
|
+
};
|
|
83
|
+
export declare function useColumnState<T>(columns: ColDef<T>[], persistKey?: string): {
|
|
84
|
+
columnState: ColumnState[];
|
|
85
|
+
setColumnState: React.Dispatch<React.SetStateAction<ColumnState[]>>;
|
|
86
|
+
getColumnState: (colId: string) => ColumnState | undefined;
|
|
87
|
+
setColumnVisible: (colIdOrColumn: string | Column<T>, visible: boolean) => void;
|
|
88
|
+
setColumnWidth: (colIdOrColumn: string | Column<T>, width: number) => void;
|
|
89
|
+
setColumnPinned: (colIdOrColumn: string | Column<T>, pinned: 'left' | 'right' | null) => void;
|
|
90
|
+
moveColumn: (colIdOrColumn: string | Column<T>, toIndex: number) => void;
|
|
91
|
+
resetColumnState: () => void;
|
|
92
|
+
processedColumns: ColDef<T>[];
|
|
93
|
+
visibleColumns: ColDef<T>[];
|
|
94
|
+
};
|
|
95
|
+
export interface EditingCell {
|
|
96
|
+
rowId: string;
|
|
97
|
+
colId: string;
|
|
98
|
+
rowIndex: number;
|
|
99
|
+
value: any;
|
|
100
|
+
}
|
|
101
|
+
export declare function useCellEditing<T>(onCellValueChanged?: (params: {
|
|
102
|
+
data: T;
|
|
103
|
+
oldValue: any;
|
|
104
|
+
newValue: any;
|
|
105
|
+
colId: string;
|
|
106
|
+
rowIndex: number;
|
|
107
|
+
}) => void): {
|
|
108
|
+
editingCell: EditingCell | null;
|
|
109
|
+
startEditing: (rowId: string, colId: string, rowIndex: number, value: any) => void;
|
|
110
|
+
stopEditing: (cancel?: boolean, newValue?: any) => void;
|
|
111
|
+
isEditing: (rowId: string, colId: string) => boolean;
|
|
112
|
+
undo: () => {
|
|
113
|
+
data: T;
|
|
114
|
+
field: string;
|
|
115
|
+
oldValue: any;
|
|
116
|
+
newValue: any;
|
|
117
|
+
} | null;
|
|
118
|
+
redo: () => {
|
|
119
|
+
data: T;
|
|
120
|
+
field: string;
|
|
121
|
+
oldValue: any;
|
|
122
|
+
newValue: any;
|
|
123
|
+
} | null;
|
|
124
|
+
canUndo: boolean;
|
|
125
|
+
canRedo: boolean;
|
|
126
|
+
};
|
|
127
|
+
export interface GroupedRow<T> {
|
|
128
|
+
isGroup: true;
|
|
129
|
+
groupValue: any;
|
|
130
|
+
groupField: string;
|
|
131
|
+
children: (T | GroupedRow<T>)[];
|
|
132
|
+
level: number;
|
|
133
|
+
expanded: boolean;
|
|
134
|
+
aggregations?: Record<string, any>;
|
|
135
|
+
}
|
|
136
|
+
export declare function useRowGrouping<T extends object>(data: T[], groupByFields: string[], aggregations?: Record<string, (values: any[]) => any>): {
|
|
137
|
+
groupedData: (T | GroupedRow<T>)[];
|
|
138
|
+
flattenedData: (T | GroupedRow<T>)[];
|
|
139
|
+
expandedGroups: Set<string>;
|
|
140
|
+
toggleGroup: (field: string, value: any, level: number) => void;
|
|
141
|
+
expandAllGroups: () => void;
|
|
142
|
+
collapseAllGroups: () => void;
|
|
143
|
+
};
|
|
144
|
+
export declare function useVirtualScrolling<T>(data: T[], rowHeight: number, containerHeight: number, overscan?: number): {
|
|
145
|
+
totalHeight: number;
|
|
146
|
+
visibleData: T[];
|
|
147
|
+
visibleRange: {
|
|
148
|
+
startIndex: number;
|
|
149
|
+
endIndex: number;
|
|
150
|
+
};
|
|
151
|
+
offsetY: number;
|
|
152
|
+
handleScroll: (e: React.UIEvent<HTMLElement>) => void;
|
|
153
|
+
scrollTop: number;
|
|
154
|
+
};
|
|
155
|
+
export declare function useClipboard<T>(): {
|
|
156
|
+
copyToClipboard: (data: T[], columns: ColDef<T>[], includeHeaders?: boolean) => Promise<void>;
|
|
157
|
+
pasteFromClipboard: () => Promise<string[][]>;
|
|
158
|
+
};
|
|
159
|
+
export declare function useResponsive(breakpoint?: number): {
|
|
160
|
+
isMobile: boolean;
|
|
161
|
+
};
|
|
162
|
+
export interface ContextMenuState {
|
|
163
|
+
visible: boolean;
|
|
164
|
+
x: number;
|
|
165
|
+
y: number;
|
|
166
|
+
data?: any;
|
|
167
|
+
}
|
|
168
|
+
export declare function useContextMenu(): {
|
|
169
|
+
contextMenu: ContextMenuState;
|
|
170
|
+
showContextMenu: (x: number, y: number, data?: any) => void;
|
|
171
|
+
hideContextMenu: () => void;
|
|
172
|
+
};
|
|
173
|
+
export declare function useKeyboardNavigation<T>(data: T[], columns: ColDef<T>[], onCellSelect?: (rowIndex: number, colId: string) => void, onEnter?: (rowIndex: number, colId: string) => void): {
|
|
174
|
+
focusedCell: {
|
|
175
|
+
rowIndex: number;
|
|
176
|
+
colIndex: number;
|
|
177
|
+
} | null;
|
|
178
|
+
setFocusedCell: React.Dispatch<React.SetStateAction<{
|
|
179
|
+
rowIndex: number;
|
|
180
|
+
colIndex: number;
|
|
181
|
+
} | null>>;
|
|
182
|
+
handleKeyDown: (e: KeyboardEvent) => void;
|
|
183
|
+
};
|
|
184
|
+
export declare function getNestedValue(obj: any, path: string): any;
|
|
185
|
+
export declare function setNestedValue(obj: any, path: string, value: any): any;
|
|
186
|
+
export declare function createRowNode<T>(data: T, index: number, id?: string): RowNode<T>;
|
|
187
|
+
export declare const aggregations: {
|
|
188
|
+
sum: (values: number[]) => number;
|
|
189
|
+
avg: (values: number[]) => number;
|
|
190
|
+
min: (values: number[]) => number;
|
|
191
|
+
max: (values: number[]) => number;
|
|
192
|
+
count: (values: any[]) => number;
|
|
193
|
+
first: <T>(values: T[]) => T;
|
|
194
|
+
last: <T_1>(values: T_1[]) => T_1;
|
|
195
|
+
};
|
|
196
|
+
export declare function exportToCsv<T>(data: T[], columns: ColDef<T>[], filename?: string): void;
|