ia-table 0.9.2 → 0.10.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,272 @@
1
+ // SmartGrid API Type Definitions
2
+
3
+ import {
4
+ SmartGridInfiniteCache,
5
+ SmartGridInfiniteRowModel,
6
+ } from "./cache.type";
7
+ import { SmartGridColumnDefinition } from "./columns.type";
8
+ import {
9
+ SmartGridFilterModel,
10
+ SmartGridRowNode,
11
+ SmartGridSortDirection,
12
+ SmartGridSortModel,
13
+ SmartGridUpdateData,
14
+ } from "./common.type";
15
+ import { SmartGridStateContext } from "./reducer.type";
16
+
17
+ export type SmartGridModelType = "normal" | "serverSide" | "infinite";
18
+
19
+ export type SmartGridPinnedType = "left" | "right" | null;
20
+
21
+ export type SmartGridFloatingType = "top" | "bottom" | null;
22
+
23
+ export interface SmartGridRowData {
24
+ [key: string]: unknown;
25
+ id?: string | number;
26
+ isChildRow?: boolean;
27
+ isChildGroup?: boolean;
28
+ childIndex?: number;
29
+ groupingLevel?: number;
30
+ level?: number;
31
+ parentRowIndex?: number;
32
+ parentRowData?: SmartGridRowData;
33
+ __parentPath?: string;
34
+ _rowHeight?: number;
35
+ _isPinnedTop?: boolean;
36
+ _isPinnedBottom?: boolean;
37
+ __isAggregationRow?: boolean;
38
+ __parentId?: string | number;
39
+ }
40
+
41
+ export interface SmartGridColumnState {
42
+ colId: string;
43
+ hide: boolean;
44
+ width: number;
45
+ sort: SmartGridSortDirection | null;
46
+ filter: SmartGridFilterModel | null;
47
+ }
48
+
49
+ export interface SmartGridPaginationModel {
50
+ currentPage: number;
51
+ pageSize: number;
52
+ totalPages: number;
53
+ totalRecords: number;
54
+ }
55
+
56
+ export interface SmartGridDisplayedRowNode extends SmartGridRowNode {
57
+ rowIndex: number;
58
+ absoluteRowIndex: number;
59
+ originalData: SmartGridRowData;
60
+ rowHeight?: number;
61
+ }
62
+
63
+ export interface SmartGridCacheState {
64
+ blockCount: number;
65
+ cache?: SmartGridInfiniteCache;
66
+ lastRowKnown: boolean;
67
+ rowCount: number;
68
+ status: string;
69
+ }
70
+
71
+ export interface SmartGridTableModel {
72
+ getData: () => SmartGridRowData[];
73
+ modelRef?: {
74
+ current?: SmartGridInfiniteRowModel;
75
+ };
76
+ infiniteCache: SmartGridInfiniteCache | null;
77
+ getColumnDefs: () => SmartGridColumnDefinition[];
78
+ getSortModel: () => SmartGridSortModel[];
79
+ getFilterModel: () => SmartGridFilterModel;
80
+ getType: () => SmartGridModelType;
81
+ getRowsToDisplay: () => number;
82
+ forEachNode: (
83
+ callback: (node: SmartGridRowNode, index: number) => void
84
+ ) => void;
85
+ getRowNode: (id: string | number) => SmartGridRowNode | null;
86
+ getSelectedRows: () => SmartGridRowData[];
87
+ getPaginationModel: () => SmartGridPaginationModel;
88
+ getColumnState: () => SmartGridColumnState[];
89
+ rowsToDisplay: SmartGridRowData[];
90
+ }
91
+
92
+ export interface SmartGridDisplayedColumn {
93
+ colDef: SmartGridColumnDefinition;
94
+ colId: string;
95
+ getColId: () => string;
96
+ isVisible: () => boolean;
97
+ isPinned: () => SmartGridPinnedType;
98
+ label: string;
99
+ }
100
+
101
+ export interface SmartGridSelectedCell {
102
+ colIndex: number;
103
+ column: SmartGridColumnDefinition;
104
+ data: SmartGridRowData;
105
+ field: string;
106
+ rowId: string | number;
107
+ rowIndex: number;
108
+ value: unknown;
109
+ }
110
+
111
+ export interface SmartGridFocusedCell extends SmartGridSelectedCell {
112
+ floating: SmartGridFloatingType;
113
+ }
114
+
115
+ export interface SmartGridRefreshOptions {
116
+ purge?: boolean;
117
+ resetPage?: boolean;
118
+ userInitiated?: boolean;
119
+ }
120
+
121
+ export interface SmartGridNotification {
122
+ message: string;
123
+ type?: "success" | "error" | "warning" | "info";
124
+ duration?: number;
125
+ }
126
+
127
+ export interface SmartGridParamsNode {
128
+ rowIndex: number;
129
+ data: SmartGridRowData;
130
+ api: SmartGridAPI;
131
+ }
132
+
133
+ export interface SmartGridDisplayedRowAtIndex {
134
+ data: SmartGridRowData;
135
+ rowIndex: number;
136
+ node: SmartGridParamsNode;
137
+ api: SmartGridAPI;
138
+ }
139
+
140
+ export interface SmartGridCachedBlockData {
141
+ [blockId: string]: SmartGridRowData[];
142
+ }
143
+
144
+ export interface SmartGridCellValueChangedParams {
145
+ colDef: SmartGridColumnDefinition;
146
+ column: SmartGridColumnDefinition;
147
+ data: SmartGridRowData;
148
+ newValue: unknown;
149
+ node: {
150
+ data: SmartGridRowData;
151
+ id: string | number;
152
+ level: number;
153
+ parent?: SmartGridUpdateData;
154
+ rowIndex: number;
155
+ };
156
+ value: unknown;
157
+ }
158
+
159
+ export interface SmartGridCheckConfiguration {
160
+ checkedRows?: string[];
161
+ unCheckedRows?: string[];
162
+ checkAll?: boolean;
163
+ searchColumns?: {
164
+ [key: string]: SmartGridFilterModel[];
165
+ };
166
+ unCheckAll?: boolean;
167
+ }
168
+ export interface SmartGridOptions {
169
+ [key: string]: unknown;
170
+ }
171
+
172
+ export interface SmartGridGetRowDataParams {
173
+ data: SmartGridRowData;
174
+ rowIndex: number;
175
+ node: SmartGridParamsNode;
176
+ api: SmartGridAPI;
177
+ }
178
+ export interface SmartGridDisptach {
179
+ type: string;
180
+ payload?: unknown;
181
+ }
182
+
183
+ export interface SmartGridAPI {
184
+ getInfiniteRowModel: () => SmartGridInfiniteRowModel | null;
185
+ getInfiniteCache: () => SmartGridInfiniteCache | null;
186
+ getModel: () => SmartGridTableModel;
187
+ onCellValueChanged: (params: SmartGridCellValueChangedParams) => void;
188
+ getPrevAction: () => string;
189
+ setPrevAction: (value: string) => void;
190
+ getCheckConfiguration: () => SmartGridCheckConfiguration[];
191
+ setCheckConfiguration: (config: SmartGridCheckConfiguration[]) => void;
192
+ addToCheckConfiguration: (item: SmartGridCheckConfiguration) => void;
193
+ getIsSelectAllRecords: () => boolean;
194
+ setIsSelectAllRecords: (value: boolean) => void;
195
+ getSelectedRows: () => SmartGridRowData[];
196
+ setSelectedRows: (rowIds: (string | number)[]) => void;
197
+ clearSelection: () => void;
198
+ selectAll: () => void;
199
+ refreshCells: () => void;
200
+ getCache: () => SmartGridInfiniteCache | null;
201
+ getCacheState: () => SmartGridCacheState | null;
202
+ getInfiniteCacheInstance: () => SmartGridInfiniteCache | undefined;
203
+ refreshServerSideStore: (options?: SmartGridRefreshOptions) => void;
204
+ getCachedBlockData: () => SmartGridCachedBlockData;
205
+ logCacheSummary: () => void | null;
206
+ getCachedRowById: (id: string | number) => SmartGridRowData | null;
207
+ getRowNode: (key: string | number) => Partial<SmartGridRowNode>;
208
+ setVisibleRange: (startRow: number, endRow: number) => void;
209
+ refreshCache: (options?: SmartGridRefreshOptions) => boolean;
210
+ deselectAll: () => void;
211
+ getRenderedNodes: () => SmartGridDisplayedRowNode[];
212
+ gridOptionsWrapper: {
213
+ gridOptions: SmartGridOptions;
214
+ };
215
+ getDisplayedRowAtIndex: (
216
+ index: number,
217
+ wholeData?: SmartGridRowData[],
218
+ api?: Partial<SmartGridAPI>
219
+ ) => SmartGridDisplayedRowAtIndex | null;
220
+ getTableWidth: () => number;
221
+ sizeColumnsToFit: () => void;
222
+ setRowData: (newData: SmartGridRowData[]) => boolean | void;
223
+ forEachNode: (
224
+ callback: (node: SmartGridRowNode, index: number) => void
225
+ ) => void;
226
+ getColumnDefs: () => SmartGridColumnDefinition[];
227
+ getAllColumns: () => SmartGridColumnDefinition[];
228
+ setColumnDefs: (newColumns: SmartGridColumnDefinition) => void;
229
+ addEventListener: (event: string, listener: Function) => void;
230
+ removeEventListener: (event: string, listener: Function) => void;
231
+ getPinnedTopRow: () => SmartGridRowData[] | null;
232
+ setPinnedTopRowData: (rows: SmartGridRowData[]) => void;
233
+ getPinnedBottomRow: () => SmartGridRowData[] | null;
234
+ setPinnedBottomRowData: (rows: SmartGridRowData[]) => void;
235
+ getRowData: (
236
+ params: SmartGridGetRowDataParams,
237
+ columnName: string
238
+ ) => string | number | boolean;
239
+ tableId: string;
240
+ getFocusedCell: () => SmartGridFocusedCell | null;
241
+ getSelectedCells: () => SmartGridSelectedCell[];
242
+ getAllDisplayedColumns: () => SmartGridDisplayedColumn[];
243
+ getDisplayedRowCount: () => number;
244
+ setFocusedCell: (
245
+ rowIndex: number,
246
+ colKey: SmartGridColumnDefinition | string | number,
247
+ floating?: SmartGridFloatingType
248
+ ) => boolean;
249
+ ensureColumnVisible: (
250
+ colKey: SmartGridColumnDefinition | string | number
251
+ ) => boolean;
252
+ getColumnByField: (fieldName: string) => SmartGridColumnDefinition | null;
253
+ getTableInstance: () =>
254
+ | {
255
+ current?: HTMLElement;
256
+ }
257
+ | undefined;
258
+ getFilterModel: () => SmartGridFilterModel;
259
+ setFilterModel: (field: string, rules: SmartGridFilterModel) => void;
260
+ getTableDispatcher: () => (action: SmartGridDisptach) => void;
261
+ getTableStateContext: () => SmartGridStateContext;
262
+ showNotification: (notification: SmartGridNotification) => void;
263
+ hideNotification: () => void;
264
+ applySearch: () => void;
265
+ getCurrentPageData: () => SmartGridRowData[];
266
+ getWholeTableData: () => SmartGridRowData[];
267
+ flashCells: () => void;
268
+ redrawRows: () => void;
269
+ refreshClientSideRowModel: () => void;
270
+ resetRecentSearchChanges: () => void;
271
+ onFilterChanged: () => void;
272
+ }
@@ -0,0 +1,65 @@
1
+ import { SmartGridRowData } from "./api.type";
2
+
3
+ export type SmartGridCacheAnalytics = {
4
+ blockEvictions: number;
5
+ blockLoadTimestamps: number[];
6
+ blockLoads: number;
7
+ bytesLoaded: number;
8
+ cachePurges: number;
9
+ cacheRefreshes: number;
10
+ hits: number;
11
+ lastBlockLoadTime: number;
12
+ misses: number;
13
+ startTime: number;
14
+ totalBlockLoadTime: number;
15
+ };
16
+
17
+ export type SmartGridCacheBlockParams = Record<string, unknown>;
18
+
19
+ export type SmartGridCacheBlock = {
20
+ endRow: number;
21
+ id: number;
22
+ infiniteCache: SmartGridInfiniteCache;
23
+ lastAccessed: number;
24
+ loadStartedAt: number;
25
+ params: SmartGridCacheBlockParams;
26
+ parent: SmartGridInfiniteCache | null;
27
+ parentCache: SmartGridInfiniteCache | null;
28
+ rowNodes: {
29
+ data: SmartGridRowData;
30
+ id: number;
31
+ rowIndex: number;
32
+ }[];
33
+ rows: unknown;
34
+ startRow: number;
35
+ state: string;
36
+ version: number;
37
+ _inactiveForPageTransition: boolean;
38
+ _processingInProgress: boolean;
39
+ _targetPage: number;
40
+ };
41
+
42
+ export interface SmartGridInfiniteCache {
43
+ analytics: SmartGridCacheAnalytics;
44
+ blockCount: number;
45
+ blocks: Record<number, SmartGridCacheBlock>;
46
+ eventListeners: Record<"cacheUpdated", Function[]>;
47
+ lastRequestedPage: number;
48
+ lastRowIndexKnown: boolean;
49
+ params: SmartGridInfiniteCacheParams;
50
+ rowCount: number;
51
+ _currentRequestedPage: number;
52
+ }
53
+
54
+ export interface SmartGridInfiniteRowModel {
55
+ infiniteCache?: SmartGridInfiniteCache;
56
+ setViewportRange?: (startRow: number, endRow: number) => void;
57
+ logCacheSummary?: () => void;
58
+ [key: string]: unknown;
59
+ }
60
+
61
+ export interface SmartGridInfiniteCacheParams {
62
+ datasource: {
63
+ getWholeData: () => SmartGridRowData[];
64
+ };
65
+ }
@@ -0,0 +1,185 @@
1
+ import { CSSProperties } from "react";
2
+ import { SmartGridAPI, SmartGridRowData } from "./api.type";
3
+ import {
4
+ SmartGridNewSortModel,
5
+ SmartGridSortModel,
6
+ SmartGridUpdateData,
7
+ } from "./common.type";
8
+
9
+ export interface SmartGridValueFormatterParams {
10
+ value: unknown;
11
+ data: SmartGridRowData;
12
+ colDef: SmartGridColumnDefinition;
13
+ }
14
+ export interface SmartGridValueGetterParams {
15
+ data: SmartGridRowData;
16
+ node: {
17
+ data: SmartGridRowData;
18
+ };
19
+ colDef: SmartGridColumnDefinition;
20
+ column: SmartGridColumnDefinition;
21
+ api: SmartGridAPI;
22
+ columnApi?: unknown;
23
+ getValue: (field: string) => unknown;
24
+ }
25
+
26
+ export type SmartGridCellRenderer = {
27
+ value: unknown;
28
+ data: SmartGridRowData;
29
+ rowIndex: number;
30
+ colIndex: number;
31
+ column: SmartGridColumnDefinition;
32
+ colDef: SmartGridColumnDefinition;
33
+ node: {
34
+ data: SmartGridRowData;
35
+ rowIndex: number;
36
+ id: string | number;
37
+ parent: SmartGridUpdateData & {
38
+ id: string | number;
39
+ level: number;
40
+ setExpanded: () => void;
41
+ };
42
+ setDataValue: (colId: string, newValue: unknown) => void;
43
+ childrenMapped: Record<string, string>;
44
+ allLeafChildren: Record<string, string>;
45
+ group: boolean;
46
+ level: number;
47
+ childIndex: number;
48
+ isSelected: () => boolean;
49
+ isExpandable: () => boolean;
50
+ isExpanded: () => boolean;
51
+ };
52
+ api: SmartGridAPI;
53
+ eGridCell: React.HTMLAttributes<HTMLDivElement>;
54
+ wholeData: SmartGridRowData[];
55
+ actions: Record<string, unknown>;
56
+ setDataValue: (colId: string, newValue: unknown) => void;
57
+ };
58
+ export type SmartGridCellRendererParams = Record<string, unknown>;
59
+
60
+ export type SmartGridHeaderStyleParams = {
61
+ column: SmartGridColumnDefinition;
62
+ displayName: string;
63
+ enableSorting: boolean;
64
+ sortState: SmartGridNewSortModel;
65
+ onSort: (field: string, direction: string) => void;
66
+ isSearchable: boolean;
67
+ showSortIcon: boolean;
68
+ toggleSearchModal: (e: React.MouseEvent<HTMLElement>) => void;
69
+ hasFilters: boolean;
70
+ isExpandable: boolean;
71
+ onToggle: (field: string, isExpandable: boolean) => void;
72
+ api: SmartGridAPI;
73
+ availableWidth: number;
74
+ wrapHeaderText: boolean;
75
+ menuButtonRef: React.RefObject<HTMLElement>;
76
+ menuToggle: (e: React.MouseEvent<HTMLElement>) => void;
77
+ toggleAdvancedSeach: (value: boolean) => void;
78
+ };
79
+ export interface SmartGridColumnDefinition {
80
+ field: string;
81
+ headerName?: string;
82
+ column_name?: string;
83
+ label?: string;
84
+ width?: number;
85
+ minWidth?: number;
86
+ maxWidth?: number;
87
+ hide?: boolean;
88
+ hidden?: boolean;
89
+ pinned?: "left" | "right" | boolean | null;
90
+ is_frozen?: boolean;
91
+ children?: SmartGridColumnDefinition[];
92
+ parent_id?: string | number;
93
+ type?: string;
94
+ cellDataType?: string;
95
+ valueFormatter?: (params: SmartGridValueFormatterParams) => string;
96
+ valueGetter?: (params: SmartGridValueGetterParams) => unknown;
97
+ leftTotalWidth?: number;
98
+ originalWidth?: number;
99
+ isAutoWidth?: boolean;
100
+ filterable?: boolean;
101
+ isSortable?: boolean;
102
+ is_sortable?: boolean;
103
+ resizable?: boolean;
104
+ align?: "left" | "center" | "right";
105
+ cellRenderer?: string | ((params: SmartGridCellRenderer) => JSX.Element);
106
+ cellRendererParams?: SmartGridCellRendererParams;
107
+ cellClassName?: string;
108
+ cellStyle?: {
109
+ textAlign?: "left" | "center" | "right";
110
+ [key: string]: unknown;
111
+ };
112
+ autoHeight?: boolean;
113
+ wrapHeaderText?: boolean;
114
+ editable?: boolean;
115
+ is_editable?: boolean;
116
+ is_disabled?: boolean;
117
+ is_searchable?: boolean;
118
+ isSearchable?: boolean;
119
+ advanceSearchEnabled?: boolean;
120
+ sortable?: boolean;
121
+ rowGroup?: boolean;
122
+ enableRowGroup?: boolean;
123
+ rowGroupIndex?: number;
124
+ aggFunc?: string;
125
+ columnGroupShow?: "open" | "closed";
126
+ originalIndex?: number;
127
+ parentColumns?: string[];
128
+ hasChildren?: boolean;
129
+ hasAnyFrozenChildren?: boolean;
130
+ hasAnyRightPinnedChildren?: boolean;
131
+ isChildWithoutParent?: boolean;
132
+ colorClass?: string;
133
+ isLeaf?: boolean;
134
+ isStandalone?: boolean;
135
+ isWithEmptyHeaderName?: boolean;
136
+ isParentWithChildEmptyHeaderName?: boolean;
137
+ path?: string[];
138
+ parentField?: string | null;
139
+ originalFields?: string[];
140
+ colId?: string;
141
+ colSpan?: number;
142
+ rowSpan?: number;
143
+ comparator?: (
144
+ valueA: unknown,
145
+ valueB: unknown,
146
+ nodeA: unknown,
147
+ nodeB: unknown,
148
+ sortModel: SmartGridSortModel
149
+ ) => number;
150
+ headerTooltip?: string;
151
+ filter?: string | boolean;
152
+ filterParams?: {
153
+ filterOptions?: string[];
154
+ textCustomComparator?: (
155
+ filter: string,
156
+ value: unknown,
157
+ filterText: string
158
+ ) => boolean;
159
+ numberCustomComparator?: (filter: number, value: unknown) => boolean;
160
+ dateCustomComparator?: (
161
+ filterLocalDateAtMidnight: Date,
162
+ cellValue: string
163
+ ) => number;
164
+ comparator?: (filterValue: unknown, cellValue: unknown) => boolean;
165
+ [key: string]: unknown;
166
+ };
167
+ order_of_display?: number;
168
+ is_hidden?: boolean;
169
+ formatter?: string | null;
170
+ accessor?: string;
171
+ id?: string;
172
+ required?: boolean;
173
+ sub_headers?: SmartGridColumnDefinition[];
174
+ extra?: {
175
+ width?: number;
176
+ is_grouping_key?: boolean;
177
+ is_disabled?: boolean;
178
+ isDisabled?: boolean;
179
+ columnGroupShow?: "open" | "closed";
180
+ [key: string]: unknown;
181
+ };
182
+ headerComponent: React.FC<SmartGridHeaderStyleParams>;
183
+ headerStyle?: (params: SmartGridHeaderStyleParams) => CSSProperties;
184
+ [key: string]: unknown;
185
+ }
@@ -0,0 +1,62 @@
1
+ import { SmartGridRowData } from "./api.type";
2
+
3
+ export type SmartGridSortDirection = "asc" | "desc" | "none";
4
+
5
+ export type SmartGridUpdateData = {
6
+ data: SmartGridRowData;
7
+ setData: (data: SmartGridRowData) => void;
8
+ setDataValue: (field: string, value: unknown, callback?: () => void) => void;
9
+ };
10
+
11
+ export interface SmartGridRowNode extends SmartGridUpdateData {
12
+ id: string | number;
13
+ childIndex?: number;
14
+ selected: boolean;
15
+ rowIndex?: number;
16
+ absoluteRowIndex?: number;
17
+ originalData?: SmartGridRowData;
18
+ rowHeight?: number;
19
+ setSelected: (selected: boolean, clearSelection?: boolean) => void;
20
+ isGroup?: () => boolean;
21
+ }
22
+
23
+ export interface SmartGridOldSortModel {
24
+ colId: string;
25
+ sort: SmartGridSortDirection;
26
+ }
27
+
28
+ export interface SmartGridNewSortModel {
29
+ column: string;
30
+ order: string;
31
+ }
32
+
33
+ export type SmartGridSortModel =
34
+ | SmartGridOldSortModel
35
+ | SmartGridNewSortModel
36
+ | null;
37
+
38
+ export type SmartGridStringFilter = {
39
+ column: string;
40
+ pattern: string;
41
+ search_type: string;
42
+ operator?: string;
43
+ };
44
+
45
+ export type SmartGridRangeFilter = {
46
+ column: string;
47
+ min_val: number;
48
+ max_val: number;
49
+ search_type: string;
50
+ operator?: string;
51
+ };
52
+
53
+ export interface SmartGridFilterModel {
54
+ pattern: string;
55
+ search_type: string;
56
+ column?: string;
57
+ field?: string;
58
+ min_val?: number;
59
+ max_val?: number;
60
+ type?: string;
61
+ operator?: string;
62
+ }
@@ -0,0 +1,7 @@
1
+ // Export all types from all type files using wildcard exports
2
+ export * from "./api.type";
3
+ export * from "./cache.type";
4
+ export * from "./columns.type";
5
+ export * from "./common.type";
6
+ export * from "./reducer.type";
7
+ export * from "./table.type";
@@ -0,0 +1,3 @@
1
+ export interface SmartGridStateContext {
2
+ [key: string]: any;
3
+ }
@@ -0,0 +1,5 @@
1
+ declare module "*.svg" {
2
+ import React from "react";
3
+ const SVGComponent: React.FC<React.SVGProps<SVGSVGElement>>;
4
+ export default SVGComponent;
5
+ }