@infinite-table/infinite-react 3.0.16 → 3.1.1

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
@@ -7497,7 +7497,7 @@ function getColumnValueToEdit(options) {
7497
7497
  }
7498
7498
  function getColumnRenderingParams(options) {
7499
7499
  var _a, _b;
7500
- const { column, context, rowInfo } = options;
7500
+ const { column, context, rowInfo, visibleColumnsIds } = options;
7501
7501
  const groupByColumnReference = getGroupByColumnReference({
7502
7502
  rowInfo,
7503
7503
  column,
@@ -7517,10 +7517,16 @@ function getColumnRenderingParams(options) {
7517
7517
  });
7518
7518
  const stylingParam = __spreadProps(__spreadValues({
7519
7519
  column: options.column,
7520
- inEdit
7520
+ inEdit,
7521
+ rowHasSelectedCells: false
7521
7522
  }, formattedValueContext), {
7522
7523
  editError: editingCell && editingCell.primaryKey === rowInfo.id && editingCell.columnId === column.id && !editingCell.active && editingCell.accepted instanceof Error ? editingCell.accepted : void 0
7523
7524
  });
7525
+ Object.defineProperty(stylingParam, "rowHasSelectedCells", {
7526
+ get() {
7527
+ return rowInfo.hasSelectedCells(visibleColumnsIds);
7528
+ }
7529
+ });
7524
7530
  const align2 = typeof column.align === "function" ? column.align(__spreadValues({ isHeader: false }, stylingParam)) : (_a = column.align) != null ? _a : "start";
7525
7531
  const verticalAlign = typeof column.verticalAlign === "function" ? column.verticalAlign(__spreadValues({ isHeader: false }, stylingParam)) : (_b = column.verticalAlign) != null ? _b : "center";
7526
7532
  return {
@@ -7550,6 +7556,7 @@ function getColumnRenderParam(options) {
7550
7556
  rowInfo,
7551
7557
  align: align2,
7552
7558
  verticalAlign,
7559
+ visibleColumnsIds,
7553
7560
  columnsMap,
7554
7561
  fieldsToColumn,
7555
7562
  formattedValueContext
@@ -7574,7 +7581,8 @@ function getColumnRenderParam(options) {
7574
7581
  fieldsToColumn,
7575
7582
  align: align2,
7576
7583
  verticalAlign,
7577
- cellSelected
7584
+ cellSelected,
7585
+ rowHasSelectedCells: false
7578
7586
  }, formattedValueContext), {
7579
7587
  editError: editingCell && editingCell.primaryKey === rowInfo.id && editingCell.columnId === column.id && !editingCell.active && editingCell.accepted instanceof Error ? editingCell.accepted : void 0,
7580
7588
  groupByColumn,
@@ -7639,6 +7647,11 @@ function getColumnRenderParam(options) {
7639
7647
  rootGroupBy: dataSourceState.groupBy,
7640
7648
  pivotBy: dataSourceState.pivotBy
7641
7649
  });
7650
+ Object.defineProperty(renderParam, "rowHasSelectedCells", {
7651
+ get() {
7652
+ return rowInfo.hasSelectedCells(visibleColumnsIds);
7653
+ }
7654
+ });
7642
7655
  return renderParam;
7643
7656
  }
7644
7657
  function getRawValueForCell(column, rowInfo) {
@@ -7914,10 +7927,12 @@ function InfiniteTableColumnCellFn(props) {
7914
7927
  api: imperativeApi,
7915
7928
  dataSourceApi
7916
7929
  };
7930
+ const visibleColumnsIds = computed.computedVisibleColumns.map((x) => x.id);
7917
7931
  const colRenderingParams = getColumnRenderingParams({
7918
7932
  column,
7919
7933
  rowInfo,
7920
7934
  columnsMap,
7935
+ visibleColumnsIds,
7921
7936
  fieldsToColumn,
7922
7937
  context: renderingContext
7923
7938
  });
@@ -8081,8 +8096,19 @@ function InfiniteTableColumnCellFn(props) {
8081
8096
  renderBag: true
8082
8097
  })
8083
8098
  ]);
8099
+ const visibleColumnIds = computed.computedVisibleColumns.map((x) => x.id);
8100
+ const allColumnIds = computed.computedColumnOrder;
8084
8101
  const rowPropsAndStyleArgs = __spreadProps(__spreadValues({}, formattedValueContext), {
8085
- rowIndex
8102
+ visibleColumnIds,
8103
+ allColumnIds,
8104
+ rowIndex,
8105
+ // we put it as false by default
8106
+ rowHasSelectedCells: false
8107
+ });
8108
+ Object.defineProperty(rowPropsAndStyleArgs, "rowHasSelectedCells", {
8109
+ get() {
8110
+ return rowInfo.hasSelectedCells(visibleColumnIds);
8111
+ }
8086
8112
  });
8087
8113
  const rowComputedClassName = typeof rowClassName === "function" ? rowClassName(rowPropsAndStyleArgs) : rowClassName;
8088
8114
  let colClassName = void 0;
