@tanstack/table-core 8.0.0-alpha.32 → 8.0.0-alpha.34

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 (37) hide show
  1. package/build/cjs/core.js +21 -0
  2. package/build/cjs/core.js.map +1 -1
  3. package/build/cjs/features/RowSelection.js +9 -3
  4. package/build/cjs/features/RowSelection.js.map +1 -1
  5. package/build/cjs/utils/getColumnFilteredRowModelSync.js +3 -1
  6. package/build/cjs/utils/getColumnFilteredRowModelSync.js.map +1 -1
  7. package/build/cjs/utils/getCoreRowModelAsync.js +4 -2
  8. package/build/cjs/utils/getCoreRowModelAsync.js.map +1 -1
  9. package/build/cjs/utils/getCoreRowModelSync.js +4 -2
  10. package/build/cjs/utils/getCoreRowModelSync.js.map +1 -1
  11. package/build/cjs/utils/getGlobalFilteredRowModelSync.js +3 -1
  12. package/build/cjs/utils/getGlobalFilteredRowModelSync.js.map +1 -1
  13. package/build/cjs/utils/getGroupedRowModel.js +3 -1
  14. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  15. package/build/cjs/utils/getSortedRowModelSync.js +3 -1
  16. package/build/cjs/utils/getSortedRowModelSync.js.map +1 -1
  17. package/build/esm/index.js +50 -11
  18. package/build/esm/index.js.map +1 -1
  19. package/build/stats-html.html +1 -1
  20. package/build/stats-react.json +305 -305
  21. package/build/types/core.d.ts +2 -0
  22. package/build/umd/index.development.js +50 -11
  23. package/build/umd/index.development.js.map +1 -1
  24. package/build/umd/index.production.js +1 -1
  25. package/build/umd/index.production.js.map +1 -1
  26. package/package.json +3 -1
  27. package/src/core.tsx +20 -0
  28. package/src/features/RowSelection.ts +5 -3
  29. package/src/utils/getColumnFilteredRowModelAsync.ts +3 -1
  30. package/src/utils/getColumnFilteredRowModelSync.ts +3 -1
  31. package/src/utils/getCoreRowModelAsync.ts +4 -2
  32. package/src/utils/getCoreRowModelSync.ts +4 -2
  33. package/src/utils/getGlobalFilteredRowModelAsync.ts +3 -1
  34. package/src/utils/getGlobalFilteredRowModelSync.ts +3 -1
  35. package/src/utils/getGroupedRowModel.ts +5 -1
  36. package/src/utils/getSortedRowModelAsync.ts +3 -1
  37. package/src/utils/getSortedRowModelSync.ts +3 -1
@@ -28,6 +28,8 @@ export declare type TableCore<TGenerics extends AnyGenerics> = {
28
28
  reset: () => void;
29
29
  options: RequiredKeys<Options<TGenerics>, 'state'>;
30
30
  setOptions: (newOptions: Updater<Options<TGenerics>>) => void;
31
+ queue: (cb: () => void) => void;
32
+ willUpdate: () => void;
31
33
  getRowId: (_: TGenerics['Row'], index: number, parent?: Row<TGenerics>) => string;
32
34
  getState: () => TableState;
33
35
  setState: (updater: Updater<TableState>) => void;
@@ -2236,7 +2236,9 @@
2236
2236
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
2237
2237
  },
2238
2238
  onChange: function onChange() {
2239
- return instance._notifyExpandedReset();
2239
+ instance.queue(function () {
2240
+ return instance._notifyExpandedReset();
2241
+ });
2240
2242
  }
2241
2243
  }),
2242
2244
  getFilteredSelectedRowModel: memo(function () {
@@ -2259,7 +2261,9 @@
2259
2261
  return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugTable;
2260
2262
  },
2261
2263
  onChange: function onChange() {
2262
- return instance._notifyExpandedReset();
2264
+ return instance.queue(function () {
2265
+ return instance._notifyExpandedReset();
2266
+ });
2263
2267
  }
2264
2268
  }),
