@tanstack/react-table 8.0.0-alpha.69 → 8.0.0-alpha.71

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.
@@ -634,28 +634,28 @@ const ColumnSizing = {
634
634
  var _instance$getHeaderGr, _instance$getHeaderGr2;
635
635
 
636
636
  return (_instance$getHeaderGr = (_instance$getHeaderGr2 = instance.getHeaderGroups()[0]) == null ? void 0 : _instance$getHeaderGr2.headers.reduce((sum, header) => {
637
- return sum + header.column.getSize();
637
+ return sum + header.getSize();
638
638
  }, 0)) != null ? _instance$getHeaderGr : 0;
639
639
  },
640
640
  getLeftTotalSize: () => {
641
641
  var _instance$getLeftHead, _instance$getLeftHead2;
642
642
 
643
643
  return (_instance$getLeftHead = (_instance$getLeftHead2 = instance.getLeftHeaderGroups()[0]) == null ? void 0 : _instance$getLeftHead2.headers.reduce((sum, header) => {
644
- return sum + header.column.getSize();
644
+ return sum + header.getSize();
645
645
  }, 0)) != null ? _instance$getLeftHead : 0;
646
646
  },
647
647
  getCenterTotalSize: () => {
648
648
  var _instance$getCenterHe, _instance$getCenterHe2;
649
649
 
650
650
  return (_instance$getCenterHe = (_instance$getCenterHe2 = instance.getCenterHeaderGroups()[0]) == null ? void 0 : _instance$getCenterHe2.headers.reduce((sum, header) => {
651
- return sum + header.column.getSize();
651
+ return sum + header.getSize();
652
652
  }, 0)) != null ? _instance$getCenterHe : 0;
653
653
  },
654
654
  getRightTotalSize: () => {
655
655
  var _instance$getRightHea, _instance$getRightHea2;
656
656
 
657
657
  return (_instance$getRightHea = (_instance$getRightHea2 = instance.getRightHeaderGroups()[0]) == null ? void 0 : _instance$getRightHea2.headers.reduce((sum, header) => {
658
- return sum + header.column.getSize();
658
+ return sum + header.getSize();
659
659
  }, 0)) != null ? _instance$getRightHea : 0;
660
660
  }
661
661
  };
@@ -709,10 +709,13 @@ const Expanding = {
709
709
  },
