@tanstack/react-table 8.0.0-alpha.6 → 8.0.0-alpha.9

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 (96) hide show
  1. package/build/cjs/core.js +66 -73
  2. package/build/cjs/core.js.map +1 -1
  3. package/build/cjs/createTable.js +47 -33
  4. package/build/cjs/createTable.js.map +1 -1
  5. package/build/cjs/features/ColumnSizing.js +23 -22
  6. package/build/cjs/features/ColumnSizing.js.map +1 -1
  7. package/build/cjs/features/Expanding.js +10 -22
  8. package/build/cjs/features/Expanding.js.map +1 -1
  9. package/build/cjs/features/Filters.js +27 -58
  10. package/build/cjs/features/Filters.js.map +1 -1
  11. package/build/cjs/features/Grouping.js +10 -27
  12. package/build/cjs/features/Grouping.js.map +1 -1
  13. package/build/cjs/features/Headers.js +108 -28
  14. package/build/cjs/features/Headers.js.map +1 -1
  15. package/build/cjs/features/Ordering.js +2 -2
  16. package/build/cjs/features/Ordering.js.map +1 -1
  17. package/build/cjs/features/Pagination.js +24 -29
  18. package/build/cjs/features/Pagination.js.map +1 -1
  19. package/build/cjs/features/Pinning.js.map +1 -1
  20. package/build/cjs/features/RowSelection.js +23 -38
  21. package/build/cjs/features/RowSelection.js.map +1 -1
  22. package/build/cjs/features/Sorting.js +10 -22
  23. package/build/cjs/features/Sorting.js.map +1 -1
  24. package/build/cjs/features/Visibility.js +10 -2
  25. package/build/cjs/features/Visibility.js.map +1 -1
  26. package/build/cjs/filterTypes.js.map +1 -1
  27. package/build/cjs/index.js +12 -0
  28. package/build/cjs/index.js.map +1 -1
  29. package/build/cjs/sortTypes.js.map +1 -1
  30. package/build/cjs/types.js +22 -0
  31. package/build/cjs/types.js.map +1 -0
  32. package/build/cjs/utils/columnFilterRowsFn.js.map +1 -1
  33. package/build/cjs/utils/expandRowsFn.js.map +1 -1
  34. package/build/cjs/utils/globalFilterRowsFn.js.map +1 -1
  35. package/build/cjs/utils/groupRowsFn.js.map +1 -1
  36. package/build/cjs/utils/paginateRowsFn.js.map +1 -1
  37. package/build/cjs/utils/sortRowsFn.js.map +1 -1
  38. package/build/cjs/utils.js +44 -18
  39. package/build/cjs/utils.js.map +1 -1
  40. package/build/esm/index.js +1388 -1355
  41. package/build/esm/index.js.map +1 -1
  42. package/build/stats-html.html +1 -1
  43. package/build/stats-react.json +337 -307
  44. package/build/types/core.d.ts +63 -67
  45. package/build/types/createTable.d.ts +34 -44
  46. package/build/types/features/ColumnSizing.d.ts +13 -7
  47. package/build/types/features/Expanding.d.ts +11 -16
  48. package/build/types/features/Filters.d.ts +39 -47
  49. package/build/types/features/Grouping.d.ts +28 -27
  50. package/build/types/features/Headers.d.ts +30 -30
  51. package/build/types/features/Ordering.d.ts +5 -5
  52. package/build/types/features/Pagination.d.ts +11 -16
  53. package/build/types/features/Pinning.d.ts +5 -5
  54. package/build/types/features/RowSelection.d.ts +15 -23
  55. package/build/types/features/Sorting.d.ts +26 -25
  56. package/build/types/features/Visibility.d.ts +9 -9
  57. package/build/types/filterTypes.d.ts +10 -10
  58. package/build/types/index.d.ts +1 -0
  59. package/build/types/sortTypes.d.ts +7 -7
  60. package/build/types/types.d.ts +34 -23
  61. package/build/types/utils/columnFilterRowsFn.d.ts +2 -2
  62. package/build/types/utils/expandRowsFn.d.ts +2 -2
  63. package/build/types/utils/globalFilterRowsFn.d.ts +2 -2
  64. package/build/types/utils/groupRowsFn.d.ts +2 -2
  65. package/build/types/utils/paginateRowsFn.d.ts +2 -2
  66. package/build/types/utils/sortRowsFn.d.ts +2 -2
  67. package/build/types/utils.d.ts +5 -6
  68. package/build/umd/index.development.js +1397 -1354
  69. package/build/umd/index.development.js.map +1 -1
  70. package/build/umd/index.production.js +1 -1
  71. package/build/umd/index.production.js.map +1 -1
  72. package/package.json +1 -1
  73. package/src/core.tsx +192 -520
  74. package/src/createTable.tsx +137 -192
  75. package/src/features/ColumnSizing.ts +48 -77
  76. package/src/features/Expanding.ts +25 -113
  77. package/src/features/Filters.ts +91 -293
  78. package/src/features/Grouping.ts +60 -165
  79. package/src/features/Headers.ts +148 -331
  80. package/src/features/Ordering.ts +19 -42
  81. package/src/features/Pagination.ts +35 -110
  82. package/src/features/Pinning.ts +16 -40
  83. package/src/features/RowSelection.ts +47 -227
  84. package/src/features/Sorting.ts +49 -143
  85. package/src/features/Visibility.ts +23 -64
  86. package/src/filterTypes.ts +19 -82
  87. package/src/index.tsx +1 -0
  88. package/src/sortTypes.ts +19 -31
  89. package/src/types.ts +80 -100
  90. package/src/utils/columnFilterRowsFn.ts +11 -53
  91. package/src/utils/expandRowsFn.ts +7 -27
  92. package/src/utils/globalFilterRowsFn.ts +10 -43
  93. package/src/utils/groupRowsFn.ts +13 -37
  94. package/src/utils/paginateRowsFn.ts +5 -11
  95. package/src/utils/sortRowsFn.ts +8 -28
  96. package/src/utils.tsx +61 -35
@@ -37,6 +37,239 @@
37
37
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
38
38
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
39
39
 
40
+ // declare global {
41
+ // const "development" !== 'production': boolean
42
+ // }
43
+ //
44
+ var Please_use_the_create_table_column_utilities_to_define_columns = Symbol();
45
+
46
+ function _extends() {
47
+ _extends = Object.assign || function (target) {
48
+ for (var i = 1; i < arguments.length; i++) {
49
+ var source = arguments[i];
50
+
51
+ for (var key in source) {
52
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
53
+ target[key] = source[key];
54
+ }
55
+ }
56
+ }
57
+
58
+ return target;
59
+ };
60
+
61
+ return _extends.apply(this, arguments);
62
+ }
63
+
64
+ function _objectWithoutPropertiesLoose(source, excluded) {
65
+ if (source == null) return {};
66
+ var target = {};
67
+ var sourceKeys = Object.keys(source);
68
+ var key, i;
69
+
70
+ for (i = 0; i < sourceKeys.length; i++) {
71
+ key = sourceKeys[i];
72
+ if (excluded.indexOf(key) >= 0) continue;
73
+ target[key] = source[key];
74
+ }
75
+
76
+ return target;
77
+ }
78
+
79
+ function _unsupportedIterableToArray(o, minLen) {
80
+ if (!o) return;
81
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
82
+ var n = Object.prototype.toString.call(o).slice(8, -1);
83
+ if (n === "Object" && o.constructor) n = o.constructor.name;
84
+ if (n === "Map" || n === "Set") return Array.from(o);
85
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
86
+ }
87
+
88
+ function _arrayLikeToArray(arr, len) {
89
+ if (len == null || len > arr.length) len = arr.length;
90
+
91
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
92
+
93
+ return arr2;
94
+ }
95
+
96
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
97
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
98
+ if (it) return (it = it.call(o)).next.bind(it);
99
+
100
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
101
+ if (it) o = it;
102
+ var i = 0;
103
+ return function () {
104
+ if (i >= o.length) return {
105
+ done: true
106
+ };
107
+ return {
108
+ done: false,
109
+ value: o[i++]
110
+ };
111
+ };
112
+ }
113
+
114
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
115
+ }
116
+
117
+ function _toPrimitive(input, hint) {
118
+ if (typeof input !== "object" || input === null) return input;
119
+ var prim = input[Symbol.toPrimitive];
120
+
121
+ if (prim !== undefined) {
122
+ var res = prim.call(input, hint || "default");
123
+ if (typeof res !== "object") return res;
124
+ throw new TypeError("@@toPrimitive must return a primitive value.");
125
+ }
126
+
127
+ return (hint === "string" ? String : Number)(input);
128
+ }
129
+
130
+ function _toPropertyKey(arg) {
131
+ var key = _toPrimitive(arg, "string");
132
+
133
+ return typeof key === "symbol" ? key : String(key);
134
+ }
135
+
136
+ function functionalUpdate(updater, input) {
137
+ return typeof updater === 'function' ? updater(input) : updater;
138
+ }
139
+ function noop() {//
140
+ }
141
+ function makeStateUpdater(key, instance) {
142
+ return function (updater) {
143
+ instance.setState(function (old) {
144
+ var _extends2;
145
+
146
+ return _extends({}, old, (_extends2 = {}, _extends2[key] = functionalUpdate(updater, old[key]), _extends2));
147
+ });
148
+ };
149
+ }
150
+ function isFunction(d) {
151
+ return d instanceof Function;
152
+ }
153
+ function flattenBy(arr, getChildren) {
154
+ var flat = [];
155
+
156
+ var recurse = function recurse(subArr) {
157
+ subArr.forEach(function (item) {
158
+ flat.push(item);
159
+ var children = getChildren(item);
160
+
161
+ if (children != null && children.length) {
162
+ recurse(children);
163
+ }
164
+ });
165
+ };
166
+
167
+ recurse(arr);
168
+ return flat;
169
+ }
170
+ // @ts-ignore // Just rely on the type, not the implementation
171
+ var propGetter = function propGetter(initial, getter) {
172
+ if (isFunction(getter)) {
173
+ return getter(initial);
174
+ }
175
+
176
+ return _extends({}, initial, getter != null ? getter : {});
177
+ };
178
+ function memo(getDeps, fn, opts) {
179
+ var deps = [];
180
+ var result;
181
+ return function () {
182
+ var depTime;
183
+ if (opts.key && opts.debug) depTime = performance.now();
184
+ var newDeps = getDeps();
185
+ var depsChanged = newDeps.length !== deps.length || newDeps.some(function (dep, index) {
186
+ return deps[index] !== dep;
187
+ });
188
+
189
+ if (depsChanged) {
190
+ var oldResult = result;
191
+ var resultTime;
192
+ if (opts.key && opts.debug) resultTime = performance.now();
193
+ result = fn.apply(void 0, newDeps);
194
+ deps = newDeps;
195
+ opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result, oldResult);
196
+
197
+ if (opts.key && opts.debug) {
198
+ if (opts != null && opts.debug()) {
199
+ var depEndTime = Math.round((performance.now() - depTime) * 100) / 100;
200
+ var resultEndTime = Math.round((performance.now() - resultTime) * 100) / 100;
201
+ var resultFpsPercentage = resultEndTime / 16;
202
+
203
+ var pad = function pad(str, num) {
204
+ str = String(str);
205
+
206
+ while (str.length < num) {
207
+ str = ' ' + str;
208
+ }
209
+
210
+ return str;
211
+ };
212
+
213
+ 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, _extends({
214
+ length: deps.length + " -> " + newDeps.length
215
+ }, newDeps.map(function (_, index) {
216
+ if (deps[index] !== newDeps[index]) {
217
+ return [index, deps[index], newDeps[index]];
218
+ }
219
+
220
+ return false;
221
+ }).filter(Boolean).reduce(function (accu, _ref) {
222
+ var _extends3;
223
+
224
+ var a = _ref[0],
225
+ b = _ref[1];
226
+ return _extends({}, accu, (_extends3 = {}, _extends3[a] = b, _extends3));
227
+ }, {}), {
228
+ parent: parent
229
+ }));
230
+ }
231
+ }
232
+
233
+ oldResult = undefined;
234
+ }
235
+
236
+ return result;
237
+ };
238
+ }
239
+ function flexRender(Comp, props) {
240
+ return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__default["default"].createElement(Comp, props) : Comp;
241
+ }
242
+
243
+ function isReactComponent(component) {
244
+ return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
245
+ }
246
+
247
+ function isClassComponent(component) {
248
+ return typeof component === 'function' && function () {
249
+ var proto = Object.getPrototypeOf(component);
250
+ return proto.prototype && proto.prototype.isReactComponent;
251
+ }();
252
+ }
253
+
254
+ function isExoticComponent(component) {
255
+ return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
256
+ } // export function hashString(str: string, seed = 0): string {
257
+ // let h1 = 0xdeadbeef ^ seed,
258
+ // h2 = 0x41c6ce57 ^ seed
259
+ // for (let i = 0, ch; i < str.length; i++) {
260
+ // ch = str.charCodeAt(i)
261
+ // h1 = Math.imul(h1 ^ ch, 2654435761)
262
+ // h2 = Math.imul(h2 ^ ch, 1597334677)
263
+ // }
264
+ // h1 =
265
+ // Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^
266
+ // Math.imul(h2 ^ (h2 >>> 13), 3266489909)
267
+ // h2 =
268
+ // Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^
269
+ // Math.imul(h1 ^ (h1 >>> 13), 3266489909)
270
+ // return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString()
271
+ // }
272
+
40
273
  function columnFilterRowsFn(instance, rowModel) {
41
274
  var columnFilters = instance.getState().columnFilters;
42
275
  var newFilteredFlatRows = [];
@@ -315,236 +548,34 @@
315
548
  };
316
549
  }
317
550
 
