@infinite-table/infinite-react 0.2.3 → 0.2.7

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 (4) hide show
  1. package/index.d.ts +28 -13
  2. package/index.esm.js +189 -90
  3. package/index.js +173 -74
  4. package/package.json +2 -2
package/index.js CHANGED
@@ -873,6 +873,7 @@ var mapPropsToState = (params) => {
873
873
  });
874
874
  const computedColumns = state.columnsWhenGrouping || state.columnsWhenInlineGroupRenderStrategy || state.columns;
875
875
  return {
876
+ controlledColumnVisibility: !!props.columnVisibility,
876
877
  groupRenderStrategy,
877
878
  groupBy,
878
879
  computedColumns,
@@ -1398,6 +1399,7 @@ var getComputedVisibleColumns = ({
1398
1399
  const result2 = __spreadProps(__spreadValues({
1399
1400
  align: colType.align,
1400
1401
  verticalAlign: colType.verticalAlign,
1402
+ defaultHiddenWhenGroupedBy: colType.defaultHiddenWhenGroupedBy,
1401
1403
  valueGetter: colType.valueGetter,
1402
1404
  renderValue: colType.renderValue,
1403
1405
  render: colType.render
@@ -2841,6 +2843,7 @@ function getEnhancedGroupData(options, deepMapValue) {
2841
2843
  id: `${groupKeys}`,
2842
2844
  collapsed,
2843
2845
  parents,
2846
+ flatRowInfoList: [],
2844
2847
  collapsedChildrenCount: 0,
2845
2848
  collapsedGroupsCount: 0,
2846
2849
  indexInParentGroups: options.indexInParentGroups,
@@ -2903,9 +2906,14 @@ function enhancedFlatten(param) {
2903
2906
  }
2904
2907
  if (collapsed) {
2905
2908
  parents.forEach((parent) => {
2909
+ parent.flatRowInfoList.push(enhancedGroupData);
2906
2910
  parent.collapsedChildrenCount += enhancedGroupData.groupCount;
2907
2911
  parent.collapsedGroupsCount += 1;
2908
2912
  });
2913
+ } else {
2914
+ parents.forEach((parent) => {
2915
+ parent.flatRowInfoList.push(enhancedGroupData);
2916
+ });
2909
2917
  }
2910
2918
  indexInParentGroups.push(indexInGroup);
2911
2919
  parents.push(enhancedGroupData);
@@ -3011,7 +3019,7 @@ function buildDataSourceDataParams(componentState, overrides) {
3011
3019
  dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
3012
3020
  dataSourceParams.cursorId = componentState.cursorId;
3013
3021
  }
3014
- if (componentState.fullLazyLoad) {
3022
+ if (componentState.lazyLoad) {
3015
3023
  if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
3016
3024
  dataSourceParams.lazyLoadBatchSize = componentState.lazyLoadBatchSize;
3017
3025
  dataSourceParams.lazyLoadStartIndex = 0;
@@ -3036,9 +3044,9 @@ function buildDataSourceDataParams(componentState, overrides) {
3036
3044
  }
3037
3045
  function loadData(data, componentState, actions, overrides) {
3038
3046
  const dataParams = buildDataSourceDataParams(componentState, overrides);
3039
- if (componentState.fullLazyLoad && dataParams.groupKeys) {
3047
+ if (componentState.lazyLoad) {
3040
3048
  const lazyGroupData = componentState.originalLazyGroupData;
3041
- const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
3049
+ const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
3042
3050
  const existingGroupRowInfo = lazyGroupData.get(key);
3043
3051
  if (existingGroupRowInfo && existingGroupRowInfo.cache) {
3044
3052
  const items = existingGroupRowInfo.items;
@@ -3059,7 +3067,7 @@ function loadData(data, componentState, actions, overrides) {
3059
3067
  data = data(dataParams);
3060
3068
  }
3061
3069
  const dataIsPromise = typeof data === "object" && typeof data.then === "function";
3062
- if (dataIsPromise && !componentState.fullLazyLoad) {
3070
+ if (dataIsPromise && !componentState.lazyLoad) {
3063
3071
  actions.loading = true;
3064
3072
  }
3065
3073
  return Promise.resolve(data).then((dataParam) => {
@@ -3075,9 +3083,9 @@ function loadData(data, componentState, actions, overrides) {
3075
3083
  if (remoteData.mappings) {
3076
3084
  actions.pivotMappings = remoteData.mappings;
3077
3085
  }
3078
- if (componentState.fullLazyLoad && dataParams.groupKeys) {
3086
+ if (componentState.lazyLoad) {
3079
3087
  const lazyGroupData = componentState.originalLazyGroupData;
3080
- const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
3088
+ const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
3081
3089
  const newGroupRowInfo = {
3082
3090
  cache: !!remoteData.cache,
3083
3091
  totalCount: (_a = remoteData.totalCount) != null ? _a : dataArray.length,
@@ -3107,6 +3115,10 @@ function loadData(data, componentState, actions, overrides) {
3107
3115
  }
3108
3116
  skipAssign = true;
3109
3117
  actions.originalLazyGroupDataChangeDetect = getChangeDetect();
3118
+ if (!dataParams.groupKeys || !dataParams.groupKeys.length) {
3119
+ const topLevelItems = lazyGroupData.get([LAZY_ROOT_KEY_FOR_GROUPS]);
3120
+ actions.originalDataArray = [...topLevelItems.items];
3121
+ }
3110
3122
  }
3111
3123
  } else {
3112
3124
  dataArray = dataParam;
@@ -3114,7 +3126,7 @@ function loadData(data, componentState, actions, overrides) {
3114
3126
  if (!skipAssign) {
3115
3127
  actions.originalDataArray = dataArray;
3116
3128
  }
3117
- if (dataIsPromise && !componentState.fullLazyLoad) {
3129
+ if (dataIsPromise && !componentState.lazyLoad) {
3118
3130
  actions.loading = false;
3119
3131
  }
3120
3132
  });
@@ -3272,27 +3284,27 @@ function lazyLoadRange(options, cache) {
3272
3284
  const cacheKeys = theGroupKeys.length ? theGroupKeys : rootGroupKeys;
3273
3285
  const indexInGroup = rowInfo.indexInGroup;
3274
3286
  if (!rowLoaded) {
3275
- let fnCalls = perGroupFnCalls.get(cacheKeys);
3287
+ let cachedFnCalls = perGroupFnCalls.get(cacheKeys);
3276
3288
  const batchStartIndexInGroup = Math.floor(indexInGroup / lazyLoadBatchSize) * lazyLoadBatchSize;
3277
3289
  const offset = rowInfo.indexInGroup - batchStartIndexInGroup;
3278
3290
  const absoluteIndexOfBatchStart = dataArray[rowInfo.indexInAll - offset].indexInAll;
3279
3291
  const batchStartRowLoaded = isRowLoaded(absoluteIndexOfBatchStart);
3280
3292
  const batchStartRowId = dataArray[absoluteIndexOfBatchStart].id;
3281
- if (batchStartRowLoaded || (fnCalls == null ? void 0 : fnCalls[batchStartRowId])) {
3293
+ if (batchStartRowLoaded || (cachedFnCalls == null ? void 0 : cachedFnCalls[batchStartRowId])) {
3282
3294
  continue;
3283
3295
  }
3284
- const shouldSetFnCalls = !fnCalls;
3285
- fnCalls = fnCalls || {};
3296
+ const shouldSetFnCalls = !cachedFnCalls;
3297
+ cachedFnCalls = cachedFnCalls || {};
3286
3298
  const currentFnCall = {
3287
3299
  lazyLoadStartIndex: batchStartIndexInGroup,
3288
3300
  lazyLoadBatchSize,
3289
3301
  groupKeys: theGroupKeys
3290
3302
  };
3291
- if (!fnCalls[batchStartRowId]) {
3292
- fnCalls[batchStartRowId] = currentFnCall;
3303
+ if (!cachedFnCalls[batchStartRowId]) {
3304
+ cachedFnCalls[batchStartRowId] = currentFnCall;
3293
3305
  }
3294
3306
  if (shouldSetFnCalls) {
3295
- perGroupFnCalls.set(cacheKeys, fnCalls);
3307
+ perGroupFnCalls.set(cacheKeys, cachedFnCalls);
3296
3308
  }
3297
3309
  }
3298
3310
  }
@@ -3549,12 +3561,11 @@ function getCompareObjectForDataParams(dataParams) {
3549
3561
  var forwardProps3 = (setupState) => {
3550
3562
  return {
3551
3563
  onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100, getCompareObjectForDataParams) : void 0,
3552
- fullLazyLoad: 1,
3564
+ lazyLoad: (lazyLoad) => !!lazyLoad,
3553
3565
  data: 1,
3554
3566
  pivotBy: 1,
3555
3567
  primaryKey: 1,
3556
3568
  livePagination: 1,
3557
- lazyLoadBatchSize: (lazyLoadBatchSize) => lazyLoadBatchSize != null ? lazyLoadBatchSize : -1,
3558
3569
  aggregationReducers: 1,
3559
3570
  collapseGroupRowsOnDataFunctionChange: (collapseGroupRowsOnDataFunctionChange) => collapseGroupRowsOnDataFunctionChange != null ? collapseGroupRowsOnDataFunctionChange : true,
3560
3571
  loading: (loading) => loading != null ? loading : false,
@@ -3581,7 +3592,8 @@ function mapPropsToState2(params) {
3581
3592
  const controlledSort = isControlledValue(props.sortInfo);
3582
3593
  const result = {
3583
3594
  controlledSort,
3584
- multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
3595
+ multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo),
3596
+ lazyLoadBatchSize: typeof props.lazyLoad === "object" ? props.lazyLoad.batchSize : void 0
3585
3597
  };
3586
3598
  if (props.livePagination) {
3587
3599
  const dataArrayChanged = !oldState || oldState.originalDataArray !== state.originalDataArray;
@@ -3594,7 +3606,7 @@ var debugFullLazyLoad = dbg("DataSource:fullLazyLoad");
3594
3606
  function onPropChange(params, props, actions) {
3595
3607
  const { name, newValue } = params;
3596
3608
  if (name === "data" && typeof newValue === "function" && !props.groupRowsState) {
3597
- if (props.fullLazyLoad) {
3609
+ if (props.lazyLoad) {
3598
3610
  debugFullLazyLoad(`"data" function prop has changed`);
3599
3611
  }
3600
3612
  if (props.collapseGroupRowsOnDataFunctionChange !== false) {
@@ -3861,17 +3873,29 @@ function concludeReducer(params) {
3861
3873
  var _a;
3862
3874
  const { state, previousState } = params;
3863
3875
  const sortInfo = state.sortInfo;
3864
- const shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
3865
- const originalDataArrayChanged = haveDepsChanged(previousState, state, [
3876
+ let shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
3877
+ if (state.lazyLoad || state.livePagination) {
3878
+ shouldSort = false;
3879
+ }
3880
+ let originalDataArrayChanged = haveDepsChanged(previousState, state, [
3866
3881
  "originalDataArray"
3867
3882
  ]);
3883
+ const dataSourceChange = previousState && state.data !== previousState.data;
3884
+ let lazyLoadGroupDataChange = state.lazyLoad && previousState && (previousState.groupBy !== state.groupBy || previousState.sortInfo !== state.sortInfo);
3885
+ if (dataSourceChange) {
3886
+ lazyLoadGroupDataChange = true;
3887
+ }
3888
+ if (lazyLoadGroupDataChange) {
3889
+ state.originalLazyGroupData = new DeepMap();
3890
+ originalDataArrayChanged = true;
3891
+ }
3868
3892
  const sortInfoChanged = haveDepsChanged(previousState, state, ["sortInfo"]);
3869
3893
  const sortDepsChanged = originalDataArrayChanged || sortInfoChanged;
3870
3894
  const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray);
3871
3895
  const groupBy = state.groupBy;
3872
3896
  const pivotBy = state.pivotBy;
3873
3897
  const shouldGroup = groupBy.length || pivotBy;
3874
- const groupsDepsChanged = haveDepsChanged(previousState, state, [
3898
+ const groupsDepsChanged = originalDataArrayChanged || haveDepsChanged(previousState, state, [
3875
3899
  "generateGroupRows",
3876
3900
  "originalDataArray",
3877
3901
  "originalLazyGroupData",
@@ -3904,7 +3928,7 @@ function concludeReducer(params) {
3904
3928
  };
3905
3929
  if (shouldGroup) {
3906
3930
  if (shouldGroupAgain) {
3907
- const groupResult = state.fullLazyLoad ? lazyGroup({
3931
+ const groupResult = state.lazyLoad ? lazyGroup({
3908
3932
  groupBy,
3909
3933
  pivot: pivotBy,
3910
3934
  mappings: state.pivotMappings,
@@ -3941,7 +3965,7 @@ function concludeReducer(params) {
3941
3965
  state.groupDeepMap = void 0;
3942
3966
  state.pivotColumns = void 0;
3943
3967
  const arrayDifferentAfterSortStep = previousState.postSortDataArray != state.postSortDataArray;
3944
- if (arrayDifferentAfterSortStep) {
3968
+ if (arrayDifferentAfterSortStep || groupsDepsChanged) {
3945
3969
  rowInfoDataArray = dataArray.map((data, index) => toRowInfo(data, data ? toPrimaryKey(data) : index, index));
3946
3970
  }
3947
3971
  }
@@ -4013,7 +4037,7 @@ function useToggleGroupRow() {
4013
4037
  const newState = new GroupRowsState(state.groupRowsState);
4014
4038
  newState.toggleGroupRow(groupKeys);
4015
4039
  dataSourceActions.groupRowsState = newState;
4016
- if (state.fullLazyLoad && newState.isGroupRowExpanded(groupKeys)) {
4040
+ if (state.lazyLoad && newState.isGroupRowExpanded(groupKeys)) {
4017
4041
  loadData(state.data, state, dataSourceActions, {
4018
4042
  groupKeys
4019
4043
  });
@@ -4052,7 +4076,7 @@ function useColumnsWhen() {
4052
4076
  }, [pivotTotalColumnPosition]);
4053
4077
  useColumnsWhenInlineGroupRenderStrategy(groupByMap);
4054
4078
  const { toggleGroupRow } = useColumnsWhenGrouping();
4055
- useHideEmptyGroupColumns();
4079
+ useHideColumns(groupByMap);
4056
4080
  return { toggleGroupRow };
4057
4081
  }
4058
4082
  function useColumnsWhenInlineGroupRenderStrategy(groupByMap) {
@@ -4174,9 +4198,10 @@ function useColumnsWhenGrouping() {
4174
4198
  ]);
4175
4199
  return { toggleGroupRow };
4176
4200
  }
4177
- function useHideEmptyGroupColumns() {
4201
+ function useHideColumns(groupByMap) {
4178
4202
  const {
4179
4203
  componentState: {
4204
+ dataArray,
4180
4205
  groupBy,
4181
4206
  groupRowsState,
4182
4207
  originalLazyGroupDataChangeDetect
@@ -4187,18 +4212,49 @@ function useHideEmptyGroupColumns() {
4187
4212
  getComponentState,
4188
4213
  componentActions,
4189
4214
  componentState: {
4190
- columnsWhenGrouping: generatedColumns,
4215
+ columnTypes,
4216
+ computedColumns,
4191
4217
  hideEmptyGroupColumns,
4192
4218
  groupRenderStrategy
4193
4219
  }
4194
4220
  } = useComponentState();
4221
+ const prevHideEmptyGroupColumns = usePrevious(hideEmptyGroupColumns);
4195
4222
  (0, import_react17.useEffect)(() => {
4196
4223
  if (groupRenderStrategy !== "multi-column") {
4197
4224
  return;
4198
4225
  }
4226
+ const currentState = getComponentState();
4227
+ const computedGroupColumns = new Map();
4228
+ computedColumns.forEach((column, colId) => {
4229
+ if (typeof column.groupByField !== "string") {
4230
+ return;
4231
+ }
4232
+ const { groupByField } = column;
4233
+ const field = groupByField;
4234
+ const groupInfoForColumn = groupByMap.get(field);
4235
+ if (!groupInfoForColumn) {
4236
+ return;
4237
+ }
4238
+ computedGroupColumns.set(colId, column);
4239
+ });
4240
+ if (!hideEmptyGroupColumns) {
4241
+ if (prevHideEmptyGroupColumns) {
4242
+ let updated2 = false;
4243
+ const columnVisibility2 = __spreadValues({}, currentState.columnVisibility);
4244
+ computedGroupColumns.forEach((_column, colId) => {
4245
+ if (columnVisibility2[colId] === false) {
4246
+ updated2 = true;
4247
+ delete columnVisibility2[colId];
4248
+ }
4249
+ });
4250
+ if (updated2) {
4251
+ componentActions.columnVisibility = columnVisibility2;
4252
+ }
4253
+ }
4254
+ return;
4255
+ }
4199
4256
  const groupsLength = groupBy.length;
4200
4257
  let expandedGroupsLevel = 0;
4201
- const { dataArray } = getDataSourceState();
4202
4258
  const len = dataArray.length;
4203
4259
  for (let i = 0; i < len; i++) {
4204
4260
  const data = dataArray[i];
@@ -4207,23 +4263,24 @@ function useHideEmptyGroupColumns() {
4207
4263
  break;
4208
4264
  }
4209
4265
  }
4210
- const currentState = getComponentState();
4211
- const { computedColumns } = currentState;
4212
4266
  let updated = false;
4213
4267
  const columnVisibility = __spreadValues({}, currentState.columnVisibility);
4214
- const cols = computedColumns;
4215
- groupBy.forEach(({ field, column: groupColumn }, index) => {
4216
- const colId = (groupColumn == null ? void 0 : groupColumn.id) || `group-by-${field}`;
4217
- let col = cols.get(colId);
4218
- if (!col) {
4219
- return;
4220
- }
4268
+ computedGroupColumns.forEach((column, colId) => {
4269
+ const { groupByField } = column;
4270
+ const field = groupByField;
4271
+ const groupInfoForColumn = groupByMap.get(field);
4272
+ const index = groupInfoForColumn.groupIndex;
4221
4273
  const shouldBeHidden = index > expandedGroupsLevel && hideEmptyGroupColumns;
4222
- updated = true;
4223
4274
  if (shouldBeHidden) {
4224
- columnVisibility[colId] = false;
4275
+ if (columnVisibility[colId] !== false) {
4276
+ updated = true;
4277
+ columnVisibility[colId] = false;
4278
+ }
4225
4279
  } else {
4226
- delete columnVisibility[colId];
4280
+ if (columnVisibility.hasOwnProperty(colId)) {
4281
+ updated = true;
4282
+ delete columnVisibility[colId];
4283
+ }
4227
4284
  }
4228
4285
  });
4229
4286
  if (updated) {
@@ -4232,12 +4289,41 @@ function useHideEmptyGroupColumns() {
4232
4289
  }, [
4233
4290
  getDataSourceState,
4234
4291
  groupRenderStrategy,
4235
- generatedColumns,
4236
4292
  originalLazyGroupDataChangeDetect,
4237
4293
  groupBy,
4294
+ groupByMap,
4295
+ computedColumns,
4296
+ hideEmptyGroupColumns ? dataArray : null,
4238
4297
  hideEmptyGroupColumns ? groupRowsState : null,
4239
4298
  hideEmptyGroupColumns
4240
4299
  ]);
4300
+ (0, import_react17.useEffect)(() => {
4301
+ const isGrouped = groupBy.length > 0;
4302
+ const currentState = getComponentState();
4303
+ const { controlledColumnVisibility, columnVisibility } = currentState;
4304
+ if (controlledColumnVisibility) {
4305
+ return;
4306
+ }
4307
+ const newColumnVisibility = __spreadValues({}, columnVisibility);
4308
+ let updated = false;
4309
+ computedColumns.forEach((col, id) => {
4310
+ if (col.defaultHiddenWhenGroupedBy) {
4311
+ const nowHidden = columnVisibility[id] === false;
4312
+ const shouldBeHidden = col.defaultHiddenWhenGroupedBy === "*" && isGrouped || typeof col.defaultHiddenWhenGroupedBy === "string" && groupByMap.get(col.defaultHiddenWhenGroupedBy) || typeof col.defaultHiddenWhenGroupedBy === "object" && Object.keys(col.defaultHiddenWhenGroupedBy).reduce((acc, field) => acc || groupByMap.has(field), false);
4313
+ if (nowHidden !== shouldBeHidden) {
4314
+ updated = true;
4315
+ if (shouldBeHidden) {
4316
+ newColumnVisibility[id] = false;
4317
+ } else {
4318
+ delete newColumnVisibility[id];
4319
+ }
4320
+ }
4321
+ }
4322
+ });
4323
+ if (updated) {
4324
+ componentActions.columnVisibility = newColumnVisibility;
4325
+ }
4326
+ }, [computedColumns, columnTypes, groupBy, groupByMap]);
4241
4327
  }
4242
4328
  function getColumnsWhenGrouping(params) {
4243
4329
  const {
@@ -4386,6 +4472,32 @@ function useComputed() {
4386
4472
  columnSizing,
4387
4473
  columnTypes
4388
4474
  });
4475
+ const rowSpan = (0, import_react18.useMemo)(() => {
4476
+ const colsWithRowspan = computedVisibleColumns.filter((col) => typeof col.rowspan === "function");
4477
+ return colsWithRowspan.length ? ({ itemIndex }) => {
4478
+ let maxSpan = 1;
4479
+ const dataArray = getDataSourceState().dataArray;
4480
+ const rowInfo = dataArray[itemIndex];
4481
+ const data = rowInfo.data;
4482
+ colsWithRowspan.forEach((column) => {
4483
+ if (!column.rowspan) {
4484
+ return;
4485
+ }
4486
+ const span = column.rowspan({
4487
+ column,
4488
+ data,
4489
+ dataArray,
4490
+ groupRowInfo: null,
4491
+ rowInfo,
4492
+ rowIndex: itemIndex
4493
+ });
4494
+ if (span > maxSpan) {
4495
+ maxSpan = span;
4496
+ }
4497
+ });
4498
+ return maxSpan;
4499
+ } : void 0;
4500
+ }, [computedVisibleColumns]);
4389
4501
  const unpinnedColumnWidths = computedUnpinnedColumns.map((c) => c.computedWidth);
4390
4502
  let sortedUnpinnedColumnWidths = [...unpinnedColumnWidths].sort(sortAscending);
4391
4503
  let unpinnedColumnRenderCount = 0;
@@ -4412,6 +4524,7 @@ function useComputed() {
4412
4524
  const computedPinnedStartOverflow = computedPinnedStartWidth ? computedPinnedStartColumnsWidth > computedPinnedStartWidth : false;
4413
4525
  const computedPinnedEndOverflow = computedPinnedEndWidth ? computedPinnedEndColumnsWidth > computedPinnedEndWidth : false;
4414
4526
  return {
4527
+ rowSpan,
4415
4528
  toggleGroupRow,
4416
4529
  computedPinnedStartOverflow,
4417
4530
  computedPinnedEndOverflow,
@@ -6064,7 +6177,8 @@ function useRowDOMProps(props, rowProps, rowStyle, rowClassName, groupRenderStra
6064
6177
  showHoverRows = false,
6065
6178
  rowIndex,
6066
6179
  domRef: domRefFromProps,
6067
- rowInfo
6180
+ rowInfo,
6181
+ rowSpan
6068
6182
  } = props;
6069
6183
  const domRef = (0, import_react31.useRef)(null);
6070
6184
  const rowDOMRef = (0, import_react31.useCallback)((node) => {
@@ -6084,7 +6198,7 @@ function useRowDOMProps(props, rowProps, rowStyle, rowClassName, groupRenderStra
6084
6198
  if (rowStyle) {
6085
6199
  style = typeof rowStyle === "function" ? __spreadValues(__spreadValues({}, style), rowStyle(rowPropsAndStyleArgs)) : __spreadValues(__spreadValues({}, style), rowStyle);
6086
6200
  }
6087
- if (inlineGroupRoot) {
6201
+ if (inlineGroupRoot || rowSpan) {
6088
6202
  style = style || {};
6089
6203
  style.zIndex = 2e6 - rowInfo.indexInAll;
6090
6204
  }
@@ -6268,6 +6382,7 @@ function useUnpinnedRendering(params) {
6268
6382
  computedPinnedStartWidth,
6269
6383
  computedPinnedEndWidth,
6270
6384
  computedUnpinnedColumns,
6385
+ rowSpan,
6271
6386
  getState
6272
6387
  } = params;
6273
6388
  const { virtualizeColumns } = getState();
@@ -6281,6 +6396,7 @@ function useUnpinnedRendering(params) {
6281
6396
  showZebraRows,
6282
6397
  showHoverRows,
6283
6398
  getData,
6399
+ rowSpan,
6284
6400
  toggleGroupRow,
6285
6401
  virtualizeColumns: shouldVirtualizeColumns,
6286
6402
  brain: null,
@@ -6297,6 +6413,7 @@ function useUnpinnedRendering(params) {
6297
6413
  }, [
6298
6414
  repaintId,
6299
6415
  rowHeight,
6416
+ rowSpan,
6300
6417
  computedUnpinnedColumns,
6301
6418
  computedUnpinnedColumnsWidth,
6302
6419
  shouldVirtualizeColumns,
@@ -6619,7 +6736,7 @@ function PinnedRowsContainer(props) {
6619
6736
  return /* @__PURE__ */ React30.createElement(RowListWithExternalScrolling, __spreadValues({}, rowListProps));
6620
6737
  }
6621
6738
  function useRenderPinnedRow(params) {
6622
- const { getData, getState, columnsWidth, columns, verticalBrain } = params;
6739
+ const { getData, getState, columnsWidth, columns, rowSpan, verticalBrain } = params;
6623
6740
  const renderPinnedRow = (0, import_react37.useCallback)((rowParams) => {
6624
6741
  const dataArray = getData();
6625
6742
  const rowInfo = dataArray[rowParams.rowIndex];
@@ -6633,6 +6750,7 @@ function useRenderPinnedRow(params) {
6633
6750
  virtualizeColumns: false,
6634
6751
  verticalBrain,
6635
6752
  brain: null,
6753
+ rowSpan,
6636
6754
  rowWidth: columnsWidth,
6637
6755
  columns
6638
6756
  }, rowParams);
@@ -6657,6 +6775,7 @@ function usePinnedRenderingForSide(side, params) {
6657
6775
  computedPinnedStartOverflow,
6658
6776
  pinnedStartScrollListener,
6659
6777
  pinnedEndScrollListener,
6778
+ rowSpan,
6660
6779
  repaintId,
6661
6780
  toggleGroupRow,
6662
6781
  scrollbars: {
@@ -6675,6 +6794,7 @@ function usePinnedRenderingForSide(side, params) {
6675
6794
  getData,
6676
6795
  getState,
6677
6796
  toggleGroupRow,
6797
+ rowSpan,
6678
6798
  verticalBrain: verticalVirtualBrain,
6679
6799
  columns,
6680
6800
  columnsWidth
@@ -7038,7 +7158,7 @@ var VirtualBrain = class extends Logger {
7038
7158
  this.computeCacheFor(lastSizeIndex);
7039
7159
  _prev = lastOffset;
7040
7160
  lastOffset = this.itemOffsetCache[lastSizeIndex];
7041
- if (_prev === lastOffset) {
7161
+ if (_prev === lastOffset && _prev != 0) {
7042
7162
  return count - 1;
7043
7163
  }
7044
7164
  }
@@ -7230,6 +7350,10 @@ function useYourBrain(param) {
7230
7350
  }, []);
7231
7351
  horizontalVirtualBrain.update(computedUnpinnedColumns.length, columnSize);
7232
7352
  verticalVirtualBrain.update(dataArray.length, rowHeight, rowSpan);
7353
+ if (true) {
7354
+ globalThis.verticalVirtualBrain = verticalVirtualBrain;
7355
+ globalThis.horizontalVirtualBrain = horizontalVirtualBrain;
7356
+ }
7233
7357
  (0, import_react40.useEffect)(() => {
7234
7358
  verticalVirtualBrain.setAvailableSize({
7235
7359
  height: bodySize.height,
@@ -7261,7 +7385,7 @@ function useListRendering(param) {
7261
7385
  computedUnpinnedColumnsWidth,
7262
7386
  computedPinnedStartOverflow,
7263
7387
  computedPinnedEndOverflow,
7264
- computedVisibleColumns,
7388
+ rowSpan,
7265
7389
  toggleGroupRow
7266
7390
  } = computed;
7267
7391
  const { componentState: dataSourceState, getState: getDataSourceState } = useDataSourceContextValue();
@@ -7280,32 +7404,6 @@ function useListRendering(param) {
7280
7404
  repaintIdRef.current++;
7281
7405
  }
7282
7406
  const repaintId = repaintIdRef.current;
7283
- const rowSpan = (0, import_react41.useMemo)(() => {
7284
- const colsWithRowspan = computedVisibleColumns.filter((col) => typeof col.rowspan === "function");
7285
- return colsWithRowspan.length ? ({ itemIndex }) => {
7286
- let maxSpan = 1;
7287
- const dataArray2 = getData();
7288
- const rowInfo = dataArray2[itemIndex];
7289
- const data = rowInfo.data;
7290
- colsWithRowspan.forEach((column) => {
7291
- if (!column.rowspan) {
7292
- return;
7293
- }
7294
- const span = column.rowspan({
7295
- column,
7296
- data,
7297
- dataArray: dataArray2,
7298
- groupRowInfo: null,
7299
- rowInfo,
7300
- rowIndex: itemIndex
7301
- });
7302
- if (span > maxSpan) {
7303
- maxSpan = span;
7304
- }
7305
- });
7306
- return maxSpan;
7307
- } : void 0;
7308
- }, [computedVisibleColumns]);
7309
7407
  const { horizontalVirtualBrain, verticalVirtualBrain } = useYourBrain({
7310
7408
  computedPinnedStartWidth: computed.computedPinnedStartWidth,
7311
7409
  computedPinnedEndWidth: computed.computedPinnedEndWidth,
@@ -7366,7 +7464,8 @@ function useListRendering(param) {
7366
7464
  rowHeight,
7367
7465
  verticalVirtualBrain,
7368
7466
  pinnedStartScrollListener,
7369
- pinnedEndScrollListener
7467
+ pinnedEndScrollListener,
7468
+ rowSpan
7370
7469
  };
7371
7470
  const centerRenderingParams = __spreadProps(__spreadValues({}, pinnedRenderingParams), {
7372
7471
  columnShifts,
@@ -7630,7 +7729,7 @@ var useLicense = (licenseKey = "") => {
7630
7729
  const valid = (0, import_react43.useMemo)(() => {
7631
7730
  let valid2 = isValidLicense(licenseKey, {
7632
7731
  publishedAt: 1624970570587,
7633
- version: "0.2.3"
7732
+ version: "0.2.7"
7634
7733
  });
7635
7734
  if (!licenseKey && !valid2 && isInsideSandbox) {
7636
7735
  return true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@infinite-table/infinite-react",
3
3
  "description": "Infinite Table for React",
4
- "version": "0.2.3",
4
+ "version": "0.2.7",
5
5
  "main": "index.js",
6
6
  "module": "index.esm.js",
7
7
  "typings": "index.d.ts",
@@ -14,5 +14,5 @@
14
14
  },
15
15
  "license": "Commercial & Open Source",
16
16
  "//": "will be updated at build time",
17
- "publishedAt": 1644358278775
17
+ "publishedAt": 1645183793183
18
18
  }