@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
@@ -11,6 +11,239 @@
11
11
  import * as React from 'react';
12
12
  import React__default from 'react';
13
13
 
14
+ // declare global {
15
+ // const process.env.NODE_ENV !== 'production': boolean
16
+ // }
17
+ //
18
+ var Please_use_the_create_table_column_utilities_to_define_columns = Symbol();
19
+
20
+ function _extends() {
21
+ _extends = Object.assign || function (target) {
22
+ for (var i = 1; i < arguments.length; i++) {
23
+ var source = arguments[i];
24
+
25
+ for (var key in source) {
26
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
27
+ target[key] = source[key];
28
+ }
29
+ }
30
+ }
31
+
32
+ return target;
33
+ };
34
+
35
+ return _extends.apply(this, arguments);
36
+ }
37
+
38
+ function _objectWithoutPropertiesLoose(source, excluded) {
39
+ if (source == null) return {};
40
+ var target = {};
41
+ var sourceKeys = Object.keys(source);
42
+ var key, i;
43
+
44
+ for (i = 0; i < sourceKeys.length; i++) {
45
+ key = sourceKeys[i];
46
+ if (excluded.indexOf(key) >= 0) continue;
47
+ target[key] = source[key];
48
+ }
49
+
50
+ return target;
51
+ }
52
+
53
+ function _unsupportedIterableToArray(o, minLen) {
54
+ if (!o) return;
55
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
56
+ var n = Object.prototype.toString.call(o).slice(8, -1);
57
+ if (n === "Object" && o.constructor) n = o.constructor.name;
58
+ if (n === "Map" || n === "Set") return Array.from(o);
59
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
60
+ }
61
+
62
+ function _arrayLikeToArray(arr, len) {
63
+ if (len == null || len > arr.length) len = arr.length;
64
+
65
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
66
+
67
+ return arr2;
68
+ }
69
+
70
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
71
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
72
+ if (it) return (it = it.call(o)).next.bind(it);
73
+
74
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
75
+ if (it) o = it;
76
+ var i = 0;
77
+ return function () {
78
+ if (i >= o.length) return {
79
+ done: true
80
+ };
81
+ return {
82
+ done: false,
83
+ value: o[i++]
84
+ };
85
+ };
86
+ }
87
+
88
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
89
+ }
90
+
91
+ function _toPrimitive(input, hint) {
92
+ if (typeof input !== "object" || input === null) return input;
93
+ var prim = input[Symbol.toPrimitive];
94
+
95
+ if (prim !== undefined) {
96
+ var res = prim.call(input, hint || "default");
97
+ if (typeof res !== "object") return res;
98
+ throw new TypeError("@@toPrimitive must return a primitive value.");
99
+ }
100
+
101
+ return (hint === "string" ? String : Number)(input);
102
+ }
103
+
104
+ function _toPropertyKey(arg) {
105
+ var key = _toPrimitive(arg, "string");
106
+
107
+ return typeof key === "symbol" ? key : String(key);
108
+ }
109
+
110
+ function functionalUpdate(updater, input) {
111
+ return typeof updater === 'function' ? updater(input) : updater;
112
+ }
113
+ function noop() {//
114
+ }
115
+ function makeStateUpdater(key, instance) {
116
+ return function (updater) {
117
+ instance.setState(function (old) {
118
+ var _extends2;
119
+
120
+ return _extends({}, old, (_extends2 = {}, _extends2[key] = functionalUpdate(updater, old[key]), _extends2));
121
+ });
122
+ };
123
+ }
124
+ function isFunction(d) {
125
+ return d instanceof Function;
126
+ }
127
+ function flattenBy(arr, getChildren) {
128
+ var flat = [];
129
+
130
+ var recurse = function recurse(subArr) {
131
+ subArr.forEach(function (item) {
132
+ flat.push(item);
133
+ var children = getChildren(item);
134
+
135
+ if (children != null && children.length) {
136
+ recurse(children);
137
+ }
138
+ });
139
+ };
140
+
141
+ recurse(arr);
142
+ return flat;
143
+ }
144
+ // @ts-ignore // Just rely on the type, not the implementation
145
+ var propGetter = function propGetter(initial, getter) {
146
+ if (isFunction(getter)) {
147
+ return getter(initial);
148
+ }
149
+
150
+ return _extends({}, initial, getter != null ? getter : {});
151
+ };
152
+ function memo(getDeps, fn, opts) {
153
+ var deps = [];
154
+ var result;
155
+ return function () {
156
+ var depTime;
157
+ if (opts.key && opts.debug) depTime = performance.now();
158
+ var newDeps = getDeps();
159
+ var depsChanged = newDeps.length !== deps.length || newDeps.some(function (dep, index) {
160
+ return deps[index] !== dep;
161
+ });
162
+
163
+ if (depsChanged) {
164
+ var oldResult = result;
165
+ var resultTime;
166
+ if (opts.key && opts.debug) resultTime = performance.now();
167
+ result = fn.apply(void 0, newDeps);
168
+ deps = newDeps;
169
+ opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result, oldResult);
170
+
171
+ if (opts.key && opts.debug) {
172
+ if (opts != null && opts.debug()) {
173
+ var depEndTime = Math.round((performance.now() - depTime) * 100) / 100;
174
+ var resultEndTime = Math.round((performance.now() - resultTime) * 100) / 100;
175
+ var resultFpsPercentage = resultEndTime / 16;
176
+
177
+ var pad = function pad(str, num) {
178
+ str = String(str);
179
+
180
+ while (str.length < num) {
181
+ str = ' ' + str;
182
+ }
183
+
184
+ return str;
185
+ };
186
+
187
+ 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({
188
+ length: deps.length + " -> " + newDeps.length
189
+ }, newDeps.map(function (_, index) {
190
+ if (deps[index] !== newDeps[index]) {
191
+ return [index, deps[index], newDeps[index]];
192
+ }
193
+
194
+ return false;
195
+ }).filter(Boolean).reduce(function (accu, _ref) {
196
+ var _extends3;
197
+
198
+ var a = _ref[0],
199
+ b = _ref[1];
200
+ return _extends({}, accu, (_extends3 = {}, _extends3[a] = b, _extends3));
201
+ }, {}), {
202
+ parent: parent
203
+ }));
204
+ }
205
+ }
206
+
207
+ oldResult = undefined;
208
+ }
209
+
210
+ return result;
211
+ };
212
+ }
213
+ function flexRender(Comp, props) {
214
+ return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__default.createElement(Comp, props) : Comp;
215
+ }
216
+
217
+ function isReactComponent(component) {
218
+ return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
219
+ }
220
+
221
+ function isClassComponent(component) {
222
+ return typeof component === 'function' && function () {
223
+ var proto = Object.getPrototypeOf(component);
224
+ return proto.prototype && proto.prototype.isReactComponent;
225
+ }();
226
+ }
227
+
228
+ function isExoticComponent(component) {
229
+ return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
230
+ } // export function hashString(str: string, seed = 0): string {
231
+ // let h1 = 0xdeadbeef ^ seed,
232
+ // h2 = 0x41c6ce57 ^ seed
233
+ // for (let i = 0, ch; i < str.length; i++) {
234
+ // ch = str.charCodeAt(i)
235
+ // h1 = Math.imul(h1 ^ ch, 2654435761)
236
+ // h2 = Math.imul(h2 ^ ch, 1597334677)
237
+ // }
238
+ // h1 =
239
+ // Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^
240
+ // Math.imul(h2 ^ (h2 >>> 13), 3266489909)
241
+ // h2 =
242
+ // Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^
243
+ // Math.imul(h1 ^ (h1 >>> 13), 3266489909)
244
+ // return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString()
245
+ // }
246
+
14
247
  function columnFilterRowsFn(instance, rowModel) {
15
248
  var columnFilters = instance.getState().columnFilters;
16
249
  var newFilteredFlatRows = [];
@@ -289,236 +522,34 @@ function sortRowsFn(instance, rowModel) {
289
522
  };
290
523
  }
291
524
 