318
- function _extends() {
319
- _extends = Object.assign || function (target) {
320
- for (var i = 1; i < arguments.length; i++) {
321
- var source = arguments[i];
551
+ function groupRowsFn(instance, sortedRowModel) {
552
+ var groupingState = instance.getState().grouping; // Filter the grouping list down to columns that exist
322
553
 
323
- for (var key in source) {
324
- if (Object.prototype.hasOwnProperty.call(source, key)) {
325
- target[key] = source[key];
326
- }
327
- }
328
- }
554
+ var existingGrouping = groupingState.filter(function (columnId) {
555
+ return instance.getColumn(columnId);
556
+ }); // Find the columns that can or are aggregating
557
+ // Uses each column to aggregate rows into a single value
329
558
 
330
- return target;
331
- };
559
+ var aggregateRowsToValues = function aggregateRowsToValues(leafRows, groupedRows, depth) {
560
+ var values = {};
561
+ instance.getAllLeafColumns().forEach(function (column) {
562
+ // Don't aggregate columns that are in the grouping
563
+ if (existingGrouping.includes(column.id)) {
564
+ values[column.id] = groupedRows[0] ? groupedRows[0].values[column.id] : null;
565
+ return;
566
+ } // Aggregate the values
332
567
 
333
- return _extends.apply(this, arguments);
334
- }
335
568
 
336
- function _objectWithoutPropertiesLoose(source, excluded) {
337
- if (source == null) return {};
338
- var target = {};
339
- var sourceKeys = Object.keys(source);
340
- var key, i;
569
+ var aggregateFn = instance.getColumnAggregationFn(column.id);
341
570
 
342
- for (i = 0; i < sourceKeys.length; i++) {
343
- key = sourceKeys[i];
344
- if (excluded.indexOf(key) >= 0) continue;
345
- target[key] = source[key];
346
- }
571
+ if (aggregateFn) {
572
+ // Get the columnValues to aggregate
573
+ var groupedValues = groupedRows.map(function (row) {
574
+ return row.values[column.id];
575
+ }); // Get the columnValues to aggregate
347
576
 
348
- return target;
349
- }
350
-
351
- function _unsupportedIterableToArray(o, minLen) {
352
- if (!o) return;
353
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
354
- var n = Object.prototype.toString.call(o).slice(8, -1);
355
- if (n === "Object" && o.constructor) n = o.constructor.name;
356
- if (n === "Map" || n === "Set") return Array.from(o);
357
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
358
- }
359
-
360
- function _arrayLikeToArray(arr, len) {
361
- if (len == null || len > arr.length) len = arr.length;
362
-
363
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
364
-
365
- return arr2;
366
- }
367
-
368
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
369
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
370
- if (it) return (it = it.call(o)).next.bind(it);
371
-
372
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
373
- if (it) o = it;
374
- var i = 0;
375
- return function () {
376
- if (i >= o.length) return {
377
- done: true
378
- };
379
- return {
380
- done: false,
381
- value: o[i++]
382
- };
383
- };
384
- }
385
-
386
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
387
- }
388
-
389
- function _toPrimitive(input, hint) {
390
- if (typeof input !== "object" || input === null) return input;
391
- var prim = input[Symbol.toPrimitive];
392
-
393
- if (prim !== undefined) {
394
- var res = prim.call(input, hint || "default");
395
- if (typeof res !== "object") return res;
396
- throw new TypeError("@@toPrimitive must return a primitive value.");
397
- }
398
-
399
- return (hint === "string" ? String : Number)(input);
400
- }
401
-
402
- function _toPropertyKey(arg) {
403
- var key = _toPrimitive(arg, "string");
404
-
405
- return typeof key === "symbol" ? key : String(key);
406
- }
407
-
408
- function functionalUpdate(updater, input) {
409
- return typeof updater === 'function' ? updater(input) : updater;
410
- }
411
- function makeStateUpdater(key, instance) {
412
- return function (updater) {
413
- instance.setState(function (old) {
414
- var _extends2;
415
-
416
- return _extends({}, old, (_extends2 = {}, _extends2[key] = functionalUpdate(updater, old[key]), _extends2));
417
- });
418
- };
419
- }
420
- function isFunction(d) {
421
- return d instanceof Function;
422
- }
423
- function flattenBy(arr, getChildren) {
424
- var flat = [];
425
-
426
- var recurse = function recurse(subArr) {
427
- subArr.forEach(function (item) {
428
- flat.push(item);
429
- var children = getChildren(item);
430
-
431
- if (children != null && children.length) {
432
- recurse(children);
433
- }
434
- });
435
- };
436
-
437
- recurse(arr);
438
- return flat;
439
- }
440
- // @ts-ignore // Just rely on the type, not the implementation
441
- var propGetter = function propGetter(initial, getter) {
442
- if (isFunction(getter)) {
443
- return getter(initial);
444
- }
445
-
446
- return _extends({}, initial, getter != null ? getter : {});
447
- };
448
- function memo(getDeps, fn, opts) {
449
- var deps = [];
450
- var result;
451
- return function () {
452
- var newDeps = getDeps();
453
- var depsChanged = newDeps.length !== deps.length || newDeps.some(function (dep, index) {
454
- return deps[index] !== dep;
455
- });
456
-
457
- if (depsChanged) {
458
- if (opts != null && opts.debug) {
459
- console.info(opts == null ? void 0 : opts.key, _extends({
460
- length: deps.length + " -> " + newDeps.length
461
- }, newDeps.map(function (_, index) {
462
- if (deps[index] !== newDeps[index]) {
463
- return [index, deps[index], newDeps[index]];
464
- }
465
-
466
- return false;
467
- }).filter(Boolean).reduce(function (accu, curr) {
468
- var _extends3;
469
-
470
- return _extends({}, accu, (_extends3 = {}, _extends3[curr[0]] = curr.slice(1), _extends3));
471
- }, {}), {
472
- parent: parent
473
- }));
474
- }
475
-
476
- var oldResult = result;
477
- result = fn.apply(void 0, newDeps);
478
- deps = newDeps;
479
- opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result, oldResult);
480
- oldResult = undefined;
481
- }
482
-
483
- return result;
484
- };
485
- }
486
- function flexRender(Comp, props) {
487
- return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__default["default"].createElement(Comp, props) : Comp;
488
- }
489
-
490
- function isReactComponent(component) {
491
- return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
492
- }
493
-
494
- function isClassComponent(component) {
495
- return typeof component === 'function' && function () {
496
- var proto = Object.getPrototypeOf(component);
497
- return proto.prototype && proto.prototype.isReactComponent;
498
- }();
499
- }
500
-
501
- function isExoticComponent(component) {
502
- return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
503
- } // export function hashString(str: string, seed = 0): string {
504
- // let h1 = 0xdeadbeef ^ seed,
505
- // h2 = 0x41c6ce57 ^ seed
506
- // for (let i = 0, ch; i < str.length; i++) {
507
- // ch = str.charCodeAt(i)
508
- // h1 = Math.imul(h1 ^ ch, 2654435761)
509
- // h2 = Math.imul(h2 ^ ch, 1597334677)
510
- // }
511
- // h1 =
512
- // Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^
513
- // Math.imul(h2 ^ (h2 >>> 13), 3266489909)
514
- // h2 =
515
- // Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^
516
- // Math.imul(h1 ^ (h1 >>> 13), 3266489909)
517
- // return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString()
518
- // }
519
-
520
- function groupRowsFn(instance, sortedRowModel) {
521
- var groupingState = instance.getState().grouping; // Filter the grouping list down to columns that exist
522
-
523
- var existingGrouping = groupingState.filter(function (columnId) {
524
- return instance.getColumn(columnId);
525
- }); // Find the columns that can or are aggregating
526
- // Uses each column to aggregate rows into a single value
527
-
528
- var aggregateRowsToValues = function aggregateRowsToValues(leafRows, groupedRows, depth) {
529
- var values = {};
530
- instance.getAllLeafColumns().forEach(function (column) {
531
- // Don't aggregate columns that are in the grouping
532
- if (existingGrouping.includes(column.id)) {
533
- values[column.id] = groupedRows[0] ? groupedRows[0].values[column.id] : null;
534
- return;
535
- } // Aggregate the values
536
-
537
-
538
- var aggregateFn = instance.getColumnAggregationFn(column.id);
539
-
540
- if (aggregateFn) {
541
- // Get the columnValues to aggregate
542
- var groupedValues = groupedRows.map(function (row) {
543
- return row.values[column.id];
544
- }); // Get the columnValues to aggregate
545
-
546
- var leafValues = leafRows.map(function (row) {
547
- var columnValue = row.values[column.id];
577
+ var leafValues = leafRows.map(function (row) {
578
+ var columnValue = row.values[column.id];
548
579
 
549
580
  if (!depth && column.aggregateValue) {
550
581
  columnValue = column.aggregateValue(columnValue);
@@ -756,7 +787,11 @@
756
787
  });
757
788
  }, {
758
789
  key: 'getVisibleFlatColumns',
759
- debug: instance.options.debug
790
+ debug: function debug() {
791
+ var _instance$options$deb;
792
+
793
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
794
+ }
760
795
  }),
761
796
  getVisibleLeafColumns: memo(function () {
762
797
  return [instance.getAllLeafColumns(), instance.getAllLeafColumns().filter(function (d) {
@@ -770,7 +805,11 @@
770
805
  });
771
806
  }, {
772
807
  key: 'getVisibleLeafColumns',
773
- debug: instance.options.debug
808
+ debug: function debug() {
809
+ var _instance$options$deb2;
810
+
811
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
812
+ }
774
813
  }),
775
814
  setColumnVisibility: function setColumnVisibility(updater) {
776
815
  return instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater, functionalUpdate(updater, instance.getState().columnVisibility));
@@ -1022,7 +1061,7 @@
1022
1061
  }
1023
1062
  },
1024
1063
  getColumnAutoAggregationFn: function getColumnAutoAggregationFn(columnId) {
1025
- var firstRow = instance.getCoreFlatRows()[0];
1064
+ var firstRow = instance.getCoreRowModel().flatRows[0];
1026
1065
  var value = firstRow == null ? void 0 : firstRow.values[columnId];
1027
1066
 
1028
1067
  if (typeof value === 'number') {
@@ -1090,11 +1129,6 @@
1090
1129
  },
1091
1130
  getToggleGroupingProps: function getToggleGroupingProps(columnId, userProps) {
1092
1131
  var column = instance.getColumn(columnId);
1093
-
1094
- if (!column) {
1095
- return;
1096
- }
1097
-
1098
1132
  var canGroup = column.getCanGroup();
1099
1133
  var initialProps = {
1100
1134
  title: canGroup ? 'Toggle Grouping' : undefined,
@@ -1110,6 +1144,9 @@
1110
1144
 
1111
1145
  return !!((_instance$getRow = instance.getRow(rowId)) != null && _instance$getRow.groupingColumnId);
1112
1146
  },
1147
+ getPreGroupedRowModel: function getPreGroupedRowModel() {
1148
+ return instance.getSortedRowModel();
1149
+ },
1113
1150
  getGroupedRowModel: memo(function () {
1114
1151
  return [instance.getState().grouping, instance.getSortedRowModel(), instance.options.groupRowsFn];
1115
1152
  }, function (grouping, rowModel, groupRowsFn) {
@@ -1117,33 +1154,18 @@
1117
1154
  return rowModel;
1118
1155
  }
1119
1156
 
1120
- if (instance.options.debug) console.info('Grouping...');
1121
1157
  return groupRowsFn(instance, rowModel);
1122
1158
  }, {
1123
1159
  key: 'getGroupedRowModel',
1124
- debug: instance.options.debug,
1160
+ debug: function debug() {
1161
+ var _instance$options$deb;
1162
+
1163
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
1164
+ },
1125
1165
  onChange: function onChange() {
1126
1166
  return instance._notifyExpandedReset();
1127
1167
  }
1128
- }),
1129
- getPreGroupedRows: function getPreGroupedRows() {
1130
- return instance.getSortedRowModel().rows;
1131
- },
1132
- getPreGroupedFlatRows: function getPreGroupedFlatRows() {
1133
- return instance.getSortedRowModel().flatRows;
1134
- },
1135
- getPreGroupedRowsById: function getPreGroupedRowsById() {
1136
- return instance.getSortedRowModel().rowsById;
1137
- },
1138
- getGroupedRows: function getGroupedRows() {
1139
- return instance.getGroupedRowModel().rows;
1140
- },
1141
- getGroupedFlatRows: function getGroupedFlatRows() {
1142
- return instance.getGroupedRowModel().flatRows;
1143
- },
1144
- getGroupedRowsById: function getGroupedRowsById() {
1145
- return instance.getGroupedRowModel().rowsById;
1146
- }
1168
+ })
1147
1169
  };
1148
1170
  }
1149
1171
  function createRow$3(row, instance) {
@@ -1260,8 +1282,8 @@
1260
1282
  return orderColumns(orderedColumns, grouping, groupedColumnMode);
1261
1283
  };
1262
1284
  }, {
1263
- key: 'getOrderColumnsFn',
1264
- debug: instance.options.debug
1285
+ key: 'getOrderColumnsFn' // debug: () => instance.options.debugAll ?? instance.options.debugTable,
1286
+
1265
1287
  })
1266
1288
  };
1267
1289
  }
@@ -1410,72 +1432,396 @@
1410
1432
  });
1411
1433
 
1412
1434
  //
