@infinite-table/infinite-react 3.0.0 → 3.0.2

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/README.md CHANGED
@@ -24,6 +24,7 @@
24
24
  - [❤️ TypeScript](#-typescript)
25
25
  - [🏢 Enterprise-ready](#-enterprise-ready)
26
26
  - [🔒 Secure by default](#-secure-by-default)
27
+ - [🚫 No dependencies](#-no-dependencies)
27
28
  - [📦 Small bundle size](#-small-bundle-size)
28
29
  - [🧪 Automated end-to-end tests](#-automated-end-to-end-tests)
29
30
  - [🎨 Themable](#-themable)
@@ -83,17 +84,21 @@ It's fully typed and offers you great developer experience to help you get up an
83
84
 
84
85
  ## 🏢 Enterprise-ready
85
86
 
86
- Infinite Table is ready to power your enterprise apps, as it supports advanced [data fetching](https://infinite-table.com/docs/learn/working-with-data#data-loading-strategies), [filtering](https://infinite-table.com/docs/learn/filtering), [sorting](https://infinite-table.com/docs/learn/sorting/overview), [grouping](https://infinite-table.com/docs/learn/grouping-and-pivoting/grouping-rows), [pivoting](https://infinite-table.com/docs/learn/grouping-and-pivoting/pivoting/overview), [aggregations](https://infinite-table.com/docs/learn/grouping-and-pivoting/group-aggregations), [live pagination](https://infinite-table.com/docs/learn/working-with-data/live-pagination), [lazy loading](https://infinite-table.com/docs/learn/working-with-data/lazy-loading) - all of those with support for both client-side and server-side implementations.
87
+ Infinite Table is ready to power your enterprise apps, as it supports advanced [data fetching](https://infinite-table.com/docs/learn/working-with-data#data-loading-strategies), [filtering](https://infinite-table.com/docs/learn/filtering), [sorting](https://infinite-table.com/docs/learn/sorting/overview), [grouping](https://infinite-table.com/docs/learn/grouping-and-pivoting/grouping-rows), [pivoting](https://infinite-table.com/docs/learn/grouping-and-pivoting/pivoting/overview), [aggregations](https://infinite-table.com/docs/learn/grouping-and-pivoting/group-aggregations), [https://infinite-table.com/docs/learn/selection/row-selection](row & cell selection), [live pagination](https://infinite-table.com/docs/learn/working-with-data/live-pagination), [lazy loading](https://infinite-table.com/docs/learn/working-with-data/lazy-loading) - all of those with support for both client-side and server-side implementations.
87
88
 
88
89
  You can choose to leverage our built-in implementations in the browser or you can process your data on the server with full support from our-side.
89
90
 
90
91
  ### 🔒 Secure by default
91
92
 
92
- We take security seriously and only have a total of 3 dependencies in our full dependency graph - and this number will only go down.
93
+ We take security seriously and we're not installing any dependencies. No extra fluff to slow down your code or make installs less secure.
94
+
95
+ ### 🚫 No dependencies
96
+
97
+ We don't depend on any external package, so you can be sure that you're not introducing any security vulnerabilities in your app.
93
98
 
94
99
  ### 📦 Small bundle size
95
100
 
96
- Our bundle size is under `250kB` and we're [keeping it small](https://bundlephobia.com/package/@infinite-table/infinite-react).
101
+ Our bundle size is under `300kB` and we're [keeping it small](https://bundlephobia.com/package/@infinite-table/infinite-react).
97
102
 
98
103
  ### 🧪 Automated end-to-end tests
99
104
 
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,8 +1385,16 @@ 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;
1394
+ getAllCellSelectionPositions(): {
1395
+ columnIds: string[];
1396
+ positions: (CellSelectionPosition | null)[][];
1397
+ };
1388
1398
  };
1389
1399
 
1390
1400
  declare type ArrayOfIds = Pick<InfiniteTable_RowInfoBase<any>, 'id'>[];
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);
@@ -14459,6 +14517,15 @@ function notNullable(value) {
14459
14517
  }
14460
14518
 
14461
14519
  // src/components/InfiniteTable/api/getCellSelectionApi.ts
14520
+ function ensureSortedPerOrder(arr, sortPattern) {
14521
+ const arrSet = new Set(arr);
14522
+ return sortPattern.map((item) => {
14523
+ if (arrSet.has(item)) {
14524
+ return item;
14525
+ }
14526
+ return null;
14527
+ }).filter((x) => x != null);
14528
+ }
14462
14529
  function ensureMinMaxCellPositionByIndex(start, end) {
14463
14530
  let { rowIndex: startRowIndex, colIndex: startColIndex } = start;
14464
14531
  let { rowIndex: endRowIndex, colIndex: endColIndex } = end;
@@ -14484,6 +14551,46 @@ function getCellSelectionApi(param) {
14484
14551
  return [rowId, colId];
14485
14552
  };
14486
14553
  const cellSelectionApi = {
14554
+ getAllCellSelectionPositions: () => {
14555
+ const dataArray = getRowInfoArray(getDataSourceState);
14556
+ const { computedVisibleColumns } = getComputed();
14557
+ const computedVisibleColumnsIds = computedVisibleColumns.map((x) => x.id);
14558
+ const colsInSelection = /* @__PURE__ */ new Set();
14559
+ const rowsInSelection = [];
14560
+ const rowIdsInSelection = /* @__PURE__ */ new Set();
14561
+ dataArray.filter((rowInfo) => {
14562
+ computedVisibleColumns.forEach((col) => {
14563
+ if (cellSelectionApi.isCellSelected({
14564
+ rowId: rowInfo.id,
14565
+ colId: col.id
14566
+ })) {
14567
+ if (!colsInSelection.has(col.id)) {
14568
+ colsInSelection.add(col.id);
14569
+ }
14570
+ if (!rowIdsInSelection.has(rowInfo.id)) {
14571
+ rowIdsInSelection.add(rowInfo.id);
14572
+ rowsInSelection.push(rowInfo);
14573
+ }
14574
+ }
14575
+ });
14576
+ });
14577
+ const columnIds = ensureSortedPerOrder(
14578
+ Array.from(colsInSelection),
14579
+ computedVisibleColumnsIds
14580
+ );
14581
+ const positions = rowsInSelection.map((rowInfo) => {
14582
+ return columnIds.map((colId) => {
14583
+ if (cellSelectionApi.isCellSelected({ rowId: rowInfo.id, colId })) {
14584
+ return [rowInfo.id, colId];
14585
+ }
14586
+ return null;
14587
+ });
14588
+ });
14589
+ return {
14590
+ columnIds,
14591
+ positions
14592
+ };
14593
+ },
14487
14594
  deselectAll: () => {
14488
14595
  const dataSourceState = getDataSourceState();
14489
14596
  const cellSelection = dataSourceState.cellSelection;
@@ -14580,6 +14687,27 @@ function getCellSelectionApi(param) {
14580
14687
  const newCellSelection = new CellSelectionState(cellSelection);
14581
14688
  newCellSelection.deselectCell(pk, colId);
14582
14689
  dataSourceActions.cellSelection = newCellSelection;
14690
+ },
14691
+ selectColumn: (colId, options) => {
14692
+ if (options == null ? void 0 : options.clear) {
14693
+ cellSelectionApi.deselectAll();
14694
+ }
14695
+ const cellSelection = getDataSourceState().cellSelection;
14696
+ if (!cellSelection) {
14697
+ return;
14698
+ }
14699
+ const newCellSelection = new CellSelectionState(cellSelection);
14700
+ newCellSelection.selectColumn(colId);
14701
+ dataSourceActions.cellSelection = newCellSelection;
14702
+ },
14703
+ deselectColumn: (colId) => {
14704
+ const cellSelection = getDataSourceState().cellSelection;
14705
+ if (!cellSelection) {
14706
+ return;
14707
+ }
14708
+ const newCellSelection = new CellSelectionState(cellSelection);
14709
+ newCellSelection.deselectColumn(colId);
14710
+ dataSourceActions.cellSelection = newCellSelection;
14583
14711
  }
14584
14712
  };
14585
14713
  if (false) {
@@ -17453,7 +17581,7 @@ var useLicense = (licenseKey = "") => {
17453
17581
  const valid = (0, import_react49.useMemo)(() => {
17454
17582
  let valid2 = isValidLicense(licenseKey, {
17455
17583
  publishedAt: 1624970570587,
17456
- version: "3.0.0"
17584
+ version: "3.0.2"
17457
17585
  });
17458
17586
  if (!licenseKey && !valid2 && isInsidePlayground) {
17459
17587
  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);
@@ -14444,6 +14502,15 @@ function notNullable(value) {
14444
14502
  }
14445
14503
 
14446
14504
  // src/components/InfiniteTable/api/getCellSelectionApi.ts
14505
+ function ensureSortedPerOrder(arr, sortPattern) {
14506
+ const arrSet = new Set(arr);
14507
+ return sortPattern.map((item) => {
14508
+ if (arrSet.has(item)) {
14509
+ return item;
14510
+ }
14511
+ return null;
14512
+ }).filter((x) => x != null);
14513
+ }
14447
14514
  function ensureMinMaxCellPositionByIndex(start, end) {
14448
14515
  let { rowIndex: startRowIndex, colIndex: startColIndex } = start;
14449
14516
  let { rowIndex: endRowIndex, colIndex: endColIndex } = end;
@@ -14469,6 +14536,46 @@ function getCellSelectionApi(param) {
14469
14536
  return [rowId, colId];
14470
14537
  };
14471
14538
  const cellSelectionApi = {
14539
+ getAllCellSelectionPositions: () => {
14540
+ const dataArray = getRowInfoArray(getDataSourceState);
14541
+ const { computedVisibleColumns } = getComputed();
14542
+ const computedVisibleColumnsIds = computedVisibleColumns.map((x) => x.id);
14543
+ const colsInSelection = /* @__PURE__ */ new Set();
14544
+ const rowsInSelection = [];
14545
+ const rowIdsInSelection = /* @__PURE__ */ new Set();
14546
+ dataArray.filter((rowInfo) => {
14547
+ computedVisibleColumns.forEach((col) => {
14548
+ if (cellSelectionApi.isCellSelected({
14549
+ rowId: rowInfo.id,
14550
+ colId: col.id
14551
+ })) {
14552
+ if (!colsInSelection.has(col.id)) {
14553
+ colsInSelection.add(col.id);
14554
+ }
14555
+ if (!rowIdsInSelection.has(rowInfo.id)) {
14556
+ rowIdsInSelection.add(rowInfo.id);
14557
+ rowsInSelection.push(rowInfo);
14558
+ }
14559
+ }
14560
+ });
14561
+ });
14562
+ const columnIds = ensureSortedPerOrder(
14563
+ Array.from(colsInSelection),
14564
+ computedVisibleColumnsIds
14565
+ );
14566
+ const positions = rowsInSelection.map((rowInfo) => {
14567
+ return columnIds.map((colId) => {
14568
+ if (cellSelectionApi.isCellSelected({ rowId: rowInfo.id, colId })) {
14569
+ return [rowInfo.id, colId];
14570
+ }
14571
+ return null;
14572
+ });
14573
+ });
14574
+ return {
14575
+ columnIds,
14576
+ positions
14577
+ };
14578
+ },
14472
14579
  deselectAll: () => {
14473
14580
  const dataSourceState = getDataSourceState();
14474
14581
  const cellSelection = dataSourceState.cellSelection;
@@ -14565,6 +14672,27 @@ function getCellSelectionApi(param) {
14565
14672
  const newCellSelection = new CellSelectionState(cellSelection);
14566
14673
  newCellSelection.deselectCell(pk, colId);
14567
14674
  dataSourceActions.cellSelection = newCellSelection;
14675
+ },
14676
+ selectColumn: (colId, options) => {
14677
+ if (options == null ? void 0 : options.clear) {
14678
+ cellSelectionApi.deselectAll();
14679
+ }
14680
+ const cellSelection = getDataSourceState().cellSelection;
14681
+ if (!cellSelection) {
14682
+ return;
14683
+ }
14684
+ const newCellSelection = new CellSelectionState(cellSelection);
14685
+ newCellSelection.selectColumn(colId);
14686
+ dataSourceActions.cellSelection = newCellSelection;
14687
+ },
14688
+ deselectColumn: (colId) => {
14689
+ const cellSelection = getDataSourceState().cellSelection;
14690
+ if (!cellSelection) {
14691
+ return;
14692
+ }
14693
+ const newCellSelection = new CellSelectionState(cellSelection);
14694
+ newCellSelection.deselectColumn(colId);
14695
+ dataSourceActions.cellSelection = newCellSelection;
14568
14696
  }
14569
14697
  };
14570
14698
  if (false) {
@@ -17442,7 +17570,7 @@ var useLicense = (licenseKey = "") => {
17442
17570
  const valid = useMemo11(() => {
17443
17571
  let valid2 = isValidLicense(licenseKey, {
17444
17572
  publishedAt: 1624970570587,
17445
- version: "3.0.0"
17573
+ version: "3.0.2"
17446
17574
  });
17447
17575
  if (!licenseKey && !valid2 && isInsidePlayground) {
17448
17576
  return true;