@@ -10288,6 +10314,7 @@ function getEnhancedGroupData(options, deepMapValue) {
10288
10314
  collapsed: false,
10289
10315
  dataSourceHasGrouping: true,
10290
10316
  isCellSelected: returnFalse,
10317
+ hasSelectedCells: returnFalse,
10291
10318
  selfLoaded,
10292
10319
  error: options.error,
10293
10320
  parents,
@@ -10424,6 +10451,7 @@ function enhancedFlatten(param) {
10424
10451
  id: itemId,
10425
10452
  data: item,
10426
10453
  isCellSelected: returnFalse,
10454
+ hasSelectedCells: returnFalse,
10427
10455
  dataSourceHasGrouping: true,
10428
10456
  isGroupRow: false,
10429
10457
  selfLoaded: !!item,
@@ -11718,6 +11746,7 @@ function getRowSelectionApi(param) {
11718
11746
  }
11719
11747
 
11720
11748
  // src/components/DataSource/CellSelectionState.ts
11749
+ var debug4 = dbg("CellSelectionState");
11721
11750
  var WILDCARD = "*";
11722
11751
  var CellSelectionState = class {
11723
11752
  constructor(clone) {
@@ -11760,7 +11789,7 @@ var CellSelectionState = class {
11760
11789
  setCellSelected(rowId, colId, selected) {
11761
11790
  const wildcardRow = rowId === this.wildcard;
11762
11791
  const wildcardColumn = colId === this.wildcard;
11763
- const isSelected = this.isCellSelected(rowId, colId);
11792
+ const isSelected = this.isCellSelected_Internal(rowId, colId);
11764
11793
  if (isSelected === selected) {
11765
11794
  return;
11766
11795
  }
@@ -11938,7 +11967,54 @@ var CellSelectionState = class {
11938
11967
  }
11939
11968
  this.defaultSelection = stateObject.defaultSelection;
11940
11969
  }
11970
+ /**
11971
+ * Returns whether there is at least one selected cell in the row
11972
+ *
11973
+ * @param rowId the row id
11974
+ * @param columnIds the columns currently available in the grid
11975
+ * @returns boolean
11976
+ */
11977
+ isCellSelectionInRow(rowId, columnIds) {
11978
+ if (this.defaultSelection) {
11979
+ const cols2 = this.deselectedRowsToColumns.get(rowId);
11980
+ if (cols2) {
11981
+ if (cols2.has(this.wildcard)) {
11982
+ const explicitlySelectedCols = this.selectedRowsToColumns.get(rowId);
11983
+ return explicitlySelectedCols && explicitlySelectedCols.size > 0 ? columnIds.some((colId) => explicitlySelectedCols.has(colId)) : false;
11984
+ }
11985
+ return columnIds.some((colId) => !cols2.has(colId));
11986
+ }
11987
+ return true;
11988
+ }
11989
+ const cols = this.selectedRowsToColumns.get(rowId);
11990
+ if (cols) {
11991
+ if (cols.has(this.wildcard)) {
11992
+ const explicitlyDeselectedCols = this.deselectedRowsToColumns.get(rowId);
11993
+ if (explicitlyDeselectedCols && explicitlyDeselectedCols.size > 0) {
11994
+ const allDeselected = columnIds.every(
11995
+ (colId) => explicitlyDeselectedCols.has(colId)
11996
+ );
11997
+ return !allDeselected;
11998
+ }
11999
+ return true;
12000
+ }
12001
+ return columnIds ? columnIds.some((colId) => cols.has(colId)) : false;
12002
+ }
12003
+ return false;
12004
+ }
11941
12005
  isCellSelected(rowId, colId) {
12006
+ if (rowId === this.wildcard || colId === this.wildcard) {
12007
+ console.error(
12008
+ `CellSelectionState.isCellSelected should not be called with wildcard`
12009
+ );
12010
+ debug4(
12011
+ `CellSelectionState.isCellSelected should not be called with wildcard`
12012
+ );
12013
+ return false;
12014
+ }
12015
+ return this.isCellSelected_Internal(rowId, colId);
12016
+ }
12017
+ isCellSelected_Internal(rowId, colId) {
11942
12018
  var _a, _b;
11943
12019
  const cacheKey = [rowId, colId];
11944
12020
  const { cache } = this;
@@ -12586,7 +12662,8 @@ function toRowInfo(data, id, index, isRowSelected, cellSelectionState) {
12586
12662
  isGroupRow: false,
12587
12663
  selfLoaded: true,
12588
12664
  rowSelected: false,
12589
- isCellSelected: returnFalse2
12665
+ isCellSelected: returnFalse2,
12666
+ hasSelectedCells: returnFalse2
12590
12667
  };
12591
12668
  if (isRowSelected) {
12592
12669
  rowInfo.rowSelected = isRowSelected(rowInfo);
@@ -12595,6 +12672,9 @@ function toRowInfo(data, id, index, isRowSelected, cellSelectionState) {
12595
12672
  rowInfo.isCellSelected = (colId) => {
12596
12673
  return cellSelectionState.isCellSelected(rowInfo.id, colId);
12597
12674
  };
12675
+ rowInfo.hasSelectedCells = (columnIds) => {
12676
+ return cellSelectionState.isCellSelectionInRow(rowInfo.id, columnIds);
12677
+ };
12598
12678
  }
12599
12679
  return rowInfo;
12600
12680
  }
@@ -12725,6 +12805,7 @@ function concludeReducer(params) {
12725
12805
  const shouldGroup = groupBy.length > 0 || !!pivotBy;
12726
12806
  const selectionDepsChanged = haveDepsChanged(previousState, state, [
12727
12807
  "rowSelection",
12808
+ "cellSelection",
12728
12809
  "isRowSelected",
12729
12810
  "originalLazyGroupDataChangeDetect"
12730
12811
  ]);
@@ -15860,13 +15941,13 @@ function useColumnRowspan(computedVisibleColumns) {
15860
15941
 
15861
15942
  // src/components/InfiniteTable/hooks/useColumnSizeFn.ts
15862
15943
  import { useCallback as useCallback20 } from "react";
15863
- var debug4 = dbg("useColumnSizeFn");
15944
+ var debug5 = dbg("useColumnSizeFn");
15864
15945
  function useColumnSizeFn(columns) {
15865
15946
  const columnSize = useCallback20(
15866
15947
  (index) => {
15867
15948
  const column = columns[index];
15868
15949
  if (false) {
15869
- debug4("cannot find column at index", index, columns);
15950
+ debug5("cannot find column at index", index, columns);
15870
15951
  }
15871
15952
  return column ? column.computedWidth : 0;
15872
15953
  },
@@ -17241,7 +17322,7 @@ var useLicense = (licenseKey = "") => {
17241
17322
  const valid = useMemo11(() => {
17242
17323
  let valid2 = isValidLicense(licenseKey, {
17243
17324
  publishedAt: 1624970570587,
17244
- version: "3.0.16"
17325
+ version: "3.1.1"
17245
17326
  });
17246
17327
  if (!licenseKey && !valid2 && isInsidePlayground) {
17247
17328
  return true;
@@ -19127,6 +19208,7 @@ function renderSubmenuForItem(item, config) {
19127
19208
  setActiveItemKey,
19128
19209
  setKeyboardActiveItemKey,
19129
19210
  constrainTo,
19211
+ onHideIntent,
19130
19212
  api
19131
19213
  } = config;
19132
19214
  const overlayId = `${parentMenuId}-submenu`;
@@ -19151,6 +19233,11 @@ function renderSubmenuForItem(item, config) {
19151
19233
  (_a = itemMenu == null ? void 0 : itemMenu.onShow) == null ? void 0 : _a.call(itemMenu, state, api2);
19152
19234
  setSubmenuApi(api2);
19153
19235
  },
19236
+ onHideIntent: (state) => {
19237
+ var _a;
19238
+ (_a = itemMenu == null ? void 0 : itemMenu.onHideIntent) == null ? void 0 : _a.call(itemMenu, state);
19239
+ onHideIntent(state);
19240
+ },
19154
19241
  onHide: (state) => {
19155
19242
  if (state.focused) {
19156
19243
  setActiveItemKey(null);
@@ -19289,6 +19376,7 @@ function MenuComponent(props) {
19289
19376
  setActiveItemKey,
19290
19377
  setKeyboardActiveItemKey,
19291
19378
  parentMenuId: menuId,
19379
+ onHideIntent: hideAll,
19292
19380
  api
19293
19381
  });
19294
19382
  if (alignTo) {
@@ -19311,11 +19399,19 @@ function MenuComponent(props) {
19311
19399
  if (item.originalMenuItem.onClick) {
19312
19400
  item.originalMenuItem.onClick(event);
19313
19401
  }
19402
+ const onActionParam = {
19403
+ key: item.key,
19404
+ item: item.originalMenuItem,
19405
+ hideMenu: hideAll
19406
+ };
19314
19407
  if (item.originalMenuItem.onAction) {
19315
- item.originalMenuItem.onAction(item.key, item.originalMenuItem);
19408
+ item.originalMenuItem.onAction(onActionParam);
19316
19409
  }
19317
19410
  if (onAction) {
19318
- onAction(item.key, item.originalMenuItem);
19411
+ onAction(onActionParam);
19412
+ }
19413
+ if (item.originalMenuItem.hideMenuOnAction) {
19414
+ hideAll();
19319
19415
  }
19320
19416
  };
19321
19417
  const {
@@ -19485,8 +19581,14 @@ function MenuComponent(props) {
19485
19581
  });
19486
19582
  }, []);
19487
19583
  const shouldSelectFirstItemOnFocus = useRef28(true);
19584
+ const hideAll = useCallback25(() => {
19585
+ var _a;
19586
+ const state = getState();
19587
+ (_a = state.onHideIntent) == null ? void 0 : _a.call(state, state);
19588
+ }, [getState]);
19488
19589
  const [api] = useState20(() => {
19489
19590
  const result2 = {
19591
+ hideMenu: hideAll,
19490
19592
  focus: () => {
19491
19593
  if (domRef.current) {
19492
19594
  domRef.current.focus();