@tanstack/react-table 8.0.0-alpha.8 → 8.0.0-alpha.80

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 (113) hide show
  1. package/build/cjs/react-table/src/index.js +133 -0
  2. package/build/cjs/react-table/src/index.js.map +1 -0
  3. package/build/cjs/table-core/build/esm/index.js +3951 -0
  4. package/build/cjs/table-core/build/esm/index.js.map +1 -0
  5. package/build/esm/index.js +3253 -4059
  6. package/build/esm/index.js.map +1 -1
  7. package/build/stats-html.html +1 -1
  8. package/build/stats-react.json +24 -797
  9. package/build/types/index.d.ts +16 -8
  10. package/build/umd/index.development.js +3349 -4124
  11. package/build/umd/index.development.js.map +1 -1
  12. package/build/umd/index.production.js +11 -1
  13. package/build/umd/index.production.js.map +1 -1
  14. package/package.json +7 -9
  15. package/src/index.tsx +113 -8
  16. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -112
  17. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  18. package/build/cjs/aggregationTypes.js +0 -130
  19. package/build/cjs/aggregationTypes.js.map +0 -1
  20. package/build/cjs/core.js +0 -560
  21. package/build/cjs/core.js.map +0 -1
  22. package/build/cjs/createTable.js +0 -108
  23. package/build/cjs/createTable.js.map +0 -1
  24. package/build/cjs/features/ColumnSizing.js +0 -317
  25. package/build/cjs/features/ColumnSizing.js.map +0 -1
  26. package/build/cjs/features/Expanding.js +0 -251
  27. package/build/cjs/features/Expanding.js.map +0 -1
  28. package/build/cjs/features/Filters.js +0 -445
  29. package/build/cjs/features/Filters.js.map +0 -1
  30. package/build/cjs/features/Grouping.js +0 -249
  31. package/build/cjs/features/Grouping.js.map +0 -1
  32. package/build/cjs/features/Headers.js +0 -549
  33. package/build/cjs/features/Headers.js.map +0 -1
  34. package/build/cjs/features/Ordering.js +0 -86
  35. package/build/cjs/features/Ordering.js.map +0 -1
  36. package/build/cjs/features/Pagination.js +0 -198
  37. package/build/cjs/features/Pagination.js.map +0 -1
  38. package/build/cjs/features/Pinning.js +0 -149
  39. package/build/cjs/features/Pinning.js.map +0 -1
  40. package/build/cjs/features/RowSelection.js +0 -541
  41. package/build/cjs/features/RowSelection.js.map +0 -1
  42. package/build/cjs/features/Sorting.js +0 -327
  43. package/build/cjs/features/Sorting.js.map +0 -1
  44. package/build/cjs/features/Visibility.js +0 -166
  45. package/build/cjs/features/Visibility.js.map +0 -1
  46. package/build/cjs/filterTypes.js +0 -172
  47. package/build/cjs/filterTypes.js.map +0 -1
  48. package/build/cjs/index.js +0 -32
  49. package/build/cjs/index.js.map +0 -1
  50. package/build/cjs/sortTypes.js +0 -122
  51. package/build/cjs/sortTypes.js.map +0 -1
  52. package/build/cjs/utils/columnFilterRowsFn.js +0 -131
  53. package/build/cjs/utils/columnFilterRowsFn.js.map +0 -1
  54. package/build/cjs/utils/expandRowsFn.js +0 -38
  55. package/build/cjs/utils/expandRowsFn.js.map +0 -1
  56. package/build/cjs/utils/globalFilterRowsFn.js +0 -101
  57. package/build/cjs/utils/globalFilterRowsFn.js.map +0 -1
  58. package/build/cjs/utils/groupRowsFn.js +0 -155
  59. package/build/cjs/utils/groupRowsFn.js.map +0 -1
  60. package/build/cjs/utils/paginateRowsFn.js +0 -44
  61. package/build/cjs/utils/paginateRowsFn.js.map +0 -1
  62. package/build/cjs/utils/sortRowsFn.js +0 -94
  63. package/build/cjs/utils/sortRowsFn.js.map +0 -1
  64. package/build/cjs/utils.js +0 -141
  65. package/build/cjs/utils.js.map +0 -1
  66. package/build/types/aggregationTypes.d.ts +0 -22
  67. package/build/types/core.d.ts +0 -110
  68. package/build/types/createTable.d.ts +0 -52
  69. package/build/types/features/ColumnSizing.d.ts +0 -67
  70. package/build/types/features/Expanding.d.ts +0 -53
  71. package/build/types/features/Filters.d.ts +0 -98
  72. package/build/types/features/Grouping.d.ts +0 -82
  73. package/build/types/features/Headers.d.ts +0 -41
  74. package/build/types/features/Ordering.d.ts +0 -19
  75. package/build/types/features/Pagination.d.ts +0 -44
  76. package/build/types/features/Pinning.d.ts +0 -39
  77. package/build/types/features/RowSelection.d.ts +0 -66
  78. package/build/types/features/Sorting.d.ts +0 -78
  79. package/build/types/features/Visibility.d.ts +0 -47
  80. package/build/types/filterTypes.d.ts +0 -50
  81. package/build/types/sortTypes.d.ts +0 -18
  82. package/build/types/types.d.ts +0 -127
  83. package/build/types/utils/columnFilterRowsFn.d.ts +0 -2
  84. package/build/types/utils/expandRowsFn.d.ts +0 -2
  85. package/build/types/utils/globalFilterRowsFn.d.ts +0 -2
  86. package/build/types/utils/groupRowsFn.d.ts +0 -2
  87. package/build/types/utils/paginateRowsFn.d.ts +0 -2
  88. package/build/types/utils/sortRowsFn.d.ts +0 -2
  89. package/build/types/utils.d.ts +0 -24
  90. package/src/aggregationTypes.ts +0 -115
  91. package/src/core.tsx +0 -1096
  92. package/src/createTable.tsx +0 -244
  93. package/src/features/ColumnSizing.ts +0 -453
  94. package/src/features/Expanding.ts +0 -406
  95. package/src/features/Filters.ts +0 -762
  96. package/src/features/Grouping.ts +0 -466
  97. package/src/features/Headers.ts +0 -912
  98. package/src/features/Ordering.ts +0 -133
  99. package/src/features/Pagination.ts +0 -325
  100. package/src/features/Pinning.ts +0 -198
  101. package/src/features/RowSelection.ts +0 -831
  102. package/src/features/Sorting.ts +0 -547
  103. package/src/features/Visibility.ts +0 -279
  104. package/src/filterTypes.ts +0 -251
  105. package/src/sortTypes.ts +0 -159
  106. package/src/types.ts +0 -331
  107. package/src/utils/columnFilterRowsFn.ts +0 -155
  108. package/src/utils/expandRowsFn.ts +0 -50
  109. package/src/utils/globalFilterRowsFn.ts +0 -122
  110. package/src/utils/groupRowsFn.ts +0 -194
  111. package/src/utils/paginateRowsFn.ts +0 -34
  112. package/src/utils/sortRowsFn.ts +0 -115
  113. package/src/utils.tsx +0 -195