292
- function _extends() {
293
- _extends = Object.assign || function (target) {
294
- for (var i = 1; i < arguments.length; i++) {
295
- var source = arguments[i];
525
+ function groupRowsFn(instance, sortedRowModel) {
526
+ var groupingState = instance.getState().grouping; // Filter the grouping list down to columns that exist
296
527
 
297
- for (var key in source) {
298
- if (Object.prototype.hasOwnProperty.call(source, key)) {
299
- target[key] = source[key];
300
- }
301
- }
302
- }
528
+ var existingGrouping = groupingState.filter(function (columnId) {
529
+ return instance.getColumn(columnId);
530
+ }); // Find the columns that can or are aggregating
531
+ // Uses each column to aggregate rows into a single value
303
532
 
304
- return target;
305
- };
533
+ var aggregateRowsToValues = function aggregateRowsToValues(leafRows, groupedRows, depth) {
534
+ var values = {};
535
+ instance.getAllLeafColumns().forEach(function (column) {
536
+ // Don't aggregate columns that are in the grouping
537
+ if (existingGrouping.includes(column.id)) {
538
+ values[column.id] = groupedRows[0] ? groupedRows[0].values[column.id] : null;
539
+ return;
540
+ } // Aggregate the values
306
541
 
307
- return _extends.apply(this, arguments);
308
- }
309
542
 
310
- function _objectWithoutPropertiesLoose(source, excluded) {
311
- if (source == null) return {};
312
- var target = {};
313
- var sourceKeys = Object.keys(source);
314
- var key, i;
543
+ var aggregateFn = instance.getColumnAggregationFn(column.id);
315
544
 
316
- for (i = 0; i < sourceKeys.length; i++) {
317
- key = sourceKeys[i];
318
- if (excluded.indexOf(key) >= 0) continue;
319
- target[key] = source[key];
320
- }
545
+ if (aggregateFn) {
546
+ // Get the columnValues to aggregate
547
+ var groupedValues = groupedRows.map(function (row) {
548
+ return row.values[column.id];
549
+ }); // Get the columnValues to aggregate
321
550
 
322
- return target;
323
- }
324
-
325
- function _unsupportedIterableToArray(o, minLen) {
326
- if (!o) return;
327
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
328
- var n = Object.prototype.toString.call(o).slice(8, -1);
329
- if (n === "Object" && o.constructor) n = o.constructor.name;
330
- if (n === "Map" || n === "Set") return Array.from(o);
331
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
332
- }
333
-
334
- function _arrayLikeToArray(arr, len) {
335
- if (len == null || len > arr.length) len = arr.length;
336
-
337
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
338
-
339
- return arr2;
340
- }
341
-
342
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
343
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
344
- if (it) return (it = it.call(o)).next.bind(it);
345
-
346
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
347
- if (it) o = it;
348
- var i = 0;
349
- return function () {
350
- if (i >= o.length) return {
351
- done: true
352
- };
353
- return {
354
- done: false,
355
- value: o[i++]
356
- };
357
- };
358
- }
359
-
360
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
361
- }
362
-
363
- function _toPrimitive(input, hint) {
364
- if (typeof input !== "object" || input === null) return input;
365
- var prim = input[Symbol.toPrimitive];
366
-
367
- if (prim !== undefined) {
368
- var res = prim.call(input, hint || "default");
369
- if (typeof res !== "object") return res;
370
- throw new TypeError("@@toPrimitive must return a primitive value.");
371
- }
372
-
373
- return (hint === "string" ? String : Number)(input);
374
- }
375
-
376
- function _toPropertyKey(arg) {
377
- var key = _toPrimitive(arg, "string");
378
-
379
- return typeof key === "symbol" ? key : String(key);
380
- }
381
-
382
- function functionalUpdate(updater, input) {
383
- return typeof updater === 'function' ? updater(input) : updater;
384
- }
385
- function makeStateUpdater(key, instance) {
386
- return function (updater) {
387
- instance.setState(function (old) {
388
- var _extends2;
389
-
390
- return _extends({}, old, (_extends2 = {}, _extends2[key] = functionalUpdate(updater, old[key]), _extends2));
391
- });
392
- };
393
- }
394
- function isFunction(d) {
395
- return d instanceof Function;
396
- }
397
- function flattenBy(arr, getChildren) {
398
- var flat = [];
399
-
400
- var recurse = function recurse(subArr) {
401
- subArr.forEach(function (item) {
402
- flat.push(item);
403
- var children = getChildren(item);
404
-
405
- if (children != null && children.length) {
406
- recurse(children);
407
- }
408
- });
409
- };
410
-
411
- recurse(arr);
412
- return flat;
413
- }
414
- // @ts-ignore // Just rely on the type, not the implementation
415
- var propGetter = function propGetter(initial, getter) {
416
- if (isFunction(getter)) {
417
- return getter(initial);
418
- }
419
-
420
- return _extends({}, initial, getter != null ? getter : {});
421
- };
422
- function memo(getDeps, fn, opts) {
423
- var deps = [];
424
- var result;
425
- return function () {
426
- var newDeps = getDeps();
427
- var depsChanged = newDeps.length !== deps.length || newDeps.some(function (dep, index) {
428
- return deps[index] !== dep;
429
- });
430
-
431
- if (depsChanged) {
432
- if (opts != null && opts.debug) {
433
- console.info(opts == null ? void 0 : opts.key, _extends({
434
- length: deps.length + " -> " + newDeps.length
435
- }, newDeps.map(function (_, index) {
436
- if (deps[index] !== newDeps[index]) {
437
- return [index, deps[index], newDeps[index]];
438
- }
439
-
440
- return false;
441
- }).filter(Boolean).reduce(function (accu, curr) {
442
- var _extends3;
443
-
444
- return _extends({}, accu, (_extends3 = {}, _extends3[curr[0]] = curr.slice(1), _extends3));
445
- }, {}), {
446
- parent: parent
447
- }));
448
- }
449
-
450
- var oldResult = result;
451
- result = fn.apply(void 0, newDeps);
452
- deps = newDeps;
453
- opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result, oldResult);
454
- oldResult = undefined;
455
- }
456
-
457
- return result;
458
- };
459
- }
460
- function flexRender(Comp, props) {
461
- return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__default.createElement(Comp, props) : Comp;
462
- }
463
-
464
- function isReactComponent(component) {
465
- return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
466
- }
467
-
468
- function isClassComponent(component) {
469
- return typeof component === 'function' && function () {
470
- var proto = Object.getPrototypeOf(component);
471
- return proto.prototype && proto.prototype.isReactComponent;
472
- }();
473
- }
474
-
475
- function isExoticComponent(component) {
476
- return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
477
- } // export function hashString(str: string, seed = 0): string {
478
- // let h1 = 0xdeadbeef ^ seed,
479
- // h2 = 0x41c6ce57 ^ seed
480
- // for (let i = 0, ch; i < str.length; i++) {
481
- // ch = str.charCodeAt(i)
482
- // h1 = Math.imul(h1 ^ ch, 2654435761)
483
- // h2 = Math.imul(h2 ^ ch, 1597334677)
484
- // }
485
- // h1 =
486
- // Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^
487
- // Math.imul(h2 ^ (h2 >>> 13), 3266489909)
488
- // h2 =
489
- // Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^
490
- // Math.imul(h1 ^ (h1 >>> 13), 3266489909)
491
- // return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString()
492
- // }
493
-
494
- function groupRowsFn(instance, sortedRowModel) {
495
- var groupingState = instance.getState().grouping; // Filter the grouping list down to columns that exist
496
-
497
- var existingGrouping = groupingState.filter(function (columnId) {
498
- return instance.getColumn(columnId);
499
- }); // Find the columns that can or are aggregating
500
- // Uses each column to aggregate rows into a single value
501
-
502
- var aggregateRowsToValues = function aggregateRowsToValues(leafRows, groupedRows, depth) {
503
- var values = {};
504
- instance.getAllLeafColumns().forEach(function (column) {
505
- // Don't aggregate columns that are in the grouping
506
- if (existingGrouping.includes(column.id)) {
507
- values[column.id] = groupedRows[0] ? groupedRows[0].values[column.id] : null;
508
- return;
509
- } // Aggregate the values
510
-
511
-
512
- var aggregateFn = instance.getColumnAggregationFn(column.id);
513
-
514
- if (aggregateFn) {
515
- // Get the columnValues to aggregate
516
- var groupedValues = groupedRows.map(function (row) {
517
- return row.values[column.id];
518
- }); // Get the columnValues to aggregate
519
-
520
- var leafValues = leafRows.map(function (row) {
521
- var columnValue = row.values[column.id];
551
+ var leafValues = leafRows.map(function (row) {
552
+ var columnValue = row.values[column.id];
522
553
 
523
554
  if (!depth && column.aggregateValue) {
524
555
  columnValue = column.aggregateValue(columnValue);
@@ -730,7 +761,11 @@ function getInstance$a(instance) {
730
761
  });
731
762
  }, {
732
763
  key: 'getVisibleFlatColumns',
733
- debug: instance.options.debug
764
+ debug: function debug() {
765
+ var _instance$options$deb;
766
+
767
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
768
+ }
734
769
  }),
735
770
  getVisibleLeafColumns: memo(function () {
736
771
  return [instance.getAllLeafColumns(), instance.getAllLeafColumns().filter(function (d) {
@@ -744,7 +779,11 @@ function getInstance$a(instance) {
744
779
  });
745
780
  }, {
746
781
  key: 'getVisibleLeafColumns',
747
- debug: instance.options.debug
782
+ debug: function debug() {
783
+ var _instance$options$deb2;
784
+
785
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
786
+ }
748
787
  }),
749
788
  setColumnVisibility: function setColumnVisibility(updater) {
750
789
  return instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater, functionalUpdate(updater, instance.getState().columnVisibility));
@@ -996,7 +1035,7 @@ function getInstance$9(instance) {
996
1035
  }
997
1036
  },
998
1037
  getColumnAutoAggregationFn: function getColumnAutoAggregationFn(columnId) {
999
- var firstRow = instance.getCoreFlatRows()[0];
1038
+ var firstRow = instance.getCoreRowModel().flatRows[0];
1000
1039
  var value = firstRow == null ? void 0 : firstRow.values[columnId];
1001
1040
 
1002
1041
  if (typeof value === 'number') {
@@ -1064,11 +1103,6 @@ function getInstance$9(instance) {
1064
1103
  },
1065
1104
  getToggleGroupingProps: function getToggleGroupingProps(columnId, userProps) {
1066
1105
  var column = instance.getColumn(columnId);
1067
-
1068
- if (!column) {
1069
- return;
1070
- }
1071
-
1072
1106
  var canGroup = column.getCanGroup();
1073
1107
  var initialProps = {
1074
1108
  title: canGroup ? 'Toggle Grouping' : undefined,
@@ -1084,6 +1118,9 @@ function getInstance$9(instance) {
1084
1118
 
1085
1119
  return !!((_instance$getRow = instance.getRow(rowId)) != null && _instance$getRow.groupingColumnId);
1086
1120
  },
1121
+ getPreGroupedRowModel: function getPreGroupedRowModel() {
1122
+ return instance.getSortedRowModel();
1123
+ },
1087
1124
  getGroupedRowModel: memo(function () {
1088
1125
  return [instance.getState().grouping, instance.getSortedRowModel(), instance.options.groupRowsFn];
1089
1126
  }, function (grouping, rowModel, groupRowsFn) {
@@ -1091,33 +1128,18 @@ function getInstance$9(instance) {
1091
1128
  return rowModel;
1092
1129
  }
1093
1130
 
1094
- if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Grouping...');
1095
1131
  return groupRowsFn(instance, rowModel);
1096
1132
  }, {
1097
1133
  key: 'getGroupedRowModel',
1098
- debug: instance.options.debug,
1134
+ debug: function debug() {
1135
+ var _instance$options$deb;
1136
+
1137
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
1138
+ },
1099
1139
  onChange: function onChange() {
1100
1140
  return instance._notifyExpandedReset();
1101
1141
  }
1102
- }),
1103
- getPreGroupedRows: function getPreGroupedRows() {
1104
- return instance.getSortedRowModel().rows;
1105
- },
1106
- getPreGroupedFlatRows: function getPreGroupedFlatRows() {
1107
- return instance.getSortedRowModel().flatRows;
1108
- },
1109
- getPreGroupedRowsById: function getPreGroupedRowsById() {
1110
- return instance.getSortedRowModel().rowsById;
1111
- },
1112
- getGroupedRows: function getGroupedRows() {
1113
- return instance.getGroupedRowModel().rows;
1114
- },
1115
- getGroupedFlatRows: function getGroupedFlatRows() {
1116
- return instance.getGroupedRowModel().flatRows;
1117
- },
1118
- getGroupedRowsById: function getGroupedRowsById() {
1119
- return instance.getGroupedRowModel().rowsById;
1120
- }
1142
+ })
1121
1143
  };
1122
1144
  }
1123
1145
  function createRow$3(row, instance) {
@@ -1234,8 +1256,8 @@ function getInstance$8(instance) {
1234
1256
  return orderColumns(orderedColumns, grouping, groupedColumnMode);
1235
1257
  };
1236
1258
  }, {
1237
- key: 'getOrderColumnsFn',
1238
- debug: instance.options.debug
1259
+ key: 'getOrderColumnsFn' // debug: () => instance.options.debugAll ?? instance.options.debugTable,
1260
+
1239
1261
  })
1240
1262
  };
1241
1263
  }
@@ -1384,72 +1406,396 @@ var Pinning = /*#__PURE__*/Object.freeze({
1384
1406
  });
1385
1407
 
1386
1408
  //
1387
- function createRow$2(row, instance) {
1409
+ var defaultColumnSizing = {
1410
+ width: 150,
1411
+ minWidth: 20,
1412
+ maxWidth: Number.MAX_SAFE_INTEGER
1413
+ };
1414
+ function getInitialState$5() {
1388
1415
  return {
1389
- _getAllVisibleCells: memo(function () {
1390
- return [row.getAllCells().filter(function (cell) {
1391
- return cell.column.getIsVisible();
1392
- }).map(function (d) {
1393
- return d.id;
1394
- }).join('_')];
1395
- }, function (_) {
1396
- return row.getAllCells().filter(function (cell) {
1397
- return cell.column.getIsVisible();
1398
- });
1399
- }, {
1400
- key: 'row._getAllVisibleCells',
1401
- debug: instance.options.debug
1402
- }),
1403
- getVisibleCells: memo(function () {
1404
- return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()];
1405
- }, function (left, center, right) {
1406
- return [].concat(left, center, right);
1407
- }, {
1408
- key: 'row.getVisibleCells',
1409
- debug: instance.options.debug
1410
- }),
1411
- getCenterVisibleCells: memo(function () {
1412
- return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
1413
- }, function (allCells, left, right) {
1414
- var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []);
1415
- return allCells.filter(function (d) {
1416
- return !leftAndRight.includes(d.columnId);
1417
- });
1418
- }, {
1419
- key: 'row.getCenterVisibleCells',
1420
- debug: instance.options.debug
1421
- }),
1422
- getLeftVisibleCells: memo(function () {
1423
- return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,];
1424
- }, function (allCells, left) {
1425
- var cells = (left != null ? left : []).map(function (columnId) {
1426
- return allCells.find(function (cell) {
1427
- return cell.columnId === columnId;
1428
- });
1429
- }).filter(Boolean);
1430
- return cells;
1431
- }, {
1432
- key: 'row.getLeftVisibleCells',
1433
- debug: instance.options.debug
1434
- }),
1435
- getRightVisibleCells: memo(function () {
1436
- return [row._getAllVisibleCells(), instance.getState().columnPinning.right];
1437
- }, function (allCells, right) {
1438
- var cells = (right != null ? right : []).map(function (columnId) {
1439
- return allCells.find(function (cell) {
1440
- return cell.columnId === columnId;
1416
+ columnSizing: {},
1417
+ columnSizingInfo: {
1418
+ startOffset: null,
1419
+ startSize: null,
1420
+ deltaOffset: null,
1421
+ deltaPercentage: null,
1422
+ isResizingColumn: false,
1423
+ columnSizingStart: []
1424
+ }
1425
+ };
1426
+ }
1427
+ function getDefaultOptions$5(instance) {
1428
+ return {
1429
+ columnResizeMode: 'onEnd',
1430
+ onColumnSizingChange: makeStateUpdater('columnSizing', instance),
1431
+ onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', instance)
1432
+ };
1433
+ }
1434
+ function getInstance$6(instance) {
1435
+ return {
1436
+ setColumnSizing: function setColumnSizing(updater) {
1437
+ return instance.options.onColumnSizingChange == null ? void 0 : instance.options.onColumnSizingChange(updater, functionalUpdate(updater, instance.getState().columnSizing));
1438
+ },
1439
+ setColumnSizingInfo: function setColumnSizingInfo(updater) {
1440
+ return instance.options.onColumnSizingInfoChange == null ? void 0 : instance.options.onColumnSizingInfoChange(updater, functionalUpdate(updater, instance.getState().columnSizingInfo));
1441
+ },
1442
+ resetColumnSizing: function resetColumnSizing() {
1443
+ var _instance$initialStat;
1444
+
1445
+ instance.setColumnSizing((_instance$initialStat = instance.initialState.columnSizing) != null ? _instance$initialStat : {});
1446
+ },
1447
+ resetHeaderSizeInfo: function resetHeaderSizeInfo() {
1448
+ var _instance$initialStat2;
1449
+
1450
+ instance.setColumnSizingInfo((_instance$initialStat2 = instance.initialState.columnSizingInfo) != null ? _instance$initialStat2 : {});
1451
+ },
1452
+ resetColumnSize: function resetColumnSize(columnId) {
1453
+ instance.setColumnSizing(function (_ref) {
1454
+ _ref[columnId];
1455
+ var rest = _objectWithoutPropertiesLoose(_ref, [columnId].map(_toPropertyKey));
1456
+
1457
+ return rest;
1458
+ });
1459
+ },
1460
+ resetHeaderSize: function resetHeaderSize(headerId) {
1461
+ var header = instance.getHeader(headerId);
1462
+ return instance.resetColumnSize(header.column.id);
1463
+ },
1464
+ getHeaderCanResize: function getHeaderCanResize(headerId) {
1465
+ var header = instance.getHeader(headerId);
1466
+
1467
+ if (!header) {
1468
+ throw new Error();
1469
+ }
1470
+
1471
+ return instance.getColumnCanResize(header.column.id);
1472
+ },
1473
+ getColumnCanResize: function getColumnCanResize(columnId) {
1474
+ var _ref2, _ref3, _column$enableResizin;
1475
+
1476
+ var column = instance.getColumn(columnId);
1477
+
1478
+ if (!column) {
1479
+ throw new Error();
1480
+ }
1481
+
1482
+ return (_ref2 = (_ref3 = (_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : instance.options.enableColumnResizing) != null ? _ref3 : column.defaultCanResize) != null ? _ref2 : true;
1483
+ },
1484
+ getColumnIsResizing: function getColumnIsResizing(columnId) {
1485
+ var column = instance.getColumn(columnId);
1486
+
1487
+ if (!column) {
1488
+ throw new Error();
1489
+ }
1490
+
1491
+ return instance.getState().columnSizingInfo.isResizingColumn === columnId;
1492
+ },
1493
+ getHeaderIsResizing: function getHeaderIsResizing(headerId) {
1494
+ var header = instance.getHeader(headerId);
1495
+
1496
+ if (!header) {
1497
+ throw new Error();
1498
+ }
1499
+
1500
+ return instance.getColumnIsResizing(header.column.id);
1501
+ },
1502
+ getHeaderResizerProps: function getHeaderResizerProps(headerId, userProps) {
1503
+ var header = instance.getHeader(headerId);
1504
+ var column = instance.getColumn(header.column.id);
1505
+ var canResize = column.getCanResize();
1506
+
1507
+ var onResizeStart = function onResizeStart(e) {
1508
+ if (isTouchStartEvent(e)) {
1509
+ // lets not respond to multiple touches (e.g. 2 or 3 fingers)
1510
+ if (e.touches && e.touches.length > 1) {
1511
+ return;
1512
+ }
1513
+ }
1514
+
1515
+ var header = headerId ? instance.getHeader(headerId) : undefined;
1516
+ var startSize = header ? header.getWidth() : column.getWidth();
1517
+ var columnSizingStart = header ? header.getLeafHeaders().map(function (d) {
1518
+ return [d.column.id, d.getWidth()];
1519
+ }) : [[column.id, column.getWidth()]];
1520
+ var clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
1521
+
1522
+ var updateOffset = function updateOffset(eventType, clientXPos) {
1523
+ if (typeof clientXPos !== 'number') {
1524
+ return;
1525
+ }
1526
+
1527
+ var newColumnSizing = {};
1528
+ instance.setColumnSizingInfo(function (old) {
1529
+ var _old$startOffset, _old$startSize;
1530
+
1531
+ var deltaOffset = clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0);
1532
+ var deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
1533
+ old.columnSizingStart.forEach(function (_ref4) {
1534
+ var columnId = _ref4[0],
1535
+ headerWidth = _ref4[1];
1536
+ newColumnSizing[columnId] = Math.round(Math.max(headerWidth + headerWidth * deltaPercentage, 0) * 100) / 100;
1537
+ });
1538
+ return _extends({}, old, {
1539
+ deltaOffset: deltaOffset,
1540
+ deltaPercentage: deltaPercentage
1541
+ });
1542
+ });
1543
+
1544
+ if (instance.options.columnResizeMode === 'onChange' || eventType === 'end') {
1545
+ instance.setColumnSizing(function (old) {
1546
+ return _extends({}, old, newColumnSizing);
1547
+ });
1548
+ }
1549
+ };
1550
+
1551
+ var onMove = function onMove(clientXPos) {
1552
+ return updateOffset('move', clientXPos);
1553
+ };
1554
+
1555
+ var onEnd = function onEnd(clientXPos) {
1556
+ updateOffset('end', clientXPos);
1557
+ instance.setColumnSizingInfo(function (old) {
1558
+ return _extends({}, old, {
1559
+ isResizingColumn: false,
1560
+ startOffset: null,
1561
+ startSize: null,
1562
+ deltaOffset: null,
1563
+ deltaPercentage: null,
1564
+ columnSizingStart: []
1565
+ });
1566
+ });
1567
+ };
1568
+
1569
+ var mouseEvents = {
1570
+ moveHandler: function moveHandler(e) {
1571
+ return onMove(e.clientX);
1572
+ },
1573
+ upHandler: function upHandler(e) {
1574
+ document.removeEventListener('mousemove', mouseEvents.moveHandler);
1575
+ document.removeEventListener('mouseup', mouseEvents.upHandler);
1576
+ onEnd(e.clientX);
1577
+ }
1578
+ };
1579
+ var touchEvents = {
1580
+ moveHandler: function moveHandler(e) {
1581
+ if (e.cancelable) {
1582
+ e.preventDefault();
1583
+ e.stopPropagation();
1584
+ }
1585
+
1586
+ onMove(e.touches[0].clientX);
1587
+ return false;
1588
+ },
1589
+ upHandler: function upHandler(e) {
1590
+ document.removeEventListener('touchmove', touchEvents.moveHandler);
1591
+ document.removeEventListener('touchend', touchEvents.upHandler);
1592
+
1593
+ if (e.cancelable) {
1594
+ e.preventDefault();
1595
+ e.stopPropagation();
1596
+ }
1597
+
1598
+ onEnd(e.touches[0].clientX);
1599
+ }
1600
+ };
1601
+ var passiveIfSupported = passiveEventSupported() ? {
1602
+ passive: false
1603
+ } : false;
1604
+
1605
+ if (isTouchStartEvent(e)) {
1606
+ document.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
1607
+ document.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
1608
+ } else {
1609
+ document.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
1610
+ document.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
1611
+ }
1612
+
1613
+ instance.setColumnSizingInfo(function (old) {
1614
+ return _extends({}, old, {
1615
+ startOffset: clientX,
1616
+ startSize: startSize,
1617
+ deltaOffset: 0,
1618
+ deltaPercentage: 0,
1619
+ columnSizingStart: columnSizingStart,
1620
+ isResizingColumn: column.id
1621
+ });
1622
+ });
1623
+ };
1624
+
1625
+ var initialProps = canResize ? {
1626
+ title: 'Toggle Grouping',
1627
+ draggable: false,
1628
+ role: 'separator',
1629
+ onMouseDown: function onMouseDown(e) {
1630
+ e.persist();
1631
+ onResizeStart(e);
1632
+ },
1633
+ onTouchStart: function onTouchStart(e) {
1634
+ e.persist();
1635
+ onResizeStart(e);
1636
+ }
1637
+ } : {};
1638
+ return propGetter(initialProps, userProps);
1639
+ }
1640
+ };
1641
+ }
1642
+ function createColumn$2(column, instance) {
1643
+ return {
1644
+ getIsResizing: function getIsResizing() {
1645
+ return instance.getColumnIsResizing(column.id);
1646
+ },
1647
+ getCanResize: function getCanResize() {
1648
+ return instance.getColumnCanResize(column.id);
1649
+ },
1650
+ resetSize: function resetSize() {
1651
+ return instance.resetColumnSize(column.id);
1652
+ }
1653
+ };
1654
+ }
1655
+ function createHeader(header, instance) {
1656
+ return {
1657
+ getIsResizing: function getIsResizing() {
1658
+ return instance.getColumnIsResizing(header.column.id);
1659
+ },
1660
+ getCanResize: function getCanResize() {
1661
+ return instance.getColumnCanResize(header.column.id);
1662
+ },
1663
+ resetSize: function resetSize() {
1664
+ return instance.resetColumnSize(header.column.id);
1665
+ },
1666
+ getResizerProps: function getResizerProps(userProps) {
1667
+ return instance.getHeaderResizerProps(header.id, userProps);
1668
+ }
1669
+ };
1670
+ }
1671
+ var passiveSupported = null;
1672
+ function passiveEventSupported() {
1673
+ if (typeof passiveSupported === 'boolean') return passiveSupported;
1674
+ var supported = false;
1675
+
1676
+ try {
1677
+ var options = {
1678
+ get passive() {
1679
+ supported = true;
1680
+ return false;
1681
+ }
1682
+
1683
+ };
1684
+
1685
+ var noop = function noop() {};
1686
+
1687
+ window.addEventListener('test', noop, options);
1688
+ window.removeEventListener('test', noop);
1689
+ } catch (err) {
1690
+ supported = false;
1691
+ }
1692
+
1693
+ passiveSupported = supported;
1694
+ return passiveSupported;
1695
+ }
1696
+
1697
+ function isTouchStartEvent(e) {
1698
+ return e.type === 'touchstart';
1699
+ }
1700
+
1701
+ var ColumnSizing = /*#__PURE__*/Object.freeze({
1702
+ __proto__: null,
1703
+ defaultColumnSizing: defaultColumnSizing,
1704
+ getInitialState: getInitialState$5,
1705
+ getDefaultOptions: getDefaultOptions$5,
1706
+ getInstance: getInstance$6,
1707
+ createColumn: createColumn$2,
1708
+ createHeader: createHeader,
1709
+ passiveEventSupported: passiveEventSupported
1710
+ });
1711
+
1712
+ //
1713
+ function createRow$2(row, instance) {
1714
+ return {
1715
+ _getAllVisibleCells: memo(function () {
1716
+ return [row.getAllCells().filter(function (cell) {
1717
+ return cell.column.getIsVisible();
1718
+ }).map(function (d) {
1719
+ return d.id;
1720
+ }).join('_')];
1721
+ }, function (_) {
1722
+ return row.getAllCells().filter(function (cell) {
1723
+ return cell.column.getIsVisible();
1724
+ });
1725
+ }, {
1726
+ key: 'row._getAllVisibleCells',
1727
+ debug: function debug() {
1728
+ var _instance$options$deb;
1729
+
1730
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
1731
+ }
1732
+ }),
1733
+ getVisibleCells: memo(function () {
1734
+ return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()];
1735
+ }, function (left, center, right) {
1736
+ return [].concat(left, center, right);
1737
+ }, {
1738
+ key: 'row.getVisibleCells',
1739
+ debug: function debug() {
1740
+ var _instance$options$deb2;
1741
+
1742
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
1743
+ }
1744
+ }),
1745
+ getCenterVisibleCells: memo(function () {
1746
+ return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
1747
+ }, function (allCells, left, right) {
1748
+ var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []);
1749
+ return allCells.filter(function (d) {
1750
+ return !leftAndRight.includes(d.columnId);
1751
+ });
1752
+ }, {
1753
+ key: 'row.getCenterVisibleCells',
1754
+ debug: function debug() {
1755
+ var _instance$options$deb3;
1756
+
1757
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugRows;
1758
+ }
1759
+ }),
1760
+ getLeftVisibleCells: memo(function () {
1761
+ return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,];
1762
+ }, function (allCells, left) {
1763
+ var cells = (left != null ? left : []).map(function (columnId) {
1764
+ return allCells.find(function (cell) {
1765
+ return cell.columnId === columnId;
1766
+ });
1767
+ }).filter(Boolean);
1768
+ return cells;
1769
+ }, {
1770
+ key: 'row.getLeftVisibleCells',
1771
+ debug: function debug() {
1772
+ var _instance$options$deb4;
1773
+
1774
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugRows;
1775
+ }
1776
+ }),
1777
+ getRightVisibleCells: memo(function () {
1778
+ return [row._getAllVisibleCells(), instance.getState().columnPinning.right];
1779
+ }, function (allCells, right) {
1780
+ var cells = (right != null ? right : []).map(function (columnId) {
1781
+ return allCells.find(function (cell) {
1782
+ return cell.columnId === columnId;
1441
1783
  });
1442
1784
  }).filter(Boolean);
1443
1785
  return cells;
1444
1786
  }, {
1445
1787
  key: 'row.getRightVisibleCells',
1446
- debug: instance.options.debug
1788
+ debug: function debug() {
1789
+ var _instance$options$deb5;
1790
+
1791
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugRows;
1792
+ }
1447
1793
  })
1448
1794
  };
1449
1795
  }
1450
- function getInstance$6(instance) {
1796
+ function getInstance$5(instance) {
1451
1797
  return {
1452
- createHeader: function createHeader(column, options) {
1798
+ createHeader: function createHeader$1(column, options) {
1453
1799
  var _options$id;
1454
1800
 
1455
1801
  var id = (_options$id = options.id) != null ? _options$id : column.id;
@@ -1512,9 +1858,9 @@ function getInstance$6(instance) {
1512
1858
  column: column
1513
1859
  });
1514
1860
  }
1515
- }; // Yes, we have to convert instance to uknown, because we know more than the compiler here.
1861
+ }; // Yes, we have to convert instance to unknown, because we know more than the compiler here.
1516
1862
 
1517
- return header;
1863
+ return Object.assign(header, createHeader(header, instance));
1518
1864
  },
1519
1865
  // Header Groups
1520
1866
  getHeaderGroups: memo(function () {
@@ -1533,7 +1879,11 @@ function getInstance$6(instance) {
1533
1879
  return headerGroups;
1534
1880
  }, {
1535
1881
  key: 'getHeaderGroups',
1536
- debug: instance.options.debug
1882
+ debug: function debug() {
1883
+ var _instance$options$deb6;
1884
+
1885
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
1886
+ }
1537
1887
  }),
1538
1888
  getCenterHeaderGroups: memo(function () {
1539
1889
  return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
@@ -1544,7 +1894,11 @@ function getInstance$6(instance) {
1544
1894
  return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
1545
1895
  }, {
1546
1896
  key: 'getCenterHeaderGroups',
1547
- debug: instance.options.debug
1897
+ debug: function debug() {
1898
+ var _instance$options$deb7;
1899
+
1900
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
1901
+ }
1548
1902
  }),
1549
1903
  getLeftHeaderGroups: memo(function () {
1550
1904
  return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left];
@@ -1555,7 +1909,11 @@ function getInstance$6(instance) {
1555
1909
  return buildHeaderGroups(allColumns, leafColumns, instance, 'left');
1556
1910
  }, {
1557
1911
  key: 'getLeftHeaderGroups',
1558
- debug: instance.options.debug
1912
+ debug: function debug() {
1913
+ var _instance$options$deb8;
1914
+
1915
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
1916
+ }
1559
1917
  }),
1560
1918
  getRightHeaderGroups: memo(function () {
1561
1919
  return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right];
@@ -1566,7 +1924,11 @@ function getInstance$6(instance) {
1566
1924
  return buildHeaderGroups(allColumns, leafColumns, instance, 'right');
1567
1925
  }, {
1568
1926
  key: 'getRightHeaderGroups',
1569
- debug: instance.options.debug
1927
+ debug: function debug() {
1928
+ var _instance$options$deb9;
1929
+
1930
+ return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
1931
+ }
1570
1932
  }),
1571
1933
  // Footer Groups
1572
1934
  getFooterGroups: memo(function () {
@@ -1575,7 +1937,11 @@ function getInstance$6(instance) {
1575
1937
  return [].concat(headerGroups).reverse();
1576
1938
  }, {
1577
1939
  key: 'getFooterGroups',
1578
- debug: instance.options.debug
1940
+ debug: function debug() {
1941
+ var _instance$options$deb10;
1942
+
1943
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
1944
+ }
1579
1945
  }),
1580
1946
  getLeftFooterGroups: memo(function () {
1581
1947
  return [instance.getLeftHeaderGroups()];
@@ -1583,7 +1949,11 @@ function getInstance$6(instance) {
1583
1949
  return [].concat(headerGroups).reverse();
1584
1950
  }, {
1585
1951
  key: 'getLeftFooterGroups',
1586
- debug: instance.options.debug
1952
+ debug: function debug() {
1953
+ var _instance$options$deb11;
1954
+
1955
+ return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
1956
+ }
1587
1957
  }),
1588
1958
  getCenterFooterGroups: memo(function () {
1589
1959
  return [instance.getCenterHeaderGroups()];
@@ -1591,7 +1961,11 @@ function getInstance$6(instance) {
1591
1961
  return [].concat(headerGroups).reverse();
1592
1962
  }, {
1593
1963
  key: 'getCenterFooterGroups',
1594
- debug: instance.options.debug
1964
+ debug: function debug() {
1965
+ var _instance$options$deb12;
1966
+
1967
+ return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
1968
+ }
1595
1969
  }),
1596
1970
  getRightFooterGroups: memo(function () {
1597
1971
  return [instance.getRightHeaderGroups()];
@@ -1599,7 +1973,11 @@ function getInstance$6(instance) {
1599
1973
  return [].concat(headerGroups).reverse();
1600
1974
  }, {
1601
1975
  key: 'getRightFooterGroups',
1602
- debug: instance.options.debug
1976
+ debug: function debug() {
1977
+ var _instance$options$deb13;
1978
+
1979
+ return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
1980
+ }
1603
1981
  }),
1604
1982
  // Flat Headers
1605
1983
  getFlatHeaders: memo(function () {
@@ -1610,7 +1988,11 @@ function getInstance$6(instance) {
1610
1988
  }).flat();
1611
1989
  }, {
1612
1990
  key: 'getFlatHeaders',
1613
- debug: instance.options.debug
1991
+ debug: function debug() {
1992
+ var _instance$options$deb14;
1993
+
1994
+ return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
1995
+ }
1614
1996
  }),
1615
1997
  getLeftFlatHeaders: memo(function () {
1616
1998
  return [instance.getLeftHeaderGroups()];
@@ -1620,7 +2002,11 @@ function getInstance$6(instance) {
1620
2002
  }).flat();
1621
2003
  }, {
1622
2004
  key: 'getLeftFlatHeaders',
1623
- debug: instance.options.debug
2005
+ debug: function debug() {
2006
+ var _instance$options$deb15;
2007
+
2008
+ return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
2009
+ }
1624
2010
  }),
1625
2011
  getCenterFlatHeaders: memo(function () {
1626
2012
  return [instance.getCenterHeaderGroups()];
@@ -1630,7 +2016,11 @@ function getInstance$6(instance) {
1630
2016
  }).flat();
1631
2017
  }, {
1632
2018
  key: 'getCenterFlatHeaders',
1633
- debug: instance.options.debug
2019
+ debug: function debug() {
2020
+ var _instance$options$deb16;
2021
+
2022
+ return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
2023
+ }
1634
2024
  }),
1635
2025
  getRightFlatHeaders: memo(function () {
1636
2026
  return [instance.getRightHeaderGroups()];
@@ -1640,7 +2030,11 @@ function getInstance$6(instance) {
1640
2030
  }).flat();
1641
2031
  }, {
1642
2032
  key: 'getRightFlatHeaders',
1643
- debug: instance.options.debug
2033
+ debug: function debug() {
2034
+ var _instance$options$deb17;
2035
+
2036
+ return (_instance$options$deb17 = instance.options.debugAll) != null ? _instance$options$deb17 : instance.options.debugHeaders;
2037
+ }
1644
2038
  }),
1645
2039
  // Leaf Headers
1646
2040
  getCenterLeafHeaders: memo(function () {
@@ -1653,7 +2047,11 @@ function getInstance$6(instance) {
1653
2047
  });
1654
2048
  }, {
1655
2049
  key: 'getCenterLeafHeaders',
1656
- debug: instance.options.debug
2050
+ debug: function debug() {
2051
+ var _instance$options$deb18;
2052
+
2053
+ return (_instance$options$deb18 = instance.options.debugAll) != null ? _instance$options$deb18 : instance.options.debugHeaders;
2054
+ }
1657
2055
  }),
1658
2056
  getLeftLeafHeaders: memo(function () {
1659
2057
  return [instance.getLeftFlatHeaders()];
@@ -1665,7 +2063,11 @@ function getInstance$6(instance) {
1665
2063
  });
1666
2064
  }, {
1667
2065
  key: 'getLeftLeafHeaders',
1668
- debug: instance.options.debug
2066
+ debug: function debug() {
2067
+ var _instance$options$deb19;
2068
+
2069
+ return (_instance$options$deb19 = instance.options.debugAll) != null ? _instance$options$deb19 : instance.options.debugHeaders;
2070
+ }
1669
2071
  }),
1670
2072
  getRightLeafHeaders: memo(function () {
1671
2073
  return [instance.getRightFlatHeaders()];
@@ -1677,7 +2079,11 @@ function getInstance$6(instance) {
1677
2079
  });
1678
2080
  }, {
1679
2081
  key: 'getRightLeafHeaders',
1680
- debug: instance.options.debug
2082
+ debug: function debug() {
2083
+ var _instance$options$deb20;
2084
+
2085
+ return (_instance$options$deb20 = instance.options.debugAll) != null ? _instance$options$deb20 : instance.options.debugHeaders;
2086
+ }
1681
2087
  }),
1682
2088
  getLeafHeaders: memo(function () {
1683
2089
  return [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()];
@@ -1689,7 +2095,11 @@ function getInstance$6(instance) {
1689
2095
  }).flat();
1690
2096
  }, {
1691
2097
  key: 'getLeafHeaders',
1692
- debug: instance.options.debug
2098
+ debug: function debug() {
2099
+ var _instance$options$deb21;
2100
+
2101
+ return (_instance$options$deb21 = instance.options.debugAll) != null ? _instance$options$deb21 : instance.options.debugHeaders;
2102
+ }
1693
2103
  }),
1694
2104
  getHeader: function getHeader(id) {
1695
2105
  var header = [].concat(instance.getFlatHeaders(), instance.getCenterFlatHeaders(), instance.getLeftFlatHeaders(), instance.getRightFlatHeaders()).find(function (d) {
@@ -1752,11 +2162,6 @@ function getInstance$6(instance) {
1752
2162
  },
1753
2163
  getFooterProps: function getFooterProps(id, userProps) {
1754
2164
  var header = instance.getHeader(id);
1755
-
1756
- if (!header) {
1757
- return;
1758
- }
1759
-
1760
2165
  var initialProps = {
1761
2166
  key: header.id,
1762
2167
  role: 'columnfooter',
@@ -1915,7 +2320,7 @@ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
1915
2320
  var Headers = /*#__PURE__*/Object.freeze({
1916
2321
  __proto__: null,
1917
2322
  createRow: createRow$2,
1918
- getInstance: getInstance$6,
2323
+ getInstance: getInstance$5,
1919
2324
  buildHeaderGroups: buildHeaderGroups
1920
2325
  });
1921
2326
 
@@ -2081,13 +2486,13 @@ function getDefaultColumn$1() {
2081
2486
  filterType: 'auto'
2082
2487
  };
2083
2488
  }
2084
- function getInitialState$5() {
2489
+ function getInitialState$4() {
2085
2490
  return {
2086
2491
  columnFilters: [],
2087
2492
  globalFilter: undefined
2088
2493
  };
2089
2494
  }
2090
- function getDefaultOptions$5(instance) {
2495
+ function getDefaultOptions$4(instance) {
2091
2496
  return {
2092
2497
  onColumnFiltersChange: makeStateUpdater('columnFilters', instance),
2093
2498
  onGlobalFilterChange: makeStateUpdater('globalFilter', instance),
@@ -2096,14 +2501,14 @@ function getDefaultOptions$5(instance) {
2096
2501
  autoResetGlobalFilter: true,
2097
2502
  globalFilterType: 'auto',
2098
2503
  getColumnCanGlobalFilterFn: function getColumnCanGlobalFilterFn(column) {
2099
- var _instance$getCoreFlat, _instance$getCoreFlat2;
2504
+ var _instance$getCoreRowM, _instance$getCoreRowM2;
2100
2505
 
2101
- var value = (_instance$getCoreFlat = instance.getCoreFlatRows()[0]) == null ? void 0 : (_instance$getCoreFlat2 = _instance$getCoreFlat.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreFlat2.value;
2506
+ var value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.value;
2102
2507
  return typeof value === 'string';
2103
2508
  }
2104
2509
  };
2105
2510
  }
2106
- function createColumn$2(column, instance) {
2511
+ function createColumn$1(column, instance) {
2107
2512
  var getFacetInfo = memo(function () {
2108
2513
  return [column.getPreFilteredRows()];
2109
2514
  }, function (rows) {
@@ -2142,7 +2547,11 @@ function createColumn$2(column, instance) {
2142
2547
  };
2143
2548
  }, {
2144
2549
  key: 'column.getFacetInfo',
2145
- debug: instance.options.debug
2550
+ debug: function debug() {
2551
+ var _instance$options$deb;
2552
+
2553
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
2554
+ }
2146
2555
  });
2147
2556
  return {
2148
2557
  filterType: column.filterType,
@@ -2175,7 +2584,7 @@ function createColumn$2(column, instance) {
2175
2584
  }
2176
2585
  };
2177
2586
  }
2178
- function getInstance$5(instance) {
2587
+ function getInstance$4(instance) {
2179
2588
  var registered = false;
2180
2589
  return {
2181
2590
  _notifyFiltersReset: function _notifyFiltersReset() {
@@ -2201,7 +2610,7 @@ function getInstance$5(instance) {
2201
2610
  }
2202
2611
  },
2203
2612
  getColumnAutoFilterFn: function getColumnAutoFilterFn(columnId) {
2204
- var firstRow = instance.getCoreFlatRows()[0];
2613
+ var firstRow = instance.getCoreRowModel().flatRows[0];
2205
2614
  var value = firstRow == null ? void 0 : firstRow.values[columnId];
2206
2615
 
2207
2616
  if (typeof value === 'string') {
@@ -2371,6 +2780,12 @@ function getInstance$5(instance) {
2371
2780
 
2372
2781
  instance.setColumnFilters((_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnFilters) != null ? _instance$initialStat : []);
2373
2782
  },
2783
+ getPreFilteredRowModel: function getPreFilteredRowModel() {
2784
+ return instance.getCoreRowModel();
2785
+ },
2786
+ getPreColumnFilteredRowModel: function getPreColumnFilteredRowModel() {
2787
+ return instance.getCoreRowModel();
2788
+ },
2374
2789
  getColumnFilteredRowModel: memo(function () {
2375
2790
  return [instance.getState().columnFilters, instance.getCoreRowModel(), instance.options.columnFilterRowsFn];
2376
2791
  }, function (columnFilters, rowModel, columnFiltersFn) {
@@ -2379,7 +2794,6 @@ function getInstance$5(instance) {
2379
2794
  return rowModel;
2380
2795
  }
2381
2796
 
2382
- if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Column Filtering...');
2383
2797
  return columnFiltersFn(instance, rowModel);
2384
2798
  }(); // Now that each filtered column has it's partially filtered rows,
2385
2799
  // lets assign the final filtered rows to all of the other columns
@@ -2402,39 +2816,14 @@ function getInstance$5(instance) {
2402
2816
  return columnFilteredRowModel;
2403
2817
  }, {
2404
2818
  key: 'getColumnFilteredRowModel',
2405
- debug: instance.options.debug
2819
+ debug: function debug() {
2820
+ var _instance$options$deb2;
2821
+
2822
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugTable;
2823
+ }
2406
2824
  }),
2407
- // These might be easier to remember than "column" filtered rows
2408
- getPreFilteredRowModel: function getPreFilteredRowModel() {
2409
- return instance.getCoreRowModel();
2410
- },
2411
- getPreFilteredRows: function getPreFilteredRows() {
2412
- return instance.getCoreRowModel().rows;
2413
- },
2414
- getPreFilteredFlatRows: function getPreFilteredFlatRows() {
2415
- return instance.getCoreRowModel().flatRows;
2416
- },
2417
- getPreFilteredRowsById: function getPreFilteredRowsById() {
2418
- return instance.getCoreRowModel().rowsById;
2419
- },
2420
- // Pre Column Filter
2421
- getPreColumnFilteredRows: function getPreColumnFilteredRows() {
2422
- return instance.getCoreRowModel().rows;
2423
- },
2424
- getPreColumnFilteredFlatRows: function getPreColumnFilteredFlatRows() {
2425
- return instance.getCoreRowModel().flatRows;
2426
- },
2427
- getPreColumnFilteredRowsById: function getPreColumnFilteredRowsById() {
2428
- return instance.getCoreRowModel().rowsById;
2429
- },
2430
- getColumnFilteredRows: function getColumnFilteredRows() {
2431
- return instance.getColumnFilteredRowModel().rows;
2432
- },
2433
- getColumnFilteredFlatRows: function getColumnFilteredFlatRows() {
2434
- return instance.getColumnFilteredRowModel().flatRows;
2435
- },
2436
- getColumnFilteredRowsById: function getColumnFilteredRowsById() {
2437
- return instance.getColumnFilteredRowModel().rowsById;
2825
+ getPreGlobalFilteredRowModel: function getPreGlobalFilteredRowModel() {
2826
+ return instance.getColumnFilteredRowModel();
2438
2827
  },
2439
2828
  getGlobalFilteredRowModel: memo(function () {
2440
2829
  return [instance.getState().globalFilter, instance.getColumnFilteredRowModel(), instance.options.globalFilterRowsFn];
@@ -2444,7 +2833,6 @@ function getInstance$5(instance) {
2444
2833
  return columnFilteredRowModel;
2445
2834
  }
2446
2835
 
2447
- if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Global Filtering...');
2448
2836
  return globalFiltersFn(instance, columnFilteredRowModel);
2449
2837
  }(); // Now that each filtered column has it's partially filtered rows,
2450
2838
  // lets assign the final filtered rows to all of the other columns
@@ -2467,29 +2855,15 @@ function getInstance$5(instance) {
2467
2855
  return globalFilteredRowModel;
2468
2856
  }, {
2469
2857
  key: 'getGlobalFilteredRowModel',
2470
- debug: instance.options.debug,
2858
+ debug: function debug() {
2859
+ var _instance$options$deb3;
2860
+
2861
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugTable;
2862
+ },
2471
2863
  onChange: function onChange() {
2472
2864
  instance._notifySortingReset();
2473
2865
  }
2474
- }),
2475
- getPreGlobalFilteredRows: function getPreGlobalFilteredRows() {
2476
- return instance.getColumnFilteredRowModel().rows;
2477
- },
2478
- getPreGlobalFilteredFlatRows: function getPreGlobalFilteredFlatRows() {
2479
- return instance.getColumnFilteredRowModel().flatRows;
2480
- },
2481
- getPreGlobalFilteredRowsById: function getPreGlobalFilteredRowsById() {
2482
- return instance.getColumnFilteredRowModel().rowsById;
2483
- },
2484
- getGlobalFilteredRows: function getGlobalFilteredRows() {
2485
- return instance.getGlobalFilteredRowModel().rows;
2486
- },
2487
- getGlobalFilteredFlatRows: function getGlobalFilteredFlatRows() {
2488
- return instance.getGlobalFilteredRowModel().flatRows;
2489
- },
2490
- getGlobalFilteredRowsById: function getGlobalFilteredRowsById() {
2491
- return instance.getGlobalFilteredRowModel().rowsById;
2492
- }
2866
+ })
2493
2867
  };
2494
2868
  }
2495
2869
  function shouldAutoRemoveFilter(filterFn, value, column) {
@@ -2499,10 +2873,10 @@ function shouldAutoRemoveFilter(filterFn, value, column) {
2499
2873
  var Filters = /*#__PURE__*/Object.freeze({
2500
2874
  __proto__: null,
2501
2875
  getDefaultColumn: getDefaultColumn$1,
2502
- getInitialState: getInitialState$5,
2503
- getDefaultOptions: getDefaultOptions$5,
2504
- createColumn: createColumn$2,
2505
- getInstance: getInstance$5,
2876
+ getInitialState: getInitialState$4,
2877
+ getDefaultOptions: getDefaultOptions$4,
2878
+ createColumn: createColumn$1,
2879
+ getInstance: getInstance$4,
2506
2880
  shouldAutoRemoveFilter: shouldAutoRemoveFilter
2507
2881
  });
2508
2882
 
@@ -2540,410 +2914,124 @@ function compareAlphanumeric(aStr, bStr) {
2540
2914
  var bn = parseInt(bb, 10);
2541
2915
  var combo = [an, bn].sort(); // Both are string
2542
2916
 
2543
- if (isNaN(combo[0])) {
2544
- if (aa > bb) {
2545
- return 1;
2546
- }
2547
-
2548
- if (bb > aa) {
2549
- return -1;
2550
- }
2551
-
2552
- continue;
2553
- } // One is a string, one is a number
2554
-
2555
-
2556
- if (isNaN(combo[1])) {
2557
- return isNaN(an) ? -1 : 1;
2558
- } // Both are numbers
2559
-
2560
-
2561
- if (an > bn) {
2562
- return 1;
2563
- }
2564
-
2565
- if (bn > an) {
2566
- return -1;
2567
- }
2568
- }
2569
-
2570
- return a.length - b.length;
2571
- } // The text filter is more basic (less numeric support)
2572
- // but is much faster
2573
-
2574
-
2575
- function text(rowA, rowB, columnId) {
2576
- return compareBasic(toString(rowA.values[columnId]).toLowerCase(), toString(rowB.values[columnId]).toLowerCase());
2577
- } // The text filter is more basic (less numeric support)
2578
- // but is much faster
2579
-
2580
-
2581
- function textCaseSensitive(rowA, rowB, columnId) {
2582
- return compareBasic(toString(rowA.values[columnId]), toString(rowB.values[columnId]));
2583
- }
2584
-
2585
- function datetime(rowA, rowB, columnId) {
2586
- return compareBasic(rowA.values[columnId].getTime(), rowB.values[columnId].getTime());
2587
- }
2588
-
2589
- function basic(rowA, rowB, columnId) {
2590
- return compareBasic(rowA.values[columnId], rowB.values[columnId]);
2591
- } // Utils
2592
-
2593
-
2594
- function compareBasic(a, b) {
2595
- return a === b ? 0 : a > b ? 1 : -1;
2596
- }
2597
-
2598
- function toString(a) {
2599
- if (typeof a === 'number') {
2600
- if (isNaN(a) || a === Infinity || a === -Infinity) {
2601
- return '';
2602
- }
2603
-
2604
- return String(a);
2605
- }
2606
-
2607
- if (typeof a === 'string') {
2608
- return a;
2609
- }
2610
-
2611
- return '';
2612
- }
2613
-
2614
- //
2615
- function getDefaultColumn() {
2616
- return {
2617
- sortType: 'auto'
2618
- };
2619
- }
2620
- function getInitialState$4() {
2621
- return {
2622
- sorting: []
2623
- };
2624
- }
2625
- function getDefaultOptions$4(instance) {
2626
- return {
2627
- onSortingChange: makeStateUpdater('sorting', instance),
2628
- autoResetSorting: true,
2629
- isMultiSortEvent: function isMultiSortEvent(e) {
2630
- return e.shiftKey;
2631
- }
2632
- };
2633
- }
2634
- function createColumn$1(column, instance) {
2635
- return {
2636
- sortType: column.sortType,
2637
- getCanSort: function getCanSort() {
2638
- return instance.getColumnCanSort(column.id);
2639
- },
2640
- getCanMultiSort: function getCanMultiSort() {
2641
- return instance.getColumnCanMultiSort(column.id);
2642
- },
2643
- getSortIndex: function getSortIndex() {
2644
- return instance.getColumnSortIndex(column.id);
2645
- },
2646
- getIsSorted: function getIsSorted() {
2647
- return instance.getColumnIsSorted(column.id);
2648
- },
2649
- toggleSorting: function toggleSorting(desc, isMulti) {
2650
- return instance.toggleColumnSorting(column.id, desc, isMulti);
2651
- },
2652
- getToggleSortingProps: function getToggleSortingProps(userProps) {
2653
- return instance.getToggleSortingProps(column.id, userProps);
2654
- }
2655
- };
2656
- }
2657
- function getInstance$4(instance) {
2658
- var registered = false;
2659
- return {
2660
- _notifySortingReset: function _notifySortingReset() {
2661
- if (!registered) {
2662
- registered = true;
2663
- return;
2664
- }
2665
-
2666
- if (instance.options.autoResetAll === false) {
2667
- return;
2668
- }
2669
-
2670
- if (instance.options.autoResetAll === true || instance.options.autoResetSorting) {
2671
- instance.resetSorting();
2672
- }
2673
- },
2674
- getColumnAutoSortingFn: function getColumnAutoSortingFn(columnId) {
2675
- var firstRows = instance.getGlobalFilteredRowModel().flatRows.slice(100);
2676
- var isString = false;
2677
-
2678
- for (var _iterator = _createForOfIteratorHelperLoose(firstRows), _step; !(_step = _iterator()).done;) {
2679
- var row = _step.value;
2680
- var value = row == null ? void 0 : row.values[columnId];
2681
-
2682
- if (Object.prototype.toString.call(value) === '[object Date]') {
2683
- return sortTypes.datetime;
2684
- }
2685
-
2686
- if (typeof value === 'string') {
2687
- isString = true;
2688
-
2689
- if (value.split(reSplitAlphaNumeric).length > 1) {
2690
- return sortTypes.alphanumeric;
2691
- }
2692
- }
2693
- }
2694
-
2695
- if (isString) {
2696
- return sortTypes.text;
2697
- }
2698
-
2699
- return sortTypes.basic;
2700
- },
2701
- getColumnAutoSortDir: function getColumnAutoSortDir(columnId) {
2702
- var firstRow = instance.getGlobalFilteredRowModel().flatRows[0];
2703
- var value = firstRow == null ? void 0 : firstRow.values[columnId];
2704
-
2705
- if (typeof value === 'string') {
2706
- return 'asc';
2707
- }
2708
-
2709
- return 'desc';
2710
- },
2711
- getColumnSortingFn: function getColumnSortingFn(columnId) {
2712
- var _ref;
2713
-
2714
- var column = instance.getColumn(columnId);
2715
- var userSortTypes = instance.options.sortTypes;
2716
-
2717
- if (!column) {
2718
- throw new Error();
2719
- }
2720
-
2721
- 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];
2722
- },
2723
- setSorting: function setSorting(updater) {
2724
- return instance.options.onSortingChange == null ? void 0 : instance.options.onSortingChange(updater, functionalUpdate(updater, instance.getState().sorting));
2725
- },
2726
- toggleColumnSorting: function toggleColumnSorting(columnId, desc, multi) {
2727
- var column = instance.getColumn(columnId);
2728
-
2729
- if (!column) {
2730
- throw new Error();
2731
- } // if (column.columns.length) {
2732
- // column.columns.forEach((c, i) => {
2733
- // if (c.id) {
2734
- // instance.toggleColumnSorting(c.id, undefined, multi || !!i)
2735
- // }
2736
- // })
2737
- // return
2738
- // }
2739
-
2740
-
2741
- instance.setSorting(function (old) {
2742
- var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
2743
-
2744
- // Find any existing sorting for this column
2745
- var existingSorting = old == null ? void 0 : old.find(function (d) {
2746
- return d.id === columnId;
2747
- });
2748
- var existingIndex = old == null ? void 0 : old.findIndex(function (d) {
2749
- return d.id === columnId;
2750
- });
2751
- var hasDescDefined = typeof desc !== 'undefined' && desc !== null;
2752
- var newSorting = []; // What should we do with this sort action?
2753
-
2754
- var sortAction;
2755
-
2756
- if (column.getCanMultiSort() && multi) {
2757
- if (existingSorting) {
2758
- sortAction = 'toggle';
2759
- } else {
2760
- sortAction = 'add';
2761
- }
2762
- } else {
2763
- // Normal mode
2764
- if (old != null && old.length && existingIndex !== old.length - 1) {
2765
- sortAction = 'replace';
2766
- } else if (existingSorting) {
2767
- sortAction = 'toggle';
2768
- } else {
2769
- sortAction = 'replace';
2770
- }
2771
- }
2772
-
2773
- 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
2774
-
2775
- if (sortAction === 'toggle' && ( // Must be toggling
2776
- (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
2777
- !hasDescDefined && ( // Must not be setting desc
2778
- multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
2779
- existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
2780
- ? !sortDescFirst : sortDescFirst)) {
2781
- sortAction = 'remove';
2782
- }
2783
-
2784
- if (sortAction === 'replace') {
2785
- newSorting = [{
2786
- id: columnId,
2787
- desc: hasDescDefined ? desc : !!sortDescFirst
2788
- }];
2789
- } else if (sortAction === 'add' && old != null && old.length) {
2790
- var _instance$options$max;
2917
+ if (isNaN(combo[0])) {
2918
+ if (aa > bb) {
2919
+ return 1;
2920
+ }
2791
2921
 
2792
- newSorting = [].concat(old, [{
2793
- id: columnId,
2794
- desc: hasDescDefined ? desc : !!sortDescFirst
2795
- }]); // Take latest n columns
2922
+ if (bb > aa) {
2923
+ return -1;
2924
+ }
2796
2925
 
2797
- newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
2798
- } else if (sortAction === 'toggle' && old != null && old.length) {
2799
- // This flips (or sets) the
2800
- newSorting = old.map(function (d) {
2801
- if (d.id === columnId) {
2802
- return _extends({}, d, {
2803
- desc: hasDescDefined ? desc : !(existingSorting != null && existingSorting.desc)
2804
- });
2805
- }
2926
+ continue;
2927
+ } // One is a string, one is a number
2806
2928
 
2807
- return d;
2808
- });
2809
- } else if (sortAction === 'remove' && old != null && old.length) {
2810
- newSorting = old.filter(function (d) {
2811
- return d.id !== columnId;
2812
- });
2813
- }
2814
2929
 
2815
- return newSorting;
2816
- });
2817
- },
2818
- getColumnCanSort: function getColumnCanSort(columnId) {
2819
- var _ref3, _ref4, _column$enableSorting;
2930
+ if (isNaN(combo[1])) {
2931
+ return isNaN(an) ? -1 : 1;
2932
+ } // Both are numbers
2820
2933
 
2821
- var column = instance.getColumn(columnId);
2822
2934
 
2823
- if (!column) {
2824
- throw new Error();
2825
- }
2935
+ if (an > bn) {
2936
+ return 1;
2937
+ }
2826
2938
 
2827
- return (_ref3 = (_ref4 = (_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : instance.options.enableSorting) != null ? _ref4 : column.defaultCanSort) != null ? _ref3 : !!column.accessorFn // (!!column.accessorFn ||
2828
- // column.columns?.some(c => c.id && instance.getColumnCanSort(c.id))) ??
2829
- // false
2830
- ;
2831
- },
2832
- getColumnCanMultiSort: function getColumnCanMultiSort(columnId) {
2833
- var _ref5, _column$enableMultiSo;
2939
+ if (bn > an) {
2940
+ return -1;
2941
+ }
2942
+ }
2834
2943
 
2835
- var column = instance.getColumn(columnId);
2944
+ return a.length - b.length;
2945
+ } // The text filter is more basic (less numeric support)
2946
+ // but is much faster
2836
2947
 
2837
- if (!column) {
2838
- throw new Error();
2839
- }
2840
2948
 
2841
- return (_ref5 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref5 : !!column.accessorFn;
2842
- },
2843
- getColumnIsSorted: function getColumnIsSorted(columnId) {
2844
- var _instance$getState$so;
2949
+ function text(rowA, rowB, columnId) {
2950
+ return compareBasic(toString(rowA.values[columnId]).toLowerCase(), toString(rowB.values[columnId]).toLowerCase());
2951
+ } // The text filter is more basic (less numeric support)
2952
+ // but is much faster
2845
2953
 
2846
- var columnSort = (_instance$getState$so = instance.getState().sorting) == null ? void 0 : _instance$getState$so.find(function (d) {
2847
- return d.id === columnId;
2848
- });
2849
- return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
2850
- },
2851
- getColumnSortIndex: function getColumnSortIndex(columnId) {
2852
- var _instance$getState$so2, _instance$getState$so3;
2853
2954
 
2854
- return (_instance$getState$so2 = (_instance$getState$so3 = instance.getState().sorting) == null ? void 0 : _instance$getState$so3.findIndex(function (d) {
2855
- return d.id === columnId;
2856
- })) != null ? _instance$getState$so2 : -1;
2857
- },
2858
- resetSorting: function resetSorting() {
2859
- var _instance$initialStat, _instance$initialStat2;
2955
+ function textCaseSensitive(rowA, rowB, columnId) {
2956
+ return compareBasic(toString(rowA.values[columnId]), toString(rowB.values[columnId]));
2957
+ }
2860
2958
 
2861
- instance.setSorting((_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.sorting) != null ? _instance$initialStat : []);
2862
- },
2863
- getToggleSortingProps: function getToggleSortingProps(columnId, userProps) {
2864
- var column = instance.getColumn(columnId);
2959
+ function datetime(rowA, rowB, columnId) {
2960
+ return compareBasic(rowA.values[columnId].getTime(), rowB.values[columnId].getTime());
2961
+ }
2865
2962
 
2866
- if (!column) {
2867
- throw new Error();
2868
- }
2963
+ function basic(rowA, rowB, columnId) {
2964
+ return compareBasic(rowA.values[columnId], rowB.values[columnId]);
2965
+ } // Utils
2869
2966
 
2870
- var canSort = column.getCanSort();
2871
- var initialProps = {
2872
- title: canSort ? 'Toggle Sorting' : undefined,
2873
- onClick: canSort ? function (e) {
2874
- e.persist();
2875
- column.toggleSorting == null ? void 0 : column.toggleSorting(undefined, column.getCanMultiSort() ? instance.options.isMultiSortEvent == null ? void 0 : instance.options.isMultiSortEvent(e) : false);
2876
- } : undefined
2877
- };
2878
- return propGetter(initialProps, userProps);
2879
- },
2880
- getSortedRowModel: memo(function () {
2881
- return [instance.getState().sorting, instance.getGlobalFilteredRowModel(), instance.options.sortRowsFn];
2882
- }, function (sorting, rowModel, sortingFn) {
2883
- if (!sortingFn || !(sorting != null && sorting.length)) {
2884
- return rowModel;
2885
- }
2886
2967
 
2887
- if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Sorting...');
2888
- return sortingFn(instance, rowModel);
2889
- }, {
2890
- key: 'getSortedRowModel',
2891
- debug: instance.options.debug,
2892
- onChange: function onChange() {
2893
- return instance._notifyGroupingReset();
2894
- }
2895
- }),
2896
- getPreSortedRows: function getPreSortedRows() {
2897
- return instance.getGlobalFilteredRowModel().rows;
2898
- },
2899
- getPreSortedFlatRows: function getPreSortedFlatRows() {
2900
- return instance.getGlobalFilteredRowModel().flatRows;
2901
- },
2902
- getPreSortedRowsById: function getPreSortedRowsById() {
2903
- return instance.getGlobalFilteredRowModel().rowsById;
2904
- },
2905
- getSortedRows: function getSortedRows() {
2906
- return instance.getSortedRowModel().rows;
2907
- },
2908
- getSortedFlatRows: function getSortedFlatRows() {
2909
- return instance.getSortedRowModel().flatRows;
2910
- },
2911
- getSortedRowsById: function getSortedRowsById() {
2912
- return instance.getSortedRowModel().rowsById;
2913
- }
2914
- };
2968
+ function compareBasic(a, b) {
2969
+ return a === b ? 0 : a > b ? 1 : -1;
2915
2970
  }
2916
2971
 
2917
- var Sorting = /*#__PURE__*/Object.freeze({
2918
- __proto__: null,
2919
- getDefaultColumn: getDefaultColumn,
2920
- getInitialState: getInitialState$4,
2921
- getDefaultOptions: getDefaultOptions$4,
2922
- createColumn: createColumn$1,
2923
- getInstance: getInstance$4
2924
- });
2972
+ function toString(a) {
2973
+ if (typeof a === 'number') {
2974
+ if (isNaN(a) || a === Infinity || a === -Infinity) {
2975
+ return '';
2976
+ }
2977
+
2978
+ return String(a);
2979
+ }
2980
+
2981
+ if (typeof a === 'string') {
2982
+ return a;
2983
+ }
2984
+
2985
+ return '';
2986
+ }
2925
2987
 
2926
2988
  //
2989
+ function getDefaultColumn() {
2990
+ return {
2991
+ sortType: 'auto'
2992
+ };
2993
+ }
2927
2994
  function getInitialState$3() {
2928
2995
  return {
2929
- expanded: {}
2996
+ sorting: []
2930
2997
  };
2931
2998
  }
2932
2999
  function getDefaultOptions$3(instance) {
2933
3000
  return {
2934
- onExpandedChange: makeStateUpdater('expanded', instance),
2935
- autoResetExpanded: true,
2936
- getIsRowExpanded: function getIsRowExpanded(row) {
2937
- return !!(row == null ? void 0 : row.original).expanded;
3001
+ onSortingChange: makeStateUpdater('sorting', instance),
3002
+ autoResetSorting: true,
3003
+ isMultiSortEvent: function isMultiSortEvent(e) {
3004
+ return e.shiftKey;
3005
+ }
3006
+ };
3007
+ }
3008
+ function createColumn(column, instance) {
3009
+ return {
3010
+ sortType: column.sortType,
3011
+ getCanSort: function getCanSort() {
3012
+ return instance.getColumnCanSort(column.id);
2938
3013
  },
2939
- expandSubRows: true,
2940
- paginateExpandedRows: true
3014
+ getCanMultiSort: function getCanMultiSort() {
3015
+ return instance.getColumnCanMultiSort(column.id);
3016
+ },
3017
+ getSortIndex: function getSortIndex() {
3018
+ return instance.getColumnSortIndex(column.id);
3019
+ },
3020
+ getIsSorted: function getIsSorted() {
3021
+ return instance.getColumnIsSorted(column.id);
3022
+ },
3023
+ toggleSorting: function toggleSorting(desc, isMulti) {
3024
+ return instance.toggleColumnSorting(column.id, desc, isMulti);
3025
+ },
3026
+ getToggleSortingProps: function getToggleSortingProps(userProps) {
3027
+ return instance.getToggleSortingProps(column.id, userProps);
3028
+ }
2941
3029
  };
2942
3030
  }
2943
3031
  function getInstance$3(instance) {
2944
3032
  var registered = false;
2945
3033
  return {
2946
- _notifyExpandedReset: function _notifyExpandedReset() {
3034
+ _notifySortingReset: function _notifySortingReset() {
2947
3035
  if (!registered) {
2948
3036
  registered = true;
2949
3037
  return;
@@ -2953,285 +3041,170 @@ function getInstance$3(instance) {
2953
3041
  return;
2954
3042
  }
2955
3043
 
2956
- if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
2957
- instance.resetExpanded();
3044
+ if (instance.options.autoResetAll === true || instance.options.autoResetSorting) {
3045
+ instance.resetSorting();
2958
3046
  }
2959
3047
  },
2960
- setExpanded: function setExpanded(updater) {
2961
- return instance.options.onExpandedChange == null ? void 0 : instance.options.onExpandedChange(updater, functionalUpdate(updater, instance.getState().expanded));
2962
- },
2963
- toggleRowExpanded: function toggleRowExpanded(rowId, expanded) {
2964
- if (!rowId) return;
2965
- instance.setExpanded(function (old) {
2966
- var _expanded;
2967
-
2968
- var exists = old === true ? true : !!(old != null && old[rowId]);
2969
- var oldExpanded = {};
2970
-
2971
- if (old === true) {
2972
- Object.keys(instance.getRowsById()).forEach(function (rowId) {
2973
- oldExpanded[rowId] = true;
2974
- });
2975
- } else {
2976
- oldExpanded = old;
2977
- }
2978
-
2979
- expanded = (_expanded = expanded) != null ? _expanded : !exists;
2980
-
2981
- if (!exists && expanded) {
2982
- var _extends2;
2983
-
2984
- return _extends({}, oldExpanded, (_extends2 = {}, _extends2[rowId] = true, _extends2));
2985
- }
3048
+ getColumnAutoSortingFn: function getColumnAutoSortingFn(columnId) {
3049
+ var firstRows = instance.getGlobalFilteredRowModel().flatRows.slice(100);
3050
+ var isString = false;
2986
3051
 
2987
- if (exists && !expanded) {
2988
- var _oldExpanded = oldExpanded;
2989
- _oldExpanded[rowId];
2990
- var rest = _objectWithoutPropertiesLoose(_oldExpanded, [rowId].map(_toPropertyKey));
3052
+ for (var _iterator = _createForOfIteratorHelperLoose(firstRows), _step; !(_step = _iterator()).done;) {
3053
+ var row = _step.value;
3054
+ var value = row == null ? void 0 : row.values[columnId];
2991
3055
 
2992
- return rest;
3056
+ if (Object.prototype.toString.call(value) === '[object Date]') {
3057
+ return sortTypes.datetime;
2993
3058
  }
2994
3059
 
2995
- return old;
2996
- });
2997
- },
2998
- toggleAllRowsExpanded: function toggleAllRowsExpanded(expanded) {
2999
- if (expanded != null ? expanded : !instance.getIsAllRowsExpanded()) {
3000
- instance.setExpanded(true);
3001
- } else {
3002
- instance.setExpanded({});
3003
- }
3004
- },
3005
- resetExpanded: function resetExpanded() {
3006
- var _instance$initialStat, _instance$initialStat2;
3007
-
3008
- instance.setExpanded((_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.expanded) != null ? _instance$initialStat : {});
3009
- },
3010
- getIsRowExpanded: function getIsRowExpanded(rowId) {
3011
- var _instance$options$get;
3012
-
3013
- var row = instance.getRow(rowId);
3060
+ if (typeof value === 'string') {
3061
+ isString = true;
3014
3062
 
3015
- if (!row) {
3016
- if (process.env.NODE_ENV !== 'production') {
3017
- console.warn("[ReactTable] getIsRowExpanded: no row found with id " + rowId);
3063
+ if (value.split(reSplitAlphaNumeric).length > 1) {
3064
+ return sortTypes.alphanumeric;
3065
+ }
3018
3066
  }
3067
+ }
3019
3068
 
3020
- throw new Error();
3069
+ if (isString) {
3070
+ return sortTypes.text;
3021
3071
  }
3022
3072
 
3023
- var expanded = instance.getState().expanded;
3024
- 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]));
3073
+ return sortTypes.basic;
3025
3074
  },
3026
- getRowCanExpand: function getRowCanExpand(rowId) {
3027
- var _ref, _ref2, _instance$options$get2, _row$subRows;
3028
-
3029
- var row = instance.getRow(rowId);
3030
-
3031
- if (!row) {
3032
- if (process.env.NODE_ENV !== 'production') {
3033
- console.warn("[ReactTable] getRowCanExpand: no row found with id " + rowId);
3034
- }
3075
+ getColumnAutoSortDir: function getColumnAutoSortDir(columnId) {
3076
+ var firstRow = instance.getGlobalFilteredRowModel().flatRows[0];
3077
+ var value = firstRow == null ? void 0 : firstRow.values[columnId];
3035
3078
 
3036
- throw new Error();
3079
+ if (typeof value === 'string') {
3080
+ return 'asc';
3037
3081
  }
3038
3082
 
3039
- 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);
3083
+ return 'desc';
3040
3084
  },
3041
- getToggleExpandedProps: function getToggleExpandedProps(rowId, userProps) {
3042
- var row = instance.getRow(rowId);
3085
+ getColumnSortingFn: function getColumnSortingFn(columnId) {
3086
+ var _ref;
3043
3087
 
3044
- if (!row) {
3045
- return;
3088
+ var column = instance.getColumn(columnId);
3089
+ var userSortTypes = instance.options.sortTypes;
3090
+
3091
+ if (!column) {
3092
+ throw new Error();
3046
3093
  }
3047
3094
 
3048
- var canExpand = instance.getRowCanExpand(rowId);
3049
- var initialProps = {
3050
- title: canExpand ? 'Toggle Expanded' : undefined,
3051
- onClick: canExpand ? function (e) {
3052
- e.persist();
3053
- instance.toggleRowExpanded(rowId);
3054
- } : undefined
3055
- };
3056
- return propGetter(initialProps, userProps);
3095
+ 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];
3057
3096
  },
3058
- getToggleAllRowsExpandedProps: function getToggleAllRowsExpandedProps(userProps) {
3059
- var initialProps = {
3060
- title: 'Toggle All Expanded',
3061
- onClick: function onClick(e) {
3062
- e.persist();
3063
- instance.toggleAllRowsExpanded();
3064
- }
3065
- };
3066
- return propGetter(initialProps, userProps);
3097
+ setSorting: function setSorting(updater) {
3098
+ return instance.options.onSortingChange == null ? void 0 : instance.options.onSortingChange(updater, functionalUpdate(updater, instance.getState().sorting));
3067
3099
  },
3068
- getIsAllRowsExpanded: function getIsAllRowsExpanded() {
3069
- var expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
3100
+ toggleColumnSorting: function toggleColumnSorting(columnId, desc, multi) {
3101
+ var column = instance.getColumn(columnId);
3070
3102
 
3071
- if (expanded === true) {
3072
- return true;
3073
- } // If any row is not expanded, return false
3103
+ if (!column) {
3104
+ throw new Error();
3105
+ } // if (column.columns.length) {
3106
+ // column.columns.forEach((c, i) => {
3107
+ // if (c.id) {
3108
+ // instance.toggleColumnSorting(c.id, undefined, multi || !!i)
3109
+ // }
3110
+ // })
3111
+ // return
3112
+ // }
3074
3113
 
3075
3114
 
3076
- if (Object.keys(instance.getRowsById()).some(function (id) {
3077
- return !instance.getIsRowExpanded(id);
3078
- })) {
3079
- return false;
3080
- } // They must all be expanded :shrug:
3115
+ instance.setSorting(function (old) {
3116
+ var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
3081
3117
 
3118
+ // Find any existing sorting for this column
3119
+ var existingSorting = old == null ? void 0 : old.find(function (d) {
3120
+ return d.id === columnId;
3121
+ });
3122
+ var existingIndex = old == null ? void 0 : old.findIndex(function (d) {
3123
+ return d.id === columnId;
3124
+ });
3125
+ var hasDescDefined = typeof desc !== 'undefined' && desc !== null;
3126
+ var newSorting = []; // What should we do with this sort action?
3082
3127
 
3083
- return true;
3084
- },
3085
- getExpandedDepth: function getExpandedDepth() {
3086
- var maxDepth = 0;
3087
- var rowIds = instance.getState().expanded === true ? Object.keys(instance.getRowsById()) : Object.keys(instance.getState().expanded);
3088
- rowIds.forEach(function (id) {
3089
- var splitId = id.split('.');
3090
- maxDepth = Math.max(maxDepth, splitId.length);
3091
- });
3092
- return maxDepth;
3093
- },
3094
- getExpandedRowModel: memo(function () {
3095
- return [instance.getState().expanded, instance.getGroupedRowModel(), instance.options.expandRowsFn, instance.options.paginateExpandedRows];
3096
- }, function (expanded, rowModel, expandRowsFn, paginateExpandedRows) {
3097
- if (!expandRowsFn || // Do not expand if rows are not included in pagination
3098
- !paginateExpandedRows || !Object.keys(expanded != null ? expanded : {}).length) {
3099
- return rowModel;
3100
- }
3128
+ var sortAction;
3101
3129
 
3102
- if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Expanding...');
3103
- return expandRowsFn(instance, rowModel);
3104
- }, {
3105
- key: 'getExpandedRowModel',
3106
- debug: instance.options.debug,
3107
- onChange: function onChange() {
3108
- instance._notifyPageIndexReset();
3109
- }
3110
- }),
3111
- getPreExpandedRows: function getPreExpandedRows() {
3112
- return instance.getGroupedRowModel().rows;
3113
- },
3114
- getPreExpandedFlatRows: function getPreExpandedFlatRows() {
3115
- return instance.getGroupedRowModel().flatRows;
3116
- },
3117
- getPreExpandedRowsById: function getPreExpandedRowsById() {
3118
- return instance.getGroupedRowModel().rowsById;
3119
- },
3120
- getExpandedRows: function getExpandedRows() {
3121
- return instance.getExpandedRowModel().rows;
3122
- },
3123
- getExpandedFlatRows: function getExpandedFlatRows() {
3124
- return instance.getExpandedRowModel().flatRows;
3125
- },
3126
- getExpandedRowsById: function getExpandedRowsById() {
3127
- return instance.getExpandedRowModel().rowsById;
3128
- }
3129
- };
3130
- }
3131
- function createRow$1(row, instance) {
3132
- return {
3133
- toggleExpanded: function toggleExpanded(expanded) {
3134
- return void instance.toggleRowExpanded(row.id, expanded);
3135
- },
3136
- getIsExpanded: function getIsExpanded() {
3137
- return instance.getIsRowExpanded(row.id);
3138
- },
3139
- getCanExpand: function getCanExpand() {
3140
- return row.subRows && !!row.subRows.length;
3141
- },
3142
- getToggleExpandedProps: function getToggleExpandedProps(userProps) {
3143
- var initialProps = {
3144
- title: 'Toggle Row Expanded',
3145
- onClick: function onClick(e) {
3146
- e.stopPropagation();
3147
- instance.toggleRowExpanded(row.id);
3130
+ if (column.getCanMultiSort() && multi) {
3131
+ if (existingSorting) {
3132
+ sortAction = 'toggle';
3133
+ } else {
3134
+ sortAction = 'add';
3135
+ }
3136
+ } else {
3137
+ // Normal mode
3138
+ if (old != null && old.length && existingIndex !== old.length - 1) {
3139
+ sortAction = 'replace';
3140
+ } else if (existingSorting) {
3141
+ sortAction = 'toggle';
3142
+ } else {
3143
+ sortAction = 'replace';
3144
+ }
3148
3145
  }
3149
- };
3150
- return propGetter(initialProps, userProps);
3151
- }
3152
- };
3153
- }
3154
3146
 
3155
- var Expanding = /*#__PURE__*/Object.freeze({
3156
- __proto__: null,
3157
- getInitialState: getInitialState$3,
3158
- getDefaultOptions: getDefaultOptions$3,
3159
- getInstance: getInstance$3,
3160
- createRow: createRow$1
3161
- });
3147
+ 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
3162
3148
 
3163
- //
3164
- var defaultColumnSizing = {
3165
- width: 150,
3166
- minWidth: 20,
3167
- maxWidth: Number.MAX_SAFE_INTEGER
3168
- };
3169
- function getInitialState$2() {
3170
- return {
3171
- columnSizing: {},
3172
- columnSizingInfo: {
3173
- startOffset: null,
3174
- startSize: null,
3175
- deltaOffset: null,
3176
- deltaPercentage: null,
3177
- isResizingColumn: false,
3178
- columnSizingStart: []
3179
- }
3180
- };
3181
- }
3182
- function getDefaultOptions$2(instance) {
3183
- return {
3184
- columnResizeMode: 'onEnd',
3185
- onColumnSizingChange: makeStateUpdater('columnSizing', instance),
3186
- onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', instance)
3187
- };
3188
- }
3189
- function getInstance$2(instance) {
3190
- return {
3191
- setColumnSizing: function setColumnSizing(updater) {
3192
- return instance.options.onColumnSizingChange == null ? void 0 : instance.options.onColumnSizingChange(updater, functionalUpdate(updater, instance.getState().columnSizing));
3193
- },
3194
- setColumnSizingInfo: function setColumnSizingInfo(updater) {
3195
- return instance.options.onColumnSizingInfoChange == null ? void 0 : instance.options.onColumnSizingInfoChange(updater, functionalUpdate(updater, instance.getState().columnSizingInfo));
3196
- },
3197
- resetColumnSizing: function resetColumnSizing() {
3198
- var _instance$initialStat;
3149
+ if (sortAction === 'toggle' && ( // Must be toggling
3150
+ (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
3151
+ !hasDescDefined && ( // Must not be setting desc
3152
+ multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
3153
+ existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
3154
+ ? !sortDescFirst : sortDescFirst)) {
3155
+ sortAction = 'remove';
3156
+ }
3199
3157
 
3200
- instance.setColumnSizing((_instance$initialStat = instance.initialState.columnSizing) != null ? _instance$initialStat : {});
3201
- },
3202
- resetHeaderSizeInfo: function resetHeaderSizeInfo() {
3203
- var _instance$initialStat2;
3158
+ if (sortAction === 'replace') {
3159
+ newSorting = [{
3160
+ id: columnId,
3161
+ desc: hasDescDefined ? desc : !!sortDescFirst
3162
+ }];
3163
+ } else if (sortAction === 'add' && old != null && old.length) {
3164
+ var _instance$options$max;
3204
3165
 
3205
- instance.setColumnSizingInfo((_instance$initialStat2 = instance.initialState.columnSizingInfo) != null ? _instance$initialStat2 : {});
3206
- },
3207
- resetColumnSize: function resetColumnSize(columnId) {
3208
- instance.setColumnSizing(function (_ref) {
3209
- _ref[columnId];
3210
- var rest = _objectWithoutPropertiesLoose(_ref, [columnId].map(_toPropertyKey));
3166
+ newSorting = [].concat(old, [{
3167
+ id: columnId,
3168
+ desc: hasDescDefined ? desc : !!sortDescFirst
3169
+ }]); // Take latest n columns
3211
3170
 
3212
- return rest;
3171
+ newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
3172
+ } else if (sortAction === 'toggle' && old != null && old.length) {
3173
+ // This flips (or sets) the
3174
+ newSorting = old.map(function (d) {
3175
+ if (d.id === columnId) {
3176
+ return _extends({}, d, {
3177
+ desc: hasDescDefined ? desc : !(existingSorting != null && existingSorting.desc)
3178
+ });
3179
+ }
3180
+
3181
+ return d;
3182
+ });
3183
+ } else if (sortAction === 'remove' && old != null && old.length) {
3184
+ newSorting = old.filter(function (d) {
3185
+ return d.id !== columnId;
3186
+ });
3187
+ }
3188
+
3189
+ return newSorting;
3213
3190
  });
3214
3191
  },
3215
- resetHeaderSize: function resetHeaderSize(headerId) {
3216
- var header = instance.getHeader(headerId);
3217
-
3218
- if (!header) {
3219
- return;
3220
- }
3192
+ getColumnCanSort: function getColumnCanSort(columnId) {
3193
+ var _ref3, _ref4, _column$enableSorting;
3221
3194
 
3222
- return instance.resetColumnSize(header.column.id);
3223
- },
3224
- getHeaderCanResize: function getHeaderCanResize(headerId) {
3225
- var header = instance.getHeader(headerId);
3195
+ var column = instance.getColumn(columnId);
3226
3196
 
3227
- if (!header) {
3197
+ if (!column) {
3228
3198
  throw new Error();
3229
3199
  }
3230
3200
 
3231
- return instance.getColumnCanResize(header.column.id);
3201
+ return (_ref3 = (_ref4 = (_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : instance.options.enableSorting) != null ? _ref4 : column.defaultCanSort) != null ? _ref3 : !!column.accessorFn // (!!column.accessorFn ||
3202
+ // column.columns?.some(c => c.id && instance.getColumnCanSort(c.id))) ??
3203
+ // false
3204
+ ;
3232
3205
  },
3233
- getColumnCanResize: function getColumnCanResize(columnId) {
3234
- var _ref2, _ref3, _column$enableResizin;
3206
+ getColumnCanMultiSort: function getColumnCanMultiSort(columnId) {
3207
+ var _ref5, _column$enableMultiSo;
3235
3208
 
3236
3209
  var column = instance.getColumn(columnId);
3237
3210
 
@@ -3239,234 +3212,309 @@ function getInstance$2(instance) {
3239
3212
  throw new Error();
3240
3213
  }
3241
3214
 
3242
- return (_ref2 = (_ref3 = (_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : instance.options.enableColumnResizing) != null ? _ref3 : column.defaultCanResize) != null ? _ref2 : true;
3215
+ return (_ref5 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref5 : !!column.accessorFn;
3243
3216
  },
3244
- getColumnIsResizing: function getColumnIsResizing(columnId) {
3217
+ getColumnIsSorted: function getColumnIsSorted(columnId) {
3218
+ var _instance$getState$so;
3219
+
3220
+ var columnSort = (_instance$getState$so = instance.getState().sorting) == null ? void 0 : _instance$getState$so.find(function (d) {
3221
+ return d.id === columnId;
3222
+ });
3223
+ return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
3224
+ },
3225
+ getColumnSortIndex: function getColumnSortIndex(columnId) {
3226
+ var _instance$getState$so2, _instance$getState$so3;
3227
+
3228
+ return (_instance$getState$so2 = (_instance$getState$so3 = instance.getState().sorting) == null ? void 0 : _instance$getState$so3.findIndex(function (d) {
3229
+ return d.id === columnId;
3230
+ })) != null ? _instance$getState$so2 : -1;
3231
+ },
3232
+ resetSorting: function resetSorting() {
3233
+ var _instance$initialStat, _instance$initialStat2;
3234
+
3235
+ instance.setSorting((_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.sorting) != null ? _instance$initialStat : []);
3236
+ },
3237
+ getToggleSortingProps: function getToggleSortingProps(columnId, userProps) {
3245
3238
  var column = instance.getColumn(columnId);
3246
3239
 
3247
3240
  if (!column) {
3248
3241
  throw new Error();
3249
3242
  }
3250
3243
 
3251
- return instance.getState().columnSizingInfo.isResizingColumn === columnId;
3244
+ var canSort = column.getCanSort();
3245
+ var initialProps = {
3246
+ title: canSort ? 'Toggle Sorting' : undefined,
3247
+ onClick: canSort ? function (e) {
3248
+ e.persist();
3249
+ column.toggleSorting == null ? void 0 : column.toggleSorting(undefined, column.getCanMultiSort() ? instance.options.isMultiSortEvent == null ? void 0 : instance.options.isMultiSortEvent(e) : false);
3250
+ } : undefined
3251
+ };
3252
+ return propGetter(initialProps, userProps);
3252
3253
  },
3253
- getHeaderIsResizing: function getHeaderIsResizing(headerId) {
3254
- var header = instance.getHeader(headerId);
3254
+ getPreSortedRowModel: function getPreSortedRowModel() {
3255
+ return instance.getGlobalFilteredRowModel();
3256
+ },
3257
+ getSortedRowModel: memo(function () {
3258
+ return [instance.getState().sorting, instance.getGlobalFilteredRowModel(), instance.options.sortRowsFn];
3259
+ }, function (sorting, rowModel, sortingFn) {
3260
+ if (!sortingFn || !(sorting != null && sorting.length)) {
3261
+ return rowModel;
3262
+ }
3255
3263
 
3256
- if (!header) {
3257
- throw new Error();
3264
+ return sortingFn(instance, rowModel);
3265
+ }, {
3266
+ key: 'getSortedRowModel',
3267
+ debug: function debug() {
3268
+ var _instance$options$deb;
3269
+
3270
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3271
+ },
3272
+ onChange: function onChange() {
3273
+ instance._notifyGroupingReset();
3258
3274
  }
3275
+ })
3276
+ };
3277
+ }
3259
3278
 
3260
- return instance.getColumnIsResizing(header.column.id);
3261
- },
3262
- getColumnResizerProps: function getColumnResizerProps(headerId, userProps) {
3263
- var header = instance.getHeader(headerId);
3279
+ var Sorting = /*#__PURE__*/Object.freeze({
3280
+ __proto__: null,
3281
+ getDefaultColumn: getDefaultColumn,
3282
+ getInitialState: getInitialState$3,
3283
+ getDefaultOptions: getDefaultOptions$3,
3284
+ createColumn: createColumn,
3285
+ getInstance: getInstance$3
3286
+ });
3264
3287
 
3265
- if (!header) {
3288
+ //
3289
+ function getInitialState$2() {
3290
+ return {
3291
+ expanded: {}
3292
+ };
3293
+ }
3294
+ function getDefaultOptions$2(instance) {
3295
+ return {
3296
+ onExpandedChange: makeStateUpdater('expanded', instance),
3297
+ autoResetExpanded: true,
3298
+ getIsRowExpanded: function getIsRowExpanded(row) {
3299
+ return !!(row == null ? void 0 : row.original).expanded;
3300
+ },
3301
+ expandSubRows: true,
3302
+ paginateExpandedRows: true
3303
+ };
3304
+ }
3305
+ function getInstance$2(instance) {
3306
+ var registered = false;
3307
+ return {
3308
+ _notifyExpandedReset: function _notifyExpandedReset() {
3309
+ if (!registered) {
3310
+ registered = true;
3266
3311
  return;
3267
3312
  }
3268
3313
 
3269
- var column = instance.getColumn(header.column.id);
3270
-
3271
- if (!column) {
3314
+ if (instance.options.autoResetAll === false) {
3272
3315
  return;
3273
3316
  }
3274
3317
 
3275
- var canResize = column.getCanResize();
3318
+ if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
3319
+ instance.resetExpanded();
3320
+ }
3321
+ },
3322
+ setExpanded: function setExpanded(updater) {
3323
+ return instance.options.onExpandedChange == null ? void 0 : instance.options.onExpandedChange(updater, functionalUpdate(updater, instance.getState().expanded));
3324
+ },
3325
+ toggleRowExpanded: function toggleRowExpanded(rowId, expanded) {
3326
+ if (!rowId) return;
3327
+ instance.setExpanded(function (old) {
3328
+ var _expanded;
3276
3329
 
3277
- var onResizeStart = function onResizeStart(e) {
3278
- if (isTouchStartEvent(e)) {
3279
- // lets not respond to multiple touches (e.g. 2 or 3 fingers)
3280
- if (e.touches && e.touches.length > 1) {
3281
- return;
3282
- }
3330
+ var exists = old === true ? true : !!(old != null && old[rowId]);
3331
+ var oldExpanded = {};
3332
+
3333
+ if (old === true) {
3334
+ Object.keys(instance.getRowModel().rowsById).forEach(function (rowId) {
3335
+ oldExpanded[rowId] = true;
3336
+ });
3337
+ } else {
3338
+ oldExpanded = old;
3283
3339
  }
3284
3340
 
3285
- var columnSizingStart = header.getLeafHeaders().map(function (d) {
3286
- return [d.column.id, d.getWidth()];
3287
- });
3288
- var clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
3341
+ expanded = (_expanded = expanded) != null ? _expanded : !exists;
3289
3342
 
3290
- var updateOffset = function updateOffset(eventType, clientXPos) {
3291
- if (typeof clientXPos !== 'number') {
3292
- return;
3293
- }
3343
+ if (!exists && expanded) {
3344
+ var _extends2;
3294
3345
 
3295
- var newColumnSizing = {};
3296
- instance.setColumnSizingInfo(function (old) {
3297
- var _old$startOffset, _old$startSize;
3346
+ return _extends({}, oldExpanded, (_extends2 = {}, _extends2[rowId] = true, _extends2));
3347
+ }
3298
3348
 
3299
- var deltaOffset = clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0);
3300
- var deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
3301
- old.columnSizingStart.forEach(function (_ref4) {
3302
- var columnId = _ref4[0],
3303
- headerWidth = _ref4[1];
3304
- newColumnSizing[columnId] = Math.max(headerWidth + headerWidth * deltaPercentage, 0);
3305
- });
3306
- return _extends({}, old, {
3307
- deltaOffset: deltaOffset,
3308
- deltaPercentage: deltaPercentage
3309
- });
3310
- });
3349
+ if (exists && !expanded) {
3350
+ var _oldExpanded = oldExpanded;
3351
+ _oldExpanded[rowId];
3352
+ var rest = _objectWithoutPropertiesLoose(_oldExpanded, [rowId].map(_toPropertyKey));
3311
3353
 
3312
- if (instance.options.columnResizeMode === 'onChange' || eventType === 'end') {
3313
- instance.setColumnSizing(function (old) {
3314
- return _extends({}, old, newColumnSizing);
3315
- });
3316
- }
3317
- };
3354
+ return rest;
3355
+ }
3318
3356
 
3319
- var onMove = function onMove(clientXPos) {
3320
- return updateOffset('move', clientXPos);
3321
- };
3357
+ return old;
3358
+ });
3359
+ },
3360
+ toggleAllRowsExpanded: function toggleAllRowsExpanded(expanded) {
3361
+ if (expanded != null ? expanded : !instance.getIsAllRowsExpanded()) {
3362
+ instance.setExpanded(true);
3363
+ } else {
3364
+ instance.setExpanded({});
3365
+ }
3366
+ },
3367
+ resetExpanded: function resetExpanded() {
3368
+ var _instance$initialStat, _instance$initialStat2;
3322
3369
 
3323
- var onEnd = function onEnd(clientXPos) {
3324
- updateOffset('end', clientXPos);
3325
- instance.setColumnSizingInfo(function (old) {
3326
- return _extends({}, old, {
3327
- isResizingColumn: false,
3328
- startOffset: null,
3329
- startSize: null,
3330
- deltaOffset: null,
3331
- deltaPercentage: null,
3332
- columnSizingStart: []
3333
- });
3334
- });
3335
- };
3370
+ instance.setExpanded((_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.expanded) != null ? _instance$initialStat : {});
3371
+ },
3372
+ getIsRowExpanded: function getIsRowExpanded(rowId) {
3373
+ var _instance$options$get;
3336
3374
 
3337
- var mouseEvents = {
3338
- moveHandler: function moveHandler(e) {
3339
- return onMove(e.clientX);
3340
- },
3341
- upHandler: function upHandler(e) {
3342
- document.removeEventListener('mousemove', mouseEvents.moveHandler);
3343
- document.removeEventListener('mouseup', mouseEvents.upHandler);
3344
- onEnd(e.clientX);
3345
- }
3346
- };
3347
- var touchEvents = {
3348
- moveHandler: function moveHandler(e) {
3349
- if (e.cancelable) {
3350
- e.preventDefault();
3351
- e.stopPropagation();
3352
- }
3375
+ var row = instance.getRow(rowId);
3353
3376
 
3354
- onMove(e.touches[0].clientX);
3355
- return false;
3356
- },
3357
- upHandler: function upHandler(e) {
3358
- document.removeEventListener('touchmove', touchEvents.moveHandler);
3359
- document.removeEventListener('touchend', touchEvents.upHandler);
3377
+ if (!row) {
3378
+ if (process.env.NODE_ENV !== 'production') {
3379
+ console.warn("[ReactTable] getIsRowExpanded: no row found with id " + rowId);
3380
+ }
3360
3381
 
3361
- if (e.cancelable) {
3362
- e.preventDefault();
3363
- e.stopPropagation();
3364
- }
3382
+ throw new Error();
3383
+ }
3365
3384
 
3366
- onEnd(e.touches[0].clientX);
3367
- }
3368
- };
3369
- var passiveIfSupported = passiveEventSupported() ? {
3370
- passive: false
3371
- } : false;
3385
+ var expanded = instance.getState().expanded;
3386
+ 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]));
3387
+ },
3388
+ getRowCanExpand: function getRowCanExpand(rowId) {
3389
+ var _ref, _ref2, _instance$options$get2, _row$subRows;
3372
3390
 
3373
- if (isTouchStartEvent(e)) {
3374
- document.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
3375
- document.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
3376
- } else {
3377
- document.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
3378
- document.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
3391
+ var row = instance.getRow(rowId);
3392
+
3393
+ if (!row) {
3394
+ if (process.env.NODE_ENV !== 'production') {
3395
+ console.warn("[ReactTable] getRowCanExpand: no row found with id " + rowId);
3379
3396
  }
3380
3397
 
3381
- instance.setColumnSizingInfo(function (old) {
3382
- return _extends({}, old, {
3383
- startOffset: clientX,
3384
- startSize: header.getWidth(),
3385
- deltaOffset: 0,
3386
- deltaPercentage: 0,
3387
- columnSizingStart: columnSizingStart,
3388
- isResizingColumn: header.column.id
3389
- });
3390
- });
3391
- };
3398
+ throw new Error();
3399
+ }
3392
3400
 
3393
- var initialProps = canResize ? {
3394
- title: 'Toggle Grouping',
3395
- draggable: false,
3396
- role: 'separator',
3397
- onMouseDown: function onMouseDown(e) {
3401
+ 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);
3402
+ },
3403
+ getToggleExpandedProps: function getToggleExpandedProps(rowId, userProps) {
3404
+ var row = instance.getRow(rowId);
3405
+
3406
+ if (!row) {
3407
+ return;
3408
+ }
3409
+
3410
+ var canExpand = instance.getRowCanExpand(rowId);
3411
+ var initialProps = {
3412
+ title: canExpand ? 'Toggle Expanded' : undefined,
3413
+ onClick: canExpand ? function (e) {
3398
3414
  e.persist();
3399
- onResizeStart(e);
3400
- },
3401
- onTouchStart: function onTouchStart(e) {
3415
+ instance.toggleRowExpanded(rowId);
3416
+ } : undefined
3417
+ };
3418
+ return propGetter(initialProps, userProps);
3419
+ },
3420
+ getToggleAllRowsExpandedProps: function getToggleAllRowsExpandedProps(userProps) {
3421
+ var initialProps = {
3422
+ title: 'Toggle All Expanded',
3423
+ onClick: function onClick(e) {
3402
3424
  e.persist();
3403
- onResizeStart(e);
3425
+ instance.toggleAllRowsExpanded();
3404
3426
  }
3405
- } : {};
3427
+ };
3406
3428
  return propGetter(initialProps, userProps);
3429
+ },
3430
+ getIsAllRowsExpanded: function getIsAllRowsExpanded() {
3431
+ var expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
3432
+
3433
+ if (expanded === true) {
3434
+ return true;
3435
+ } // If any row is not expanded, return false
3436
+
3437
+
3438
+ if (Object.keys(instance.getRowModel().rowsById).some(function (id) {
3439
+ return !instance.getIsRowExpanded(id);
3440
+ })) {
3441
+ return false;
3442
+ } // They must all be expanded :shrug:
3443
+
3444
+
3445
+ return true;
3446
+ },
3447
+ getExpandedDepth: function getExpandedDepth() {
3448
+ var maxDepth = 0;
3449
+ var rowIds = instance.getState().expanded === true ? Object.keys(instance.getRowModel().rowsById) : Object.keys(instance.getState().expanded);
3450
+ rowIds.forEach(function (id) {
3451
+ var splitId = id.split('.');
3452
+ maxDepth = Math.max(maxDepth, splitId.length);
3453
+ });
3454
+ return maxDepth;
3455
+ },
3456
+ getExpandedRowModel: memo(function () {
3457
+ return [instance.getState().expanded, instance.getGroupedRowModel(), instance.options.expandRowsFn, instance.options.paginateExpandedRows];
3458
+ }, function (expanded, rowModel, expandRowsFn, paginateExpandedRows) {
3459
+ if (!expandRowsFn || // Do not expand if rows are not included in pagination
3460
+ !paginateExpandedRows || !Object.keys(expanded != null ? expanded : {}).length) {
3461
+ return rowModel;
3462
+ }
3463
+
3464
+ return expandRowsFn(instance, rowModel);
3465
+ }, {
3466
+ key: 'getExpandedRowModel',
3467
+ debug: function debug() {
3468
+ var _instance$options$deb;
3469
+
3470
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3471
+ },
3472
+ onChange: function onChange() {
3473
+ instance._notifyPageIndexReset();
3474
+ }
3475
+ }),
3476
+ getPreExpandedRowModel: function getPreExpandedRowModel() {
3477
+ return instance.getGroupedRowModel();
3407
3478
  }
3408
3479
  };
3409
3480
  }
3410
- function createColumn(column, instance) {
3481
+ function createRow$1(row, instance) {
3411
3482
  return {
3412
- getIsResizing: function getIsResizing() {
3413
- return instance.getColumnIsResizing(column.id);
3483
+ toggleExpanded: function toggleExpanded(expanded) {
3484
+ return void instance.toggleRowExpanded(row.id, expanded);
3414
3485
  },
3415
- getCanResize: function getCanResize() {
3416
- return instance.getColumnCanResize(column.id);
3486
+ getIsExpanded: function getIsExpanded() {
3487
+ return instance.getIsRowExpanded(row.id);
3417
3488
  },
3418
- resetSize: function resetSize() {
3419
- return instance.resetColumnSize(column.id);
3489
+ getCanExpand: function getCanExpand() {
3490
+ return row.subRows && !!row.subRows.length;
3420
3491
  },
3421
- getResizerProps: function getResizerProps(userProps) {
3422
- return instance.getColumnResizerProps(column.id, userProps);
3492
+ getToggleExpandedProps: function getToggleExpandedProps(userProps) {
3493
+ var initialProps = {
3494
+ title: 'Toggle Row Expanded',
3495
+ onClick: function onClick(e) {
3496
+ e.stopPropagation();
3497
+ instance.toggleRowExpanded(row.id);
3498
+ }
3499
+ };
3500
+ return propGetter(initialProps, userProps);
3423
3501
  }
3424
3502
  };
3425
3503
  }
3426
- var passiveSupported = null;
3427
- function passiveEventSupported() {
3428
- if (typeof passiveSupported === 'boolean') return passiveSupported;
3429
- var supported = false;
3430
-
3431
- try {
3432
- var options = {
3433
- get passive() {
3434
- supported = true;
3435
- return false;
3436
- }
3437
-
3438
- };
3439
-
3440
- var noop = function noop() {};
3441
-
3442
- window.addEventListener('test', noop, options);
3443
- window.removeEventListener('test', noop);
3444
- } catch (err) {
3445
- supported = false;
3446
- }
3447
-
3448
- passiveSupported = supported;
3449
- return passiveSupported;
3450
- }
3451
-
3452
- function isTouchStartEvent(e) {
3453
- return e.type === 'touchstart';
3454
- }
3455
3504
 
3456
- var ColumnSizing = /*#__PURE__*/Object.freeze({
3505
+ var Expanding = /*#__PURE__*/Object.freeze({
3457
3506
  __proto__: null,
3458
- defaultColumnSizing: defaultColumnSizing,
3459
3507
  getInitialState: getInitialState$2,
3460
3508
  getDefaultOptions: getDefaultOptions$2,
3461
3509
  getInstance: getInstance$2,
3462
- createColumn: createColumn,
3463
- passiveEventSupported: passiveEventSupported
3510
+ createRow: createRow$1
3464
3511
  });
3465
3512
 
3466
3513
  //
3467
3514
  function getInitialState$1() {
3468
3515
  return {
3469
3516
  pagination: {
3517
+ pageCount: -1,
3470
3518
  pageIndex: 0,
3471
3519
  pageSize: 10
3472
3520
  }
@@ -3492,19 +3540,12 @@ function getInstance$1(instance) {
3492
3540
  }
3493
3541
 
3494
3542
  if (instance.options.autoResetAll === true || instance.options.autoResetPageIndex) {
3495
- instance.resetPageSize();
3543
+ instance.resetPageIndex();
3496
3544
  }
3497
3545
  },
3498
3546
  setPagination: function setPagination(updater) {
3499
3547
  var safeUpdater = function safeUpdater(old) {
3500
3548
  var newState = functionalUpdate(updater, old);
3501
-
3502
- if (instance.options.paginateRowsFn) {
3503
- var _instance$getPrePagin;
3504
-
3505
- newState.pageCount = (_instance$getPrePagin = instance.getPrePaginationRows()) != null && _instance$getPrePagin.length ? Math.ceil(instance.getPrePaginationRows().length / instance.getState().pagination.pageSize) : 0;
3506
- }
3507
-
3508
3549
  return newState;
3509
3550
  };
3510
3551
 
@@ -3575,7 +3616,11 @@ function getInstance$1(instance) {
3575
3616
  return pageOptions;
3576
3617
  }, {
3577
3618
  key: 'getPageOptions',
3578
- debug: instance.options.debug
3619
+ debug: function debug() {
3620
+ var _instance$options$deb;
3621
+
3622
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3623
+ }
3579
3624
  }),
3580
3625
  getCanPreviousPage: function getCanPreviousPage() {
3581
3626
  return instance.getState().pagination.pageIndex > 0;
@@ -3594,7 +3639,7 @@ function getInstance$1(instance) {
3594
3639
  return false;
3595
3640
  }
3596
3641
 
3597
- return pageIndex < Math.ceil(instance.getPrePaginationRows().length / pageSize) - 1;
3642
+ return pageIndex < Math.ceil(instance.getPrePaginationRowModel().rows.length / pageSize) - 1;
3598
3643
  },
3599
3644
  previousPage: function previousPage() {
3600
3645
  return instance.setPageIndex(function (old) {
@@ -3606,6 +3651,9 @@ function getInstance$1(instance) {
3606
3651
  return old + 1;
3607
3652
  });
3608
3653
  },
3654
+ getPrePaginationRowModel: function getPrePaginationRowModel() {
3655
+ return instance.getExpandedRowModel();
3656
+ },
3609
3657
  getPaginationRowModel: memo(function () {
3610
3658
  return [instance.getState().pagination, instance.getExpandedRowModel(), instance.options.paginateRowsFn];
3611
3659
  }, function (_pagination, rowModel, paginateRowsFn) {
@@ -3613,29 +3661,23 @@ function getInstance$1(instance) {
3613
3661
  return rowModel;
3614
3662
  }
3615
3663
 
3616
- if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Paginating...');
3617
3664
  return paginateRowsFn(instance, rowModel);
3618
3665
  }, {
3619
3666
  key: 'getPaginationRowModel',
3620
- debug: instance.options.debug
3667
+ debug: function debug() {
3668
+ var _instance$options$deb2;
3669
+
3670
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugTable;
3671
+ }
3621
3672
  }),
3622
- getPrePaginationRows: function getPrePaginationRows() {
3623
- return instance.getExpandedRowModel().rows;
3624
- },
3625
- getPrePaginationFlatRows: function getPrePaginationFlatRows() {
3626
- return instance.getExpandedRowModel().flatRows;
3627
- },
3628
- getPrePaginationRowsById: function getPrePaginationRowsById() {
3629
- return instance.getExpandedRowModel().rowsById;
3630
- },
3631
- getPaginationRows: function getPaginationRows() {
3632
- return instance.getPaginationRowModel().rows;
3633
- },
3634
- getPaginationFlatRows: function getPaginationFlatRows() {
3635
- return instance.getPaginationRowModel().flatRows;
3636
- },
3637
- getPaginationRowsById: function getPaginationRowsById() {
3638
- return instance.getPaginationRowModel().rowsById;
3673
+ getPageCount: function getPageCount() {
3674
+ var pageCount = instance.getState().pagination.pageCount;
3675
+
3676
+ if (pageCount > 0) {
3677
+ return pageCount;
3678
+ }
3679
+
3680
+ return Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
3639
3681
  }
3640
3682
  };
3641
3683
  }
@@ -3697,7 +3739,7 @@ function getInstance(instance) {
3697
3739
  // Leave all the other rows that are selected alone.
3698
3740
 
3699
3741
  var rowSelection = Object.assign({}, old);
3700
- var preGroupedFlatRows = instance.getPreGroupedFlatRows(); // We don't use `mutateRowIsSelected` here for performance reasons.
3742
+ var preGroupedFlatRows = instance.getPreGroupedRowModel().flatRows; // We don't use `mutateRowIsSelected` here for performance reasons.
3701
3743
  // All of the rows are flat already, so it wouldn't be worth it
3702
3744
 
3703
3745
  if (value) {
@@ -3719,7 +3761,7 @@ function getInstance(instance) {
3719
3761
 
3720
3762
  var rowSelection = _extends({}, old);
3721
3763
 
3722
- instance.getRows().forEach(function (row) {
3764
+ instance.getRowModel().rows.forEach(function (row) {
3723
3765
  mutateRowIsSelected(rowSelection, row.id, value, instance);
3724
3766
  });
3725
3767
  return rowSelection;
@@ -3791,6 +3833,9 @@ function getInstance(instance) {
3791
3833
  // })
3792
3834
  // instance.setRowSelection(selectedRowIds)
3793
3835
  // },
3836
+ getPreSelectedRowModel: function getPreSelectedRowModel() {
3837
+ return instance.getCoreRowModel();
3838
+ },
3794
3839
  getSelectedRowModel: memo(function () {
3795
3840
  return [instance.getState().rowSelection, instance.getCoreRowModel()];
3796
3841
  }, function (rowSelection, rowModel) {
@@ -3802,24 +3847,18 @@ function getInstance(instance) {
3802
3847
  };
3803
3848
  }
3804
3849
 
3805
- if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Selecting...');
3806
3850
  return selectRowsFn(instance, rowModel);
3807
3851
  }, {
3808
3852
  key: 'getSelectedRowModel',
3809
- debug: instance.options.debug,
3853
+ debug: function debug() {
3854
+ var _instance$options$deb;
3855
+
3856
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3857
+ },
3810
3858
  onChange: function onChange() {
3811
3859
  return instance._notifyExpandedReset();
3812
3860
  }
3813
3861
  }),
3814
- getSelectedRows: function getSelectedRows() {
3815
- return instance.getSelectedRowModel().rows;
3816
- },
3817
- getSelectedFlatRows: function getSelectedFlatRows() {
3818
- return instance.getSelectedRowModel().flatRows;
3819
- },
3820
- getSelectedRowsById: function getSelectedRowsById() {
3821
- return instance.getSelectedRowModel().rowsById;
3822
- },
3823
3862
  getFilteredSelectedRowModel: memo(function () {
3824
3863
  return [instance.getState().rowSelection, instance.getGlobalFilteredRowModel()];
3825
3864
  }, function (rowSelection, rowModel) {
@@ -3831,24 +3870,18 @@ function getInstance(instance) {
3831
3870
  };
3832
3871
  }
3833
3872
 
3834
- if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Selecting...');
3835
3873
  return selectRowsFn(instance, rowModel);
3836
3874
  }, {
3837
3875
  key: 'getFilteredSelectedRowModel',
3838
- debug: instance.options.debug,
3876
+ debug: function debug() {
3877
+ var _instance$options$deb2;
3878
+
3879
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugTable;
3880
+ },
3839
3881
  onChange: function onChange() {
3840
3882
  return instance._notifyExpandedReset();
3841
3883
  }
3842
3884
  }),
3843
- getFilteredSelectedRows: function getFilteredSelectedRows() {
3844
- return instance.getFilteredSelectedRowModel().rows;
3845
- },
3846
- getFilteredSelectedFlatRows: function getFilteredSelectedFlatRows() {
3847
- return instance.getFilteredSelectedRowModel().flatRows;
3848
- },
3849
- getFilteredSelectedRowsById: function getFilteredSelectedRowsById() {
3850
- return instance.getFilteredSelectedRowModel().rowsById;
3851
- },
3852
3885
  getGroupedSelectedRowModel: memo(function () {
3853
3886
  return [instance.getState().rowSelection, instance.getGroupedRowModel()];
3854
3887
  }, function (rowSelection, rowModel) {
@@ -3860,24 +3893,18 @@ function getInstance(instance) {
3860
3893
  };
3861
3894
  }
3862
3895
 
3863
- if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Selecting...');
3864
3896
  return selectRowsFn(instance, rowModel);
3865
3897
  }, {
3866
3898
  key: 'getGroupedSelectedRowModel',
3867
- debug: instance.options.debug,
3899
+ debug: function debug() {
3900
+ var _instance$options$deb3;
3901
+
3902
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugTable;
3903
+ },
3868
3904
  onChange: function onChange() {
3869
3905
  return instance._notifyExpandedReset();
3870
3906
  }
3871
3907
  }),
3872
- getGroupedSelectedRows: function getGroupedSelectedRows() {
3873
- return instance.getGroupedSelectedRowModel().rows;
3874
- },
3875
- getGroupedSelectedFlatRows: function getGroupedSelectedFlatRows() {
3876
- return instance.getGroupedSelectedRowModel().flatRows;
3877
- },
3878
- getGroupedSelectedRowsById: function getGroupedSelectedRowsById() {
3879
- return instance.getGroupedSelectedRowModel().rowsById;
3880
- },
3881
3908
  ///
3882
3909
  getRowIsSelected: function getRowIsSelected(rowId) {
3883
3910
  var _instance$getState = instance.getState(),
@@ -3959,7 +3986,7 @@ function getInstance(instance) {
3959
3986
  // return instance.options.enableGroupingRowSelection ?? false
3960
3987
  // },
3961
3988
  getIsAllRowsSelected: function getIsAllRowsSelected() {
3962
- var preFilteredFlatRows = instance.getPreGlobalFilteredFlatRows();
3989
+ var preFilteredFlatRows = instance.getPreGlobalFilteredRowModel().flatRows;
3963
3990
 
3964
3991
  var _instance$getState3 = instance.getState(),
3965
3992
  rowSelection = _instance$getState3.rowSelection;
@@ -3977,7 +4004,7 @@ function getInstance(instance) {
3977
4004
  return isAllRowsSelected;
3978
4005
  },
3979
4006
  getIsAllPageRowsSelected: function getIsAllPageRowsSelected() {
3980
- var paginationFlatRows = instance.getPaginationFlatRows();
4007
+ var paginationFlatRows = instance.getPaginationRowModel().flatRows;
3981
4008
 
3982
4009
  var _instance$getState4 = instance.getState(),
3983
4010
  rowSelection = _instance$getState4.rowSelection;
@@ -3998,7 +4025,7 @@ function getInstance(instance) {
3998
4025
  return !instance.getIsAllRowsSelected() && !!Object.keys((_instance$getState$ro = instance.getState().rowSelection) != null ? _instance$getState$ro : {}).length;
3999
4026
  },
4000
4027
  getIsSomePageRowsSelected: function getIsSomePageRowsSelected() {
4001
- var paginationFlatRows = instance.getPaginationFlatRows();
4028
+ var paginationFlatRows = instance.getPaginationRowModel().flatRows;
4002
4029
  return instance.getIsAllPageRowsSelected() ? false : !!(paginationFlatRows != null && paginationFlatRows.length);
4003
4030
  },
4004
4031
  getToggleRowSelectedProps: function getToggleRowSelectedProps(rowId, userProps) {
@@ -4175,10 +4202,10 @@ var RowSelection = /*#__PURE__*/Object.freeze({
4175
4202
  });
4176
4203
 
4177
4204
  var features = [Visibility, Ordering, Pinning, Headers, Filters, Sorting, Grouping, Expanding, ColumnSizing, Pagination, RowSelection];
4178
- function createTableInstance(options, rerender) {
4205
+ function createTableInstance(options) {
4179
4206
  var _options$initialState;
4180
4207
 
4181
- if (process.env.NODE_ENV !== 'production' && options.debug) {
4208
+ if (options.debugAll || options.debugTable) {
4182
4209
  console.info('Creating React Table Instance...');
4183
4210
  }
4184
4211
 
@@ -4186,12 +4213,9 @@ function createTableInstance(options, rerender) {
4186
4213
  var defaultOptions = features.reduce(function (obj, feature) {
4187
4214
  return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(instance));
4188
4215
  }, {});
4189
- var defaultState = {};
4190
4216
 
4191
4217
  var buildOptions = function buildOptions(options) {
4192
- return _extends({
4193
- state: defaultState
4194
- }, defaultOptions, options);
4218
+ return _extends({}, defaultOptions, options);
4195
4219
  };
4196
4220
 
4197
4221
  instance.options = buildOptions(options);
@@ -4203,41 +4227,21 @@ function createTableInstance(options, rerender) {
4203
4227
  var finalInstance = _extends({}, instance, features.reduce(function (obj, feature) {
4204
4228
  return Object.assign(obj, feature.getInstance == null ? void 0 : feature.getInstance(instance));
4205
4229
  }, {}), {
4206
- rerender: rerender,
4207
4230
  initialState: initialState,
4208
- internalState: initialState,
4209
4231
  reset: function reset() {
4210
4232
  instance.setState(instance.initialState);
4211
4233
  },
4212
- updateOptions: function updateOptions(newOptions) {
4213
- instance.options = buildOptions(newOptions);
4234
+ setOptions: function setOptions(updater) {
4235
+ instance.options = buildOptions(functionalUpdate(updater, instance.options));
4214
4236
  },
4215
4237
  getRowId: function getRowId(_, index, parent) {
4216
4238
  return "" + (parent ? [parent.id, index].join('.') : index);
4217
4239
  },
4218
4240
  getState: function getState() {
4219
- var state = _extends({}, instance.internalState, instance.options.state);
4220
-
4221
- return state;
4241
+ return instance.options.state;
4222
4242
  },
4223
- setState: function setState(updater, shouldRerender) {
4224
- if (shouldRerender === void 0) {
4225
- shouldRerender = true;
4226
- }
4227
-
4228
- var onStateChange = instance.options.onStateChange;
4229
- var internalState = instance.internalState;
4230
- var newState = functionalUpdate(updater, internalState);
4231
- instance.internalState = newState;
4232
-
4233
- if (onStateChange) {
4234
- onStateChange(newState);
4235
- return;
4236
- }
4237
-
4238
- if (shouldRerender) {
4239
- instance.rerender();
4240
- }
4243
+ setState: function setState(updater) {
4244
+ instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
4241
4245
  },
4242
4246
  getDefaultColumn: memo(function () {
4243
4247
  return [instance.options.defaultColumn];
@@ -4261,7 +4265,11 @@ function createTableInstance(options, rerender) {
4261
4265
  return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
4262
4266
  }, {}), defaultColumn);
4263
4267
  }, {
4264
- debug: instance.options.debug,
4268
+ debug: function debug() {
4269
+ var _instance$options$deb;
4270
+
4271
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
4272
+ },
4265
4273
  key: 'getDefaultColumn'
4266
4274
  }),
4267
4275
  getColumnDefs: function getColumnDefs() {
@@ -4310,7 +4318,11 @@ function createTableInstance(options, rerender) {
4310
4318
  }));
4311
4319
  }, {
4312
4320
  key: 'column.getFlatColumns',
4313
- debug: instance.options.debug
4321
+ debug: function debug() {
4322
+ var _instance$options$deb2;
4323
+
4324
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
4325
+ }
4314
4326
  }),
4315
4327
  getLeafColumns: memo(function () {
4316
4328
  return [instance.getOrderColumnsFn()];
@@ -4327,7 +4339,11 @@ function createTableInstance(options, rerender) {
4327
4339
  return [column];
4328
4340
  }, {
4329
4341
  key: 'column.getLeafColumns',
4330
- debug: instance.options.debug
4342
+ debug: function debug() {
4343
+ var _instance$options$deb3;
4344
+
4345
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
4346
+ }
4331
4347
  })
4332
4348
  });
4333
4349
 
@@ -4340,8 +4356,6 @@ function createTableInstance(options, rerender) {
4340
4356
  getAllColumns: memo(function () {
4341
4357
  return [instance.getColumnDefs()];
4342
4358
  }, function (columnDefs) {
4343
- if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Building Columns...');
4344
-
4345
4359
  var recurseColumns = function recurseColumns(columnDefs, parent, depth) {
4346
4360
  if (depth === void 0) {
4347
4361
  depth = 0;
@@ -4357,7 +4371,11 @@ function createTableInstance(options, rerender) {
4357
4371
  return recurseColumns(columnDefs);
4358
4372
  }, {
4359
4373
  key: 'getAllColumns',
4360
- debug: instance.options.debug
4374
+ debug: function debug() {
4375
+ var _instance$options$deb4;
4376
+
4377
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
4378
+ }
4361
4379
  }),
4362
4380
  getAllFlatColumns: memo(function () {
4363
4381
  return [instance.getAllColumns()];
@@ -4367,7 +4385,11 @@ function createTableInstance(options, rerender) {
4367
4385
  });
4368
4386
  }, {
4369
4387
  key: 'getAllFlatColumns',
4370
- debug: instance.options.debug
4388
+ debug: function debug() {
4389
+ var _instance$options$deb5;
4390
+
4391
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
4392
+ }
4371
4393
  }),
4372
4394
  getAllFlatColumnsById: memo(function () {
4373
4395
  return [instance.getAllFlatColumns()];
@@ -4378,7 +4400,11 @@ function createTableInstance(options, rerender) {
4378
4400
  }, {});
4379
4401
  }, {
4380
4402
  key: 'getAllFlatColumnsById',
4381
- debug: instance.options.debug
4403
+ debug: function debug() {
4404
+ var _instance$options$deb6;
4405
+
4406
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns;
4407
+ }
4382
4408
  }),
4383
4409
  getAllLeafColumns: memo(function () {
4384
4410
  return [instance.getAllColumns(), instance.getOrderColumnsFn()];
@@ -4389,7 +4415,11 @@ function createTableInstance(options, rerender) {
4389
4415
  return orderColumns(leafColumns);
4390
4416
  }, {
4391
4417
  key: 'getAllLeafColumns',
4392
- debug: instance.options.debug
4418
+ debug: function debug() {
4419
+ var _instance$options$deb7;
4420
+
4421
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns;
4422
+ }
4393
4423
  }),
4394
4424
  getColumn: function getColumn(columnId) {
4395
4425
  var column = instance.getAllFlatColumnsById()[columnId];
@@ -4465,7 +4495,11 @@ function createTableInstance(options, rerender) {
4465
4495
  });
4466
4496
  }, {
4467
4497
  key: process.env.NODE_ENV !== 'production' ? 'row.getAllCells' : '',
4468
- debug: instance.options.debug
4498
+ debug: function debug() {
4499
+ var _instance$options$deb8;
4500
+
4501
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugRows;
4502
+ }
4469
4503
  });
4470
4504
  row.getAllCellsByColumnId = memo(function () {
4471
4505
  return [row.getAllCells()];
@@ -4476,18 +4510,24 @@ function createTableInstance(options, rerender) {
4476
4510
  }, {});
4477
4511
  }, {
4478
4512
  key: 'row.getAllCellsByColumnId',
4479
- debug: instance.options.debug
4513
+ debug: function debug() {
4514
+ var _instance$options$deb9;
4515
+
4516
+ return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugRows;
4517
+ }
4480
4518
  });
4481
- features.forEach(function (feature) {
4519
+
4520
+ for (var i = 0; i < features.length; i++) {
4521
+ var feature = features[i];
4482
4522
  Object.assign(row, feature.createRow == null ? void 0 : feature.createRow(row, instance));
4483
- });
4523
+ }
4524
+
4484
4525
  return row;
4485
4526
  },
4486
4527
  getCoreRowModel: memo(function () {
4487
4528
  return [instance.options.data];
4488
4529
  }, function (data) {
4489
- if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Accessing...'); // Access the row model using initial columns
4490
-
4530
+ // Access the row model using initial columns
4491
4531
  var rows = [];
4492
4532
  var flatRows = [];
4493
4533
  var rowsById = {};
@@ -4556,39 +4596,24 @@ function createTableInstance(options, rerender) {
4556
4596
  };
4557
4597
  }, {
4558
4598
  key: 'getRowModel',
4559
- debug: instance.options.debug,
4599
+ debug: function debug() {
4600
+ var _instance$options$deb10;
4601
+
4602
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugTable;
4603
+ },
4560
4604
  onChange: function onChange() {
4561
4605
  instance._notifyRowSelectionReset();
4562
4606
 
4563
4607
  instance._notifyFiltersReset();
4564
4608
  }
4565
4609
  }),
4566
- // The standard
4567
- getCoreRows: function getCoreRows() {
4568
- return instance.getCoreRowModel().rows;
4569
- },
4570
- getCoreFlatRows: function getCoreFlatRows() {
4571
- return instance.getCoreRowModel().flatRows;
4572
- },
4573
- getCoreRowsById: function getCoreRowsById() {
4574
- return instance.getCoreRowModel().rowsById;
4575
- },
4576
4610
  // The final calls start at the bottom of the model,
4577
4611
  // expanded rows, which then work their way up
4578
4612
  getRowModel: function getRowModel() {
4579
4613
  return instance.getPaginationRowModel();
4580
4614
  },
4581
- getRows: function getRows() {
4582
- return instance.getRowModel().rows;
4583
- },
4584
- getFlatRows: function getFlatRows() {
4585
- return instance.getRowModel().flatRows;
4586
- },
4587
- getRowsById: function getRowsById() {
4588
- return instance.getRowModel().rowsById;
4589
- },
4590
4615
  getRow: function getRow(id) {
4591
- var row = instance.getRowsById()[id];
4616
+ var row = instance.getRowModel().rowsById[id];
4592
4617
 
4593
4618
  if (!row) {
4594
4619
  if (process.env.NODE_ENV !== 'production') {
@@ -4687,41 +4712,29 @@ function createTableInstance(options, rerender) {
4687
4712
  }
4688
4713
  });
4689
4714
 
4690
- instance = Object.assign(instance, finalInstance); // This won't trigger a rerender yet, but it will force
4691
- // pagination derivation to run (particularly pageSize detection)
4692
-
4693
- instance.setPagination(function (d) {
4694
- return d;
4695
- });
4715
+ instance = Object.assign(instance, finalInstance);
4696
4716
  return instance;
4697
4717
  }
4698
4718
 
4719
+ function createTableFactory(opts) {
4720
+ return function () {
4721
+ return _createTable(undefined, undefined, opts);
4722
+ };
4723
+ }
4699
4724
  function createTable() {
4725
+ return _createTable();
4726
+ }
4727
+
4728
+ function _createTable(_, __, opts) {
4700
4729
  return {
4701
- RowType: function RowType() {
4702
- return createTable();
4703
- },
4704
- FilterFns: function FilterFns() {
4705
- return createTable();
4706
- },
4707
- SortingFns: function SortingFns() {
4708
- return createTable();
4709
- },
4710
- AggregationFns: function AggregationFns() {
4711
- return createTable();
4712
- },
4713
4730
  createColumns: function createColumns(columns) {
4714
4731
  return columns;
4715
4732
  },
4716
4733
  createDisplayColumn: function createDisplayColumn(column) {
4717
- return _extends({}, column, {
4718
- __generated: true
4719
- });
4734
+ return column;
4720
4735
  },
4721
4736
  createGroup: function createGroup(column) {
4722
- return _extends({}, column, {
4723
- __generated: true
4724
- });
4737
+ return column;
4725
4738
  },
4726
4739
  createDataColumn: function createDataColumn(accessor, column) {
4727
4740
  column = _extends({}, column, {
@@ -4733,36 +4746,56 @@ function createTable() {
4733
4746
 
4734
4747
  return _extends({}, column, {
4735
4748
  id: (_column$id = column.id) != null ? _column$id : accessor,
4736
- accessorKey: accessor,
4737
- __generated: true
4749
+ accessorKey: accessor
4738
4750
  });
4739
4751
  }
4740
4752
 
4741
4753
  if (typeof accessor === 'function') {
4742
4754
  return _extends({}, column, {
4743
- accessorFn: accessor,
4744
- __generated: true
4755
+ accessorFn: accessor
4745
4756
  });
4746
4757
  }
4747
4758
 
4748
4759
  throw new Error('Invalid accessor');
4749
4760
  },
4750
4761
  useTable: function useTable(options) {
4751
- var instanceRef = React.useRef(undefined);
4752
- var rerender = React.useReducer(function () {
4753
- return {};
4754
- }, {})[1];
4755
-
4756
- if (!instanceRef.current) {
4757
- instanceRef.current = createTableInstance(options, rerender);
4758
- }
4759
-
4760
- instanceRef.current.updateOptions(options);
4761
- return instanceRef.current;
4762
- },
4763
- types: undefined
4762
+ // Compose in the generic options to the user options
4763
+ var resolvedOptions = _extends({}, opts != null ? opts : {}, {
4764
+ state: {},
4765
+ // Dummy state
4766
+ onStateChange: function onStateChange() {}
4767
+ }, options); // Create a new table instance and store it in state
4768
+
4769
+
4770
+ var _React$useState = React.useState(function () {
4771
+ return createTableInstance(resolvedOptions);
4772
+ }),
4773
+ instance = _React$useState[0]; // By default, manage table state here using the instance's initial state
4774
+
4775
+
4776
+ var _React$useState2 = React.useState(function () {
4777
+ return instance.initialState;
4778
+ }),
4779
+ state = _React$useState2[0],
4780
+ setState = _React$useState2[1]; // Compose the default state above with any user state. This will allow the user
4781
+ // to only control a subset of the state if desired.
4782
+
4783
+
4784
+ instance.setOptions(function (prev) {
4785
+ return _extends({}, prev, options, {
4786
+ state: _extends({}, state, options.state),
4787
+ // Similarly, we'll maintain both our internal state and any user-provided
4788
+ // state.
4789
+ onStateChange: function onStateChange(updater) {
4790
+ setState(updater);
4791
+ options.onStateChange == null ? void 0 : options.onStateChange(updater);
4792
+ }
4793
+ });
4794
+ });
4795
+ return instance;
4796
+ }
4764
4797
  };
4765
4798
  }
4766
4799
 
4767
- export { columnFilterRowsFn, createTable, expandRowsFn, globalFilterRowsFn, groupRowsFn, paginateRowsFn, sortRowsFn };
4800
+ export { Please_use_the_create_table_column_utilities_to_define_columns, columnFilterRowsFn, createTable, createTableFactory, expandRowsFn, flattenBy, flexRender, functionalUpdate, globalFilterRowsFn, groupRowsFn, isFunction, makeStateUpdater, memo, noop, paginateRowsFn, propGetter, sortRowsFn };
4768
4801
  //# sourceMappingURL=index.js.map