1413
- function createRow$2(row, instance) {
1435
+ var defaultColumnSizing = {
1436
+ width: 150,
1437
+ minWidth: 20,
1438
+ maxWidth: Number.MAX_SAFE_INTEGER
1439
+ };
1440
+ function getInitialState$5() {
1414
1441
  return {
1415
- _getAllVisibleCells: memo(function () {
1416
- return [row.getAllCells().filter(function (cell) {
1417
- return cell.column.getIsVisible();
1418
- }).map(function (d) {
1419
- return d.id;
1420
- }).join('_')];
1421
- }, function (_) {
1422
- return row.getAllCells().filter(function (cell) {
1423
- return cell.column.getIsVisible();
1424
- });
1425
- }, {
1426
- key: 'row._getAllVisibleCells',
1427
- debug: instance.options.debug
1428
- }),
1429
- getVisibleCells: memo(function () {
1430
- return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()];
1431
- }, function (left, center, right) {
1432
- return [].concat(left, center, right);
1433
- }, {
1434
- key: 'row.getVisibleCells',
1435
- debug: instance.options.debug
1436
- }),
1437
- getCenterVisibleCells: memo(function () {
1438
- return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
1439
- }, function (allCells, left, right) {
1440
- var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []);
1441
- return allCells.filter(function (d) {
1442
- return !leftAndRight.includes(d.columnId);
1443
- });
1444
- }, {
1445
- key: 'row.getCenterVisibleCells',
1446
- debug: instance.options.debug
1447
- }),
1448
- getLeftVisibleCells: memo(function () {
1449
- return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,];
1450
- }, function (allCells, left) {
1451
- var cells = (left != null ? left : []).map(function (columnId) {
1452
- return allCells.find(function (cell) {
1453
- return cell.columnId === columnId;
1454
- });
1455
- }).filter(Boolean);
1456
- return cells;
1457
- }, {
1458
- key: 'row.getLeftVisibleCells',
1459
- debug: instance.options.debug
1460
- }),
1461
- getRightVisibleCells: memo(function () {
1462
- return [row._getAllVisibleCells(), instance.getState().columnPinning.right];
1463
- }, function (allCells, right) {
1464
- var cells = (right != null ? right : []).map(function (columnId) {
1465
- return allCells.find(function (cell) {
1466
- return cell.columnId === columnId;
1442
+ columnSizing: {},
1443
+ columnSizingInfo: {
1444
+ startOffset: null,
1445
+ startSize: null,
1446
+ deltaOffset: null,
1447
+ deltaPercentage: null,
1448
+ isResizingColumn: false,
1449
+ columnSizingStart: []
1450
+ }
1451
+ };
1452
+ }
1453
+ function getDefaultOptions$5(instance) {
1454
+ return {
1455
+ columnResizeMode: 'onEnd',
1456
+ onColumnSizingChange: makeStateUpdater('columnSizing', instance),
1457
+ onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', instance)
1458
+ };
1459
+ }
1460
+ function getInstance$6(instance) {
1461
+ return {
1462
+ setColumnSizing: function setColumnSizing(updater) {
1463
+ return instance.options.onColumnSizingChange == null ? void 0 : instance.options.onColumnSizingChange(updater, functionalUpdate(updater, instance.getState().columnSizing));
1464
+ },
1465
+ setColumnSizingInfo: function setColumnSizingInfo(updater) {
1466
+ return instance.options.onColumnSizingInfoChange == null ? void 0 : instance.options.onColumnSizingInfoChange(updater, functionalUpdate(updater, instance.getState().columnSizingInfo));
1467
+ },
1468
+ resetColumnSizing: function resetColumnSizing() {
1469
+ var _instance$initialStat;
1470
+
1471
+ instance.setColumnSizing((_instance$initialStat = instance.initialState.columnSizing) != null ? _instance$initialStat : {});
1472
+ },
1473
+ resetHeaderSizeInfo: function resetHeaderSizeInfo() {
1474
+ var _instance$initialStat2;
1475
+
1476
+ instance.setColumnSizingInfo((_instance$initialStat2 = instance.initialState.columnSizingInfo) != null ? _instance$initialStat2 : {});
1477
+ },
1478
+ resetColumnSize: function resetColumnSize(columnId) {
1479
+ instance.setColumnSizing(function (_ref) {
1480
+ _ref[columnId];
1481
+ var rest = _objectWithoutPropertiesLoose(_ref, [columnId].map(_toPropertyKey));
1482
+
1483
+ return rest;
1484
+ });
1485
+ },
1486
+ resetHeaderSize: function resetHeaderSize(headerId) {
1487
+ var header = instance.getHeader(headerId);
1488
+ return instance.resetColumnSize(header.column.id);
1489
+ },
1490
+ getHeaderCanResize: function getHeaderCanResize(headerId) {
1491
+ var header = instance.getHeader(headerId);
1492
+
1493
+ if (!header) {
1494
+ throw new Error();
1495
+ }
1496
+
1497
+ return instance.getColumnCanResize(header.column.id);
1498
+ },
1499
+ getColumnCanResize: function getColumnCanResize(columnId) {
1500
+ var _ref2, _ref3, _column$enableResizin;
1501
+
1502
+ var column = instance.getColumn(columnId);
1503
+
1504
+ if (!column) {
1505
+ throw new Error();
1506
+ }
1507
+
1508
+ return (_ref2 = (_ref3 = (_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : instance.options.enableColumnResizing) != null ? _ref3 : column.defaultCanResize) != null ? _ref2 : true;
1509
+ },
1510
+ getColumnIsResizing: function getColumnIsResizing(columnId) {
1511
+ var column = instance.getColumn(columnId);
1512
+
1513
+ if (!column) {
1514
+ throw new Error();
1515
+ }
1516
+
1517
+ return instance.getState().columnSizingInfo.isResizingColumn === columnId;
1518
+ },
1519
+ getHeaderIsResizing: function getHeaderIsResizing(headerId) {
1520
+ var header = instance.getHeader(headerId);
1521
+
1522
+ if (!header) {
1523
+ throw new Error();
1524
+ }
1525
+
1526
+ return instance.getColumnIsResizing(header.column.id);
1527
+ },
1528
+ getHeaderResizerProps: function getHeaderResizerProps(headerId, userProps) {
1529
+ var header = instance.getHeader(headerId);
1530
+ var column = instance.getColumn(header.column.id);
1531
+ var canResize = column.getCanResize();
1532
+
1533
+ var onResizeStart = function onResizeStart(e) {
1534
+ if (isTouchStartEvent(e)) {
1535
+ // lets not respond to multiple touches (e.g. 2 or 3 fingers)
1536
+ if (e.touches && e.touches.length > 1) {
1537
+ return;
1538
+ }
1539
+ }
1540
+
1541
+ var header = headerId ? instance.getHeader(headerId) : undefined;
1542
+ var startSize = header ? header.getWidth() : column.getWidth();
1543
+ var columnSizingStart = header ? header.getLeafHeaders().map(function (d) {
1544
+ return [d.column.id, d.getWidth()];
1545
+ }) : [[column.id, column.getWidth()]];
1546
+ var clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
1547
+
1548
+ var updateOffset = function updateOffset(eventType, clientXPos) {
1549
+ if (typeof clientXPos !== 'number') {
1550
+ return;
1551
+ }
1552
+
1553
+ var newColumnSizing = {};
1554
+ instance.setColumnSizingInfo(function (old) {
1555
+ var _old$startOffset, _old$startSize;
1556
+
1557
+ var deltaOffset = clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0);
1558
+ var deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
1559
+ old.columnSizingStart.forEach(function (_ref4) {
1560
+ var columnId = _ref4[0],
1561
+ headerWidth = _ref4[1];
1562
+ newColumnSizing[columnId] = Math.round(Math.max(headerWidth + headerWidth * deltaPercentage, 0) * 100) / 100;
1563
+ });
1564
+ return _extends({}, old, {
1565
+ deltaOffset: deltaOffset,
1566
+ deltaPercentage: deltaPercentage
1567
+ });
1568
+ });
1569
+
1570
+ if (instance.options.columnResizeMode === 'onChange' || eventType === 'end') {
1571
+ instance.setColumnSizing(function (old) {
1572
+ return _extends({}, old, newColumnSizing);
1573
+ });
1574
+ }
1575
+ };
1576
+
1577
+ var onMove = function onMove(clientXPos) {
1578
+ return updateOffset('move', clientXPos);
1579
+ };
1580
+
1581
+ var onEnd = function onEnd(clientXPos) {
1582
+ updateOffset('end', clientXPos);
1583
+ instance.setColumnSizingInfo(function (old) {
1584
+ return _extends({}, old, {
1585
+ isResizingColumn: false,
1586
+ startOffset: null,
1587
+ startSize: null,
1588
+ deltaOffset: null,
1589
+ deltaPercentage: null,
1590
+ columnSizingStart: []
1591
+ });
1592
+ });
1593
+ };
1594
+
1595
+ var mouseEvents = {
1596
+ moveHandler: function moveHandler(e) {
1597
+ return onMove(e.clientX);
1598
+ },
1599
+ upHandler: function upHandler(e) {
1600
+ document.removeEventListener('mousemove', mouseEvents.moveHandler);
1601
+ document.removeEventListener('mouseup', mouseEvents.upHandler);
1602
+ onEnd(e.clientX);
1603
+ }
1604
+ };
1605
+ var touchEvents = {
1606
+ moveHandler: function moveHandler(e) {
1607
+ if (e.cancelable) {
1608
+ e.preventDefault();
1609
+ e.stopPropagation();
1610
+ }
1611
+
1612
+ onMove(e.touches[0].clientX);
1613
+ return false;
1614
+ },
1615
+ upHandler: function upHandler(e) {
1616
+ document.removeEventListener('touchmove', touchEvents.moveHandler);
1617
+ document.removeEventListener('touchend', touchEvents.upHandler);
1618
+
1619
+ if (e.cancelable) {
1620
+ e.preventDefault();
1621
+ e.stopPropagation();
1622
+ }
1623
+
1624
+ onEnd(e.touches[0].clientX);
1625
+ }
1626
+ };
1627
+ var passiveIfSupported = passiveEventSupported() ? {
1628
+ passive: false
1629
+ } : false;
1630
+
1631
+ if (isTouchStartEvent(e)) {
1632
+ document.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
1633
+ document.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
1634
+ } else {
1635
+ document.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
1636
+ document.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
1637
+ }
1638
+
1639
+ instance.setColumnSizingInfo(function (old) {
1640
+ return _extends({}, old, {
1641
+ startOffset: clientX,
1642
+ startSize: startSize,
1643
+ deltaOffset: 0,
1644
+ deltaPercentage: 0,
1645
+ columnSizingStart: columnSizingStart,
1646
+ isResizingColumn: column.id
1647
+ });
1648
+ });
1649
+ };
1650
+
1651
+ var initialProps = canResize ? {
1652
+ title: 'Toggle Grouping',
1653
+ draggable: false,
1654
+ role: 'separator',
1655
+ onMouseDown: function onMouseDown(e) {
1656
+ e.persist();
1657
+ onResizeStart(e);
1658
+ },
1659
+ onTouchStart: function onTouchStart(e) {
1660
+ e.persist();
1661
+ onResizeStart(e);
1662
+ }
1663
+ } : {};
1664
+ return propGetter(initialProps, userProps);
1665
+ }
1666
+ };
1667
+ }
1668
+ function createColumn$2(column, instance) {
1669
+ return {
1670
+ getIsResizing: function getIsResizing() {
1671
+ return instance.getColumnIsResizing(column.id);
1672
+ },
1673
+ getCanResize: function getCanResize() {
1674
+ return instance.getColumnCanResize(column.id);
1675
+ },
1676
+ resetSize: function resetSize() {
1677
+ return instance.resetColumnSize(column.id);
1678
+ }
1679
+ };
1680
+ }
1681
+ function createHeader(header, instance) {
1682
+ return {
1683
+ getIsResizing: function getIsResizing() {
1684
+ return instance.getColumnIsResizing(header.column.id);
1685
+ },
1686
+ getCanResize: function getCanResize() {
1687
+ return instance.getColumnCanResize(header.column.id);
1688
+ },
1689
+ resetSize: function resetSize() {
1690
+ return instance.resetColumnSize(header.column.id);
1691
+ },
1692
+ getResizerProps: function getResizerProps(userProps) {
1693
+ return instance.getHeaderResizerProps(header.id, userProps);
1694
+ }
1695
+ };
1696
+ }
1697
+ var passiveSupported = null;
1698
+ function passiveEventSupported() {
1699
+ if (typeof passiveSupported === 'boolean') return passiveSupported;
1700
+ var supported = false;
1701
+
1702
+ try {
1703
+ var options = {
1704
+ get passive() {
1705
+ supported = true;
1706
+ return false;
1707
+ }
1708
+
1709
+ };
1710
+
1711
+ var noop = function noop() {};
1712
+
1713
+ window.addEventListener('test', noop, options);
1714
+ window.removeEventListener('test', noop);
1715
+ } catch (err) {
1716
+ supported = false;
1717
+ }
1718
+
1719
+ passiveSupported = supported;
1720
+ return passiveSupported;
1721
+ }
1722
+
1723
+ function isTouchStartEvent(e) {
1724
+ return e.type === 'touchstart';
1725
+ }
1726
+
1727
+ var ColumnSizing = /*#__PURE__*/Object.freeze({
1728
+ __proto__: null,
1729
+ defaultColumnSizing: defaultColumnSizing,
1730
+ getInitialState: getInitialState$5,
1731
+ getDefaultOptions: getDefaultOptions$5,
1732
+ getInstance: getInstance$6,
1733
+ createColumn: createColumn$2,
1734
+ createHeader: createHeader,
1735
+ passiveEventSupported: passiveEventSupported
1736
+ });
1737
+
1738
+ //
1739
+ function createRow$2(row, instance) {
1740
+ return {
1741
+ _getAllVisibleCells: memo(function () {
1742
+ return [row.getAllCells().filter(function (cell) {
1743
+ return cell.column.getIsVisible();
1744
+ }).map(function (d) {
1745
+ return d.id;
1746
+ }).join('_')];
1747
+ }, function (_) {
1748
+ return row.getAllCells().filter(function (cell) {
1749
+ return cell.column.getIsVisible();
1750
+ });
1751
+ }, {
1752
+ key: 'row._getAllVisibleCells',
1753
+ debug: function 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
+ getVisibleCells: memo(function () {
1760
+ return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()];
1761
+ }, function (left, center, right) {
1762
+ return [].concat(left, center, right);
1763
+ }, {
1764
+ key: 'row.getVisibleCells',
1765
+ debug: function debug() {
1766
+ var _instance$options$deb2;
1767
+
1768
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
1769
+ }
1770
+ }),
1771
+ getCenterVisibleCells: memo(function () {
1772
+ return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
1773
+ }, function (allCells, left, right) {
1774
+ var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []);
1775
+ return allCells.filter(function (d) {
1776
+ return !leftAndRight.includes(d.columnId);
1777
+ });
1778
+ }, {
1779
+ key: 'row.getCenterVisibleCells',
1780
+ debug: function debug() {
1781
+ var _instance$options$deb3;
1782
+
1783
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugRows;
1784
+ }
1785
+ }),
1786
+ getLeftVisibleCells: memo(function () {
1787
+ return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,];
1788
+ }, function (allCells, left) {
1789
+ var cells = (left != null ? left : []).map(function (columnId) {
1790
+ return allCells.find(function (cell) {
1791
+ return cell.columnId === columnId;
1792
+ });
1793
+ }).filter(Boolean);
1794
+ return cells;
1795
+ }, {
1796
+ key: 'row.getLeftVisibleCells',
1797
+ debug: function debug() {
1798
+ var _instance$options$deb4;
1799
+
1800
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugRows;
1801
+ }
1802
+ }),
1803
+ getRightVisibleCells: memo(function () {
1804
+ return [row._getAllVisibleCells(), instance.getState().columnPinning.right];
1805
+ }, function (allCells, right) {
1806
+ var cells = (right != null ? right : []).map(function (columnId) {
1807
+ return allCells.find(function (cell) {
1808
+ return cell.columnId === columnId;
1467
1809
  });
1468
1810
  }).filter(Boolean);
1469
1811
  return cells;
1470
1812
  }, {
1471
1813
  key: 'row.getRightVisibleCells',
1472
- debug: instance.options.debug
1814
+ debug: function debug() {
1815
+ var _instance$options$deb5;
1816
+
1817
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugRows;
1818
+ }
1473
1819
  })
1474
1820
  };
1475
1821
  }
1476
- function getInstance$6(instance) {
1822
+ function getInstance$5(instance) {
1477
1823
  return {
1478
- createHeader: function createHeader(column, options) {
1824
+ createHeader: function createHeader$1(column, options) {
1479
1825
  var _options$id;
1480
1826
 
1481
1827
  var id = (_options$id = options.id) != null ? _options$id : column.id;
@@ -1538,9 +1884,9 @@
1538
1884
  column: column
1539
1885
  });
1540
1886
  }
1541
- }; // Yes, we have to convert instance to uknown, because we know more than the compiler here.
1887
+ }; // Yes, we have to convert instance to unknown, because we know more than the compiler here.
1542
1888
 
1543
- return header;
1889
+ return Object.assign(header, createHeader(header, instance));
1544
1890
  },
1545
1891
  // Header Groups
1546
1892
  getHeaderGroups: memo(function () {
@@ -1559,7 +1905,11 @@
1559
1905
  return headerGroups;
1560
1906
  }, {
1561
1907
  key: 'getHeaderGroups',
1562
- debug: instance.options.debug
1908
+ debug: function debug() {
1909
+ var _instance$options$deb6;
1910
+
1911
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
1912
+ }
1563
1913
  }),
1564
1914
  getCenterHeaderGroups: memo(function () {
1565
1915
  return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
@@ -1570,7 +1920,11 @@
1570
1920
  return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
1571
1921
  }, {
1572
1922
  key: 'getCenterHeaderGroups',
1573
- debug: instance.options.debug
1923
+ debug: function debug() {
1924
+ var _instance$options$deb7;
1925
+
1926
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
1927
+ }
1574
1928
  }),
1575
1929
  getLeftHeaderGroups: memo(function () {
1576
1930
  return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left];
@@ -1581,7 +1935,11 @@
1581
1935
  return buildHeaderGroups(allColumns, leafColumns, instance, 'left');
1582
1936
  }, {
1583
1937
  key: 'getLeftHeaderGroups',
1584
- debug: instance.options.debug
1938
+ debug: function debug() {
1939
+ var _instance$options$deb8;
1940
+
1941
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
1942
+ }
1585
1943
  }),
1586
1944
  getRightHeaderGroups: memo(function () {
1587
1945
  return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right];
@@ -1592,7 +1950,11 @@
1592
1950
  return buildHeaderGroups(allColumns, leafColumns, instance, 'right');
1593
1951
  }, {
1594
1952
  key: 'getRightHeaderGroups',
1595
- debug: instance.options.debug
1953
+ debug: function debug() {
1954
+ var _instance$options$deb9;
1955
+
1956
+ return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
1957
+ }
1596
1958
  }),
1597
1959
  // Footer Groups
1598
1960
  getFooterGroups: memo(function () {
@@ -1601,7 +1963,11 @@
1601
1963
  return [].concat(headerGroups).reverse();
1602
1964
  }, {
1603
1965
  key: 'getFooterGroups',
1604
- debug: instance.options.debug
1966
+ debug: function debug() {
1967
+ var _instance$options$deb10;
1968
+
1969
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
1970
+ }
1605
1971
  }),
1606
1972
  getLeftFooterGroups: memo(function () {
1607
1973
  return [instance.getLeftHeaderGroups()];
@@ -1609,7 +1975,11 @@
1609
1975
  return [].concat(headerGroups).reverse();
1610
1976
  }, {
1611
1977
  key: 'getLeftFooterGroups',
1612
- debug: instance.options.debug
1978
+ debug: function debug() {
1979
+ var _instance$options$deb11;
1980
+
1981
+ return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
1982
+ }
1613
1983
  }),
1614
1984
  getCenterFooterGroups: memo(function () {
1615
1985
  return [instance.getCenterHeaderGroups()];
@@ -1617,7 +1987,11 @@
1617
1987
  return [].concat(headerGroups).reverse();
1618
1988
  }, {
1619
1989
  key: 'getCenterFooterGroups',
1620
- debug: instance.options.debug
1990
+ debug: function debug() {
1991
+ var _instance$options$deb12;
1992
+
1993
+ return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
1994
+ }
1621
1995
  }),
1622
1996
  getRightFooterGroups: memo(function () {
1623
1997
  return [instance.getRightHeaderGroups()];
@@ -1625,7 +1999,11 @@
1625
1999
  return [].concat(headerGroups).reverse();
1626
2000
  }, {
1627
2001
  key: 'getRightFooterGroups',
1628
- debug: instance.options.debug
2002
+ debug: function debug() {
2003
+ var _instance$options$deb13;
2004
+
2005
+ return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
2006
+ }
1629
2007
  }),
1630
2008
  // Flat Headers
1631
2009
  getFlatHeaders: memo(function () {
@@ -1636,7 +2014,11 @@
1636
2014
  }).flat();
1637
2015
  }, {
1638
2016
  key: 'getFlatHeaders',
1639
- debug: instance.options.debug
2017
+ debug: function debug() {
2018
+ var _instance$options$deb14;
2019
+
2020
+ return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
2021
+ }
1640
2022
  }),
1641
2023
  getLeftFlatHeaders: memo(function () {
1642
2024
  return [instance.getLeftHeaderGroups()];
@@ -1646,7 +2028,11 @@
1646
2028
  }).flat();
1647
2029
  }, {
1648
2030
  key: 'getLeftFlatHeaders',
1649
- debug: instance.options.debug
2031
+ debug: function debug() {
2032
+ var _instance$options$deb15;
2033
+
2034
+ return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
2035
+ }
1650
2036
  }),
1651
2037
  getCenterFlatHeaders: memo(function () {
1652
2038
  return [instance.getCenterHeaderGroups()];
@@ -1656,7 +2042,11 @@
1656
2042
  }).flat();
1657
2043
  }, {
1658
2044
  key: 'getCenterFlatHeaders',
1659
- debug: instance.options.debug
2045
+ debug: function debug() {
2046
+ var _instance$options$deb16;
2047
+
2048
+ return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
2049
+ }
1660
2050
  }),
1661
2051
  getRightFlatHeaders: memo(function () {
1662
2052
  return [instance.getRightHeaderGroups()];
@@ -1666,7 +2056,11 @@
1666
2056
  }).flat();
1667
2057
  }, {
1668
2058
  key: 'getRightFlatHeaders',
1669
- debug: instance.options.debug
2059
+ debug: function debug() {
2060
+ var _instance$options$deb17;
2061
+
2062
+ return (_instance$options$deb17 = instance.options.debugAll) != null ? _instance$options$deb17 : instance.options.debugHeaders;
2063
+ }
1670
2064
  }),
1671
2065
  // Leaf Headers
1672
2066
  getCenterLeafHeaders: memo(function () {
@@ -1679,7 +2073,11 @@
1679
2073
  });
1680
2074
  }, {
1681
2075
  key: 'getCenterLeafHeaders',
1682
- debug: instance.options.debug
2076
+ debug: function debug() {
2077
+ var _instance$options$deb18;
2078
+
2079
+ return (_instance$options$deb18 = instance.options.debugAll) != null ? _instance$options$deb18 : instance.options.debugHeaders;
2080
+ }
1683
2081
  }),
1684
2082
  getLeftLeafHeaders: memo(function () {
1685
2083
  return [instance.getLeftFlatHeaders()];
@@ -1691,7 +2089,11 @@
1691
2089
  });
1692
2090
  }, {
1693
2091
  key: 'getLeftLeafHeaders',
1694
- debug: instance.options.debug
2092
+ debug: function debug() {
2093
+ var _instance$options$deb19;
2094
+
2095
+ return (_instance$options$deb19 = instance.options.debugAll) != null ? _instance$options$deb19 : instance.options.debugHeaders;
2096
+ }
1695
2097
  }),
1696
2098
  getRightLeafHeaders: memo(function () {
1697
2099
  return [instance.getRightFlatHeaders()];
@@ -1703,7 +2105,11 @@
1703
2105
  });
1704
2106
  }, {
1705
2107
  key: 'getRightLeafHeaders',
1706
- debug: instance.options.debug
2108
+ debug: function debug() {
2109
+ var _instance$options$deb20;
2110
+
2111
+ return (_instance$options$deb20 = instance.options.debugAll) != null ? _instance$options$deb20 : instance.options.debugHeaders;
2112
+ }
1707
2113
  }),
1708
2114
  getLeafHeaders: memo(function () {
1709
2115
  return [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()];
@@ -1715,7 +2121,11 @@
1715
2121
  }).flat();
1716
2122
  }, {
1717
2123
  key: 'getLeafHeaders',
1718
- debug: instance.options.debug
2124
+ debug: function debug() {
2125
+ var _instance$options$deb21;
2126
+
2127
+ return (_instance$options$deb21 = instance.options.debugAll) != null ? _instance$options$deb21 : instance.options.debugHeaders;
2128
+ }
1719
2129
  }),