2265
2269
  getGroupedSelectedRowModel: memo(function () {
@@ -2282,7 +2286,9 @@
2282
2286
  return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugTable;
2283
2287
  },
2284
2288
  onChange: function onChange() {
2285
- return instance._notifyExpandedReset();
2289
+ return instance.queue(function () {
2290
+ return instance._notifyExpandedReset();
2291
+ });
2286
2292
  }
2287
2293
  }),
2288
2294
  ///
@@ -3764,9 +3770,30 @@
3764
3770
  return Object.assign(obj, feature.getInitialState == null ? void 0 : feature.getInitialState());
3765
3771
  }, {}), (_options$initialState = options.initialState) != null ? _options$initialState : {});
3766
3772
 
3773
+ var queued = [];
3774
+ var queuedTimeout;
3775
+
3767
3776
  var finalInstance = _extends({}, instance, features.reduce(function (obj, feature) {
3768
3777
  return Object.assign(obj, feature.getInstance == null ? void 0 : feature.getInstance(instance));
3769
3778
  }, {}), {
3779
+ queue: function queue(cb) {
3780
+ queued.push(cb);
3781
+
3782
+ if (!queuedTimeout) {
3783
+ queuedTimeout = setTimeout(function () {
3784
+ instance.setState(function (old) {
3785
+ return _extends({}, old);
3786
+ });
3787
+ });
3788
+ }
3789
+ },
3790
+ willUpdate: function willUpdate() {
3791
+ clearTimeout(queuedTimeout);
3792
+
3793
+ while (queued.length) {
3794
+ queued.shift()();
3795
+ }
3796
+ },
3770
3797
  initialState: initialState,
3771
3798
  reset: function reset() {
3772
3799
  instance.setState(instance.initialState);
@@ -4331,9 +4358,11 @@
4331
4358
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
4332
4359
  },
4333
4360
  onChange: function onChange() {
4334
- instance._notifyFiltersReset();
4361
+ instance.queue(function () {
4362
+ instance._notifyFiltersReset();
4335
4363
 
4336
- instance._notifyRowSelectionReset();
4364
+ instance._notifyRowSelectionReset();
4365
+ });
4337
4366
  }
4338
4367
  });
4339
4368
  };
@@ -4437,9 +4466,11 @@
4437
4466
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
4438
4467
  },
4439
4468
  onChange: function onChange() {
4440
- instance._notifyFiltersReset();
4469
+ instance.queue(function () {
4470
+ instance._notifyFiltersReset();
4441
4471
 
4442
- instance._notifyRowSelectionReset();
4472
+ instance._notifyRowSelectionReset();
4473
+ });
4443
4474
  }
4444
4475
  });
4445
4476
  };
@@ -4616,7 +4647,9 @@
4616
4647
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
4617
4648
  },
4618
4649
  onChange: function onChange() {
4619
- instance._notifySortingReset();
4650
+ instance.queue(function () {
4651
+ instance._notifySortingReset();
4652
+ });
4620
4653
  }
4621
4654
  });
4622
4655
  };
@@ -4686,7 +4719,9 @@
4686
4719
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
4687
4720
  },
4688
4721
  onChange: function onChange() {
4689
- instance._notifySortingReset();
4722
+ instance.queue(function () {
4723
+ instance._notifySortingReset();
4724
+ });
4690
4725
  }
4691
4726
  });
4692
4727
  };
@@ -4784,7 +4819,9 @@
4784
4819
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
4785
4820
  },
4786
4821
  onChange: function onChange() {
4787
- instance._notifyGroupingReset();
4822
+ instance.queue(function () {
4823
+ instance._notifyGroupingReset();
4824
+ });
4788
4825
  }
4789
4826
  });
4790
4827
  };
@@ -4924,7 +4961,9 @@
4924
4961
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
4925
4962
  },
4926
4963
  onChange: function onChange() {
4927
- return instance._notifyExpandedReset();
4964
+ instance.queue(function () {
4965
+ instance._notifyExpandedReset();
4966
+ });
4928
4967
  }
4929
4968
  });
4930
4969
  };