@tanstack/react-table 8.0.0-alpha.70 → 8.0.0-alpha.73

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.
@@ -387,7 +387,7 @@ const Cells = {
387
387
  row,
388
388
  column,
389
389
  getValue: () => row.getValue(columnId),
390
- renderCell: () => column.cell ? instance.render(column.cell, {
390
+ renderCell: () => column.cell ? instance._render(column.cell, {
391
391
  instance,
392
392
  column,
393
393
  row,
@@ -636,28 +636,28 @@ const ColumnSizing = {
636
636
  var _instance$getHeaderGr, _instance$getHeaderGr2;
637
637
 
638
638
  return (_instance$getHeaderGr = (_instance$getHeaderGr2 = instance.getHeaderGroups()[0]) == null ? void 0 : _instance$getHeaderGr2.headers.reduce((sum, header) => {
639
- return sum + header.column.getSize();
639
+ return sum + header.getSize();
640
640
  }, 0)) != null ? _instance$getHeaderGr : 0;
641
641
  },
642
642
  getLeftTotalSize: () => {
643
643
  var _instance$getLeftHead, _instance$getLeftHead2;
644
644
 
645
645
  return (_instance$getLeftHead = (_instance$getLeftHead2 = instance.getLeftHeaderGroups()[0]) == null ? void 0 : _instance$getLeftHead2.headers.reduce((sum, header) => {
646
- return sum + header.column.getSize();
646
+ return sum + header.getSize();
647
647
  }, 0)) != null ? _instance$getLeftHead : 0;
648
648
  },
649
649
  getCenterTotalSize: () => {
650
650
  var _instance$getCenterHe, _instance$getCenterHe2;
651
651
 
652
652
  return (_instance$getCenterHe = (_instance$getCenterHe2 = instance.getCenterHeaderGroups()[0]) == null ? void 0 : _instance$getCenterHe2.headers.reduce((sum, header) => {
653
- return sum + header.column.getSize();
653
+ return sum + header.getSize();
654
654
  }, 0)) != null ? _instance$getCenterHe : 0;
655
655
  },
656
656
  getRightTotalSize: () => {
657
657
  var _instance$getRightHea, _instance$getRightHea2;
658
658
 
659
659
  return (_instance$getRightHea = (_instance$getRightHea2 = instance.getRightHeaderGroups()[0]) == null ? void 0 : _instance$getRightHea2.headers.reduce((sum, header) => {
660
- return sum + header.column.getSize();
660
+ return sum + header.getSize();
661
661
  }, 0)) != null ? _instance$getRightHea : 0;
662
662
  }
663
663
  };
@@ -711,10 +711,14 @@ const Expanding = {
711
711
  },
712
712
  createInstance: instance => {
713
713
  let registered = false;
714
+ let queued = false;
714
715
  return {
715
716
  _autoResetExpanded: () => {
716
717
  if (!registered) {
717
- registered = true;
718
+ instance._queue(() => {
719
+ registered = true;
720
+ });
721
+
718
722
  return;
719
723
  }
720
724
 
@@ -723,7 +727,13 @@ const Expanding = {
723
727
  }
724
728
 
725
729
  if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
726
- instance.resetExpanded();
730
+ if (queued) return;
731
+ queued = true;
732
+
733
+ instance._queue(() => {
734
+ instance.resetExpanded();
735
+ queued = false;
736
+ });
727
737
  }
728
738
  },
729
739
  setExpanded: updater => instance.options.onExpandedChange == null ? void 0 : instance.options.onExpandedChange(updater),
@@ -1076,7 +1086,7 @@ const Filters = {
1076
1086
  _getFacetedMinMaxValues: instance.options.getFacetedMinMaxValues && instance.options.getFacetedMinMaxValues(instance, column.id),
1077
1087
  getFacetedMinMaxValues: () => {
1078
1088
  if (!column._getFacetedMinMaxValues) {
1079
- return [NaN, NaN];
1089
+ return undefined;
1080
1090
  }
1081
1091
 
1082
1092
  return column._getFacetedMinMaxValues();
@@ -1167,7 +1177,7 @@ const Filters = {
1167
1177
  _getGlobalFacetedMinMaxValues: instance.options.getFacetedMinMaxValues && instance.options.getFacetedMinMaxValues(instance, '__global__'),
1168
1178
  getGlobalFacetedMinMaxValues: () => {
1169
1179
  if (!instance._getGlobalFacetedMinMaxValues) {
1170
- return [NaN, NaN];
1180
+ return;
1171
1181
  }
1172
1182
 
1173
1183
  return instance._getGlobalFacetedMinMaxValues();
@@ -1404,7 +1414,7 @@ const Grouping = {
1404
1414
  var _column$aggregatedCel;
1405
1415
 
1406
1416
  const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
1407
- return template ? instance.render(template, {
1417
+ return template ? instance._render(template, {
1408
1418
  instance,
1409
1419
  column,
1410
1420
  row,
@@ -1505,25 +1515,32 @@ const Pagination = {
1505
1515
  },
1506
1516
  getDefaultOptions: instance => {
1507
1517
  return {
1508
- onPaginationChange: makeStateUpdater('pagination', instance),
1509
- autoResetPageIndex: true
1518
+ onPaginationChange: makeStateUpdater('pagination', instance)
1510
1519
  };
1511
1520
  },
1512
1521
  createInstance: instance => {
1513
1522
  let registered = false;
1523
+ let queued = false;
1514
1524
  return {
1515
1525
  _autoResetPageIndex: () => {
1526
+ var _ref, _instance$options$aut;
1527
+
1516
1528
  if (!registered) {
1517
- registered = true;
1518
- return;
1519
- }
1529
+ instance._queue(() => {
1530
+ registered = true;
1531
+ });
1520
1532
 
1521
- if (instance.options.autoResetAll === false) {
1522
1533
  return;
1523
1534
  }
1524
1535
 
1525
- if (instance.options.autoResetAll === true || instance.options.autoResetPageIndex) {
1526
- instance.resetPageIndex();
1536
+ if ((_ref = (_instance$options$aut = instance.options.autoResetAll) != null ? _instance$options$aut : instance.options.autoResetPageIndex) != null ? _ref : !instance.options.manualPagination) {
1537
+ if (queued) return;
1538
+ queued = true;
1539
+
1540
+ instance._queue(() => {
1541
+ instance.resetPageIndex();
1542
+ queued = false;
1543
+ });
1527
1544
  }
1528
1545
  },
1529
1546
  setPagination: updater => {
@@ -1542,7 +1559,7 @@ const Pagination = {
1542
1559
  setPageIndex: updater => {
1543
1560
  instance.setPagination(old => {
1544
1561
  let pageIndex = functionalUpdate(updater, old.pageIndex);
1545
- const maxPageIndex = old.pageCount && old.pageCount > 0 ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
1562
+ const maxPageIndex = typeof old.pageCount !== 'undefined' ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
1546
1563
  pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
1547
1564
  return { ...old,
1548
1565
  pageIndex
@@ -2653,12 +2670,12 @@ const Headers = {
2653
2670
  recurseHeader(header);
2654
2671
  return leafHeaders;
2655
2672
  },
2656
- renderHeader: () => column.header ? instance.render(column.header, {
2673
+ renderHeader: () => column.header ? instance._render(column.header, {
2657
2674
  instance,
2658
2675
  header: header,
2659
2676
  column
2660
2677
  }) : null,
2661
- renderFooter: () => column.footer ? instance.render(column.footer, {
2678
+ renderFooter: () => column.footer ? instance._render(column.footer, {
2662
2679
  instance,
2663
2680
  header: header,
2664
2681
  column
@@ -3132,7 +3149,7 @@ function createTableInstance(options) {
3132
3149
  ...options
3133
3150
  },
3134
3151
  initialState,
3135
- queue: cb => {
3152
+ _queue: cb => {
3136
3153
  queued.push(cb);
3137
3154
 
3138
3155
  if (!queuedTimeout) {
@@ -3190,7 +3207,7 @@ function createTableInstance(options) {
3190
3207
  const newOptions = functionalUpdate(updater, instance.options);
3191
3208
  instance.options = mergeOptions(newOptions);
3192
3209
  },
3193
- render: (template, props) => {
3210
+ _render: (template, props) => {
3194
3211
  if (typeof instance.options.render === 'function') {
3195
3212
  return instance.options.render(template, props);
3196
3213
  }
@@ -3364,9 +3381,7 @@ function getCoreRowModel() {
3364
3381
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3365
3382
  },
3366
3383
  onChange: () => {
3367
- instance.queue(() => {
3368
- instance._autoResetPageIndex();
3369
- });
3384
+ instance._autoResetPageIndex();
3370
3385
  }
3371
3386
  });
3372
3387
  }
@@ -3572,9 +3587,7 @@ function getFilteredRowModel() {
3572
3587
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3573
3588
  },
3574
3589
  onChange: () => {
3575
- instance.queue(() => {
3576
- instance._autoResetPageIndex();
3577
- });
3590
+ instance._autoResetPageIndex();
3578
3591
  }
3579
3592
  });
3580
3593
  }
@@ -3642,14 +3655,20 @@ function getFacetedUniqueValues() {
3642
3655
 
3643
3656
  function getFacetedMinMaxValues() {
3644
3657
  return (instance, columnId) => memo(() => [instance.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
3645
- var _facetedRowModel$flat, _facetedRowModel$flat2, _facetedRowModel$flat3, _facetedRowModel$flat4;
3658
+ var _facetedRowModel$flat;
3646
3659
 
3647
- let facetedMinMaxValues = [(_facetedRowModel$flat = (_facetedRowModel$flat2 = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat2.getValue(columnId)) != null ? _facetedRowModel$flat : null, (_facetedRowModel$flat3 = (_facetedRowModel$flat4 = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat4.getValue(columnId)) != null ? _facetedRowModel$flat3 : null];
3660
+ const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getValue(columnId);
3661
+
3662
+ if (typeof firstValue === 'undefined') {
3663
+ return undefined;
3664
+ }
3665
+
3666
+ let facetedMinMaxValues = [firstValue, firstValue];
3648
3667
 
3649
3668
  for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3650
- var _facetedRowModel$flat5;
3669
+ var _facetedRowModel$flat2;
3651
3670
 
3652
- const value = (_facetedRowModel$flat5 = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat5.getValue(columnId);
3671
+ const value = (_facetedRowModel$flat2 = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat2.getValue(columnId);
3653
3672
 
3654
3673
  if (value < facetedMinMaxValues[0]) {
3655
3674
  facetedMinMaxValues[0] = value;
@@ -3757,9 +3776,7 @@ function getSortedRowModel() {
3757
3776
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3758
3777
  },
3759
3778
  onChange: () => {
3760
- instance.queue(() => {
3761
- instance._autoResetPageIndex();
3762
- });
3779
+ instance._autoResetPageIndex();
3763
3780
  }
3764
3781
  });
3765
3782
  }
@@ -3889,7 +3906,7 @@ function getGroupedRowModel() {
3889
3906
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3890
3907
  },
3891
3908
  onChange: () => {
3892
- instance.queue(() => {
3909
+ instance._queue(() => {
3893
3910
  instance._autoResetExpanded();
3894
3911
 
3895
3912
  instance._autoResetPageIndex();