1720
2130
  getHeader: function getHeader(id) {
1721
2131
  var header = [].concat(instance.getFlatHeaders(), instance.getCenterFlatHeaders(), instance.getLeftFlatHeaders(), instance.getRightFlatHeaders()).find(function (d) {
@@ -1778,11 +2188,6 @@
1778
2188
  },
1779
2189
  getFooterProps: function getFooterProps(id, userProps) {
1780
2190
  var header = instance.getHeader(id);
1781
-
1782
- if (!header) {
1783
- return;
1784
- }
1785
-
1786
2191
  var initialProps = {
1787
2192
  key: header.id,
1788
2193
  role: 'columnfooter',
@@ -1941,7 +2346,7 @@
1941
2346
  var Headers = /*#__PURE__*/Object.freeze({
1942
2347
  __proto__: null,
1943
2348
  createRow: createRow$2,
1944
- getInstance: getInstance$6,
2349
+ getInstance: getInstance$5,
1945
2350
  buildHeaderGroups: buildHeaderGroups
1946
2351
  });
1947
2352
 
@@ -2107,13 +2512,13 @@
2107
2512
  filterType: 'auto'
2108
2513
  };
2109
2514
  }
2110
- function getInitialState$5() {
2515
+ function getInitialState$4() {
2111
2516
  return {
2112
2517
  columnFilters: [],
2113
2518
  globalFilter: undefined
2114
2519
  };
2115
2520
  }
2116
- function getDefaultOptions$5(instance) {
2521
+ function getDefaultOptions$4(instance) {
2117
2522
  return {
2118
2523
  onColumnFiltersChange: makeStateUpdater('columnFilters', instance),
2119
2524
  onGlobalFilterChange: makeStateUpdater('globalFilter', instance),
@@ -2122,14 +2527,14 @@
2122
2527
  autoResetGlobalFilter: true,
2123
2528
  globalFilterType: 'auto',
2124
2529
  getColumnCanGlobalFilterFn: function getColumnCanGlobalFilterFn(column) {
2125
- var _instance$getCoreFlat, _instance$getCoreFlat2;
2530
+ var _instance$getCoreRowM, _instance$getCoreRowM2;
2126
2531
 
2127
- var value = (_instance$getCoreFlat = instance.getCoreFlatRows()[0]) == null ? void 0 : (_instance$getCoreFlat2 = _instance$getCoreFlat.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreFlat2.value;
2532
+ var value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.value;
2128
2533
  return typeof value === 'string';
2129
2534
  }
2130
2535
  };
2131
2536
  }
2132
- function createColumn$2(column, instance) {
2537
+ function createColumn$1(column, instance) {
2133
2538
  var getFacetInfo = memo(function () {
2134
2539
  return [column.getPreFilteredRows()];
2135
2540
  }, function (rows) {
@@ -2168,7 +2573,11 @@
2168
2573
  };
2169
2574
  }, {
2170
2575
  key: 'column.getFacetInfo',
2171
- debug: instance.options.debug
2576
+ debug: function debug() {
2577
+ var _instance$options$deb;
2578
+
2579
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
2580
+ }
2172
2581
  });
2173
2582
  return {
2174
2583
  filterType: column.filterType,
@@ -2201,7 +2610,7 @@
2201
2610
  }
2202
2611
  };
2203
2612
  }
2204
- function getInstance$5(instance) {
2613
+ function getInstance$4(instance) {
2205
2614
  var registered = false;
2206
2615
  return {
2207
2616
  _notifyFiltersReset: function _notifyFiltersReset() {
@@ -2227,7 +2636,7 @@
2227
2636
  }
2228
2637
  },
2229
2638
  getColumnAutoFilterFn: function getColumnAutoFilterFn(columnId) {
2230
- var firstRow = instance.getCoreFlatRows()[0];
2639
+ var firstRow = instance.getCoreRowModel().flatRows[0];
2231
2640
  var value = firstRow == null ? void 0 : firstRow.values[columnId];
2232
2641
 
2233
2642
  if (typeof value === 'string') {
@@ -2397,6 +2806,12 @@
2397
2806
 
2398
2807
  instance.setColumnFilters((_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnFilters) != null ? _instance$initialStat : []);
2399
2808
  },
2809
+ getPreFilteredRowModel: function getPreFilteredRowModel() {
2810
+ return instance.getCoreRowModel();
2811
+ },
2812
+ getPreColumnFilteredRowModel: function getPreColumnFilteredRowModel() {
2813
+ return instance.getCoreRowModel();
2814
+ },
2400
2815
  getColumnFilteredRowModel: memo(function () {
2401
2816
  return [instance.getState().columnFilters, instance.getCoreRowModel(), instance.options.columnFilterRowsFn];
2402
2817
  }, function (columnFilters, rowModel, columnFiltersFn) {
@@ -2405,7 +2820,6 @@
2405
2820
  return rowModel;
2406
2821
  }
2407
2822
 
2408
- if (instance.options.debug) console.info('Column Filtering...');
2409
2823
  return columnFiltersFn(instance, rowModel);
2410
2824
  }(); // Now that each filtered column has it's partially filtered rows,
2411
2825
  // lets assign the final filtered rows to all of the other columns
@@ -2428,39 +2842,14 @@
2428
2842
  return columnFilteredRowModel;
2429
2843
  }, {
2430
2844
  key: 'getColumnFilteredRowModel',
2431
- debug: instance.options.debug
2845
+ debug: function debug() {
2846
+ var _instance$options$deb2;
2847
+
2848
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugTable;
2849
+ }
2432
2850
  }),
2433
- // These might be easier to remember than "column" filtered rows
2434
- getPreFilteredRowModel: function getPreFilteredRowModel() {
2435
- return instance.getCoreRowModel();
2436
- },
2437
- getPreFilteredRows: function getPreFilteredRows() {
2438
- return instance.getCoreRowModel().rows;
2439
- },
2440
- getPreFilteredFlatRows: function getPreFilteredFlatRows() {
2441
- return instance.getCoreRowModel().flatRows;
2442
- },
2443
- getPreFilteredRowsById: function getPreFilteredRowsById() {
2444
- return instance.getCoreRowModel().rowsById;
2445
- },
2446
- // Pre Column Filter
2447
- getPreColumnFilteredRows: function getPreColumnFilteredRows() {
2448
- return instance.getCoreRowModel().rows;
2449
- },
2450
- getPreColumnFilteredFlatRows: function getPreColumnFilteredFlatRows() {
2451
- return instance.getCoreRowModel().flatRows;
2452
- },
2453
- getPreColumnFilteredRowsById: function getPreColumnFilteredRowsById() {
2454
- return instance.getCoreRowModel().rowsById;
2455
- },
2456
- getColumnFilteredRows: function getColumnFilteredRows() {
2457
- return instance.getColumnFilteredRowModel().rows;
2458
- },
2459
- getColumnFilteredFlatRows: function getColumnFilteredFlatRows() {
2460
- return instance.getColumnFilteredRowModel().flatRows;
2461
- },
2462
- getColumnFilteredRowsById: function getColumnFilteredRowsById() {
2463
- return instance.getColumnFilteredRowModel().rowsById;
2851
+ getPreGlobalFilteredRowModel: function getPreGlobalFilteredRowModel() {
2852
+ return instance.getColumnFilteredRowModel();
2464
2853
  },
2465
2854
  getGlobalFilteredRowModel: memo(function () {
2466
2855
  return [instance.getState().globalFilter, instance.getColumnFilteredRowModel(), instance.options.globalFilterRowsFn];
@@ -2470,7 +2859,6 @@
2470
2859
  return columnFilteredRowModel;
2471
2860
  }
2472
2861
 
2473
- if (instance.options.debug) console.info('Global Filtering...');
2474
2862
  return globalFiltersFn(instance, columnFilteredRowModel);
2475
2863
  }(); // Now that each filtered column has it's partially filtered rows,
2476
2864
  // lets assign the final filtered rows to all of the other columns
@@ -2493,29 +2881,15 @@
2493
2881
  return globalFilteredRowModel;
2494
2882
  }, {
2495
2883
  key: 'getGlobalFilteredRowModel',
2496
- debug: instance.options.debug,
2884
+ debug: function debug() {
2885
+ var _instance$options$deb3;
2886
+
2887
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugTable;
2888
+ },
2497
2889
  onChange: function onChange() {
2498
2890
  instance._notifySortingReset();
2499
2891
  }
2500
- }),
2501
- getPreGlobalFilteredRows: function getPreGlobalFilteredRows() {
2502
- return instance.getColumnFilteredRowModel().rows;
2503
- },
2504
- getPreGlobalFilteredFlatRows: function getPreGlobalFilteredFlatRows() {
2505
- return instance.getColumnFilteredRowModel().flatRows;
2506
- },
2507
- getPreGlobalFilteredRowsById: function getPreGlobalFilteredRowsById() {
2508
- return instance.getColumnFilteredRowModel().rowsById;
2509
- },
2510
- getGlobalFilteredRows: function getGlobalFilteredRows() {
2511
- return instance.getGlobalFilteredRowModel().rows;
2512
- },
2513
- getGlobalFilteredFlatRows: function getGlobalFilteredFlatRows() {
2514
- return instance.getGlobalFilteredRowModel().flatRows;
2515
- },
2516
- getGlobalFilteredRowsById: function getGlobalFilteredRowsById() {
2517
- return instance.getGlobalFilteredRowModel().rowsById;
2518
- }
2892
+ })
2519
2893
  };
2520
2894
  }
