@infinite-table/infinite-react 3.0.1 → 3.0.3

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
@@ -1391,6 +1391,10 @@ declare type InfiniteTableCellSelectionApi = {
1391
1391
  deselectColumn(colId: string): void;
1392
1392
  selectRange(start: CellPositionOptions, end: CellPositionOptions): void;
1393
1393
  deselectRange(start: CellPositionOptions, end: CellPositionOptions): void;
1394
+ getAllCellSelectionPositions(): {
1395
+ columnIds: string[];
1396
+ positions: (CellSelectionPosition | null)[][];
1397
+ };
1394
1398
  };
1395
1399
 
1396
1400
  declare type ArrayOfIds = Pick<InfiniteTable_RowInfoBase<any>, 'id'>[];
@@ -1517,7 +1521,7 @@ declare class DataSourceCache<DataType, PrimaryKeyType = string> {
1517
1521
  isEmpty: () => boolean;
1518
1522
  removeInfo: (primaryKey: PrimaryKeyType) => void;
1519
1523
  getMutationsForPrimaryKey: (primaryKey: PrimaryKeyType) => DataSourceMutation<DataType>[] | undefined;
1520
- getMutations: () => Map<string, DataSourceMutation<DataType>[]>;
1524
+ getMutations: () => Map<PrimaryKeyType, DataSourceMutation<DataType>[]>;
1521
1525
  }
1522
1526
 
1523
1527
  declare type BooleanDeepCollectionStateKeys<KeyType> = true | KeyType[][];
@@ -1568,13 +1572,13 @@ declare class GroupRowsState<KeyType extends any = any> extends BooleanDeepColle
1568
1572
  }
1569
1573
 
1570
1574
  declare class Indexer<DataType, PrimaryKeyType = string> {
1571
- primaryKeyToData: Map<string, DataType>;
1575
+ primaryKeyToData: Map<PrimaryKeyType, DataType>;
1572
1576
  private add;
1573
1577
  clear: () => void;
1574
- getDataForPrimaryKey: (primaryKey: PrimaryKeyType | string) => DataType | undefined;
1578
+ getDataForPrimaryKey: (primaryKey: PrimaryKeyType) => DataType | undefined;
1575
1579
  indexArray: (arr: DataType[], options: {
1576
1580
  toPrimaryKey: (data: DataType) => PrimaryKeyType;
1577
- cache?: DataSourceCache<DataType, string> | undefined;
1581
+ cache?: DataSourceCache<DataType, PrimaryKeyType> | undefined;
1578
1582
  }) => DataType[];
1579
1583
  }
1580
1584
 
package/index.dev.js CHANGED
@@ -11003,7 +11003,7 @@ var DataSourceCache = class {
11003
11003
  };
