@infinite-table/infinite-react 4.3.4 → 4.3.6

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.dev.mjs CHANGED
@@ -6913,6 +6913,7 @@ function reorderColumnsOnDrag(params) {
6913
6913
  infiniteDOMNode,
6914
6914
  brain,
6915
6915
  dragColumnHeaderTargetRect,
6916
+ draggableColumnsRestrictTo,
6916
6917
  tableRect,
6917
6918
  setProxyPosition,
6918
6919
  api: imperativeApi
@@ -6941,8 +6942,9 @@ function reorderColumnsOnDrag(params) {
6941
6942
  const scrollLeft2 = brain.getScrollPosition().scrollLeft;
6942
6943
  return col.computedOffset >= scrollLeft2 + getCurrentPinnedWidth("start") && col.computedOffset + col.computedWidth < scrollLeft2 + tableRect.width - getCurrentPinnedWidth("end");
6943
6944
  }
6944
- const getBreakPoints = (columns) => {
6945
- const breakpoints = [];
6945
+ const getBreakPoints = (columns, options) => {
6946
+ const { restrictToParentGroup, dragColumn: dragColumn2 } = options;
6947
+ let breakpoints = [];
6946
6948
  columns.forEach((c) => {
6947
6949
  const b = {
6948
6950
  columnId: c.id,
@@ -6956,6 +6958,26 @@ function reorderColumnsOnDrag(params) {
6956
6958
  breakpoints.push(b);
6957
6959
  }
6958
6960
  });
6961
+ if (restrictToParentGroup) {
6962
+ let checkAllowedColumnsInDirection2 = function(colIndex, dir2, disallowedTargets2) {
6963
+ const col = columns[colIndex];
6964
+ if (!col) {
6965
+ return;
6966
+ }
6967
+ if (col.columnGroup !== dragColumn2.columnGroup) {
6968
+ disallowedTargets2.add(col.id);
6969
+ }
6970
+ checkAllowedColumnsInDirection2(colIndex + dir2, dir2, disallowedTargets2);
6971
+ };
6972
+ var checkAllowedColumnsInDirection = checkAllowedColumnsInDirection2;
6973
+ const dragColIndex = dragColumn2.computedVisibleIndex;
6974
+ const disallowedTargets = /* @__PURE__ */ new Set();
6975
+ checkAllowedColumnsInDirection2(dragColIndex - 1, -1, disallowedTargets);
6976
+ checkAllowedColumnsInDirection2(dragColIndex + 1, 1, disallowedTargets);
6977
+ breakpoints = breakpoints.filter((b) => {
6978
+ return !disallowedTargets.has(b.columnId);
6979
+ });
6980
+ }
6959
6981
  return breakpoints;
6960
6982
  };
6961
6983
  const initialPinnedStartCount = computedPinnedStartColumns.length;
@@ -7134,7 +7156,10 @@ function reorderColumnsOnDrag(params) {
7134
7156
  imperativeApi.scrollLeft = value;
7135
7157
  }
7136
7158
  });
7137
- const breakpoints = getBreakPoints(computedVisibleColumns);
7159
+ const breakpoints = getBreakPoints(computedVisibleColumns, {
7160
+ dragColumn,
7161
+ restrictToParentGroup: draggableColumnsRestrictTo === "group"
7162
+ });
7138
7163
  let currentPos = dir === -1 ? dragColumn.computedOffset + diffX : dragColumn.computedOffset + dragColumn.computedWidth + diffX;
7139
7164
  let idx = (0, import_binary_search2.default)(
7140
7165
  breakpoints,
@@ -7293,7 +7318,7 @@ var useColumnPointerEvents = ({
7293
7318
  if (((_a2 = e.target) == null ? void 0 : _a2.tagName) === "INPUT") {
7294
7319
  return;
7295
7320
  }
7296
- const { brain } = getState();
7321
+ const { brain, draggableColumnsRestrictTo } = getState();
7297
7322
  const {
7298
7323
  computedVisibleColumns,
7299
7324
  computedVisibleColumnsMap,
@@ -7315,6 +7340,7 @@ var useColumnPointerEvents = ({
7315
7340
  let didDragAtLeastOnce = false;
7316
7341
  const dragger = reorderColumnsOnDrag({
7317
7342
  brain,
7343
+ draggableColumnsRestrictTo,
7318
7344
  columnOffsetAtIndexCSSVar: columnOffsetAtIndex4,
7319
7345
  columnWidthAtIndexCSSVar: columnWidthAtIndex3,
7320
7346
  computedPinnedEndColumns,
@@ -9923,6 +9949,7 @@ function InfiniteTableHeaderFn(props) {
9923
9949
  } = props;
9924
9950
  const {
9925
9951
  computed,
9952
+ getState,
9926
9953
  state: { headerBrain, headerOptions, showColumnFilters }
9927
9954
  } = useInfiniteTable();
9928
9955
  const { computedColumnsMap } = computed;
@@ -9975,7 +10002,8 @@ function InfiniteTableHeaderFn(props) {
9975
10002
  computedWidth: colGroupItem.computedWidth,
9976
10003
  groupOffset: colGroupItem.groupOffset
9977
10004
  });
9978
- return /* @__PURE__ */ React46.createElement(
10005
+ const visible = getState().columnGroupVisibility[colGroupItem.id] !== false;
10006
+ return visible ? /* @__PURE__ */ React46.createElement(
9979
10007
  InfiniteTableHeaderGroup,
9980
10008
  {
9981
10009
  bodyBrain,
@@ -9986,7 +10014,7 @@ function InfiniteTableHeaderFn(props) {
9986
10014
  height,
9987
10015
  columnGroup: computedColumnGroup
9988
10016
  }
9989
- );
10017
+ ) : null;
9990
10018
  }
9991
10019
  return /* @__PURE__ */ React46.createElement(
9992
10020
  InfiniteTableHeaderCell,
@@ -14851,136 +14879,6 @@ function useDataSourceInternal(props) {
14851
14879
  };
14852
14880
  }
14853
14881
 
14854
- // src/utils/FixedSizeMap.ts
14855
- var _FixedSizeMap = class {
14856
- constructor(clone, size) {
14857
- this.keysInOrder = [];
14858
- if (typeof clone === "number") {
14859
- this.maxSize = clone;
14860
- this.currentMap = /* @__PURE__ */ new Map();
14861
- } else {
14862
- this.maxSize = size != null ? size : _FixedSizeMap.DEFAULT_SIZE;
14863
- if (clone) {
14864
- const arr = Array.from(clone);
14865
- if (this.maxSize < arr.length) {
14866
- arr.slice(arr.length - this.maxSize);
14867
- }
14868
- this.currentMap = /* @__PURE__ */ new Map();
14869
- arr.forEach(([k, v]) => {
14870
- this.set(k, v);
14871
- });
14872
- } else {
14873
- this.currentMap = /* @__PURE__ */ new Map();
14874
- }
14875
- }
14876
- }
14877
- values() {
14878
- return this.currentMap.values();
14879
- }
14880
- get size() {
14881
- return this.currentMap.size;
14882
- }
14883
- delete(key) {
14884
- if (this.currentMap.has(key)) {
14885
- this.currentMap.delete(key);
14886
- this.keysInOrder = this.keysInOrder.filter((k) => k !== key);
14887
- return true;
14888
- }
14889
- return false;
14890
- }
14891
- has(key) {
14892
- return this.currentMap.has(key);
14893
- }
14894
- get(key) {
14895
- return this.currentMap.get(key);
14896
- }
14897
- set(key, el) {
14898
- if (this.has(key)) {
14899
- this.delete(key);
14900
- }
14901
- const canAddCount = this.maxSize - this.currentMap.size;
14902
- if (canAddCount <= 0) {
14903
- const [removedKey] = this.keysInOrder.splice(0, 1);
14904
- if (removedKey != void 0) {
14905
- this.currentMap.delete(removedKey);
14906
- }
14907
- }
14908
- this.keysInOrder.push(key);
14909
- this.currentMap.set(key, el);
14910
- return this;
14911
- }
14912
- };
14913
- var FixedSizeMap = _FixedSizeMap;
14914
- FixedSizeMap.DEFAULT_SIZE = 10;
14915
-
14916
- // src/components/DataSource/RowDetailCache.ts
14917
- var RowDetailNoCacheStorage = class {
14918
- add(_key, _value) {
14919
- return;
14920
- }
14921
- get(_key) {
14922
- return void 0;
14923
- }
14924
- delete(_key) {
14925
- return;
14926
- }
14927
- has(_key) {
14928
- return false;
14929
- }
14930
- };
14931
- var RowDetailFixedSizeCacheStorage = class {
14932
- constructor(maxSize) {
14933
- this.storage = new FixedSizeMap(maxSize);
14934
- }
14935
- add(key, value) {
14936
- this.storage.set(key, value);
14937
- }
14938
- get(key) {
14939
- return this.storage.get(key);
14940
- }
14941
- delete(key) {
14942
- this.storage.delete(key);
14943
- }
14944
- has(key) {
14945
- return this.storage.has(key);
14946
- }
14947
- };
14948
- var RowDetailFullCacheStorage = class {
14949
- constructor() {
14950
- this.storage = /* @__PURE__ */ new Map();
14951
- }
14952
- add(key, value) {
14953
- this.storage.set(key, value);
14954
- }
14955
- get(key) {
14956
- return this.storage.get(key);
14957
- }
14958
- delete(key) {
14959
- this.storage.delete(key);
14960
- }
14961
- has(key) {
14962
- return this.storage.has(key);
14963
- }
14964
- };
14965
- var RowDetailCache = class {
14966
- // public instanceIndex: number = 0;
14967
- constructor(cache) {
14968
- this.cacheStorage = cache === false ? new RowDetailNoCacheStorage() : cache === true ? new RowDetailFullCacheStorage() : typeof cache === "number" ? new RowDetailFixedSizeCacheStorage(cache) : new RowDetailFixedSizeCacheStorage(5);
14969
- }
14970
- add(key, value) {
14971
- this.cacheStorage.add(key, value);
14972
- }
14973
- get(key) {
14974
- return this.cacheStorage.get(key);
14975
- }
14976
- delete(key) {
14977
- this.cacheStorage.delete(key);
14978
- }
14979
- has(key) {
14980
- return this.cacheStorage.has(key);
14981
- }
14982
- };
14983
-
14984
14882
  // src/components/DataSource/BooleanCollectionState.ts
14985
14883
  var BooleanCollectionState = class {
14986
14884
  constructor(state) {
@@ -15178,6 +15076,136 @@ var RowDetailState = class extends BooleanCollectionState {
15178
15076
  }
15179
15077
  };
15180
15078
 
15079
+ // src/utils/FixedSizeMap.ts
15080
+ var _FixedSizeMap = class {
15081
+ constructor(clone, size) {
15082
+ this.keysInOrder = [];
15083
+ if (typeof clone === "number") {
15084
+ this.maxSize = clone;
15085
+ this.currentMap = /* @__PURE__ */ new Map();
15086
+ } else {
15087
+ this.maxSize = size != null ? size : _FixedSizeMap.DEFAULT_SIZE;
15088
+ if (clone) {
15089
+ const arr = Array.from(clone);
15090
+ if (this.maxSize < arr.length) {
15091
+ arr.slice(arr.length - this.maxSize);
15092
+ }
15093
+ this.currentMap = /* @__PURE__ */ new Map();
15094
+ arr.forEach(([k, v]) => {
15095
+ this.set(k, v);
15096
+ });
15097
+ } else {
15098
+ this.currentMap = /* @__PURE__ */ new Map();
15099
+ }
15100
+ }
15101
+ }
15102
+ values() {
15103
+ return this.currentMap.values();
15104
+ }
15105
+ get size() {
15106
+ return this.currentMap.size;
15107
+ }
15108
+ delete(key) {
15109
+ if (this.currentMap.has(key)) {
15110
+ this.currentMap.delete(key);
15111
+ this.keysInOrder = this.keysInOrder.filter((k) => k !== key);
15112
+ return true;
15113
+ }
15114
+ return false;
15115
+ }
15116
+ has(key) {
15117
+ return this.currentMap.has(key);
15118
+ }
15119
+ get(key) {
15120
+ return this.currentMap.get(key);
15121
+ }
15122
+ set(key, el) {
15123
+ if (this.has(key)) {
15124
+ this.delete(key);
15125
+ }
15126
+ const canAddCount = this.maxSize - this.currentMap.size;
15127
+ if (canAddCount <= 0) {
15128
+ const [removedKey] = this.keysInOrder.splice(0, 1);
15129
+ if (removedKey != void 0) {
15130
+ this.currentMap.delete(removedKey);
15131
+ }
15132
+ }
15133
+ this.keysInOrder.push(key);
15134
+ this.currentMap.set(key, el);
15135
+ return this;
15136
+ }
15137
+ };
15138
+ var FixedSizeMap = _FixedSizeMap;
15139
+ FixedSizeMap.DEFAULT_SIZE = 10;
15140
+
15141
+ // src/components/DataSource/RowDetailCache.ts
15142
+ var RowDetailNoCacheStorage = class {
15143
+ add(_key, _value) {
15144
+ return;
15145
+ }
15146
+ get(_key) {
15147
+ return void 0;
15148
+ }
15149
+ delete(_key) {
15150
+ return;
15151
+ }
15152
+ has(_key) {
15153
+ return false;
15154
+ }
15155
+ };
15156
+ var RowDetailFixedSizeCacheStorage = class {
15157
+ constructor(maxSize) {
15158
+ this.storage = new FixedSizeMap(maxSize);
15159
+ }
15160
+ add(key, value) {
15161
+ this.storage.set(key, value);
15162
+ }
15163
+ get(key) {
15164
+ return this.storage.get(key);
15165
+ }
15166
+ delete(key) {
15167
+ this.storage.delete(key);
15168
+ }
15169
+ has(key) {
15170
+ return this.storage.has(key);
15171
+ }
15172
+ };
15173
+ var RowDetailFullCacheStorage = class {
15174
+ constructor() {
15175
+ this.storage = /* @__PURE__ */ new Map();
15176
+ }
15177
+ add(key, value) {
15178
+ this.storage.set(key, value);
15179
+ }
15180
+ get(key) {
15181
+ return this.storage.get(key);
15182
+ }
15183
+ delete(key) {
15184
+ this.storage.delete(key);
15185
+ }
15186
+ has(key) {
15187
+ return this.storage.has(key);
15188
+ }
15189
+ };
15190
+ var RowDetailCache = class {
15191
+ // public instanceIndex: number = 0;
15192
+ constructor(cache) {
15193
+ this.cacheStorage = cache === false ? new RowDetailNoCacheStorage() : cache === true ? new RowDetailFullCacheStorage() : typeof cache === "number" ? new RowDetailFixedSizeCacheStorage(cache) : new RowDetailFixedSizeCacheStorage(5);
15194
+ }
15195
+ add(key, value) {
15196
+ this.cacheStorage.add(key, value);
15197
+ }
15198
+ get(key) {
15199
+ return this.cacheStorage.get(key);
15200
+ }
15201
+ delete(key) {
15202
+ this.cacheStorage.delete(key);
15203
+ }
15204
+ has(key) {
15205
+ return this.cacheStorage.has(key);
15206
+ }
15207
+ };
15208
+
15181
15209
  // src/components/DataSource/types.ts
15182
15210
  var DataSourceActionType = /* @__PURE__ */ ((DataSourceActionType2) => {
15183
15211
  DataSourceActionType2["INIT"] = "INIT";
@@ -17305,12 +17333,18 @@ var ScrollListener = class {
17305
17333
  };
17306
17334
 
17307
17335
  // src/components/InfiniteTable/state/computeColumnGroupsDepths.ts
17308
- function computeColumnGroupsDepths(columnGroups) {
17336
+ function computeColumnGroupsDepths(columnGroups, columnGroupVisibility) {
17309
17337
  const map2 = /* @__PURE__ */ new Map();
17338
+ function isVisible(colGroupId) {
17339
+ return columnGroupVisibility[colGroupId] !== false;
17340
+ }
17310
17341
  Object.keys(columnGroups).forEach((colGroupId) => {
17311
17342
  const colGroup = columnGroups[colGroupId];
17312
17343
  let parentGroupId = colGroup.columnGroup;
17313
17344
  let depth = 0;
17345
+ if (!isVisible(colGroupId)) {
17346
+ depth = -1;
17347
+ }
17314
17348
  while (parentGroupId) {
17315
17349
  const parent = columnGroups[parentGroupId];
17316
17350
  if (!parent) {
@@ -17319,7 +17353,9 @@ function computeColumnGroupsDepths(columnGroups) {
17319
17353
  }
17320
17354
  break;
17321
17355
  }
17322
- depth++;
17356
+ if (isVisible(parentGroupId)) {
17357
+ depth++;
17358
+ }
17323
17359
  parentGroupId = parent.columnGroup;
17324
17360
  }
17325
17361
  map2.set(colGroupId, depth);
@@ -17336,6 +17372,7 @@ function getRowDetailRendererFromComponent(RowDetail) {
17336
17372
  }
17337
17373
 
17338
17374
  // src/components/InfiniteTable/state/getInitialState.ts
17375
+ var EMPTY_OBJECT = {};
17339
17376
  function createRenderer2(brain) {
17340
17377
  const renderer = new ReactHeadlessTableRenderer(brain);
17341
17378
  const onRenderUpdater = buildSubscriptionCallback();
@@ -17483,6 +17520,7 @@ var forwardProps4 = (_setupState) => {
17483
17520
  onScrollbarsChange: 1,
17484
17521
  autoSizeColumnsKey: 1,
17485
17522
  columnDefaultFlex: 1,
17523
+ draggableColumnsRestrictTo: (draggableColumnsRestrictTo) => draggableColumnsRestrictTo != null ? draggableColumnsRestrictTo : false,
17486
17524
  columnMenuRealignDelay: (columnMenuRealignDelay) => columnMenuRealignDelay != null ? columnMenuRealignDelay : 50,
17487
17525
  scrollStopDelay: (scrollStopDelay) => scrollStopDelay != null ? scrollStopDelay : 250,
17488
17526
  viewportReservedWidth: (viewportReservedWidth) => viewportReservedWidth != null ? viewportReservedWidth : 0,
@@ -17521,7 +17559,8 @@ var forwardProps4 = (_setupState) => {
17521
17559
  rowDetailHeight: (rowDetailHeight) => typeof rowDetailHeight === "number" || typeof rowDetailHeight === "function" ? rowDetailHeight : 300,
17522
17560
  columnHeaderHeight: (columnHeaderHeight) => typeof columnHeaderHeight === "number" ? columnHeaderHeight : 30,
17523
17561
  columns: 1,
17524
- columnVisibility: (columnVisibility) => columnVisibility != null ? columnVisibility : {},
17562
+ columnVisibility: (columnVisibility) => columnVisibility != null ? columnVisibility : EMPTY_OBJECT,
17563
+ columnGroupVisibility: (columnGroupVisibility) => columnGroupVisibility != null ? columnGroupVisibility : EMPTY_OBJECT,
17525
17564
  // TODO check if columnPinning works when the value for a pinned col is `true` instead of `"start"`
17526
17565
  columnSizing: (columnSizing) => columnSizing || {},
17527
17566
  columnTypes: (columnTypes) => columnTypes || {},
@@ -17602,7 +17641,10 @@ var mapPropsToState = (params) => {
17602
17641
  var _a, _b, _c, _d, _e;
17603
17642
  const { props, state, oldState, parentState } = params;
17604
17643
  const computedColumnGroups = state.pivotColumnGroups || state.columnGroups;
17605
- const columnGroupsDepthsMap = state.columnGroups && state.columnGroups != (oldState == null ? void 0 : oldState.columnGroups) || state.pivotColumnGroups && state.pivotColumnGroups != (oldState == null ? void 0 : oldState.pivotColumnGroups) ? computeColumnGroupsDepths(computedColumnGroups) : state.columnGroupsDepthsMap;
17644
+ const columnGroupsDepthsMap = state.columnGroups && state.columnGroups != (oldState == null ? void 0 : oldState.columnGroups) || state.columnGroups && state.columnGroupVisibility != (oldState == null ? void 0 : oldState.columnGroupVisibility) || state.pivotColumnGroups && state.pivotColumnGroups != (oldState == null ? void 0 : oldState.pivotColumnGroups) ? computeColumnGroupsDepths(
17645
+ computedColumnGroups,
17646
+ state.columnGroupVisibility
17647
+ ) : state.columnGroupsDepthsMap;
17606
17648
  const groupBy = parentState == null ? void 0 : parentState.groupBy;
17607
17649
  const groupRenderStrategy = getGroupRenderStrategy({
17608
17650
  groupRenderStrategy: props.groupRenderStrategy,
@@ -17657,7 +17699,11 @@ var mapPropsToState = (params) => {
17657
17699
  keyboardNavigation: (_c = props.keyboardNavigation) != null ? _c : state.activeCellIndex != null ? "cell" : state.activeRowIndex != null ? "row" : "cell",
17658
17700
  columnHeaderCssEllipsis: (_e = (_d = props.columnHeaderCssEllipsis) != null ? _d : props.columnCssEllipsis) != null ? _e : true,
17659
17701
  columnGroupsDepthsMap,
17660
- columnGroupsMaxDepth: columnGroupsDepthsMap != state.columnGroupsDepthsMap ? Math.max(...columnGroupsDepthsMap.values(), 0) : state.columnGroupsMaxDepth,
17702
+ columnGroupsMaxDepth: columnGroupsDepthsMap != state.columnGroupsDepthsMap ? (
17703
+ // was 0, but after implementing columnGroupVisibility
17704
+ // it can be -1, to denote that no column group is visible
17705
+ Math.max(...columnGroupsDepthsMap.values(), -1)
17706
+ ) : state.columnGroupsMaxDepth,
17661
17707
  computedColumnGroups,
17662
17708
  rowHeightCSSVar: typeof props.rowHeight === "string" ? props.rowHeight : "",
17663
17709
  rowDetailHeightCSSVar: typeof props.rowDetailHeight === "string" ? props.rowDetailHeight : "",
@@ -18583,7 +18629,11 @@ function useComputed() {
18583
18629
  const computedPinnedEndOverflow = computedPinnedEndWidth ? computedPinnedEndColumnsWidth > computedPinnedEndWidth : false;
18584
18630
  const [multiRowSelector] = useState17(() => {
18585
18631
  const multiRowSelector2 = new MultiRowSelector({
18586
- getIdForIndex: (index) => getDataSourceState().dataArray[index].id
18632
+ getIdForIndex: (index) => {
18633
+ var _a2;
18634
+ const dataItem = getDataSourceState().dataArray[index];
18635
+ return (_a2 = dataItem == null ? void 0 : dataItem.id) != null ? _a2 : -1;
18636
+ }
18587
18637
  });
18588
18638
  return multiRowSelector2;
18589
18639
  });
@@ -18815,7 +18865,7 @@ var useLicense = (licenseKey = "") => {
18815
18865
  }
18816
18866
  let valid2 = isValidLicense(licenseKey, {
18817
18867
  publishedAt: 1624970570587,
18818
- version: "4.3.4"
18868
+ version: "4.3.6"
18819
18869
  });
18820
18870
  if (!licenseKey && !valid2 && isInsidePlayground) {
18821
18871
  return true;
@@ -22542,7 +22592,8 @@ function InfiniteTableBody() {
22542
22592
  components: components2,
22543
22593
  bodySize,
22544
22594
  activeCellIndex,
22545
- rowDetailRenderer
22595
+ rowDetailRenderer,
22596
+ showHoverRows
22546
22597
  } = componentState;
22547
22598
  const LoadMaskCmp = (_a = components2 == null ? void 0 : components2.LoadMask) != null ? _a : LoadMask;
22548
22599
  const computed = getComputed();
@@ -22610,7 +22661,7 @@ function InfiniteTableBody() {
22610
22661
  activeCellRowHeight,
22611
22662
  renderCell,
22612
22663
  renderDetailRow: rowDetailRenderer ? renderDetailRow : void 0,
22613
- cellHoverClassNames: HOVERED_CLASS_NAMES,
22664
+ cellHoverClassNames: showHoverRows ? HOVERED_CLASS_NAMES : void 0,
22614
22665
  scrollerDOMRef
22615
22666
  }
22616
22667
  ), /* @__PURE__ */ React68.createElement(LoadMaskCmp, { visible: loading }, loadingText));