2521
2895
  function shouldAutoRemoveFilter(filterFn, value, column) {
@@ -2525,10 +2899,10 @@
2525
2899
  var Filters = /*#__PURE__*/Object.freeze({
2526
2900
  __proto__: null,
2527
2901
  getDefaultColumn: getDefaultColumn$1,
2528
- getInitialState: getInitialState$5,
2529
- getDefaultOptions: getDefaultOptions$5,
2530
- createColumn: createColumn$2,
2531
- getInstance: getInstance$5,
2902
+ getInitialState: getInitialState$4,
2903
+ getDefaultOptions: getDefaultOptions$4,
2904
+ createColumn: createColumn$1,
2905
+ getInstance: getInstance$4,
2532
2906
  shouldAutoRemoveFilter: shouldAutoRemoveFilter
2533
2907
  });
2534
2908
 
@@ -2566,410 +2940,124 @@
2566
2940
  var bn = parseInt(bb, 10);
2567
2941
  var combo = [an, bn].sort(); // Both are string
2568
2942
 
2569
- if (isNaN(combo[0])) {
2570
- if (aa > bb) {
2571
- return 1;
2572
- }
2573
-
2574
- if (bb > aa) {
2575
- return -1;
2576
- }
2577
-
2578
- continue;
2579
- } // One is a string, one is a number
2580
-
2581
-
2582
- if (isNaN(combo[1])) {
2583
- return isNaN(an) ? -1 : 1;
2584
- } // Both are numbers
2585
-
2586
-
2587
- if (an > bn) {
2588
- return 1;
2589
- }
2590
-
2591
- if (bn > an) {
2592
- return -1;
2593
- }
2594
- }
2595
-
2596
- return a.length - b.length;
2597
- } // The text filter is more basic (less numeric support)
2598
- // but is much faster
2599
-
2600
-
2601
- function text(rowA, rowB, columnId) {
2602
- return compareBasic(toString(rowA.values[columnId]).toLowerCase(), toString(rowB.values[columnId]).toLowerCase());
2603
- } // The text filter is more basic (less numeric support)
2604
- // but is much faster
2605
-
2606
-
2607
- function textCaseSensitive(rowA, rowB, columnId) {
2608
- return compareBasic(toString(rowA.values[columnId]), toString(rowB.values[columnId]));
2609
- }
2610
-
2611
- function datetime(rowA, rowB, columnId) {
2612
- return compareBasic(rowA.values[columnId].getTime(), rowB.values[columnId].getTime());
2613
- }
2614
-
2615
- function basic(rowA, rowB, columnId) {
2616
- return compareBasic(rowA.values[columnId], rowB.values[columnId]);
2617
- } // Utils
2618
-
2619
-
2620
- function compareBasic(a, b) {
2621
- return a === b ? 0 : a > b ? 1 : -1;
2622
- }
2623
-
2624
- function toString(a) {
2625
- if (typeof a === 'number') {
2626
- if (isNaN(a) || a === Infinity || a === -Infinity) {
2627
- return '';
2628
- }
2629
-
2630
- return String(a);
2631
- }
2632
-
2633
- if (typeof a === 'string') {
2634
- return a;
2635
- }
2636
-
2637
- return '';
2638
- }
2639
-
2640
- //
2641
- function getDefaultColumn() {
2642
- return {
2643
- sortType: 'auto'
2644
- };
2645
- }
2646
- function getInitialState$4() {
2647
- return {
2648
- sorting: []
2649
- };
2650
- }
2651
- function getDefaultOptions$4(instance) {
2652
- return {
2653
- onSortingChange: makeStateUpdater('sorting', instance),
2654
- autoResetSorting: true,
2655
- isMultiSortEvent: function isMultiSortEvent(e) {
2656
- return e.shiftKey;
2657
- }
2658
- };
2659
- }
2660
- function createColumn$1(column, instance) {
2661
- return {
2662
- sortType: column.sortType,
2663
- getCanSort: function getCanSort() {
2664
- return instance.getColumnCanSort(column.id);
2665
- },
2666
- getCanMultiSort: function getCanMultiSort() {
2667
- return instance.getColumnCanMultiSort(column.id);
2668
- },
2669
- getSortIndex: function getSortIndex() {
2670
- return instance.getColumnSortIndex(column.id);
2671
- },
2672
- getIsSorted: function getIsSorted() {
2673
- return instance.getColumnIsSorted(column.id);
2674
- },
2675
- toggleSorting: function toggleSorting(desc, isMulti) {
2676
- return instance.toggleColumnSorting(column.id, desc, isMulti);
2677
- },
2678
- getToggleSortingProps: function getToggleSortingProps(userProps) {
2679
- return instance.getToggleSortingProps(column.id, userProps);
2680
- }
2681
- };
2682
- }
2683
- function getInstance$4(instance) {
2684
- var registered = false;
2685
- return {
2686
- _notifySortingReset: function _notifySortingReset() {
2687
- if (!registered) {
2688
- registered = true;
2689
- return;
2690
- }
2691
-
2692
- if (instance.options.autoResetAll === false) {
2693
- return;
2694
- }
2695
-
2696
- if (instance.options.autoResetAll === true || instance.options.autoResetSorting) {
2697
- instance.resetSorting();
2698
- }
2699
- },
2700
- getColumnAutoSortingFn: function getColumnAutoSortingFn(columnId) {
2701
- var firstRows = instance.getGlobalFilteredRowModel().flatRows.slice(100);
2702
- var isString = false;
2703
-
2704
- for (var _iterator = _createForOfIteratorHelperLoose(firstRows), _step; !(_step = _iterator()).done;) {
2705
- var row = _step.value;
2706
- var value = row == null ? void 0 : row.values[columnId];
2707
-
2708
- if (Object.prototype.toString.call(value) === '[object Date]') {
2709
- return sortTypes.datetime;
2710
- }
2711
-
2712
- if (typeof value === 'string') {
2713
- isString = true;
2714
-
2715
- if (value.split(reSplitAlphaNumeric).length > 1) {
2716
- return sortTypes.alphanumeric;
2717
- }
2718
- }
2719
- }
2720
-
2721
- if (isString) {
2722
- return sortTypes.text;
2723
- }
2724
-
2725
- return sortTypes.basic;
2726
- },
2727
- getColumnAutoSortDir: function getColumnAutoSortDir(columnId) {
2728
- var firstRow = instance.getGlobalFilteredRowModel().flatRows[0];
2729
- var value = firstRow == null ? void 0 : firstRow.values[columnId];
2730
-
2731
- if (typeof value === 'string') {
2732
- return 'asc';
2733
- }
2734
-
2735
- return 'desc';
2736
- },
2737
- getColumnSortingFn: function getColumnSortingFn(columnId) {
2738
- var _ref;
2739
-
2740
- var column = instance.getColumn(columnId);
2741
- var userSortTypes = instance.options.sortTypes;
2742
-
2743
- if (!column) {
2744
- throw new Error();
2745
- }
2746
-
2747
- return isFunction(column.sortType) ? column.sortType : column.sortType === 'auto' ? instance.getColumnAutoSortingFn(columnId) : (_ref = userSortTypes == null ? void 0 : userSortTypes[column.sortType]) != null ? _ref : sortTypes[column.sortType];
2748
- },
2749
- setSorting: function setSorting(updater) {
2750
- return instance.options.onSortingChange == null ? void 0 : instance.options.onSortingChange(updater, functionalUpdate(updater, instance.getState().sorting));
2751
- },
2752
- toggleColumnSorting: function toggleColumnSorting(columnId, desc, multi) {
2753
- var column = instance.getColumn(columnId);
2754
-
2755
- if (!column) {
2756
- throw new Error();
2757
- } // if (column.columns.length) {
2758
- // column.columns.forEach((c, i) => {
2759
- // if (c.id) {
2760
- // instance.toggleColumnSorting(c.id, undefined, multi || !!i)
2761
- // }
2762
- // })
2763
- // return
2764
- // }
2765
-
2766
-
2767
- instance.setSorting(function (old) {
2768
- var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
2769
-
2770
- // Find any existing sorting for this column
2771
- var existingSorting = old == null ? void 0 : old.find(function (d) {
2772
- return d.id === columnId;
2773
- });
2774
- var existingIndex = old == null ? void 0 : old.findIndex(function (d) {
2775
- return d.id === columnId;
2776
- });
2777
- var hasDescDefined = typeof desc !== 'undefined' && desc !== null;
2778
- var newSorting = []; // What should we do with this sort action?
2779
-
2780
- var sortAction;
2781
-
2782
- if (column.getCanMultiSort() && multi) {
2783
- if (existingSorting) {
2784
- sortAction = 'toggle';
2785
- } else {
2786
- sortAction = 'add';
2787
- }
2788
- } else {
2789
- // Normal mode
2790
- if (old != null && old.length && existingIndex !== old.length - 1) {
2791
- sortAction = 'replace';
2792
- } else if (existingSorting) {
2793
- sortAction = 'toggle';
2794
- } else {
2795
- sortAction = 'replace';
2796
- }
2797
- }
2798
-
2799
- var sortDescFirst = (_ref2 = (_column$sortDescFirst = column.sortDescFirst) != null ? _column$sortDescFirst : instance.options.sortDescFirst) != null ? _ref2 : instance.getColumnAutoSortDir(columnId) === 'desc'; // Handle toggle states that will remove the sorting
2800
-
2801
- if (sortAction === 'toggle' && ( // Must be toggling
2802
- (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
2803
- !hasDescDefined && ( // Must not be setting desc
2804
- multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
2805
- existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
2806
- ? !sortDescFirst : sortDescFirst)) {
2807
- sortAction = 'remove';
2808
- }
2809
-
2810
- if (sortAction === 'replace') {
2811
- newSorting = [{
2812
- id: columnId,
2813
- desc: hasDescDefined ? desc : !!sortDescFirst
2814
- }];
2815
- } else if (sortAction === 'add' && old != null && old.length) {
2816
- var _instance$options$max;
2943
+ if (isNaN(combo[0])) {
2944
+ if (aa > bb) {
2945
+ return 1;
2946
+ }
2817
2947
 
2818
- newSorting = [].concat(old, [{
2819
- id: columnId,
2820
- desc: hasDescDefined ? desc : !!sortDescFirst
2821
- }]); // Take latest n columns
2948
+ if (bb > aa) {
2949
+ return -1;
2950
+ }
2822
2951
 
2823
- newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
2824
- } else if (sortAction === 'toggle' && old != null && old.length) {
2825
- // This flips (or sets) the
2826
- newSorting = old.map(function (d) {
2827
- if (d.id === columnId) {
2828
- return _extends({}, d, {
2829
- desc: hasDescDefined ? desc : !(existingSorting != null && existingSorting.desc)
2830
- });
2831
- }
2952
+ continue;
2953
+ } // One is a string, one is a number
2832
2954
 
2833
- return d;
2834
- });
2835
- } else if (sortAction === 'remove' && old != null && old.length) {
2836
- newSorting = old.filter(function (d) {
2837
- return d.id !== columnId;
2838
- });
2839
- }
2840
2955
 
2841
- return newSorting;
2842
- });
2843
- },
2844
- getColumnCanSort: function getColumnCanSort(columnId) {
2845
- var _ref3, _ref4, _column$enableSorting;
2956
+ if (isNaN(combo[1])) {
2957
+ return isNaN(an) ? -1 : 1;
2958
+ } // Both are numbers
2846
2959
 
2847
- var column = instance.getColumn(columnId);
2848
2960
 
2849
- if (!column) {
2850
- throw new Error();
2851
- }
2961
+ if (an > bn) {
2962
+ return 1;
2963
+ }
2852
2964
 
2853
- return (_ref3 = (_ref4 = (_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : instance.options.enableSorting) != null ? _ref4 : column.defaultCanSort) != null ? _ref3 : !!column.accessorFn // (!!column.accessorFn ||
2854
- // column.columns?.some(c => c.id && instance.getColumnCanSort(c.id))) ??
2855
- // false
2856
- ;
2857
- },
2858
- getColumnCanMultiSort: function getColumnCanMultiSort(columnId) {
2859
- var _ref5, _column$enableMultiSo;
2965
+ if (bn > an) {
2966
+ return -1;
2967
+ }
2968
+ }
2860
2969
 
2861
- var column = instance.getColumn(columnId);
2970
+ return a.length - b.length;
2971
+ } // The text filter is more basic (less numeric support)
2972
+ // but is much faster
2862
2973
 
2863
- if (!column) {
2864
- throw new Error();
2865
- }
2866
2974
 
2867
- return (_ref5 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref5 : !!column.accessorFn;
2868
- },
2869
- getColumnIsSorted: function getColumnIsSorted(columnId) {
2870
- var _instance$getState$so;
2975
+ function text(rowA, rowB, columnId) {
2976
+ return compareBasic(toString(rowA.values[columnId]).toLowerCase(), toString(rowB.values[columnId]).toLowerCase());
2977
+ } // The text filter is more basic (less numeric support)
2978
+ // but is much faster
2871
2979
 
2872
- var columnSort = (_instance$getState$so = instance.getState().sorting) == null ? void 0 : _instance$getState$so.find(function (d) {
2873
- return d.id === columnId;
2874
- });
2875
- return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
2876
- },
2877
- getColumnSortIndex: function getColumnSortIndex(columnId) {
2878
- var _instance$getState$so2, _instance$getState$so3;
2879
2980
 
2880
- return (_instance$getState$so2 = (_instance$getState$so3 = instance.getState().sorting) == null ? void 0 : _instance$getState$so3.findIndex(function (d) {
2881
- return d.id === columnId;
2882
- })) != null ? _instance$getState$so2 : -1;
2883
- },
2884
- resetSorting: function resetSorting() {
2885
- var _instance$initialStat, _instance$initialStat2;
2981
+ function textCaseSensitive(rowA, rowB, columnId) {
2982
+ return compareBasic(toString(rowA.values[columnId]), toString(rowB.values[columnId]));
2983
+ }
2886
2984
 
2887
- instance.setSorting((_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.sorting) != null ? _instance$initialStat : []);
2888
- },
2889
- getToggleSortingProps: function getToggleSortingProps(columnId, userProps) {
2890
- var column = instance.getColumn(columnId);
2985
+ function datetime(rowA, rowB, columnId) {
2986
+ return compareBasic(rowA.values[columnId].getTime(), rowB.values[columnId].getTime());
2987
+ }
2891
2988
 
2892
- if (!column) {
2893
- throw new Error();
2894
- }
2989
+ function basic(rowA, rowB, columnId) {
2990
+ return compareBasic(rowA.values[columnId], rowB.values[columnId]);
2991
+ } // Utils
2895
2992
 
2896
- var canSort = column.getCanSort();
2897
- var initialProps = {
2898
- title: canSort ? 'Toggle Sorting' : undefined,
2899
- onClick: canSort ? function (e) {
2900
- e.persist();
2901
- column.toggleSorting == null ? void 0 : column.toggleSorting(undefined, column.getCanMultiSort() ? instance.options.isMultiSortEvent == null ? void 0 : instance.options.isMultiSortEvent(e) : false);
2902
- } : undefined
2903
- };
2904
- return propGetter(initialProps, userProps);
2905
- },
2906
- getSortedRowModel: memo(function () {
2907
- return [instance.getState().sorting, instance.getGlobalFilteredRowModel(), instance.options.sortRowsFn];
2908
- }, function (sorting, rowModel, sortingFn) {
2909
- if (!sortingFn || !(sorting != null && sorting.length)) {
2910
- return rowModel;
2911
- }
2912
2993
 
2913
- if (instance.options.debug) console.info('Sorting...');
2914
- return sortingFn(instance, rowModel);
2915
- }, {
2916
- key: 'getSortedRowModel',
2917
- debug: instance.options.debug,
2918
- onChange: function onChange() {
2919
- return instance._notifyGroupingReset();
2920
- }
2921
- }),
2922
- getPreSortedRows: function getPreSortedRows() {
2923
- return instance.getGlobalFilteredRowModel().rows;
2924
- },
2925
- getPreSortedFlatRows: function getPreSortedFlatRows() {
2926
- return instance.getGlobalFilteredRowModel().flatRows;
2927
- },
2928
- getPreSortedRowsById: function getPreSortedRowsById() {
2929
- return instance.getGlobalFilteredRowModel().rowsById;
2930
- },
2931
- getSortedRows: function getSortedRows() {
2932
- return instance.getSortedRowModel().rows;
2933
- },
2934
- getSortedFlatRows: function getSortedFlatRows() {
2935
- return instance.getSortedRowModel().flatRows;
2936
- },
2937
- getSortedRowsById: function getSortedRowsById() {
2938
- return instance.getSortedRowModel().rowsById;
2939
- }
2940
- };
2994
+ function compareBasic(a, b) {
2995
+ return a === b ? 0 : a > b ? 1 : -1;
2941
2996
  }
2942
2997
 
2943
- var Sorting = /*#__PURE__*/Object.freeze({
2944
- __proto__: null,
2945
- getDefaultColumn: getDefaultColumn,
2946
- getInitialState: getInitialState$4,
2947
- getDefaultOptions: getDefaultOptions$4,
2948
- createColumn: createColumn$1,
2949
- getInstance: getInstance$4
2950
- });
2998
+ function toString(a) {
2999
+ if (typeof a === 'number') {
3000
+ if (isNaN(a) || a === Infinity || a === -Infinity) {
3001
+ return '';
3002
+ }
3003
+
3004
+ return String(a);
3005
+ }
3006
+
3007
+ if (typeof a === 'string') {
3008
+ return a;
3009
+ }
3010
+
3011
+ return '';
3012
+ }
2951
3013
 
2952
3014
  //
3015
+ function getDefaultColumn() {
3016
+ return {
3017
+ sortType: 'auto'
3018
+ };
3019
+ }
2953
3020
  function getInitialState$3() {
2954
3021
  return {
2955
- expanded: {}
3022
+ sorting: []
2956
3023
  };
2957
3024
  }
2958
3025
  function getDefaultOptions$3(instance) {
2959
3026
  return {
2960
- onExpandedChange: makeStateUpdater('expanded', instance),
2961
- autoResetExpanded: true,
2962
- getIsRowExpanded: function getIsRowExpanded(row) {
2963
- return !!(row == null ? void 0 : row.original).expanded;
3027
+ onSortingChange: makeStateUpdater('sorting', instance),
3028
+ autoResetSorting: true,
3029
+ isMultiSortEvent: function isMultiSortEvent(e) {
3030
+ return e.shiftKey;
3031
+ }
3032
+ };
3033
+ }
3034
+ function createColumn(column, instance) {
3035
+ return {
3036
+ sortType: column.sortType,
3037
+ getCanSort: function getCanSort() {
3038
+ return instance.getColumnCanSort(column.id);
2964
3039
  },
2965
- expandSubRows: true,
2966
- paginateExpandedRows: true
3040
+ getCanMultiSort: function getCanMultiSort() {
3041
+ return instance.getColumnCanMultiSort(column.id);
3042
+ },
3043
+ getSortIndex: function getSortIndex() {
3044
+ return instance.getColumnSortIndex(column.id);
3045
+ },
3046
+ getIsSorted: function getIsSorted() {
3047
+ return instance.getColumnIsSorted(column.id);
3048
+ },
3049
+ toggleSorting: function toggleSorting(desc, isMulti) {
3050
+ return instance.toggleColumnSorting(column.id, desc, isMulti);
3051
+ },
3052
+ getToggleSortingProps: function getToggleSortingProps(userProps) {
3053
+ return instance.getToggleSortingProps(column.id, userProps);
3054
+ }
2967
3055
  };
2968
3056
  }
2969
3057
  function getInstance$3(instance) {
2970
3058
  var registered = false;
2971
3059
  return {
2972
- _notifyExpandedReset: function _notifyExpandedReset() {
3060
+ _notifySortingReset: function _notifySortingReset() {
2973
3061
  if (!registered) {
2974
3062
  registered = true;
2975
3063
  return;
@@ -2979,285 +3067,170 @@
2979
3067
  return;
2980
3068
  }
2981
3069
 
2982
- if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
2983
- instance.resetExpanded();
3070
+ if (instance.options.autoResetAll === true || instance.options.autoResetSorting) {
3071
+ instance.resetSorting();
2984
3072
  }
2985
3073
  },
2986
- setExpanded: function setExpanded(updater) {
2987
- return instance.options.onExpandedChange == null ? void 0 : instance.options.onExpandedChange(updater, functionalUpdate(updater, instance.getState().expanded));
2988
- },
2989
- toggleRowExpanded: function toggleRowExpanded(rowId, expanded) {
2990
- if (!rowId) return;
2991
- instance.setExpanded(function (old) {
2992
- var _expanded;
2993
-
2994
- var exists = old === true ? true : !!(old != null && old[rowId]);
2995
- var oldExpanded = {};
2996
-
2997
- if (old === true) {
2998
- Object.keys(instance.getRowsById()).forEach(function (rowId) {
2999
- oldExpanded[rowId] = true;
3000
- });
3001
- } else {
3002
- oldExpanded = old;
3003
- }
3004
-
3005
- expanded = (_expanded = expanded) != null ? _expanded : !exists;
3006
-
3007
- if (!exists && expanded) {
3008
- var _extends2;
3009
-
3010
- return _extends({}, oldExpanded, (_extends2 = {}, _extends2[rowId] = true, _extends2));
3011
- }
3074
+ getColumnAutoSortingFn: function getColumnAutoSortingFn(columnId) {
3075
+ var firstRows = instance.getGlobalFilteredRowModel().flatRows.slice(100);
3076
+ var isString = false;
3012
3077
 
3013
- if (exists && !expanded) {
3014
- var _oldExpanded = oldExpanded;
3015
- _oldExpanded[rowId];
3016
- var rest = _objectWithoutPropertiesLoose(_oldExpanded, [rowId].map(_toPropertyKey));
3078
+ for (var _iterator = _createForOfIteratorHelperLoose(firstRows), _step; !(_step = _iterator()).done;) {
3079
+ var row = _step.value;
3080
+ var value = row == null ? void 0 : row.values[columnId];
3017
3081
 
3018
- return rest;
3082
+ if (Object.prototype.toString.call(value) === '[object Date]') {
3083
+ return sortTypes.datetime;
3019
3084
  }
3020
3085
 
3021
- return old;
3022
- });
3023
- },
3024
- toggleAllRowsExpanded: function toggleAllRowsExpanded(expanded) {
3025
- if (expanded != null ? expanded : !instance.getIsAllRowsExpanded()) {
3026
- instance.setExpanded(true);
3027
- } else {
3028
- instance.setExpanded({});
3029
- }
3030
- },
3031
- resetExpanded: function resetExpanded() {
3032
- var _instance$initialStat, _instance$initialStat2;
3033
-
3034
- instance.setExpanded((_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.expanded) != null ? _instance$initialStat : {});
3035
- },
3036
- getIsRowExpanded: function getIsRowExpanded(rowId) {
3037
- var _instance$options$get;
3038
-
3039
- var row = instance.getRow(rowId);
3086
+ if (typeof value === 'string') {
3087
+ isString = true;
3040
3088
 
3041
- if (!row) {
3042
- {
3043
- console.warn("[ReactTable] getIsRowExpanded: no row found with id " + rowId);
3089
+ if (value.split(reSplitAlphaNumeric).length > 1) {
3090
+ return sortTypes.alphanumeric;
3091
+ }
3044
3092
  }
3093
+ }
3045
3094
 
3046
- throw new Error();
3095
+ if (isString) {
3096
+ return sortTypes.text;
3047
3097
  }
3048
3098
 
3049
- var expanded = instance.getState().expanded;
3050
- return !!((_instance$options$get = instance.options.getIsRowExpanded == null ? void 0 : instance.options.getIsRowExpanded(row)) != null ? _instance$options$get : expanded || (expanded == null ? void 0 : expanded[rowId]));
3099
+ return sortTypes.basic;
3051
3100
  },
3052
- getRowCanExpand: function getRowCanExpand(rowId) {
3053
- var _ref, _ref2, _instance$options$get2, _row$subRows;
3054
-
3055
- var row = instance.getRow(rowId);
3056
-
3057
- if (!row) {
3058
- {
3059
- console.warn("[ReactTable] getRowCanExpand: no row found with id " + rowId);
3060
- }
3101
+ getColumnAutoSortDir: function getColumnAutoSortDir(columnId) {
3102
+ var firstRow = instance.getGlobalFilteredRowModel().flatRows[0];
3103
+ var value = firstRow == null ? void 0 : firstRow.values[columnId];
3061
3104
 
3062
- throw new Error();
3105
+ if (typeof value === 'string') {
3106
+ return 'asc';
3063
3107
  }
3064
3108
 
3065
- return (_ref = (_ref2 = (_instance$options$get2 = instance.options.getRowCanExpand == null ? void 0 : instance.options.getRowCanExpand(row)) != null ? _instance$options$get2 : instance.options.enableExpanded) != null ? _ref2 : instance.options.defaultCanExpand) != null ? _ref : !!((_row$subRows = row.subRows) != null && _row$subRows.length);
3109
+ return 'desc';
3066
3110
  },
3067
- getToggleExpandedProps: function getToggleExpandedProps(rowId, userProps) {
3068
- var row = instance.getRow(rowId);
3111
+ getColumnSortingFn: function getColumnSortingFn(columnId) {
3112
+ var _ref;
3069
3113
 
3070
- if (!row) {
3071
- return;
3114
+ var column = instance.getColumn(columnId);
3115
+ var userSortTypes = instance.options.sortTypes;
3116
+
3117
+ if (!column) {
3118
+ throw new Error();
3072
3119
  }
3073
3120
 
3074
- var canExpand = instance.getRowCanExpand(rowId);
3075
- var initialProps = {
3076
- title: canExpand ? 'Toggle Expanded' : undefined,
3077
- onClick: canExpand ? function (e) {
3078
- e.persist();
3079
- instance.toggleRowExpanded(rowId);
3080
- } : undefined
3081
- };
3082
- return propGetter(initialProps, userProps);
3121
+ return isFunction(column.sortType) ? column.sortType : column.sortType === 'auto' ? instance.getColumnAutoSortingFn(columnId) : (_ref = userSortTypes == null ? void 0 : userSortTypes[column.sortType]) != null ? _ref : sortTypes[column.sortType];
3083
3122
  },
3084
- getToggleAllRowsExpandedProps: function getToggleAllRowsExpandedProps(userProps) {
3085
- var initialProps = {
3086
- title: 'Toggle All Expanded',
3087
- onClick: function onClick(e) {
3088
- e.persist();
3089
- instance.toggleAllRowsExpanded();
3090
- }
3091
- };
3092
- return propGetter(initialProps, userProps);
3123
+ setSorting: function setSorting(updater) {
3124
+ return instance.options.onSortingChange == null ? void 0 : instance.options.onSortingChange(updater, functionalUpdate(updater, instance.getState().sorting));
3093
3125
  },
3094
- getIsAllRowsExpanded: function getIsAllRowsExpanded() {
3095
- var expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
3126
+ toggleColumnSorting: function toggleColumnSorting(columnId, desc, multi) {
3127
+ var column = instance.getColumn(columnId);
3096
3128
 
3097
- if (expanded === true) {
3098
- return true;
3099
- } // If any row is not expanded, return false
3129
+ if (!column) {
3130
+ throw new Error();
3131
+ } // if (column.columns.length) {
3132
+ // column.columns.forEach((c, i) => {
3133
+ // if (c.id) {
3134
+ // instance.toggleColumnSorting(c.id, undefined, multi || !!i)
3135
+ // }
3136
+ // })
3137
+ // return
3138
+ // }
3100
3139
 
3101
3140
 
3102
- if (Object.keys(instance.getRowsById()).some(function (id) {
3103
- return !instance.getIsRowExpanded(id);
3104
- })) {
3105
- return false;
3106
- } // They must all be expanded :shrug:
3141
+ instance.setSorting(function (old) {
3142
+ var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
3107
3143
 
3144
+ // Find any existing sorting for this column
3145
+ var existingSorting = old == null ? void 0 : old.find(function (d) {
3146
+ return d.id === columnId;
3147
+ });
3148
+ var existingIndex = old == null ? void 0 : old.findIndex(function (d) {
3149
+ return d.id === columnId;
3150
+ });
3151
+ var hasDescDefined = typeof desc !== 'undefined' && desc !== null;
3152
+ var newSorting = []; // What should we do with this sort action?
3108
3153
 
3109
- return true;
3110
- },
3111
- getExpandedDepth: function getExpandedDepth() {
3112
- var maxDepth = 0;
3113
- var rowIds = instance.getState().expanded === true ? Object.keys(instance.getRowsById()) : Object.keys(instance.getState().expanded);
3114
- rowIds.forEach(function (id) {
3115
- var splitId = id.split('.');
3116
- maxDepth = Math.max(maxDepth, splitId.length);
3117
- });
3118
- return maxDepth;
3119
- },
3120
- getExpandedRowModel: memo(function () {
3121
- return [instance.getState().expanded, instance.getGroupedRowModel(), instance.options.expandRowsFn, instance.options.paginateExpandedRows];
3122
- }, function (expanded, rowModel, expandRowsFn, paginateExpandedRows) {
3123
- if (!expandRowsFn || // Do not expand if rows are not included in pagination
3124
- !paginateExpandedRows || !Object.keys(expanded != null ? expanded : {}).length) {
3125
- return rowModel;
3126
- }
3154
+ var sortAction;
3127
3155
 
3128
- if (instance.options.debug) console.info('Expanding...');
3129
- return expandRowsFn(instance, rowModel);
3130
- }, {
3131
- key: 'getExpandedRowModel',
3132
- debug: instance.options.debug,
3133
- onChange: function onChange() {
3134
- instance._notifyPageIndexReset();
3135
- }
3136
- }),
3137
- getPreExpandedRows: function getPreExpandedRows() {
3138
- return instance.getGroupedRowModel().rows;
3139
- },
3140
- getPreExpandedFlatRows: function getPreExpandedFlatRows() {
3141
- return instance.getGroupedRowModel().flatRows;
3142
- },
3143
- getPreExpandedRowsById: function getPreExpandedRowsById() {
3144
- return instance.getGroupedRowModel().rowsById;
3145
- },
3146
- getExpandedRows: function getExpandedRows() {
3147
- return instance.getExpandedRowModel().rows;
3148
- },
3149
- getExpandedFlatRows: function getExpandedFlatRows() {
3150
- return instance.getExpandedRowModel().flatRows;
3151
- },
3152
- getExpandedRowsById: function getExpandedRowsById() {
3153
- return instance.getExpandedRowModel().rowsById;
3154
- }
3155
- };
3156
- }
3157
- function createRow$1(row, instance) {
3158
- return {
3159
- toggleExpanded: function toggleExpanded(expanded) {
3160
- return void instance.toggleRowExpanded(row.id, expanded);
3161
- },
3162
- getIsExpanded: function getIsExpanded() {
3163
- return instance.getIsRowExpanded(row.id);
3164
- },
3165
- getCanExpand: function getCanExpand() {
3166
- return row.subRows && !!row.subRows.length;
3167
- },
3168
- getToggleExpandedProps: function getToggleExpandedProps(userProps) {
3169
- var initialProps = {
3170
- title: 'Toggle Row Expanded',
3171
- onClick: function onClick(e) {
3172
- e.stopPropagation();
3173
- instance.toggleRowExpanded(row.id);
3156
+ if (column.getCanMultiSort() && multi) {
3157
+ if (existingSorting) {
3158
+ sortAction = 'toggle';
3159
+ } else {
3160
+ sortAction = 'add';
3161
+ }
3162
+ } else {
3163
+ // Normal mode
3164
+ if (old != null && old.length && existingIndex !== old.length - 1) {
3165
+ sortAction = 'replace';
3166
+ } else if (existingSorting) {
3167
+ sortAction = 'toggle';
3168
+ } else {
3169
+ sortAction = 'replace';
3170
+ }
3174
3171
  }
3175
- };
3176
- return propGetter(initialProps, userProps);
3177
- }
3178
- };
3179
- }
3180
3172
 
3181
- var Expanding = /*#__PURE__*/Object.freeze({
3182
- __proto__: null,
3183
- getInitialState: getInitialState$3,
3184
- getDefaultOptions: getDefaultOptions$3,
3185
- getInstance: getInstance$3,
3186
- createRow: createRow$1
3187
- });
3173
+ var sortDescFirst = (_ref2 = (_column$sortDescFirst = column.sortDescFirst) != null ? _column$sortDescFirst : instance.options.sortDescFirst) != null ? _ref2 : instance.getColumnAutoSortDir(columnId) === 'desc'; // Handle toggle states that will remove the sorting
3188
3174
 
3189
- //
3190
- var defaultColumnSizing = {
3191
- width: 150,
3192
- minWidth: 20,
3193
- maxWidth: Number.MAX_SAFE_INTEGER
3194
- };
3195
- function getInitialState$2() {
3196
- return {
3197
- columnSizing: {},
3198
- columnSizingInfo: {
3199
- startOffset: null,
3200
- startSize: null,
3201
- deltaOffset: null,
3202
- deltaPercentage: null,
3203
- isResizingColumn: false,
3204
- columnSizingStart: []
3205
- }
3206
- };
3207
- }
3208
- function getDefaultOptions$2(instance) {
3209
- return {
3210
- columnResizeMode: 'onEnd',
3211
- onColumnSizingChange: makeStateUpdater('columnSizing', instance),
3212
- onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', instance)
3213
- };
3214
- }
3215
- function getInstance$2(instance) {
3216
- return {
3217
- setColumnSizing: function setColumnSizing(updater) {
3218
- return instance.options.onColumnSizingChange == null ? void 0 : instance.options.onColumnSizingChange(updater, functionalUpdate(updater, instance.getState().columnSizing));
3219
- },
3220
- setColumnSizingInfo: function setColumnSizingInfo(updater) {
3221
- return instance.options.onColumnSizingInfoChange == null ? void 0 : instance.options.onColumnSizingInfoChange(updater, functionalUpdate(updater, instance.getState().columnSizingInfo));
3222
- },
3223
- resetColumnSizing: function resetColumnSizing() {
3224
- var _instance$initialStat;
3175
+ if (sortAction === 'toggle' && ( // Must be toggling
3176
+ (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
3177
+ !hasDescDefined && ( // Must not be setting desc
3178
+ multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
3179
+ existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
3180
+ ? !sortDescFirst : sortDescFirst)) {
3181
+ sortAction = 'remove';
3182
+ }
3225
3183
 
3226
- instance.setColumnSizing((_instance$initialStat = instance.initialState.columnSizing) != null ? _instance$initialStat : {});
3227
- },
3228
- resetHeaderSizeInfo: function resetHeaderSizeInfo() {
3229
- var _instance$initialStat2;
3184
+ if (sortAction === 'replace') {
3185
+ newSorting = [{
3186
+ id: columnId,
3187
+ desc: hasDescDefined ? desc : !!sortDescFirst
3188
+ }];
3189
+ } else if (sortAction === 'add' && old != null && old.length) {
3190
+ var _instance$options$max;
3230
3191
 
3231
- instance.setColumnSizingInfo((_instance$initialStat2 = instance.initialState.columnSizingInfo) != null ? _instance$initialStat2 : {});
3232
- },
3233
- resetColumnSize: function resetColumnSize(columnId) {
3234
- instance.setColumnSizing(function (_ref) {
3235
- _ref[columnId];
3236
- var rest = _objectWithoutPropertiesLoose(_ref, [columnId].map(_toPropertyKey));
3192
+ newSorting = [].concat(old, [{
3193
+ id: columnId,
3194
+ desc: hasDescDefined ? desc : !!sortDescFirst
3195
+ }]); // Take latest n columns
3237
3196
 
3238
- return rest;
3197
+ newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
3198
+ } else if (sortAction === 'toggle' && old != null && old.length) {
3199
+ // This flips (or sets) the
3200
+ newSorting = old.map(function (d) {
3201
+ if (d.id === columnId) {
3202
+ return _extends({}, d, {
3203
+ desc: hasDescDefined ? desc : !(existingSorting != null && existingSorting.desc)
3204
+ });
3205
+ }
3206
+
3207
+ return d;
3208
+ });
3209
+ } else if (sortAction === 'remove' && old != null && old.length) {
3210
+ newSorting = old.filter(function (d) {
3211
+ return d.id !== columnId;
3212
+ });
3213
+ }
3214
+
3215
+ return newSorting;
3239
3216
  });
3240
3217
  },
3241
- resetHeaderSize: function resetHeaderSize(headerId) {
3242
- var header = instance.getHeader(headerId);
3243
-
3244
- if (!header) {
3245
- return;
3246
- }
3218
+ getColumnCanSort: function getColumnCanSort(columnId) {
3219
+ var _ref3, _ref4, _column$enableSorting;
3247
3220
 
3248
- return instance.resetColumnSize(header.column.id);
3249
- },
3250
- getHeaderCanResize: function getHeaderCanResize(headerId) {
3251
- var header = instance.getHeader(headerId);
3221
+ var column = instance.getColumn(columnId);
3252
3222
 
3253
- if (!header) {
3223
+ if (!column) {
3254
3224
  throw new Error();
3255
3225
  }
3256
3226
 
3257
- return instance.getColumnCanResize(header.column.id);
3227
+ return (_ref3 = (_ref4 = (_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : instance.options.enableSorting) != null ? _ref4 : column.defaultCanSort) != null ? _ref3 : !!column.accessorFn // (!!column.accessorFn ||
3228
+ // column.columns?.some(c => c.id && instance.getColumnCanSort(c.id))) ??
3229
+ // false
3230
+ ;
3258
3231
  },
3259
- getColumnCanResize: function getColumnCanResize(columnId) {
3260
- var _ref2, _ref3, _column$enableResizin;
3232
+ getColumnCanMultiSort: function getColumnCanMultiSort(columnId) {
3233
+ var _ref5, _column$enableMultiSo;
3261
3234
 
3262
3235
  var column = instance.getColumn(columnId);
3263
3236
 
@@ -3265,234 +3238,309 @@
3265
3238
  throw new Error();
3266
3239
  }
3267
3240
 
3268
- return (_ref2 = (_ref3 = (_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : instance.options.enableColumnResizing) != null ? _ref3 : column.defaultCanResize) != null ? _ref2 : true;
3241
+ return (_ref5 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref5 : !!column.accessorFn;
3269
3242
  },
3270
- getColumnIsResizing: function getColumnIsResizing(columnId) {
3243
+ getColumnIsSorted: function getColumnIsSorted(columnId) {
3244
+ var _instance$getState$so;
3245
+
3246
+ var columnSort = (_instance$getState$so = instance.getState().sorting) == null ? void 0 : _instance$getState$so.find(function (d) {
3247
+ return d.id === columnId;
3248
+ });
3249
+ return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
3250
+ },
3251
+ getColumnSortIndex: function getColumnSortIndex(columnId) {
3252
+ var _instance$getState$so2, _instance$getState$so3;
3253
+
3254
+ return (_instance$getState$so2 = (_instance$getState$so3 = instance.getState().sorting) == null ? void 0 : _instance$getState$so3.findIndex(function (d) {
3255
+ return d.id === columnId;
3256
+ })) != null ? _instance$getState$so2 : -1;
3257
+ },
3258
+ resetSorting: function resetSorting() {
3259
+ var _instance$initialStat, _instance$initialStat2;
3260
+
3261
+ instance.setSorting((_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.sorting) != null ? _instance$initialStat : []);
3262
+ },
3263
+ getToggleSortingProps: function getToggleSortingProps(columnId, userProps) {
3271
3264
  var column = instance.getColumn(columnId);
3272
3265
 
3273
3266
  if (!column) {
3274
3267
  throw new Error();
3275
3268
  }
3276
3269
 
3277
- return instance.getState().columnSizingInfo.isResizingColumn === columnId;
3270
+ var canSort = column.getCanSort();
3271
+ var initialProps = {
3272
+ title: canSort ? 'Toggle Sorting' : undefined,
3273
+ onClick: canSort ? function (e) {
3274
+ e.persist();
3275
+ column.toggleSorting == null ? void 0 : column.toggleSorting(undefined, column.getCanMultiSort() ? instance.options.isMultiSortEvent == null ? void 0 : instance.options.isMultiSortEvent(e) : false);
3276
+ } : undefined
3277
+ };
3278
+ return propGetter(initialProps, userProps);
3278
3279
  },
3279
- getHeaderIsResizing: function getHeaderIsResizing(headerId) {
3280
- var header = instance.getHeader(headerId);
3280
+ getPreSortedRowModel: function getPreSortedRowModel() {
3281
+ return instance.getGlobalFilteredRowModel();
3282
+ },
3283
+ getSortedRowModel: memo(function () {
3284
+ return [instance.getState().sorting, instance.getGlobalFilteredRowModel(), instance.options.sortRowsFn];
3285
+ }, function (sorting, rowModel, sortingFn) {
3286
+ if (!sortingFn || !(sorting != null && sorting.length)) {
3287
+ return rowModel;
3288
+ }
3281
3289
 
3282
- if (!header) {
3283
- throw new Error();
3290
+ return sortingFn(instance, rowModel);
3291
+ }, {
3292
+ key: 'getSortedRowModel',
3293
+ debug: function debug() {
3294
+ var _instance$options$deb;
3295
+
3296
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3297
+ },
3298
+ onChange: function onChange() {
3299
+ instance._notifyGroupingReset();
3284
3300
  }
3301
+ })
3302
+ };
3303
+ }
3285
3304
 
3286
- return instance.getColumnIsResizing(header.column.id);
3287
- },
3288
- getColumnResizerProps: function getColumnResizerProps(headerId, userProps) {
3289
- var header = instance.getHeader(headerId);
3305
+ var Sorting = /*#__PURE__*/Object.freeze({
3306
+ __proto__: null,
3307
+ getDefaultColumn: getDefaultColumn,
3308
+ getInitialState: getInitialState$3,
3309
+ getDefaultOptions: getDefaultOptions$3,
3310
+ createColumn: createColumn,
3311
+ getInstance: getInstance$3
3312
+ });
3290
3313
 
3291
- if (!header) {
3314
+ //
3315
+ function getInitialState$2() {
3316
+ return {
3317
+ expanded: {}
3318
+ };
3319
+ }
3320
+ function getDefaultOptions$2(instance) {
3321
+ return {
3322
+ onExpandedChange: makeStateUpdater('expanded', instance),
3323
+ autoResetExpanded: true,
3324
+ getIsRowExpanded: function getIsRowExpanded(row) {
3325
+ return !!(row == null ? void 0 : row.original).expanded;
3326
+ },
3327
+ expandSubRows: true,
3328
+ paginateExpandedRows: true
3329
+ };
3330
+ }
3331
+ function getInstance$2(instance) {
3332
+ var registered = false;
3333
+ return {
3334
+ _notifyExpandedReset: function _notifyExpandedReset() {
3335
+ if (!registered) {
3336
+ registered = true;
3292
3337
  return;
3293
3338
  }
3294
3339
 
3295
- var column = instance.getColumn(header.column.id);
3296
-
3297
- if (!column) {
3340
+ if (instance.options.autoResetAll === false) {
3298
3341
  return;
3299
3342
  }
3300
3343
 
3301
- var canResize = column.getCanResize();
3344
+ if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
3345
+ instance.resetExpanded();
3346
+ }
3347
+ },
3348
+ setExpanded: function setExpanded(updater) {
3349
+ return instance.options.onExpandedChange == null ? void 0 : instance.options.onExpandedChange(updater, functionalUpdate(updater, instance.getState().expanded));
3350
+ },
3351
+ toggleRowExpanded: function toggleRowExpanded(rowId, expanded) {
3352
+ if (!rowId) return;
3353
+ instance.setExpanded(function (old) {
3354
+ var _expanded;
3302
3355
 
3303
- var onResizeStart = function onResizeStart(e) {
3304
- if (isTouchStartEvent(e)) {
3305
- // lets not respond to multiple touches (e.g. 2 or 3 fingers)
3306
- if (e.touches && e.touches.length > 1) {
3307
- return;
3308
- }
3356
+ var exists = old === true ? true : !!(old != null && old[rowId]);
3357
+ var oldExpanded = {};
3358
+
3359
+ if (old === true) {
3360
+ Object.keys(instance.getRowModel().rowsById).forEach(function (rowId) {
3361
+ oldExpanded[rowId] = true;
3362
+ });
3363
+ } else {
3364
+ oldExpanded = old;
3309
3365
  }
3310
3366
 
3311
- var columnSizingStart = header.getLeafHeaders().map(function (d) {
3312
- return [d.column.id, d.getWidth()];
3313
- });
3314
- var clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
3367
+ expanded = (_expanded = expanded) != null ? _expanded : !exists;
3315
3368
 
3316
- var updateOffset = function updateOffset(eventType, clientXPos) {
3317
- if (typeof clientXPos !== 'number') {
3318
- return;
3319
- }
3369
+ if (!exists && expanded) {
3370
+ var _extends2;
3320
3371
 
3321
- var newColumnSizing = {};
3322
- instance.setColumnSizingInfo(function (old) {
3323
- var _old$startOffset, _old$startSize;
3372
+ return _extends({}, oldExpanded, (_extends2 = {}, _extends2[rowId] = true, _extends2));
3373
+ }
3324
3374
 
3325
- var deltaOffset = clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0);
3326
- var deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
3327
- old.columnSizingStart.forEach(function (_ref4) {
3328
- var columnId = _ref4[0],
3329
- headerWidth = _ref4[1];
3330
- newColumnSizing[columnId] = Math.max(headerWidth + headerWidth * deltaPercentage, 0);
3331
- });
3332
- return _extends({}, old, {
3333
- deltaOffset: deltaOffset,
3334
- deltaPercentage: deltaPercentage
3335
- });
3336
- });
3375
+ if (exists && !expanded) {
3376
+ var _oldExpanded = oldExpanded;
3377
+ _oldExpanded[rowId];
3378
+ var rest = _objectWithoutPropertiesLoose(_oldExpanded, [rowId].map(_toPropertyKey));
3337
3379
 
3338
- if (instance.options.columnResizeMode === 'onChange' || eventType === 'end') {
3339
- instance.setColumnSizing(function (old) {
3340
- return _extends({}, old, newColumnSizing);
3341
- });
3342
- }
3343
- };
3380
+ return rest;
3381
+ }
3344
3382
 
3345
- var onMove = function onMove(clientXPos) {
3346
- return updateOffset('move', clientXPos);
3347
- };
3383
+ return old;
3384
+ });
3385
+ },
3386
+ toggleAllRowsExpanded: function toggleAllRowsExpanded(expanded) {
3387
+ if (expanded != null ? expanded : !instance.getIsAllRowsExpanded()) {
3388
+ instance.setExpanded(true);
3389
+ } else {
3390
+ instance.setExpanded({});
3391
+ }
3392
+ },
3393
+ resetExpanded: function resetExpanded() {
3394
+ var _instance$initialStat, _instance$initialStat2;
3348
3395
 
3349
- var onEnd = function onEnd(clientXPos) {
3350
- updateOffset('end', clientXPos);
3351
- instance.setColumnSizingInfo(function (old) {
3352
- return _extends({}, old, {
3353
- isResizingColumn: false,
3354
- startOffset: null,
3355
- startSize: null,
3356
- deltaOffset: null,
3357
- deltaPercentage: null,
3358
- columnSizingStart: []
3359
- });
3360
- });
3361
- };
3396
+ instance.setExpanded((_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.expanded) != null ? _instance$initialStat : {});
3397
+ },
3398
+ getIsRowExpanded: function getIsRowExpanded(rowId) {
3399
+ var _instance$options$get;
3362
3400
 
3363
- var mouseEvents = {
3364
- moveHandler: function moveHandler(e) {
3365
- return onMove(e.clientX);
3366
- },
3367
- upHandler: function upHandler(e) {
3368
- document.removeEventListener('mousemove', mouseEvents.moveHandler);
3369
- document.removeEventListener('mouseup', mouseEvents.upHandler);
3370
- onEnd(e.clientX);
3371
- }
3372
- };
3373
- var touchEvents = {
3374
- moveHandler: function moveHandler(e) {
3375
- if (e.cancelable) {
3376
- e.preventDefault();
3377
- e.stopPropagation();
3378
- }
3401
+ var row = instance.getRow(rowId);
3379
3402
 
3380
- onMove(e.touches[0].clientX);
3381
- return false;
3382
- },
3383
- upHandler: function upHandler(e) {
3384
- document.removeEventListener('touchmove', touchEvents.moveHandler);
3385
- document.removeEventListener('touchend', touchEvents.upHandler);
3403
+ if (!row) {
3404
+ {
3405
+ console.warn("[ReactTable] getIsRowExpanded: no row found with id " + rowId);
3406
+ }
3386
3407
 
3387
- if (e.cancelable) {
3388
- e.preventDefault();
3389
- e.stopPropagation();
3390
- }
3408
+ throw new Error();
3409
+ }
3391
3410
 
3392
- onEnd(e.touches[0].clientX);
3393
- }
3394
- };
3395
- var passiveIfSupported = passiveEventSupported() ? {
3396
- passive: false
3397
- } : false;
3411
+ var expanded = instance.getState().expanded;
3412
+ return !!((_instance$options$get = instance.options.getIsRowExpanded == null ? void 0 : instance.options.getIsRowExpanded(row)) != null ? _instance$options$get : expanded || (expanded == null ? void 0 : expanded[rowId]));
3413
+ },
3414
+ getRowCanExpand: function getRowCanExpand(rowId) {
3415
+ var _ref, _ref2, _instance$options$get2, _row$subRows;
3398
3416
 
3399
- if (isTouchStartEvent(e)) {
3400
- document.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
3401
- document.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
3402
- } else {
3403
- document.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
3404
- document.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
3417
+ var row = instance.getRow(rowId);
3418
+
3419
+ if (!row) {
3420
+ {
3421
+ console.warn("[ReactTable] getRowCanExpand: no row found with id " + rowId);
3405
3422
  }
3406
3423
 
3407
- instance.setColumnSizingInfo(function (old) {
3408
- return _extends({}, old, {
3409
- startOffset: clientX,
3410
- startSize: header.getWidth(),
3411
- deltaOffset: 0,
3412
- deltaPercentage: 0,
3413
- columnSizingStart: columnSizingStart,
3414
- isResizingColumn: header.column.id
3415
- });
3416
- });
3417
- };
3424
+ throw new Error();
3425
+ }
3418
3426
 
3419
- var initialProps = canResize ? {
3420
- title: 'Toggle Grouping',
3421
- draggable: false,
3422
- role: 'separator',
3423
- onMouseDown: function onMouseDown(e) {
3427
+ return (_ref = (_ref2 = (_instance$options$get2 = instance.options.getRowCanExpand == null ? void 0 : instance.options.getRowCanExpand(row)) != null ? _instance$options$get2 : instance.options.enableExpanded) != null ? _ref2 : instance.options.defaultCanExpand) != null ? _ref : !!((_row$subRows = row.subRows) != null && _row$subRows.length);
3428
+ },
3429
+ getToggleExpandedProps: function getToggleExpandedProps(rowId, userProps) {
3430
+ var row = instance.getRow(rowId);
3431
+
3432
+ if (!row) {
3433
+ return;
3434
+ }
3435
+
3436
+ var canExpand = instance.getRowCanExpand(rowId);
3437
+ var initialProps = {
3438
+ title: canExpand ? 'Toggle Expanded' : undefined,
3439
+ onClick: canExpand ? function (e) {
3424
3440
  e.persist();
3425
- onResizeStart(e);
3426
- },
3427
- onTouchStart: function onTouchStart(e) {
3441
+ instance.toggleRowExpanded(rowId);
3442
+ } : undefined
3443
+ };
3444
+ return propGetter(initialProps, userProps);
3445
+ },
3446
+ getToggleAllRowsExpandedProps: function getToggleAllRowsExpandedProps(userProps) {
3447
+ var initialProps = {
3448
+ title: 'Toggle All Expanded',
3449
+ onClick: function onClick(e) {
3428
3450
  e.persist();
3429
- onResizeStart(e);
3451
+ instance.toggleAllRowsExpanded();
3430
3452
  }
3431
- } : {};
3453
+ };
3432
3454
  return propGetter(initialProps, userProps);
3455
+ },
3456
+ getIsAllRowsExpanded: function getIsAllRowsExpanded() {
3457
+ var expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
3458
+
3459
+ if (expanded === true) {
3460
+ return true;
3461
+ } // If any row is not expanded, return false
3462
+
3463
+
3464
+ if (Object.keys(instance.getRowModel().rowsById).some(function (id) {
3465
+ return !instance.getIsRowExpanded(id);
3466
+ })) {
3467
+ return false;
3468
+ } // They must all be expanded :shrug:
3469
+
3470
+
3471
+ return true;
3472
+ },
3473
+ getExpandedDepth: function getExpandedDepth() {
3474
+ var maxDepth = 0;
3475
+ var rowIds = instance.getState().expanded === true ? Object.keys(instance.getRowModel().rowsById) : Object.keys(instance.getState().expanded);
3476
+ rowIds.forEach(function (id) {
3477
+ var splitId = id.split('.');
3478
+ maxDepth = Math.max(maxDepth, splitId.length);
3479
+ });
3480
+ return maxDepth;
3481
+ },
3482
+ getExpandedRowModel: memo(function () {
3483
+ return [instance.getState().expanded, instance.getGroupedRowModel(), instance.options.expandRowsFn, instance.options.paginateExpandedRows];
3484
+ }, function (expanded, rowModel, expandRowsFn, paginateExpandedRows) {
3485
+ if (!expandRowsFn || // Do not expand if rows are not included in pagination
3486
+ !paginateExpandedRows || !Object.keys(expanded != null ? expanded : {}).length) {
3487
+ return rowModel;
3488
+ }
3489
+
3490
+ return expandRowsFn(instance, rowModel);
3491
+ }, {
3492
+ key: 'getExpandedRowModel',
3493
+ debug: function debug() {
3494
+ var _instance$options$deb;
3495
+
3496
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3497
+ },
3498
+ onChange: function onChange() {
3499
+ instance._notifyPageIndexReset();
3500
+ }
3501
+ }),
3502
+ getPreExpandedRowModel: function getPreExpandedRowModel() {
3503
+ return instance.getGroupedRowModel();
3433
3504
  }
3434
3505
  };
3435
3506
  }
3436
- function createColumn(column, instance) {
3507
+ function createRow$1(row, instance) {
3437
3508
  return {
3438
- getIsResizing: function getIsResizing() {
3439
- return instance.getColumnIsResizing(column.id);
3509
+ toggleExpanded: function toggleExpanded(expanded) {
3510
+ return void instance.toggleRowExpanded(row.id, expanded);
3440
3511
  },
3441
- getCanResize: function getCanResize() {
3442
- return instance.getColumnCanResize(column.id);
3512
+ getIsExpanded: function getIsExpanded() {
3513
+ return instance.getIsRowExpanded(row.id);
3443
3514
  },
3444
- resetSize: function resetSize() {
3445
- return instance.resetColumnSize(column.id);
3515
+ getCanExpand: function getCanExpand() {
3516
+ return row.subRows && !!row.subRows.length;
3446
3517
  },
3447
- getResizerProps: function getResizerProps(userProps) {
3448
- return instance.getColumnResizerProps(column.id, userProps);
3518
+ getToggleExpandedProps: function getToggleExpandedProps(userProps) {
3519
+ var initialProps = {
3520
+ title: 'Toggle Row Expanded',
3521
+ onClick: function onClick(e) {
3522
+ e.stopPropagation();
3523
+ instance.toggleRowExpanded(row.id);
3524
+ }
3525
+ };
3526
+ return propGetter(initialProps, userProps);
3449
3527
  }
3450
3528
  };
3451
3529
  }
3452
- var passiveSupported = null;
3453
- function passiveEventSupported() {
3454
- if (typeof passiveSupported === 'boolean') return passiveSupported;
3455
- var supported = false;
3456
-
3457
- try {
3458
- var options = {
3459
- get passive() {
3460
- supported = true;
3461
- return false;
3462
- }
3463
-
3464
- };
3465
-
3466
- var noop = function noop() {};
3467
-
3468
- window.addEventListener('test', noop, options);
3469
- window.removeEventListener('test', noop);
3470
- } catch (err) {
3471
- supported = false;
3472
- }
3473
-
3474
- passiveSupported = supported;
3475
- return passiveSupported;
3476
- }
3477
-
3478
- function isTouchStartEvent(e) {
3479
- return e.type === 'touchstart';
3480
- }
3481
3530
 
3482
- var ColumnSizing = /*#__PURE__*/Object.freeze({
3531
+ var Expanding = /*#__PURE__*/Object.freeze({
3483
3532
  __proto__: null,
3484
- defaultColumnSizing: defaultColumnSizing,
3485
3533
  getInitialState: getInitialState$2,
3486
3534
  getDefaultOptions: getDefaultOptions$2,
3487
3535
  getInstance: getInstance$2,
3488
- createColumn: createColumn,
3489
- passiveEventSupported: passiveEventSupported
3536
+ createRow: createRow$1
3490
3537
  });
3491
3538
 
3492
3539
  //
3493
3540
  function getInitialState$1() {
3494
3541
  return {
3495
3542
  pagination: {
3543
+ pageCount: -1,
3496
3544
  pageIndex: 0,
3497
3545
  pageSize: 10
3498
3546
  }
@@ -3518,19 +3566,12 @@
3518
3566
  }
3519
3567
 
3520
3568
  if (instance.options.autoResetAll === true || instance.options.autoResetPageIndex) {
3521
- instance.resetPageSize();
3569
+ instance.resetPageIndex();
3522
3570
  }
3523
3571
  },
3524
3572
  setPagination: function setPagination(updater) {
3525
3573
  var safeUpdater = function safeUpdater(old) {
3526
3574
  var newState = functionalUpdate(updater, old);
3527
-
3528
- if (instance.options.paginateRowsFn) {
3529
- var _instance$getPrePagin;
3530
-
3531
- newState.pageCount = (_instance$getPrePagin = instance.getPrePaginationRows()) != null && _instance$getPrePagin.length ? Math.ceil(instance.getPrePaginationRows().length / instance.getState().pagination.pageSize) : 0;
3532
- }
3533
-
3534
3575
  return newState;
3535
3576
  };
3536
3577
 
@@ -3601,7 +3642,11 @@
3601
3642
  return pageOptions;
3602
3643
  }, {
3603
3644
  key: 'getPageOptions',
3604
- debug: instance.options.debug
3645
+ debug: function debug() {
3646
+ var _instance$options$deb;
3647
+
3648
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3649
+ }
3605
3650
  }),
3606
3651
  getCanPreviousPage: function getCanPreviousPage() {
3607
3652
  return instance.getState().pagination.pageIndex > 0;
@@ -3620,7 +3665,7 @@
3620
3665
  return false;
3621
3666
  }
3622
3667
 
3623
- return pageIndex < Math.ceil(instance.getPrePaginationRows().length / pageSize) - 1;
3668
+ return pageIndex < Math.ceil(instance.getPrePaginationRowModel().rows.length / pageSize) - 1;
3624
3669
  },
3625
3670
  previousPage: function previousPage() {
3626
3671
  return instance.setPageIndex(function (old) {
@@ -3632,6 +3677,9 @@
3632
3677
  return old + 1;
3633
3678
  });
3634
3679
  },
3680
+ getPrePaginationRowModel: function getPrePaginationRowModel() {
3681
+ return instance.getExpandedRowModel();
3682
+ },
3635
3683
  getPaginationRowModel: memo(function () {
3636
3684
  return [instance.getState().pagination, instance.getExpandedRowModel(), instance.options.paginateRowsFn];
3637
3685
  }, function (_pagination, rowModel, paginateRowsFn) {
@@ -3639,29 +3687,23 @@
3639
3687
  return rowModel;
3640
3688
  }
3641
3689
 
3642
- if (instance.options.debug) console.info('Paginating...');
3643
3690
  return paginateRowsFn(instance, rowModel);
3644
3691
  }, {
3645
3692
  key: 'getPaginationRowModel',
3646
- debug: instance.options.debug
3693
+ debug: function debug() {
3694
+ var _instance$options$deb2;
3695
+
3696
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugTable;
3697
+ }
3647
3698
  }),
3648
- getPrePaginationRows: function getPrePaginationRows() {
3649
- return instance.getExpandedRowModel().rows;
3650
- },
3651
- getPrePaginationFlatRows: function getPrePaginationFlatRows() {
3652
- return instance.getExpandedRowModel().flatRows;
3653
- },
3654
- getPrePaginationRowsById: function getPrePaginationRowsById() {
3655
- return instance.getExpandedRowModel().rowsById;
3656
- },
3657
- getPaginationRows: function getPaginationRows() {
3658
- return instance.getPaginationRowModel().rows;
3659
- },
3660
- getPaginationFlatRows: function getPaginationFlatRows() {
3661
- return instance.getPaginationRowModel().flatRows;
3662
- },
3663
- getPaginationRowsById: function getPaginationRowsById() {
3664
- return instance.getPaginationRowModel().rowsById;
3699
+ getPageCount: function getPageCount() {
3700
+ var pageCount = instance.getState().pagination.pageCount;
3701
+
3702
+ if (pageCount > 0) {
3703
+ return pageCount;
3704
+ }
3705
+
3706
+ return Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
3665
3707
  }
3666
3708
  };
3667
3709
  }
@@ -3723,7 +3765,7 @@
3723
3765
  // Leave all the other rows that are selected alone.
3724
3766
 
3725
3767
  var rowSelection = Object.assign({}, old);
3726
- var preGroupedFlatRows = instance.getPreGroupedFlatRows(); // We don't use `mutateRowIsSelected` here for performance reasons.
3768
+ var preGroupedFlatRows = instance.getPreGroupedRowModel().flatRows; // We don't use `mutateRowIsSelected` here for performance reasons.
3727
3769
  // All of the rows are flat already, so it wouldn't be worth it
3728
3770
 
3729
3771
  if (value) {
@@ -3745,7 +3787,7 @@
3745
3787
 
3746
3788
  var rowSelection = _extends({}, old);
3747
3789
 
3748
- instance.getRows().forEach(function (row) {
3790
+ instance.getRowModel().rows.forEach(function (row) {
3749
3791
  mutateRowIsSelected(rowSelection, row.id, value, instance);
3750
3792
  });
3751
3793
  return rowSelection;
@@ -3817,6 +3859,9 @@
3817
3859
  // })
3818
3860
  // instance.setRowSelection(selectedRowIds)
3819
3861
  // },
3862
+ getPreSelectedRowModel: function getPreSelectedRowModel() {
3863
+ return instance.getCoreRowModel();
3864
+ },
3820
3865
  getSelectedRowModel: memo(function () {
3821
3866
  return [instance.getState().rowSelection, instance.getCoreRowModel()];
3822
3867
  }, function (rowSelection, rowModel) {
@@ -3828,24 +3873,18 @@
3828
3873
  };
3829
3874
  }
3830
3875
 
3831
- if (instance.options.debug) console.info('Selecting...');
3832
3876
  return selectRowsFn(instance, rowModel);
3833
3877
  }, {
3834
3878
  key: 'getSelectedRowModel',
3835
- debug: instance.options.debug,
3879
+ debug: function debug() {
3880
+ var _instance$options$deb;
3881
+
3882
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3883
+ },
3836
3884
  onChange: function onChange() {
3837
3885
  return instance._notifyExpandedReset();
3838
3886
  }
3839
3887
  }),
3840
- getSelectedRows: function getSelectedRows() {
3841
- return instance.getSelectedRowModel().rows;
3842
- },
3843
- getSelectedFlatRows: function getSelectedFlatRows() {
3844
- return instance.getSelectedRowModel().flatRows;
3845
- },
3846
- getSelectedRowsById: function getSelectedRowsById() {
3847
- return instance.getSelectedRowModel().rowsById;
3848
- },
3849
3888
  getFilteredSelectedRowModel: memo(function () {
3850
3889
  return [instance.getState().rowSelection, instance.getGlobalFilteredRowModel()];
3851
3890
  }, function (rowSelection, rowModel) {
@@ -3857,24 +3896,18 @@
3857
3896
  };
3858
3897
  }
3859
3898
 
3860
- if (instance.options.debug) console.info('Selecting...');
3861
3899
  return selectRowsFn(instance, rowModel);
3862
3900
  }, {
3863
3901
  key: 'getFilteredSelectedRowModel',
3864
- debug: instance.options.debug,
3902
+ debug: function debug() {
3903
+ var _instance$options$deb2;
3904
+
3905
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugTable;
3906
+ },
3865
3907
  onChange: function onChange() {
3866
3908
  return instance._notifyExpandedReset();
3867
3909
  }
3868
3910
  }),
3869
- getFilteredSelectedRows: function getFilteredSelectedRows() {
3870
- return instance.getFilteredSelectedRowModel().rows;
3871
- },
3872
- getFilteredSelectedFlatRows: function getFilteredSelectedFlatRows() {
3873
- return instance.getFilteredSelectedRowModel().flatRows;
3874
- },
3875
- getFilteredSelectedRowsById: function getFilteredSelectedRowsById() {
3876
- return instance.getFilteredSelectedRowModel().rowsById;
3877
- },
3878
3911
  getGroupedSelectedRowModel: memo(function () {
3879
3912
  return [instance.getState().rowSelection, instance.getGroupedRowModel()];
3880
3913
  }, function (rowSelection, rowModel) {
@@ -3886,24 +3919,18 @@
3886
3919
  };
3887
3920
  }
3888
3921
 
3889
- if (instance.options.debug) console.info('Selecting...');
3890
3922
  return selectRowsFn(instance, rowModel);
3891
3923
  }, {
3892
3924
  key: 'getGroupedSelectedRowModel',
3893
- debug: instance.options.debug,
3925
+ debug: function debug() {
3926
+ var _instance$options$deb3;
3927
+
3928
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugTable;
3929
+ },
3894
3930
  onChange: function onChange() {
3895
3931
  return instance._notifyExpandedReset();
3896
3932
  }
3897
3933
  }),
3898
- getGroupedSelectedRows: function getGroupedSelectedRows() {
3899
- return instance.getGroupedSelectedRowModel().rows;
3900
- },
3901
- getGroupedSelectedFlatRows: function getGroupedSelectedFlatRows() {
3902
- return instance.getGroupedSelectedRowModel().flatRows;
3903
- },
3904
- getGroupedSelectedRowsById: function getGroupedSelectedRowsById() {
3905
- return instance.getGroupedSelectedRowModel().rowsById;
3906
- },
3907
3934
  ///
3908
3935
  getRowIsSelected: function getRowIsSelected(rowId) {
3909
3936
  var _instance$getState = instance.getState(),
@@ -3985,7 +4012,7 @@
3985
4012
  // return instance.options.enableGroupingRowSelection ?? false
3986
4013
  // },
3987
4014
  getIsAllRowsSelected: function getIsAllRowsSelected() {
3988
- var preFilteredFlatRows = instance.getPreGlobalFilteredFlatRows();
4015
+ var preFilteredFlatRows = instance.getPreGlobalFilteredRowModel().flatRows;
3989
4016
 
3990
4017
  var _instance$getState3 = instance.getState(),
3991
4018
  rowSelection = _instance$getState3.rowSelection;
@@ -4003,7 +4030,7 @@
4003
4030
  return isAllRowsSelected;
4004
4031
  },
4005
4032
  getIsAllPageRowsSelected: function getIsAllPageRowsSelected() {
4006
- var paginationFlatRows = instance.getPaginationFlatRows();
4033
+ var paginationFlatRows = instance.getPaginationRowModel().flatRows;
4007
4034
 
4008
4035
  var _instance$getState4 = instance.getState(),
4009
4036
  rowSelection = _instance$getState4.rowSelection;
@@ -4024,7 +4051,7 @@
4024
4051
  return !instance.getIsAllRowsSelected() && !!Object.keys((_instance$getState$ro = instance.getState().rowSelection) != null ? _instance$getState$ro : {}).length;
4025
4052
  },
4026
4053
  getIsSomePageRowsSelected: function getIsSomePageRowsSelected() {
4027
- var paginationFlatRows = instance.getPaginationFlatRows();
4054
+ var paginationFlatRows = instance.getPaginationRowModel().flatRows;
4028
4055
  return instance.getIsAllPageRowsSelected() ? false : !!(paginationFlatRows != null && paginationFlatRows.length);
4029
4056
  },
4030
4057
  getToggleRowSelectedProps: function getToggleRowSelectedProps(rowId, userProps) {
@@ -4201,10 +4228,10 @@
4201
4228
  });
4202
4229
 
4203
4230
  var features = [Visibility, Ordering, Pinning, Headers, Filters, Sorting, Grouping, Expanding, ColumnSizing, Pagination, RowSelection];
4204
- function createTableInstance(options, rerender) {
4231
+ function createTableInstance(options) {
4205
4232
  var _options$initialState;
4206
4233
 
4207
- if (options.debug) {
4234
+ if (options.debugAll || options.debugTable) {
4208
4235
  console.info('Creating React Table Instance...');
4209
4236
  }
4210
4237
 
@@ -4212,12 +4239,9 @@
4212
4239
  var defaultOptions = features.reduce(function (obj, feature) {
4213
4240
  return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(instance));
4214
4241
  }, {});
4215
- var defaultState = {};
4216
4242
 
4217
4243
  var buildOptions = function buildOptions(options) {
4218
- return _extends({
4219
- state: defaultState
4220
- }, defaultOptions, options);
4244
+ return _extends({}, defaultOptions, options);
4221
4245
  };
4222
4246
 
4223
4247
  instance.options = buildOptions(options);
@@ -4229,41 +4253,21 @@
4229
4253
  var finalInstance = _extends({}, instance, features.reduce(function (obj, feature) {
4230
4254
  return Object.assign(obj, feature.getInstance == null ? void 0 : feature.getInstance(instance));
4231
4255
  }, {}), {
4232
- rerender: rerender,
4233
4256
  initialState: initialState,
4234
- internalState: initialState,
4235
4257
  reset: function reset() {
4236
4258
  instance.setState(instance.initialState);
4237
4259
  },
4238
- updateOptions: function updateOptions(newOptions) {
4239
- instance.options = buildOptions(newOptions);
4260
+ setOptions: function setOptions(updater) {
4261
+ instance.options = buildOptions(functionalUpdate(updater, instance.options));
4240
4262
  },
4241
4263
  getRowId: function getRowId(_, index, parent) {
4242
4264
  return "" + (parent ? [parent.id, index].join('.') : index);
4243
4265
  },
4244
4266
  getState: function getState() {
4245
- var state = _extends({}, instance.internalState, instance.options.state);
4246
-
4247
- return state;
4267
+ return instance.options.state;
4248
4268
  },
4249
- setState: function setState(updater, shouldRerender) {
4250
- if (shouldRerender === void 0) {
4251
- shouldRerender = true;
4252
- }
4253
-
4254
- var onStateChange = instance.options.onStateChange;
4255
- var internalState = instance.internalState;
4256
- var newState = functionalUpdate(updater, internalState);
4257
- instance.internalState = newState;
4258
-
4259
- if (onStateChange) {
4260
- onStateChange(newState);
4261
- return;
4262
- }
4263
-
4264
- if (shouldRerender) {
4265
- instance.rerender();
4266
- }
4269
+ setState: function setState(updater) {
4270
+ instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
4267
4271
  },
4268
4272
  getDefaultColumn: memo(function () {
4269
4273
  return [instance.options.defaultColumn];
@@ -4287,7 +4291,11 @@
4287
4291
  return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
4288
4292
  }, {}), defaultColumn);
4289
4293
  }, {
4290
- debug: instance.options.debug,
4294
+ debug: function debug() {
4295
+ var _instance$options$deb;
4296
+
4297
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
4298
+ },
4291
4299
  key: 'getDefaultColumn'
4292
4300
  }),
4293
4301
  getColumnDefs: function getColumnDefs() {
@@ -4334,7 +4342,11 @@
4334
4342
  }));
4335
4343
  }, {
4336
4344
  key: 'column.getFlatColumns',
4337
- debug: instance.options.debug
4345
+ debug: function debug() {
4346
+ var _instance$options$deb2;
4347
+
4348
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
4349
+ }
4338
4350
  }),
4339
4351
  getLeafColumns: memo(function () {
4340
4352
  return [instance.getOrderColumnsFn()];
@@ -4351,7 +4363,11 @@
4351
4363
  return [column];
4352
4364
  }, {
4353
4365
  key: 'column.getLeafColumns',
4354
- debug: instance.options.debug
4366
+ debug: function debug() {
4367
+ var _instance$options$deb3;
4368
+
4369
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
4370
+ }
4355
4371
  })
4356
4372
  });
4357
4373
 
@@ -4364,8 +4380,6 @@
4364
4380
  getAllColumns: memo(function () {
4365
4381
  return [instance.getColumnDefs()];
4366
4382
  }, function (columnDefs) {
4367
- if (instance.options.debug) console.info('Building Columns...');
4368
-
4369
4383
  var recurseColumns = function recurseColumns(columnDefs, parent, depth) {
4370
4384
  if (depth === void 0) {
4371
4385
  depth = 0;
@@ -4381,7 +4395,11 @@
4381
4395
  return recurseColumns(columnDefs);
4382
4396
  }, {
4383
4397
  key: 'getAllColumns',
4384
- debug: instance.options.debug
4398
+ debug: function debug() {
4399
+ var _instance$options$deb4;
4400
+
4401
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
4402
+ }
4385
4403
  }),
4386
4404
  getAllFlatColumns: memo(function () {
4387
4405
  return [instance.getAllColumns()];
@@ -4391,7 +4409,11 @@
4391
4409
  });
4392
4410
  }, {
4393
4411
  key: 'getAllFlatColumns',
4394
- debug: instance.options.debug
4412
+ debug: function debug() {
4413
+ var _instance$options$deb5;
4414
+
4415
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
4416
+ }
4395
4417
  }),
4396
4418
  getAllFlatColumnsById: memo(function () {
4397
4419
  return [instance.getAllFlatColumns()];
@@ -4402,7 +4424,11 @@
4402
4424
  }, {});
4403
4425
  }, {
4404
4426
  key: 'getAllFlatColumnsById',
4405
- debug: instance.options.debug
4427
+ debug: function debug() {
4428
+ var _instance$options$deb6;
4429
+
4430
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns;
4431
+ }
4406
4432
  }),
4407
4433
  getAllLeafColumns: memo(function () {
4408
4434
  return [instance.getAllColumns(), instance.getOrderColumnsFn()];
@@ -4413,7 +4439,11 @@
4413
4439
  return orderColumns(leafColumns);
4414
4440
  }, {
4415
4441
  key: 'getAllLeafColumns',
4416
- debug: instance.options.debug
4442
+ debug: function debug() {
4443
+ var _instance$options$deb7;
4444
+
4445
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns;
4446
+ }
4417
4447
  }),
4418
4448
  getColumn: function getColumn(columnId) {
4419
4449
  var column = instance.getAllFlatColumnsById()[columnId];
@@ -4489,7 +4519,11 @@
4489
4519
  });
4490
4520
  }, {
4491
4521
  key: 'row.getAllCells' ,
4492
- debug: instance.options.debug
4522
+ debug: function debug() {
4523
+ var _instance$options$deb8;
4524
+
4525
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugRows;
4526
+ }
4493
4527
  });
4494
4528
  row.getAllCellsByColumnId = memo(function () {
4495
4529
  return [row.getAllCells()];
@@ -4500,18 +4534,24 @@
4500
4534
  }, {});
4501
4535
  }, {
4502
4536
  key: 'row.getAllCellsByColumnId',
4503
- debug: instance.options.debug
4537
+ debug: function debug() {
4538
+ var _instance$options$deb9;
4539
+
4540
+ return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugRows;
4541
+ }
4504
4542
  });
4505
- features.forEach(function (feature) {
4543
+
4544
+ for (var i = 0; i < features.length; i++) {
4545
+ var feature = features[i];
4506
4546
  Object.assign(row, feature.createRow == null ? void 0 : feature.createRow(row, instance));
4507
- });
4547
+ }
4548
+
4508
4549
  return row;
4509
4550
  },
4510
4551
  getCoreRowModel: memo(function () {
4511
4552
  return [instance.options.data];
4512
4553
  }, function (data) {
4513
- if (instance.options.debug) console.info('Accessing...'); // Access the row model using initial columns
4514
-
4554
+ // Access the row model using initial columns
4515
4555
  var rows = [];
4516
4556
  var flatRows = [];
4517
4557
  var rowsById = {};
@@ -4580,39 +4620,24 @@
4580
4620
  };
4581
4621
  }, {
4582
4622
  key: 'getRowModel',
4583
- debug: instance.options.debug,
4623
+ debug: function debug() {
4624
+ var _instance$options$deb10;
4625
+
4626
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugTable;
4627
+ },
4584
4628
  onChange: function onChange() {
4585
4629
  instance._notifyRowSelectionReset();
4586
4630
 
4587
4631
  instance._notifyFiltersReset();
4588
4632
  }
4589
4633
  }),
4590
- // The standard
4591
- getCoreRows: function getCoreRows() {
4592
- return instance.getCoreRowModel().rows;
4593
- },
4594
- getCoreFlatRows: function getCoreFlatRows() {
4595
- return instance.getCoreRowModel().flatRows;
4596
- },
4597
- getCoreRowsById: function getCoreRowsById() {
4598
- return instance.getCoreRowModel().rowsById;
4599
- },
4600
4634
  // The final calls start at the bottom of the model,
4601
4635
  // expanded rows, which then work their way up
4602
4636
  getRowModel: function getRowModel() {
4603
4637
  return instance.getPaginationRowModel();
4604
4638
  },
4605
- getRows: function getRows() {
4606
- return instance.getRowModel().rows;
4607
- },
4608
- getFlatRows: function getFlatRows() {
4609
- return instance.getRowModel().flatRows;
4610
- },
4611
- getRowsById: function getRowsById() {
4612
- return instance.getRowModel().rowsById;
4613
- },
4614
4639
  getRow: function getRow(id) {
4615
- var row = instance.getRowsById()[id];
4640
+ var row = instance.getRowModel().rowsById[id];
4616
4641
 
4617
4642
  if (!row) {
4618
4643
  {
@@ -4705,41 +4730,29 @@
4705
4730
  }
4706
4731
  });
4707
4732
 
4708
- instance = Object.assign(instance, finalInstance); // This won't trigger a rerender yet, but it will force
4709
- // pagination derivation to run (particularly pageSize detection)
4710
-
4711
- instance.setPagination(function (d) {
4712
- return d;
4713
- });
4733
+ instance = Object.assign(instance, finalInstance);
4714
4734
  return instance;
4715
4735
  }
4716
4736
 
4737
+ function createTableFactory(opts) {
4738
+ return function () {
4739
+ return _createTable(undefined, undefined, opts);
4740
+ };
4741
+ }
4717
4742
  function createTable() {
4743
+ return _createTable();
4744
+ }
4745
+
4746
+ function _createTable(_, __, opts) {
4718
4747
  return {
4719
- RowType: function RowType() {
4720
- return createTable();
4721
- },
4722
- FilterFns: function FilterFns() {
4723
- return createTable();
4724
- },
4725
- SortingFns: function SortingFns() {
4726
- return createTable();
4727
- },
4728
- AggregationFns: function AggregationFns() {
4729
- return createTable();
4730
- },
4731
4748
  createColumns: function createColumns(columns) {
4732
4749
  return columns;
4733
4750
  },
4734
4751
  createDisplayColumn: function createDisplayColumn(column) {
4735
- return _extends({}, column, {
4736
- __generated: true
4737
- });
4752
+ return column;
4738
4753
  },
4739
4754
  createGroup: function createGroup(column) {
4740
- return _extends({}, column, {
4741
- __generated: true
4742
- });
4755
+ return column;
4743
4756
  },
4744
4757
  createDataColumn: function createDataColumn(accessor, column) {
4745
4758
  column = _extends({}, column, {
@@ -4751,43 +4764,73 @@
4751
4764
 
4752
4765
  return _extends({}, column, {
4753
4766
  id: (_column$id = column.id) != null ? _column$id : accessor,
4754
- accessorKey: accessor,
4755
- __generated: true
4767
+ accessorKey: accessor
4756
4768
  });
4757
4769
  }
4758
4770
 
4759
4771
  if (typeof accessor === 'function') {
4760
4772
  return _extends({}, column, {
4761
- accessorFn: accessor,
4762
- __generated: true
4773
+ accessorFn: accessor
4763
4774
  });
4764
4775
  }
4765
4776
 
4766
4777
  throw new Error('Invalid accessor');
4767
4778
  },
4768
4779
  useTable: function useTable(options) {
4769
- var instanceRef = React__namespace.useRef(undefined);
4770
- var rerender = React__namespace.useReducer(function () {
4771
- return {};
4772
- }, {})[1];
4773
-
4774
- if (!instanceRef.current) {
4775
- instanceRef.current = createTableInstance(options, rerender);
4776
- }
4777
-
4778
- instanceRef.current.updateOptions(options);
4779
- return instanceRef.current;
4780
- },
4781
- types: undefined
4780
+ // Compose in the generic options to the user options
4781
+ var resolvedOptions = _extends({}, opts != null ? opts : {}, {
4782
+ state: {},
4783
+ // Dummy state
4784
+ onStateChange: function onStateChange() {}
4785
+ }, options); // Create a new table instance and store it in state
4786
+
4787
+
4788
+ var _React$useState = React__namespace.useState(function () {
4789
+ return createTableInstance(resolvedOptions);
4790
+ }),
4791
+ instance = _React$useState[0]; // By default, manage table state here using the instance's initial state
4792
+
4793
+
4794
+ var _React$useState2 = React__namespace.useState(function () {
4795
+ return instance.initialState;
4796
+ }),
4797
+ state = _React$useState2[0],
4798
+ setState = _React$useState2[1]; // Compose the default state above with any user state. This will allow the user
4799
+ // to only control a subset of the state if desired.
4800
+
4801
+
4802
+ instance.setOptions(function (prev) {
4803
+ return _extends({}, prev, options, {
4804
+ state: _extends({}, state, options.state),
4805
+ // Similarly, we'll maintain both our internal state and any user-provided
4806
+ // state.
4807
+ onStateChange: function onStateChange(updater) {
4808
+ setState(updater);
4809
+ options.onStateChange == null ? void 0 : options.onStateChange(updater);
4810
+ }
4811
+ });
4812
+ });
4813
+ return instance;
4814
+ }
4782
4815
  };
4783
4816
  }
4784
4817
 
4818
+ exports.Please_use_the_create_table_column_utilities_to_define_columns = Please_use_the_create_table_column_utilities_to_define_columns;
4785
4819
  exports.columnFilterRowsFn = columnFilterRowsFn;
4786
4820
  exports.createTable = createTable;
4821
+ exports.createTableFactory = createTableFactory;
4787
4822
  exports.expandRowsFn = expandRowsFn;
4823
+ exports.flattenBy = flattenBy;
4824
+ exports.flexRender = flexRender;
4825
+ exports.functionalUpdate = functionalUpdate;
4788
4826
  exports.globalFilterRowsFn = globalFilterRowsFn;
4789
4827
  exports.groupRowsFn = groupRowsFn;
4828
+ exports.isFunction = isFunction;
4829
+ exports.makeStateUpdater = makeStateUpdater;
4830
+ exports.memo = memo;
4831
+ exports.noop = noop;
4790
4832
  exports.paginateRowsFn = paginateRowsFn;
4833
+ exports.propGetter = propGetter;
4791
4834
  exports.sortRowsFn = sortRowsFn;
4792
4835
 
4793
4836
  Object.defineProperty(exports, '__esModule', { value: true });