11004
11004
  this.delete = (primaryKey, originalData, metadata) => {
11005
11005
  this.allFieldsAffected = true;
11006
- const pk = `${primaryKey}`;
11006
+ const pk = primaryKey;
11007
11007
  const value = this.primaryKeyToData.get(pk) || [];
11008
11008
  value.push({
11009
11009
  type: "delete",
@@ -11014,7 +11014,7 @@ var DataSourceCache = class {
11014
11014
  this.primaryKeyToData.set(pk, value);
11015
11015
  };
11016
11016
  this.insert = (primaryKey, data, position2, metadata) => {
11017
- const pk = `${primaryKey}`;
11017
+ const pk = primaryKey;
11018
11018
  const value = this.primaryKeyToData.get(pk) || [];
11019
11019
  this.allFieldsAffected = true;
11020
11020
  value.push({
@@ -11032,7 +11032,7 @@ var DataSourceCache = class {
11032
11032
  const keys = Object.keys(data);
11033
11033
  keys.forEach((key) => this.affectedFields.add(key));
11034
11034
  }
11035
- const pk = `${primaryKey}`;
11035
+ const pk = primaryKey;
11036
11036
  const value = this.primaryKeyToData.get(pk) || [];
11037
11037
  value.push({
11038
11038
  type: "update",
@@ -11041,7 +11041,7 @@ var DataSourceCache = class {
11041
11041
  originalData,
11042
11042
  metadata
11043
11043
  });
11044
- this.primaryKeyToData.set(`${primaryKey}`, value);
11044
+ this.primaryKeyToData.set(primaryKey, value);
11045
11045
  };
11046
11046
  this.clear = () => {
11047
11047
  this.allFieldsAffected = false;
@@ -11052,10 +11052,10 @@ var DataSourceCache = class {
11052
11052
  return this.primaryKeyToData.size === 0;
11053
11053
  };
11054
11054
  this.removeInfo = (primaryKey) => {
11055
- this.primaryKeyToData.delete(`${primaryKey}`);
11055
+ this.primaryKeyToData.delete(primaryKey);
11056
11056
  };
11057
11057
  this.getMutationsForPrimaryKey = (primaryKey) => {
11058
- const data = this.primaryKeyToData.get(`${primaryKey}`);
11058
+ const data = this.primaryKeyToData.get(primaryKey);
11059
11059
  return data;
11060
11060
  };
11061
11061
  this.getMutations = () => {
@@ -11066,7 +11066,9 @@ var DataSourceCache = class {
11066
11066
  const clone = new DataSourceCache();
11067
11067
  clone.allFieldsAffected = cache.allFieldsAffected;
11068
11068
  clone.affectedFields = new Set(cache.affectedFields);
11069
- clone.primaryKeyToData = light ? cache.primaryKeyToData : new Map(cache.primaryKeyToData);
11069
+ clone.primaryKeyToData = light ? cache.primaryKeyToData : new Map(
11070
+ cache.primaryKeyToData
11071
+ );
11070
11072
  return clone;
11071
11073
  }
11072
11074
  };
@@ -13963,13 +13965,13 @@ var Indexer = class {
13963
13965
  constructor() {
13964
13966
  this.primaryKeyToData = /* @__PURE__ */ new Map();
13965
13967
  this.add = (primaryKey, data) => {
13966
- this.primaryKeyToData.set(`${primaryKey}`, data);
13968
+ this.primaryKeyToData.set(primaryKey, data);
13967
13969
  };
13968
13970
  this.clear = () => {
13969
13971
  this.primaryKeyToData.clear();
13970
13972
  };
13971
13973
  this.getDataForPrimaryKey = (primaryKey) => {
13972
- return this.primaryKeyToData.get(`${primaryKey}`);
13974
+ return this.primaryKeyToData.get(primaryKey);
13973
13975
  };
13974
13976
  this.indexArray = (arr, options) => {
13975
13977
  const { cache, toPrimaryKey } = options;
@@ -13980,7 +13982,7 @@ var Indexer = class {
13980
13982
  let item = arr[i];
13981
13983
  let deleted = false;
13982
13984
  if (item != null) {
13983
- const pk = `${toPrimaryKey(item)}`;
13985
+ const pk = toPrimaryKey(item);
13984
13986
  const cacheInfo = cache == null ? void 0 : cache.getMutationsForPrimaryKey(pk);
13985
13987
  if (cacheInfo && cacheInfo.length) {
13986
13988
  for (let cacheIndex = 0, cacheLength = cacheInfo.length; cacheIndex < cacheLength; cacheIndex++) {
@@ -13995,7 +13997,7 @@ var Indexer = class {
13995
13997
  arr[i] = item;
13996
13998
  }
13997
13999
  if (info.type === "insert") {
13998
- const insertPK = `${toPrimaryKey(info.data)}`;
14000
+ const insertPK = toPrimaryKey(info.data);
13999
14001
  this.add(insertPK, info.data);
14000
14002
  if (info.position === "before") {
14001
14003
  arr.splice(i, 0, info.data);
@@ -14517,6 +14519,15 @@ function notNullable(value) {
14517
14519
  }
14518
14520
 
14519
14521
  // src/components/InfiniteTable/api/getCellSelectionApi.ts
14522
+ function ensureSortedPerOrder(arr, sortPattern) {
14523
+ const arrSet = new Set(arr);
14524
+ return sortPattern.map((item) => {
14525
+ if (arrSet.has(item)) {
14526
+ return item;
14527
+ }
14528
+ return null;
14529
+ }).filter((x) => x != null);
14530
+ }
14520
14531
  function ensureMinMaxCellPositionByIndex(start, end) {
14521
14532
  let { rowIndex: startRowIndex, colIndex: startColIndex } = start;
14522
14533
  let { rowIndex: endRowIndex, colIndex: endColIndex } = end;
@@ -14542,6 +14553,46 @@ function getCellSelectionApi(param) {
14542
14553
  return [rowId, colId];
14543
14554
  };
14544
14555
  const cellSelectionApi = {
14556
+ getAllCellSelectionPositions: () => {
14557
+ const dataArray = getRowInfoArray(getDataSourceState);
14558
+ const { computedVisibleColumns } = getComputed();
14559
+ const computedVisibleColumnsIds = computedVisibleColumns.map((x) => x.id);
14560
+ const colsInSelection = /* @__PURE__ */ new Set();
14561
+ const rowsInSelection = [];
14562
+ const rowIdsInSelection = /* @__PURE__ */ new Set();
14563
+ dataArray.filter((rowInfo) => {
14564
+ computedVisibleColumns.forEach((col) => {
14565
+ if (cellSelectionApi.isCellSelected({
14566
+ rowId: rowInfo.id,
14567
+ colId: col.id
14568
+ })) {
14569
+ if (!colsInSelection.has(col.id)) {
14570
+ colsInSelection.add(col.id);
14571
+ }
14572
+ if (!rowIdsInSelection.has(rowInfo.id)) {
14573
+ rowIdsInSelection.add(rowInfo.id);
14574
+ rowsInSelection.push(rowInfo);
14575
+ }
14576
+ }
14577
+ });
14578
+ });
14579
+ const columnIds = ensureSortedPerOrder(
14580
+ Array.from(colsInSelection),
14581
+ computedVisibleColumnsIds
14582
+ );
14583
+ const positions = rowsInSelection.map((rowInfo) => {
14584
+ return columnIds.map((colId) => {
14585
+ if (cellSelectionApi.isCellSelected({ rowId: rowInfo.id, colId })) {
14586
+ return [rowInfo.id, colId];
14587
+ }
14588
+ return null;
14589
+ });
14590
+ });
14591
+ return {
14592
+ columnIds,
14593
+ positions
14594
+ };
14595
+ },
14545
14596
  deselectAll: () => {
14546
14597
  const dataSourceState = getDataSourceState();
14547
14598
  const cellSelection = dataSourceState.cellSelection;
@@ -17532,7 +17583,7 @@ var useLicense = (licenseKey = "") => {
17532
17583
  const valid = (0, import_react49.useMemo)(() => {
17533
17584
  let valid2 = isValidLicense(licenseKey, {
17534
17585
  publishedAt: 1624970570587,
17535
- version: "3.0.1"
17586
+ version: "3.0.3"
17536
17587
  });
17537
17588
  if (!licenseKey && !valid2 && isInsidePlayground) {
17538
17589
  return true;
package/index.dev.mjs CHANGED
@@ -10988,7 +10988,7 @@ var DataSourceCache = class {
10988
10988
  };
10989
10989
  this.delete = (primaryKey, originalData, metadata) => {
10990
10990
  this.allFieldsAffected = true;
10991
- const pk = `${primaryKey}`;
10991
+ const pk = primaryKey;
10992
10992
  const value = this.primaryKeyToData.get(pk) || [];
10993
10993
  value.push({
10994
10994
  type: "delete",
@@ -10999,7 +10999,7 @@ var DataSourceCache = class {
10999
10999
  this.primaryKeyToData.set(pk, value);
11000
11000
  };
11001
11001
  this.insert = (primaryKey, data, position2, metadata) => {
11002
- const pk = `${primaryKey}`;
11002
+ const pk = primaryKey;
11003
11003
  const value = this.primaryKeyToData.get(pk) || [];
11004
11004
  this.allFieldsAffected = true;
11005
11005
  value.push({
@@ -11017,7 +11017,7 @@ var DataSourceCache = class {
11017
11017
  const keys = Object.keys(data);
11018
11018
  keys.forEach((key) => this.affectedFields.add(key));
11019
11019
  }
11020
- const pk = `${primaryKey}`;
11020
+ const pk = primaryKey;
11021
11021
  const value = this.primaryKeyToData.get(pk) || [];
11022
11022
  value.push({
11023
11023
  type: "update",
@@ -11026,7 +11026,7 @@ var DataSourceCache = class {
11026
11026
  originalData,
11027
11027
  metadata
11028
11028
  });
11029
- this.primaryKeyToData.set(`${primaryKey}`, value);
11029
+ this.primaryKeyToData.set(primaryKey, value);
11030
11030
  };
11031
11031
  this.clear = () => {
11032
11032
  this.allFieldsAffected = false;
@@ -11037,10 +11037,10 @@ var DataSourceCache = class {
11037
11037
  return this.primaryKeyToData.size === 0;
11038
11038
  };
11039
11039
  this.removeInfo = (primaryKey) => {
11040
- this.primaryKeyToData.delete(`${primaryKey}`);
11040
+ this.primaryKeyToData.delete(primaryKey);
11041
11041
  };
11042
11042
  this.getMutationsForPrimaryKey = (primaryKey) => {
11043
- const data = this.primaryKeyToData.get(`${primaryKey}`);
11043
+ const data = this.primaryKeyToData.get(primaryKey);
11044
11044
  return data;
11045
11045
  };
11046
11046
  this.getMutations = () => {
@@ -11051,7 +11051,9 @@ var DataSourceCache = class {
11051
11051
  const clone = new DataSourceCache();
11052
11052
  clone.allFieldsAffected = cache.allFieldsAffected;
11053
11053
  clone.affectedFields = new Set(cache.affectedFields);
11054
- clone.primaryKeyToData = light ? cache.primaryKeyToData : new Map(cache.primaryKeyToData);
11054
+ clone.primaryKeyToData = light ? cache.primaryKeyToData : new Map(
11055
+ cache.primaryKeyToData
11056
+ );
11055
11057
  return clone;
11056
11058
  }
11057
11059
  };
@@ -13948,13 +13950,13 @@ var Indexer = class {
13948
13950
  constructor() {
13949
13951
  this.primaryKeyToData = /* @__PURE__ */ new Map();
13950
13952
  this.add = (primaryKey, data) => {
13951
- this.primaryKeyToData.set(`${primaryKey}`, data);
13953
+ this.primaryKeyToData.set(primaryKey, data);
13952
13954
  };
13953
13955
  this.clear = () => {
13954
13956
  this.primaryKeyToData.clear();
13955
13957
  };
13956
13958
  this.getDataForPrimaryKey = (primaryKey) => {
13957
- return this.primaryKeyToData.get(`${primaryKey}`);
13959
+ return this.primaryKeyToData.get(primaryKey);
13958
13960
  };
13959
13961
  this.indexArray = (arr, options) => {
13960
13962
  const { cache, toPrimaryKey } = options;
@@ -13965,7 +13967,7 @@ var Indexer = class {
13965
13967
  let item = arr[i];
13966
13968
  let deleted = false;
13967
13969
  if (item != null) {
13968
- const pk = `${toPrimaryKey(item)}`;
13970
+ const pk = toPrimaryKey(item);
13969
13971
  const cacheInfo = cache == null ? void 0 : cache.getMutationsForPrimaryKey(pk);
13970
13972
  if (cacheInfo && cacheInfo.length) {
13971
13973
  for (let cacheIndex = 0, cacheLength = cacheInfo.length; cacheIndex < cacheLength; cacheIndex++) {
@@ -13980,7 +13982,7 @@ var Indexer = class {
13980
13982
  arr[i] = item;
13981
13983
  }
13982
13984
  if (info.type === "insert") {
13983
- const insertPK = `${toPrimaryKey(info.data)}`;
13985
+ const insertPK = toPrimaryKey(info.data);
13984
13986
  this.add(insertPK, info.data);
13985
13987
  if (info.position === "before") {
13986
13988
  arr.splice(i, 0, info.data);
@@ -14502,6 +14504,15 @@ function notNullable(value) {
14502
14504
  }
14503
14505
 
14504
14506
  // src/components/InfiniteTable/api/getCellSelectionApi.ts
14507
+ function ensureSortedPerOrder(arr, sortPattern) {
14508
+ const arrSet = new Set(arr);
14509
+ return sortPattern.map((item) => {
14510
+ if (arrSet.has(item)) {
14511
+ return item;
14512
+ }
14513
+ return null;
14514
+ }).filter((x) => x != null);
14515
+ }
14505
14516
  function ensureMinMaxCellPositionByIndex(start, end) {
14506
14517
  let { rowIndex: startRowIndex, colIndex: startColIndex } = start;
14507
14518
  let { rowIndex: endRowIndex, colIndex: endColIndex } = end;
@@ -14527,6 +14538,46 @@ function getCellSelectionApi(param) {
14527
14538
  return [rowId, colId];
14528
14539
  };
14529
14540
  const cellSelectionApi = {
14541
+ getAllCellSelectionPositions: () => {
14542
+ const dataArray = getRowInfoArray(getDataSourceState);
14543
+ const { computedVisibleColumns } = getComputed();
14544
+ const computedVisibleColumnsIds = computedVisibleColumns.map((x) => x.id);
14545
+ const colsInSelection = /* @__PURE__ */ new Set();
14546
+ const rowsInSelection = [];
14547
+ const rowIdsInSelection = /* @__PURE__ */ new Set();
14548
+ dataArray.filter((rowInfo) => {
14549
+ computedVisibleColumns.forEach((col) => {
14550
+ if (cellSelectionApi.isCellSelected({
14551
+ rowId: rowInfo.id,
14552
+ colId: col.id
14553
+ })) {
14554
+ if (!colsInSelection.has(col.id)) {
14555
+ colsInSelection.add(col.id);
14556
+ }
14557
+ if (!rowIdsInSelection.has(rowInfo.id)) {
14558
+ rowIdsInSelection.add(rowInfo.id);
14559
+ rowsInSelection.push(rowInfo);
14560
+ }
14561
+ }
14562
+ });
14563
+ });
14564
+ const columnIds = ensureSortedPerOrder(
14565
+ Array.from(colsInSelection),
14566
+ computedVisibleColumnsIds
14567
+ );
14568
+ const positions = rowsInSelection.map((rowInfo) => {
14569
+ return columnIds.map((colId) => {
14570
+ if (cellSelectionApi.isCellSelected({ rowId: rowInfo.id, colId })) {
14571
+ return [rowInfo.id, colId];
14572
+ }
14573
+ return null;
14574
+ });
14575
+ });
14576
+ return {
14577
+ columnIds,
14578
+ positions
14579
+ };
14580
+ },
14530
14581
  deselectAll: () => {
14531
14582
  const dataSourceState = getDataSourceState();
14532
14583
  const cellSelection = dataSourceState.cellSelection;
@@ -17521,7 +17572,7 @@ var useLicense = (licenseKey = "") => {
17521
17572
  const valid = useMemo11(() => {
17522
17573
  let valid2 = isValidLicense(licenseKey, {
17523
17574
  publishedAt: 1624970570587,
17524
- version: "3.0.1"
17575
+ version: "3.0.3"
17525
17576
  });
17526
17577
  if (!licenseKey && !valid2 && isInsidePlayground) {
17527
17578
  return true;