@infinite-table/infinite-react 3.0.0 → 3.0.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.d.ts CHANGED
@@ -811,6 +811,8 @@ declare class CellSelectionState {
811
811
  selectAll: () => void;
812
812
  selectCell(rowId: any, colId: string): void;
813
813
  deselectCell(rowId: any, colId: string): void;
814
+ selectColumn(colId: string): void;
815
+ deselectColumn(colId: string): void;
814
816
  setCellSelected(rowId: any, colId: string, selected: boolean): void;
815
817
  private setCellInDeselection;
816
818
  private setCellInSelection;
@@ -1383,6 +1385,10 @@ declare type InfiniteTableCellSelectionApi = {
1383
1385
  deselectAll(): void;
1384
1386
  clear(): void;
1385
1387
  selectAll(): void;
1388
+ selectColumn(colId: string, options?: {
1389
+ clear?: boolean;
1390
+ }): void;
1391
+ deselectColumn(colId: string): void;
1386
1392
  selectRange(start: CellPositionOptions, end: CellPositionOptions): void;
1387
1393
  deselectRange(start: CellPositionOptions, end: CellPositionOptions): void;
1388
1394
  };
package/index.dev.js CHANGED
@@ -12156,15 +12156,68 @@ var CellSelectionState = class {
12156
12156
  deselectCell(rowId, colId) {
12157
12157
  this.setCellSelected(rowId, colId, false);
12158
12158
  }
12159
+ selectColumn(colId) {
12160
+ this.setCellSelected(this.wildcard, colId, true);
12161
+ }
12162
+ deselectColumn(colId) {
12163
+ this.setCellSelected(this.wildcard, colId, false);
12164
+ }
12159
12165
  setCellSelected(rowId, colId, selected) {
12160
- if (rowId === this.wildcard || colId === this.wildcard) {
12161
- throw "Please dont use this private method to select cells with wildcard";
12162
- }
12166
+ const wildcardRow = rowId === this.wildcard;
12167
+ const wildcardColumn = colId === this.wildcard;
12163
12168
  const isSelected = this.isCellSelected(rowId, colId);
12164
12169
  if (isSelected === selected) {
12165
12170
  return;
12166
12171
  }
12172
+ const clearKeys = [];
12173
+ if (wildcardRow) {
12174
+ const deselectedRowsForColumn = this.deselectedColumnsToRows.get(colId);
12175
+ const selectedRowsForColumn = this.selectedColumnsToRows.get(colId);
12176
+ deselectedRowsForColumn == null ? void 0 : deselectedRowsForColumn.forEach((rowId2) => {
12177
+ if (rowId2 === this.wildcard) {
12178
+ return;
12179
+ }
12180
+ this.setCellInDeselection(rowId2, colId, false);
12181
+ });
12182
+ selectedRowsForColumn == null ? void 0 : selectedRowsForColumn.forEach((rowId2) => {
12183
+ if (rowId2 === this.wildcard) {
12184
+ return;
12185
+ }
12186
+ this.setCellInSelection(rowId2, colId, false);
12187
+ });
12188
+ [...this.cache.keys()].forEach((key) => {
12189
+ const [rowId2, c] = key;
12190
+ if (c === colId) {
12191
+ clearKeys.push([rowId2, colId]);
12192
+ }
12193
+ });
12194
+ }
12195
+ if (wildcardColumn) {
12196
+ const deselectedColumnsForRow = this.deselectedRowsToColumns.get(colId);
12197
+ const selectedColumnsForRow = this.selectedRowsToColumns.get(colId);
12198
+ deselectedColumnsForRow == null ? void 0 : deselectedColumnsForRow.forEach((colId2) => {
12199
+ if (colId2 === this.wildcard) {
12200
+ return;
12201
+ }
12202
+ this.setCellInDeselection(rowId, colId2, false);
12203
+ });
12204
+ selectedColumnsForRow == null ? void 0 : selectedColumnsForRow.forEach((colId2) => {
12205
+ if (colId2 === this.wildcard) {
12206
+ return;
12207
+ }
12208
+ this.setCellInSelection(rowId, colId2, false);
12209
+ });
12210
+ [...this.cache.keys()].forEach((key) => {
12211
+ const [row] = key;
12212
+ if (row === rowId) {
12213
+ clearKeys.push([rowId, colId]);
12214
+ }
12215
+ });
12216
+ }
12167
12217
  const cacheKey = [rowId, colId];
12218
+ clearKeys.forEach((key) => {
12219
+ this.cache.delete(key);
12220
+ });
12168
12221
  this.cache.delete(cacheKey);
12169
12222
  if (selected) {
12170
12223
  if (this.defaultSelection) {
@@ -12238,6 +12291,11 @@ var CellSelectionState = class {
12238
12291
  }
12239
12292
  }
12240
12293
  setCellInSelection(rowId, colId, selected) {
12294
+ if (rowId === this.wildcard && colId === this.wildcard) {
12295
+ throw new Error(
12296
+ "rowId and colId cannot be used as a wildcard at the same time!"
12297
+ );
12298
+ }
12241
12299
  if (selected) {
12242
12300
  const selectedColsForRow = this.selectedRowsToColumns.get(rowId) || /* @__PURE__ */ new Set();
12243
12301
  selectedColsForRow.add(colId);
@@ -14580,6 +14638,27 @@ function getCellSelectionApi(param) {
14580
14638
  const newCellSelection = new CellSelectionState(cellSelection);
14581
14639
  newCellSelection.deselectCell(pk, colId);
14582
14640
  dataSourceActions.cellSelection = newCellSelection;
14641
+ },
14642
+ selectColumn: (colId, options) => {
14643
+ if (options == null ? void 0 : options.clear) {
14644
+ cellSelectionApi.deselectAll();
14645
+ }
14646
+ const cellSelection = getDataSourceState().cellSelection;
14647
+ if (!cellSelection) {
14648
+ return;
14649
+ }
14650
+ const newCellSelection = new CellSelectionState(cellSelection);
14651
+ newCellSelection.selectColumn(colId);
14652
+ dataSourceActions.cellSelection = newCellSelection;
14653
+ },
14654
+ deselectColumn: (colId) => {
14655
+ const cellSelection = getDataSourceState().cellSelection;
14656
+ if (!cellSelection) {
14657
+ return;
14658
+ }
14659
+ const newCellSelection = new CellSelectionState(cellSelection);
14660
+ newCellSelection.deselectColumn(colId);
14661
+ dataSourceActions.cellSelection = newCellSelection;
14583
14662
  }
14584
14663
  };
14585
14664
  if (false) {
@@ -17453,7 +17532,7 @@ var useLicense = (licenseKey = "") => {
17453
17532
  const valid = (0, import_react49.useMemo)(() => {
17454
17533
  let valid2 = isValidLicense(licenseKey, {
17455
17534
  publishedAt: 1624970570587,
17456
- version: "3.0.0"
17535
+ version: "3.0.1"
17457
17536
  });
17458
17537
  if (!licenseKey && !valid2 && isInsidePlayground) {
17459
17538
  return true;
package/index.dev.mjs CHANGED
@@ -12141,15 +12141,68 @@ var CellSelectionState = class {
12141
12141
  deselectCell(rowId, colId) {
12142
12142
  this.setCellSelected(rowId, colId, false);
12143
12143
  }
12144
+ selectColumn(colId) {
12145
+ this.setCellSelected(this.wildcard, colId, true);
12146
+ }
12147
+ deselectColumn(colId) {
12148
+ this.setCellSelected(this.wildcard, colId, false);
12149
+ }
12144
12150
  setCellSelected(rowId, colId, selected) {
12145
- if (rowId === this.wildcard || colId === this.wildcard) {
12146
- throw "Please dont use this private method to select cells with wildcard";
12147
- }
12151
+ const wildcardRow = rowId === this.wildcard;
12152
+ const wildcardColumn = colId === this.wildcard;
12148
12153
  const isSelected = this.isCellSelected(rowId, colId);
12149
12154
  if (isSelected === selected) {
12150
12155
  return;
12151
12156
  }
12157
+ const clearKeys = [];
12158
+ if (wildcardRow) {
12159
+ const deselectedRowsForColumn = this.deselectedColumnsToRows.get(colId);
12160
+ const selectedRowsForColumn = this.selectedColumnsToRows.get(colId);
12161
+ deselectedRowsForColumn == null ? void 0 : deselectedRowsForColumn.forEach((rowId2) => {
12162
+ if (rowId2 === this.wildcard) {
12163
+ return;
12164
+ }
12165
+ this.setCellInDeselection(rowId2, colId, false);
12166
+ });
12167
+ selectedRowsForColumn == null ? void 0 : selectedRowsForColumn.forEach((rowId2) => {
12168
+ if (rowId2 === this.wildcard) {
12169
+ return;
12170
+ }
12171
+ this.setCellInSelection(rowId2, colId, false);
12172
+ });
12173
+ [...this.cache.keys()].forEach((key) => {
12174
+ const [rowId2, c] = key;
12175
+ if (c === colId) {
12176
+ clearKeys.push([rowId2, colId]);
12177
+ }
12178
+ });
12179
+ }
12180
+ if (wildcardColumn) {
12181
+ const deselectedColumnsForRow = this.deselectedRowsToColumns.get(colId);
12182
+ const selectedColumnsForRow = this.selectedRowsToColumns.get(colId);
12183
+ deselectedColumnsForRow == null ? void 0 : deselectedColumnsForRow.forEach((colId2) => {
12184
+ if (colId2 === this.wildcard) {
12185
+ return;
12186
+ }
12187
+ this.setCellInDeselection(rowId, colId2, false);
12188
+ });
12189
+ selectedColumnsForRow == null ? void 0 : selectedColumnsForRow.forEach((colId2) => {
12190
+ if (colId2 === this.wildcard) {
12191
+ return;
12192
+ }
12193
+ this.setCellInSelection(rowId, colId2, false);
12194
+ });
12195
+ [...this.cache.keys()].forEach((key) => {
12196
+ const [row] = key;
12197
+ if (row === rowId) {
12198
+ clearKeys.push([rowId, colId]);
12199
+ }
12200
+ });
12201
+ }
12152
12202
  const cacheKey = [rowId, colId];
12203
+ clearKeys.forEach((key) => {
12204
+ this.cache.delete(key);
12205
+ });
12153
12206
  this.cache.delete(cacheKey);
12154
12207
  if (selected) {
12155
12208
  if (this.defaultSelection) {
@@ -12223,6 +12276,11 @@ var CellSelectionState = class {
12223
12276
  }
12224
12277
  }
12225
12278
  setCellInSelection(rowId, colId, selected) {
12279
+ if (rowId === this.wildcard && colId === this.wildcard) {
12280
+ throw new Error(
12281
+ "rowId and colId cannot be used as a wildcard at the same time!"
12282
+ );
12283
+ }
12226
12284
  if (selected) {
12227
12285
  const selectedColsForRow = this.selectedRowsToColumns.get(rowId) || /* @__PURE__ */ new Set();
12228
12286
  selectedColsForRow.add(colId);
@@ -14565,6 +14623,27 @@ function getCellSelectionApi(param) {
14565
14623
  const newCellSelection = new CellSelectionState(cellSelection);
14566
14624
  newCellSelection.deselectCell(pk, colId);
14567
14625
  dataSourceActions.cellSelection = newCellSelection;
14626
+ },
14627
+ selectColumn: (colId, options) => {
14628
+ if (options == null ? void 0 : options.clear) {
14629
+ cellSelectionApi.deselectAll();
14630
+ }
14631
+ const cellSelection = getDataSourceState().cellSelection;
14632
+ if (!cellSelection) {
14633
+ return;
14634
+ }
14635
+ const newCellSelection = new CellSelectionState(cellSelection);
14636
+ newCellSelection.selectColumn(colId);
14637
+ dataSourceActions.cellSelection = newCellSelection;
14638
+ },
14639
+ deselectColumn: (colId) => {
14640
+ const cellSelection = getDataSourceState().cellSelection;
14641
+ if (!cellSelection) {
14642
+ return;
14643
+ }
14644
+ const newCellSelection = new CellSelectionState(cellSelection);
14645
+ newCellSelection.deselectColumn(colId);
14646
+ dataSourceActions.cellSelection = newCellSelection;
14568
14647
  }
14569
14648
  };
14570
14649
  if (false) {
@@ -17442,7 +17521,7 @@ var useLicense = (licenseKey = "") => {
17442
17521
  const valid = useMemo11(() => {
17443
17522
  let valid2 = isValidLicense(licenseKey, {
17444
17523
  publishedAt: 1624970570587,
17445
- version: "3.0.0"
17524
+ version: "3.0.1"
17446
17525
  });
17447
17526
  if (!licenseKey && !valid2 && isInsidePlayground) {
17448
17527
  return true;