@infinite-table/infinite-react 0.3.0-canary.0 → 0.3.2

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.
package/index.esm.js CHANGED
@@ -636,7 +636,7 @@ function debounce(fn, { wait }) {
636
636
  // src/components/InfiniteTable/index.tsx
637
637
  import {
638
638
  StrictMode,
639
- createElement as createElement21,
639
+ createElement as createElement22,
640
640
  memo as memo9,
641
641
  useEffect as useEffect23
642
642
  } from "react";
@@ -1010,13 +1010,30 @@ function AvoidReactDiffFn(props) {
1010
1010
  var AvoidReactDiff = memo2(AvoidReactDiffFn);
1011
1011
 
1012
1012
  // src/components/utils/buildSubscriptionCallback.tsx
1013
- function buildSubscriptionCallback() {
1013
+ function buildSubscriptionCallback(withRaf = false) {
1014
1014
  let result = null;
1015
1015
  let fns = [];
1016
- const updater = (items) => {
1017
- result = items;
1018
- for (let i = 0, len = fns.length; i < len; i++) {
1019
- fns[i](items);
1016
+ let rafId = null;
1017
+ const updater = (items, callback) => {
1018
+ if (withRaf) {
1019
+ if (rafId != null) {
1020
+ cancelAnimationFrame(rafId);
1021
+ rafId = null;
1022
+ }
1023
+ requestAnimationFrame(() => {
1024
+ result = items;
1025
+ rafId = null;
1026
+ for (let i = 0, len = fns.length; i < len; i++) {
1027
+ fns[i](items);
1028
+ }
1029
+ callback == null ? void 0 : callback();
1030
+ });
1031
+ } else {
1032
+ result = items;
1033
+ for (let i = 0, len = fns.length; i < len; i++) {
1034
+ fns[i](items);
1035
+ }
1036
+ callback == null ? void 0 : callback();
1020
1037
  }
1021
1038
  };
1022
1039
  updater.get = () => result;
@@ -1057,6 +1074,19 @@ function arrayIntersection(...arrays) {
1057
1074
  });
1058
1075
  }
1059
1076
 
1077
+ // src/utils/getGlobal.ts
1078
+ function getGlobal() {
1079
+ return globalThis;
1080
+ }
1081
+
1082
+ // src/utils/raf.ts
1083
+ var raf = getGlobal().requestAnimationFrame || ((fn) => {
1084
+ return setTimeout(fn, 16);
1085
+ });
1086
+ var cancelRaf = getGlobal().cancelAnimationFrame || ((timeoutId) => {
1087
+ return clearTimeout(timeoutId);
1088
+ });
1089
+
1060
1090
  // src/components/VirtualBrain/MatrixBrain.ts
1061
1091
  var import_binary_search = __toModule(require_binary_search());
1062
1092
  var getRenderRangeCellCount = (range) => {
@@ -1069,7 +1099,7 @@ var getRenderRangeCellCount = (range) => {
1069
1099
  };
1070
1100
  var ALL_DIRECTIONS = { horizontal: true, vertical: true };
1071
1101
  var SORT_ASC = (a, b) => a - b;
1072
- var raf = typeof window !== "undefined" ? requestAnimationFrame : (fn) => setTimeout(fn, 0);
1102
+ var raf2 = typeof window !== "undefined" ? requestAnimationFrame : (fn) => setTimeout(fn, 0);
1073
1103
  var MatrixBrain = class extends Logger {
1074
1104
  constructor() {
1075
1105
  super(`MatrixBrain`);
@@ -1254,7 +1284,7 @@ var MatrixBrain = class extends Logger {
1254
1284
  const fns = this.onAvailableSizeChangeFns;
1255
1285
  const range = this.getAvailableSize();
1256
1286
  for (let i = 0, len = fns.length; i < len; i++) {
1257
- raf(() => {
1287
+ raf2(() => {
1258
1288
  fns[i](range);
1259
1289
  });
1260
1290
  }
@@ -1263,7 +1293,7 @@ var MatrixBrain = class extends Logger {
1263
1293
  const fns = this.onRenderRangeChangeFns;
1264
1294
  const range = this.getRenderRange();
1265
1295
  for (let i = 0, len = fns.length; i < len; i++) {
1266
- raf(() => {
1296
+ raf2(() => {
1267
1297
  fns[i](range);
1268
1298
  });
1269
1299
  }
@@ -1272,7 +1302,7 @@ var MatrixBrain = class extends Logger {
1272
1302
  const fns = this.onVerticalRenderRangeChangeFns;
1273
1303
  const range = this.verticalRenderRange;
1274
1304
  for (let i = 0, len = fns.length; i < len; i++) {
1275
- raf(() => {
1305
+ raf2(() => {
1276
1306
  fns[i]([range.startIndex, range.endIndex]);
1277
1307
  });
1278
1308
  }
@@ -1281,7 +1311,7 @@ var MatrixBrain = class extends Logger {
1281
1311
  const fns = this.onHorizontalRenderRangeChangeFns;
1282
1312
  const range = this.horizontalRenderRange;
1283
1313
  for (let i = 0, len = fns.length; i < len; i++) {
1284
- raf(() => {
1314
+ raf2(() => {
1285
1315
  fns[i]([range.startIndex, range.endIndex]);
1286
1316
  });
1287
1317
  }
@@ -1981,7 +2011,7 @@ var MatrixBrain = class extends Logger {
1981
2011
  };
1982
2012
  const fns = this.onRenderCountChangeFns;
1983
2013
  for (let i = 0, len = fns.length; i < len; i++) {
1984
- raf(() => {
2014
+ raf2(() => {
1985
2015
  fns[i](renderCount);
1986
2016
  });
1987
2017
  }
@@ -2077,6 +2107,20 @@ var DeepMap = class {
2077
2107
  return clone;
2078
2108
  }
2079
2109
  getValuesStartingWith(keys) {
2110
+ const result = [];
2111
+ this.getStartingWith(keys, (_keys, value) => {
2112
+ result.push(value);
2113
+ });
2114
+ return result;
2115
+ }
2116
+ getKeysStartingWith(keys) {
2117
+ const result = [];
2118
+ this.getStartingWith(keys, (keys2) => {
2119
+ result.push(keys2);
2120
+ });
2121
+ return result;
2122
+ }
2123
+ getStartingWith(keys, fn) {
2080
2124
  let currentMap = this.map;
2081
2125
  let pair;
2082
2126
  if (!keys.length) {
@@ -2086,16 +2130,37 @@ var DeepMap = class {
2086
2130
  const key = keys[i];
2087
2131
  pair = currentMap.get(key);
2088
2132
  if (!pair || !pair.map) {
2089
- return [];
2133
+ return;
2090
2134
  }
2091
2135
  currentMap = pair.map;
2092
2136
  }
2093
- const result = pair && pair.value !== void 0 ? [pair.value] : [];
2094
- this.visitWithNext(keys, (value, _key, _i, next) => {
2095
- result.push(value);
2137
+ if (pair && pair.value !== void 0) {
2138
+ fn(keys, pair.value);
2139
+ }
2140
+ this.visitWithNext(keys, (value, keys2, _i, next) => {
2141
+ fn(keys2, value);
2096
2142
  next == null ? void 0 : next();
2097
2143
  }, currentMap);
2098
- return result;
2144
+ }
2145
+ getDirectChildrenSizeFor(keys) {
2146
+ var _a;
2147
+ let currentMap = this.map;
2148
+ if (!keys.length) {
2149
+ keys = [this.emptyKey];
2150
+ }
2151
+ for (let i = 0, len = keys.length; i < len; i++) {
2152
+ const key = keys[i];
2153
+ const last = i === len - 1;
2154
+ const pair = currentMap.get(key);
2155
+ if (!pair || !pair.map) {
2156
+ return 0;
2157
+ }
2158
+ currentMap = pair.map;
2159
+ if (last) {
2160
+ return (_a = currentMap == null ? void 0 : currentMap.size) != null ? _a : 0;
2161
+ }
2162
+ }
2163
+ return 0;
2099
2164
  }
2100
2165
  set(keys, value) {
2101
2166
  let currentMap = this.map;
@@ -2165,7 +2230,7 @@ var DeepMap = class {
2165
2230
  } else {
2166
2231
  keys = [...keys];
2167
2232
  }
2168
- let maps = [currentMap];
2233
+ const maps = [currentMap];
2169
2234
  let result = false;
2170
2235
  for (let i = 0, len = keys.length; i < len; i++) {
2171
2236
  const key = keys[i];
@@ -2454,6 +2519,7 @@ var ReactHeadlessTableRenderer = class extends Logger {
2454
2519
  this.updaters = [];
2455
2520
  this.items = [];
2456
2521
  this.currentHoveredRow = -1;
2522
+ this.hoverRowUpdatesInProgress = new Map();
2457
2523
  this.getExtraSpanCellsForRange = (range) => {
2458
2524
  const { start, end } = range;
2459
2525
  const [startRow, startCol] = start;
@@ -2732,7 +2798,29 @@ var ReactHeadlessTableRenderer = class extends Logger {
2732
2798
  }
2733
2799
  });
2734
2800
  };
2735
- this.updateElementPosition = (elementIndex) => {
2801
+ this.updateHoverClassNamesForRow = (rowIndex) => {
2802
+ if (this.scrolling) {
2803
+ return;
2804
+ }
2805
+ if (this.hoverRowUpdatesInProgress.has(rowIndex)) {
2806
+ return;
2807
+ }
2808
+ this.hoverRowUpdatesInProgress.set(rowIndex, true);
2809
+ const checkHoverClass = () => {
2810
+ if (this.currentHoveredRow != -1 && !this.scrolling) {
2811
+ if (this.currentHoveredRow === rowIndex) {
2812
+ this.addHoverClass(rowIndex);
2813
+ } else {
2814
+ this.removeHoverClass(rowIndex);
2815
+ }
2816
+ }
2817
+ };
2818
+ raf(() => {
2819
+ checkHoverClass();
2820
+ this.hoverRowUpdatesInProgress.delete(rowIndex);
2821
+ });
2822
+ };
2823
+ this.updateElementPosition = (elementIndex, options) => {
2736
2824
  const itemElement = this.itemDOMElements[elementIndex];
2737
2825
  const cell = this.mappedCells.getRenderedCellAtElement(elementIndex);
2738
2826
  if (cell == null) {
@@ -2748,17 +2836,7 @@ var ReactHeadlessTableRenderer = class extends Logger {
2748
2836
  }
2749
2837
  const { x, y } = itemPosition;
2750
2838
  if (itemElement) {
2751
- if (this.currentHoveredRow != -1 && !this.scrolling) {
2752
- if (this.currentHoveredRow === rowIndex) {
2753
- this.cellHoverClassNames.forEach((cls) => {
2754
- itemElement.classList.add(cls);
2755
- });
2756
- } else {
2757
- this.cellHoverClassNames.forEach((cls) => {
2758
- itemElement.classList.remove(cls);
2759
- });
2760
- }
2761
- }
2839
+ this.updateHoverClassNamesForRow(rowIndex);
2762
2840
  if (true) {
2763
2841
  itemElement.dataset.rowIndex = rowIndex;
2764
2842
  itemElement.dataset.colIndex = colIndex;
@@ -2767,7 +2845,8 @@ var ReactHeadlessTableRenderer = class extends Logger {
2767
2845
  itemElement.style.transform = `translate3d(${x}px, ${y}px, 0)`;
2768
2846
  itemElement.style.willChange = "transform";
2769
2847
  itemElement.style.backfaceVisibility = "hidden";
2770
- itemElement.style.zIndex = "auto";
2848
+ const hidden = options ? options.hidden : !!this.isCellCovered(rowIndex, colIndex);
2849
+ itemElement.style.zIndex = hidden ? "-1" : "auto";
2771
2850
  } else {
2772
2851
  itemElement.style.display = "";
2773
2852
  itemElement.style.left = `${x}px`;
@@ -2907,6 +2986,8 @@ var ReactHeadlessTableRenderer = class extends Logger {
2907
2986
  this.destroyed = true;
2908
2987
  this.reset();
2909
2988
  this.onDestroy();
2989
+ this.hoverRowUpdatesInProgress.clear();
2990
+ this.hoverRowUpdatesInProgress = null;
2910
2991
  this.brain = null;
2911
2992
  this.mappedCells = null;
2912
2993
  };
@@ -2915,7 +2996,7 @@ var ReactHeadlessTableRenderer = class extends Logger {
2915
2996
  const removeOnScroll = brain.onScroll(this.adjustFixedElementsOnScroll);
2916
2997
  const removeOnSizeChange = brain.onAvailableSizeChange(() => {
2917
2998
  this.adjustFixedElementsOnScroll();
2918
- requestAnimationFrame(() => {
2999
+ raf(() => {
2919
3000
  this.adjustFixedElementsOnScroll();
2920
3001
  });
2921
3002
  });
@@ -2960,6 +3041,7 @@ var ReactHeadlessTableRenderer = class extends Logger {
2960
3041
  const heightWithRowspan = rowspan === 1 ? height : this.brain.getRowHeightWithSpan(rowIndex, colIndex, rowspan);
2961
3042
  const widthWithColspan = colspan === 1 ? width : this.brain.getColWidthWithSpan(rowIndex, colIndex, colspan);
2962
3043
  const { row: rowFixed, col: colFixed } = this.isCellFixed(rowIndex, colIndex);
3044
+ const hidden = !!covered;
2963
3045
  const renderedNode = renderCell({
2964
3046
  rowIndex,
2965
3047
  colIndex,
@@ -2969,7 +3051,7 @@ var ReactHeadlessTableRenderer = class extends Logger {
2969
3051
  colspan,
2970
3052
  rowFixed,
2971
3053
  colFixed,
2972
- hidden: !!covered,
3054
+ hidden,
2973
3055
  heightWithRowspan,
2974
3056
  widthWithColspan,
2975
3057
  onMouseEnter: this.onMouseEnter.bind(null, rowIndex),
@@ -2986,7 +3068,7 @@ var ReactHeadlessTableRenderer = class extends Logger {
2986
3068
  this.debug(`Render cell ${rowIndex},${colIndex} at element ${elementIndex}`);
2987
3069
  }
2988
3070
  itemUpdater(renderedNode);
2989
- this.updateElementPosition(elementIndex);
3071
+ this.updateElementPosition(elementIndex, { hidden, rowspan, colspan });
2990
3072
  return;
2991
3073
  }
2992
3074
  reset() {
@@ -3465,19 +3547,19 @@ var useInternalProps = () => {
3465
3547
  };
3466
3548
 
3467
3549
  // src/components/InfiniteTable/utilities.css.ts
3468
- var alignItems = { center: "_16lm1iw11", stretch: "_16lm1iw12" };
3469
- var cssEllipsisClassName = "_16lm1iw1a _16lm1iw1b _16lm1iw16";
3470
- var cursor = { pointer: "_16lm1iwb" };
3471
- var display = { flex: "_16lm1iwj", block: "_16lm1iwk", inlineBlock: "_16lm1iwl" };
3472
- var flex = { "1": "_16lm1iwc", none: "_16lm1iwd" };
3473
- var justifyContent = { center: "_16lm1iw13", start: "_16lm1iw14", end: "_16lm1iw15" };
3474
- var left = { "0": "_16lm1iwt", "100%": "_16lm1iwu" };
3475
- var overflow = { hidden: "_16lm1iw16", auto: "_16lm1iw17", visible: "_16lm1iw18" };
3550
+ var alignItems = { center: "_16lm1iw13", stretch: "_16lm1iw14" };
3551
+ var cssEllipsisClassName = "_16lm1iw1c _16lm1iw1d _16lm1iw18";
3552
+ var cursor = { pointer: "_16lm1iwd" };
3553
+ var display = { flex: "_16lm1iwl", block: "_16lm1iwm", inlineBlock: "_16lm1iwn" };
3554
+ var flex = { "1": "_16lm1iwe", none: "_16lm1iwf" };
3555
+ var justifyContent = { center: "_16lm1iw15", start: "_16lm1iw16", end: "_16lm1iw17" };
3556
+ var left = { "0": "_16lm1iwv", "100%": "_16lm1iww" };
3557
+ var overflow = { hidden: "_16lm1iw18", auto: "_16lm1iw19", visible: "_16lm1iw1a" };
3476
3558
  var position = { relative: "_16lm1iw1", absolute: "_16lm1iw2", sticky: "_16lm1iw3", fixed: "_16lm1iw4" };
3477
- var top = { "0": "_16lm1iwr", "100%": "_16lm1iws" };
3478
- var transformTranslateZero = "_16lm1iw8";
3479
- var userSelect = { none: "_16lm1iwm" };
3480
- var zIndex = { "1": "_16lm1iwe", "10": "_16lm1iwf", "1000": "_16lm1iwg", "10000": "_16lm1iwh", "100000": "_16lm1iwi" };
3559
+ var top = { "0": "_16lm1iwt", "100%": "_16lm1iwu" };
3560
+ var transformTranslateZero = "_16lm1iwa";
3561
+ var userSelect = { none: "_16lm1iwo" };
3562
+ var zIndex = { "1": "_16lm1iwg", "10": "_16lm1iwh", "1000": "_16lm1iwi", "10000": "_16lm1iwj", "100000": "_16lm1iwk" };
3481
3563
 
3482
3564
  // src/components/InfiniteTable/components/InfiniteTableBody/InfiniteTableBody.tsx
3483
3565
  var InfiniteTableBody = forwardRef2(function InfiniteTableBody2(props, ref) {
@@ -3527,7 +3609,7 @@ var useInfiniteTableState = () => {
3527
3609
  // src/components/InfiniteTable/components/cell.css.ts
3528
3610
  var import_createRuntimeFn = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
3529
3611
  var CellClsVariants = { shifting: "_1eexc2a3", dragging: "_1eexc2a4" };
3530
- var ColumnCellCls = "_1eexc2a5 _16lm1iwj _16lm1iw10 _16lm1iw11 _16lm1iw2 _16lm1iw19 _16lm1iw1a";
3612
+ var ColumnCellCls = "_1eexc2a5 _16lm1iwl _16lm1iw12 _16lm1iw13 _16lm1iw2 _16lm1iw1b _16lm1iw1c";
3531
3613
  var ColumnCellRecipe = (0, import_createRuntimeFn.createRuntimeFn)({ defaultClassName: "_1eexc2a7", variantClassNames: { dragging: { false: "_1eexc2a8", true: "_1eexc2a9" }, zebra: { false: "_1eexc2aa", even: "_1eexc2ab", odd: "_1eexc2ac" }, first: { true: "_1eexc2ad", false: "_1eexc2ae" }, last: { true: "_1eexc2af", false: "_1eexc2ag" }, groupByField: { true: "_1eexc2ah", false: "_1eexc2ai" }, firstInCategory: { true: "_1eexc2aj", false: "_1eexc2ak" }, lastInCategory: { true: "_1eexc2al", false: "_1eexc2am" }, pinned: { start: "_1eexc2an", end: "_1eexc2ao", false: "_1eexc2ap" } }, defaultVariants: {}, compoundVariants: [[{ pinned: "start", lastInCategory: true }, "_1eexc2aq"], [{ pinned: "end", firstInCategory: true }, "_1eexc2ar"]] });
3532
3614
  var columnAlignCellStyle = { center: "_1eexc2a0", start: "_1eexc2a1", end: "_1eexc2a2" };
3533
3615
 
@@ -3876,18 +3958,19 @@ function SortIcon(props) {
3876
3958
 
3877
3959
  // src/components/InfiniteTable/components/InfiniteTableHeader/header.css.ts
3878
3960
  var import_createRuntimeFn2 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
3879
- var CellCls = "_1eexc2a5 _16lm1iwj _16lm1iw10 _16lm1iw11 _16lm1iw2 _16lm1iw19 _16lm1iw1a";
3961
+ var CellCls = "_1eexc2a5 _16lm1iwl _16lm1iw12 _16lm1iw13 _16lm1iw2 _16lm1iw1b _16lm1iw1c";
3880
3962
  var HeaderCellProxy = "_12zfob10";
3881
3963
  var HeaderCellRecipe = (0, import_createRuntimeFn2.createRuntimeFn)({ defaultClassName: "_12zfob1d", variantClassNames: { zebra: { false: "_12zfob1e", even: "_12zfob1f", odd: "_12zfob1g" }, dragging: { true: "_12zfob1h", false: "_12zfob1i" }, first: { true: "_12zfob1j", false: "_12zfob1k" }, last: { true: "_12zfob1l", false: "_12zfob1m" }, groupByField: { true: "_12zfob1n", false: "_12zfob1o" }, firstInCategory: { true: "_12zfob1p", false: "_12zfob1q" }, lastInCategory: { true: "_12zfob1r", false: "_12zfob1s" }, pinned: { start: "_12zfob1t", end: "_12zfob1u", false: "_12zfob1v" } }, defaultVariants: {}, compoundVariants: [[{ pinned: "start", lastInCategory: true }, "_12zfob1w"], [{ pinned: "end", firstInCategory: true }, "_12zfob1x"], [{ pinned: false, lastInCategory: true }, "_12zfob1y"]] });
3882
- var HeaderClsRecipe = (0, import_createRuntimeFn2.createRuntimeFn)({ defaultClassName: "_12zfob13 _16lm1iw10 _16lm1iw2", variantClassNames: { pinned: { start: "_12zfob14", end: "_12zfob15", false: "_12zfob16" }, virtualized: { true: "_12zfob17", false: "_12zfob18" }, overflow: { true: "_12zfob19", false: "_12zfob1a" } }, defaultVariants: {}, compoundVariants: [[{ overflow: true, pinned: "start" }, "_12zfob1b"], [{ overflow: true, pinned: "end" }, "_12zfob1c"]] });
3883
- var HeaderGroupCls = "_12zfob110 _16lm1iwj _16lm1iw10 _16lm1iw11";
3964
+ var HeaderClsRecipe = (0, import_createRuntimeFn2.createRuntimeFn)({ defaultClassName: "_12zfob13 _16lm1iw12 _16lm1iw2", variantClassNames: { pinned: { start: "_12zfob14", end: "_12zfob15", false: "_12zfob16" }, virtualized: { true: "_12zfob17", false: "_12zfob18" }, overflow: { true: "_12zfob19", false: "_12zfob1a" } }, defaultVariants: {}, compoundVariants: [[{ overflow: true, pinned: "start" }, "_12zfob1b"], [{ overflow: true, pinned: "end" }, "_12zfob1c"]] });
3965
+ var HeaderGroupCls = "_12zfob110 _16lm1iwl _16lm1iw12 _16lm1iw13";
3884
3966
  var HeaderScrollbarPlaceholderCls = "_12zfob12 _16lm1iw2";
3885
3967
  var HeaderSortIconCls = "_12zfob11 _16lm1iw1";
3886
- var HeaderWrapperCls = "_12zfob1z _16lm1iw16 _16lm1iw1 _16lm1iwj _16lm1iw10";
3968
+ var HeaderWrapperCls = "_12zfob1z _16lm1iw18 _16lm1iw1 _16lm1iwl _16lm1iw12";
3887
3969
 
3888
3970
  // src/components/InfiniteTable/utils/RenderHookComponent.tsx
3889
3971
  function RenderHookComponent(props) {
3890
- return props.render(props.renderParam);
3972
+ var _a;
3973
+ return (_a = props.render(props.renderParam)) != null ? _a : null;
3891
3974
  }
3892
3975
 
3893
3976
  // src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderCell.tsx
@@ -3997,11 +4080,6 @@ import {
3997
4080
  useMemo as useMemo5
3998
4081
  } from "react";
3999
4082
 
4000
- // src/utils/getGlobal.ts
4001
- function getGlobal() {
4002
- return globalThis;
4003
- }
4004
-
4005
4083
  // src/components/utils/getScrollbarWidth.ts
4006
4084
  var scrollbarWidth;
4007
4085
  function getScrollbarWidth() {
@@ -4353,9 +4431,9 @@ var ThemeVars = { color: { accent: "var(--infinite-accent-color)", color: "var(-
4353
4431
  // src/components/InfiniteTable/InfiniteCls.css.ts
4354
4432
  var import_createRuntimeFn3 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
4355
4433
  var FooterCls = "_16lm1iw1";
4356
- var InfiniteCls = "_1yeub2v0 _16lm1iw1 _16lm1iwj _16lm1iwz _16lm1iw0";
4434
+ var InfiniteCls = "_1yeub2v0 _16lm1iw1 _16lm1iwl _16lm1iw11 _16lm1iw0";
4357
4435
  var InfiniteClsRecipe = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "", variantClassNames: { focused: { true: "_1yeub2v2", false: "_1yeub2v3" }, focusedWithin: { true: "_1yeub2v4", false: "_1yeub2v5" }, hasPinnedStart: { true: "_1yeub2v6", false: "_1yeub2v7" }, hasPinnedEnd: { true: "_1yeub2v8", false: "_1yeub2v9" }, hasPinnedStartOverflow: { true: "_1yeub2va", false: "_1yeub2vb" }, hasPinnedEndOverflow: { true: "_1yeub2vc", false: "_1yeub2vd" } }, defaultVariants: {}, compoundVariants: [] });
4358
- var InfiniteClsShiftingColumns = "_16lm1iwm";
4436
+ var InfiniteClsShiftingColumns = "_16lm1iwo";
4359
4437
  var PinnedRowsContainerClsVariants = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "", variantClassNames: { pinned: { start: "_1yeub2vh", end: "_1yeub2vi", false: "_1yeub2vj" } }, defaultVariants: {}, compoundVariants: [] });
4360
4438
 
4361
4439
  // src/components/InfiniteTable/components/InfiniteTableLicenseFooter/index.tsx
@@ -4443,6 +4521,8 @@ function InfiniteTableColumnCellFn(props) {
4443
4521
  var _a;
4444
4522
  const {
4445
4523
  rowInfo,
4524
+ rowStyle,
4525
+ rowClassName,
4446
4526
  width,
4447
4527
  column,
4448
4528
  onMouseLeave,
@@ -4461,40 +4541,51 @@ function InfiniteTableColumnCellFn(props) {
4461
4541
  ref: domRef
4462
4542
  }, "no column");
4463
4543
  }
4464
- const { data, isGroupRow, groupBy } = rowInfo;
4544
+ const { data, isGroupRow, dataSourceHasGrouping } = rowInfo;
4545
+ const groupBy = dataSourceHasGrouping ? rowInfo.groupBy : void 0;
4465
4546
  const groupRowInfo = null;
4466
4547
  let value = isGroupRow && groupBy && column.groupByField ? rowInfo.value : isColumnWithField(column) ? data == null ? void 0 : data[column.field] : null;
4467
4548
  if (column.valueGetter) {
4468
4549
  value = column.valueGetter(isGroupRow ? {
4469
4550
  data: rowInfo.data,
4551
+ isGroupRow,
4470
4552
  rowInfo
4471
4553
  } : {
4472
4554
  data: rowInfo.data,
4555
+ isGroupRow,
4473
4556
  rowInfo
4474
4557
  });
4475
4558
  }
4476
4559
  const { componentState: computedDataSource } = useDataSourceContextValue();
4477
4560
  const rest = rowInfo.isGroupRow ? {
4478
4561
  rowInfo,
4562
+ isGroupRow: rowInfo.isGroupRow,
4479
4563
  data: rowInfo.data
4480
4564
  } : {
4481
4565
  rowInfo,
4566
+ isGroupRow: rowInfo.isGroupRow,
4482
4567
  data: rowInfo.data
4483
4568
  };
4484
4569
  const stylingRenderParam = __spreadValues({
4485
4570
  value,
4486
4571
  column
4487
4572
  }, rest);
4488
- let renderValue = value;
4573
+ const renderValue = value;
4489
4574
  const renderParam = __spreadProps(__spreadValues({
4490
4575
  value,
4491
4576
  column,
4492
4577
  domRef,
4493
4578
  groupRowInfo
4494
4579
  }, rest), {
4580
+ isGroupRow,
4495
4581
  rowIndex,
4496
4582
  toggleGroupRow,
4497
- toggleCurrentGroupRow: () => toggleGroupRow(rowInfo.groupKeys),
4583
+ toggleCurrentGroupRow: () => {
4584
+ if (!rowInfo.isGroupRow) {
4585
+ return;
4586
+ }
4587
+ toggleGroupRow(rowInfo.groupKeys);
4588
+ },
4498
4589
  groupBy: computedDataSource.groupBy,
4499
4590
  pivotBy: computedDataSource.pivotBy
4500
4591
  });
@@ -4511,8 +4602,16 @@ function InfiniteTableColumnCellFn(props) {
4511
4602
  }
4512
4603
  return renderValue;
4513
4604
  };
4605
+ const rowPropsAndStyleArgs = __spreadProps(__spreadValues({}, rest), {
4606
+ rowIndex
4607
+ });
4608
+ const rowComputedClassName = typeof rowClassName === "function" ? rowClassName(rowPropsAndStyleArgs) : rowClassName;
4514
4609
  const colClassName = column.className ? typeof column.className === "function" ? column.className(stylingRenderParam) : column.className : void 0;
4515
- const style = column.style ? typeof column.style === "function" ? column.style(stylingRenderParam) || {} : __spreadValues({}, column.style) : {};
4610
+ let style;
4611
+ if (rowStyle) {
4612
+ style = typeof rowStyle === "function" ? __spreadValues(__spreadValues({}, style), rowStyle(rowPropsAndStyleArgs)) : __spreadValues(__spreadValues({}, style), rowStyle);
4613
+ }
4614
+ style = column.style ? typeof column.style === "function" ? __spreadValues(__spreadValues({}, style), column.style(stylingRenderParam) || {}) : __spreadValues(__spreadValues({}, style), column.style) : style || {};
4516
4615
  style.width = width;
4517
4616
  style.height = rowHeight;
4518
4617
  const odd = (rowInfo.indexInAll != null ? rowInfo.indexInAll : rowIndex) % 2 === 1;
@@ -4528,7 +4627,7 @@ function InfiniteTableColumnCellFn(props) {
4528
4627
  onMouseLeave,
4529
4628
  onMouseEnter,
4530
4629
  cssEllipsis: (_a = column.cssEllipsis) != null ? _a : true,
4531
- className: join(useCellClassName(column, [InfiniteTableColumnCellClassName, InfiniteTableCellClassName], ColumnCellRecipe, { dragging: false, zebra }), colClassName),
4630
+ className: join(useCellClassName(column, [InfiniteTableColumnCellClassName, InfiniteTableCellClassName], ColumnCellRecipe, { dragging: false, zebra }), colClassName, rowComputedClassName),
4532
4631
  renderChildren
4533
4632
  };
4534
4633
  const ContextProvider = InfiniteTableColumnCellContext.Provider;
@@ -4555,8 +4654,8 @@ import {
4555
4654
  } from "react";
4556
4655
 
4557
4656
  // src/components/InfiniteTable/components/LoadMask.css.ts
4558
- var LoadMaskCls = { visible: "qy58ya1 qy58ya0 _16lm1iw2 _16lm1iwr _16lm1iwt _16lm1iwx _16lm1iwv", hidden: "qy58ya2 qy58ya0 _16lm1iw2 _16lm1iwr _16lm1iwt _16lm1iwx _16lm1iwv" };
4559
- var LoadMaskOverlayCls = "qy58ya3 _16lm1iw2 _16lm1iwr _16lm1iwt _16lm1iwx _16lm1iwv";
4657
+ var LoadMaskCls = { visible: "qy58ya1 qy58ya0 _16lm1iw2 _16lm1iwt _16lm1iwv _16lm1iwz _16lm1iwx", hidden: "qy58ya2 qy58ya0 _16lm1iw2 _16lm1iwt _16lm1iwv _16lm1iwz _16lm1iwx" };
4658
+ var LoadMaskOverlayCls = "qy58ya3 _16lm1iw2 _16lm1iwt _16lm1iwv _16lm1iwz _16lm1iwx";
4560
4659
  var LoadMaskTextCls = "qy58ya4";
4561
4660
 
4562
4661
  // src/components/InfiniteTable/components/LoadMask.tsx
@@ -4589,7 +4688,6 @@ function getColumnContentMaxWidths(domRef, options) {
4589
4688
  const measuredMaxWidths = {};
4590
4689
  const computedPaddingsForColumns = {};
4591
4690
  if (match && match.length) {
4592
- console.log(match);
4593
4691
  match.forEach((content) => {
4594
4692
  const cell = content.parentElement;
4595
4693
  const isHeader = cell.matches(`.${InfiniteTableHeaderCellClassName}`);
@@ -4766,6 +4864,8 @@ function useCellRendering(param) {
4766
4864
  groupRenderStrategy,
4767
4865
  brain,
4768
4866
  showZebraRows,
4867
+ rowStyle,
4868
+ rowClassName,
4769
4869
  onScrollToTop,
4770
4870
  onScrollToBottom,
4771
4871
  scrollToBottomOffset
@@ -4860,7 +4960,9 @@ function useCellRendering(param) {
4860
4960
  onMouseLeave,
4861
4961
  domRef,
4862
4962
  width,
4863
- column
4963
+ column,
4964
+ rowStyle,
4965
+ rowClassName
4864
4966
  };
4865
4967
  return /* @__PURE__ */ React22.createElement(InfiniteTableColumnCell, __spreadValues({}, cellProps));
4866
4968
  }, [
@@ -4870,7 +4972,9 @@ function useCellRendering(param) {
4870
4972
  groupRenderStrategy,
4871
4973
  toggleGroupRow,
4872
4974
  showZebraRows,
4873
- repaintId
4975
+ repaintId,
4976
+ rowStyle,
4977
+ rowClassName
4874
4978
  ]);
4875
4979
  return {
4876
4980
  renderCell
@@ -5026,6 +5130,9 @@ function useColumnRowspan(computedVisibleColumns) {
5026
5130
  return colsWithRowspan.length ? ({ rowIndex, colIndex }) => {
5027
5131
  const dataArray = getDataSourceState().dataArray;
5028
5132
  const rowInfo = dataArray[rowIndex];
5133
+ if (!rowInfo) {
5134
+ return 1;
5135
+ }
5029
5136
  const data = rowInfo.data;
5030
5137
  const column = computedVisibleColumns[colIndex];
5031
5138
  if (!column || !column.rowspan) {
@@ -5062,9 +5169,22 @@ import { useEffect as useEffect19, useMemo as useMemo8 } from "react";
5062
5169
 
5063
5170
  // src/components/InfiniteTable/utils/getColumnForGroupBy.tsx
5064
5171
  import {
5065
- createElement as createElement19
5172
+ createElement as createElement20
5066
5173
  } from "react";
5067
5174
 
5175
+ // src/utils/stripVar.ts
5176
+ function stripVar(cssVariableWithVarString) {
5177
+ return cssVariableWithVarString.slice(4, -1);
5178
+ }
5179
+
5180
+ // src/components/DataSource/state/rowInfoStatus.ts
5181
+ var showLoadingIcon = (rowInfo) => {
5182
+ if (rowInfo.dataSourceHasGrouping) {
5183
+ return rowInfo.isGroupRow ? rowInfo.childrenLoading || !rowInfo.selfLoaded : !rowInfo.selfLoaded;
5184
+ }
5185
+ return !rowInfo.selfLoaded;
5186
+ };
5187
+
5068
5188
  // src/components/InfiniteTable/components/icons/ExpanderIcon.tsx
5069
5189
  import {
5070
5190
  createElement as createElement18,
@@ -5074,8 +5194,8 @@ import { useState as useState8 } from "react";
5074
5194
 
5075
5195
  // src/components/InfiniteTable/components/icons/ExpanderIcon.css.ts
5076
5196
  var import_createRuntimeFn5 = __toModule(require_vanilla_extract_recipes_createRuntimeFn_cjs());
5077
- var ExpanderIconCls = "_16lm1iw6 _16lm1iwd _16lm1iwb";
5078
- var ExpanderIconClsVariants = (0, import_createRuntimeFn5.createRuntimeFn)({ defaultClassName: "", variantClassNames: { expanded: { true: "_16lm1iwa", false: "_198z9782" } }, defaultVariants: {}, compoundVariants: [] });
5197
+ var ExpanderIconCls = "_16lm1iw6 _16lm1iwf _16lm1iwd";
5198
+ var ExpanderIconClsVariants = (0, import_createRuntimeFn5.createRuntimeFn)({ defaultClassName: "", variantClassNames: { expanded: { true: "_16lm1iwc", false: "_198z9782" } }, defaultVariants: {}, compoundVariants: [] });
5079
5199
 
5080
5200
  // src/components/InfiniteTable/components/icons/ExpanderIcon.tsx
5081
5201
  function ExpanderIcon(props) {
@@ -5110,6 +5230,45 @@ function ExpanderIcon(props) {
5110
5230
  }));
5111
5231
  }
5112
5232
 
5233
+ // src/components/InfiniteTable/components/icons/LoadingIcon.tsx
5234
+ import {
5235
+ createElement as createElement19
5236
+ } from "react";
5237
+
5238
+ // src/components/InfiniteTable/components/icons/LoadingIcon.css.ts
5239
+ var LoadingIconCls = "_16lm1iw8 _16lm1iwf _16lm1iwd";
5240
+
5241
+ // src/components/InfiniteTable/components/icons/LoadingIcon.tsx
5242
+ var LoadingIcon = (props) => {
5243
+ return /* @__PURE__ */ createElement19("svg", {
5244
+ xmlns: "http://www.w3.org/2000/svg",
5245
+ style: {
5246
+ margin: "auto",
5247
+ display: "block",
5248
+ shapeRendering: "auto"
5249
+ },
5250
+ width: "24px",
5251
+ height: "24px",
5252
+ viewBox: "0 0 100 100",
5253
+ preserveAspectRatio: "xMidYMid",
5254
+ className: join(props.className, LoadingIconCls, "InfiniteIcon", "InfiniteIcon-loading")
5255
+ }, /* @__PURE__ */ createElement19("circle", {
5256
+ cx: "50",
5257
+ cy: "50",
5258
+ fill: "none",
5259
+ strokeWidth: "10",
5260
+ r: "35",
5261
+ strokeDasharray: "164.93361431346415 56.97787143782138"
5262
+ }, /* @__PURE__ */ createElement19("animateTransform", {
5263
+ attributeName: "transform",
5264
+ type: "rotate",
5265
+ repeatCount: "indefinite",
5266
+ dur: "1s",
5267
+ values: "0 50 50;360 50 50",
5268
+ keyTimes: "0;1"
5269
+ })));
5270
+ };
5271
+
5113
5272
  // src/components/InfiniteTable/utils/getColumnForGroupBy.tsx
5114
5273
  function getGroupColumnRender({
5115
5274
  groupIndexForColumn,
@@ -5120,12 +5279,12 @@ function getGroupColumnRender({
5120
5279
  var _a, _b, _c;
5121
5280
  let { value, rowInfo, column, groupBy, pivotBy } = renderOptions;
5122
5281
  if (column.renderValue) {
5123
- value = /* @__PURE__ */ createElement19(RenderHookComponent, {
5282
+ value = /* @__PURE__ */ createElement20(RenderHookComponent, {
5124
5283
  render: column.renderValue,
5125
5284
  renderParam: renderOptions
5126
5285
  });
5127
5286
  }
5128
- let groupRowInfo = groupRenderStrategy !== "inline" ? rowInfo : ((_a = rowInfo.parents) == null ? void 0 : _a[groupIndexForColumn]) || rowInfo;
5287
+ const groupRowInfo = groupRenderStrategy !== "inline" ? rowInfo : rowInfo.isGroupRow && ((_a = rowInfo.parents) == null ? void 0 : _a[groupIndexForColumn]) || rowInfo;
5129
5288
  if (!groupRowInfo) {
5130
5289
  return null;
5131
5290
  }
@@ -5148,31 +5307,30 @@ function getGroupColumnRender({
5148
5307
  }
5149
5308
  let icon = null;
5150
5309
  const showExpanderIcon = pivotBy ? (((_b = groupRowInfo.groupKeys) == null ? void 0 : _b.length) || 0) < (groupBy == null ? void 0 : groupBy.length) : (((_c = groupRowInfo.groupKeys) == null ? void 0 : _c.length) || 0) <= (groupBy == null ? void 0 : groupBy.length);
5151
- if (showExpanderIcon) {
5152
- const defaultIcon = /* @__PURE__ */ createElement19(ExpanderIcon, {
5310
+ const isLoading = showLoadingIcon(groupRowInfo);
5311
+ if (isLoading) {
5312
+ icon = /* @__PURE__ */ createElement20(LoadingIcon, null);
5313
+ } else if (showExpanderIcon) {
5314
+ const defaultIcon = /* @__PURE__ */ createElement20(ExpanderIcon, {
5153
5315
  expanded: !collapsed,
5154
5316
  onChange: () => {
5155
5317
  toggleGroupRow(groupKeys);
5156
5318
  }
5157
5319
  });
5158
- icon = column.renderGroupIcon ? /* @__PURE__ */ createElement19(RenderHookComponent, {
5320
+ icon = column.renderGroupIcon ? /* @__PURE__ */ createElement20(RenderHookComponent, {
5159
5321
  render: column.renderGroupIcon,
5160
5322
  renderParam: Object.assign({ collapsed, groupIcon: defaultIcon }, renderOptions)
5161
5323
  }) : defaultIcon;
5162
5324
  }
5163
- return /* @__PURE__ */ createElement19("div", {
5325
+ return /* @__PURE__ */ createElement20("div", {
5164
5326
  className: join(display.flex, alignItems.center)
5165
- }, icon, /* @__PURE__ */ createElement19("div", {
5327
+ }, icon, /* @__PURE__ */ createElement20("div", {
5166
5328
  className: cssEllipsisClassName
5167
5329
  }, value != null ? value : null));
5168
5330
  };
5169
5331
  }
5170
5332
  function getColumnForGroupBy(options, toggleGroupRow, groupColumnFromProps) {
5171
- const {
5172
- groupByForColumn,
5173
- groupIndexForColumn,
5174
- groupRenderStrategy
5175
- } = options;
5333
+ const { groupByForColumn, groupIndexForColumn, groupRenderStrategy } = options;
5176
5334
  let generatedGroupColumn = __spreadValues({
5177
5335
  header: `Group by ${groupByForColumn.field}`,
5178
5336
  groupByField: groupByForColumn.field,
@@ -5197,30 +5355,40 @@ function getSingleGroupColumn(options, toggleGroupRow, groupColumnFromProps) {
5197
5355
  header: `Group`,
5198
5356
  groupByField: options.groupBy.map((g) => g.field),
5199
5357
  sortable: false,
5358
+ style: ({ rowInfo }) => ({
5359
+ [stripVar(ThemeVars.components.Row.groupNesting)]: rowInfo.isGroupRow ? rowInfo.groupNesting - 1 : 0
5360
+ }),
5200
5361
  render: (renderOptions) => {
5201
5362
  var _a, _b;
5202
5363
  let { value, rowInfo, column, groupBy, pivotBy } = renderOptions;
5203
- if (!rowInfo.isGroupRow) {
5204
- return null;
5205
- }
5206
5364
  if (column.renderValue) {
5207
5365
  value = column.renderValue(renderOptions);
5208
5366
  }
5209
- const collapsed = rowInfo.collapsed;
5367
+ const collapsed = rowInfo.isGroupRow ? rowInfo.collapsed : false;
5210
5368
  let icon = null;
5211
- const showExpanderIcon = pivotBy ? (((_a = rowInfo.groupKeys) == null ? void 0 : _a.length) || 0) < (groupBy == null ? void 0 : groupBy.length) : (((_b = rowInfo.groupKeys) == null ? void 0 : _b.length) || 0) <= (groupBy == null ? void 0 : groupBy.length);
5212
- if (showExpanderIcon) {
5213
- const defaultIcon = /* @__PURE__ */ createElement19(ExpanderIcon, {
5369
+ const showExpanderIcon = rowInfo.isGroupRow ? pivotBy ? (((_a = rowInfo.groupKeys) == null ? void 0 : _a.length) || 0) < (groupBy == null ? void 0 : groupBy.length) : (((_b = rowInfo.groupKeys) == null ? void 0 : _b.length) || 0) <= (groupBy == null ? void 0 : groupBy.length) : false;
5370
+ const isLoading = showLoadingIcon(rowInfo);
5371
+ if (isLoading) {
5372
+ icon = /* @__PURE__ */ createElement20(LoadingIcon, null);
5373
+ } else if (showExpanderIcon) {
5374
+ const defaultIcon = /* @__PURE__ */ createElement20(ExpanderIcon, {
5214
5375
  expanded: !collapsed,
5215
5376
  onChange: () => {
5377
+ if (!rowInfo.isGroupRow) {
5378
+ return;
5379
+ }
5216
5380
  toggleGroupRow(rowInfo.groupKeys);
5217
5381
  }
5218
5382
  });
5219
- icon = column.renderGroupIcon ? column.renderGroupIcon(Object.assign({ collapsed, groupIcon: defaultIcon }, renderOptions)) : defaultIcon;
5383
+ icon = defaultIcon;
5384
+ if (column.renderGroupIcon) {
5385
+ const renderParam = Object.assign({ collapsed, groupIcon: defaultIcon }, renderOptions);
5386
+ icon = column.renderGroupIcon(renderParam);
5387
+ }
5220
5388
  }
5221
- return /* @__PURE__ */ createElement19("div", {
5389
+ return /* @__PURE__ */ createElement20("div", {
5222
5390
  className: join(display.flex, alignItems.center, GroupRowExpanderCls)
5223
- }, icon, /* @__PURE__ */ createElement19("div", {
5391
+ }, icon, /* @__PURE__ */ createElement20("div", {
5224
5392
  className: cssEllipsisClassName
5225
5393
  }, value != null ? value : null));
5226
5394
  }
@@ -5259,89 +5427,6 @@ function useEffectWithRaf(fn, deps) {
5259
5427
  // src/components/InfiniteTable/hooks/useToggleGroupRow.ts
5260
5428
  import { useCallback as useCallback13 } from "react";
5261
5429
 
5262
- // src/components/DataSource/index.tsx
5263
- import {
5264
- Fragment as Fragment2,
5265
- createElement as createElement20
5266
- } from "react";
5267
-
5268
- // src/utils/multisort/sortTypes.ts
5269
- var numberComparator = function(first, second) {
5270
- return first - second;
5271
- };
5272
- var stringComparator = function(first, second) {
5273
- first = `${first}`;
5274
- second = `${second}`;
5275
- return first.localeCompare(second);
5276
- };
5277
- var sortTypes = {
5278
- number: numberComparator,
5279
- string: stringComparator
5280
- };
5281
- var sortTypes_default = sortTypes;
5282
-
5283
- // src/utils/multisort/index.ts
5284
- var multisort = (sortInfo, array, get) => {
5285
- array.sort(getMultisortFunction(sortInfo, get));
5286
- return array;
5287
- };
5288
- multisort.knownTypes = sortTypes_default;
5289
- var getSingleSortFunction = (info) => {
5290
- if (!info) {
5291
- return;
5292
- }
5293
- const field = info.field;
5294
- var dir = info.dir < 0 ? -1 : info.dir > 0 ? 1 : 0;
5295
- if (!dir) {
5296
- return;
5297
- }
5298
- let fn = info.fn;
5299
- if (!fn && info.type) {
5300
- fn = multisort.knownTypes[info.type];
5301
- if (!fn) {
5302
- console.warn(`Unknown sort type "${info.type}" - please pass one of ${Object.keys(multisort.knownTypes).join(", ")}`);
5303
- }
5304
- }
5305
- if (!fn) {
5306
- fn = sortTypes_default.string;
5307
- }
5308
- return (first, second) => {
5309
- const a = field ? first[field] : first;
5310
- const b = field ? second[field] : second;
5311
- return dir * fn(a, b);
5312
- };
5313
- };
5314
- var getSortFunctions = (sortInfo) => {
5315
- return sortInfo.map(getSingleSortFunction).filter((fn) => fn instanceof Function);
5316
- };
5317
- var getMultisortFunction = (sortInfo, get) => {
5318
- const fns = getSortFunctions(sortInfo);
5319
- return (first, second) => {
5320
- if (get) {
5321
- first = get(first);
5322
- second = get(second);
5323
- }
5324
- let result = 0;
5325
- let i = 0;
5326
- let fn;
5327
- const len = fns.length;
5328
- for (; i < len; i++) {
5329
- fn = fns[i];
5330
- if (!fn) {
5331
- continue;
5332
- }
5333
- result = fn(first, second);
5334
- if (result !== 0) {
5335
- return result;
5336
- }
5337
- }
5338
- return result;
5339
- };
5340
- };
5341
-
5342
- // src/components/DataSource/privateHooks/useLoadData.ts
5343
- import { useEffect as useEffect18, useMemo as useMemo7, useRef as useRef17, useState as useState9 } from "react";
5344
-
5345
5430
  // src/utils/groupAndPivot/index.ts
5346
5431
  var LAZY_ROOT_KEY_FOR_GROUPS = "____root____";
5347
5432
  var NOT_LOADED_YET_KEY_PREFIX = "____not_loaded_yet____";
@@ -5353,7 +5438,7 @@ function initReducers(reducers) {
5353
5438
  return {};
5354
5439
  }
5355
5440
  const result = {};
5356
- for (let key in reducers)
5441
+ for (const key in reducers)
5357
5442
  if (reducers.hasOwnProperty(key)) {
5358
5443
  result[key] = reducers[key].initialValue;
5359
5444
  }
@@ -5364,7 +5449,7 @@ function computeReducersFor(data, reducers, reducerResults) {
5364
5449
  if (!reducers || !Object.keys(reducers).length) {
5365
5450
  return;
5366
5451
  }
5367
- for (let key in reducers)
5452
+ for (const key in reducers)
5368
5453
  if (reducers.hasOwnProperty(key)) {
5369
5454
  const reducer = reducers[key];
5370
5455
  if (typeof reducer.reducer !== "function") {
@@ -5386,7 +5471,7 @@ function lazyGroup(groupParams, rootData) {
5386
5471
  function traverseValues(pivotDeepMap, container, pivot2, pivotIndex = 0, currentPivotKeys2 = []) {
5387
5472
  const last = !pivot2.length || pivotIndex === pivot2.length - 1;
5388
5473
  const values = container[(mappings == null ? void 0 : mappings.values) || "values"] || {};
5389
- for (var k in values)
5474
+ for (const k in values)
5390
5475
  if (values.hasOwnProperty(k)) {
5391
5476
  const pivotKey = k;
5392
5477
  currentPivotKeys2.push(pivotKey);
@@ -5402,12 +5487,12 @@ function lazyGroup(groupParams, rootData) {
5402
5487
  }
5403
5488
  }
5404
5489
  const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
5405
- let currentPivotKeys = [];
5490
+ const currentPivotKeys = [];
5406
5491
  const initialReducerValue = initReducers(reducers);
5407
5492
  const globalReducerResults = __spreadValues({}, initialReducerValue);
5408
5493
  rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
5409
5494
  const [_rootKey, ...currentGroupKeys] = keys;
5410
- const dataArray = lazyGroupRowInfo.items;
5495
+ const dataArray = lazyGroupRowInfo.children;
5411
5496
  if (currentGroupKeys.length == groupBy.length && groupBy.length) {
5412
5497
  const deepMapGroupValue = deepMap.get(currentGroupKeys);
5413
5498
  if (deepMapGroupValue) {
@@ -5415,11 +5500,23 @@ function lazyGroup(groupParams, rootData) {
5415
5500
  }
5416
5501
  return next == null ? void 0 : next();
5417
5502
  }
5503
+ if (lazyGroupRowInfo) {
5504
+ const current = deepMap.get(currentGroupKeys);
5505
+ if (current) {
5506
+ current.cache = lazyGroupRowInfo.cache;
5507
+ current.childrenLoading = lazyGroupRowInfo.childrenLoading;
5508
+ current.childrenAvailable = lazyGroupRowInfo.childrenAvailable;
5509
+ current.error = lazyGroupRowInfo.error;
5510
+ }
5511
+ }
5418
5512
  for (let i = 0, len = dataArray.length; i < len; i++) {
5419
5513
  if (!dataArray[i]) {
5420
5514
  const deepMapGroupValue2 = {
5421
5515
  items: [],
5422
- reducerResults: {}
5516
+ reducerResults: {},
5517
+ cache: false,
5518
+ childrenLoading: false,
5519
+ childrenAvailable: false
5423
5520
  };
5424
5521
  deepMap.set([
5425
5522
  ...currentGroupKeys,
@@ -5429,14 +5526,15 @@ function lazyGroup(groupParams, rootData) {
5429
5526
  }
5430
5527
  const dataObject = dataArray[i].data;
5431
5528
  const dataKeys = dataArray[i].keys;
5432
- let item = dataObject;
5433
5529
  if (dataKeys.length) {
5434
- const { field: groupByProperty } = groupBy[dataKeys.length - 1];
5435
- const key = item[groupByProperty];
5530
+ const key = dataKeys[dataKeys.length - 1];
5436
5531
  currentGroupKeys.push(key);
5437
5532
  }
5438
5533
  const deepMapGroupValue = {
5439
5534
  items: [],
5535
+ cache: false,
5536
+ childrenLoading: false,
5537
+ childrenAvailable: false,
5440
5538
  commonData: dataObject,
5441
5539
  reducerResults: dataArray[i].aggregations || {}
5442
5540
  };
@@ -5505,13 +5603,16 @@ function group(groupParams, data) {
5505
5603
  const groupByLength = groupBy.length;
5506
5604
  const topLevelPivotColumns = pivot ? new DeepMap() : void 0;
5507
5605
  const deepMap = new DeepMap();
5508
- let currentGroupKeys = [];
5509
- let currentPivotKeys = [];
5606
+ const currentGroupKeys = [];
5607
+ const currentPivotKeys = [];
5510
5608
  const initialReducerValue = initReducers(reducers);
5511
5609
  const globalReducerResults = __spreadValues({}, initialReducerValue);
5512
5610
  if (!groupByLength) {
5513
5611
  const deepMapGroupValue = {
5514
5612
  items: [],
5613
+ cache: false,
5614
+ childrenLoading: false,
5615
+ childrenAvailable: false,
5515
5616
  reducerResults: __spreadValues({}, initialReducerValue)
5516
5617
  };
5517
5618
  if (pivot) {
@@ -5520,7 +5621,7 @@ function group(groupParams, data) {
5520
5621
  deepMap.set(currentGroupKeys, deepMapGroupValue);
5521
5622
  }
5522
5623
  for (let i = 0, len = data.length; i < len; i++) {
5523
- let item = data[i];
5624
+ const item = data[i];
5524
5625
  for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
5525
5626
  const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
5526
5627
  const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
@@ -5528,6 +5629,9 @@ function group(groupParams, data) {
5528
5629
  if (!deepMap.has(currentGroupKeys)) {
5529
5630
  const deepMapGroupValue = {
5530
5631
  items: [],
5632
+ cache: false,
5633
+ childrenLoading: false,
5634
+ childrenAvailable: false,
5531
5635
  reducerResults: __spreadValues({}, initialReducerValue)
5532
5636
  };
5533
5637
  if (pivot) {
@@ -5586,7 +5690,8 @@ function flatten(groupResult) {
5586
5690
  return result;
5587
5691
  }
5588
5692
  function getEnhancedGroupData(options, deepMapValue) {
5589
- const { groupBy, groupKeys, collapsed, parents, reducers } = options;
5693
+ var _a;
5694
+ const { groupBy, groupKeys, collapsed, parents, reducers, lazyLoad } = options;
5590
5695
  const groupNesting = groupKeys.length;
5591
5696
  const {
5592
5697
  items: groupItems,
@@ -5594,10 +5699,10 @@ function getEnhancedGroupData(options, deepMapValue) {
5594
5699
  pivotDeepMap,
5595
5700
  commonData
5596
5701
  } = deepMapValue;
5597
- let data = null;
5702
+ let data = commonData != null ? commonData : null;
5598
5703
  if (Object.keys(reducerResults).length > 0) {
5599
- data = commonData || {};
5600
- for (let key in reducers)
5704
+ data = __spreadValues({}, commonData);
5705
+ for (const key in reducers)
5601
5706
  if (reducers.hasOwnProperty(key)) {
5602
5707
  const reducer = reducers[key];
5603
5708
  const field = reducer.field;
@@ -5606,8 +5711,10 @@ function getEnhancedGroupData(options, deepMapValue) {
5606
5711
  }
5607
5712
  }
5608
5713
  }
5609
- let theValue = groupKeys[groupKeys.length - 1];
5714
+ let selfLoaded = true;
5715
+ let theValue = (_a = data != null ? data[groupBy[groupKeys.length - 1]] : null) != null ? _a : groupKeys[groupKeys.length - 1];
5610
5716
  if (typeof theValue === "string" && theValue.startsWith(NOT_LOADED_YET_KEY_PREFIX)) {
5717
+ selfLoaded = false;
5611
5718
  theValue = null;
5612
5719
  }
5613
5720
  const enhancedGroupData = {
@@ -5617,13 +5724,20 @@ function getEnhancedGroupData(options, deepMapValue) {
5617
5724
  groupKeys,
5618
5725
  id: `${groupKeys}`,
5619
5726
  collapsed,
5727
+ dataSourceHasGrouping: true,
5728
+ selfLoaded,
5729
+ error: options.error,
5620
5730
  parents,
5621
- flatRowInfoList: [],
5731
+ deepRowInfoArray: [],
5622
5732
  collapsedChildrenCount: 0,
5623
5733
  collapsedGroupsCount: 0,
5734
+ childrenAvailable: lazyLoad ? options.childrenAvailable : true,
5735
+ childrenLoading: options.childrenLoading,
5624
5736
  indexInParentGroups: options.indexInParentGroups,
5625
5737
  indexInGroup: options.indexInGroup,
5626
5738
  indexInAll: options.indexInAll,
5739
+ directChildrenCount: options.directChildrenCount,
5740
+ directChildrenLoadedCount: lazyLoad ? options.directChildrenLoadedCount : options.directChildrenCount,
5627
5741
  value: theValue,
5628
5742
  rootGroupBy: groupBy,
5629
5743
  groupBy: groupNesting === groupBy.length ? groupBy : groupBy.slice(0, groupNesting),
@@ -5636,7 +5750,7 @@ function getEnhancedGroupData(options, deepMapValue) {
5636
5750
  }
5637
5751
  function completeReducers(reducers, reducerResults, items) {
5638
5752
  if (reducers) {
5639
- for (let key in reducers)
5753
+ for (const key in reducers)
5640
5754
  if (reducers.hasOwnProperty(key)) {
5641
5755
  const reducer = reducers[key];
5642
5756
  if (reducer.done) {
@@ -5648,6 +5762,7 @@ function completeReducers(reducers, reducerResults, items) {
5648
5762
  }
5649
5763
  function enhancedFlatten(param) {
5650
5764
  const {
5765
+ lazyLoad,
5651
5766
  groupResult,
5652
5767
  toPrimaryKey,
5653
5768
  groupRowsState,
@@ -5661,11 +5776,13 @@ function enhancedFlatten(param) {
5661
5776
  const parents = [];
5662
5777
  const indexInParentGroups = [];
5663
5778
  deepMap.visitDepthFirst((deepMapValue, groupKeys, indexInGroup, next) => {
5664
- var _a;
5779
+ var _a, _b;
5665
5780
  const items = deepMapValue.items;
5666
5781
  const groupNesting = groupKeys.length;
5667
5782
  const collapsed = (_a = groupRowsState == null ? void 0 : groupRowsState.isGroupRowCollapsed(groupKeys)) != null ? _a : false;
5783
+ indexInParentGroups.push(indexInGroup);
5668
5784
  const enhancedGroupData = getEnhancedGroupData({
5785
+ lazyLoad,
5669
5786
  groupBy: groupByStrings,
5670
5787
  parents: Array.from(parents),
5671
5788
  reducers,
@@ -5673,35 +5790,60 @@ function enhancedFlatten(param) {
5673
5790
  indexInParentGroups: Array.from(indexInParentGroups),
5674
5791
  indexInAll: result.length,
5675
5792
  groupKeys,
5793
+ error: deepMapValue.error,
5794
+ childrenLoading: deepMapValue.childrenLoading,
5795
+ childrenAvailable: deepMapValue.childrenAvailable,
5796
+ directChildrenCount: groupKeys.length === groupByStrings.length ? deepMapValue.items.length : deepMap.getDirectChildrenSizeFor(groupKeys),
5797
+ directChildrenLoadedCount: 0,
5676
5798
  collapsed
5677
5799
  }, deepMapValue);
5678
- const include = generateGroupRows || collapsed;
5800
+ const parent = parents[parents.length - 1];
5801
+ const parentCollapsed = (_b = parent == null ? void 0 : parent.collapsed) != null ? _b : false;
5802
+ let include = generateGroupRows || collapsed;
5803
+ if (parentCollapsed) {
5804
+ include = false;
5805
+ }
5679
5806
  if (include) {
5680
5807
  result.push(enhancedGroupData);
5681
5808
  }
5682
5809
  if (collapsed) {
5683
- parents.forEach((parent) => {
5684
- parent.flatRowInfoList.push(enhancedGroupData);
5685
- parent.collapsedChildrenCount += enhancedGroupData.groupCount;
5686
- parent.collapsedGroupsCount += 1;
5810
+ enhancedGroupData.collapsedChildrenCount = enhancedGroupData.groupCount;
5811
+ parents.forEach((parent2) => {
5812
+ if (!parentCollapsed) {
5813
+ parent2.deepRowInfoArray.push(enhancedGroupData);
5814
+ }
5815
+ parent2.collapsedChildrenCount += enhancedGroupData.groupCount;
5816
+ parent2.collapsedGroupsCount += 1;
5687
5817
  });
5688
5818
  } else {
5689
- parents.forEach((parent) => {
5690
- parent.flatRowInfoList.push(enhancedGroupData);
5691
- });
5819
+ if (!parentCollapsed) {
5820
+ parents.forEach((parent2) => {
5821
+ parent2.deepRowInfoArray.push(enhancedGroupData);
5822
+ });
5823
+ }
5824
+ }
5825
+ if (parent && enhancedGroupData.selfLoaded && lazyLoad) {
5826
+ parent.directChildrenLoadedCount += 1;
5692
5827
  }
5693
- indexInParentGroups.push(indexInGroup);
5694
5828
  parents.push(enhancedGroupData);
5695
- if (!collapsed) {
5829
+ const continueWithChildren = !collapsed || lazyLoad;
5830
+ if (continueWithChildren) {
5696
5831
  if (!next) {
5697
5832
  if (!pivot) {
5698
5833
  const startIndex = result.length;
5699
- result.push(...items.map((item, index) => {
5834
+ if (!collapsed) {
5835
+ result.length += items.length;
5836
+ }
5837
+ for (let index = 0, len = items.length; index < len; index++) {
5838
+ const item = items[index];
5700
5839
  const rowInfo = {
5701
5840
  id: item ? toPrimaryKey(item) : `${groupKeys}-${index}`,
5702
5841
  data: item,
5842
+ dataSourceHasGrouping: true,
5703
5843
  isGroupRow: false,
5704
- collapsed: false,
5844
+ selfLoaded: !!item,
5845
+ rootGroupBy: groupByStrings,
5846
+ collapsed,
5705
5847
  groupKeys,
5706
5848
  parents: Array.from(parents),
5707
5849
  indexInParentGroups: [...indexInParentGroups, index],
@@ -5711,11 +5853,19 @@ function enhancedFlatten(param) {
5711
5853
  groupNesting,
5712
5854
  groupCount: enhancedGroupData.groupCount
5713
5855
  };
5714
- parents.forEach((parent) => {
5715
- parent.flatRowInfoList.push(rowInfo);
5856
+ parents.forEach((parent2, i) => {
5857
+ const last = i === parents.length - 1;
5858
+ if (last && item) {
5859
+ parent2.directChildrenLoadedCount += 1;
5860
+ }
5861
+ if (!parentCollapsed) {
5862
+ parent2.deepRowInfoArray.push(rowInfo);
5863
+ }
5716
5864
  });
5717
- return rowInfo;
5718
- }));
5865
+ if (!collapsed) {
5866
+ result[startIndex + index] = rowInfo;
5867
+ }
5868
+ }
5719
5869
  }
5720
5870
  } else {
5721
5871
  next();
@@ -5729,47 +5879,152 @@ function enhancedFlatten(param) {
5729
5879
  };
5730
5880
  }
5731
5881
 
5732
- // src/components/hooks/useEffectWithChanges.ts
5733
- import { useEffect as useEffect17, useRef as useRef16 } from "react";
5734
- function useEffectWithChanges(fn, deps) {
5735
- const prevRef = useRef16({});
5736
- const oldValuesRef = useRef16({});
5737
- const oldValues = oldValuesRef.current;
5738
- const changesRef = useRef16({});
5739
- const changes = changesRef.current;
5740
- const useEffectDeps = [];
5741
- for (const k in deps) {
5742
- if (deps.hasOwnProperty(k)) {
5743
- if (deps[k] !== prevRef.current[k]) {
5744
- changes[k] = deps[k];
5745
- oldValues[k] = prevRef.current[k];
5746
- }
5747
- useEffectDeps.push(deps[k]);
5748
- }
5749
- }
5750
- prevRef.current = deps;
5751
- useEffect17(() => {
5752
- const changes2 = changesRef.current;
5753
- const result = fn(changes2, oldValues);
5754
- changesRef.current = {};
5755
- oldValuesRef.current = {};
5756
- return result;
5757
- }, useEffectDeps);
5758
- }
5882
+ // src/components/DataSource/index.tsx
5883
+ import {
5884
+ Fragment as Fragment2,
5885
+ createElement as createElement21
5886
+ } from "react";
5759
5887
 
5760
- // src/components/DataSource/privateHooks/useLoadData.ts
5761
- var getRafPromise = () => new Promise((resolve) => {
5762
- requestAnimationFrame(resolve);
5763
- });
5764
- var SKIP_DATA_CHANGES_KEYS = {
5765
- originalDataArray: true,
5766
- changes: true
5888
+ // src/utils/multisort/sortTypes.ts
5889
+ var numberComparator = function(first, second) {
5890
+ return first - second;
5767
5891
  };
5768
- function getChangeDetect() {
5892
+ var stringComparator = function(first, second) {
5893
+ first = `${first}`;
5894
+ second = `${second}`;
5895
+ return first.localeCompare(second);
5896
+ };
5897
+ var sortTypes = {
5898
+ number: numberComparator,
5899
+ string: stringComparator
5900
+ };
5901
+ var sortTypes_default = sortTypes;
5902
+
5903
+ // src/utils/multisort/index.ts
5904
+ var multisort = (sortInfo, array, get) => {
5905
+ array.sort(getMultisortFunction(sortInfo, get));
5906
+ return array;
5907
+ };
5908
+ multisort.knownTypes = sortTypes_default;
5909
+ var getSingleSortFunction = (info) => {
5910
+ if (!info) {
5911
+ return;
5912
+ }
5913
+ const field = info.field;
5914
+ var dir = info.dir < 0 ? -1 : info.dir > 0 ? 1 : 0;
5915
+ if (!dir) {
5916
+ return;
5917
+ }
5918
+ let fn = info.fn;
5919
+ if (!fn && info.type) {
5920
+ fn = multisort.knownTypes[info.type];
5921
+ if (!fn) {
5922
+ console.warn(`Unknown sort type "${info.type}" - please pass one of ${Object.keys(multisort.knownTypes).join(", ")}`);
5923
+ }
5924
+ }
5925
+ if (!fn) {
5926
+ fn = sortTypes_default.string;
5927
+ }
5928
+ return (first, second) => {
5929
+ const a = field ? first[field] : first;
5930
+ const b = field ? second[field] : second;
5931
+ return dir * fn(a, b);
5932
+ };
5933
+ };
5934
+ var getSortFunctions = (sortInfo) => {
5935
+ return sortInfo.map(getSingleSortFunction).filter((fn) => fn instanceof Function);
5936
+ };
5937
+ var getMultisortFunction = (sortInfo, get) => {
5938
+ const fns = getSortFunctions(sortInfo);
5939
+ return (first, second) => {
5940
+ if (get) {
5941
+ first = get(first);
5942
+ second = get(second);
5943
+ }
5944
+ let result = 0;
5945
+ let i = 0;
5946
+ let fn;
5947
+ const len = fns.length;
5948
+ for (; i < len; i++) {
5949
+ fn = fns[i];
5950
+ if (!fn) {
5951
+ continue;
5952
+ }
5953
+ result = fn(first, second);
5954
+ if (result !== 0) {
5955
+ return result;
5956
+ }
5957
+ }
5958
+ return result;
5959
+ };
5960
+ };
5961
+
5962
+ // src/components/DataSource/privateHooks/useLoadData.ts
5963
+ import { useEffect as useEffect18, useMemo as useMemo7, useRef as useRef17, useState as useState9 } from "react";
5964
+
5965
+ // src/components/hooks/useEffectWithChanges.ts
5966
+ import { useEffect as useEffect17, useRef as useRef16 } from "react";
5967
+ function useEffectWithChanges(fn, deps) {
5968
+ const prevRef = useRef16({});
5969
+ const oldValuesRef = useRef16({});
5970
+ const oldValues = oldValuesRef.current;
5971
+ const changesRef = useRef16({});
5972
+ const changes = changesRef.current;
5973
+ const useEffectDeps = [];
5974
+ for (const k in deps) {
5975
+ if (deps.hasOwnProperty(k)) {
5976
+ if (deps[k] !== prevRef.current[k]) {
5977
+ changes[k] = deps[k];
5978
+ oldValues[k] = prevRef.current[k];
5979
+ }
5980
+ useEffectDeps.push(deps[k]);
5981
+ }
5982
+ }
5983
+ prevRef.current = deps;
5984
+ useEffect17(() => {
5985
+ const changes2 = changesRef.current;
5986
+ const result = fn(changes2, oldValues);
5987
+ changesRef.current = {};
5988
+ oldValuesRef.current = {};
5989
+ return result;
5990
+ }, useEffectDeps);
5991
+ }
5992
+
5993
+ // src/components/InfiniteTable/utils/assignFiltered.ts
5994
+ function assignFiltered(filterFn, target, ...rest) {
5995
+ const result = target;
5996
+ rest.forEach((obj) => {
5997
+ for (const key in obj) {
5998
+ if (obj.hasOwnProperty(key) && filterFn(obj[key], key)) {
5999
+ result[key] = obj[key];
6000
+ }
6001
+ }
6002
+ });
6003
+ return result;
6004
+ }
6005
+ function assignNonNull(target, ...rest) {
6006
+ return assignFiltered((value) => value != null, target, ...rest);
6007
+ }
6008
+ function assignExcept(exceptKeys, target, ...rest) {
6009
+ return assignFiltered((_value, key) => !(key in exceptKeys), target, ...rest);
6010
+ }
6011
+
6012
+ // src/components/DataSource/privateHooks/getChangeDetect.ts
6013
+ function getChangeDetect() {
5769
6014
  var _a;
5770
6015
  const perfNow = (_a = getGlobal().performance) == null ? void 0 : _a.now();
5771
6016
  return `${Date.now()}:${perfNow}`;
5772
6017
  }
6018
+
6019
+ // src/components/DataSource/privateHooks/useLoadData.ts
6020
+ var CACHE_DEFAULT = true;
6021
+ var getRafPromise = () => new Promise((resolve) => {
6022
+ requestAnimationFrame(resolve);
6023
+ });
6024
+ var SKIP_DATA_CHANGES_KEYS = {
6025
+ originalDataArray: true,
6026
+ changes: true
6027
+ };
5773
6028
  function buildDataSourceDataParams(componentState, overrides) {
5774
6029
  var _a, _b;
5775
6030
  const sortInfo = componentState.multiSort ? componentState.sortInfo : (_b = (_a = componentState.sortInfo) == null ? void 0 : _a[0]) != null ? _b : null;
@@ -5781,6 +6036,9 @@ function buildDataSourceDataParams(componentState, overrides) {
5781
6036
  pivotBy: componentState.pivotBy,
5782
6037
  aggregationReducers: componentState.aggregationReducers
5783
6038
  };
6039
+ if (dataSourceParams.groupBy) {
6040
+ dataSourceParams.groupRowsState = componentState.groupRowsState.getState();
6041
+ }
5784
6042
  if (componentState.livePagination !== void 0) {
5785
6043
  dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
5786
6044
  dataSourceParams.__cursorId = componentState.cursorId;
@@ -5816,7 +6074,7 @@ function loadData(data, componentState, actions, overrides) {
5816
6074
  const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
5817
6075
  const existingGroupRowInfo = lazyGroupData.get(key);
5818
6076
  if (existingGroupRowInfo && existingGroupRowInfo.cache && key.length > 1) {
5819
- const items = existingGroupRowInfo.items;
6077
+ const items = existingGroupRowInfo.children;
5820
6078
  const len = items.length;
5821
6079
  let allLoaded = true;
5822
6080
  for (let i = 0; i < len; i++) {
@@ -5829,6 +6087,21 @@ function loadData(data, componentState, actions, overrides) {
5829
6087
  return Promise.resolve(true);
5830
6088
  }
5831
6089
  }
6090
+ if (existingGroupRowInfo) {
6091
+ if (!existingGroupRowInfo.childrenLoading) {
6092
+ existingGroupRowInfo.childrenLoading = true;
6093
+ }
6094
+ } else {
6095
+ lazyGroupData.set(key, {
6096
+ error: void 0,
6097
+ children: [],
6098
+ childrenLoading: true,
6099
+ childrenAvailable: false,
6100
+ cache: CACHE_DEFAULT,
6101
+ totalCount: 0
6102
+ });
6103
+ }
6104
+ actions.originalLazyGroupDataChangeDetect = getChangeDetect();
5832
6105
  }
5833
6106
  if (typeof data === "function") {
5834
6107
  data = data(dataParams);
@@ -5838,7 +6111,6 @@ function loadData(data, componentState, actions, overrides) {
5838
6111
  actions.loading = true;
5839
6112
  }
5840
6113
  return Promise.resolve(data).then((dataParam) => {
5841
- var _a, _b, _c, _d;
5842
6114
  let dataArray = [];
5843
6115
  let skipAssign = false;
5844
6116
  if (Array.isArray(dataParam.data)) {
@@ -5851,57 +6123,87 @@ function loadData(data, componentState, actions, overrides) {
5851
6123
  actions.pivotMappings = remoteData.mappings;
5852
6124
  }
5853
6125
  if (componentState.lazyLoad) {
5854
- const lazyGroupData = componentState.originalLazyGroupData;
5855
- const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
5856
- const newGroupRowInfo = {
5857
- cache: !!remoteData.cache,
5858
- totalCount: (_a = remoteData.totalCount) != null ? _a : dataArray.length,
5859
- items: dataArray
5860
- };
5861
- if (dataParams.lazyLoadBatchSize) {
5862
- const existingGroupRowInfo = lazyGroupData.get(key);
5863
- const currentGroupRowInfo = existingGroupRowInfo != null ? existingGroupRowInfo : {
5864
- items: [],
5865
- totalCount: newGroupRowInfo.totalCount,
5866
- cache: (_b = newGroupRowInfo.cache) != null ? _b : true
6126
+ let resolveRemoteData = function(keys, remoteData2, parentKeys) {
6127
+ var _a, _b, _c;
6128
+ const theKey = [LAZY_ROOT_KEY_FOR_GROUPS, ...keys];
6129
+ const dataArray2 = remoteData2.data;
6130
+ const newGroupRowInfo = {
6131
+ cache: !!remoteData2.cache,
6132
+ childrenLoading: false,
6133
+ childrenAvailable: true,
6134
+ totalCount: (_a = remoteData2.totalCount) != null ? _a : dataArray2.length,
6135
+ children: dataArray2,
6136
+ error: remoteData2.error
5867
6137
  };
5868
- if (existingGroupRowInfo) {
5869
- existingGroupRowInfo.cache = newGroupRowInfo.cache;
5870
- }
5871
- currentGroupRowInfo.items.length = currentGroupRowInfo.totalCount;
5872
- const start = (_c = dataParams.lazyLoadStartIndex) != null ? _c : 0;
5873
- const end = Math.min((_d = remoteData.totalCount) != null ? _d : dataArray.length, start + dataParams.lazyLoadBatchSize);
5874
- for (let i = start; i < end; i++) {
5875
- const it = newGroupRowInfo.items[i - start];
5876
- if (!it) {
5877
- throw `lazily loaded item not found at index ${i - start}`;
6138
+ const childDatasets = [];
6139
+ if (dataParams.lazyLoadBatchSize && !parentKeys) {
6140
+ const existingGroupRowInfo = lazyGroupData.get(theKey);
6141
+ const isGroupNew = !existingGroupRowInfo;
6142
+ const currentGroupRowInfo = assignExcept({
6143
+ children: true
6144
+ }, existingGroupRowInfo || {}, newGroupRowInfo);
6145
+ if (isGroupNew) {
6146
+ currentGroupRowInfo.chidren = [];
5878
6147
  }
5879
- currentGroupRowInfo.items[i] = it;
6148
+ currentGroupRowInfo.children.length = currentGroupRowInfo.totalCount;
6149
+ const start = (_b = dataParams.lazyLoadStartIndex) != null ? _b : 0;
6150
+ const end = Math.min((_c = remoteData2.totalCount) != null ? _c : dataArray2.length, start + dataParams.lazyLoadBatchSize);
6151
+ for (let i = start; i < end; i++) {
6152
+ const it = newGroupRowInfo.children[i - start];
6153
+ if (!it) {
6154
+ throw `lazily loaded item not found at index ${i - start}`;
6155
+ }
6156
+ currentGroupRowInfo.children[i] = it;
6157
+ if (it.dataset) {
6158
+ childDatasets.push({
6159
+ keys: it.keys,
6160
+ dataset: it.dataset
6161
+ });
6162
+ }
6163
+ }
6164
+ if (isGroupNew) {
6165
+ lazyGroupData.set(theKey, currentGroupRowInfo);
6166
+ }
6167
+ } else {
6168
+ if (parentKeys) {
6169
+ newGroupRowInfo.children.forEach((child) => {
6170
+ if (child && child.dataset) {
6171
+ childDatasets.push({
6172
+ keys: child.keys,
6173
+ dataset: child.dataset
6174
+ });
6175
+ }
6176
+ });
6177
+ newGroupRowInfo.children.length = newGroupRowInfo.totalCount;
6178
+ }
6179
+ lazyGroupData.set(theKey, newGroupRowInfo);
5880
6180
  }
5881
- if (!existingGroupRowInfo) {
5882
- lazyGroupData.set(key, currentGroupRowInfo);
6181
+ let skipTriggerChangeAsAlreadyOriginalArrayWasUpdated = false;
6182
+ if (!keys || !keys.length) {
6183
+ const topLevelLazyGroupData = lazyGroupData.get([
6184
+ LAZY_ROOT_KEY_FOR_GROUPS
6185
+ ]);
6186
+ actions.originalDataArray = [...topLevelLazyGroupData.children];
6187
+ skipTriggerChangeAsAlreadyOriginalArrayWasUpdated = true;
5883
6188
  }
5884
- } else {
5885
- lazyGroupData.set(key, newGroupRowInfo);
5886
- }
6189
+ if (!skipTriggerChangeAsAlreadyOriginalArrayWasUpdated) {
6190
+ actions.originalLazyGroupDataChangeDetect = getChangeDetect();
6191
+ }
6192
+ if (childDatasets.length) {
6193
+ const parentKeys2 = keys;
6194
+ childDatasets.forEach(({ keys: keys2, dataset }) => {
6195
+ resolveRemoteData(keys2, dataset, parentKeys2);
6196
+ });
6197
+ }
6198
+ };
6199
+ const lazyGroupData = componentState.originalLazyGroupData;
5887
6200
  skipAssign = true;
5888
- let skipTriggerChangeAsAlreadyOriginalArrayWasUpdated = false;
5889
- if (!dataParams.groupKeys || !dataParams.groupKeys.length) {
5890
- const topLevelItems = lazyGroupData.get([LAZY_ROOT_KEY_FOR_GROUPS]);
5891
- actions.originalDataArray = [...topLevelItems.items];
5892
- skipTriggerChangeAsAlreadyOriginalArrayWasUpdated = true;
5893
- }
5894
- if (!skipTriggerChangeAsAlreadyOriginalArrayWasUpdated) {
5895
- actions.originalLazyGroupDataChangeDetect = getChangeDetect();
5896
- }
6201
+ resolveRemoteData(dataParams.groupKeys || [], remoteData);
5897
6202
  }
5898
6203
  } else {
5899
6204
  dataArray = dataParam;
5900
6205
  }
5901
6206
  if (!skipAssign) {
5902
- if (append) {
5903
- console.log("appending", dataArray);
5904
- }
5905
6207
  actions.originalDataArray = append ? componentState.originalDataArray.concat(dataArray) : dataArray;
5906
6208
  }
5907
6209
  if (dataIsPromise && !componentState.lazyLoad) {
@@ -6018,8 +6320,8 @@ function useLazyLoadRange() {
6018
6320
  componentActions: actions,
6019
6321
  componentState
6020
6322
  } = useComponentState();
6021
- const loadingCache = useMemo7(() => {
6022
- return new Map();
6323
+ useEffect18(() => {
6324
+ actions.lazyLoadCacheOfLoadedBatches = new DeepMap();
6023
6325
  }, [componentState.data, componentState.dataParams]);
6024
6326
  const {
6025
6327
  lazyLoadBatchSize,
@@ -6028,7 +6330,7 @@ function useLazyLoadRange() {
6028
6330
  scrollStopDelayUpdatedByTable
6029
6331
  } = componentState;
6030
6332
  const latestRenderRangeRef = useRef17(null);
6031
- const loadRange = (renderRange, cache = loadingCache) => {
6333
+ const loadRange = (renderRange, cache = getComponentState().lazyLoadCacheOfLoadedBatches) => {
6032
6334
  const componentState2 = getComponentState();
6033
6335
  renderRange = renderRange || latestRenderRangeRef.current;
6034
6336
  if (!renderRange) {
@@ -6051,11 +6353,11 @@ function useLazyLoadRange() {
6051
6353
  if (lazyLoadBatchSize && lazyLoadBatchSize > 0) {
6052
6354
  return notifyRenderRangeChange.onChange((renderRange) => {
6053
6355
  latestRenderRangeRef.current = renderRange;
6054
- loadRange(renderRange, loadingCache);
6356
+ loadRange(renderRange);
6055
6357
  });
6056
6358
  }
6057
6359
  return;
6058
- }, [lazyLoadBatchSize, loadingCache]);
6360
+ }, [lazyLoadBatchSize]);
6059
6361
  useEffect18(() => {
6060
6362
  if (lazyLoadBatchSize && lazyLoadBatchSize > 0) {
6061
6363
  debouncedLoadRange();
@@ -6072,7 +6374,10 @@ function lazyLoadRange(options, cache) {
6072
6374
  componentActions
6073
6375
  } = options;
6074
6376
  const { dataArray } = componentState;
6075
- const isRowLoaded = (index) => dataArray[index].data != null;
6377
+ const isRowLoaded = (index) => {
6378
+ const rowInfo = dataArray[index];
6379
+ return rowInfo.data != null;
6380
+ };
6076
6381
  const perGroupFnCalls = new DeepMap();
6077
6382
  const rootGroupKeys = ["_______xxx______"];
6078
6383
  for (let i = startIndex; i <= endIndex; i++) {
@@ -6080,17 +6385,36 @@ function lazyLoadRange(options, cache) {
6080
6385
  if (!rowInfo) {
6081
6386
  continue;
6082
6387
  }
6083
- const rowLoaded = rowInfo.data != null;
6084
- const theGroupKeys = rowInfo.groupKeys ? [...rowInfo.groupKeys] : [];
6085
- if (rowInfo.groupKeys && rowInfo.isGroupRow) {
6388
+ const rowLoaded = isRowLoaded(i);
6389
+ const theGroupKeys = rowInfo.dataSourceHasGrouping && rowInfo.groupKeys ? [...rowInfo.groupKeys] : [];
6390
+ if (rowInfo.isGroupRow && rowInfo.dataSourceHasGrouping && rowInfo.groupKeys) {
6086
6391
  theGroupKeys.pop();
6087
6392
  }
6088
6393
  const cacheKeys = theGroupKeys.length ? theGroupKeys : rootGroupKeys;
6089
- const indexInGroup = rowInfo.indexInGroup;
6394
+ const indexInGroup = rowInfo.isGroupRow ? rowInfo.indexInGroup : rowInfo.indexInAll;
6395
+ if (rowInfo.isGroupRow && !rowInfo.collapsed && !rowInfo.childrenAvailable) {
6396
+ const currentFnCall = {
6397
+ lazyLoadStartIndex: 0,
6398
+ lazyLoadBatchSize,
6399
+ groupKeys: rowInfo.groupKeys
6400
+ };
6401
+ const cacheKeys2 = rowInfo.groupKeys;
6402
+ let cachedFnCalls = perGroupFnCalls.get(cacheKeys2);
6403
+ if (!(cachedFnCalls == null ? void 0 : cachedFnCalls[rowInfo.id])) {
6404
+ const shouldSetFnCalls = !cachedFnCalls;
6405
+ cachedFnCalls = cachedFnCalls || {};
6406
+ if (!cachedFnCalls[rowInfo.id]) {
6407
+ cachedFnCalls[rowInfo.id] = currentFnCall;
6408
+ }
6409
+ if (shouldSetFnCalls) {
6410
+ perGroupFnCalls.set(cacheKeys2, cachedFnCalls);
6411
+ }
6412
+ }
6413
+ }
6090
6414
  if (!rowLoaded) {
6091
6415
  let cachedFnCalls = perGroupFnCalls.get(cacheKeys);
6092
6416
  const batchStartIndexInGroup = Math.floor(indexInGroup / lazyLoadBatchSize) * lazyLoadBatchSize;
6093
- const offset = rowInfo.indexInGroup - batchStartIndexInGroup;
6417
+ const offset = (rowInfo.isGroupRow ? rowInfo.indexInGroup : rowInfo.indexInAll) - batchStartIndexInGroup;
6094
6418
  const absoluteIndexOfBatchStart = dataArray[rowInfo.indexInAll - offset].indexInAll;
6095
6419
  const batchStartRowLoaded = isRowLoaded(absoluteIndexOfBatchStart);
6096
6420
  const batchStartRowId = dataArray[absoluteIndexOfBatchStart].id;
@@ -6118,7 +6442,7 @@ function lazyLoadRange(options, cache) {
6118
6442
  allFnCalls.push(...Object.values(record));
6119
6443
  });
6120
6444
  allFnCalls.reduce((promise, fnCall) => {
6121
- const cacheKey = `${fnCall.groupKeys.join("-")}:${fnCall.lazyLoadStartIndex}`;
6445
+ const cacheKey = [...fnCall.groupKeys, fnCall.lazyLoadStartIndex];
6122
6446
  if (cache && cache.has(cacheKey)) {
6123
6447
  return promise;
6124
6448
  }
@@ -6128,22 +6452,65 @@ function lazyLoadRange(options, cache) {
6128
6452
  }, initialPromise);
6129
6453
  }
6130
6454
 
6131
- // src/components/DataSource/state/normalizeSortInfo.ts
6132
- var EMPTY_ARRAY = Object.freeze([]);
6133
- var normalizeSortInfo = (initialSortInfo, weakMap) => {
6134
- const sortInfo = initialSortInfo != null ? initialSortInfo : EMPTY_ARRAY;
6135
- const result = Array.isArray(sortInfo) ? sortInfo : [sortInfo];
6136
- if (weakMap && weakMap.has(sortInfo)) {
6137
- const prevResult = weakMap.get(sortInfo);
6138
- if (prevResult && prevResult.length === result.length) {
6139
- return prevResult;
6140
- }
6455
+ // src/utils/shallowEqualObjects.ts
6456
+ function shallowEqualObjects(objA, objB, ignoreKeys) {
6457
+ if (objA === objB) {
6458
+ return true;
6141
6459
  }
6142
- if (weakMap && sortInfo) {
6143
- weakMap.set(sortInfo, result);
6460
+ if (!objA || !objB) {
6461
+ return false;
6144
6462
  }
6145
- return result;
6146
- };
6463
+ var aKeys = Object.keys(objA);
6464
+ var bKeys = Object.keys(objB);
6465
+ if (ignoreKeys) {
6466
+ aKeys = aKeys.filter((key2) => !ignoreKeys.has(key2));
6467
+ bKeys = bKeys.filter((key2) => !ignoreKeys.has(key2));
6468
+ }
6469
+ var len = aKeys.length;
6470
+ if (bKeys.length !== len) {
6471
+ return false;
6472
+ }
6473
+ for (var i = 0; i < len; i++) {
6474
+ var key = aKeys[i];
6475
+ if (ignoreKeys) {
6476
+ if (ignoreKeys.has(key)) {
6477
+ continue;
6478
+ }
6479
+ }
6480
+ if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {
6481
+ return false;
6482
+ }
6483
+ }
6484
+ return true;
6485
+ }
6486
+
6487
+ // src/components/utils/discardCallsWithEqualArg.ts
6488
+ var map = new WeakMap();
6489
+ var getCompareDefault = (a) => a;
6490
+ function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject) {
6491
+ map.set(fn, {
6492
+ lastCallTime: 0,
6493
+ lastCallArg: null
6494
+ });
6495
+ const getCompare = getCompareObject != null ? getCompareObject : getCompareDefault;
6496
+ return (arg) => {
6497
+ const { lastCallTime, lastCallArg } = map.get(fn) || {
6498
+ lastCallTime: 0,
6499
+ lastCallArg: null
6500
+ };
6501
+ const now = Date.now();
6502
+ const diff = now - lastCallTime;
6503
+ const objectsEqual = shallowEqualObjects(getCompare(lastCallArg), getCompare(arg));
6504
+ if (diff < timeframe && objectsEqual) {
6505
+ return;
6506
+ }
6507
+ map.set(fn, {
6508
+ lastCallTime: now,
6509
+ lastCallArg: arg
6510
+ });
6511
+ fn(arg);
6512
+ };
6513
+ }
6147
6514
 
6148
6515
  // src/components/DataSource/GroupRowsState.ts
6149
6516
  var GroupRowsState = class {
@@ -6255,65 +6622,22 @@ var GroupRowsState = class {
6255
6622
  }
6256
6623
  };
6257
6624
 
6258
- // src/utils/shallowEqualObjects.ts
6259
- function shallowEqualObjects(objA, objB, ignoreKeys) {
6260
- if (objA === objB) {
6261
- return true;
6262
- }
6263
- if (!objA || !objB) {
6264
- return false;
6265
- }
6266
- var aKeys = Object.keys(objA);
6267
- var bKeys = Object.keys(objB);
6268
- if (ignoreKeys) {
6269
- aKeys = aKeys.filter((key2) => !ignoreKeys.has(key2));
6270
- bKeys = bKeys.filter((key2) => !ignoreKeys.has(key2));
6271
- }
6272
- var len = aKeys.length;
6273
- if (bKeys.length !== len) {
6274
- return false;
6275
- }
6276
- for (var i = 0; i < len; i++) {
6277
- var key = aKeys[i];
6278
- if (ignoreKeys) {
6279
- if (ignoreKeys.has(key)) {
6280
- continue;
6281
- }
6282
- }
6283
- if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {
6284
- return false;
6625
+ // src/components/DataSource/state/normalizeSortInfo.ts
6626
+ var EMPTY_ARRAY = Object.freeze([]);
6627
+ var normalizeSortInfo = (initialSortInfo, weakMap) => {
6628
+ const sortInfo = initialSortInfo != null ? initialSortInfo : EMPTY_ARRAY;
6629
+ const result = Array.isArray(sortInfo) ? sortInfo : [sortInfo];
6630
+ if (weakMap && weakMap.has(sortInfo)) {
6631
+ const prevResult = weakMap.get(sortInfo);
6632
+ if (prevResult && prevResult.length === result.length) {
6633
+ return prevResult;
6285
6634
  }
6286
6635
  }
6287
- return true;
6288
- }
6289
-
6290
- // src/components/utils/discardCallsWithEqualArg.ts
6291
- var map = new WeakMap();
6292
- var getCompareDefault = (a) => a;
6293
- function discardCallsWithEqualArg(fn, timeframe = 50, getCompareObject) {
6294
- map.set(fn, {
6295
- lastCallTime: 0,
6296
- lastCallArg: null
6297
- });
6298
- const getCompare = getCompareObject != null ? getCompareObject : getCompareDefault;
6299
- return (arg) => {
6300
- const { lastCallTime, lastCallArg } = map.get(fn) || {
6301
- lastCallTime: 0,
6302
- lastCallArg: null
6303
- };
6304
- const now = Date.now();
6305
- const diff = now - lastCallTime;
6306
- const objectsEqual = shallowEqualObjects(getCompare(lastCallArg), getCompare(arg));
6307
- if (diff < timeframe && objectsEqual) {
6308
- return;
6309
- }
6310
- map.set(fn, {
6311
- lastCallTime: now,
6312
- lastCallArg: arg
6313
- });
6314
- fn(arg);
6315
- };
6316
- }
6636
+ if (weakMap && sortInfo) {
6637
+ weakMap.set(sortInfo, result);
6638
+ }
6639
+ return result;
6640
+ };
6317
6641
 
6318
6642
  // src/components/DataSource/state/getInitialState.ts
6319
6643
  var defaultCursorId = Symbol("cursorId");
@@ -6323,6 +6647,7 @@ function initSetupState() {
6323
6647
  const dataArray = [];
6324
6648
  const originalLazyGroupData = new DeepMap();
6325
6649
  return {
6650
+ lazyLoadCacheOfLoadedBatches: new DeepMap(),
6326
6651
  dataParams: void 0,
6327
6652
  notifyScrollbarsChange: buildSubscriptionCallback(),
6328
6653
  notifyScrollStop: buildSubscriptionCallback(),
@@ -6373,6 +6698,9 @@ var forwardProps2 = (setupState) => {
6373
6698
  sortInfo: (sortInfo) => normalizeSortInfo(sortInfo, setupState.propsCache.get("sortInfo")),
6374
6699
  groupBy: (groupBy) => groupBy != null ? groupBy : [],
6375
6700
  groupRowsState: (groupRowsState) => {
6701
+ if (groupRowsState && !(groupRowsState instanceof GroupRowsState)) {
6702
+ groupRowsState = new GroupRowsState(groupRowsState);
6703
+ }
6376
6704
  return groupRowsState || new GroupRowsState({
6377
6705
  expandedRows: true,
6378
6706
  collapsedRows: []
@@ -6540,7 +6868,7 @@ function getPivotColumnsAndColumnGroups({
6540
6868
  pivotIndex: -1,
6541
6869
  valueGetter: ({ rowInfo }) => {
6542
6870
  var _a;
6543
- return (_a = rowInfo.reducerResults) == null ? void 0 : _a[reducer.id];
6871
+ return rowInfo.isGroupRow ? (_a = rowInfo.reducerResults) == null ? void 0 : _a[reducer.id] : null;
6544
6872
  }
6545
6873
  }));
6546
6874
  });
@@ -6589,6 +6917,9 @@ function getPivotColumnsAndColumnGroups({
6589
6917
  header,
6590
6918
  valueGetter: ({ rowInfo }) => {
6591
6919
  var _a, _b;
6920
+ if (!rowInfo.isGroupRow) {
6921
+ return null;
6922
+ }
6592
6923
  return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
6593
6924
  }
6594
6925
  });
@@ -6611,7 +6942,7 @@ function getPivotColumnsAndColumnGroups({
6611
6942
  const pivotByForColumn = pivotBy[keys.length - 1];
6612
6943
  let columnGroupId = parentKeys.length ? parentKeys.join("/") : void 0;
6613
6944
  if (!isSingleAggregationColumn) {
6614
- let parentGroupForTotalsGroup = columnGroupId;
6945
+ const parentGroupForTotalsGroup = columnGroupId;
6615
6946
  columnGroupId = `total:${keys.join("/")}`;
6616
6947
  columnGroups.set(columnGroupId, prepareColumnGroup({
6617
6948
  header: `${keys[keys.length - 1]} total`,
@@ -6641,6 +6972,9 @@ function getPivotColumnsAndColumnGroups({
6641
6972
  sortable: false,
6642
6973
  valueGetter: ({ rowInfo }) => {
6643
6974
  var _a, _b;
6975
+ if (!rowInfo.isGroupRow) {
6976
+ return null;
6977
+ }
6644
6978
  return (_b = (_a = rowInfo.pivotValuesMap) == null ? void 0 : _a.get(keys)) == null ? void 0 : _b.reducerResults[reducer.id];
6645
6979
  }
6646
6980
  });
@@ -6676,12 +7010,12 @@ var haveDepsChanged = (state1, state2, deps) => {
6676
7010
  };
6677
7011
  function toRowInfo(data, id, index) {
6678
7012
  return {
7013
+ dataSourceHasGrouping: false,
6679
7014
  data,
6680
- collapsed: true,
6681
7015
  id,
6682
7016
  indexInAll: index,
6683
- indexInGroup: index,
6684
- isGroupRow: false
7017
+ isGroupRow: false,
7018
+ selfLoaded: true
6685
7019
  };
6686
7020
  }
6687
7021
  function concludeReducer(params) {
@@ -6709,7 +7043,7 @@ function concludeReducer(params) {
6709
7043
  const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray);
6710
7044
  const groupBy = state.groupBy;
6711
7045
  const pivotBy = state.pivotBy;
6712
- const shouldGroup = groupBy.length || pivotBy;
7046
+ const shouldGroup = groupBy.length > 0 || !!pivotBy;
6713
7047
  const groupsDepsChanged = originalDataArrayChanged || haveDepsChanged(previousState, state, [
6714
7048
  "generateGroupRows",
6715
7049
  "originalDataArray",
@@ -6734,12 +7068,8 @@ function concludeReducer(params) {
6734
7068
  state.sortedAt = now;
6735
7069
  }
6736
7070
  state.postSortDataArray = dataArray;
6737
- state.groupDeepMap = void 0;
6738
7071
  const toPrimaryKey = (data) => {
6739
7072
  const pk = data[state.primaryKey];
6740
- if (Array.isArray(pk)) {
6741
- debugger;
6742
- }
6743
7073
  return pk;
6744
7074
  };
6745
7075
  if (shouldGroup) {
@@ -6756,6 +7086,7 @@ function concludeReducer(params) {
6756
7086
  }, dataArray);
6757
7087
  const flattenResult = enhancedFlatten({
6758
7088
  groupResult,
7089
+ lazyLoad: !!state.lazyLoad,
6759
7090
  reducers: state.aggregationReducers,
6760
7091
  toPrimaryKey,
6761
7092
  groupRowsState: state.groupRowsState,
@@ -6811,7 +7142,7 @@ function DataSourceWithContext(props) {
6811
7142
  if (typeof children === "function") {
6812
7143
  children = children(computedValues);
6813
7144
  }
6814
- return /* @__PURE__ */ createElement20(Fragment2, null, children);
7145
+ return /* @__PURE__ */ createElement21(Fragment2, null, children);
6815
7146
  }
6816
7147
  var DataSourceRoot = getComponentStateRoot({
6817
7148
  initSetupState,
@@ -6834,14 +7165,14 @@ function DataSourceCmp({ children }) {
6834
7165
  globalThis.getDataSourceState = getState;
6835
7166
  }
6836
7167
  useLoadData();
6837
- return /* @__PURE__ */ createElement20(DataSourceContext.Provider, {
7168
+ return /* @__PURE__ */ createElement21(DataSourceContext.Provider, {
6838
7169
  value: contextValue
6839
- }, /* @__PURE__ */ createElement20(DataSourceWithContext, {
7170
+ }, /* @__PURE__ */ createElement21(DataSourceWithContext, {
6840
7171
  children
6841
7172
  }));
6842
7173
  }
6843
7174
  function DataSource(props) {
6844
- return /* @__PURE__ */ createElement20(DataSourceRoot, __spreadValues({}, props), /* @__PURE__ */ createElement20(DataSourceCmp, {
7175
+ return /* @__PURE__ */ createElement21(DataSourceRoot, __spreadValues({}, props), /* @__PURE__ */ createElement21(DataSourceCmp, {
6845
7176
  children: props.children
6846
7177
  }));
6847
7178
  }
@@ -6854,10 +7185,26 @@ function useToggleGroupRow() {
6854
7185
  const newState = new GroupRowsState(state.groupRowsState);
6855
7186
  newState.toggleGroupRow(groupKeys);
6856
7187
  dataSourceActions.groupRowsState = newState;
6857
- if (state.lazyLoad && newState.isGroupRowExpanded(groupKeys)) {
6858
- loadData(state.data, state, dataSourceActions, {
6859
- groupKeys
6860
- });
7188
+ if (state.lazyLoad) {
7189
+ const dataKeys = [LAZY_ROOT_KEY_FOR_GROUPS, ...groupKeys];
7190
+ const currentData = state.originalLazyGroupData.get(dataKeys);
7191
+ if (newState.isGroupRowExpanded(groupKeys)) {
7192
+ if (!(currentData == null ? void 0 : currentData.cache)) {
7193
+ loadData(state.data, state, dataSourceActions, {
7194
+ groupKeys
7195
+ });
7196
+ }
7197
+ } else {
7198
+ if (!(currentData == null ? void 0 : currentData.cache)) {
7199
+ const keysToDelete = state.lazyLoadCacheOfLoadedBatches.getKeysStartingWith(groupKeys);
7200
+ keysToDelete.forEach((keys) => {
7201
+ state.lazyLoadCacheOfLoadedBatches.delete(keys);
7202
+ });
7203
+ dataSourceActions.lazyLoadCacheOfLoadedBatches = DeepMap.clone(state.lazyLoadCacheOfLoadedBatches);
7204
+ state.originalLazyGroupData.delete(dataKeys);
7205
+ dataSourceActions.originalLazyGroupDataChangeDetect = getChangeDetect();
7206
+ }
7207
+ }
6861
7208
  }
6862
7209
  }, []);
6863
7210
  return toggleGroupRow;
@@ -6927,12 +7274,18 @@ function useColumnsWhenInlineGroupRenderStrategy(groupByMap) {
6927
7274
  field,
6928
7275
  valueGetter: ({ rowInfo }) => {
6929
7276
  var _a;
6930
- return (_a = rowInfo.groupKeys) == null ? void 0 : _a[groupIndex];
7277
+ return rowInfo.isGroupRow ? (_a = rowInfo.groupKeys) == null ? void 0 : _a[groupIndex] : rowInfo.value;
6931
7278
  },
6932
7279
  rowspan: ({ rowInfo, dataArray }) => {
7280
+ if (!rowInfo.isGroupRow) {
7281
+ return 1;
7282
+ }
6933
7283
  const prevRowInfo = dataArray[rowInfo.indexInAll - 1] || {
6934
7284
  indexInParentGroups: []
6935
7285
  };
7286
+ if (!prevRowInfo || !prevRowInfo.dataSourceHasGrouping) {
7287
+ return 1;
7288
+ }
6936
7289
  const prevIndexes = prevRowInfo.indexInParentGroups || [];
6937
7290
  const currentIndexes = rowInfo.indexInParentGroups || [];
6938
7291
  let computeSpan = false;
@@ -7085,8 +7438,11 @@ function useHideColumns(groupByMap) {
7085
7438
  let expandedGroupsLevel = 0;
7086
7439
  const len = dataArray.length;
7087
7440
  for (let i = 0; i < len; i++) {
7088
- const data = dataArray[i];
7089
- expandedGroupsLevel = Math.max(expandedGroupsLevel, data.groupNesting - 1);
7441
+ const rowInfo = dataArray[i];
7442
+ if (!rowInfo.isGroupRow) {
7443
+ continue;
7444
+ }
7445
+ expandedGroupsLevel = Math.max(expandedGroupsLevel, rowInfo.groupNesting - 1);
7090
7446
  if (expandedGroupsLevel === groupsLength - 1) {
7091
7447
  break;
7092
7448
  }
@@ -7413,22 +7769,6 @@ function getColumnComputedType(column, columnTypes) {
7413
7769
  return column.type.reduce((acc, columnType) => Object.assign(acc, columnTypes[columnType]), {});
7414
7770
  }
7415
7771
 
7416
- // src/components/InfiniteTable/utils/assignFiltered.ts
7417
- function assignFiltered(filterFn, target, ...rest) {
7418
- let result = target;
7419
- rest.forEach((obj) => {
7420
- for (const key in obj) {
7421
- if (obj.hasOwnProperty(key) && filterFn(obj[key], key)) {
7422
- result[key] = obj[key];
7423
- }
7424
- }
7425
- });
7426
- return result;
7427
- }
7428
- function assignNonNull(target, ...rest) {
7429
- return assignFiltered((value) => value != null, target, ...rest);
7430
- }
7431
-
7432
7772
  // src/components/InfiniteTable/utils/getComputedVisibleColumns.ts
7433
7773
  var logError = err("getComputedVisibleColumns");
7434
7774
  var isColumnVisible = (columnVisibility, _columnVisibilityAssumeVisible, colId) => {
@@ -8195,7 +8535,7 @@ var useLicense = (licenseKey = "") => {
8195
8535
  const valid = useMemo10(() => {
8196
8536
  let valid2 = isValidLicense(licenseKey, {
8197
8537
  publishedAt: 1624970570587,
8198
- version: "0.3.0-canary.0"
8538
+ version: "0.3.2"
8199
8539
  });
8200
8540
  if (!licenseKey && !valid2 && isInsidePlayground) {
8201
8541
  return true;
@@ -8471,27 +8811,27 @@ var InfiniteTableComponent = memo9(function InfiniteTableComponent2() {
8471
8811
  dataSourceActions.scrollStopDelayUpdatedByTable = scrollStopDelay;
8472
8812
  }, [scrollStopDelay]);
8473
8813
  useAutoSizeColumns();
8474
- return /* @__PURE__ */ createElement21("div", __spreadValues({
8814
+ return /* @__PURE__ */ createElement22("div", __spreadValues({
8475
8815
  ref: domRef
8476
- }, domProps), header ? /* @__PURE__ */ createElement21(TableHeaderWrapper, {
8816
+ }, domProps), header ? /* @__PURE__ */ createElement22(TableHeaderWrapper, {
8477
8817
  brain: headerBrain,
8478
8818
  scrollbars
8479
- }) : null, /* @__PURE__ */ createElement21(InfiniteTableBody, null, /* @__PURE__ */ createElement21(HeadlessTable, {
8819
+ }) : null, /* @__PURE__ */ createElement22(InfiniteTableBody, null, /* @__PURE__ */ createElement22(HeadlessTable, {
8480
8820
  tabIndex: 0,
8481
8821
  scrollStopDelay,
8482
8822
  brain,
8483
8823
  renderCell,
8484
8824
  cellHoverClassNames: HOVERED_CLASS_NAMES,
8485
8825
  scrollerDOMRef
8486
- }), /* @__PURE__ */ createElement21(LoadMaskCmp, {
8826
+ }), /* @__PURE__ */ createElement22(LoadMaskCmp, {
8487
8827
  visible: loading
8488
- }, loadingText)), licenseValid ? null : /* @__PURE__ */ createElement21(InfiniteTableLicenseFooter, null), /* @__PURE__ */ createElement21("div", {
8828
+ }, loadingText)), licenseValid ? null : /* @__PURE__ */ createElement22(InfiniteTableLicenseFooter, null), /* @__PURE__ */ createElement22("div", {
8489
8829
  ref: portalDOMRef,
8490
8830
  className: join(`${rootClassName2}Portal`, zIndex[1e3], position.absolute, top[0], left[0])
8491
- }), rowHeightCSSVar ? /* @__PURE__ */ createElement21(CSSVariableWatch, {
8831
+ }), rowHeightCSSVar ? /* @__PURE__ */ createElement22(CSSVariableWatch, {
8492
8832
  varName: rowHeightCSSVar,
8493
8833
  onChange: onRowHeightCSSVarChange
8494
- }) : null, headerHeightCSSVar ? /* @__PURE__ */ createElement21(CSSVariableWatch, {
8834
+ }) : null, headerHeightCSSVar ? /* @__PURE__ */ createElement22(CSSVariableWatch, {
8495
8835
  varName: headerHeightCSSVar,
8496
8836
  onChange: onHeaderHeightCSSVarChange
8497
8837
  }) : null);
@@ -8534,13 +8874,13 @@ function InfiniteTableContextProvider() {
8534
8874
  }
8535
8875
  }, [scrollTopKey, scrollerDOMRef]);
8536
8876
  const TableContext2 = getInfiniteTableContext();
8537
- return /* @__PURE__ */ createElement21(TableContext2.Provider, {
8877
+ return /* @__PURE__ */ createElement22(TableContext2.Provider, {
8538
8878
  value: contextValue
8539
- }, /* @__PURE__ */ createElement21(InfiniteTableComponent, null));
8879
+ }, /* @__PURE__ */ createElement22(InfiniteTableComponent, null));
8540
8880
  }
8541
8881
  function InfiniteTable(props) {
8542
- const table = /* @__PURE__ */ createElement21(InfiniteTableRoot, __spreadValues({}, props), /* @__PURE__ */ createElement21(InfiniteTableContextProvider, null));
8543
- return /* @__PURE__ */ createElement21(StrictMode, null, table);
8882
+ const table = /* @__PURE__ */ createElement22(InfiniteTableRoot, __spreadValues({}, props), /* @__PURE__ */ createElement22(InfiniteTableContextProvider, null));
8883
+ return /* @__PURE__ */ createElement22(StrictMode, null, table);
8544
8884
  }
8545
8885
  InfiniteTable.defaultProps = {
8546
8886
  rowHeight: 40,