@gridsuite/commons-ui 0.46.0 → 0.47.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.
Files changed (183) hide show
  1. package/README.md +0 -17
  2. package/dist/components/AuthenticationRouter/AuthenticationRouter.js +147 -0
  3. package/dist/components/CardErrorBoundary/card-error-boundary.js +110 -0
  4. package/dist/components/ElementSearchDialog/element-search-dialog.js +139 -0
  5. package/dist/components/ElementSearchDialog/equipment-item.js +77 -0
  6. package/dist/components/ElementSearchDialog/tag-renderer.js +34 -0
  7. package/dist/components/FlatParameters/FlatParameters.js +411 -0
  8. package/dist/components/Login/Login.js +78 -0
  9. package/dist/components/Login/Logout.js +69 -0
  10. package/dist/components/MuiVirtualizedTable/ColumnHeader.js +127 -0
  11. package/dist/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +548 -0
  12. package/dist/components/MuiVirtualizedTable/MuiVirtualizedTable.js +790 -0
  13. package/dist/components/MultipleSelectionDialog/MultipleSelectionDialog.js +87 -0
  14. package/dist/components/OverflowableText/overflowable-text.js +87 -0
  15. package/dist/components/ReportViewer/filter-button.js +64 -0
  16. package/dist/components/ReportViewer/log-report-item.js +95 -0
  17. package/dist/components/ReportViewer/log-report.js +49 -0
  18. package/dist/components/ReportViewer/log-table.js +131 -0
  19. package/dist/components/ReportViewer/multi-select-list.js +40 -0
  20. package/dist/components/ReportViewer/report-item.js +112 -0
  21. package/dist/components/ReportViewer/report-tree-view-context.js +8 -0
  22. package/dist/components/ReportViewer/report-viewer.js +158 -0
  23. package/dist/components/ReportViewerDialog/report-viewer-dialog.js +61 -0
  24. package/dist/components/SignInCallbackHandler/SignInCallbackHandler.js +13 -0
  25. package/dist/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +16 -0
  26. package/dist/components/SnackbarProvider/SnackbarProvider.js +28 -0
  27. package/dist/components/TopBar/AboutDialog.js +467 -0
  28. package/dist/components/TopBar/GridLogo.js +71 -0
  29. package/dist/components/TopBar/TopBar.js +679 -0
  30. package/dist/components/TreeViewFinder/TreeViewFinder.js +288 -0
  31. package/dist/components/react-hook-form/autocomplete-input.js +96 -0
  32. package/dist/components/react-hook-form/booleans/boolean-input.js +49 -0
  33. package/dist/components/react-hook-form/booleans/checkbox-input.js +24 -0
  34. package/dist/components/react-hook-form/booleans/switch-input.js +24 -0
  35. package/dist/components/react-hook-form/error-management/error-input.js +42 -0
  36. package/dist/components/react-hook-form/error-management/field-error-alert.js +9 -0
  37. package/dist/components/react-hook-form/error-management/mid-form-error.js +20 -0
  38. package/dist/components/react-hook-form/numbers/float-input.js +51 -0
  39. package/dist/components/react-hook-form/numbers/integer-input.js +36 -0
  40. package/dist/components/react-hook-form/numbers/utils.js +10 -0
  41. package/dist/components/react-hook-form/radio-input.js +44 -0
  42. package/dist/components/react-hook-form/select-input.js +31 -0
  43. package/dist/components/react-hook-form/slider-input.js +43 -0
  44. package/dist/components/react-hook-form/text-input.js +94 -0
  45. package/dist/components/react-hook-form/utils/cancel-button.js +16 -0
  46. package/dist/components/react-hook-form/utils/field-label.js +12 -0
  47. package/dist/components/react-hook-form/utils/functions.js +36 -0
  48. package/dist/components/react-hook-form/utils/submit-button.js +23 -0
  49. package/dist/components/react-hook-form/utils/text-field-with-adornment.js +96 -0
  50. package/dist/components/translations/card-error-boundary-en.js +8 -0
  51. package/dist/components/translations/card-error-boundary-fr.js +8 -0
  52. package/dist/components/translations/common-button-en.js +7 -0
  53. package/dist/components/translations/common-button-fr.js +7 -0
  54. package/dist/components/translations/element-search-en.js +7 -0
  55. package/dist/components/translations/element-search-fr.js +7 -0
  56. package/dist/components/translations/equipment-search-en.js +21 -0
  57. package/dist/components/translations/equipment-search-fr.js +21 -0
  58. package/dist/components/translations/flat-parameters-en.js +8 -0
  59. package/dist/components/translations/flat-parameters-fr.js +8 -0
  60. package/dist/components/translations/login-en.js +14 -0
  61. package/dist/components/translations/login-fr.js +14 -0
  62. package/dist/components/translations/multiple-selection-dialog-en.js +8 -0
  63. package/dist/components/translations/multiple-selection-dialog-fr.js +8 -0
  64. package/dist/components/translations/report-viewer-en.js +8 -0
  65. package/dist/components/translations/report-viewer-fr.js +8 -0
  66. package/dist/components/translations/table-en.js +6 -0
  67. package/dist/components/translations/table-fr.js +6 -0
  68. package/dist/components/translations/top-bar-en.js +27 -0
  69. package/dist/components/translations/top-bar-fr.js +27 -0
  70. package/dist/components/translations/treeview-finder-en.js +12 -0
  71. package/dist/components/translations/treeview-finder-fr.js +12 -0
  72. package/dist/hooks/useDebounce.js +17 -0
  73. package/{es/components/ElementSearchDialog/index.js → dist/hooks/useIntlRef.d.ts} +2 -2
  74. package/dist/hooks/useIntlRef.js +13 -0
  75. package/dist/hooks/useSnackMessage.js +81 -0
  76. package/dist/index.d.ts +225 -0
  77. package/dist/index.js +154 -0
  78. package/dist/utils/AuthService.js +336 -0
  79. package/dist/utils/ElementType.js +38 -0
  80. package/dist/utils/EquipmentType.js +132 -0
  81. package/dist/utils/UserManagerMock.js +85 -0
  82. package/dist/utils/actions.js +71 -0
  83. package/dist/utils/algos.js +24 -0
  84. package/dist/utils/styles.js +13 -0
  85. package/package.json +36 -21
  86. package/es/components/AuthenticationRouter/AuthenticationRouter.js +0 -102
  87. package/es/components/AuthenticationRouter/index.js +0 -7
  88. package/es/components/CardErrorBoundary/card-error-boundary.js +0 -138
  89. package/es/components/CardErrorBoundary/index.js +0 -7
  90. package/es/components/ElementSearchDialog/element-search-dialog.js +0 -153
  91. package/es/components/ElementSearchDialog/equipment-item.js +0 -63
  92. package/es/components/ElementSearchDialog/tag-renderer.js +0 -29
  93. package/es/components/FlatParameters/FlatParameters.js +0 -448
  94. package/es/components/FlatParameters/index.js +0 -8
  95. package/es/components/Login/Login.js +0 -79
  96. package/es/components/Login/Logout.js +0 -78
  97. package/es/components/Login/index.js +0 -7
  98. package/es/components/MuiVirtualizedTable/ColumnHeader.js +0 -125
  99. package/es/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +0 -619
  100. package/es/components/MuiVirtualizedTable/MuiVirtualizedTable.js +0 -780
  101. package/es/components/MuiVirtualizedTable/index.js +0 -9
  102. package/es/components/MultipleSelectionDialog/MultipleSelectionDialog.js +0 -95
  103. package/es/components/MultipleSelectionDialog/index.js +0 -8
  104. package/es/components/OverflowableText/index.js +0 -7
  105. package/es/components/OverflowableText/overflowable-text.js +0 -81
  106. package/es/components/ReportViewer/filter-button.js +0 -77
  107. package/es/components/ReportViewer/index.js +0 -7
  108. package/es/components/ReportViewer/log-report-item.js +0 -97
  109. package/es/components/ReportViewer/log-report.js +0 -63
  110. package/es/components/ReportViewer/log-table.js +0 -130
  111. package/es/components/ReportViewer/multi-select-list.js +0 -56
  112. package/es/components/ReportViewer/report-item.js +0 -131
  113. package/es/components/ReportViewer/report-tree-view-context.js +0 -13
  114. package/es/components/ReportViewer/report-viewer.js +0 -167
  115. package/es/components/ReportViewerDialog/index.js +0 -7
  116. package/es/components/ReportViewerDialog/report-viewer-dialog.js +0 -67
  117. package/es/components/SignInCallbackHandler/SignInCallbackHandler.js +0 -19
  118. package/es/components/SignInCallbackHandler/index.js +0 -7
  119. package/es/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +0 -19
  120. package/es/components/SilentRenewCallbackHandler/index.js +0 -7
  121. package/es/components/SnackbarProvider/SnackbarProvider.js +0 -39
  122. package/es/components/SnackbarProvider/index.js +0 -7
  123. package/es/components/TopBar/AboutDialog.js +0 -456
  124. package/es/components/TopBar/GridLogo.js +0 -73
  125. package/es/components/TopBar/TopBar.js +0 -487
  126. package/es/components/TopBar/index.js +0 -9
  127. package/es/components/TreeViewFinder/TreeViewFinder.js +0 -341
  128. package/es/components/TreeViewFinder/index.js +0 -7
  129. package/es/components/images/powsybl_logo.svg +0 -35
  130. package/es/components/react-hook-form/autocomplete-input.js +0 -110
  131. package/es/components/react-hook-form/booleans/boolean-input.js +0 -56
  132. package/es/components/react-hook-form/booleans/checkbox-input.js +0 -28
  133. package/es/components/react-hook-form/booleans/switch-input.js +0 -28
  134. package/es/components/react-hook-form/error-management/error-input.js +0 -50
  135. package/es/components/react-hook-form/error-management/field-error-alert.js +0 -22
  136. package/es/components/react-hook-form/error-management/mid-form-error.js +0 -25
  137. package/es/components/react-hook-form/numbers/float-input.js +0 -105
  138. package/es/components/react-hook-form/numbers/integer-input.js +0 -35
  139. package/es/components/react-hook-form/numbers/utils.js +0 -6
  140. package/es/components/react-hook-form/radio-input.js +0 -55
  141. package/es/components/react-hook-form/select-input.js +0 -40
  142. package/es/components/react-hook-form/slider-input.js +0 -48
  143. package/es/components/react-hook-form/text-input.js +0 -100
  144. package/es/components/react-hook-form/utils/cancel-button.js +0 -28
  145. package/es/components/react-hook-form/utils/field-label.js +0 -15
  146. package/es/components/react-hook-form/utils/functions.js +0 -42
  147. package/es/components/react-hook-form/utils/submit-button.js +0 -29
  148. package/es/components/react-hook-form/utils/text-field-with-adornment.js +0 -92
  149. package/es/components/translations/card-error-boundary-en.js +0 -13
  150. package/es/components/translations/card-error-boundary-fr.js +0 -13
  151. package/es/components/translations/common-button-en.js +0 -12
  152. package/es/components/translations/common-button-fr.js +0 -12
  153. package/es/components/translations/element-search-en.js +0 -12
  154. package/es/components/translations/element-search-fr.js +0 -12
  155. package/es/components/translations/equipment-search-en.js +0 -26
  156. package/es/components/translations/equipment-search-fr.js +0 -26
  157. package/es/components/translations/flat-parameters-en.js +0 -13
  158. package/es/components/translations/flat-parameters-fr.js +0 -13
  159. package/es/components/translations/inputs-en.js +0 -25
  160. package/es/components/translations/inputs-fr.js +0 -25
  161. package/es/components/translations/login-en.js +0 -19
  162. package/es/components/translations/login-fr.js +0 -19
  163. package/es/components/translations/multiple-selection-dialog-en.js +0 -13
  164. package/es/components/translations/multiple-selection-dialog-fr.js +0 -13
  165. package/es/components/translations/report-viewer-en.js +0 -13
  166. package/es/components/translations/report-viewer-fr.js +0 -13
  167. package/es/components/translations/table-en.js +0 -11
  168. package/es/components/translations/table-fr.js +0 -11
  169. package/es/components/translations/top-bar-en.js +0 -32
  170. package/es/components/translations/top-bar-fr.js +0 -32
  171. package/es/components/translations/treeview-finder-en.js +0 -17
  172. package/es/components/translations/treeview-finder-fr.js +0 -17
  173. package/es/hooks/useDebounce.js +0 -26
  174. package/es/hooks/useIntlRef.js +0 -22
  175. package/es/hooks/useSnackMessage.js +0 -81
  176. package/es/index.js +0 -71
  177. package/es/utils/AuthService.js +0 -312
  178. package/es/utils/ElementType.js +0 -53
  179. package/es/utils/EquipmentType.js +0 -133
  180. package/es/utils/UserManagerMock.js +0 -81
  181. package/es/utils/actions.js +0 -65
  182. package/es/utils/algos.js +0 -29
  183. package/es/utils/styles.js +0 -35
