@infinite-table/infinite-react 3.0.3 → 3.0.5

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
@@ -13097,7 +13097,7 @@ function concludeReducer(params) {
13097
13097
  }
13098
13098
  if (cache) {
13099
13099
  cache.clear();
13100
- state.cache = cache;
13100
+ state.cache = void 0;
13101
13101
  }
13102
13102
  const { filterFunction, filterValue, filterTypes, operatorsByFilterType } = state;
13103
13103
  const shouldFilter = !!filterFunction || Array.isArray(filterValue) && filterValue.length;
@@ -13350,7 +13350,7 @@ function concludeReducer(params) {
13350
13350
  if (originalDataArrayChanged) {
13351
13351
  state.originalDataArrayChangedInfo = {
13352
13352
  timestamp: now,
13353
- mutations
13353
+ mutations: (mutations == null ? void 0 : mutations.size) ? mutations : void 0
13354
13354
  };
13355
13355
  }
13356
13356
  return state;
@@ -13960,7 +13960,7 @@ var Indexer = class {
13960
13960
  };
13961
13961
  this.indexArray = (arr, options) => {
13962
13962
  const { cache, toPrimaryKey } = options;
13963
- if (cache) {
13963
+ if (cache && !cache.isEmpty()) {
13964
13964
  arr = arr.concat();
13965
13965
  }
13966
13966
  for (let i = 0; i < arr.length; i++) {
@@ -14433,7 +14433,7 @@ function DataSourceCmp({ children }) {
14433
14433
  componentState.originalDataArray,
14434
14434
  componentState.originalDataArrayChangedInfo
14435
14435
  );
14436
- if (componentState.onDataMutations && componentState.originalDataArrayChangedInfo.mutations) {
14436
+ if (componentState.onDataMutations && componentState.originalDataArrayChangedInfo.mutations && componentState.originalDataArrayChangedInfo.mutations.size) {
14437
14437
  componentState.onDataMutations({
14438
14438
  primaryKeyField: typeof componentState.primaryKey === "string" ? componentState.primaryKey : void 0,
14439
14439
  dataArray: componentState.originalDataArray,
@@ -14523,31 +14523,67 @@ function ensureMinMaxCellPositionByIndex(start, end) {
14523
14523
  { rowIndex: rowEnd, colIndex: colEnd }
14524
14524
  ];
14525
14525
  }
14526
- function getCellSelectionApi(param) {
14527
- const {
14528
- getComputed,
14529
- // getState,
14530
- getDataSourceState,
14531
- // componentActions,
14532
- dataSourceActions
14533
- } = param;
14534
- const getCellSelectionPosition = (options) => {
14535
- var _a, _b, _c;
14536
- const rowId = (_b = options.rowId) != null ? _b : (_a = getRowInfoAt(options.rowIndex, getDataSourceState)) == null ? void 0 : _a.id;
14537
- const colId = (_c = options.colId) != null ? _c : getComputed().computedVisibleColumns[options.colIndex].id;
14538
- return [rowId, colId];
14539
- };
14540
- const cellSelectionApi = {
14541
- getAllCellSelectionPositions: () => {
14542
- const dataArray = getRowInfoArray(getDataSourceState);
14543
- const { computedVisibleColumns } = getComputed();
14526
+ var InfiniteTableCellSelectionApiImpl = class {
14527
+ constructor(param) {
14528
+ this.getCellSelectionPosition = (options) => {
14529
+ var _a, _b, _c;
14530
+ const rowId = (_b = options.rowId) != null ? _b : (_a = getRowInfoAt(options.rowIndex, this.getDataSourceState)) == null ? void 0 : _a.id;
14531
+ const colId = (_c = options.colId) != null ? _c : this.getComputed().computedVisibleColumns[options.colIndex].id;
14532
+ return [rowId, colId];
14533
+ };
14534
+ this.setRangeSelected = (startOptions, endOptions, selected) => {
14535
+ const dataSourceState = this.getDataSourceState();
14536
+ const cellSelection = dataSourceState.cellSelection;
14537
+ if (!cellSelection) {
14538
+ return;
14539
+ }
14540
+ const newCellSelection = new CellSelectionState(cellSelection);
14541
+ const [startRowId, startColId] = this.getCellSelectionPosition(startOptions);
14542
+ const [endRowId, endColId] = this.getCellSelectionPosition(endOptions);
14543
+ const startCol = this.getComputed().computedVisibleColumnsMap.get(startColId);
14544
+ const endCol = this.getComputed().computedVisibleColumnsMap.get(endColId);
14545
+ if (!startCol || !endCol) {
14546
+ return;
14547
+ }
14548
+ const startColIndex = startCol.computedVisibleIndex;
14549
+ const endColIndex = endCol.computedVisibleIndex;
14550
+ const startRowInfo = getRowInfoAt(startRowId, this.getDataSourceState);
14551
+ const endRowInfo = getRowInfoAt(endRowId, this.getDataSourceState);
14552
+ if (!startRowInfo || !endRowInfo) {
14553
+ return;
14554
+ }
14555
+ const startRowIndex = startRowInfo.indexInAll;
14556
+ const endRowIndex = endRowInfo.indexInAll;
14557
+ const [start, end] = ensureMinMaxCellPositionByIndex(
14558
+ { rowIndex: startRowIndex, colIndex: startColIndex },
14559
+ { rowIndex: endRowIndex, colIndex: endColIndex }
14560
+ );
14561
+ for (let i = start.rowIndex; i <= end.rowIndex; i++) {
14562
+ for (let j = start.colIndex; j <= end.colIndex; j++) {
14563
+ const pos = {
14564
+ rowIndex: i,
14565
+ colIndex: j
14566
+ };
14567
+ const [pk, colId] = this.getCellSelectionPosition(pos);
14568
+ if (selected) {
14569
+ newCellSelection.selectCell(pk, colId);
14570
+ } else {
14571
+ newCellSelection.deselectCell(pk, colId);
14572
+ }
14573
+ }
14574
+ }
14575
+ this.dataSourceActions.cellSelection = newCellSelection;
14576
+ };
14577
+ this.getCellSelectionPositionsWithFn = (fn, emptyValue) => {
14578
+ const dataArray = getRowInfoArray(this.getDataSourceState);
14579
+ const { computedVisibleColumns } = this.getComputed();
14544
14580
  const computedVisibleColumnsIds = computedVisibleColumns.map((x) => x.id);
14545
14581
  const colsInSelection = /* @__PURE__ */ new Set();
14546
14582
  const rowsInSelection = [];
14547
14583
  const rowIdsInSelection = /* @__PURE__ */ new Set();
14548
14584
  dataArray.filter((rowInfo) => {
14549
14585
  computedVisibleColumns.forEach((col) => {
14550
- if (cellSelectionApi.isCellSelected({
14586
+ if (this.isCellSelected({
14551
14587
  rowId: rowInfo.id,
14552
14588
  colId: col.id
14553
14589
  })) {
@@ -14567,136 +14603,107 @@ function getCellSelectionApi(param) {
14567
14603
  );
14568
14604
  const positions = rowsInSelection.map((rowInfo) => {
14569
14605
  return columnIds.map((colId) => {
14570
- if (cellSelectionApi.isCellSelected({ rowId: rowInfo.id, colId })) {
14571
- return [rowInfo.id, colId];
14606
+ if (this.isCellSelected({ rowId: rowInfo.id, colId })) {
14607
+ return fn(rowInfo, colId);
14572
14608
  }
14573
- return null;
14609
+ return emptyValue;
14574
14610
  });
14575
14611
  });
14576
14612
  return {
14577
14613
  columnIds,
14578
14614
  positions
14579
14615
  };
14580
- },
14581
- deselectAll: () => {
14582
- const dataSourceState = getDataSourceState();
14616
+ };
14617
+ this.getAllCellSelectionPositions = () => {
14618
+ return this.getCellSelectionPositionsWithFn((rowInfo, colId) => {
14619
+ return [rowInfo.id, colId];
14620
+ }, null);
14621
+ };
14622
+ this.getMappedCellSelectionPositions = (fn, emptyValue) => {
14623
+ return this.getCellSelectionPositionsWithFn(fn, emptyValue);
14624
+ };
14625
+ this.deselectAll = () => {
14626
+ const dataSourceState = this.getDataSourceState();
14583
14627
  const cellSelection = dataSourceState.cellSelection;
14584
14628
  if (!cellSelection) {
14585
14629
  return;
14586
14630
  }
14587
14631
  const newCellSelection = new CellSelectionState(cellSelection);
14588
14632
  newCellSelection.deselectAll();
14589
- dataSourceActions.cellSelection = newCellSelection;
14590
- },
14591
- clear: () => {
14592
- cellSelectionApi.deselectAll();
14593
- },
14594
- selectAll: () => {
14595
- const dataSourceState = getDataSourceState();
14633
+ this.dataSourceActions.cellSelection = newCellSelection;
14634
+ };
14635
+ this.clear = () => {
14636
+ this.deselectAll();
14637
+ };
14638
+ this.selectAll = () => {
14639
+ const dataSourceState = this.getDataSourceState();
14596
14640
  const cellSelection = dataSourceState.cellSelection;
14597
14641
  if (!cellSelection) {
14598
14642
  return;
14599
14643
  }
14600
14644
  const newCellSelection = new CellSelectionState(cellSelection);
14601
14645
  newCellSelection.selectAll();
14602
- dataSourceActions.cellSelection = newCellSelection;
14603
- },
14604
- selectRange: (startOptions, endOptions) => {
14605
- cellSelectionApi.setRangeSelected(startOptions, endOptions, true);
14606
- },
14607
- deselectRange: (startOptions, endOptions) => {
14608
- cellSelectionApi.setRangeSelected(startOptions, endOptions, false);
14609
- },
14610
- setRangeSelected: (startOptions, endOptions, selected) => {
14611
- const dataSourceState = getDataSourceState();
14612
- const cellSelection = dataSourceState.cellSelection;
14613
- if (!cellSelection) {
14614
- return;
14615
- }
14616
- const newCellSelection = new CellSelectionState(cellSelection);
14617
- const [startRowId, startColId] = getCellSelectionPosition(startOptions);
14618
- const [endRowId, endColId] = getCellSelectionPosition(endOptions);
14619
- const startCol = getComputed().computedVisibleColumnsMap.get(startColId);
14620
- const endCol = getComputed().computedVisibleColumnsMap.get(endColId);
14621
- if (!startCol || !endCol) {
14622
- return;
14623
- }
14624
- const startColIndex = startCol.computedVisibleIndex;
14625
- const endColIndex = endCol.computedVisibleIndex;
14626
- const startRowInfo = getRowInfoAt(startRowId, getDataSourceState);
14627
- const endRowInfo = getRowInfoAt(endRowId, getDataSourceState);
14628
- if (!startRowInfo || !endRowInfo) {
14629
- return;
14630
- }
14631
- const startRowIndex = startRowInfo.indexInAll;
14632
- const endRowIndex = endRowInfo.indexInAll;
14633
- const [start, end] = ensureMinMaxCellPositionByIndex(
14634
- { rowIndex: startRowIndex, colIndex: startColIndex },
14635
- { rowIndex: endRowIndex, colIndex: endColIndex }
14636
- );
14637
- for (let i = start.rowIndex; i <= end.rowIndex; i++) {
14638
- for (let j = start.colIndex; j <= end.colIndex; j++) {
14639
- const pos = {
14640
- rowIndex: i,
14641
- colIndex: j
14642
- };
14643
- const [pk, colId] = getCellSelectionPosition(pos);
14644
- if (selected) {
14645
- newCellSelection.selectCell(pk, colId);
14646
- } else {
14647
- newCellSelection.deselectCell(pk, colId);
14648
- }
14649
- }
14650
- }
14651
- dataSourceActions.cellSelection = newCellSelection;
14652
- },
14653
- isCellSelected: (options) => {
14646
+ this.dataSourceActions.cellSelection = newCellSelection;
14647
+ };
14648
+ this.selectRange = (startOptions, endOptions) => {
14649
+ this.setRangeSelected(startOptions, endOptions, true);
14650
+ };
14651
+ this.deselectRange = (startOptions, endOptions) => {
14652
+ this.setRangeSelected(startOptions, endOptions, false);
14653
+ };
14654
+ this.isCellSelected = (options) => {
14654
14655
  var _a, _b;
14655
- const [pk, colId] = getCellSelectionPosition(options);
14656
- return (_b = (_a = getDataSourceState().cellSelection) == null ? void 0 : _a.isCellSelected(pk, colId)) != null ? _b : false;
14657
- },
14658
- selectCell: (options) => {
14659
- const cellSelection = getDataSourceState().cellSelection;
14656
+ const [pk, colId] = this.getCellSelectionPosition(options);
14657
+ return (_b = (_a = this.getDataSourceState().cellSelection) == null ? void 0 : _a.isCellSelected(pk, colId)) != null ? _b : false;
14658
+ };
14659
+ this.selectCell = (options) => {
14660
+ const cellSelection = this.getDataSourceState().cellSelection;
14660
14661
  if (!cellSelection) {
14661
14662
  return;
14662
14663
  }
14663
- const [pk, colId] = getCellSelectionPosition(options);
14664
+ const [pk, colId] = this.getCellSelectionPosition(options);
14664
14665
  const newCellSelection = options.clear ? new CellSelectionState() : new CellSelectionState(cellSelection);
14665
14666
  newCellSelection.selectCell(pk, colId);
14666
- dataSourceActions.cellSelection = newCellSelection;
14667
- },
14668
- deselectCell: (options) => {
14669
- const cellSelection = getDataSourceState().cellSelection;
14667
+ this.dataSourceActions.cellSelection = newCellSelection;
14668
+ };
14669
+ this.deselectCell = (options) => {
14670
+ const cellSelection = this.getDataSourceState().cellSelection;
14670
14671
  if (!cellSelection) {
14671
14672
  return;
14672
14673
  }
14673
- const [pk, colId] = getCellSelectionPosition(options);
14674
+ const [pk, colId] = this.getCellSelectionPosition(options);
14674
14675
  const newCellSelection = new CellSelectionState(cellSelection);
14675
14676
  newCellSelection.deselectCell(pk, colId);
14676
- dataSourceActions.cellSelection = newCellSelection;
14677
- },
14678
- selectColumn: (colId, options) => {
14677
+ this.dataSourceActions.cellSelection = newCellSelection;
14678
+ };
14679
+ this.selectColumn = (colId, options) => {
14679
14680
  if (options == null ? void 0 : options.clear) {
14680
- cellSelectionApi.deselectAll();
14681
+ this.deselectAll();
14681
14682
  }
14682
- const cellSelection = getDataSourceState().cellSelection;
14683
+ const cellSelection = this.getDataSourceState().cellSelection;
14683
14684
  if (!cellSelection) {
14684
14685
  return;
14685
14686
  }
14686
14687
  const newCellSelection = new CellSelectionState(cellSelection);
14687
14688
  newCellSelection.selectColumn(colId);
14688
- dataSourceActions.cellSelection = newCellSelection;
14689
- },
14690
- deselectColumn: (colId) => {
14691
- const cellSelection = getDataSourceState().cellSelection;
14689
+ this.dataSourceActions.cellSelection = newCellSelection;
14690
+ };
14691
+ this.deselectColumn = (colId) => {
14692
+ const cellSelection = this.getDataSourceState().cellSelection;
14692
14693
  if (!cellSelection) {
14693
14694
  return;
14694
14695
  }
14695
14696
  const newCellSelection = new CellSelectionState(cellSelection);
14696
14697
  newCellSelection.deselectColumn(colId);
14697
- dataSourceActions.cellSelection = newCellSelection;
14698
- }
14699
- };
14698
+ this.dataSourceActions.cellSelection = newCellSelection;
14699
+ };
14700
+ this.getComputed = param.getComputed;
14701
+ this.getDataSourceState = param.getDataSourceState;
14702
+ this.dataSourceActions = param.dataSourceActions;
14703
+ }
14704
+ };
14705
+ function getCellSelectionApi(param) {
14706
+ const cellSelectionApi = new InfiniteTableCellSelectionApiImpl(param);
14700
14707
  if (false) {
14701
14708
  globalThis.cellSelectionApi = cellSelectionApi;
14702
14709
  }
@@ -17572,7 +17579,7 @@ var useLicense = (licenseKey = "") => {
17572
17579
  const valid = useMemo11(() => {
17573
17580
  let valid2 = isValidLicense(licenseKey, {
17574
17581
  publishedAt: 1624970570587,
17575
- version: "3.0.3"
17582
+ version: "3.0.5"
17576
17583
  });
17577
17584
  if (!licenseKey && !valid2 && isInsidePlayground) {
17578
17585
  return true;