@gridsuite/commons-ui 0.77.2 → 0.79.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/dist/components/customAGGrid/customAggrid.js +2 -2
- package/dist/components/filter/explicitNaming/ExplicitNamingFilterForm.js +8 -3
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +1 -15
- package/dist/components/inputs/index.js +1 -2
- package/dist/components/inputs/reactHookForm/agGridTable/CustomAgGridTable.d.ts +3 -8
- package/dist/components/inputs/reactHookForm/agGridTable/CustomAgGridTable.js +4 -14
- package/dist/components/inputs/reactHookForm/agGridTable/index.js +2 -3
- package/dist/components/inputs/reactHookForm/index.js +1 -2
- package/dist/index.js +1 -15
- package/package.json +5 -7
- package/dist/components/muiVirtualizedTable/ColumnHeader.d.ts +0 -26
- package/dist/components/muiVirtualizedTable/ColumnHeader.js +0 -108
- package/dist/components/muiVirtualizedTable/KeyedColumnsRowIndexer.d.ts +0 -130
- package/dist/components/muiVirtualizedTable/KeyedColumnsRowIndexer.js +0 -521
- package/dist/components/muiVirtualizedTable/MuiVirtualizedTable.d.ts +0 -97
- package/dist/components/muiVirtualizedTable/MuiVirtualizedTable.js +0 -692
- package/dist/components/muiVirtualizedTable/index.d.ts +0 -8
- package/dist/components/muiVirtualizedTable/index.js +0 -15
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { ColumnProps } from 'react-virtualized';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
|
|
4
|
-
export interface RowProps {
|
|
5
|
-
notClickable?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export interface CustomColumnProps extends ColumnProps {
|
|
8
|
-
sortable?: boolean;
|
|
9
|
-
numeric?: boolean;
|
|
10
|
-
indexer?: KeyedColumnsRowIndexer;
|
|
11
|
-
label: string;
|
|
12
|
-
clickable?: boolean;
|
|
13
|
-
fractionDigits?: number;
|
|
14
|
-
unit?: number;
|
|
15
|
-
extra?: ReactElement;
|
|
16
|
-
nostat?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export declare enum ChangeWays {
|
|
19
|
-
SIMPLE = "Simple",
|
|
20
|
-
TAIL = "Tail",
|
|
21
|
-
AMEND = "Amend",
|
|
22
|
-
REMOVE = "Remove"
|
|
23
|
-
}
|
|
24
|
-
export interface ColStat {
|
|
25
|
-
imin?: number | null;
|
|
26
|
-
imax?: number | null;
|
|
27
|
-
seen?: any;
|
|
28
|
-
kept?: any;
|
|
29
|
-
}
|
|
30
|
-
export declare const noOpHelper: Readonly<{
|
|
31
|
-
debugName: "noOp";
|
|
32
|
-
maintainsStats: false;
|
|
33
|
-
initStat: () => undefined;
|
|
34
|
-
updateStat: (colStat: ColStat, value: number) => void;
|
|
35
|
-
accepts: (value: any, userParams: any[] | undefined, outerParams: any[] | undefined) => true;
|
|
36
|
-
}>;
|
|
37
|
-
export declare const collectibleHelper: Readonly<{
|
|
38
|
-
debugName: "collectible";
|
|
39
|
-
maintainsStats: true;
|
|
40
|
-
initStat: () => {
|
|
41
|
-
seen: {};
|
|
42
|
-
kept: {};
|
|
43
|
-
};
|
|
44
|
-
updateStat: (colStat: ColStat, cellValue: number, isForKeep: boolean) => void;
|
|
45
|
-
accepts: (value: number, userParams: any[] | undefined, outerParams: any[] | undefined) => boolean;
|
|
46
|
-
}>;
|
|
47
|
-
export declare const getHelper: (column?: CustomColumnProps) => Readonly<{
|
|
48
|
-
debugName: "noOp";
|
|
49
|
-
maintainsStats: false;
|
|
50
|
-
initStat: () => undefined;
|
|
51
|
-
updateStat: (colStat: ColStat, value: number) => void;
|
|
52
|
-
accepts: (value: any, userParams: any[] | undefined, outerParams: any[] | undefined) => true;
|
|
53
|
-
}> | Readonly<{
|
|
54
|
-
debugName: "num";
|
|
55
|
-
maintainsStats: true;
|
|
56
|
-
initStat: () => {
|
|
57
|
-
imin: null;
|
|
58
|
-
imax: null;
|
|
59
|
-
};
|
|
60
|
-
updateStat: (colStat: ColStat, value: number) => void;
|
|
61
|
-
accepts: (value: number, userParams: any[] | undefined, outerParams: any[] | undefined) => true;
|
|
62
|
-
}> | Readonly<{
|
|
63
|
-
debugName: "collectible";
|
|
64
|
-
maintainsStats: true;
|
|
65
|
-
initStat: () => {
|
|
66
|
-
seen: {};
|
|
67
|
-
kept: {};
|
|
68
|
-
};
|
|
69
|
-
updateStat: (colStat: ColStat, cellValue: number, isForKeep: boolean) => void;
|
|
70
|
-
accepts: (value: number, userParams: any[] | undefined, outerParams: any[] | undefined) => boolean;
|
|
71
|
-
}>;
|
|
72
|
-
export interface Preferences {
|
|
73
|
-
isThreeState: boolean;
|
|
74
|
-
singleColumnByDefault: boolean;
|
|
75
|
-
}
|
|
76
|
-
export interface FilteredRows {
|
|
77
|
-
rowAndOrigIndex: [RowProps, number][];
|
|
78
|
-
colsStats: Record<string, ColStat>;
|
|
79
|
-
rowsCount: number;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* A rows indexer for MuiVirtualizedTable to delegate to an instance of it
|
|
83
|
-
* for filtering, grouping and multi-column sorting via
|
|
84
|
-
* a view index to model index array.
|
|
85
|
-
*/
|
|
86
|
-
export declare class KeyedColumnsRowIndexer {
|
|
87
|
-
static get CHANGE_WAYS(): typeof ChangeWays;
|
|
88
|
-
versionSetter: ((version: number) => void) | null;
|
|
89
|
-
byColFilter: Record<string, {
|
|
90
|
-
userParams?: any[];
|
|
91
|
-
outerParams?: any[];
|
|
92
|
-
}> | null;
|
|
93
|
-
byRowFilter: ((row: RowProps) => boolean) | null;
|
|
94
|
-
delegatorCallback: ((instance: KeyedColumnsRowIndexer, callback: (input: any) => void) => void) | null;
|
|
95
|
-
filterVersion: number;
|
|
96
|
-
groupingCount: number;
|
|
97
|
-
indirectionStatus: string | null;
|
|
98
|
-
isThreeState: boolean;
|
|
99
|
-
lastUsedRank: number;
|
|
100
|
-
singleColumnByDefault: boolean;
|
|
101
|
-
sortingState: [string, string | undefined][] | null;
|
|
102
|
-
version: number;
|
|
103
|
-
constructor(isThreeState?: boolean, singleColumnByDefault?: boolean, delegatorCallback?: null, versionSetter?: ((version: number) => void) | null);
|
|
104
|
-
hasVersionSetter: () => boolean;
|
|
105
|
-
getVersion: () => number;
|
|
106
|
-
bumpVersion: (isFilter?: boolean) => void;
|
|
107
|
-
updatePreferences: (preferences: Preferences) => boolean;
|
|
108
|
-
preFilterRowMapping: (columns: CustomColumnProps[], rows: RowProps[], rowFilter: (row: RowProps) => boolean) => FilteredRows | null;
|
|
109
|
-
makeGroupAndSortIndirector: (preFilteredRowPairs: FilteredRows | null, columns: CustomColumnProps[]) => number[] | null;
|
|
110
|
-
getSortingAsKeyAndCodedRank: () => (string | number)[][];
|
|
111
|
-
updateSortingFromUser: (colKey: string, change_way: ChangeWays) => boolean;
|
|
112
|
-
codedRankByColumnIndex: (columns: CustomColumnProps[]) => number[] | null;
|
|
113
|
-
columnSortingSignedRank: (colKey: string) => number;
|
|
114
|
-
highestCodedColumn: (columns: CustomColumnProps[]) => number;
|
|
115
|
-
getColFilterParams: (colKey: string | null, isForUser: boolean) => any[] | undefined;
|
|
116
|
-
setColFilterParams: (colKey: string | null, params: any[] | null, isForUser: boolean) => boolean;
|
|
117
|
-
getColFilterOuterParams: (colKey: string | null) => any[] | undefined;
|
|
118
|
-
setColFilterOuterParams: (colKey: string, outerParams: any[]) => boolean;
|
|
119
|
-
getColFilterUserParams: (colKey: string | null) => any[] | undefined;
|
|
120
|
-
setColFilterUserParams: (colKey: string | null, params: any[] | null) => boolean;
|
|
121
|
-
getUserFiltering: () => Record<string, object>;
|
|
122
|
-
updateRowFiltering: (rowFilterFunc: (row: RowProps) => boolean) => void;
|
|
123
|
-
}
|
|
124
|
-
export declare const forTesting: {
|
|
125
|
-
codedColumnsFromKeyAndDirection: (keyAndDirections: [
|
|
126
|
-
string,
|
|
127
|
-
string | undefined
|
|
128
|
-
][] | null, columns: CustomColumnProps[]) => number[] | null;
|
|
129
|
-
makeCompositeComparatorFromCodedColumns: (codedColumns: number[] | null, columns: CustomColumnProps[], rowExtractor: (row: [Record<string, number | string | undefined>, number][]) => Record<string, number | string | undefined>) => (row_a_i: [Record<string, number | string | undefined>, number][], row_b_i: [Record<string, number | string | undefined>, number][]) => number;
|
|
130
|
-
};
|
|
@@ -1,521 +0,0 @@
|
|
|
1
|
-
import { equalsArray } from "../../utils/algos.js";
|
|
2
|
-
var ChangeWays = /* @__PURE__ */ ((ChangeWays2) => {
|
|
3
|
-
ChangeWays2["SIMPLE"] = "Simple";
|
|
4
|
-
ChangeWays2["TAIL"] = "Tail";
|
|
5
|
-
ChangeWays2["AMEND"] = "Amend";
|
|
6
|
-
ChangeWays2["REMOVE"] = "Remove";
|
|
7
|
-
return ChangeWays2;
|
|
8
|
-
})(ChangeWays || {});
|
|
9
|
-
const noOpHelper = Object.freeze({
|
|
10
|
-
debugName: "noOp",
|
|
11
|
-
maintainsStats: false,
|
|
12
|
-
initStat: () => void 0,
|
|
13
|
-
updateStat: (colStat, value) => {
|
|
14
|
-
},
|
|
15
|
-
accepts: (value, userParams, outerParams) => {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const numericHelper = Object.freeze({
|
|
20
|
-
debugName: "num",
|
|
21
|
-
maintainsStats: true,
|
|
22
|
-
initStat: () => {
|
|
23
|
-
return { imin: null, imax: null };
|
|
24
|
-
},
|
|
25
|
-
updateStat: (colStat, value) => {
|
|
26
|
-
if (colStat.imin === void 0 || colStat.imin === null || colStat.imin > value) {
|
|
27
|
-
colStat.imin = value;
|
|
28
|
-
}
|
|
29
|
-
if (colStat.imax === void 0 || colStat.imax === null || colStat.imax < value) {
|
|
30
|
-
colStat.imax = value;
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
accepts: (value, userParams, outerParams) => {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const collectibleHelper = Object.freeze({
|
|
38
|
-
debugName: "collectible",
|
|
39
|
-
maintainsStats: true,
|
|
40
|
-
initStat: () => {
|
|
41
|
-
return { seen: {}, kept: {} };
|
|
42
|
-
},
|
|
43
|
-
updateStat: (colStat, cellValue, isForKeep) => {
|
|
44
|
-
const m = isForKeep ? colStat.kept : colStat.seen;
|
|
45
|
-
if (!m[cellValue]) {
|
|
46
|
-
m[cellValue] = 1;
|
|
47
|
-
} else {
|
|
48
|
-
m[cellValue] += 1;
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
accepts: (value, userParams, outerParams) => {
|
|
52
|
-
return !userParams || userParams.some((v) => v === value);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
const getHelper = (column) => {
|
|
56
|
-
if (column == null ? void 0 : column.numeric) {
|
|
57
|
-
return numericHelper;
|
|
58
|
-
}
|
|
59
|
-
if (!(column == null ? void 0 : column.nostat)) {
|
|
60
|
-
return collectibleHelper;
|
|
61
|
-
}
|
|
62
|
-
return noOpHelper;
|
|
63
|
-
};
|
|
64
|
-
const giveDirSignFor = (fuzzySign) => {
|
|
65
|
-
if (fuzzySign < 0) {
|
|
66
|
-
return -1;
|
|
67
|
-
}
|
|
68
|
-
if (fuzzySign > 0) {
|
|
69
|
-
return 1;
|
|
70
|
-
}
|
|
71
|
-
if (fuzzySign === "asc") {
|
|
72
|
-
return 1;
|
|
73
|
-
}
|
|
74
|
-
if (fuzzySign === "desc") {
|
|
75
|
-
return -1;
|
|
76
|
-
}
|
|
77
|
-
return 0;
|
|
78
|
-
};
|
|
79
|
-
const codedColumnsFromKeyAndDirection = (keyAndDirections, columns) => {
|
|
80
|
-
if (!keyAndDirections) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
let ret = [];
|
|
84
|
-
const columIndexByKey = {};
|
|
85
|
-
for (let colIdx = 0; colIdx < columns.length; colIdx++) {
|
|
86
|
-
const col = columns[colIdx];
|
|
87
|
-
const colKey = col.dataKey;
|
|
88
|
-
columIndexByKey[colKey] = colIdx;
|
|
89
|
-
}
|
|
90
|
-
ret = keyAndDirections.map((knd) => {
|
|
91
|
-
const colKey = knd[0];
|
|
92
|
-
const dir = knd[1];
|
|
93
|
-
const colIdx = columIndexByKey[colKey];
|
|
94
|
-
if (colIdx === void 0) {
|
|
95
|
-
return 0;
|
|
96
|
-
}
|
|
97
|
-
const sign = giveDirSignFor(dir);
|
|
98
|
-
return (colIdx + 1) * sign;
|
|
99
|
-
});
|
|
100
|
-
return ret;
|
|
101
|
-
};
|
|
102
|
-
const compareValue = (a, b, isNumeric, undefSign = -1) => {
|
|
103
|
-
if (a === void 0 && b === void 0) {
|
|
104
|
-
return 0;
|
|
105
|
-
}
|
|
106
|
-
if (a === void 0) {
|
|
107
|
-
return undefSign;
|
|
108
|
-
}
|
|
109
|
-
if (b === void 0) {
|
|
110
|
-
return -undefSign;
|
|
111
|
-
}
|
|
112
|
-
if (!isNumeric) {
|
|
113
|
-
return `${a}`.localeCompare(b);
|
|
114
|
-
}
|
|
115
|
-
if (Number.isNaN(a)) {
|
|
116
|
-
return Number.isNaN(b) ? 0 : 1;
|
|
117
|
-
}
|
|
118
|
-
if (Number.isNaN(b)) {
|
|
119
|
-
return -1;
|
|
120
|
-
}
|
|
121
|
-
return Math.sign(Number(a) - Number(b));
|
|
122
|
-
};
|
|
123
|
-
const makeCompositeComparatorFromCodedColumns = (codedColumns, columns, rowExtractor) => {
|
|
124
|
-
return (row_a_i, row_b_i) => {
|
|
125
|
-
const rowA = rowExtractor(row_a_i);
|
|
126
|
-
const rowB = rowExtractor(row_b_i);
|
|
127
|
-
codedColumns.map((cc) => {
|
|
128
|
-
const i = Math.abs(cc) - 1;
|
|
129
|
-
const mul = Math.sign(cc);
|
|
130
|
-
const col = columns[i];
|
|
131
|
-
const key = col.dataKey;
|
|
132
|
-
const sgn = compareValue(rowA[key], rowB[key], col.numeric);
|
|
133
|
-
if (sgn) {
|
|
134
|
-
return mul * sgn;
|
|
135
|
-
}
|
|
136
|
-
return void 0;
|
|
137
|
-
});
|
|
138
|
-
return 0;
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
const canonicalForSign = (dirSign) => {
|
|
142
|
-
if (dirSign > 0) {
|
|
143
|
-
return "asc";
|
|
144
|
-
}
|
|
145
|
-
if (dirSign < 0) {
|
|
146
|
-
return "desc";
|
|
147
|
-
}
|
|
148
|
-
return void 0;
|
|
149
|
-
};
|
|
150
|
-
const groupRows = (groupingColumnsCount, columns, indexedArray) => {
|
|
151
|
-
const groupingComparator = makeCompositeComparatorFromCodedColumns(
|
|
152
|
-
Array(groupingColumnsCount).map((x, i) => i + 1),
|
|
153
|
-
columns,
|
|
154
|
-
// @ts-ignore does not match other pattern
|
|
155
|
-
(ar) => ar[0]
|
|
156
|
-
);
|
|
157
|
-
indexedArray.sort(groupingComparator);
|
|
158
|
-
const groups = [];
|
|
159
|
-
let prevSlice = null;
|
|
160
|
-
let inBuildGroup = [];
|
|
161
|
-
groups.push(inBuildGroup);
|
|
162
|
-
indexedArray.forEach((p) => {
|
|
163
|
-
const nextSlice = p[0].slice(0, groupingColumnsCount);
|
|
164
|
-
if (prevSlice === null || !equalsArray(prevSlice, nextSlice)) {
|
|
165
|
-
inBuildGroup = [];
|
|
166
|
-
groups.push(inBuildGroup);
|
|
167
|
-
}
|
|
168
|
-
inBuildGroup.push(p);
|
|
169
|
-
prevSlice = nextSlice;
|
|
170
|
-
});
|
|
171
|
-
return groups;
|
|
172
|
-
};
|
|
173
|
-
const groupAndSort = (preFilteredRowPairs, codedColumns, groupingColumnsCount, columns) => {
|
|
174
|
-
const nothingToDo = !codedColumns && !groupingColumnsCount;
|
|
175
|
-
let indexedArray = preFilteredRowPairs.rowAndOrigIndex;
|
|
176
|
-
const noOutFiltered = preFilteredRowPairs.rowsCount === indexedArray.length;
|
|
177
|
-
if (nothingToDo && noOutFiltered) {
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
if (!nothingToDo) {
|
|
181
|
-
indexedArray = [...indexedArray];
|
|
182
|
-
}
|
|
183
|
-
if (nothingToDo)
|
|
184
|
-
;
|
|
185
|
-
else if (!groupingColumnsCount) {
|
|
186
|
-
const sortingComparator = makeCompositeComparatorFromCodedColumns(
|
|
187
|
-
codedColumns,
|
|
188
|
-
columns,
|
|
189
|
-
// @ts-ignore I don't know how to fix this one
|
|
190
|
-
(ar) => ar[0]
|
|
191
|
-
);
|
|
192
|
-
indexedArray.sort(sortingComparator);
|
|
193
|
-
} else {
|
|
194
|
-
const groups = groupRows(groupingColumnsCount, columns, indexedArray);
|
|
195
|
-
const interGroupSortingComparator = makeCompositeComparatorFromCodedColumns(
|
|
196
|
-
codedColumns,
|
|
197
|
-
columns,
|
|
198
|
-
(ar) => ar[0][0]
|
|
199
|
-
);
|
|
200
|
-
groups.sort(interGroupSortingComparator);
|
|
201
|
-
const intraGroupSortingComparator = makeCompositeComparatorFromCodedColumns(
|
|
202
|
-
codedColumns,
|
|
203
|
-
columns,
|
|
204
|
-
// @ts-ignore I don't know how to fix this one
|
|
205
|
-
(ar) => ar[0]
|
|
206
|
-
);
|
|
207
|
-
indexedArray = [];
|
|
208
|
-
groups.forEach((group) => {
|
|
209
|
-
group.sort(intraGroupSortingComparator);
|
|
210
|
-
indexedArray.push(...group);
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
return indexedArray;
|
|
214
|
-
};
|
|
215
|
-
class KeyedColumnsRowIndexer {
|
|
216
|
-
constructor(isThreeState = true, singleColumnByDefault = false, delegatorCallback = null, versionSetter = null) {
|
|
217
|
-
this.hasVersionSetter = () => {
|
|
218
|
-
return !!this.versionSetter;
|
|
219
|
-
};
|
|
220
|
-
this.getVersion = () => {
|
|
221
|
-
return this.version;
|
|
222
|
-
};
|
|
223
|
-
this.bumpVersion = (isFilter = false) => {
|
|
224
|
-
this.version += 1;
|
|
225
|
-
if (isFilter) {
|
|
226
|
-
this.filterVersion = this.version;
|
|
227
|
-
}
|
|
228
|
-
if (this.delegatorCallback) {
|
|
229
|
-
this.indirectionStatus = "to sort";
|
|
230
|
-
this.delegatorCallback(this, (updated_ok) => {
|
|
231
|
-
this.indirectionStatus = updated_ok ? "done" : "no_luck";
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
if (this.versionSetter) {
|
|
235
|
-
this.versionSetter(this.version);
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
this.updatePreferences = (preferences) => {
|
|
239
|
-
if (preferences.isThreeState === this.isThreeState && preferences.singleColumnByDefault === this.singleColumnByDefault) {
|
|
240
|
-
return false;
|
|
241
|
-
}
|
|
242
|
-
if (preferences.isThreeState !== this.isThreeState) {
|
|
243
|
-
this.isThreeState = preferences.isThreeState;
|
|
244
|
-
}
|
|
245
|
-
if (preferences.singleColumnByDefault !== this.singleColumnByDefault) {
|
|
246
|
-
this.singleColumnByDefault = preferences.singleColumnByDefault;
|
|
247
|
-
}
|
|
248
|
-
this.bumpVersion();
|
|
249
|
-
return true;
|
|
250
|
-
};
|
|
251
|
-
this.preFilterRowMapping = (columns, rows, rowFilter) => {
|
|
252
|
-
var _a;
|
|
253
|
-
if (!(rows == null ? void 0 : rows.length) || !(columns == null ? void 0 : columns.length)) {
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
const ri = [];
|
|
257
|
-
const cs = {};
|
|
258
|
-
columns.forEach((col) => {
|
|
259
|
-
const helper = getHelper(col);
|
|
260
|
-
const colStat = helper.initStat();
|
|
261
|
-
if (colStat) {
|
|
262
|
-
cs[col.dataKey] = colStat;
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
for (let rowIdx = 0; rowIdx < rows.length; rowIdx++) {
|
|
266
|
-
const row = rows[rowIdx];
|
|
267
|
-
let acceptsRow = true;
|
|
268
|
-
const acceptedOnRow = {};
|
|
269
|
-
for (let colIdx = 0; colIdx < columns.length; colIdx++) {
|
|
270
|
-
const col = columns[colIdx];
|
|
271
|
-
const helper = getHelper(col);
|
|
272
|
-
const colKey = col.dataKey;
|
|
273
|
-
const cellValue = row[colKey];
|
|
274
|
-
helper.updateStat(cs[colKey], cellValue, false);
|
|
275
|
-
const colFilterParams = (_a = this.byColFilter) == null ? void 0 : _a[colKey];
|
|
276
|
-
let acceptsCell = true;
|
|
277
|
-
if (colFilterParams) {
|
|
278
|
-
const up = colFilterParams.userParams;
|
|
279
|
-
const op = colFilterParams.outerParams;
|
|
280
|
-
if (!helper.accepts(cellValue, up, op)) {
|
|
281
|
-
acceptsCell = false;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
if (helper.maintainsStats && acceptsCell) {
|
|
285
|
-
acceptedOnRow[colIdx] = cellValue;
|
|
286
|
-
}
|
|
287
|
-
acceptsRow && (acceptsRow = acceptsCell);
|
|
288
|
-
}
|
|
289
|
-
if (acceptsRow && rowFilter) {
|
|
290
|
-
acceptsRow = rowFilter(row);
|
|
291
|
-
}
|
|
292
|
-
if (acceptsRow && this.byRowFilter) {
|
|
293
|
-
acceptsRow = this.byRowFilter(row);
|
|
294
|
-
}
|
|
295
|
-
if (acceptsRow) {
|
|
296
|
-
Object.entries(acceptedOnRow).forEach(([idx, value]) => {
|
|
297
|
-
const col = columns[Number(idx)];
|
|
298
|
-
const helper = getHelper(col);
|
|
299
|
-
helper.updateStat(cs[col.dataKey], value, true);
|
|
300
|
-
});
|
|
301
|
-
ri.push([row, rowIdx]);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return { rowAndOrigIndex: ri, colsStats: cs, rowsCount: rows.length };
|
|
305
|
-
};
|
|
306
|
-
this.makeGroupAndSortIndirector = (preFilteredRowPairs, columns) => {
|
|
307
|
-
if (!preFilteredRowPairs) {
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
const codedColumns = !this.sortingState ? null : codedColumnsFromKeyAndDirection(this.sortingState, columns);
|
|
311
|
-
const groupingColumnsCount = this.groupingCount;
|
|
312
|
-
const indexedArray = groupAndSort(preFilteredRowPairs, codedColumns, groupingColumnsCount, columns);
|
|
313
|
-
return !indexedArray ? null : indexedArray.map((k) => k[1]);
|
|
314
|
-
};
|
|
315
|
-
this.getSortingAsKeyAndCodedRank = () => {
|
|
316
|
-
if (!this.sortingState) {
|
|
317
|
-
return [];
|
|
318
|
-
}
|
|
319
|
-
return this.sortingState.map((kd, i) => {
|
|
320
|
-
const sign = giveDirSignFor(kd[1]);
|
|
321
|
-
const codedRank = sign * (i + 1);
|
|
322
|
-
return [kd[0], codedRank];
|
|
323
|
-
});
|
|
324
|
-
};
|
|
325
|
-
this.updateSortingFromUser = (colKey, change_way) => {
|
|
326
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
327
|
-
const keyAndDirections = this.sortingState;
|
|
328
|
-
if (change_way === "Remove") {
|
|
329
|
-
if (!keyAndDirections) {
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
332
|
-
const would = keyAndDirections.filter((p) => p[0] !== colKey);
|
|
333
|
-
if (would.length === keyAndDirections.length) {
|
|
334
|
-
return false;
|
|
335
|
-
}
|
|
336
|
-
this.sortingState = would.length ? would : null;
|
|
337
|
-
} else if (!keyAndDirections) {
|
|
338
|
-
this.sortingState = [[colKey, canonicalForSign(1)]];
|
|
339
|
-
this.lastUsedRank = 1;
|
|
340
|
-
} else {
|
|
341
|
-
const wasAtIdx = keyAndDirections.findIndex((p) => p[0] === colKey);
|
|
342
|
-
const wasFuzzyDir = wasAtIdx < 0 ? 0 : keyAndDirections[wasAtIdx][1];
|
|
343
|
-
const wasSignDir = giveDirSignFor(wasFuzzyDir);
|
|
344
|
-
if (change_way === "Simple") {
|
|
345
|
-
if (wasSignDir < 0 && this.isThreeState) {
|
|
346
|
-
if (((_a = this.sortingState) == null ? void 0 : _a.length) === 1) {
|
|
347
|
-
this.sortingState = null;
|
|
348
|
-
} else {
|
|
349
|
-
(_b = this.sortingState) == null ? void 0 : _b.splice(wasAtIdx, 1);
|
|
350
|
-
}
|
|
351
|
-
} else {
|
|
352
|
-
if (this.singleColumnByDefault || wasAtIdx < 0) {
|
|
353
|
-
this.sortingState = [];
|
|
354
|
-
} else {
|
|
355
|
-
(_c = this.sortingState) == null ? void 0 : _c.splice(wasAtIdx, 1);
|
|
356
|
-
}
|
|
357
|
-
const nextSign = wasSignDir ? -wasSignDir : 1;
|
|
358
|
-
const nextKD = [colKey, canonicalForSign(nextSign)];
|
|
359
|
-
(_d = this.sortingState) == null ? void 0 : _d.unshift(nextKD);
|
|
360
|
-
}
|
|
361
|
-
} else if (change_way === "Tail") {
|
|
362
|
-
if (wasAtIdx < 0) {
|
|
363
|
-
(_e = this.sortingState) == null ? void 0 : _e.push([colKey, canonicalForSign(1)]);
|
|
364
|
-
} else if (wasAtIdx !== keyAndDirections.length - 1) {
|
|
365
|
-
return false;
|
|
366
|
-
} else if (!(this.isThreeState && wasSignDir === -1)) {
|
|
367
|
-
this.sortingState[wasAtIdx][1] = canonicalForSign(-wasSignDir);
|
|
368
|
-
} else {
|
|
369
|
-
(_f = this.sortingState) == null ? void 0 : _f.splice(wasAtIdx, 1);
|
|
370
|
-
}
|
|
371
|
-
} else if (wasAtIdx < 0) {
|
|
372
|
-
if (this.lastUsedRank - 1 > // @ts-ignore could be undefined, how to handle this case ?
|
|
373
|
-
this.sortingState.length) {
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
(_g = this.sortingState) == null ? void 0 : _g.splice(this.lastUsedRank - 1, 0, [colKey, canonicalForSign(1)]);
|
|
377
|
-
} else if (!(this.isThreeState && wasSignDir === -1)) {
|
|
378
|
-
this.sortingState[wasAtIdx][1] = canonicalForSign(-wasSignDir);
|
|
379
|
-
} else {
|
|
380
|
-
this.lastUsedRank = wasAtIdx + 1;
|
|
381
|
-
(_h = this.sortingState) == null ? void 0 : _h.splice(wasAtIdx, 1);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
this.bumpVersion();
|
|
385
|
-
return true;
|
|
386
|
-
};
|
|
387
|
-
this.codedRankByColumnIndex = (columns) => {
|
|
388
|
-
return codedColumnsFromKeyAndDirection(this.sortingState, columns);
|
|
389
|
-
};
|
|
390
|
-
this.columnSortingSignedRank = (colKey) => {
|
|
391
|
-
var _a;
|
|
392
|
-
if (!((_a = this == null ? void 0 : this.sortingState) == null ? void 0 : _a.length)) {
|
|
393
|
-
return 0;
|
|
394
|
-
}
|
|
395
|
-
const idx = this.sortingState.findIndex((kd) => kd[0] === colKey);
|
|
396
|
-
if (idx < 0) {
|
|
397
|
-
return 0;
|
|
398
|
-
}
|
|
399
|
-
const colSorting = this.sortingState[idx];
|
|
400
|
-
return giveDirSignFor(colSorting[1]) * (idx + 1);
|
|
401
|
-
};
|
|
402
|
-
this.highestCodedColumn = (columns) => {
|
|
403
|
-
var _a;
|
|
404
|
-
if (!((_a = this == null ? void 0 : this.sortingState) == null ? void 0 : _a.length)) {
|
|
405
|
-
return 0;
|
|
406
|
-
}
|
|
407
|
-
const colSorting = this.sortingState[0];
|
|
408
|
-
const colKey = colSorting[0];
|
|
409
|
-
const idx = columns.findIndex((col) => col.dataKey === colKey);
|
|
410
|
-
if (idx < 0) {
|
|
411
|
-
return 0;
|
|
412
|
-
}
|
|
413
|
-
return giveDirSignFor(colSorting[1]) * (idx + 1);
|
|
414
|
-
};
|
|
415
|
-
this.getColFilterParams = (colKey, isForUser) => {
|
|
416
|
-
if (!colKey || !this.byColFilter) {
|
|
417
|
-
return void 0;
|
|
418
|
-
}
|
|
419
|
-
const colFilter = this.byColFilter[colKey];
|
|
420
|
-
if (!colFilter) {
|
|
421
|
-
return void 0;
|
|
422
|
-
}
|
|
423
|
-
return colFilter[isForUser ? "userParams" : "outerParams"];
|
|
424
|
-
};
|
|
425
|
-
this.setColFilterParams = (colKey, params, isForUser) => {
|
|
426
|
-
var _a;
|
|
427
|
-
if (!colKey) {
|
|
428
|
-
if (params) {
|
|
429
|
-
throw new Error("column key has to be defined");
|
|
430
|
-
}
|
|
431
|
-
return false;
|
|
432
|
-
}
|
|
433
|
-
const fieldName = isForUser ? "userParams" : "outerParams";
|
|
434
|
-
if (params) {
|
|
435
|
-
if (!this.byColFilter) {
|
|
436
|
-
this.byColFilter = {};
|
|
437
|
-
}
|
|
438
|
-
let colFilter = this.byColFilter[colKey];
|
|
439
|
-
if (!colFilter) {
|
|
440
|
-
colFilter = {};
|
|
441
|
-
this.byColFilter[colKey] = colFilter;
|
|
442
|
-
} else if (colFilter[fieldName] === params) {
|
|
443
|
-
return false;
|
|
444
|
-
}
|
|
445
|
-
colFilter[fieldName] = params;
|
|
446
|
-
} else {
|
|
447
|
-
if (!this.byColFilter) {
|
|
448
|
-
return false;
|
|
449
|
-
}
|
|
450
|
-
const otherFieldName = !isForUser ? "userParams" : "outerParams";
|
|
451
|
-
if ((_a = this.byColFilter[colKey]) == null ? void 0 : _a[otherFieldName]) {
|
|
452
|
-
delete this.byColFilter[colKey][fieldName];
|
|
453
|
-
} else {
|
|
454
|
-
delete this.byColFilter[colKey];
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
if (isForUser) {
|
|
458
|
-
this.bumpVersion(true);
|
|
459
|
-
}
|
|
460
|
-
return true;
|
|
461
|
-
};
|
|
462
|
-
this.getColFilterOuterParams = (colKey) => {
|
|
463
|
-
return this.getColFilterParams(colKey, false);
|
|
464
|
-
};
|
|
465
|
-
this.setColFilterOuterParams = (colKey, outerParams) => {
|
|
466
|
-
return this.setColFilterParams(colKey, outerParams, false);
|
|
467
|
-
};
|
|
468
|
-
this.getColFilterUserParams = (colKey) => {
|
|
469
|
-
return this.getColFilterParams(colKey, true);
|
|
470
|
-
};
|
|
471
|
-
this.setColFilterUserParams = (colKey, params) => {
|
|
472
|
-
return this.setColFilterParams(colKey, params, true);
|
|
473
|
-
};
|
|
474
|
-
this.getUserFiltering = () => {
|
|
475
|
-
const ret = {};
|
|
476
|
-
if (this.byColFilter) {
|
|
477
|
-
Object.entries(this.byColFilter).forEach(([k, v]) => {
|
|
478
|
-
if (!v.userParams) {
|
|
479
|
-
return;
|
|
480
|
-
}
|
|
481
|
-
ret[k] = [...v.userParams];
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
return ret;
|
|
485
|
-
};
|
|
486
|
-
this.updateRowFiltering = (rowFilterFunc) => {
|
|
487
|
-
if (typeof rowFilterFunc !== "function") {
|
|
488
|
-
throw new Error("row filter should be a function");
|
|
489
|
-
}
|
|
490
|
-
this.byRowFilter = rowFilterFunc;
|
|
491
|
-
this.bumpVersion();
|
|
492
|
-
};
|
|
493
|
-
this.versionSetter = versionSetter;
|
|
494
|
-
this.version = 0;
|
|
495
|
-
this.filterVersion = 0;
|
|
496
|
-
this.delegatorCallback = delegatorCallback;
|
|
497
|
-
this.indirectionStatus = null;
|
|
498
|
-
this.isThreeState = isThreeState;
|
|
499
|
-
this.singleColumnByDefault = singleColumnByDefault;
|
|
500
|
-
this.lastUsedRank = 1;
|
|
501
|
-
this.sortingState = null;
|
|
502
|
-
this.groupingCount = 0;
|
|
503
|
-
this.byColFilter = null;
|
|
504
|
-
this.byRowFilter = null;
|
|
505
|
-
}
|
|
506
|
-
static get CHANGE_WAYS() {
|
|
507
|
-
return ChangeWays;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
const forTesting = {
|
|
511
|
-
codedColumnsFromKeyAndDirection,
|
|
512
|
-
makeCompositeComparatorFromCodedColumns
|
|
513
|
-
};
|
|
514
|
-
export {
|
|
515
|
-
ChangeWays,
|
|
516
|
-
KeyedColumnsRowIndexer,
|
|
517
|
-
collectibleHelper,
|
|
518
|
-
forTesting,
|
|
519
|
-
getHelper,
|
|
520
|
-
noOpHelper
|
|
521
|
-
};
|