@@ -0,0 +1,3951 @@
1
+ /**
2
+ * react-table
3
+ *
4
+ * Copyright (c) TanStack
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ /**
16
+ * table-core
17
+ *
18
+ * Copyright (c) TanStack
19
+ *
20
+ * This source code is licensed under the MIT license found in the
21
+ * LICENSE.md file in the root directory of this source tree.
22
+ *
23
+ * @license MIT
24
+ */
25
+ function functionalUpdate(updater, input) {
26
+ return typeof updater === 'function' ? updater(input) : updater;
27
+ }
28
+ function noop() {//
29
+ }
30
+ function makeStateUpdater(key, instance) {
31
+ return updater => {
32
+ instance.setState(old => {
33
+ return { ...old,
34
+ [key]: functionalUpdate(updater, old[key])
35
+ };
36
+ });
37
+ };
38
+ }
39
+ function isFunction(d) {
40
+ return d instanceof Function;
41
+ }
42
+ function flattenBy(arr, getChildren) {
43
+ const flat = [];
44
+
45
+ const recurse = subArr => {
46
+ subArr.forEach(item => {
47
+ flat.push(item);
48
+ const children = getChildren(item);
49
+
50
+ if (children != null && children.length) {
51
+ recurse(children);
52
+ }
53
+ });
54
+ };
55
+
56
+ recurse(arr);
57
+ return flat;
58
+ }
59
+ function memo(getDeps, fn, opts) {
60
+ let deps = [];
61
+ let result;
62
+ return () => {
63
+ let depTime;
64
+ if (opts.key && opts.debug) depTime = Date.now();
65
+ const newDeps = getDeps();
66
+ const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
67
+
68
+ if (!depsChanged) {
69
+ return result;
70
+ }
71
+
72
+ deps = newDeps;
73
+ let resultTime;
74
+ if (opts.key && opts.debug) resultTime = Date.now();
75
+ result = fn(...newDeps);
76
+ opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result);
77
+
78
+ if (opts.key && opts.debug) {
79
+ if (opts != null && opts.debug()) {
80
+ const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
81
+ const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
82
+ const resultFpsPercentage = resultEndTime / 16;
83
+
84
+ const pad = (str, num) => {
85
+ str = String(str);
86
+
87
+ while (str.length < num) {
88
+ str = ' ' + str;
89
+ }
90
+
91
+ return str;
92
+ };
93
+
94
+ console.info("%c\u23F1 " + pad(resultEndTime, 5) + " /" + pad(depEndTime, 5) + " ms", "\n font-size: .6rem;\n font-weight: bold;\n color: hsl(" + Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120)) + "deg 100% 31%);", opts == null ? void 0 : opts.key);
95
+ }
96
+ }
97
+
98
+ return result;
99
+ };
100
+ }
101
+
102
+ //
103
+ const Columns = {
104
+ createInstance: instance => {
105
+ return {
106
+ getDefaultColumn: memo(() => [instance.options.defaultColumn], defaultColumn => {
107
+ var _defaultColumn;
108
+
109
+ defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
110
+ return {
111
+ header: props => props.header.column.id,
112
+ footer: props => props.header.column.id,
113
+ cell: props => {
114
+ var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
115
+
116
+ return (_props$getValue$toStr = (_props$getValue$toStr2 = (_props$getValue = props.getValue()).toString) == null ? void 0 : _props$getValue$toStr2.call(_props$getValue)) != null ? _props$getValue$toStr : null;
117
+ },
118
+ ...instance._features.reduce((obj, feature) => {
119
+ return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
120
+ }, {}),
121
+ ...defaultColumn
122
+ };
123
+ }, {
124
+ debug: () => {
125
+ var _instance$options$deb;
126
+
127
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
128
+ },
129
+ key: process.env.NODE_ENV === 'development' && 'getDefaultColumn'
130
+ }),
131
+ getColumnDefs: () => instance.options.columns,
132
+ createColumn: (columnDef, depth, parent) => {
133
+ var _ref, _columnDef$id;
134
+
135
+ const defaultColumn = instance.getDefaultColumn();
136
+ let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
137
+ let accessorFn;
138
+
139
+ if (columnDef.accessorFn) {
140
+ accessorFn = columnDef.accessorFn;
141
+ } else if (columnDef.accessorKey) {
142
+ accessorFn = originalRow => originalRow[columnDef.accessorKey];
143
+ }
144
+
145
+ if (!id) {
146
+ if (process.env.NODE_ENV !== 'production') {
147
+ throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
148
+ }
149
+
150
+ throw new Error();
151
+ }
152
+
153
+ let column = { ...defaultColumn,
154
+ ...columnDef,
155
+ id: "" + id,
156
+ accessorFn,
157
+ parent: parent,
158
+ depth,
159
+ columnDef,
160
+ columnDefType: columnDef.columnDefType,
161
+ columns: [],
162
+ getFlatColumns: memo(() => [true], () => {
163
+ var _column$columns;
164
+
165
+ return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
166
+ }, {
167
+ key: process.env.NODE_ENV === 'production' && 'column.getFlatColumns',
168
+ debug: () => {
169
+ var _instance$options$deb2;
170
+
171
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
172
+ }
173
+ }),
174
+ getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
175
+ var _column$columns2;
176
+
177
+ if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
178
+ let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
179
+ return orderColumns(leafColumns);
180
+ }
181
+
182
+ return [column];
183
+ }, {
184
+ key: process.env.NODE_ENV === 'production' && 'column.getLeafColumns',
185
+ debug: () => {
186
+ var _instance$options$deb3;
187
+
188
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
189
+ }
190
+ })
191
+ };
192
+ column = instance._features.reduce((obj, feature) => {
193
+ return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
194
+ }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
195
+
196
+ return column;
197
+ },
198
+ getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
199
+ const recurseColumns = function (columnDefs, parent, depth) {
200
+ if (depth === void 0) {
201
+ depth = 0;
202
+ }
203
+
204
+ return columnDefs.map(columnDef => {
205
+ const column = instance.createColumn(columnDef, depth, parent);
206
+ column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
207
+ return column;
208
+ });
209
+ };
210
+
211
+ return recurseColumns(columnDefs);
212
+ }, {
213
+ key: process.env.NODE_ENV === 'development' && 'getAllColumns',
214
+ debug: () => {
215
+ var _instance$options$deb4;
216
+
217
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
218
+ }
219
+ }),
220
+ getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
221
+ return allColumns.flatMap(column => {
222
+ return column.getFlatColumns();
223
+ });
224
+ }, {
225
+ key: process.env.NODE_ENV === 'development' && 'getAllFlatColumns',
226
+ debug: () => {
227
+ var _instance$options$deb5;
228
+
229
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
230
+ }
231
+ }),
232
+ getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
233
+ return flatColumns.reduce((acc, column) => {
234
+ acc[column.id] = column;
235
+ return acc;
236
+ }, {});
237
+ }, {
238
+ key: process.env.NODE_ENV === 'development' && 'getAllFlatColumnsById',
239
+ debug: () => {
240
+ var _instance$options$deb6;
241
+
242
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns;
243
+ }
244
+ }),
245
+ getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
246
+ let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
247
+ return orderColumns(leafColumns);
248
+ }, {
249
+ key: process.env.NODE_ENV === 'development' && 'getAllLeafColumns',
250
+ debug: () => {
251
+ var _instance$options$deb7;
252
+
253
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns;
254
+ }
255
+ }),
256
+ getColumn: columnId => {
257
+ const column = instance.getAllFlatColumnsById()[columnId];
258
+
259
+ if (!column) {
260
+ if (process.env.NODE_ENV !== 'production') {
261
+ console.warn("[Table] Column with id " + columnId + " does not exist.");
262
+ }
263
+
264
+ throw new Error();
265
+ }
266
+
267
+ return column;
268
+ }
269
+ };
270
+ }
271
+ };
272
+
273
+ //
274
+ const Rows = {
275
+ // createRow: <TGenerics extends TableGenerics>(
276
+ // row: Row<TGenerics>,
277
+ // instance: TableInstance<TGenerics>
278
+ // ): CellsRow<TGenerics> => {
279
+ // return {}
280
+ // },
281
+ createInstance: instance => {
282
+ return {
283
+ getRowId: (row, index, parent) => {
284
+ var _instance$options$get;
285
+
286
+ return (_instance$options$get = instance.options.getRowId == null ? void 0 : instance.options.getRowId(row, index, parent)) != null ? _instance$options$get : "" + (parent ? [parent.id, index].join('.') : index);
287
+ },
288
+ createRow: (id, original, rowIndex, depth, subRows) => {
289
+ let row = {
290
+ id,
291
+ index: rowIndex,
292
+ original,
293
+ depth,
294
+ valuesCache: {},
295
+ getValue: columnId => {
296
+ if (row.valuesCache.hasOwnProperty(columnId)) {
297
+ return row.valuesCache[columnId];
298
+ }
299
+
300
+ const column = instance.getColumn(columnId);
301
+
302
+ if (!column.accessorFn) {
303
+ return undefined;
304
+ }
305
+
306
+ row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
307
+ return row.valuesCache[columnId];
308
+ },
309
+ subRows: subRows != null ? subRows : [],
310
+ getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
311
+ };
312
+
313
+ for (let i = 0; i < instance._features.length; i++) {
314
+ const feature = instance._features[i];
315
+ Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
316
+ }
317
+
318
+ return row;
319
+ },
320
+ getCoreRowModel: () => {
321
+ if (!instance._getCoreRowModel) {
322
+ instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
323
+ }
324
+
325
+ return instance._getCoreRowModel();
326
+ },
327
+ // The final calls start at the bottom of the model,
328
+ // expanded rows, which then work their way up
329
+ getRowModel: () => {
330
+ return instance.getPaginationRowModel();
331
+ },
332
+ getRow: id => {
333
+ const row = instance.getRowModel().rowsById[id];
334
+
335
+ if (!row) {
336
+ if (process.env.NODE_ENV !== 'production') {
337
+ throw new Error("getRow expected an ID, but got " + id);
338
+ }
339
+
340
+ throw new Error();
341
+ }
342
+
343
+ return row;
344
+ }
345
+ };
346
+ }
347
+ };
348
+
349
+ //
350
+ const Cells = {
351
+ createRow: (row, instance) => {
352
+ return {
353
+ getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
354
+ return leafColumns.map(column => {
355
+ return instance.createCell(row, column, column.id);
356
+ });
357
+ }, {
358
+ key: process.env.NODE_ENV === 'development' && 'row.getAllCells',
359
+ debug: () => {
360
+ var _instance$options$deb;
361
+
362
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
363
+ }
364
+ }),
365
+ getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
366
+ return allCells.reduce((acc, cell) => {
367
+ acc[cell.columnId] = cell;
368
+ return acc;
369
+ }, {});
370
+ }, {
371
+ key: process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',
372
+ debug: () => {
373
+ var _instance$options$deb2;
374
+
375
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
376
+ }
377
+ })
378
+ };
379
+ },
380
+ createInstance: instance => {
381
+ return {
382
+ createCell: (row, column, columnId) => {
383
+ const cell = {
384
+ id: row.id + "_" + column.id,
385
+ rowId: row.id,
386
+ columnId,
387
+ row,
388
+ column,
389
+ getValue: () => row.getValue(columnId),
390
+ renderCell: () => column.cell ? instance._render(column.cell, {
391
+ instance,
392
+ column,
393
+ row,
394
+ cell: cell,
395
+ getValue: cell.getValue
396
+ }) : null
397
+ };
398
+
399
+ instance._features.forEach(feature => {
400
+ Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
401
+ }, {});
402
+
403
+ return cell;
404
+ },
405
+ getCell: (rowId, columnId) => {
406
+ const row = instance.getRow(rowId);
407
+
408
+ if (!row) {
409
+ if (process.env.NODE_ENV !== 'production') {
410
+ throw new Error("[Table] could not find row with id " + rowId);
411
+ }
412
+
413
+ throw new Error();
414
+ }
415
+
416
+ const cell = row.getAllCellsByColumnId()[columnId];
417
+
418
+ if (!cell) {
419
+ if (process.env.NODE_ENV !== 'production') {
420
+ throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
421
+ }
422
+
423
+ throw new Error();
424
+ }
425
+
426
+ return cell;
427
+ }
428
+ };
429
+ }
430
+ };
431
+
432
+ //
433
+ const defaultColumnSizing = {
434
+ size: 150,
435
+ minSize: 20,
436
+ maxSize: Number.MAX_SAFE_INTEGER
437
+ };
438
+
439
+ const getDefaultColumnSizingInfoState = () => ({
440
+ startOffset: null,
441
+ startSize: null,
442
+ deltaOffset: null,
443
+ deltaPercentage: null,
444
+ isResizingColumn: false,
445
+ columnSizingStart: []
446
+ });
447
+
448
+ const ColumnSizing = {
449
+ getDefaultColumn: () => {
450
+ return defaultColumnSizing;
451
+ },
452
+ getInitialState: state => {
453
+ return {
454
+ columnSizing: {},
455
+ columnSizingInfo: getDefaultColumnSizingInfoState(),
456
+ ...state
457
+ };
458
+ },
459
+ getDefaultOptions: instance => {
460
+ return {
461
+ columnResizeMode: 'onEnd',
462
+ onColumnSizingChange: makeStateUpdater('columnSizing', instance),
463
+ onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', instance)
464
+ };
465
+ },
466
+ createColumn: (column, instance) => {
467
+ return {
468
+ getSize: () => {
469
+ var _column$minSize, _ref, _column$maxSize;
470
+
471
+ const columnSize = instance.getState().columnSizing[column.id];
472
+ return Math.min(Math.max((_column$minSize = column.minSize) != null ? _column$minSize : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.size) != null ? _ref : defaultColumnSizing.size), (_column$maxSize = column.maxSize) != null ? _column$maxSize : defaultColumnSizing.maxSize);
473
+ },
474
+ getStart: position => {
475
+ const columns = !position ? instance.getVisibleLeafColumns() : position === 'left' ? instance.getLeftVisibleLeafColumns() : instance.getRightVisibleLeafColumns();
476
+ const index = columns.findIndex(d => d.id === column.id);
477
+
478
+ if (index > 0) {
479
+ const prevSiblingColumn = columns[index - 1];
480
+ return prevSiblingColumn.getStart(position) + prevSiblingColumn.getSize();
481
+ }
482
+
483
+ return 0;
484
+ },
485
+ resetSize: () => {
486
+ instance.setColumnSizing(_ref2 => {
487
+ let {
488
+ [column.id]: _,
489
+ ...rest
490
+ } = _ref2;
491
+ return rest;
492
+ });
493
+ },
494
+ getCanResize: () => {
495
+ var _column$enableResizin, _instance$options$ena;
496
+
497
+ return ((_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
498
+ },
499
+ getIsResizing: () => {
500
+ return instance.getState().columnSizingInfo.isResizingColumn === column.id;
501
+ }
502
+ };
503
+ },
504
+ createHeader: (header, instance) => {
505
+ return {
506
+ getSize: () => {
507
+ let sum = 0;
508
+
509
+ const recurse = header => {
510
+ if (header.subHeaders.length) {
511
+ header.subHeaders.forEach(recurse);
512
+ } else {
513
+ var _header$column$getSiz;
514
+
515
+ sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
516
+ }
517
+ };
518
+
519
+ recurse(header);
520
+ return sum;
521
+ },
522
+ getStart: () => {
523
+ if (header.index > 0) {
524
+ const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
525
+ return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
526
+ }
527
+
528
+ return 0;
529
+ },
530
+ getResizeHandler: () => {
531
+ const column = instance.getColumn(header.column.id);
532
+ const canResize = column.getCanResize();
533
+ return e => {
534
+ if (!canResize) {
535
+ return;
536
+ }
537
+ e.persist == null ? void 0 : e.persist();
538
+
539
+ if (isTouchStartEvent(e)) {
540
+ // lets not respond to multiple touches (e.g. 2 or 3 fingers)
541
+ if (e.touches && e.touches.length > 1) {
542
+ return;
543
+ }
544
+ }
545
+
546
+ const startSize = header.getSize();
547
+ const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
548
+ const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
549
+
550
+ const updateOffset = (eventType, clientXPos) => {
551
+ if (typeof clientXPos !== 'number') {
552
+ return;
553
+ }
554
+
555
+ let newColumnSizing = {};
556
+ instance.setColumnSizingInfo(old => {
557
+ var _old$startOffset, _old$startSize;
558
+
559
+ const deltaOffset = clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0);
560
+ const deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
561
+ old.columnSizingStart.forEach(_ref3 => {
562
+ let [columnId, headerSize] = _ref3;
563
+ newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
564
+ });
565
+ return { ...old,
566
+ deltaOffset,
567
+ deltaPercentage
568
+ };
569
+ });
570
+
571
+ if (instance.options.columnResizeMode === 'onChange' || eventType === 'end') {
572
+ instance.setColumnSizing(old => ({ ...old,
573
+ ...newColumnSizing
574
+ }));
575
+ }
576
+ };
577
+
578
+ const onMove = clientXPos => updateOffset('move', clientXPos);
579
+
580
+ const onEnd = clientXPos => {
581
+ updateOffset('end', clientXPos);
582
+ instance.setColumnSizingInfo(old => ({ ...old,
583
+ isResizingColumn: false,
584
+ startOffset: null,
585
+ startSize: null,
586
+ deltaOffset: null,
587
+ deltaPercentage: null,
588
+ columnSizingStart: []
589
+ }));
590
+ };
591
+
592
+ const mouseEvents = {
593
+ moveHandler: e => onMove(e.clientX),
594
+ upHandler: e => {
595
+ document.removeEventListener('mousemove', mouseEvents.moveHandler);
596
+ document.removeEventListener('mouseup', mouseEvents.upHandler);
597
+ onEnd(e.clientX);
598
+ }
599
+ };
600
+ const passiveIfSupported = passiveEventSupported() ? {
601
+ passive: false
602
+ } : false;
603
+
604
+ if (isTouchStartEvent(e)) ; else {
605
+ document.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
606
+ document.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
607
+ }
608
+
609
+ instance.setColumnSizingInfo(old => ({ ...old,
610
+ startOffset: clientX,
611
+ startSize,
612
+ deltaOffset: 0,
613
+ deltaPercentage: 0,
614
+ columnSizingStart,
615
+ isResizingColumn: column.id
616
+ }));
617
+ };
618
+ }
619
+ };
620
+ },
621
+ createInstance: instance => {
622
+ return {
623
+ setColumnSizing: updater => instance.options.onColumnSizingChange == null ? void 0 : instance.options.onColumnSizingChange(updater),
624
+ setColumnSizingInfo: updater => instance.options.onColumnSizingInfoChange == null ? void 0 : instance.options.onColumnSizingInfoChange(updater),
625
+ resetColumnSizing: defaultState => {
626
+ var _instance$initialStat;
627
+
628
+ instance.setColumnSizing(defaultState ? {} : (_instance$initialStat = instance.initialState.columnSizing) != null ? _instance$initialStat : {});
629
+ },
630
+ resetHeaderSizeInfo: defaultState => {
631
+ var _instance$initialStat2;
632
+
633
+ instance.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : (_instance$initialStat2 = instance.initialState.columnSizingInfo) != null ? _instance$initialStat2 : getDefaultColumnSizingInfoState());
634
+ },
635
+ getTotalSize: () => {
636
+ var _instance$getHeaderGr, _instance$getHeaderGr2;
637
+
638
+ return (_instance$getHeaderGr = (_instance$getHeaderGr2 = instance.getHeaderGroups()[0]) == null ? void 0 : _instance$getHeaderGr2.headers.reduce((sum, header) => {
639
+ return sum + header.getSize();
640
+ }, 0)) != null ? _instance$getHeaderGr : 0;
641
+ },
642
+ getLeftTotalSize: () => {
643
+ var _instance$getLeftHead, _instance$getLeftHead2;
644
+
645
+ return (_instance$getLeftHead = (_instance$getLeftHead2 = instance.getLeftHeaderGroups()[0]) == null ? void 0 : _instance$getLeftHead2.headers.reduce((sum, header) => {
646
+ return sum + header.getSize();
647
+ }, 0)) != null ? _instance$getLeftHead : 0;
648
+ },
649
+ getCenterTotalSize: () => {
650
+ var _instance$getCenterHe, _instance$getCenterHe2;
651
+
652
+ return (_instance$getCenterHe = (_instance$getCenterHe2 = instance.getCenterHeaderGroups()[0]) == null ? void 0 : _instance$getCenterHe2.headers.reduce((sum, header) => {
653
+ return sum + header.getSize();
654
+ }, 0)) != null ? _instance$getCenterHe : 0;
655
+ },
656
+ getRightTotalSize: () => {
657
+ var _instance$getRightHea, _instance$getRightHea2;
658
+
659
+ return (_instance$getRightHea = (_instance$getRightHea2 = instance.getRightHeaderGroups()[0]) == null ? void 0 : _instance$getRightHea2.headers.reduce((sum, header) => {
660
+ return sum + header.getSize();
661
+ }, 0)) != null ? _instance$getRightHea : 0;
662
+ }
663
+ };
664
+ }
665
+ };
666
+ let passiveSupported = null;
667
+ function passiveEventSupported() {
668
+ if (typeof passiveSupported === 'boolean') return passiveSupported;
669
+ let supported = false;
670
+
671
+ try {
672
+ const options = {
673
+ get passive() {
674
+ supported = true;
675
+ return false;
676
+ }
677
+
678
+ };
679
+
680
+ const noop = () => {};
681
+
682
+ window.addEventListener('test', noop, options);
683
+ window.removeEventListener('test', noop);
684
+ } catch (err) {
685
+ supported = false;
686
+ }
687
+
688
+ passiveSupported = supported;
689
+ return passiveSupported;
690
+ }
691
+
692
+ function isTouchStartEvent(e) {
693
+ return e.type === 'touchstart';
694
+ }
695
+
696
+ //
697
+ const Expanding = {
698
+ getInitialState: state => {
699
+ return {
700
+ expanded: {},
701
+ ...state
702
+ };
703
+ },
704
+ getDefaultOptions: instance => {
705
+ return {
706
+ onExpandedChange: makeStateUpdater('expanded', instance),
707
+ autoResetExpanded: true,
708
+ expandSubRows: true,
709
+ paginateExpandedRows: true
710
+ };
711
+ },
712
+ createInstance: instance => {
713
+ let registered = false;
714
+ let queued = false;
715
+ return {
716
+ _autoResetExpanded: () => {
717
+ if (!registered) {
718
+ instance._queue(() => {
719
+ registered = true;
720
+ });
721
+
722
+ return;
723
+ }
724
+
725
+ if (instance.options.autoResetAll === false) {
726
+ return;
727
+ }
728
+
729
+ if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
730
+ if (queued) return;
731
+ queued = true;
732
+
733
+ instance._queue(() => {
734
+ instance.resetExpanded();
735
+ queued = false;
736
+ });
737
+ }
738
+ },
739
+ setExpanded: updater => instance.options.onExpandedChange == null ? void 0 : instance.options.onExpandedChange(updater),
740
+ toggleAllRowsExpanded: expanded => {
741
+ if (expanded != null ? expanded : !instance.getIsAllRowsExpanded()) {
742
+ instance.setExpanded(true);
743
+ } else {
744
+ instance.setExpanded({});
745
+ }
746
+ },
747
+ resetExpanded: defaultState => {
748
+ var _instance$initialStat, _instance$initialStat2;
749
+
750
+ instance.setExpanded(defaultState ? {} : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.expanded) != null ? _instance$initialStat : {});
751
+ },
752
+ getCanSomeRowsExpand: () => {
753
+ return instance.getRowModel().flatRows.some(row => row.getCanExpand());
754
+ },
755
+ getToggleAllRowsExpandedHandler: () => {
756
+ return e => {
757
+ e.persist == null ? void 0 : e.persist();
758
+ instance.toggleAllRowsExpanded();
759
+ };
760
+ },
761
+ getIsSomeRowsExpanded: () => {
762
+ const expanded = instance.getState().expanded;
763
+ return expanded === true || Object.values(expanded).some(Boolean);
764
+ },
765
+ getIsAllRowsExpanded: () => {
766
+ const expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
767
+
768
+ if (expanded === true) {
769
+ return true;
770
+ } // If any row is not expanded, return false
771
+
772
+
773
+ if (instance.getRowModel().flatRows.some(row => row.getIsExpanded())) {
774
+ return false;
775
+ } // They must all be expanded :shrug:
776
+
777
+
778
+ return true;
779
+ },
780
+ getExpandedDepth: () => {
781
+ let maxDepth = 0;
782
+ const rowIds = instance.getState().expanded === true ? Object.keys(instance.getRowModel().rowsById) : Object.keys(instance.getState().expanded);
783
+ rowIds.forEach(id => {
784
+ const splitId = id.split('.');
785
+ maxDepth = Math.max(maxDepth, splitId.length);
786
+ });
787
+ return maxDepth;
788
+ },
789
+ getPreExpandedRowModel: () => instance.getGroupedRowModel(),
790
+ getExpandedRowModel: () => {
791
+ if (!instance._getExpandedRowModel && instance.options.getExpandedRowModel) {
792
+ instance._getExpandedRowModel = instance.options.getExpandedRowModel(instance);
793
+ }
794
+
795
+ if (instance.options.manualExpanding || !instance._getExpandedRowModel) {
796
+ return instance.getPreExpandedRowModel();
797
+ }
798
+
799
+ return instance._getExpandedRowModel();
800
+ }
801
+ };
802
+ },
803
+ createRow: (row, instance) => {
804
+ return {
805
+ toggleExpanded: expanded => {
806
+ instance.setExpanded(old => {
807
+ var _expanded;
808
+
809
+ const exists = old === true ? true : !!(old != null && old[row.id]);
810
+ let oldExpanded = {};
811
+
812
+ if (old === true) {
813
+ Object.keys(instance.getRowModel().rowsById).forEach(rowId => {
814
+ oldExpanded[rowId] = true;
815
+ });
816
+ } else {
817
+ oldExpanded = old;
818
+ }
819
+
820
+ expanded = (_expanded = expanded) != null ? _expanded : !exists;
821
+
822
+ if (!exists && expanded) {
823
+ return { ...oldExpanded,
824
+ [row.id]: true
825
+ };
826
+ }
827
+
828
+ if (exists && !expanded) {
829
+ const {
830
+ [row.id]: _,
831
+ ...rest
832
+ } = oldExpanded;
833
+ return rest;
834
+ }
835
+
836
+ return old;
837
+ });
838
+ },
839
+ getIsExpanded: () => {
840
+ var _instance$options$get;
841
+
842
+ const expanded = instance.getState().expanded;
843
+ return !!((_instance$options$get = instance.options.getIsRowExpanded == null ? void 0 : instance.options.getIsRowExpanded(row)) != null ? _instance$options$get : expanded === true || (expanded == null ? void 0 : expanded[row.id]));
844
+ },
845
+ getCanExpand: () => {
846
+ var _instance$options$get2, _instance$options$ena, _row$subRows;
847
+
848
+ return ((_instance$options$get2 = instance.options.getRowCanExpand == null ? void 0 : instance.options.getRowCanExpand(row)) != null ? _instance$options$get2 : true) && ((_instance$options$ena = instance.options.enableExpanding) != null ? _instance$options$ena : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
849
+ },
850
+ getToggleExpandedHandler: () => {
851
+ const canExpand = row.getCanExpand();
852
+ return () => {
853
+ if (!canExpand) return;
854
+ row.toggleExpanded();
855
+ };
856
+ }
857
+ };
858
+ }
859
+ };
860
+
861
+ const includesString = (row, columnId, filterValue) => {
862
+ const search = filterValue.toLowerCase();
863
+ return row.getValue(columnId).toLowerCase().includes(search);
864
+ };
865
+
866
+ includesString.autoRemove = val => testFalsey(val);
867
+
868
+ const includesStringSensitive = (row, columnId, filterValue) => {
869
+ return row.getValue(columnId).includes(filterValue);
870
+ };
871
+
872
+ includesStringSensitive.autoRemove = val => testFalsey(val);
873
+
874
+ const equalsString = (row, columnId, filterValue) => {
875
+ return row.getValue(columnId).toLowerCase() === filterValue.toLowerCase();
876
+ };
877
+
878
+ equalsString.autoRemove = val => testFalsey(val);
879
+
880
+ const arrIncludes = (row, columnId, filterValue) => {
881
+ return row.getValue(columnId).includes(filterValue);
882
+ };
883
+
884
+ arrIncludes.autoRemove = val => testFalsey(val) || !(val != null && val.length);
885
+
886
+ const arrIncludesAll = (row, columnId, filterValue) => {
887
+ return !filterValue.some(val => !row.getValue(columnId).includes(val));
888
+ };
889
+
890
+ arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
891
+
892
+ const arrIncludesSome = (row, columnId, filterValue) => {
893
+ return filterValue.some(val => row.getValue(columnId).includes(val));
894
+ };
895
+
896
+ arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
897
+
898
+ const equals = (row, columnId, filterValue) => {
899
+ return row.getValue(columnId) === filterValue;
900
+ };
901
+
902
+ equals.autoRemove = val => testFalsey(val);
903
+
904
+ const weakEquals = (row, columnId, filterValue) => {
905
+ return row.getValue(columnId) == filterValue;
906
+ };
907
+
908
+ weakEquals.autoRemove = val => testFalsey(val);
909
+
910
+ const inNumberRange = (row, columnId, filterValue) => {
911
+ let [min, max] = filterValue;
912
+ const rowValue = row.getValue(columnId);
913
+ return rowValue >= min && rowValue <= max;
914
+ };
915
+
916
+ inNumberRange.resolveFilterValue = val => {
917
+ let [unsafeMin, unsafeMax] = val;
918
+ let parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
919
+ let parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
920
+ let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
921
+ let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
922
+
923
+ if (min > max) {
924
+ const temp = min;
925
+ min = max;
926
+ max = temp;
927
+ }
928
+
929
+ return [min, max];
930
+ };
931
+
932
+ inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]); // Export
933
+
934
+
935
+ const filterFns = {
936
+ includesString,
937
+ includesStringSensitive,
938
+ equalsString,
939
+ arrIncludes,
940
+ arrIncludesAll,
941
+ arrIncludesSome,
942
+ equals,
943
+ weakEquals,
944
+ inNumberRange
945
+ };
946
+
947
+ // Utils
948
+ function testFalsey(val) {
949
+ return val === undefined || val === null || val === '';
950
+ }
951
+
952
+ //
953
+ const Filters = {
954
+ getDefaultColumn: () => {
955
+ return {
956
+ filterFn: 'auto'
957
+ };
958
+ },
959
+ getInitialState: state => {
960
+ return {
961
+ columnFilters: [],
962
+ globalFilter: undefined,
963
+ // filtersProgress: 1,
964
+ // facetProgress: {},
965
+ ...state
966
+ };
967
+ },
968
+ getDefaultOptions: instance => {
969
+ return {
970
+ onColumnFiltersChange: makeStateUpdater('columnFilters', instance),
971
+ onGlobalFilterChange: makeStateUpdater('globalFilter', instance),
972
+ filterFromLeafRows: false,
973
+ globalFilterFn: 'auto',
974
+ getColumnCanGlobalFilter: column => {
975
+ var _instance$getCoreRowM, _instance$getCoreRowM2;
976
+
977
+ const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
978
+ return typeof value === 'string';
979
+ }
980
+ };
981
+ },
982
+ createColumn: (column, instance) => {
983
+ return {
984
+ filterFn: column.filterFn,
985
+ getAutoFilterFn: () => {
986
+ const firstRow = instance.getCoreRowModel().flatRows[0];
987
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
988
+
989
+ if (typeof value === 'string') {
990
+ return filterFns.includesString;
991
+ }
992
+
993
+ if (typeof value === 'number') {
994
+ return filterFns.inNumberRange;
995
+ }
996
+
997
+ if (value !== null && typeof value === 'object') {
998
+ return filterFns.equals;
999
+ }
1000
+
1001
+ if (Array.isArray(value)) {
1002
+ return filterFns.arrIncludes;
1003
+ }
1004
+
1005
+ return filterFns.weakEquals;
1006
+ },
1007
+ getFilterFn: () => {
1008
+ var _ref;
1009
+
1010
+ const userFilterFns = instance.options.filterFns;
1011
+ return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? column.getAutoFilterFn() : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
1012
+ },
1013
+ getCanFilter: () => {
1014
+ var _column$enableColumnF, _instance$options$ena, _instance$options$ena2;
1015
+
1016
+ return ((_column$enableColumnF = column.enableColumnFilter) != null ? _column$enableColumnF : true) && ((_instance$options$ena = instance.options.enableColumnFilters) != null ? _instance$options$ena : true) && ((_instance$options$ena2 = instance.options.enableFilters) != null ? _instance$options$ena2 : true) && !!column.accessorFn;
1017
+ },
1018
+ getCanGlobalFilter: () => {
1019
+ var _column$enableGlobalF, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
1020
+
1021
+ return ((_column$enableGlobalF = column.enableGlobalFilter) != null ? _column$enableGlobalF : true) && ((_instance$options$ena3 = instance.options.enableGlobalFilter) != null ? _instance$options$ena3 : true) && ((_instance$options$ena4 = instance.options.enableFilters) != null ? _instance$options$ena4 : true) && ((_instance$options$get = instance.options.getColumnCanGlobalFilter == null ? void 0 : instance.options.getColumnCanGlobalFilter(column)) != null ? _instance$options$get : true) && !!column.accessorFn;
1022
+ },
1023
+ getIsFiltered: () => column.getFilterIndex() > -1,
1024
+ getFilterValue: () => {
1025
+ var _instance$getState$co, _instance$getState$co2;
1026
+
1027
+ return (_instance$getState$co = instance.getState().columnFilters) == null ? void 0 : (_instance$getState$co2 = _instance$getState$co.find(d => d.id === column.id)) == null ? void 0 : _instance$getState$co2.value;
1028
+ },
1029
+ getFilterIndex: () => {
1030
+ var _instance$getState$co3, _instance$getState$co4;
1031
+
1032
+ return (_instance$getState$co3 = (_instance$getState$co4 = instance.getState().columnFilters) == null ? void 0 : _instance$getState$co4.findIndex(d => d.id === column.id)) != null ? _instance$getState$co3 : -1;
1033
+ },
1034
+ setFilterValue: value => {
1035
+ instance.setColumnFilters(old => {
1036
+ const filterFn = column.getFilterFn();
1037
+ const previousfilter = old == null ? void 0 : old.find(d => d.id === column.id);
1038
+ const newFilter = functionalUpdate(value, previousfilter ? previousfilter.value : undefined); //
1039
+
1040
+ if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
1041
+ var _old$filter;
1042
+
1043
+ return (_old$filter = old == null ? void 0 : old.filter(d => d.id !== column.id)) != null ? _old$filter : [];
1044
+ }
1045
+
1046
+ const newFilterObj = {
1047
+ id: column.id,
1048
+ value: newFilter
1049
+ };
1050
+
1051
+ if (previousfilter) {
1052
+ var _old$map;
1053
+
1054
+ return (_old$map = old == null ? void 0 : old.map(d => {
1055
+ if (d.id === column.id) {
1056
+ return newFilterObj;
1057
+ }
1058
+
1059
+ return d;
1060
+ })) != null ? _old$map : [];
1061
+ }
1062
+
1063
+ if (old != null && old.length) {
1064
+ return [...old, newFilterObj];
1065
+ }
1066
+
1067
+ return [newFilterObj];
1068
+ });
1069
+ },
1070
+ _getFacetedRowModel: instance.options.getFacetedRowModel && instance.options.getFacetedRowModel(instance, column.id),
1071
+ getFacetedRowModel: () => {
1072
+ if (!column._getFacetedRowModel) {
1073
+ return instance.getPreFilteredRowModel();
1074
+ }
1075
+
1076
+ return column._getFacetedRowModel();
1077
+ },
1078
+ _getFacetedUniqueValues: instance.options.getFacetedUniqueValues && instance.options.getFacetedUniqueValues(instance, column.id),
1079
+ getFacetedUniqueValues: () => {
1080
+ if (!column._getFacetedUniqueValues) {
1081
+ return new Map();
1082
+ }
1083
+
1084
+ return column._getFacetedUniqueValues();
1085
+ },
1086
+ _getFacetedMinMaxValues: instance.options.getFacetedMinMaxValues && instance.options.getFacetedMinMaxValues(instance, column.id),
1087
+ getFacetedMinMaxValues: () => {
1088
+ if (!column._getFacetedMinMaxValues) {
1089
+ return undefined;
1090
+ }
1091
+
1092
+ return column._getFacetedMinMaxValues();
1093
+ } // () => [column.getFacetedRowModel()],
1094
+ // facetedRowModel => getRowModelMinMaxValues(facetedRowModel, column.id),
1095
+
1096
+ };
1097
+ },
1098
+ createRow: (row, instance) => {
1099
+ return {
1100
+ columnFilterMap: {},
1101
+ subRowsByFacetId: {}
1102
+ };
1103
+ },
1104
+ createInstance: instance => {
1105
+ return {
1106
+ getGlobalAutoFilterFn: () => {
1107
+ return filterFns.includesString;
1108
+ },
1109
+ getGlobalFilterFn: () => {
1110
+ var _ref2;
1111
+
1112
+ const {
1113
+ filterFns: userFilterFns,
1114
+ globalFilterFn: globalFilterFn
1115
+ } = instance.options;
1116
+ return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? instance.getGlobalAutoFilterFn() : (_ref2 = userFilterFns == null ? void 0 : userFilterFns[globalFilterFn]) != null ? _ref2 : filterFns[globalFilterFn];
1117
+ },
1118
+ setColumnFilters: updater => {
1119
+ const leafColumns = instance.getAllLeafColumns();
1120
+
1121
+ const updateFn = old => {
1122
+ var _functionalUpdate;
1123
+
1124
+ return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(filter => {
1125
+ const column = leafColumns.find(d => d.id === filter.id);
1126
+
1127
+ if (column) {
1128
+ const filterFn = column.getFilterFn();
1129
+
1130
+ if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
1131
+ return false;
1132
+ }
1133
+ }
1134
+
1135
+ return true;
1136
+ });
1137
+ };
1138
+
1139
+ instance.options.onColumnFiltersChange == null ? void 0 : instance.options.onColumnFiltersChange(updateFn);
1140
+ },
1141
+ setGlobalFilter: updater => {
1142
+ instance.options.onGlobalFilterChange == null ? void 0 : instance.options.onGlobalFilterChange(updater);
1143
+ },
1144
+ resetGlobalFilter: defaultState => {
1145
+ instance.setGlobalFilter(defaultState ? undefined : instance.initialState.globalFilter);
1146
+ },
1147
+ resetColumnFilters: defaultState => {
1148
+ var _instance$initialStat, _instance$initialStat2;
1149
+
1150
+ instance.setColumnFilters(defaultState ? [] : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnFilters) != null ? _instance$initialStat : []);
1151
+ },
1152
+ getPreFilteredRowModel: () => instance.getCoreRowModel(),
1153
+ _getFilteredRowModel: instance.options.getFilteredRowModel && instance.options.getFilteredRowModel(instance),
1154
+ getFilteredRowModel: () => {
1155
+ if (instance.options.manualFiltering || !instance._getFilteredRowModel) {
1156
+ return instance.getPreFilteredRowModel();
1157
+ }
1158
+
1159
+ return instance._getFilteredRowModel();
1160
+ },
1161
+ _getGlobalFacetedRowModel: instance.options.getFacetedRowModel && instance.options.getFacetedRowModel(instance, '__global__'),
1162
+ getGlobalFacetedRowModel: () => {
1163
+ if (instance.options.manualFiltering || !instance._getGlobalFacetedRowModel) {
1164
+ return instance.getPreFilteredRowModel();
1165
+ }
1166
+
1167
+ return instance._getGlobalFacetedRowModel();
1168
+ },
1169
+ _getGlobalFacetedUniqueValues: instance.options.getFacetedUniqueValues && instance.options.getFacetedUniqueValues(instance, '__global__'),
1170
+ getGlobalFacetedUniqueValues: () => {
1171
+ if (!instance._getGlobalFacetedUniqueValues) {
1172
+ return new Map();
1173
+ }
1174
+
1175
+ return instance._getGlobalFacetedUniqueValues();
1176
+ },
1177
+ _getGlobalFacetedMinMaxValues: instance.options.getFacetedMinMaxValues && instance.options.getFacetedMinMaxValues(instance, '__global__'),
1178
+ getGlobalFacetedMinMaxValues: () => {
1179
+ if (!instance._getGlobalFacetedMinMaxValues) {
1180
+ return;
1181
+ }
1182
+
1183
+ return instance._getGlobalFacetedMinMaxValues();
1184
+ }
1185
+ };
1186
+ }
1187
+ };
1188
+ function shouldAutoRemoveFilter(filterFn, value, column) {
1189
+ return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
1190
+ }
1191
+
1192
+ const aggregationFns = {
1193
+ sum,
1194
+ min,
1195
+ max,
1196
+ extent,
1197
+ mean,
1198
+ median,
1199
+ unique,
1200
+ uniqueCount,
1201
+ count
1202
+ };
1203
+
1204
+ function sum(_getLeafValues, getChildValues) {
1205
+ // It's faster to just add the aggregations together instead of
1206
+ // process leaf nodes individually
1207
+ return getChildValues().reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1208
+ }
1209
+
1210
+ function min(_getLeafValues, getChildValues) {
1211
+ let min;
1212
+
1213
+ for (const value of getChildValues()) {
1214
+ if (value != null && (min > value || min === undefined && value >= value)) {
1215
+ min = value;
1216
+ }
1217
+ }
1218
+
1219
+ return min;
1220
+ }
1221
+
1222
+ function max(_getLeafValues, getChildValues) {
1223
+ let max;
1224
+
1225
+ for (const value of getChildValues()) {
1226
+ if (value != null && (max < value || max === undefined && value >= value)) {
1227
+ max = value;
1228
+ }
1229
+ }
1230
+
1231
+ return max;
1232
+ }
1233
+
1234
+ function extent(_getLeafValues, getChildValues) {
1235
+ let min;
1236
+ let max;
1237
+
1238
+ for (const value of getChildValues()) {
1239
+ if (value != null) {
1240
+ if (min === undefined) {
1241
+ if (value >= value) min = max = value;
1242
+ } else {
1243
+ if (min > value) min = value;
1244
+ if (max < value) max = value;
1245
+ }
1246
+ }
1247
+ }
1248
+
1249
+ return [min, max];
1250
+ }
1251
+
1252
+ function mean(getLeafValues) {
1253
+ let count = 0;
1254
+ let sum = 0;
1255
+
1256
+ for (let value of getLeafValues()) {
1257
+ if (value != null && (value = +value) >= value) {
1258
+ ++count, sum += value;
1259
+ }
1260
+ }
1261
+
1262
+ if (count) return sum / count;
1263
+ return;
1264
+ }
1265
+
1266
+ function median(getLeafValues) {
1267
+ const leafValues = getLeafValues();
1268
+
1269
+ if (!leafValues.length) {
1270
+ return;
1271
+ }
1272
+
1273
+ let min = 0;
1274
+ let max = 0;
1275
+ leafValues.forEach(value => {
1276
+ if (typeof value === 'number') {
1277
+ min = Math.min(min, value);
1278
+ max = Math.max(max, value);
1279
+ }
1280
+ });
1281
+ return (min + max) / 2;
1282
+ }
1283
+
1284
+ function unique(getLeafValues) {
1285
+ return Array.from(new Set(getLeafValues()).values());
1286
+ }
1287
+
1288
+ function uniqueCount(getLeafValues) {
1289
+ return new Set(getLeafValues()).size;
1290
+ }
1291
+
1292
+ function count(getLeafValues) {
1293
+ return getLeafValues().length;
1294
+ }
1295
+
1296
+ //
1297
+ const Grouping = {
1298
+ getDefaultColumn: () => {
1299
+ return {
1300
+ aggregationFn: 'auto'
1301
+ };
1302
+ },
1303
+ getInitialState: state => {
1304
+ return {
1305
+ grouping: [],
1306
+ ...state
1307
+ };
1308
+ },
1309
+ getDefaultOptions: instance => {
1310
+ return {
1311
+ onGroupingChange: makeStateUpdater('grouping', instance),
1312
+ groupedColumnMode: 'reorder'
1313
+ };
1314
+ },
1315
+ createColumn: (column, instance) => {
1316
+ return {
1317
+ toggleGrouping: () => {
1318
+ instance.setGrouping(old => {
1319
+ // Find any existing grouping for this column
1320
+ if (old != null && old.includes(column.id)) {
1321
+ return old.filter(d => d !== column.id);
1322
+ }
1323
+
1324
+ return [...(old != null ? old : []), column.id];
1325
+ });
1326
+ },
1327
+ getCanGroup: () => {
1328
+ var _ref, _ref2, _ref3, _column$enableGroupin;
1329
+
1330
+ return (_ref = (_ref2 = (_ref3 = (_column$enableGroupin = column.enableGrouping) != null ? _column$enableGroupin : true) != null ? _ref3 : instance.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
1331
+ },
1332
+ getIsGrouped: () => {
1333
+ var _instance$getState$gr;
1334
+
1335
+ return (_instance$getState$gr = instance.getState().grouping) == null ? void 0 : _instance$getState$gr.includes(column.id);
1336
+ },
1337
+ getGroupedIndex: () => {
1338
+ var _instance$getState$gr2;
1339
+
1340
+ return (_instance$getState$gr2 = instance.getState().grouping) == null ? void 0 : _instance$getState$gr2.indexOf(column.id);
1341
+ },
1342
+ getToggleGroupingHandler: () => {
1343
+ const canGroup = column.getCanGroup();
1344
+ return () => {
1345
+ if (!canGroup) return;
1346
+ column.toggleGrouping();
1347
+ };
1348
+ },
1349
+ getColumnAutoAggregationFn: () => {
1350
+ const firstRow = instance.getCoreRowModel().flatRows[0];
1351
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
1352
+
1353
+ if (typeof value === 'number') {
1354
+ return aggregationFns.sum;
1355
+ }
1356
+
1357
+ if (Object.prototype.toString.call(value) === '[object Date]') {
1358
+ return aggregationFns.extent;
1359
+ }
1360
+
1361
+ return aggregationFns.count;
1362
+ },
1363
+ getColumnAggregationFn: () => {
1364
+ var _ref4;
1365
+
1366
+ const userAggregationFns = instance.options.aggregationFns;
1367
+
1368
+ if (!column) {
1369
+ throw new Error();
1370
+ }
1371
+
1372
+ return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getColumnAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1373
+ }
1374
+ };
1375
+ },
1376
+ createInstance: instance => {
1377
+ return {
1378
+ setGrouping: updater => instance.options.onGroupingChange == null ? void 0 : instance.options.onGroupingChange(updater),
1379
+ resetGrouping: defaultState => {
1380
+ var _instance$initialStat, _instance$initialStat2;
1381
+
1382
+ instance.setGrouping(defaultState ? [] : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.grouping) != null ? _instance$initialStat : []);
1383
+ },
1384
+ getPreGroupedRowModel: () => instance.getSortedRowModel(),
1385
+ getGroupedRowModel: () => {
1386
+ if (!instance._getGroupedRowModel && instance.options.getGroupedRowModel) {
1387
+ instance._getGroupedRowModel = instance.options.getGroupedRowModel(instance);
1388
+ }
1389
+
1390
+ if (instance.options.manualGrouping || !instance._getGroupedRowModel) {
1391
+ return instance.getPreGroupedRowModel();
1392
+ }
1393
+
1394
+ return instance._getGroupedRowModel();
1395
+ }
1396
+ };
1397
+ },
1398
+ createRow: (row, instance) => {
1399
+ return {
1400
+ getIsGrouped: () => !!row.groupingColumnId,
1401
+ groupingValuesCache: {}
1402
+ };
1403
+ },
1404
+ createCell: (cell, column, row, instance) => {
1405
+ return {
1406
+ getIsGrouped: () => column.getIsGrouped() && column.id === row.groupingColumnId,
1407
+ getIsPlaceholder: () => !cell.getIsGrouped() && column.getIsGrouped(),
1408
+ getIsAggregated: () => {
1409
+ var _row$subRows;
1410
+
1411
+ return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1412
+ },
1413
+ renderAggregatedCell: () => {
1414
+ var _column$aggregatedCel;
1415
+
1416
+ const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
1417
+ return template ? instance._render(template, {
1418
+ instance,
1419
+ column,
1420
+ row,
1421
+ cell,
1422
+ getValue: cell.getValue
1423
+ }) : null;
1424
+ }
1425
+ };
1426
+ }
1427
+ };
1428
+ function orderColumns(leafColumns, grouping, groupedColumnMode) {
1429
+ if (!(grouping != null && grouping.length) || !groupedColumnMode) {
1430
+ return leafColumns;
1431
+ }
1432
+
1433
+ const nonGroupingColumns = leafColumns.filter(col => !grouping.includes(col.id));
1434
+
1435
+ if (groupedColumnMode === 'remove') {
1436
+ return nonGroupingColumns;
1437
+ }
1438
+
1439
+ const groupingColumns = grouping.map(g => leafColumns.find(col => col.id === g)).filter(Boolean);
1440
+ return [...groupingColumns, ...nonGroupingColumns];
1441
+ }
1442
+
1443
+ //
1444
+ const Ordering = {
1445
+ getInitialState: state => {
1446
+ return {
1447
+ columnOrder: [],
1448
+ ...state
1449
+ };
1450
+ },
1451
+ getDefaultOptions: instance => {
1452
+ return {
1453
+ onColumnOrderChange: makeStateUpdater('columnOrder', instance)
1454
+ };
1455
+ },
1456
+ createInstance: instance => {
1457
+ return {
1458
+ setColumnOrder: updater => instance.options.onColumnOrderChange == null ? void 0 : instance.options.onColumnOrderChange(updater),
1459
+ resetColumnOrder: defaultState => {
1460
+ var _instance$initialStat;
1461
+
1462
+ instance.setColumnOrder(defaultState ? [] : (_instance$initialStat = instance.initialState.columnOrder) != null ? _instance$initialStat : []);
1463
+ },
1464
+ _getOrderColumnsFn: memo(() => [instance.getState().columnOrder, instance.getState().grouping, instance.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
1465
+ // Sort grouped columns to the start of the column list
1466
+ // before the headers are built
1467
+ let orderedColumns = []; // If there is no order, return the normal columns
1468
+
1469
+ if (!(columnOrder != null && columnOrder.length)) {
1470
+ orderedColumns = columns;
1471
+ } else {
1472
+ const columnOrderCopy = [...columnOrder]; // If there is an order, make a copy of the columns
1473
+
1474
+ const columnsCopy = [...columns]; // And make a new ordered array of the columns
1475
+ // Loop over the columns and place them in order into the new array
1476
+
1477
+ while (columnsCopy.length && columnOrderCopy.length) {
1478
+ const targetColumnId = columnOrderCopy.shift();
1479
+ const foundIndex = columnsCopy.findIndex(d => d.id === targetColumnId);
1480
+
1481
+ if (foundIndex > -1) {
1482
+ orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
1483
+ }
1484
+ } // If there are any columns left, add them to the end
1485
+
1486
+
1487
+ orderedColumns = [...orderedColumns, ...columnsCopy];
1488
+ }
1489
+
1490
+ return orderColumns(orderedColumns, grouping, groupedColumnMode);
1491
+ }, {
1492
+ key: process.env.NODE_ENV === 'development' && 'getOrderColumnsFn' // debug: () => instance.options.debugAll ?? instance.options.debugTable,
1493
+
1494
+ })
1495
+ };
1496
+ }
1497
+ };
1498
+
1499
+ //
1500
+ const defaultPageIndex = 0;
1501
+ const defaultPageSize = 10;
1502
+
1503
+ const getDefaultPaginationState = () => ({
1504
+ pageIndex: defaultPageIndex,
1505
+ pageSize: defaultPageSize
1506
+ });
1507
+
1508
+ const Pagination = {
1509
+ getInitialState: state => {
1510
+ return { ...state,
1511
+ pagination: { ...getDefaultPaginationState(),
1512
+ ...(state == null ? void 0 : state.pagination)
1513
+ }
1514
+ };
1515
+ },
1516
+ getDefaultOptions: instance => {
1517
+ return {
1518
+ onPaginationChange: makeStateUpdater('pagination', instance)
1519
+ };
1520
+ },
1521
+ createInstance: instance => {
1522
+ let registered = false;
1523
+ let queued = false;
1524
+ return {
1525
+ _autoResetPageIndex: () => {
1526
+ var _ref, _instance$options$aut;
1527
+
1528
+ if (!registered) {
1529
+ instance._queue(() => {
1530
+ registered = true;
1531
+ });
1532
+
1533
+ return;
1534
+ }
1535
+
1536
+ if ((_ref = (_instance$options$aut = instance.options.autoResetAll) != null ? _instance$options$aut : instance.options.autoResetPageIndex) != null ? _ref : !instance.options.manualPagination) {
1537
+ if (queued) return;
1538
+ queued = true;
1539
+
1540
+ instance._queue(() => {
1541
+ instance.resetPageIndex();
1542
+ queued = false;
1543
+ });
1544
+ }
1545
+ },
1546
+ setPagination: updater => {
1547
+ const safeUpdater = old => {
1548
+ let newState = functionalUpdate(updater, old);
1549
+ return newState;
1550
+ };
1551
+
1552
+ return instance.options.onPaginationChange == null ? void 0 : instance.options.onPaginationChange(safeUpdater);
1553
+ },
1554
+ resetPagination: defaultState => {
1555
+ var _instance$initialStat;
1556
+
1557
+ instance.setPagination(defaultState ? getDefaultPaginationState() : (_instance$initialStat = instance.initialState.pagination) != null ? _instance$initialStat : getDefaultPaginationState());
1558
+ },
1559
+ setPageIndex: updater => {
1560
+ instance.setPagination(old => {
1561
+ let pageIndex = functionalUpdate(updater, old.pageIndex);
1562
+ const maxPageIndex = typeof old.pageCount !== 'undefined' ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
1563
+ pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
1564
+ return { ...old,
1565
+ pageIndex
1566
+ };
1567
+ });
1568
+ },
1569
+ resetPageIndex: defaultState => {
1570
+ var _instance$initialStat2, _instance$initialStat3, _instance$initialStat4;
1571
+
1572
+ instance.setPageIndex(defaultState ? defaultPageIndex : (_instance$initialStat2 = (_instance$initialStat3 = instance.initialState) == null ? void 0 : (_instance$initialStat4 = _instance$initialStat3.pagination) == null ? void 0 : _instance$initialStat4.pageIndex) != null ? _instance$initialStat2 : defaultPageIndex);
1573
+ },
1574
+ resetPageSize: defaultState => {
1575
+ var _instance$initialStat5, _instance$initialStat6, _instance$initialStat7;
1576
+
1577
+ instance.setPageSize(defaultState ? defaultPageSize : (_instance$initialStat5 = (_instance$initialStat6 = instance.initialState) == null ? void 0 : (_instance$initialStat7 = _instance$initialStat6.pagination) == null ? void 0 : _instance$initialStat7.pageSize) != null ? _instance$initialStat5 : defaultPageSize);
1578
+ },
1579
+ setPageSize: updater => {
1580
+ instance.setPagination(old => {
1581
+ const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
1582
+ const topRowIndex = old.pageSize * old.pageIndex;
1583
+ const pageIndex = Math.floor(topRowIndex / pageSize);
1584
+ return { ...old,
1585
+ pageIndex,
1586
+ pageSize
1587
+ };
1588
+ });
1589
+ },
1590
+ setPageCount: updater => instance.setPagination(old => {
1591
+ var _old$pageCount;
1592
+
1593
+ let newPageCount = functionalUpdate(updater, (_old$pageCount = old.pageCount) != null ? _old$pageCount : -1);
1594
+
1595
+ if (typeof newPageCount === 'number') {
1596
+ newPageCount = Math.max(-1, newPageCount);
1597
+ }
1598
+
1599
+ return { ...old,
1600
+ pageCount: newPageCount
1601
+ };
1602
+ }),
1603
+ getPageOptions: memo(() => [instance.getState().pagination.pageSize, instance.getState().pagination.pageCount], (pageSize, pageCount) => {
1604
+ let pageOptions = [];
1605
+
1606
+ if (pageCount && pageCount > 0) {
1607
+ pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
1608
+ }
1609
+
1610
+ return pageOptions;
1611
+ }, {
1612
+ key: process.env.NODE_ENV === 'development' && 'getPageOptions',
1613
+ debug: () => {
1614
+ var _instance$options$deb;
1615
+
1616
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
1617
+ }
1618
+ }),
1619
+ getCanPreviousPage: () => instance.getState().pagination.pageIndex > 0,
1620
+ getCanNextPage: () => {
1621
+ const {
1622
+ pageIndex
1623
+ } = instance.getState().pagination;
1624
+ const pageCount = instance.getPageCount();
1625
+
1626
+ if (pageCount === -1) {
1627
+ return true;
1628
+ }
1629
+
1630
+ if (pageCount === 0) {
1631
+ return false;
1632
+ }
1633
+
1634
+ return pageIndex < pageCount - 1;
1635
+ },
1636
+ previousPage: () => {
1637
+ return instance.setPageIndex(old => old - 1);
1638
+ },
1639
+ nextPage: () => {
1640
+ return instance.setPageIndex(old => {
1641
+ return old + 1;
1642
+ });
1643
+ },
1644
+ getPrePaginationRowModel: () => instance.getExpandedRowModel(),
1645
+ getPaginationRowModel: () => {
1646
+ if (!instance._getPaginationRowModel && instance.options.getPaginationRowModel) {
1647
+ instance._getPaginationRowModel = instance.options.getPaginationRowModel(instance);
1648
+ }
1649
+
1650
+ if (instance.options.manualPagination || !instance._getPaginationRowModel) {
1651
+ return instance.getPrePaginationRowModel();
1652
+ }
1653
+
1654
+ return instance._getPaginationRowModel();
1655
+ },
1656
+ getPageCount: () => {
1657
+ const {
1658
+ pageCount
1659
+ } = instance.getState().pagination;
1660
+
1661
+ if (typeof pageCount !== 'undefined') {
1662
+ return pageCount;
1663
+ }
1664
+
1665
+ return Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
1666
+ }
1667
+ };
1668
+ }
1669
+ };
1670
+
1671
+ //
1672
+ const getDefaultPinningState = () => ({
1673
+ left: [],
1674
+ right: []
1675
+ });
1676
+
1677
+ const Pinning = {
1678
+ getInitialState: state => {
1679
+ return {
1680
+ columnPinning: getDefaultPinningState(),
1681
+ ...state
1682
+ };
1683
+ },
1684
+ getDefaultOptions: instance => {
1685
+ return {
1686
+ onColumnPinningChange: makeStateUpdater('columnPinning', instance)
1687
+ };
1688
+ },
1689
+ createColumn: (column, instance) => {
1690
+ return {
1691
+ pin: position => {
1692
+ const columnIds = column.getLeafColumns().map(d => d.id).filter(Boolean);
1693
+ instance.setColumnPinning(old => {
1694
+ var _old$left3, _old$right3;
1695
+
1696
+ if (position === 'right') {
1697
+ var _old$left, _old$right;
1698
+
1699
+ return {
1700
+ left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter(d => !(columnIds != null && columnIds.includes(d))),
1701
+ right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds]
1702
+ };
1703
+ }
1704
+
1705
+ if (position === 'left') {
1706
+ var _old$left2, _old$right2;
1707
+
1708
+ return {
1709
+ left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds],
1710
+ right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
1711
+ };
1712
+ }
1713
+
1714
+ return {
1715
+ left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter(d => !(columnIds != null && columnIds.includes(d))),
1716
+ right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
1717
+ };
1718
+ });
1719
+ },
1720
+ getCanPin: () => {
1721
+ const leafColumns = column.getLeafColumns();
1722
+ return leafColumns.some(d => {
1723
+ var _d$enablePinning, _instance$options$ena;
1724
+
1725
+ return ((_d$enablePinning = d.enablePinning) != null ? _d$enablePinning : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1726
+ });
1727
+ },
1728
+ getIsPinned: () => {
1729
+ const leafColumnIds = column.getLeafColumns().map(d => d.id);
1730
+ const {
1731
+ left,
1732
+ right
1733
+ } = instance.getState().columnPinning;
1734
+ const isLeft = leafColumnIds.some(d => left == null ? void 0 : left.includes(d));
1735
+ const isRight = leafColumnIds.some(d => right == null ? void 0 : right.includes(d));
1736
+ return isLeft ? 'left' : isRight ? 'right' : false;
1737
+ },
1738
+ getPinnedIndex: () => {
1739
+ var _instance$getState$co, _instance$getState$co2, _instance$getState$co3;
1740
+
1741
+ const position = column.getIsPinned();
1742
+ return position ? (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnPinning) == null ? void 0 : (_instance$getState$co3 = _instance$getState$co2[position]) == null ? void 0 : _instance$getState$co3.indexOf(column.id)) != null ? _instance$getState$co : -1 : 0;
1743
+ }
1744
+ };
1745
+ },
1746
+ createRow: (row, instance) => {
1747
+ return {
1748
+ getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
1749
+ const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1750
+ return allCells.filter(d => !leftAndRight.includes(d.columnId));
1751
+ }, {
1752
+ key: process.env.NODE_ENV === 'production' && 'row.getCenterVisibleCells',
1753
+ debug: () => {
1754
+ var _instance$options$deb;
1755
+
1756
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
1757
+ }
1758
+ }),
1759
+ getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
1760
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1761
+ position: 'left'
1762
+ }));
1763
+ return cells;
1764
+ }, {
1765
+ key: process.env.NODE_ENV === 'production' && 'row.getLeftVisibleCells',
1766
+ debug: () => {
1767
+ var _instance$options$deb2;
1768
+
1769
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
1770
+ }
1771
+ }),
1772
+ getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
1773
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1774
+ position: 'left'
1775
+ }));
1776
+ return cells;
1777
+ }, {
1778
+ key: process.env.NODE_ENV === 'production' && 'row.getRightVisibleCells',
1779
+ debug: () => {
1780
+ var _instance$options$deb3;
1781
+
1782
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugRows;
1783
+ }
1784
+ })
1785
+ };
1786
+ },
1787
+ createInstance: instance => {
1788
+ return {
1789
+ setColumnPinning: updater => instance.options.onColumnPinningChange == null ? void 0 : instance.options.onColumnPinningChange(updater),
1790
+ resetColumnPinning: defaultState => {
1791
+ var _instance$initialStat, _instance$initialStat2;
1792
+
1793
+ return instance.setColumnPinning(defaultState ? getDefaultPinningState() : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnPinning) != null ? _instance$initialStat : getDefaultPinningState());
1794
+ },
1795
+ getIsSomeColumnsPinned: () => {
1796
+ const {
1797
+ left,
1798
+ right
1799
+ } = instance.getState().columnPinning;
1800
+ return Boolean((left == null ? void 0 : left.length) || (right == null ? void 0 : right.length));
1801
+ },
1802
+ getLeftLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left], (allColumns, left) => {
1803
+ return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
1804
+ }, {
1805
+ key: process.env.NODE_ENV === 'development' && 'getLeftLeafColumns',
1806
+ debug: () => {
1807
+ var _instance$options$deb4;
1808
+
1809
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
1810
+ }
1811
+ }),
1812
+ getRightLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.right], (allColumns, right) => {
1813
+ return (right != null ? right : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
1814
+ }, {
1815
+ key: process.env.NODE_ENV === 'development' && 'getRightLeafColumns',
1816
+ debug: () => {
1817
+ var _instance$options$deb5;
1818
+
1819
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
1820
+ }
1821
+ }),
1822
+ getCenterLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, left, right) => {
1823
+ const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1824
+ return allColumns.filter(d => !leftAndRight.includes(d.id));
1825
+ }, {
1826
+ key: process.env.NODE_ENV === 'development' && 'getCenterLeafColumns',
1827
+ debug: () => {
1828
+ var _instance$options$deb6;
1829
+
1830
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns;
1831
+ }
1832
+ })
1833
+ };
1834
+ }
1835
+ };
1836
+
1837
+ //
1838
+ const RowSelection = {
1839
+ getInitialState: state => {
1840
+ return {
1841
+ rowSelection: {},
1842
+ ...state
1843
+ };
1844
+ },
1845
+ getDefaultOptions: instance => {
1846
+ return {
1847
+ onRowSelectionChange: makeStateUpdater('rowSelection', instance),
1848
+ enableRowSelection: true,
1849
+ enableMultiRowSelection: true,
1850
+ enableSubRowSelection: true // enableGroupingRowSelection: false,
1851
+ // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
1852
+ // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
1853
+
1854
+ };
1855
+ },
1856
+ createInstance: instance => {
1857
+ return {
1858
+ setRowSelection: updater => instance.options.onRowSelectionChange == null ? void 0 : instance.options.onRowSelectionChange(updater),
1859
+ resetRowSelection: defaultState => {
1860
+ var _instance$initialStat;
1861
+
1862
+ return instance.setRowSelection(defaultState ? {} : (_instance$initialStat = instance.initialState.rowSelection) != null ? _instance$initialStat : {});
1863
+ },
1864
+ toggleAllRowsSelected: value => {
1865
+ instance.setRowSelection(old => {
1866
+ value = typeof value !== 'undefined' ? value : !instance.getIsAllRowsSelected();
1867
+ const rowSelection = { ...old
1868
+ };
1869
+ const preGroupedFlatRows = instance.getPreGroupedRowModel().flatRows; // We don't use `mutateRowIsSelected` here for performance reasons.
1870
+ // All of the rows are flat already, so it wouldn't be worth it
1871
+
1872
+ if (value) {
1873
+ preGroupedFlatRows.forEach(row => {
1874
+ rowSelection[row.id] = true;
1875
+ });
1876
+ } else {
1877
+ preGroupedFlatRows.forEach(row => {
1878
+ delete rowSelection[row.id];
1879
+ });
1880
+ }
1881
+
1882
+ return rowSelection;
1883
+ });
1884
+ },
1885
+ toggleAllPageRowsSelected: value => instance.setRowSelection(old => {
1886
+ typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
1887
+ const rowSelection = { ...old
1888
+ };
1889
+ instance.getRowModel().rows.forEach(row => {
1890
+ mutateRowIsSelected(rowSelection, row.id, value, instance);
1891
+ });
1892
+ return rowSelection;
1893
+ }),
1894
+ // addRowSelectionRange: rowId => {
1895
+ // const {
1896
+ // rows,
1897
+ // rowsById,
1898
+ // options: { selectGroupingRows, selectSubRows },
1899
+ // } = instance
1900
+ // const findSelectedRow = (rows: Row[]) => {
1901
+ // let found
1902
+ // rows.find(d => {
1903
+ // if (d.getIsSelected()) {
1904
+ // found = d
1905
+ // return true
1906
+ // }
1907
+ // const subFound = findSelectedRow(d.subRows || [])
1908
+ // if (subFound) {
1909
+ // found = subFound
1910
+ // return true
1911
+ // }
1912
+ // return false
1913
+ // })
1914
+ // return found
1915
+ // }
1916
+ // const firstRow = findSelectedRow(rows) || rows[0]
1917
+ // const lastRow = rowsById[rowId]
1918
+ // let include = false
1919
+ // const selectedRowIds = {}
1920
+ // const addRow = (row: Row) => {
1921
+ // mutateRowIsSelected(selectedRowIds, row.id, true, {
1922
+ // rowsById,
1923
+ // selectGroupingRows: selectGroupingRows!,
1924
+ // selectSubRows: selectSubRows!,
1925
+ // })
1926
+ // }
1927
+ // instance.rows.forEach(row => {
1928
+ // const isFirstRow = row.id === firstRow.id
1929
+ // const isLastRow = row.id === lastRow.id
1930
+ // if (isFirstRow || isLastRow) {
1931
+ // if (!include) {
1932
+ // include = true
1933
+ // } else if (include) {
1934
+ // addRow(row)
1935
+ // include = false
1936
+ // }
1937
+ // }
1938
+ // if (include) {
1939
+ // addRow(row)
1940
+ // }
1941
+ // })
1942
+ // instance.setRowSelection(selectedRowIds)
1943
+ // },
1944
+ getPreSelectedRowModel: () => instance.getCoreRowModel(),
1945
+ getSelectedRowModel: memo(() => [instance.getState().rowSelection, instance.getCoreRowModel()], (rowSelection, rowModel) => {
1946
+ if (!Object.keys(rowSelection).length) {
1947
+ return {
1948
+ rows: [],
1949
+ flatRows: [],
1950
+ rowsById: {}
1951
+ };
1952
+ }
1953
+
1954
+ return selectRowsFn(instance, rowModel);
1955
+ }, {
1956
+ key: process.env.NODE_ENV === 'development' && 'getSelectedRowModel',
1957
+ debug: () => {
1958
+ var _instance$options$deb;
1959
+
1960
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
1961
+ }
1962
+ }),
1963
+ getFilteredSelectedRowModel: memo(() => [instance.getState().rowSelection, instance.getFilteredRowModel()], (rowSelection, rowModel) => {
1964
+ if (!Object.keys(rowSelection).length) {
1965
+ return {
1966
+ rows: [],
1967
+ flatRows: [],
1968
+ rowsById: {}
1969
+ };
1970
+ }
1971
+
1972
+ return selectRowsFn(instance, rowModel);
1973
+ }, {
1974
+ key: process.env.NODE_ENV === 'production' && 'getFilteredSelectedRowModel',
1975
+ debug: () => {
1976
+ var _instance$options$deb2;
1977
+
1978
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugTable;
1979
+ }
1980
+ }),
1981
+ getGroupedSelectedRowModel: memo(() => [instance.getState().rowSelection, instance.getGroupedRowModel()], (rowSelection, rowModel) => {
1982
+ if (!Object.keys(rowSelection).length) {
1983
+ return {
1984
+ rows: [],
1985
+ flatRows: [],
1986
+ rowsById: {}
1987
+ };
1988
+ }
1989
+
1990
+ return selectRowsFn(instance, rowModel);
1991
+ }, {
1992
+ key: process.env.NODE_ENV === 'production' && 'getGroupedSelectedRowModel',
1993
+ debug: () => {
1994
+ var _instance$options$deb3;
1995
+
1996
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugTable;
1997
+ }
1998
+ }),
1999
+ ///
2000
+ // getGroupingRowCanSelect: rowId => {
2001
+ // const row = instance.getRow(rowId)
2002
+ // if (!row) {
2003
+ // throw new Error()
2004
+ // }
2005
+ // if (typeof instance.options.enableGroupingRowSelection === 'function') {
2006
+ // return instance.options.enableGroupingRowSelection(row)
2007
+ // }
2008
+ // return instance.options.enableGroupingRowSelection ?? false
2009
+ // },
2010
+ getIsAllRowsSelected: () => {
2011
+ const preFilteredFlatRows = instance.getPreFilteredRowModel().flatRows;
2012
+ const {
2013
+ rowSelection
2014
+ } = instance.getState();
2015
+ let isAllRowsSelected = Boolean(preFilteredFlatRows.length && Object.keys(rowSelection).length);
2016
+
2017
+ if (isAllRowsSelected) {
2018
+ if (preFilteredFlatRows.some(row => !rowSelection[row.id])) {
2019
+ isAllRowsSelected = false;
2020
+ }
2021
+ }
2022
+
2023
+ return isAllRowsSelected;
2024
+ },
2025
+ getIsAllPageRowsSelected: () => {
2026
+ const paginationFlatRows = instance.getPaginationRowModel().flatRows;
2027
+ const {
2028
+ rowSelection
2029
+ } = instance.getState();
2030
+ let isAllPageRowsSelected = !!paginationFlatRows.length;
2031
+
2032
+ if (isAllPageRowsSelected && paginationFlatRows.some(row => !rowSelection[row.id])) {
2033
+ isAllPageRowsSelected = false;
2034
+ }
2035
+
2036
+ return isAllPageRowsSelected;
2037
+ },
2038
+ getIsSomeRowsSelected: () => {
2039
+ var _instance$getState$ro;
2040
+
2041
+ return !instance.getIsAllRowsSelected() && !!Object.keys((_instance$getState$ro = instance.getState().rowSelection) != null ? _instance$getState$ro : {}).length;
2042
+ },
2043
+ getIsSomePageRowsSelected: () => {
2044
+ const paginationFlatRows = instance.getPaginationRowModel().flatRows;
2045
+ return instance.getIsAllPageRowsSelected() ? false : !!(paginationFlatRows != null && paginationFlatRows.length);
2046
+ },
2047
+ getToggleAllRowsSelectedHandler: () => {
2048
+ return e => {
2049
+ instance.toggleAllRowsSelected(e.target.checked);
2050
+ };
2051
+ },
2052
+ getToggleAllPageRowsSelectedHandler: () => {
2053
+ return e => {
2054
+ instance.toggleAllPageRowsSelected(e.target.checked);
2055
+ };
2056
+ }
2057
+ };
2058
+ },
2059
+ createRow: (row, instance) => {
2060
+ return {
2061
+ toggleSelected: value => {
2062
+ const isSelected = row.getIsSelected();
2063
+ instance.setRowSelection(old => {
2064
+ value = typeof value !== 'undefined' ? value : !isSelected;
2065
+
2066
+ if (isSelected === value) {
2067
+ return old;
2068
+ }
2069
+
2070
+ const selectedRowIds = { ...old
2071
+ };
2072
+ mutateRowIsSelected(selectedRowIds, row.id, value, instance);
2073
+ return selectedRowIds;
2074
+ });
2075
+ },
2076
+ getIsSelected: () => {
2077
+ const {
2078
+ rowSelection
2079
+ } = instance.getState();
2080
+ return isRowSelected(row, rowSelection) === true;
2081
+ },
2082
+ getIsSomeSelected: () => {
2083
+ const {
2084
+ rowSelection
2085
+ } = instance.getState();
2086
+ return isRowSelected(row, rowSelection) === 'some';
2087
+ },
2088
+ getCanSelect: () => {
2089
+ var _instance$options$ena;
2090
+
2091
+ if (typeof instance.options.enableRowSelection === 'function') {
2092
+ return instance.options.enableRowSelection(row);
2093
+ }
2094
+
2095
+ return (_instance$options$ena = instance.options.enableRowSelection) != null ? _instance$options$ena : true;
2096
+ },
2097
+ getCanSelectSubRows: () => {
2098
+ var _instance$options$ena2;
2099
+
2100
+ if (typeof instance.options.enableSubRowSelection === 'function') {
2101
+ return instance.options.enableSubRowSelection(row);
2102
+ }
2103
+
2104
+ return (_instance$options$ena2 = instance.options.enableSubRowSelection) != null ? _instance$options$ena2 : true;
2105
+ },
2106
+ getCanMultiSelect: () => {
2107
+ var _instance$options$ena3;
2108
+
2109
+ if (typeof instance.options.enableMultiRowSelection === 'function') {
2110
+ return instance.options.enableMultiRowSelection(row);
2111
+ }
2112
+
2113
+ return (_instance$options$ena3 = instance.options.enableMultiRowSelection) != null ? _instance$options$ena3 : true;
2114
+ },
2115
+ getToggleSelectedHandler: () => {
2116
+ const canSelect = row.getCanSelect();
2117
+ return e => {
2118
+ var _target;
2119
+
2120
+ if (!canSelect) return;
2121
+ row.toggleSelected((_target = e.target) == null ? void 0 : _target.checked);
2122
+ };
2123
+ }
2124
+ };
2125
+ }
2126
+ };
2127
+
2128
+ const mutateRowIsSelected = (selectedRowIds, id, value, instance) => {
2129
+ var _row$subRows;
2130
+
2131
+ const row = instance.getRow(id);
2132
+ row.getIsGrouped(); // if ( // TODO: enforce grouping row selection rules
2133
+ // !isGrouped ||
2134
+ // (isGrouped && instance.options.enableGroupingRowSelection)
2135
+ // ) {
2136
+
2137
+ if (value) {
2138
+ selectedRowIds[id] = true;
2139
+ } else {
2140
+ delete selectedRowIds[id];
2141
+ } // }
2142
+
2143
+
2144
+ if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getCanSelectSubRows()) {
2145
+ row.subRows.forEach(row => mutateRowIsSelected(selectedRowIds, row.id, value, instance));
2146
+ }
2147
+ };
2148
+
2149
+ function selectRowsFn(instance, rowModel) {
2150
+ const rowSelection = instance.getState().rowSelection;
2151
+ const newSelectedFlatRows = [];
2152
+ const newSelectedRowsById = {}; // Filters top level and nested rows
2153
+
2154
+ const recurseRows = function (rows, depth) {
2155
+ if (depth === void 0) {
2156
+ depth = 0;
2157
+ }
2158
+
2159
+ return rows.map(row => {
2160
+ var _row$subRows2;
2161
+
2162
+ const isSelected = isRowSelected(row, rowSelection) === true;
2163
+
2164
+ if (isSelected) {
2165
+ newSelectedFlatRows.push(row);
2166
+ newSelectedRowsById[row.id] = row;
2167
+ }
2168
+
2169
+ if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
2170
+ row = { ...row,
2171
+ subRows: recurseRows(row.subRows, depth + 1)
2172
+ };
2173
+ }
2174
+
2175
+ if (isSelected) {
2176
+ return row;
2177
+ }
2178
+ }).filter(Boolean);
2179
+ };
2180
+
2181
+ return {
2182
+ rows: recurseRows(rowModel.rows),
2183
+ flatRows: newSelectedFlatRows,
2184
+ rowsById: newSelectedRowsById
2185
+ };
2186
+ }
2187
+ function isRowSelected(row, selection, instance) {
2188
+ if (selection[row.id]) {
2189
+ return true;
2190
+ }
2191
+
2192
+ if (row.subRows && row.subRows.length) {
2193
+ let allChildrenSelected = true;
2194
+ let someSelected = false;
2195
+ row.subRows.forEach(subRow => {
2196
+ // Bail out early if we know both of these
2197
+ if (someSelected && !allChildrenSelected) {
2198
+ return;
2199
+ }
2200
+
2201
+ if (isRowSelected(subRow, selection)) {
2202
+ someSelected = true;
2203
+ } else {
2204
+ allChildrenSelected = false;
2205
+ }
2206
+ });
2207
+ return allChildrenSelected ? true : someSelected ? 'some' : false;
2208
+ }
2209
+
2210
+ return false;
2211
+ }
2212
+
2213
+ const reSplitAlphaNumeric = /([0-9]+)/gm;
2214
+ const sortingFns = {
2215
+ alphanumeric,
2216
+ alphanumericCaseSensitive,
2217
+ text,
2218
+ textCaseSensitive,
2219
+ datetime,
2220
+ basic
2221
+ };
2222
+
2223
+ function alphanumeric(rowA, rowB, columnId) {
2224
+ return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
2225
+ }
2226
+
2227
+ function alphanumericCaseSensitive(rowA, rowB, columnId) {
2228
+ return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
2229
+ } // Mixed sorting is slow, but very inclusive of many edge cases.
2230
+ // It handles numbers, mixed alphanumeric combinations, and even
2231
+ // null, undefined, and Infinity
2232
+
2233
+
2234
+ function compareAlphanumeric(aStr, bStr) {
2235
+ // Split on number groups, but keep the delimiter
2236
+ // Then remove falsey split values
2237
+ const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
2238
+ const b = bStr.split(reSplitAlphaNumeric).filter(Boolean); // While
2239
+
2240
+ while (a.length && b.length) {
2241
+ const aa = a.shift();
2242
+ const bb = b.shift();
2243
+ const an = parseInt(aa, 10);
2244
+ const bn = parseInt(bb, 10);
2245
+ const combo = [an, bn].sort(); // Both are string
2246
+
2247
+ if (isNaN(combo[0])) {
2248
+ if (aa > bb) {
2249
+ return 1;
2250
+ }
2251
+
2252
+ if (bb > aa) {
2253
+ return -1;
2254
+ }
2255
+
2256
+ continue;
2257
+ } // One is a string, one is a number
2258
+
2259
+
2260
+ if (isNaN(combo[1])) {
2261
+ return isNaN(an) ? -1 : 1;
2262
+ } // Both are numbers
2263
+
2264
+
2265
+ if (an > bn) {
2266
+ return 1;
2267
+ }
2268
+
2269
+ if (bn > an) {
2270
+ return -1;
2271
+ }
2272
+ }
2273
+
2274
+ return a.length - b.length;
2275
+ } // The text filter is more basic (less numeric support)
2276
+ // but is much faster
2277
+
2278
+
2279
+ function text(rowA, rowB, columnId) {
2280
+ return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
2281
+ } // The text filter is more basic (less numeric support)
2282
+ // but is much faster
2283
+
2284
+
2285
+ function textCaseSensitive(rowA, rowB, columnId) {
2286
+ return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
2287
+ }
2288
+
2289
+ function datetime(rowA, rowB, columnId) {
2290
+ return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
2291
+ }
2292
+
2293
+ function basic(rowA, rowB, columnId) {
2294
+ return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
2295
+ } // Utils
2296
+
2297
+
2298
+ function compareBasic(a, b) {
2299
+ return a === b ? 0 : a > b ? 1 : -1;
2300
+ }
2301
+
2302
+ function toString(a) {
2303
+ if (typeof a === 'number') {
2304
+ if (isNaN(a) || a === Infinity || a === -Infinity) {
2305
+ return '';
2306
+ }
2307
+
2308
+ return String(a);
2309
+ }
2310
+
2311
+ if (typeof a === 'string') {
2312
+ return a;
2313
+ }
2314
+
2315
+ return '';
2316
+ }
2317
+
2318
+ //
2319
+ const Sorting = {
2320
+ getInitialState: state => {
2321
+ return {
2322
+ sorting: [],
2323
+ ...state
2324
+ };
2325
+ },
2326
+ getDefaultColumn: () => {
2327
+ return {
2328
+ sortingFn: 'auto'
2329
+ };
2330
+ },
2331
+ getDefaultOptions: instance => {
2332
+ return {
2333
+ onSortingChange: makeStateUpdater('sorting', instance),
2334
+ isMultiSortEvent: e => {
2335
+ return e.shiftKey;
2336
+ }
2337
+ };
2338
+ },
2339
+ createColumn: (column, instance) => {
2340
+ return {
2341
+ getAutoSortingFn: () => {
2342
+ const firstRows = instance.getFilteredRowModel().flatRows.slice(100);
2343
+ let isString = false;
2344
+
2345
+ for (const row of firstRows) {
2346
+ const value = row == null ? void 0 : row.getValue(column.id);
2347
+
2348
+ if (Object.prototype.toString.call(value) === '[object Date]') {
2349
+ return sortingFns.datetime;
2350
+ }
2351
+
2352
+ if (typeof value === 'string') {
2353
+ isString = true;
2354
+
2355
+ if (value.split(reSplitAlphaNumeric).length > 1) {
2356
+ return sortingFns.alphanumeric;
2357
+ }
2358
+ }
2359
+ }
2360
+
2361
+ if (isString) {
2362
+ return sortingFns.text;
2363
+ }
2364
+
2365
+ return sortingFns.basic;
2366
+ },
2367
+ getAutoSortDir: () => {
2368
+ const firstRow = instance.getFilteredRowModel().flatRows[0];
2369
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
2370
+
2371
+ if (typeof value === 'string') {
2372
+ return 'asc';
2373
+ }
2374
+
2375
+ return 'desc';
2376
+ },
2377
+ getSortingFn: () => {
2378
+ var _ref;
2379
+
2380
+ const userSortingFn = instance.options.sortingFns;
2381
+
2382
+ if (!column) {
2383
+ throw new Error();
2384
+ }
2385
+
2386
+ return isFunction(column.sortingFn) ? column.sortingFn : column.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.sortingFn]) != null ? _ref : sortingFns[column.sortingFn];
2387
+ },
2388
+ toggleSorting: (desc, multi) => {
2389
+ // if (column.columns.length) {
2390
+ // column.columns.forEach((c, i) => {
2391
+ // if (c.id) {
2392
+ // instance.toggleColumnSorting(c.id, undefined, multi || !!i)
2393
+ // }
2394
+ // })
2395
+ // return
2396
+ // }
2397
+ instance.setSorting(old => {
2398
+ var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
2399
+
2400
+ // Find any existing sorting for this column
2401
+ const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
2402
+ const existingIndex = old == null ? void 0 : old.findIndex(d => d.id === column.id);
2403
+ const hasDescDefined = typeof desc !== 'undefined' && desc !== null;
2404
+ let newSorting = []; // What should we do with this sort action?
2405
+
2406
+ let sortAction;
2407
+
2408
+ if (column.getCanMultiSort() && multi) {
2409
+ if (existingSorting) {
2410
+ sortAction = 'toggle';
2411
+ } else {
2412
+ sortAction = 'add';
2413
+ }
2414
+ } else {
2415
+ // Normal mode
2416
+ if (old != null && old.length && existingIndex !== old.length - 1) {
2417
+ sortAction = 'replace';
2418
+ } else if (existingSorting) {
2419
+ sortAction = 'toggle';
2420
+ } else {
2421
+ sortAction = 'replace';
2422
+ }
2423
+ }
2424
+
2425
+ const sortDescFirst = (_ref2 = (_column$sortDescFirst = column.sortDescFirst) != null ? _column$sortDescFirst : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
2426
+
2427
+ if (sortAction === 'toggle' && ( // Must be toggling
2428
+ (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
2429
+ !hasDescDefined && ( // Must not be setting desc
2430
+ multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
2431
+ existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
2432
+ ? !sortDescFirst : sortDescFirst)) {
2433
+ sortAction = 'remove';
2434
+ }
2435
+
2436
+ if (sortAction === 'replace') {
2437
+ newSorting = [{
2438
+ id: column.id,
2439
+ desc: hasDescDefined ? desc : !!sortDescFirst
2440
+ }];
2441
+ } else if (sortAction === 'add' && old != null && old.length) {
2442
+ var _instance$options$max;
2443
+
2444
+ newSorting = [...old, {
2445
+ id: column.id,
2446
+ desc: hasDescDefined ? desc : !!sortDescFirst
2447
+ }]; // Take latest n columns
2448
+
2449
+ newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
2450
+ } else if (sortAction === 'toggle' && old != null && old.length) {
2451
+ // This flips (or sets) the
2452
+ newSorting = old.map(d => {
2453
+ if (d.id === column.id) {
2454
+ return { ...d,
2455
+ desc: hasDescDefined ? desc : !(existingSorting != null && existingSorting.desc)
2456
+ };
2457
+ }
2458
+
2459
+ return d;
2460
+ });
2461
+ } else if (sortAction === 'remove' && old != null && old.length) {
2462
+ newSorting = old.filter(d => d.id !== column.id);
2463
+ }
2464
+
2465
+ return newSorting;
2466
+ });
2467
+ },
2468
+ getCanSort: () => {
2469
+ var _column$enableSorting, _instance$options$ena3;
2470
+
2471
+ return ((_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : true) && ((_instance$options$ena3 = instance.options.enableSorting) != null ? _instance$options$ena3 : true) && !!column.accessorFn;
2472
+ },
2473
+ getCanMultiSort: () => {
2474
+ var _ref3, _column$enableMultiSo;
2475
+
2476
+ return (_ref3 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2477
+ },
2478
+ getIsSorted: () => {
2479
+ var _instance$getState$so;
2480
+
2481
+ const columnSort = (_instance$getState$so = instance.getState().sorting) == null ? void 0 : _instance$getState$so.find(d => d.id === column.id);
2482
+ return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
2483
+ },
2484
+ getSortIndex: () => {
2485
+ var _instance$getState$so2, _instance$getState$so3;
2486
+
2487
+ return (_instance$getState$so2 = (_instance$getState$so3 = instance.getState().sorting) == null ? void 0 : _instance$getState$so3.findIndex(d => d.id === column.id)) != null ? _instance$getState$so2 : -1;
2488
+ },
2489
+ clearSorting: () => {
2490
+ //clear sorting for just 1 column
2491
+ instance.setSorting(old => old != null && old.length ? old.filter(d => d.id !== column.id) : []);
2492
+ },
2493
+ getToggleSortingHandler: () => {
2494
+ const canSort = column.getCanSort();
2495
+ return e => {
2496
+ if (!canSort) return;
2497
+ e.persist == null ? void 0 : e.persist();
2498
+ column.toggleSorting == null ? void 0 : column.toggleSorting(undefined, column.getCanMultiSort() ? instance.options.isMultiSortEvent == null ? void 0 : instance.options.isMultiSortEvent(e) : false);
2499
+ };
2500
+ }
2501
+ };
2502
+ },
2503
+ createInstance: instance => {
2504
+ return {
2505
+ setSorting: updater => instance.options.onSortingChange == null ? void 0 : instance.options.onSortingChange(updater),
2506
+ resetSorting: defaultState => {
2507
+ var _instance$initialStat, _instance$initialStat2;
2508
+
2509
+ instance.setSorting(defaultState ? [] : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.sorting) != null ? _instance$initialStat : []);
2510
+ },
2511
+ getPreSortedRowModel: () => instance.getFilteredRowModel(),
2512
+ getSortedRowModel: () => {
2513
+ if (!instance._getSortedRowModel && instance.options.getSortedRowModel) {
2514
+ instance._getSortedRowModel = instance.options.getSortedRowModel(instance);
2515
+ }
2516
+
2517
+ if (instance.options.manualSorting || !instance._getSortedRowModel) {
2518
+ return instance.getPreSortedRowModel();
2519
+ }
2520
+
2521
+ return instance._getSortedRowModel();
2522
+ }
2523
+ };
2524
+ }
2525
+ };
2526
+
2527
+ //
2528
+ const Visibility = {
2529
+ getInitialState: state => {
2530
+ return {
2531
+ columnVisibility: {},
2532
+ ...state
2533
+ };
2534
+ },
2535
+ getDefaultOptions: instance => {
2536
+ return {
2537
+ onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
2538
+ };
2539
+ },
2540
+ getDefaultColumn: () => {
2541
+ return {
2542
+ defaultIsVisible: true
2543
+ };
2544
+ },
2545
+ createColumn: (column, instance) => {
2546
+ return {
2547
+ toggleVisibility: value => {
2548
+ if (column.getCanHide()) {
2549
+ instance.setColumnVisibility(old => ({ ...old,
2550
+ [column.id]: value != null ? value : !column.getIsVisible()
2551
+ }));
2552
+ }
2553
+ },
2554
+ getIsVisible: () => {
2555
+ var _instance$getState$co, _instance$getState$co2;
2556
+
2557
+ return (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[column.id]) != null ? _instance$getState$co : true;
2558
+ },
2559
+ getCanHide: () => {
2560
+ var _column$enableHiding, _instance$options$ena;
2561
+
2562
+ return ((_column$enableHiding = column.enableHiding) != null ? _column$enableHiding : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2563
+ },
2564
+ getToggleVisibilityHandler: () => {
2565
+ return e => {
2566
+ column.toggleVisibility == null ? void 0 : column.toggleVisibility(e.target.checked);
2567
+ };
2568
+ }
2569
+ };
2570
+ },
2571
+ createRow: (row, instance) => {
2572
+ return {
2573
+ _getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
2574
+ return row.getAllCells().filter(cell => cell.column.getIsVisible());
2575
+ }, {
2576
+ key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
2577
+ debug: () => {
2578
+ var _instance$options$deb;
2579
+
2580
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2581
+ }
2582
+ }),
2583
+ getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2584
+ key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
2585
+ debug: () => {
2586
+ var _instance$options$deb2;
2587
+
2588
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2589
+ }
2590
+ })
2591
+ };
2592
+ },
2593
+ createInstance: instance => {
2594
+ const makeVisibleColumnsMethod = (key, getColumns) => {
2595
+ return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2596
+ return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2597
+ }, {
2598
+ key,
2599
+ debug: () => {
2600
+ var _instance$options$deb3;
2601
+
2602
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2603
+ }
2604
+ });
2605
+ };
2606
+
2607
+ return {
2608
+ getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2609
+ getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2610
+ getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2611
+ getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2612
+ getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2613
+ setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2614
+ resetColumnVisibility: defaultState => {
2615
+ var _instance$initialStat;
2616
+
2617
+ instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2618
+ },
2619
+ toggleAllColumnsVisible: value => {
2620
+ var _value;
2621
+
2622
+ value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2623
+ instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2624
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2625
+ }), {}));
2626
+ },
2627
+ getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2628
+ getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2629
+ getToggleAllColumnsVisibilityHandler: () => {
2630
+ return e => {
2631
+ var _target;
2632
+
2633
+ instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2634
+ };
2635
+ }
2636
+ };
2637
+ }
2638
+ };
2639
+
2640
+ //
2641
+ const Headers = {
2642
+ createInstance: instance => {
2643
+ return {
2644
+ createHeader: (column, options) => {
2645
+ var _options$id;
2646
+
2647
+ const id = (_options$id = options.id) != null ? _options$id : column.id;
2648
+ let header = {
2649
+ id,
2650
+ column,
2651
+ index: options.index,
2652
+ isPlaceholder: options.isPlaceholder,
2653
+ placeholderId: options.placeholderId,
2654
+ depth: options.depth,
2655
+ subHeaders: [],
2656
+ colSpan: 0,
2657
+ rowSpan: 0,
2658
+ headerGroup: null,
2659
+ getLeafHeaders: () => {
2660
+ const leafHeaders = [];
2661
+
2662
+ const recurseHeader = h => {
2663
+ if (h.subHeaders && h.subHeaders.length) {
2664
+ h.subHeaders.map(recurseHeader);
2665
+ }
2666
+
2667
+ leafHeaders.push(h);
2668
+ };
2669
+
2670
+ recurseHeader(header);
2671
+ return leafHeaders;
2672
+ },
2673
+ renderHeader: () => column.header ? instance._render(column.header, {
2674
+ instance,
2675
+ header: header,
2676
+ column
2677
+ }) : null,
2678
+ renderFooter: () => column.footer ? instance._render(column.footer, {
2679
+ instance,
2680
+ header: header,
2681
+ column
2682
+ }) : null
2683
+ };
2684
+
2685
+ instance._features.forEach(feature => {
2686
+ Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
2687
+ });
2688
+
2689
+ return header;
2690
+ },
2691
+ // Header Groups
2692
+ getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2693
+ var _left$map$filter, _right$map$filter;
2694
+
2695
+ const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2696
+ const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2697
+ const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2698
+ const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
2699
+ return headerGroups;
2700
+ }, {
2701
+ key: process.env.NODE_ENV === 'development' && 'getHeaderGroups',
2702
+ debug: () => {
2703
+ var _instance$options$deb;
2704
+
2705
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
2706
+ }
2707
+ }),
2708
+ getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2709
+ leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2710
+ return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
2711
+ }, {
2712
+ key: process.env.NODE_ENV === 'development' && 'getCenterHeaderGroups',
2713
+ debug: () => {
2714
+ var _instance$options$deb2;
2715
+
2716
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
2717
+ }
2718
+ }),
2719
+ getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2720
+ var _left$map$filter2;
2721
+
2722
+ const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
2723
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2724
+ }, {
2725
+ key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
2726
+ debug: () => {
2727
+ var _instance$options$deb3;
2728
+
2729
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
2730
+ }
2731
+ }),
2732
+ getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2733
+ var _right$map$filter2;
2734
+
2735
+ const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
2736
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2737
+ }, {
2738
+ key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
2739
+ debug: () => {
2740
+ var _instance$options$deb4;
2741
+
2742
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
2743
+ }
2744
+ }),
2745
+ // Footer Groups
2746
+ getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
2747
+ return [...headerGroups].reverse();
2748
+ }, {
2749
+ key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
2750
+ debug: () => {
2751
+ var _instance$options$deb5;
2752
+
2753
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
2754
+ }
2755
+ }),
2756
+ getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
2757
+ return [...headerGroups].reverse();
2758
+ }, {
2759
+ key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
2760
+ debug: () => {
2761
+ var _instance$options$deb6;
2762
+
2763
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
2764
+ }
2765
+ }),
2766
+ getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
2767
+ return [...headerGroups].reverse();
2768
+ }, {
2769
+ key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
2770
+ debug: () => {
2771
+ var _instance$options$deb7;
2772
+
2773
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
2774
+ }
2775
+ }),
2776
+ getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
2777
+ return [...headerGroups].reverse();
2778
+ }, {
2779
+ key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
2780
+ debug: () => {
2781
+ var _instance$options$deb8;
2782
+
2783
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
2784
+ }
2785
+ }),
2786
+ // Flat Headers
2787
+ getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
2788
+ return headerGroups.map(headerGroup => {
2789
+ return headerGroup.headers;
2790
+ }).flat();
2791
+ }, {
2792
+ key: process.env.NODE_ENV === 'development' && 'getFlatHeaders',
2793
+ debug: () => {
2794
+ var _instance$options$deb9;
2795
+
2796
+ return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
2797
+ }
2798
+ }),
2799
+ getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
2800
+ return left.map(headerGroup => {
2801
+ return headerGroup.headers;
2802
+ }).flat();
2803
+ }, {
2804
+ key: process.env.NODE_ENV === 'development' && 'getLeftFlatHeaders',
2805
+ debug: () => {
2806
+ var _instance$options$deb10;
2807
+
2808
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
2809
+ }
2810
+ }),
2811
+ getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
2812
+ return left.map(headerGroup => {
2813
+ return headerGroup.headers;
2814
+ }).flat();
2815
+ }, {
2816
+ key: process.env.NODE_ENV === 'development' && 'getCenterFlatHeaders',
2817
+ debug: () => {
2818
+ var _instance$options$deb11;
2819
+
2820
+ return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
2821
+ }
2822
+ }),
2823
+ getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
2824
+ return left.map(headerGroup => {
2825
+ return headerGroup.headers;
2826
+ }).flat();
2827
+ }, {
2828
+ key: process.env.NODE_ENV === 'development' && 'getRightFlatHeaders',
2829
+ debug: () => {
2830
+ var _instance$options$deb12;
2831
+
2832
+ return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
2833
+ }
2834
+ }),
2835
+ // Leaf Headers
2836
+ getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
2837
+ return flatHeaders.filter(header => {
2838
+ var _header$subHeaders;
2839
+
2840
+ return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
2841
+ });
2842
+ }, {
2843
+ key: process.env.NODE_ENV === 'development' && 'getCenterLeafHeaders',
2844
+ debug: () => {
2845
+ var _instance$options$deb13;
2846
+
2847
+ return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
2848
+ }
2849
+ }),
2850
+ getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
2851
+ return flatHeaders.filter(header => {
2852
+ var _header$subHeaders2;
2853
+
2854
+ return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
2855
+ });
2856
+ }, {
2857
+ key: process.env.NODE_ENV === 'development' && 'getLeftLeafHeaders',
2858
+ debug: () => {
2859
+ var _instance$options$deb14;
2860
+
2861
+ return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
2862
+ }
2863
+ }),
2864
+ getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
2865
+ return flatHeaders.filter(header => {
2866
+ var _header$subHeaders3;
2867
+
2868
+ return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
2869
+ });
2870
+ }, {
2871
+ key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
2872
+ debug: () => {
2873
+ var _instance$options$deb15;
2874
+
2875
+ return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
2876
+ }
2877
+ }),
2878
+ getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
2879
+ var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
2880
+
2881
+ return [...((_left$0$headers = (_left$ = left[0]) == null ? void 0 : _left$.headers) != null ? _left$0$headers : []), ...((_center$0$headers = (_center$ = center[0]) == null ? void 0 : _center$.headers) != null ? _center$0$headers : []), ...((_right$0$headers = (_right$ = right[0]) == null ? void 0 : _right$.headers) != null ? _right$0$headers : [])].map(header => {
2882
+ return header.getLeafHeaders();
2883
+ }).flat();
2884
+ }, {
2885
+ key: process.env.NODE_ENV === 'development' && 'getLeafHeaders',
2886
+ debug: () => {
2887
+ var _instance$options$deb16;
2888
+
2889
+ return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
2890
+ }
2891
+ }),
2892
+ getHeader: id => {
2893
+ const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
2894
+
2895
+ if (!header) {
2896
+ if (process.env.NODE_ENV !== 'production') {
2897
+ console.warn("Could not find header with id: " + id);
2898
+ }
2899
+
2900
+ throw new Error();
2901
+ }
2902
+
2903
+ return header;
2904
+ }
2905
+ };
2906
+ }
2907
+ };
2908
+ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
2909
+ var _headerGroups$0$heade, _headerGroups$;
2910
+
2911
+ // Find the max depth of the columns:
2912
+ // build the leaf column row
2913
+ // build each buffer row going up
2914
+ // placeholder for non-existent level
2915
+ // real column for existing level
2916
+ let maxDepth = 0;
2917
+
2918
+ const findMaxDepth = function (columns, depth) {
2919
+ if (depth === void 0) {
2920
+ depth = 1;
2921
+ }
2922
+
2923
+ maxDepth = Math.max(maxDepth, depth);
2924
+ columns.filter(column => column.getIsVisible()).forEach(column => {
2925
+ var _column$columns;
2926
+
2927
+ if ((_column$columns = column.columns) != null && _column$columns.length) {
2928
+ findMaxDepth(column.columns, depth + 1);
2929
+ }
2930
+ }, 0);
2931
+ };
2932
+
2933
+ findMaxDepth(allColumns);
2934
+ let headerGroups = [];
2935
+
2936
+ const createHeaderGroup = (headersToGroup, depth) => {
2937
+ // The header group we are creating
2938
+ const headerGroup = {
2939
+ depth,
2940
+ id: [headerFamily, "" + depth].filter(Boolean).join('_'),
2941
+ headers: []
2942
+ }; // The parent columns we're going to scan next
2943
+
2944
+ const pendingParentHeaders = []; // Scan each column for parents
2945
+
2946
+ headersToGroup.forEach(headerToGroup => {
2947
+ // What is the latest (last) parent column?
2948
+ const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
2949
+ const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
2950
+ let column;
2951
+ let isPlaceholder = false;
2952
+
2953
+ if (isLeafHeader && headerToGroup.column.parent) {
2954
+ // The parent header is new
2955
+ column = headerToGroup.column.parent;
2956
+ } else {
2957
+ // The parent header is repeated
2958
+ column = headerToGroup.column;
2959
+ isPlaceholder = true;
2960
+ }
2961
+
2962
+ if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
2963
+ // This column is repeated. Add it as a sub header to the next batch
2964
+ latestPendingParentHeader.subHeaders.push(headerToGroup);
2965
+ } else {
2966
+ // This is a new header. Let's create it
2967
+ const header = instance.createHeader(column, {
2968
+ id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
2969
+ isPlaceholder,
2970
+ placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
2971
+ depth,
2972
+ index: pendingParentHeaders.length
2973
+ }); // Add the headerToGroup as a subHeader of the new header
2974
+
2975
+ header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
2976
+ // in the next batch
2977
+
2978
+ pendingParentHeaders.push(header);
2979
+ }
2980
+
2981
+ headerGroup.headers.push(headerToGroup);
2982
+ headerToGroup.headerGroup = headerGroup;
2983
+ });
2984
+ headerGroups.push(headerGroup);
2985
+
2986
+ if (depth > 0) {
2987
+ createHeaderGroup(pendingParentHeaders, depth - 1);
2988
+ }
2989
+ };
2990
+
2991
+ const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
2992
+ depth: maxDepth,
2993
+ index
2994
+ }));
2995
+ createHeaderGroup(bottomHeaders, maxDepth - 1);
2996
+ headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
2997
+ // return !headerGroup.headers.every(header => header.isPlaceholder)
2998
+ // })
2999
+
3000
+ const recurseHeadersForSpans = headers => {
3001
+ const filteredHeaders = headers.filter(header => header.column.getIsVisible());
3002
+ return filteredHeaders.map(header => {
3003
+ let colSpan = 0;
3004
+ let rowSpan = 0;
3005
+ let childRowSpans = [0];
3006
+
3007
+ if (header.subHeaders && header.subHeaders.length) {
3008
+ childRowSpans = [];
3009
+ recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
3010
+ let {
3011
+ colSpan: childColSpan,
3012
+ rowSpan: childRowSpan
3013
+ } = _ref;
3014
+ colSpan += childColSpan;
3015
+ childRowSpans.push(childRowSpan);
3016
+ });
3017
+ } else {
3018
+ colSpan = 1;
3019
+ }
3020
+
3021
+ const minChildRowSpan = Math.min(...childRowSpans);
3022
+ rowSpan = rowSpan + minChildRowSpan;
3023
+ header.colSpan = colSpan > 0 ? colSpan : undefined;
3024
+ header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
3025
+ return {
3026
+ colSpan,
3027
+ rowSpan
3028
+ };
3029
+ });
3030
+ };
3031
+
3032
+ recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
3033
+ return headerGroups;
3034
+ }
3035
+
3036
+ // export type Batch = {
3037
+ // id: number
3038
+ // priority: keyof CoreBatches
3039
+ // tasks: (() => void)[]
3040
+ // schedule: (cb: () => void) => void
3041
+ // cancel: () => void
3042
+ // }
3043
+ // type CoreBatches = {
3044
+ // data: Batch[]
3045
+ // facets: Batch[]
3046
+ // }
3047
+ function createTableInstance(options) {
3048
+ var _options$initialState;
3049
+
3050
+ if (options.debugAll || options.debugTable) {
3051
+ console.info('Creating Table Instance...');
3052
+ }
3053
+
3054
+ let instance = {
3055
+ _features: [Columns, Rows, Cells, Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]
3056
+ };
3057
+
3058
+ const defaultOptions = instance._features.reduce((obj, feature) => {
3059
+ return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(instance));
3060
+ }, {});
3061
+
3062
+ const mergeOptions = options => {
3063
+ if (instance.options.mergeOptions) {
3064
+ return instance.options.mergeOptions(defaultOptions, options);
3065
+ }
3066
+
3067
+ return { ...defaultOptions,
3068
+ ...options
3069
+ };
3070
+ };
3071
+
3072
+ const coreInitialState = {// coreProgress: 1,
3073
+ };
3074
+ let initialState = { ...coreInitialState,
3075
+ ...((_options$initialState = options.initialState) != null ? _options$initialState : {})
3076
+ };
3077
+
3078
+ instance._features.forEach(feature => {
3079
+ var _feature$getInitialSt;
3080
+
3081
+ initialState = (_feature$getInitialSt = feature.getInitialState == null ? void 0 : feature.getInitialState(initialState)) != null ? _feature$getInitialSt : initialState;
3082
+ });
3083
+
3084
+ const queued = [];
3085
+ let queuedTimeout = false;
3086
+ const midInstance = { ...instance,
3087
+ // init: () => {
3088
+ // startWork()
3089
+ // },
3090
+ // willUpdate: () => {
3091
+ // startWork()
3092
+ // },
3093
+ // destroy: () => {
3094
+ // stopWork()
3095
+ // },
3096
+ options: { ...defaultOptions,
3097
+ ...options
3098
+ },
3099
+ initialState,
3100
+ _queue: cb => {
3101
+ queued.push(cb);
3102
+
3103
+ if (!queuedTimeout) {
3104
+ queuedTimeout = true; // Schedule a microtask to run the queued callbacks after
3105
+ // the current call stack (render, etc) has finished.
3106
+
3107
+ Promise.resolve().then(() => {
3108
+ while (queued.length) {
3109
+ queued.shift()();
3110
+ }
3111
+
3112
+ queuedTimeout = false;
3113
+ }).catch(error => setTimeout(() => {
3114
+ throw error;
3115
+ }));
3116
+ }
3117
+ },
3118
+ reset: () => {
3119
+ instance.setState(instance.initialState);
3120
+ },
3121
+ setOptions: updater => {
3122
+ const newOptions = functionalUpdate(updater, instance.options);
3123
+ instance.options = mergeOptions(newOptions);
3124
+ },
3125
+ _render: (template, props) => {
3126
+ if (typeof instance.options.render === 'function') {
3127
+ return instance.options.render(template, props);
3128
+ }
3129
+
3130
+ if (typeof template === 'function') {
3131
+ return template(props);
3132
+ }
3133
+
3134
+ return template;
3135
+ },
3136
+ getState: () => {
3137
+ return instance.options.state;
3138
+ },
3139
+ setState: updater => {
3140
+ instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
3141
+ } // getOverallProgress: () => {
3142
+ // const { coreProgress, filtersProgress, facetProgress } =
3143
+ // instance.getState()
3144
+ // return mean(() =>
3145
+ // [coreProgress, filtersProgress].filter(d => d < 1)
3146
+ // ) as number
3147
+ // },
3148
+ // getProgressStage: () => {
3149
+ // const { coreProgress, filtersProgress, facetProgress } =
3150
+ // instance.getState()
3151
+ // if (coreProgress < 1) {
3152
+ // return 'coreRowModel'
3153
+ // }
3154
+ // if (filtersProgress < 1) {
3155
+ // return 'filteredRowModel'
3156
+ // }
3157
+ // if (Object.values(facetProgress).some(d => d < 1)) {
3158
+ // return 'facetedRowModel'
3159
+ // }
3160
+ // },
3161
+
3162
+ };
3163
+ instance = Object.assign(instance, midInstance);
3164
+
3165
+ instance._features.forEach(feature => {
3166
+ return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
3167
+ });
3168
+
3169
+ return instance;
3170
+ }
3171
+
3172
+ //
3173
+ function createTableFactory(opts) {
3174
+ return () => createTable(undefined, undefined, opts);
3175
+ } // A lot of returns in here are `as any` for a reason. Unless you
3176
+ // can find a better way to do this, then don't worry about them
3177
+
3178
+ function createTable(_, __, options) {
3179
+ const table = {
3180
+ generics: undefined,
3181
+ options: options != null ? options : {
3182
+ render: (() => {
3183
+ throw new Error('');
3184
+ })()
3185
+ },
3186
+ setGenerics: () => table,
3187
+ setRowType: () => table,
3188
+ setTableMetaType: () => table,
3189
+ setColumnMetaType: () => table,
3190
+ setOptions: newOptions => createTable(_, __, { ...options,
3191
+ ...newOptions
3192
+ }),
3193
+ createDisplayColumn: column => ({ ...column,
3194
+ columnDefType: 'display'
3195
+ }),
3196
+ createGroup: column => ({ ...column,
3197
+ columnDefType: 'group'
3198
+ }),
3199
+ createDataColumn: (accessor, column) => {
3200
+ column = { ...column,
3201
+ columnDefType: 'data',
3202
+ id: column.id
3203
+ };
3204
+
3205
+ if (typeof accessor === 'string') {
3206
+ var _column$id;
3207
+
3208
+ return { ...column,
3209
+ id: (_column$id = column.id) != null ? _column$id : accessor,
3210
+ accessorKey: accessor
3211
+ };
3212
+ }
3213
+
3214
+ if (typeof accessor === 'function') {
3215
+ return { ...column,
3216
+ accessorFn: accessor
3217
+ };
3218
+ }
3219
+
3220
+ throw new Error('Invalid accessor');
3221
+ }
3222
+ };
3223
+ return table;
3224
+ }
3225
+
3226
+ function getCoreRowModel() {
3227
+ return instance => memo(() => [instance.options.data], data => {
3228
+ const rowModel = {
3229
+ rows: [],
3230
+ flatRows: [],
3231
+ rowsById: {}
3232
+ };
3233
+ let rows;
3234
+ let row;
3235
+ let originalRow;
3236
+
3237
+ const accessRows = function (originalRows, depth, parent) {
3238
+ if (depth === void 0) {
3239
+ depth = 0;
3240
+ }
3241
+
3242
+ rows = [];
3243
+
3244
+ for (let i = 0; i < originalRows.length; i++) {
3245
+ originalRow = originalRows[i]; // This could be an expensive check at scale, so we should move it somewhere else, but where?
3246
+ // if (!id) {
3247
+ // if (process.env.NODE_ENV !== 'production') {
3248
+ // throw new Error(`getRowId expected an ID, but got ${id}`)
3249
+ // }
3250
+ // }
3251
+ // Make the row
3252
+
3253
+ row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3254
+
3255
+ rowModel.flatRows.push(row); // Also keep track of every row by its ID
3256
+
3257
+ rowModel.rowsById[row.id] = row; // Push instance row into parent
3258
+
3259
+ rows.push(row); // Get the original subrows
3260
+
3261
+ if (instance.options.getSubRows) {
3262
+ var _row$originalSubRows;
3263
+
3264
+ row.originalSubRows = instance.options.getSubRows(originalRow, i); // Then recursively access them
3265
+
3266
+ if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
3267
+ row.subRows = accessRows(row.originalSubRows, depth + 1, row);
3268
+ }
3269
+ }
3270
+ }
3271
+
3272
+ return rows;
3273
+ };
3274
+
3275
+ rowModel.rows = accessRows(data);
3276
+ return rowModel;
3277
+ }, {
3278
+ key: process.env.NODE_ENV === 'development' && 'getRowModel',
3279
+ debug: () => {
3280
+ var _instance$options$deb;
3281
+
3282
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3283
+ },
3284
+ onChange: () => {
3285
+ instance._autoResetPageIndex();
3286
+ }
3287
+ });
3288
+ }
3289
+
3290
+ function filterRows(rows, filterRowImpl, instance) {
3291
+ if (instance.options.filterFromLeafRows) {
3292
+ return filterRowModelFromLeafs(rows, filterRowImpl, instance);
3293
+ }
3294
+
3295
+ return filterRowModelFromRoot(rows, filterRowImpl, instance);
3296
+ }
3297
+ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3298
+ const newFilteredFlatRows = [];
3299
+ const newFilteredRowsById = {};
3300
+ let row;
3301
+ let newRow;
3302
+
3303
+ const recurseFilterRows = function (rowsToFilter, depth) {
3304
+ if (depth === void 0) {
3305
+ depth = 0;
3306
+ }
3307
+
3308
+ const rows = []; // Filter from children up first
3309
+
3310
+ for (let i = 0; i < rowsToFilter.length; i++) {
3311
+ var _row$subRows;
3312
+
3313
+ row = rowsToFilter[i];
3314
+
3315
+ if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3316
+ newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3317
+ newRow.columnFilterMap = row.columnFilterMap;
3318
+ newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3319
+
3320
+ if (!newRow.subRows.length) {
3321
+ continue;
3322
+ }
3323
+
3324
+ row = newRow;
3325
+ }
3326
+
3327
+ if (filterRow(row)) {
3328
+ rows.push(row);
3329
+ newFilteredRowsById[row.id] = row;
3330
+ newFilteredRowsById[i] = row;
3331
+ }
3332
+ }
3333
+
3334
+ return rows;
3335
+ };
3336
+
3337
+ return {
3338
+ rows: recurseFilterRows(rowsToFilter),
3339
+ flatRows: newFilteredFlatRows,
3340
+ rowsById: newFilteredRowsById
3341
+ };
3342
+ }
3343
+ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
3344
+ const newFilteredFlatRows = [];
3345
+ const newFilteredRowsById = {};
3346
+ let rows;
3347
+ let row;
3348
+ let newRow; // Filters top level and nested rows
3349
+
3350
+ const recurseFilterRows = function (rowsToFilter, depth) {
3351
+ if (depth === void 0) {
3352
+ depth = 0;
3353
+ }
3354
+
3355
+ // Filter from parents downward first
3356
+ rows = []; // Apply the filter to any subRows
3357
+
3358
+ for (let i = 0; i < rowsToFilter.length; i++) {
3359
+ row = rowsToFilter[i];
3360
+ const pass = filterRow(row);
3361
+
3362
+ if (pass) {
3363
+ var _row$subRows2;
3364
+
3365
+ if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3366
+ newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3367
+ newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3368
+ row = newRow;
3369
+ }
3370
+
3371
+ rows.push(row);
3372
+ newFilteredFlatRows.push(row);
3373
+ newFilteredRowsById[row.id] = row;
3374
+ }
3375
+ }
3376
+
3377
+ return rows;
3378
+ };
3379
+
3380
+ return {
3381
+ rows: recurseFilterRows(rowsToFilter),
3382
+ flatRows: newFilteredFlatRows,
3383
+ rowsById: newFilteredRowsById
3384
+ };
3385
+ }
3386
+
3387
+ function getFilteredRowModel() {
3388
+ return instance => memo(() => [instance.getPreFilteredRowModel(), instance.getState().columnFilters, instance.getState().globalFilter], (rowModel, columnFilters, globalFilter) => {
3389
+ if (!rowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
3390
+ return rowModel;
3391
+ }
3392
+
3393
+ const resolvedColumnFilters = [];
3394
+ const resolvedGlobalFilters = [];
3395
+ (columnFilters != null ? columnFilters : []).forEach(d => {
3396
+ var _filterFn$resolveFilt;
3397
+
3398
+ const column = instance.getColumn(d.id);
3399
+
3400
+ if (!column) {
3401
+ if (process.env.NODE_ENV !== 'production') {
3402
+ console.warn("Table: Could not find a column to filter with columnId: " + d.id);
3403
+ }
3404
+ }
3405
+
3406
+ const filterFn = column.getFilterFn();
3407
+
3408
+ if (!filterFn) {
3409
+ if (process.env.NODE_ENV !== 'production') {
3410
+ console.warn("Could not find a valid 'column.filterFn' for column with the ID: " + column.id + ".");
3411
+ }
3412
+
3413
+ return;
3414
+ }
3415
+
3416
+ resolvedColumnFilters.push({
3417
+ id: d.id,
3418
+ filterFn,
3419
+ resolvedValue: (_filterFn$resolveFilt = filterFn.resolveFilterValue == null ? void 0 : filterFn.resolveFilterValue(d.value)) != null ? _filterFn$resolveFilt : d.value
3420
+ });
3421
+ });
3422
+ const filterableIds = columnFilters.map(d => d.id);
3423
+ const globalFilterFn = instance.getGlobalFilterFn();
3424
+ const globallyFilterableColumns = instance.getAllLeafColumns().filter(column => column.getCanGlobalFilter());
3425
+
3426
+ if (globalFilter && globalFilterFn && globallyFilterableColumns.length) {
3427
+ filterableIds.push('__global__');
3428
+ globallyFilterableColumns.forEach(column => {
3429
+ var _globalFilterFn$resol;
3430
+
3431
+ resolvedGlobalFilters.push({
3432
+ id: column.id,
3433
+ filterFn: globalFilterFn,
3434
+ resolvedValue: (_globalFilterFn$resol = globalFilterFn.resolveFilterValue == null ? void 0 : globalFilterFn.resolveFilterValue(globalFilter)) != null ? _globalFilterFn$resol : globalFilter
3435
+ });
3436
+ });
3437
+ }
3438
+
3439
+ let currentColumnFilter;
3440
+ let currentGlobalFilter; // Flag the prefiltered row model with each filter state
3441
+
3442
+ for (let j = 0; j < rowModel.flatRows.length; j++) {
3443
+ const row = rowModel.flatRows[j];
3444
+ row.columnFilterMap = {};
3445
+
3446
+ if (resolvedColumnFilters.length) {
3447
+ for (let i = 0; i < resolvedColumnFilters.length; i++) {
3448
+ currentColumnFilter = resolvedColumnFilters[i]; // Tag the row with the column filter state
3449
+
3450
+ row.columnFilterMap[currentColumnFilter.id] = currentColumnFilter.filterFn(row, currentColumnFilter.id, currentColumnFilter.resolvedValue);
3451
+ }
3452
+ }
3453
+
3454
+ if (resolvedGlobalFilters.length) {
3455
+ for (let i = 0; i < resolvedGlobalFilters.length; i++) {
3456
+ currentGlobalFilter = resolvedGlobalFilters[i]; // Tag the row with the first truthy global filter state
3457
+
3458
+ if (currentGlobalFilter.filterFn(row, currentGlobalFilter.id, currentGlobalFilter.resolvedValue)) {
3459
+ row.columnFilterMap.__global__ = true;
3460
+ break;
3461
+ }
3462
+ }
3463
+
3464
+ if (row.columnFilterMap.__global__ !== true) {
3465
+ row.columnFilterMap.__global__ = false;
3466
+ }
3467
+ }
3468
+ }
3469
+
3470
+ const filterRowsImpl = row => {
3471
+ // Horizontally filter rows through each column
3472
+ for (let i = 0; i < filterableIds.length; i++) {
3473
+ if (row.columnFilterMap[filterableIds[i]] === false) {
3474
+ return false;
3475
+ }
3476
+ }
3477
+
3478
+ return true;
3479
+ }; // Filter final rows using all of the active filters
3480
+
3481
+
3482
+ return filterRows(rowModel.rows, filterRowsImpl, instance);
3483
+ }, {
3484
+ key: process.env.NODE_ENV === 'development' && 'getFilteredRowModel',
3485
+ debug: () => {
3486
+ var _instance$options$deb;
3487
+
3488
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3489
+ },
3490
+ onChange: () => {
3491
+ instance._autoResetPageIndex();
3492
+ }
3493
+ });
3494
+ }
3495
+
3496
+ function getFacetedRowModel() {
3497
+ return (instance, columnId) => memo(() => [instance.getPreFilteredRowModel(), instance.getState().columnFilters, instance.getState().globalFilter, instance.getFilteredRowModel()], (preRowModel, columnFilters, globalFilter) => {
3498
+ if (!preRowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
3499
+ return preRowModel;
3500
+ }
3501
+
3502
+ const filterableIds = [...columnFilters.map(d => d.id).filter(d => d !== columnId), globalFilter ? '__global__' : undefined].filter(Boolean);
3503
+
3504
+ const filterRowsImpl = row => {
3505
+ // Horizontally filter rows through each column
3506
+ for (let i = 0; i < filterableIds.length; i++) {
3507
+ if (row.columnFilterMap[filterableIds[i]] === false) {
3508
+ return false;
3509
+ }
3510
+ }
3511
+
3512
+ return true;
3513
+ };
3514
+
3515
+ return filterRows(preRowModel.rows, filterRowsImpl, instance);
3516
+ }, {
3517
+ key: process.env.NODE_ENV === 'development' && 'getFacetedRowModel_' + columnId,
3518
+ debug: () => {
3519
+ var _instance$options$deb;
3520
+
3521
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3522
+ },
3523
+ onChange: () => {}
3524
+ });
3525
+ }
3526
+
3527
+ function getFacetedUniqueValues() {
3528
+ return (instance, columnId) => memo(() => [instance.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
3529
+ let facetedUniqueValues = new Map();
3530
+
3531
+ for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3532
+ var _facetedRowModel$flat;
3533
+
3534
+ const value = (_facetedRowModel$flat = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat.getValue(columnId);
3535
+
3536
+ if (facetedUniqueValues.has(value)) {
3537
+ var _facetedUniqueValues$;
3538
+
3539
+ facetedUniqueValues.set(value, ((_facetedUniqueValues$ = facetedUniqueValues.get(value)) != null ? _facetedUniqueValues$ : 0) + 1);
3540
+ } else {
3541
+ facetedUniqueValues.set(value, 1);
3542
+ }
3543
+ }
3544
+
3545
+ return facetedUniqueValues;
3546
+ }, {
3547
+ key: process.env.NODE_ENV === 'development' && 'getFacetedUniqueValues_' + columnId,
3548
+ debug: () => {
3549
+ var _instance$options$deb;
3550
+
3551
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3552
+ },
3553
+ onChange: () => {}
3554
+ });
3555
+ }
3556
+
3557
+ function getFacetedMinMaxValues() {
3558
+ return (instance, columnId) => memo(() => [instance.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
3559
+ var _facetedRowModel$flat;
3560
+
3561
+ const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getValue(columnId);
3562
+
3563
+ if (typeof firstValue === 'undefined') {
3564
+ return undefined;
3565
+ }
3566
+
3567
+ let facetedMinMaxValues = [firstValue, firstValue];
3568
+
3569
+ for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3570
+ var _facetedRowModel$flat2;
3571
+
3572
+ const value = (_facetedRowModel$flat2 = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat2.getValue(columnId);
3573
+
3574
+ if (value < facetedMinMaxValues[0]) {
3575
+ facetedMinMaxValues[0] = value;
3576
+ } else if (value > facetedMinMaxValues[1]) {
3577
+ facetedMinMaxValues[1] = value;
3578
+ }
3579
+ }
3580
+
3581
+ return facetedMinMaxValues;
3582
+ }, {
3583
+ key: process.env.NODE_ENV === 'development' && 'getFacetedMinMaxValues_' + columnId,
3584
+ debug: () => {
3585
+ var _instance$options$deb;
3586
+
3587
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3588
+ },
3589
+ onChange: () => {}
3590
+ });
3591
+ }
3592
+
3593
+ function getSortedRowModel() {
3594
+ return instance => memo(() => [instance.getState().sorting, instance.getPreSortedRowModel()], (sorting, rowModel) => {
3595
+ if (!rowModel.rows.length || !(sorting != null && sorting.length)) {
3596
+ return rowModel;
3597
+ }
3598
+
3599
+ const sortingState = instance.getState().sorting;
3600
+ const sortedFlatRows = []; // Filter out sortings that correspond to non existing columns
3601
+
3602
+ const availableSorting = sortingState.filter(sort => instance.getColumn(sort.id).getCanSort());
3603
+ const columnInfoById = {};
3604
+ availableSorting.forEach(sortEntry => {
3605
+ const column = instance.getColumn(sortEntry.id);
3606
+ columnInfoById[sortEntry.id] = {
3607
+ sortUndefined: column.sortUndefined,
3608
+ invertSorting: column.invertSorting,
3609
+ sortingFn: column.getSortingFn()
3610
+ };
3611
+ });
3612
+
3613
+ const sortData = rows => {
3614
+ // This will also perform a stable sorting using the row index
3615
+ // if needed.
3616
+ const sortedData = rows.slice();
3617
+ sortedData.sort((rowA, rowB) => {
3618
+ for (let i = 0; i < availableSorting.length; i += 1) {
3619
+ var _sortEntry$desc;
3620
+
3621
+ const sortEntry = availableSorting[i];
3622
+ const columnInfo = columnInfoById[sortEntry.id];
3623
+ const isDesc = (_sortEntry$desc = sortEntry == null ? void 0 : sortEntry.desc) != null ? _sortEntry$desc : false;
3624
+
3625
+ if (columnInfo.sortUndefined) {
3626
+ const aValue = rowA.getValue(sortEntry.id);
3627
+ const bValue = rowB.getValue(sortEntry.id);
3628
+ const aUndefined = typeof aValue === 'undefined';
3629
+ const bUndefined = typeof bValue === 'undefined';
3630
+
3631
+ if (aUndefined || bUndefined) {
3632
+ return aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
3633
+ }
3634
+ } // This function should always return in ascending order
3635
+
3636
+
3637
+ let sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
3638
+
3639
+ if (sortInt !== 0) {
3640
+ if (isDesc) {
3641
+ sortInt *= -1;
3642
+ }
3643
+
3644
+ if (columnInfo.invertSorting) {
3645
+ sortInt *= -1;
3646
+ }
3647
+
3648
+ return sortInt;
3649
+ }
3650
+ }
3651
+
3652
+ return rowA.index - rowB.index;
3653
+ }); // If there are sub-rows, sort them
3654
+
3655
+ sortedData.forEach(row => {
3656
+ sortedFlatRows.push(row);
3657
+
3658
+ if (!row.subRows || row.subRows.length <= 1) {
3659
+ return;
3660
+ }
3661
+
3662
+ row.subRows = sortData(row.subRows);
3663
+ });
3664
+ return sortedData;
3665
+ };
3666
+
3667
+ return {
3668
+ rows: sortData(rowModel.rows),
3669
+ flatRows: sortedFlatRows,
3670
+ rowsById: rowModel.rowsById
3671
+ };
3672
+ }, {
3673
+ key: process.env.NODE_ENV === 'development' && 'getSortedRowModel',
3674
+ debug: () => {
3675
+ var _instance$options$deb;
3676
+
3677
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3678
+ },
3679
+ onChange: () => {
3680
+ instance._autoResetPageIndex();
3681
+ }
3682
+ });
3683
+ }
3684
+
3685
+ function getGroupedRowModel() {
3686
+ return instance => memo(() => [instance.getState().grouping, instance.getPreGroupedRowModel()], (grouping, rowModel) => {
3687
+ if (!rowModel.rows.length || !grouping.length) {
3688
+ return rowModel;
3689
+ } // Filter the grouping list down to columns that exist
3690
+
3691
+
3692
+ const existingGrouping = grouping.filter(columnId => instance.getColumn(columnId));
3693
+ const groupedFlatRows = [];
3694
+ const groupedRowsById = {}; // const onlyGroupedFlatRows: Row[] = [];
3695
+ // const onlyGroupedRowsById: Record<RowId, Row> = {};
3696
+ // const nonGroupedFlatRows: Row[] = [];
3697
+ // const nonGroupedRowsById: Record<RowId, Row> = {};
3698
+ // Recursively group the data
3699
+
3700
+ const groupUpRecursively = function (rows, depth, parentId) {
3701
+ if (depth === void 0) {
3702
+ depth = 0;
3703
+ }
3704
+
3705
+ // This is the last level, just return the rows
3706
+ if (depth === existingGrouping.length) {
3707
+ return rows;
3708
+ }
3709
+
3710
+ const columnId = existingGrouping[depth]; // Group the rows together for this level
3711
+
3712
+ const rowGroupsMap = groupBy(rows, columnId); // Peform aggregations for each group
3713
+
3714
+ const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map((_ref, index) => {
3715
+ let [groupingValue, groupedRows] = _ref;
3716
+ let id = columnId + ":" + groupingValue;
3717
+ id = parentId ? parentId + ">" + id : id; // First, Recurse to group sub rows before aggregation
3718
+
3719
+ const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3720
+
3721
+ const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3722
+ const row = instance.createRow(id, undefined, index, depth);
3723
+ Object.assign(row, {
3724
+ groupingColumnId: columnId,
3725
+ groupingValue,
3726
+ subRows,
3727
+ leafRows,
3728
+ getValue: columnId => {
3729
+ // Don't aggregate columns that are in the grouping
3730
+ if (existingGrouping.includes(columnId)) {
3731
+ if (row.valuesCache.hasOwnProperty(columnId)) {
3732
+ return row.valuesCache[columnId];
3733
+ }
3734
+
3735
+ if (groupedRows[0]) {
3736
+ var _groupedRows$0$getVal;
3737
+
3738
+ row.valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3739
+ }
3740
+
3741
+ return row.valuesCache[columnId];
3742
+ }
3743
+
3744
+ if (row.groupingValuesCache.hasOwnProperty(columnId)) {
3745
+ return row.groupingValuesCache[columnId];
3746
+ } // Aggregate the values
3747
+
3748
+
3749
+ const column = instance.getColumn(columnId);
3750
+ const aggregateFn = column.getColumnAggregationFn();
3751
+
3752
+ if (aggregateFn) {
3753
+ row.groupingValuesCache[columnId] = aggregateFn(() => leafRows.map(row => {
3754
+ let columnValue = row.getValue(columnId);
3755
+
3756
+ if (!depth && column.aggregateValue) {
3757
+ columnValue = column.aggregateValue(columnValue);
3758
+ }
3759
+
3760
+ return columnValue;
3761
+ }), () => groupedRows.map(row => row.getValue(columnId)));
3762
+ return row.groupingValuesCache[columnId];
3763
+ } else if (column.aggregationFn) {
3764
+ console.info({
3765
+ column
3766
+ });
3767
+ throw new Error(process.env.NODE_ENV !== 'production' ? "Table: Invalid column.aggregateType option for column listed above" : '');
3768
+ }
3769
+ }
3770
+ });
3771
+ subRows.forEach(subRow => {
3772
+ groupedFlatRows.push(subRow);
3773
+ groupedRowsById[subRow.id] = subRow; // if (subRow.getIsGrouped?.()) {
3774
+ // onlyGroupedFlatRows.push(subRow);
3775
+ // onlyGroupedRowsById[subRow.id] = subRow;
3776
+ // } else {
3777
+ // nonGroupedFlatRows.push(subRow);
3778
+ // nonGroupedRowsById[subRow.id] = subRow;
3779
+ // }
3780
+ });
3781
+ return row;
3782
+ });
3783
+ return aggregatedGroupedRows;
3784
+ };
3785
+
3786
+ const groupedRows = groupUpRecursively(rowModel.rows, 0, '');
3787
+ groupedRows.forEach(subRow => {
3788
+ groupedFlatRows.push(subRow);
3789
+ groupedRowsById[subRow.id] = subRow; // if (subRow.getIsGrouped?.()) {
3790
+ // onlyGroupedFlatRows.push(subRow);
3791
+ // onlyGroupedRowsById[subRow.id] = subRow;
3792
+ // } else {
3793
+ // nonGroupedFlatRows.push(subRow);
3794
+ // nonGroupedRowsById[subRow.id] = subRow;
3795
+ // }
3796
+ });
3797
+ return {
3798
+ rows: groupedRows,
3799
+ flatRows: groupedFlatRows,
3800
+ rowsById: groupedRowsById
3801
+ };
3802
+ }, {
3803
+ key: process.env.NODE_ENV === 'development' && 'getGroupedRowModel',
3804
+ debug: () => {
3805
+ var _instance$options$deb;
3806
+
3807
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3808
+ },
3809
+ onChange: () => {
3810
+ instance._queue(() => {
3811
+ instance._autoResetExpanded();
3812
+
3813
+ instance._autoResetPageIndex();
3814
+ });
3815
+ }
3816
+ });
3817
+ }
3818
+
3819
+ function groupBy(rows, columnId) {
3820
+ const groupMap = new Map();
3821
+ return rows.reduce((map, row) => {
3822
+ const resKey = "" + row.getValue(columnId);
3823
+ const previous = map.get(resKey);
3824
+
3825
+ if (!previous) {
3826
+ map.set(resKey, [row]);
3827
+ } else {
3828
+ map.set(resKey, [...previous, row]);
3829
+ }
3830
+
3831
+ return map;
3832
+ }, groupMap);
3833
+ }
3834
+
3835
+ function getExpandedRowModel() {
3836
+ return instance => memo(() => [instance.getState().expanded, instance.getPreExpandedRowModel(), instance.options.paginateExpandedRows], (expanded, rowModel, paginateExpandedRows) => {
3837
+ if (!rowModel.rows.length || // Do not expand if rows are not included in pagination
3838
+ !paginateExpandedRows || expanded !== true && !Object.keys(expanded != null ? expanded : {}).length) {
3839
+ return rowModel;
3840
+ }
3841
+
3842
+ return expandRows(rowModel, instance);
3843
+ }, {
3844
+ key: process.env.NODE_ENV === 'development' && 'getExpandedRowModel',
3845
+ debug: () => {
3846
+ var _instance$options$deb;
3847
+
3848
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3849
+ }
3850
+ });
3851
+ }
3852
+ function expandRows(rowModel, instance) {
3853
+ const expandedRows = [];
3854
+
3855
+ const handleRow = row => {
3856
+ var _row$subRows;
3857
+
3858
+ expandedRows.push(row);
3859
+
3860
+ if (instance.options.expandSubRows && (_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
3861
+ row.subRows.forEach(handleRow);
3862
+ }
3863
+ };
3864
+
3865
+ rowModel.rows.forEach(handleRow);
3866
+ return {
3867
+ rows: expandedRows,
3868
+ flatRows: rowModel.flatRows,
3869
+ rowsById: rowModel.rowsById
3870
+ };
3871
+ }
3872
+
3873
+ function getPaginationRowModel(opts) {
3874
+ return instance => memo(() => [instance.getState().pagination, instance.getPrePaginationRowModel()], (pagination, rowModel) => {
3875
+ if (!rowModel.rows.length) {
3876
+ return rowModel;
3877
+ }
3878
+
3879
+ const {
3880
+ pageSize,
3881
+ pageIndex
3882
+ } = pagination;
3883
+ let {
3884
+ rows,
3885
+ flatRows,
3886
+ rowsById
3887
+ } = rowModel;
3888
+ const pageStart = pageSize * pageIndex;
3889
+ const pageEnd = pageStart + pageSize;
3890
+ rows = rows.slice(pageStart, pageEnd);
3891
+
3892
+ if (!instance.options.paginateExpandedRows) {
3893
+ return expandRows({
3894
+ rows,
3895
+ flatRows,
3896
+ rowsById
3897
+ }, instance);
3898
+ }
3899
+
3900
+ return {
3901
+ rows,
3902
+ flatRows,
3903
+ rowsById
3904
+ };
3905
+ }, {
3906
+ key: process.env.NODE_ENV === 'development' && 'getPaginationRowModel',
3907
+ debug: () => {
3908
+ var _instance$options$deb;
3909
+
3910
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3911
+ }
3912
+ });
3913
+ }
3914
+
3915
+ exports.ColumnSizing = ColumnSizing;
3916
+ exports.Expanding = Expanding;
3917
+ exports.Filters = Filters;
3918
+ exports.Grouping = Grouping;
3919
+ exports.Headers = Headers;
3920
+ exports.Ordering = Ordering;
3921
+ exports.Pagination = Pagination;
3922
+ exports.Pinning = Pinning;
3923
+ exports.RowSelection = RowSelection;
3924
+ exports.Sorting = Sorting;
3925
+ exports.Visibility = Visibility;
3926
+ exports.buildHeaderGroups = buildHeaderGroups;
3927
+ exports.createTableFactory = createTableFactory;
3928
+ exports.createTableInstance = createTableInstance;
3929
+ exports.defaultColumnSizing = defaultColumnSizing;
3930
+ exports.expandRows = expandRows;
3931
+ exports.flattenBy = flattenBy;
3932
+ exports.functionalUpdate = functionalUpdate;
3933
+ exports.getCoreRowModel = getCoreRowModel;
3934
+ exports.getExpandedRowModel = getExpandedRowModel;
3935
+ exports.getFacetedMinMaxValues = getFacetedMinMaxValues;
3936
+ exports.getFacetedRowModel = getFacetedRowModel;
3937
+ exports.getFacetedUniqueValues = getFacetedUniqueValues;
3938
+ exports.getFilteredRowModel = getFilteredRowModel;
3939
+ exports.getGroupedRowModel = getGroupedRowModel;
3940
+ exports.getPaginationRowModel = getPaginationRowModel;
3941
+ exports.getSortedRowModel = getSortedRowModel;
3942
+ exports.isFunction = isFunction;
3943
+ exports.isRowSelected = isRowSelected;
3944
+ exports.makeStateUpdater = makeStateUpdater;
3945
+ exports.memo = memo;
3946
+ exports.noop = noop;
3947
+ exports.orderColumns = orderColumns;
3948
+ exports.passiveEventSupported = passiveEventSupported;
3949
+ exports.selectRowsFn = selectRowsFn;
3950
+ exports.shouldAutoRemoveFilter = shouldAutoRemoveFilter;
3951
+ //# sourceMappingURL=index.js.map