710
710
  createInstance: instance => {
711
711
  let registered = false;
712
+ let queued = false;
712
713
  return {
713
714
  _autoResetExpanded: () => {
714
715
  if (!registered) {
715
- registered = true;
716
+ instance.queue(() => {
717
+ registered = true;
718
+ });
716
719
  return;
717
720
  }
718
721
 
@@ -721,7 +724,12 @@ const Expanding = {
721
724
  }
722
725
 
723
726
  if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
724
- instance.resetExpanded();
727
+ if (queued) return;
728
+ queued = true;
729
+ instance.queue(() => {
730
+ instance.resetExpanded();
731
+ queued = false;
732
+ });
725
733
  }
726
734
  },
727
735
  setExpanded: updater => instance.options.onExpandedChange == null ? void 0 : instance.options.onExpandedChange(updater),
@@ -1074,7 +1082,7 @@ const Filters = {
1074
1082
  _getFacetedMinMaxValues: instance.options.getFacetedMinMaxValues && instance.options.getFacetedMinMaxValues(instance, column.id),
1075
1083
  getFacetedMinMaxValues: () => {
1076
1084
  if (!column._getFacetedMinMaxValues) {
1077
- return [NaN, NaN];
1085
+ return undefined;
1078
1086
  }
1079
1087
 
1080
1088
  return column._getFacetedMinMaxValues();
@@ -1165,7 +1173,7 @@ const Filters = {
1165
1173
  _getGlobalFacetedMinMaxValues: instance.options.getFacetedMinMaxValues && instance.options.getFacetedMinMaxValues(instance, '__global__'),
1166
1174
  getGlobalFacetedMinMaxValues: () => {
1167
1175
  if (!instance._getGlobalFacetedMinMaxValues) {
1168
- return [NaN, NaN];
1176
+ return;
1169
1177
  }
1170
1178
 
1171
1179
  return instance._getGlobalFacetedMinMaxValues();
@@ -1485,12 +1493,10 @@ const Ordering = {
1485
1493
  };
1486
1494
 
1487
1495
  //
1488
- const defaultPageCount = -1;
1489
1496
  const defaultPageIndex = 0;
1490
1497
  const defaultPageSize = 10;
1491
1498
 
1492
1499
  const getDefaultPaginationState = () => ({
1493
- pageCount: defaultPageCount,
1494
1500
  pageIndex: defaultPageIndex,
1495
1501
  pageSize: defaultPageSize
1496
1502
  });
@@ -1511,10 +1517,13 @@ const Pagination = {
1511
1517
  },
1512
1518
  createInstance: instance => {
1513
1519
  let registered = false;
1520
+ let queued = false;
1514
1521
  return {
1515
1522
  _autoResetPageIndex: () => {
1516
1523
  if (!registered) {
1517
- registered = true;
1524
+ instance.queue(() => {
1525
+ registered = true;
1526
+ });
1518
1527
  return;
1519
1528
  }
1520
1529
 
@@ -1523,7 +1532,12 @@ const Pagination = {
1523
1532
  }
1524
1533
 
1525
1534
  if (instance.options.autoResetAll === true || instance.options.autoResetPageIndex) {
1526
- instance.resetPageIndex();
1535
+ if (queued) return;
1536
+ queued = true;
1537
+ instance.queue(() => {
1538
+ instance.resetPageIndex();
1539
+ queued = false;
1540
+ });
1527
1541
  }
1528
1542
  },
1529
1543
  setPagination: updater => {
@@ -1571,7 +1585,9 @@ const Pagination = {
1571
1585
  });
1572
1586
  },
1573
1587
  setPageCount: updater => instance.setPagination(old => {
1574
- let newPageCount = functionalUpdate(updater, old.pageCount);
1588
+ var _old$pageCount;
1589
+
1590
+ let newPageCount = functionalUpdate(updater, (_old$pageCount = old.pageCount) != null ? _old$pageCount : -1);
1575
1591
 
1576
1592
  if (typeof newPageCount === 'number') {
1577
1593
  newPageCount = Math.max(-1, newPageCount);
@@ -1639,7 +1655,7 @@ const Pagination = {
1639
1655
  pageCount
1640
1656
  } = instance.getState().pagination;
1641
1657
 
1642
- if (pageCount > 0) {
1658
+ if (typeof pageCount !== 'undefined') {
1643
1659
  return pageCount;
1644
1660
  }
1645
1661
 
@@ -3362,9 +3378,7 @@ function getCoreRowModel() {
3362
3378
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3363
3379
  },
3364
3380
  onChange: () => {
3365
- instance.queue(() => {
3366
- instance._autoResetPageIndex();
3367
- });
3381
+ instance._autoResetPageIndex();
3368
3382
  }
3369
3383
  });
3370
3384
  }
@@ -3570,9 +3584,7 @@ function getFilteredRowModel() {
3570
3584
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3571
3585
  },
3572
3586
  onChange: () => {
3573
- instance.queue(() => {
3574
- instance._autoResetPageIndex();
3575
- });
3587
+ instance._autoResetPageIndex();
3576
3588
  }
3577
3589
  });
3578
3590
  }
@@ -3640,14 +3652,20 @@ function getFacetedUniqueValues() {
3640
3652
 
3641
3653
  function getFacetedMinMaxValues() {
3642
3654
  return (instance, columnId) => memo(() => [instance.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
3643
- var _facetedRowModel$flat, _facetedRowModel$flat2, _facetedRowModel$flat3, _facetedRowModel$flat4;
3655
+ var _facetedRowModel$flat;
3644
3656
 
3645
- 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];
3657
+ const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getValue(columnId);
3658
+
3659
+ if (typeof firstValue === 'undefined') {
3660
+ return undefined;
3661
+ }
3662
+
3663
+ let facetedMinMaxValues = [firstValue, firstValue];
3646
3664
 
3647
3665
  for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3648
- var _facetedRowModel$flat5;
3666
+ var _facetedRowModel$flat2;
3649
3667
 
3650
- const value = (_facetedRowModel$flat5 = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat5.getValue(columnId);
3668
+ const value = (_facetedRowModel$flat2 = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat2.getValue(columnId);
3651
3669
 
3652
3670
  if (value < facetedMinMaxValues[0]) {
3653
3671
  facetedMinMaxValues[0] = value;
@@ -3755,9 +3773,7 @@ function getSortedRowModel() {
3755
3773
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3756
3774
  },
3757
3775
  onChange: () => {
3758
- instance.queue(() => {
3759
- instance._autoResetPageIndex();
3760
- });
3776
+ instance._autoResetPageIndex();
3761
3777
  }
3762
3778
  });
3763
3779
  }