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