@@ -0,0 +1,548 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import { equalsArray } from "../../utils/algos.js";
8
+ const CHANGE_WAYS = {
9
+ SIMPLE: "Simple",
10
+ TAIL: "Tail",
11
+ AMEND: "Amend",
12
+ REMOVE: "Remove"
13
+ };
14
+ const noOpHelper = Object.freeze({
15
+ debugName: "noOp",
16
+ maintainsStats: false,
17
+ initStat: () => void 0,
18
+ updateStat: (colStat, value) => {
19
+ },
20
+ accepts: (value, userParams, outerParams) => {
21
+ return true;
22
+ }
23
+ });
24
+ const numericHelper = Object.freeze({
25
+ debugName: "num",
26
+ maintainsStats: true,
27
+ initStat: () => {
28
+ return { imin: null, imax: null };
29
+ },
30
+ updateStat: (colStat, value) => {
31
+ if (colStat.imin === null || colStat.imin > value) {
32
+ colStat.imin = value;
33
+ }
34
+ if (colStat.imax === null || colStat.imax < value) {
35
+ colStat.imax = value;
36
+ }
37
+ },
38
+ accepts: (value, userParams, outerParams) => {
39
+ return true;
40
+ }
41
+ });
42
+ const collectibleHelper = Object.freeze({
43
+ debugName: "collectible",
44
+ maintainsStats: true,
45
+ initStat: () => {
46
+ return { seen: {}, kept: {} };
47
+ },
48
+ updateStat: (colStat, cellValue, isForKeep) => {
49
+ const m = isForKeep ? colStat.kept : colStat.seen;
50
+ if (!m[cellValue]) {
51
+ m[cellValue] = 1;
52
+ } else {
53
+ m[cellValue] += 1;
54
+ }
55
+ },
56
+ accepts: (value, userParams, outerParams) => {
57
+ return !userParams || userParams.some((v) => v === value);
58
+ }
59
+ });
60
+ const getHelper = (column) => {
61
+ if (column == null ? void 0 : column.numeric) {
62
+ return numericHelper;
63
+ } else if (!(column == null ? void 0 : column.nostat)) {
64
+ return collectibleHelper;
65
+ } else {
66
+ return noOpHelper;
67
+ }
68
+ };
69
+ class KeyedColumnsRowIndexer {
70
+ constructor(isThreeState = true, singleColumnByDefault = false, delegatorCallback = null, versionSetter = null) {
71
+ __publicField(this, "hasVersionSetter", () => {
72
+ return !!this._versionSetter;
73
+ });
74
+ __publicField(this, "getVersion", () => {
75
+ return this.version;
76
+ });
77
+ __publicField(this, "_bumpVersion", (isFilter = false) => {
78
+ this.version += 1;
79
+ if (isFilter) {
80
+ this.filterVersion = this.version;
81
+ }
82
+ if (this.delegatorCallback) {
83
+ this.indirectionStatus = "to sort";
84
+ this.delegatorCallback(this, (updated_ok) => {
85
+ this.indirectionStatus = updated_ok ? "done" : "no_luck";
86
+ });
87
+ }
88
+ if (this._versionSetter) {
89
+ this._versionSetter(this.version);
90
+ }
91
+ });
92
+ __publicField(this, "updatePreferences", (preferences) => {
93
+ if (preferences.isThreeState === this.isThreeState && preferences.singleColumnByDefault === this.singleColumnByDefault) {
94
+ return false;
95
+ }
96
+ if (preferences.isThreeState !== this.isThreeState) {
97
+ this.isThreeState = preferences.isThreeState;
98
+ }
99
+ if (preferences.singleColumnByDefault !== this.singleColumnByDefault) {
100
+ this.singleColumnByDefault = preferences.singleColumnByDefault;
101
+ }
102
+ this._bumpVersion();
103
+ });
104
+ // Does not mutate any internal
105
+ // returns
106
+ // { rowAndOrigIndex : [[row, originalRowIndex],...],
107
+ // colsStats : {
108
+ // colKey1 : {
109
+ // seen : Map(value : count),
110
+ // kept : Map(value : count)
111
+ // },
112
+ // colKey2 : {
113
+ // imin : number,
114
+ // imax : number,
115
+ // }, colKeyN, ...
116
+ // }
117
+ // }
118
+ __publicField(this, "preFilterRowMapping", (columns, rows, rowFilter) => {
119
+ var _a;
120
+ if (!(rows == null ? void 0 : rows.length) || !(columns == null ? void 0 : columns.length)) {
121
+ return null;
122
+ }
123
+ const ri = [];
124
+ const cs = {};
125
+ for (const col of columns) {
126
+ const helper = getHelper(col);
127
+ const colStat = helper.initStat();
128
+ if (colStat) {
129
+ cs[col.dataKey] = colStat;
130
+ }
131
+ }
132
+ for (let rowIdx = 0; rowIdx < rows.length; rowIdx++) {
133
+ const row = rows[rowIdx];
134
+ let acceptsRow = true;
135
+ let acceptedOnRow = {};
136
+ for (let colIdx = 0; colIdx < columns.length; colIdx++) {
137
+ const col = columns[colIdx];
138
+ const helper = getHelper(col);
139
+ const colKey = col.dataKey;
140
+ const cellValue = row[colKey];
141
+ helper.updateStat(cs[colKey], cellValue, false);
142
+ const colFilterParams = (_a = this.byColFilter) == null ? void 0 : _a[colKey];
143
+ let acceptsCell = true;
144
+ if (colFilterParams) {
145
+ const up = colFilterParams.userParams;
146
+ const op = colFilterParams.outerParams;
147
+ if (!helper.accepts(cellValue, up, op)) {
148
+ acceptsCell = false;
149
+ }
150
+ }
151
+ if (helper.maintainsStats && acceptsCell) {
152
+ acceptedOnRow[colIdx] = cellValue;
153
+ }
154
+ acceptsRow &= acceptsCell;
155
+ }
156
+ if (acceptsRow && rowFilter) {
157
+ acceptsRow = rowFilter(row);
158
+ }
159
+ if (acceptsRow && this.byRowFilter) {
160
+ acceptsRow = this.byRowFilter(row);
161
+ }
162
+ if (acceptsRow) {
163
+ for (let [idx, value] of Object.entries(acceptedOnRow)) {
164
+ const col = columns[idx];
165
+ const helper = getHelper(col);
166
+ helper.updateStat(cs[col.dataKey], value, true);
167
+ }
168
+ ri.push([row, rowIdx]);
169
+ }
170
+ }
171
+ return { rowAndOrigIndex: ri, colsStats: cs, rowsCount: rows.length };
172
+ });
173
+ // Does not mutate any internal
174
+ // returns an array of indexes in rows given to preFilter
175
+ __publicField(this, "makeGroupAndSortIndirector", (preFilteredRowPairs, columns) => {
176
+ if (!preFilteredRowPairs) {
177
+ return null;
178
+ }
179
+ const codedColumns = !this.sortingState ? null : codedColumnsFromKeyAndDirection(this.sortingState, columns);
180
+ const groupingColumnsCount = this.groupingCount;
181
+ let indexedArray = groupAndSort(
182
+ preFilteredRowPairs,
183
+ codedColumns,
184
+ groupingColumnsCount,
185
+ columns
186
+ );
187
+ return !indexedArray ? null : indexedArray.map((k) => k[1]);
188
+ });
189
+ __publicField(this, "getSortingAsKeyAndCodedRank", () => {
190
+ if (!this.sortingState) {
191
+ return [];
192
+ }
193
+ return this.sortingState.map((kd, i) => {
194
+ const sign = giveDirSignFor(kd[1]);
195
+ const codedRank = sign * (i + 1);
196
+ return [kd[0], codedRank];
197
+ });
198
+ });
199
+ // returns true if really changed (and calls versionSetter if needed)
200
+ __publicField(this, "updateSortingFromUser", (colKey, change_way) => {
201
+ const keyAndDirections = this.sortingState;
202
+ if (change_way === CHANGE_WAYS.REMOVE) {
203
+ if (!keyAndDirections) {
204
+ return false;
205
+ }
206
+ const would = keyAndDirections.filter((p) => p[0] !== colKey);
207
+ if (would.length === keyAndDirections.length) {
208
+ return false;
209
+ }
210
+ this.sortingState = would.length ? would : null;
211
+ } else if (!keyAndDirections) {
212
+ this.sortingState = [[colKey, canonicalForSign(1)]];
213
+ this.lastUsedRank = 1;
214
+ } else {
215
+ let wasAtIdx = keyAndDirections.findIndex((p) => p[0] === colKey);
216
+ const wasFuzzyDir = wasAtIdx < 0 ? 0 : keyAndDirections[wasAtIdx][1];
217
+ const wasSignDir = giveDirSignFor(wasFuzzyDir);
218
+ if (change_way === CHANGE_WAYS.SIMPLE) {
219
+ if (wasSignDir < 0 && this.isThreeState) {
220
+ if (this.sortingState.length === 1) {
221
+ this.sortingState = null;
222
+ } else {
223
+ this.sortingState.splice(wasAtIdx, 1);
224
+ }
225
+ } else {
226
+ if (this.singleColumnByDefault || wasAtIdx < 0) {
227
+ this.sortingState = [];
228
+ } else {
229
+ this.sortingState.splice(wasAtIdx, 1);
230
+ }
231
+ const nextSign = wasSignDir ? -wasSignDir : 1;
232
+ const nextKD = [colKey, canonicalForSign(nextSign)];
233
+ this.sortingState.unshift(nextKD);
234
+ }
235
+ } else if (change_way === CHANGE_WAYS.TAIL) {
236
+ if (wasAtIdx < 0) {
237
+ this.sortingState.push([colKey, canonicalForSign(1)]);
238
+ } else if (wasAtIdx !== keyAndDirections.length - 1) {
239
+ return false;
240
+ } else if (!(this.isThreeState && wasSignDir === -1)) {
241
+ this.sortingState[wasAtIdx][1] = canonicalForSign(
242
+ -wasSignDir
243
+ );
244
+ } else {
245
+ this.sortingState.splice(wasAtIdx, 1);
246
+ }
247
+ } else {
248
+ if (wasAtIdx < 0) {
249
+ if (this.lastUsedRank - 1 > this.sortingState.length) {
250
+ return false;
251
+ } else {
252
+ this.sortingState.splice(this.lastUsedRank - 1, 0, [
253
+ colKey,
254
+ canonicalForSign(1)
255
+ ]);
256
+ }
257
+ } else if (!(this.isThreeState && wasSignDir === -1)) {
258
+ this.sortingState[wasAtIdx][1] = canonicalForSign(
259
+ -wasSignDir
260
+ );
261
+ } else {
262
+ this.lastUsedRank = wasAtIdx + 1;
263
+ this.sortingState.splice(wasAtIdx, 1);
264
+ }
265
+ }
266
+ }
267
+ this._bumpVersion();
268
+ return true;
269
+ });
270
+ __publicField(this, "codedRankByColumnIndex", (columns) => {
271
+ return codedColumnsFromKeyAndDirection(this.sortingState, columns);
272
+ });
273
+ __publicField(this, "columnSortingSignedRank", (colKey) => {
274
+ var _a;
275
+ if (!((_a = this == null ? void 0 : this.sortingState) == null ? void 0 : _a.length)) {
276
+ return 0;
277
+ }
278
+ const idx = this.sortingState.findIndex((kd) => kd[0] === colKey);
279
+ if (idx < 0) {
280
+ return 0;
281
+ }
282
+ const colSorting = this.sortingState[idx];
283
+ return giveDirSignFor(colSorting[1]) * (idx + 1);
284
+ });
285
+ __publicField(this, "highestCodedColumn", (columns) => {
286
+ var _a;
287
+ if (!((_a = this == null ? void 0 : this.sortingState) == null ? void 0 : _a.length)) {
288
+ return 0;
289
+ }
290
+ const colSorting = this.sortingState[0];
291
+ const colKey = colSorting[0];
292
+ const idx = columns.findIndex((col) => col.dataKey === colKey);
293
+ if (idx < 0) {
294
+ return 0;
295
+ }
296
+ return giveDirSignFor(colSorting[1]) * (idx + 1);
297
+ });
298
+ __publicField(this, "_getColFilterParams", (colKey, isForUser) => {
299
+ if (!colKey || !this.byColFilter) {
300
+ return void 0;
301
+ }
302
+ const colFilter = this.byColFilter[colKey];
303
+ if (!colFilter) {
304
+ return void 0;
305
+ }
306
+ return colFilter[isForUser ? "userParams" : "outerParams"];
307
+ });
308
+ __publicField(this, "_setColFilterParams", (colKey, params, isForUser) => {
309
+ var _a;
310
+ if (!colKey) {
311
+ if (params) {
312
+ throw new Error("column key has to be defined");
313
+ }
314
+ return false;
315
+ }
316
+ const fieldName = isForUser ? "userParams" : "outerParams";
317
+ if (params) {
318
+ if (!this.byColFilter) {
319
+ this.byColFilter = {};
320
+ }
321
+ let colFilter = this.byColFilter[colKey];
322
+ if (!colFilter) {
323
+ colFilter = {};
324
+ this.byColFilter[colKey] = colFilter;
325
+ } else if (colFilter[fieldName] === params) {
326
+ return false;
327
+ }
328
+ colFilter[fieldName] = params;
329
+ } else {
330
+ if (!this.byColFilter) {
331
+ return false;
332
+ }
333
+ const otherFieldName = !isForUser ? "userParams" : "outerParams";
334
+ if ((_a = this.byColFilter[colKey]) == null ? void 0 : _a[otherFieldName]) {
335
+ delete this.byColFilter[colKey][fieldName];
336
+ } else {
337
+ delete this.byColFilter[colKey];
338
+ }
339
+ }
340
+ if (isForUser) {
341
+ this._bumpVersion(true);
342
+ }
343
+ return true;
344
+ });
345
+ __publicField(this, "getColFilterOuterParams", (colKey) => {
346
+ return this._getColFilterParams(colKey, false);
347
+ });
348
+ __publicField(this, "setColFilterOuterParams", (colKey, outerParams) => {
349
+ return this._setColFilterParams(colKey, outerParams, false);
350
+ });
351
+ __publicField(this, "getColFilterUserParams", (colKey) => {
352
+ return this._getColFilterParams(colKey, true);
353
+ });
354
+ __publicField(this, "setColFilterUserParams", (colKey, params) => {
355
+ return this._setColFilterParams(colKey, params, true);
356
+ });
357
+ __publicField(this, "getUserFiltering", () => {
358
+ const ret = {};
359
+ if (this.byColFilter) {
360
+ Object.entries(this.byColFilter).forEach(([k, v]) => {
361
+ if (!v.userParams) {
362
+ return;
363
+ }
364
+ ret[k] = [...v.userParams];
365
+ });
366
+ }
367
+ return ret;
368
+ });
369
+ __publicField(this, "updateRowFiltering", (rowFilterFunc) => {
370
+ if (typeof rowFilterFunc !== "function") {
371
+ throw new Error("row filter should be a function");
372
+ }
373
+ this.byRowFilter = rowFilterFunc;
374
+ this._bumpVersion();
375
+ });
376
+ this._versionSetter = versionSetter;
377
+ this.version = 0;
378
+ this.filterVersion = 0;
379
+ this.delegatorCallback = delegatorCallback;
380
+ this.indirectionStatus = null;
381
+ this.isThreeState = isThreeState;
382
+ this.singleColumnByDefault = singleColumnByDefault;
383
+ this.lastUsedRank = 1;
384
+ this.sortingState = null;
385
+ this.groupingCount = 0;
386
+ this.byColFilter = null;
387
+ this.byRowFilter = null;
388
+ }
389
+ static get CHANGE_WAYS() {
390
+ return CHANGE_WAYS;
391
+ }
392
+ }
393
+ const giveDirSignFor = (fuzzySign) => {
394
+ if (fuzzySign < 0) {
395
+ return -1;
396
+ }
397
+ if (fuzzySign > 0) {
398
+ return 1;
399
+ }
400
+ if (fuzzySign === "asc") {
401
+ return 1;
402
+ }
403
+ if (fuzzySign === "desc") {
404
+ return -1;
405
+ }
406
+ return 0;
407
+ };
408
+ const canonicalForSign = (dirSign) => {
409
+ if (dirSign > 0) {
410
+ return "asc";
411
+ }
412
+ if (dirSign < 0) {
413
+ return "desc";
414
+ }
415
+ return void 0;
416
+ };
417
+ const codedColumnsFromKeyAndDirection = (keyAndDirections, columns) => {
418
+ if (!keyAndDirections) {
419
+ return null;
420
+ }
421
+ const ret = [];
422
+ const columIndexByKey = {};
423
+ for (let colIdx = 0; colIdx < columns.length; colIdx++) {
424
+ const col = columns[colIdx];
425
+ const colKey = col.dataKey;
426
+ columIndexByKey[colKey] = colIdx;
427
+ }
428
+ for (const knd of keyAndDirections) {
429
+ const colKey = knd[0];
430
+ const dir = knd[1];
431
+ const colIdx = columIndexByKey[colKey];
432
+ if (colIdx === void 0) {
433
+ continue;
434
+ }
435
+ const sign = giveDirSignFor(dir);
436
+ ret.push((colIdx + 1) * sign);
437
+ }
438
+ return ret;
439
+ };
440
+ const compareValue = (a, b, isNumeric, undefSign = -1) => {
441
+ if (a === void 0 && b === void 0) {
442
+ return 0;
443
+ } else {
444
+ if (a === void 0) {
445
+ return undefSign;
446
+ } else {
447
+ if (b === void 0) {
448
+ return -undefSign;
449
+ }
450
+ }
451
+ }
452
+ if (!isNumeric) {
453
+ return ("" + a).localeCompare(b);
454
+ } else {
455
+ if (isNaN(a)) {
456
+ return isNaN(b) ? 0 : 1;
457
+ }
458
+ if (isNaN(b)) {
459
+ return -1;
460
+ }
461
+ return Math.sign(Number(a) - Number(b));
462
+ }
463
+ };
464
+ const makeCompositeComparatorFromCodedColumns = (codedColumns, columns, rowExtractor) => {
465
+ return (row_a_i, row_b_i) => {
466
+ const row_a = rowExtractor(row_a_i);
467
+ const row_b = rowExtractor(row_b_i);
468
+ for (const cc of codedColumns) {
469
+ const i = Math.abs(cc) - 1;
470
+ const mul = Math.sign(cc);
471
+ const col = columns[i];
472
+ const key = col.dataKey;
473
+ const sgn = compareValue(row_a[key], row_b[key], col.numeric);
474
+ if (sgn) {
475
+ return mul * sgn;
476
+ }
477
+ }
478
+ return 0;
479
+ };
480
+ };
481
+ const groupRows = (groupingColumnsCount, columns, indexedArray) => {
482
+ const groupingComparator = makeCompositeComparatorFromCodedColumns(
483
+ Array(groupingColumnsCount).map((x, i) => i + 1),
484
+ columns,
485
+ (ar) => ar[0]
486
+ );
487
+ indexedArray.sort(groupingComparator);
488
+ const groups = [];
489
+ let prevSlice = null;
490
+ let inBuildGroup = [];
491
+ groups.push(inBuildGroup);
492
+ for (const p of indexedArray) {
493
+ const nextSlice = p[0].slice(0, groupingColumnsCount);
494
+ if (prevSlice === null || !equalsArray(prevSlice, nextSlice)) {
495
+ inBuildGroup = [];
496
+ groups.push(inBuildGroup);
497
+ }
498
+ inBuildGroup.push(p);
499
+ prevSlice = nextSlice;
500
+ }
501
+ return groups;
502
+ };
503
+ const groupAndSort = (preFilteredRowPairs, codedColumns, groupingColumnsCount, columns) => {
504
+ const nothingToDo = !codedColumns && !groupingColumnsCount;
505
+ let indexedArray = preFilteredRowPairs.rowAndOrigIndex;
506
+ const noOutFiltered = preFilteredRowPairs.rowsCount === indexedArray.length;
507
+ if (nothingToDo && noOutFiltered) {
508
+ return null;
509
+ } else if (!nothingToDo) {
510
+ indexedArray = [...indexedArray];
511
+ }
512
+ if (nothingToDo)
513
+ ;
514
+ else if (!groupingColumnsCount) {
515
+ const sortingComparator = makeCompositeComparatorFromCodedColumns(
516
+ codedColumns,
517
+ columns,
518
+ (ar) => ar[0]
519
+ );
520
+ indexedArray.sort(sortingComparator);
521
+ } else {
522
+ const groups = groupRows(groupingColumnsCount, columns, indexedArray);
523
+ const interGroupSortingComparator = makeCompositeComparatorFromCodedColumns(
524
+ codedColumns,
525
+ columns,
526
+ (ar) => ar[0][0]
527
+ );
528
+ groups.sort(interGroupSortingComparator);
529
+ const intraGroupSortingComparator = makeCompositeComparatorFromCodedColumns(
530
+ codedColumns,
531
+ columns,
532
+ (ar) => ar[0]
533
+ );
534
+ indexedArray = [];
535
+ for (const group of groups) {
536
+ group.sort(intraGroupSortingComparator);
537
+ indexedArray.push(...group);
538
+ }
539
+ }
540
+ return indexedArray;
541
+ };
542
+ export {
543
+ CHANGE_WAYS,
544
+ KeyedColumnsRowIndexer,
545
+ collectibleHelper,
546
+ getHelper,
547
+ noOpHelper
548
+ };