@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.
@@ -385,7 +385,7 @@ const Cells = {
385
385
  row,
386
386
  column,
387
387
  getValue: () => row.getValue(columnId),
388
- renderCell: () => column.cell ? instance.render(column.cell, {
388
+ renderCell: () => column.cell ? instance._render(column.cell, {
389
389
  instance,
390
390
  column,
391
391
  row,
@@ -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,14 @@ 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
+ });
719
+
716
720
  return;
717
721
  }
718
722
 
@@ -721,7 +725,13 @@ const Expanding = {
721
725
  }
722
726
 
723
727
  if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
724
- instance.resetExpanded();
728
+ if (queued) return;
729
+ queued = true;
730
+
731
+ instance._queue(() => {
732
+ instance.resetExpanded();
733
+ queued = false;
734
+ });
725
735
  }
726
736
  },
727
737
  setExpanded: updater => instance.options.onExpandedChange == null ? void 0 : instance.options.onExpandedChange(updater),
@@ -1074,7 +1084,7 @@ const Filters = {
1074
1084
  _getFacetedMinMaxValues: instance.options.getFacetedMinMaxValues && instance.options.getFacetedMinMaxValues(instance, column.id),
1075
1085
  getFacetedMinMaxValues: () => {
1076
1086
  if (!column._getFacetedMinMaxValues) {
1077
- return [NaN, NaN];
1087
+ return undefined;
1078
1088
  }
1079
1089
 
1080
1090
  return column._getFacetedMinMaxValues();
@@ -1165,7 +1175,7 @@ const Filters = {
1165
1175
  _getGlobalFacetedMinMaxValues: instance.options.getFacetedMinMaxValues && instance.options.getFacetedMinMaxValues(instance, '__global__'),
1166
1176
  getGlobalFacetedMinMaxValues: () => {
1167
1177
  if (!instance._getGlobalFacetedMinMaxValues) {
1168
- return [NaN, NaN];
1178
+ return;
1169
1179
  }
1170
1180
 
1171
1181
  return instance._getGlobalFacetedMinMaxValues();
@@ -1402,7 +1412,7 @@ const Grouping = {
1402
1412
  var _column$aggregatedCel;
1403
1413
 
1404
1414
  const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
1405
- return template ? instance.render(template, {
1415
+ return template ? instance._render(template, {
1406
1416
  instance,
1407
1417
  column,
1408
1418
  row,
@@ -1503,25 +1513,32 @@ const Pagination = {
1503
1513
  },
1504
1514
  getDefaultOptions: instance => {
1505
1515
  return {
1506
- onPaginationChange: makeStateUpdater('pagination', instance),
1507
- autoResetPageIndex: true
1516
+ onPaginationChange: makeStateUpdater('pagination', instance)
1508
1517
  };
1509
1518
  },
1510
1519
  createInstance: instance => {
1511
1520
  let registered = false;
1521
+ let queued = false;
1512
1522
  return {
1513
1523
  _autoResetPageIndex: () => {
1524
+ var _ref, _instance$options$aut;
1525
+
1514
1526
  if (!registered) {
1515
- registered = true;
1516
- return;
1517
- }
1527
+ instance._queue(() => {
1528
+ registered = true;
1529
+ });
1518
1530
 
1519
- if (instance.options.autoResetAll === false) {
1520
1531
  return;
1521
1532
  }
1522
1533
 
1523
- if (instance.options.autoResetAll === true || instance.options.autoResetPageIndex) {
1524
- instance.resetPageIndex();
1534
+ if ((_ref = (_instance$options$aut = instance.options.autoResetAll) != null ? _instance$options$aut : instance.options.autoResetPageIndex) != null ? _ref : !instance.options.manualPagination) {
1535
+ if (queued) return;
1536
+ queued = true;
1537
+
1538
+ instance._queue(() => {
1539
+ instance.resetPageIndex();
1540
+ queued = false;
1541
+ });
1525
1542
  }
1526
1543
  },
1527
1544
  setPagination: updater => {
@@ -1540,7 +1557,7 @@ const Pagination = {
1540
1557
  setPageIndex: updater => {
1541
1558
  instance.setPagination(old => {
1542
1559
  let pageIndex = functionalUpdate(updater, old.pageIndex);
1543
- const maxPageIndex = old.pageCount && old.pageCount > 0 ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
1560
+ const maxPageIndex = typeof old.pageCount !== 'undefined' ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
1544
1561
  pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
1545
1562
  return { ...old,
1546
1563
  pageIndex
@@ -2651,12 +2668,12 @@ const Headers = {
2651
2668
  recurseHeader(header);
2652
2669
  return leafHeaders;
2653
2670
  },
2654
- renderHeader: () => column.header ? instance.render(column.header, {
2671
+ renderHeader: () => column.header ? instance._render(column.header, {
2655
2672
  instance,
2656
2673
  header: header,
2657
2674
  column
2658
2675
  }) : null,
2659
- renderFooter: () => column.footer ? instance.render(column.footer, {
2676
+ renderFooter: () => column.footer ? instance._render(column.footer, {
2660
2677
  instance,
2661
2678
  header: header,
2662
2679
  column
@@ -3130,7 +3147,7 @@ function createTableInstance(options) {
3130
3147
  ...options
3131
3148
  },
3132
3149
  initialState,
3133
- queue: cb => {
3150
+ _queue: cb => {
3134
3151
  queued.push(cb);
3135
3152
 
3136
3153
  if (!queuedTimeout) {
@@ -3188,7 +3205,7 @@ function createTableInstance(options) {
3188
3205
  const newOptions = functionalUpdate(updater, instance.options);
3189
3206
  instance.options = mergeOptions(newOptions);
3190
3207
  },
3191
- render: (template, props) => {
3208
+ _render: (template, props) => {
3192
3209
  if (typeof instance.options.render === 'function') {
3193
3210
  return instance.options.render(template, props);
3194
3211
  }
@@ -3362,9 +3379,7 @@ function getCoreRowModel() {
3362
3379
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3363
3380
  },
3364
3381
  onChange: () => {
3365
- instance.queue(() => {
3366
- instance._autoResetPageIndex();
3367
- });
3382
+ instance._autoResetPageIndex();
3368
3383
  }
3369
3384
  });
3370
3385
  }
@@ -3570,9 +3585,7 @@ function getFilteredRowModel() {
3570
3585
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3571
3586
  },
3572
3587
  onChange: () => {
3573
- instance.queue(() => {
3574
- instance._autoResetPageIndex();
3575
- });
3588
+ instance._autoResetPageIndex();
3576
3589
  }
3577
3590
  });
3578
3591
  }
@@ -3640,14 +3653,20 @@ function getFacetedUniqueValues() {
3640
3653
 
3641
3654
  function getFacetedMinMaxValues() {
3642
3655
  return (instance, columnId) => memo(() => [instance.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
3643
- var _facetedRowModel$flat, _facetedRowModel$flat2, _facetedRowModel$flat3, _facetedRowModel$flat4;
3656
+ var _facetedRowModel$flat;
3644
3657
 
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];
3658
+ const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getValue(columnId);
3659
+
3660
+ if (typeof firstValue === 'undefined') {
3661
+ return undefined;
3662
+ }
3663
+
3664
+ let facetedMinMaxValues = [firstValue, firstValue];
3646
3665
 
3647
3666
  for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3648
- var _facetedRowModel$flat5;
3667
+ var _facetedRowModel$flat2;
3649
3668
 
3650
- const value = (_facetedRowModel$flat5 = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat5.getValue(columnId);
3669
+ const value = (_facetedRowModel$flat2 = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat2.getValue(columnId);
3651
3670
 
3652
3671
  if (value < facetedMinMaxValues[0]) {
3653
3672
  facetedMinMaxValues[0] = value;
@@ -3755,9 +3774,7 @@ function getSortedRowModel() {
3755
3774
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3756
3775
  },
3757
3776
  onChange: () => {
3758
- instance.queue(() => {
3759
- instance._autoResetPageIndex();
3760
- });
3777
+ instance._autoResetPageIndex();
3761
3778
  }
3762
3779
  });
3763
3780
  }
@@ -3887,7 +3904,7 @@ function getGroupedRowModel() {
3887
3904
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3888
3905
  },
3889
3906
  onChange: () => {
3890
- instance.queue(() => {
3907
+ instance._queue(() => {
3891
3908
  instance._autoResetExpanded();
3892
3909
 
3893
3910
  instance._autoResetPageIndex();