@infinite-table/infinite-react 6.0.12 → 6.0.13

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
@@ -2300,6 +2300,13 @@ declare class GroupRowsState<KeyType extends any = any> extends BooleanDeepColle
2300
2300
  toggleGroupRow(keys: KeyType[]): void;
2301
2301
  }
2302
2302
 
2303
+ declare type IndexerOptions<DataType, PrimaryKeyType> = {
2304
+ toPrimaryKey: (data: DataType) => PrimaryKeyType;
2305
+ cache?: DataSourceCache<DataType, PrimaryKeyType>;
2306
+ getNodeChildren?: TreeParams<DataType, PrimaryKeyType>['getNodeChildren'];
2307
+ isLeafNode?: TreeParams<DataType, PrimaryKeyType>['isLeafNode'];
2308
+ nodesKey: string | undefined;
2309
+ };
2303
2310
  declare class Indexer<DataType, PrimaryKeyType = string> {
2304
2311
  primaryKeyToData: Map<PrimaryKeyType, DataType>;
2305
2312
  nodePathsToData: DeepMap<PrimaryKeyType, DataType>;
@@ -2308,13 +2315,7 @@ declare class Indexer<DataType, PrimaryKeyType = string> {
2308
2315
  clear: () => void;
2309
2316
  getDataForPrimaryKey: (primaryKey: PrimaryKeyType) => DataType | undefined;
2310
2317
  getDataForNodePath: (nodePath: NodePath$1<any>) => DataType | undefined;
2311
- indexArray: (arr: DataType[], options: {
2312
- toPrimaryKey: (data: DataType) => PrimaryKeyType;
2313
- cache?: DataSourceCache<DataType, PrimaryKeyType> | undefined;
2314
- getNodeChildren?: ((item: DataType) => DataType[] | null) | undefined;
2315
- isLeafNode?: ((item: DataType) => boolean) | undefined;
2316
- nodesKey: string | undefined;
2317
- }) => DataType[];
2318
+ indexArray: (arr: DataType[], options: IndexerOptions<DataType, PrimaryKeyType>) => DataType[];
2318
2319
  }
2319
2320
 
2320
2321
  declare class RowDisabledState<KeyType = any> extends BooleanCollectionState<RowDisabledStateObject<KeyType>, KeyType> {
@@ -6023,6 +6024,12 @@ declare type PivotBy<DataType, KeyType> = Omit<GroupBy<DataType, KeyType>, 'colu
6023
6024
  columnGroup: InfiniteTablePivotFinalColumnGroup<DataType, KeyType>;
6024
6025
  }) => ColumnTypeWithInherit<Partial<InfiniteTablePivotFinalColumnGroup<DataType>>>);
6025
6026
  };
6027
+ declare type TreeParams<DataType, _KeyType> = {
6028
+ isLeafNode: (item: DataType) => boolean;
6029
+ getNodeChildren: (item: DataType) => null | DataType[];
6030
+ toKey: (item: DataType) => any;
6031
+ reducers?: Record<string, DataSourceAggregationReducer<DataType, any>>;
6032
+ };
6026
6033
  declare type GroupParams<DataType, KeyType> = {
6027
6034
  groupBy: GroupBy<DataType, KeyType>[];
6028
6035
  defaultToKey?: (value: any, item: DataType) => GroupKeyType<KeyType>;
package/index.dev.js CHANGED
@@ -13858,9 +13858,20 @@ var Indexer = class {
13858
13858
  this.add = (primaryKey, data) => {
13859
13859
  this.primaryKeyToData.set(primaryKey, data);
13860
13860
  };
13861
- this.addNodePath = (nodePath, data) => {
13861
+ this.addNodePath = (nodePath, data, options) => {
13862
13862
  this.nodePathsToData.set(nodePath, data);
13863
13863
  this.add(nodePath[nodePath.length - 1], data);
13864
+ const children = options.getNodeChildren ? options.getNodeChildren(data) : options.nodesKey ? (
13865
+ //@ts-ignore
13866
+ data[options.nodesKey]
13867
+ ) : null;
13868
+ if (children && Array.isArray(children)) {
13869
+ for (let i = 0, len = children.length; i < len; i++) {
13870
+ const child = children[i];
13871
+ const childPath = [...nodePath, options.toPrimaryKey(child)];
13872
+ this.addNodePath(childPath, child, options);
13873
+ }
13874
+ }
13864
13875
  };
13865
13876
  this.clear = () => {
13866
13877
  this.primaryKeyToData.clear();
@@ -13894,7 +13905,7 @@ var Indexer = class {
13894
13905
  if (info.type === "insert") {
13895
13906
  const insertPK = toPrimaryKey(info.data);
13896
13907
  if (isTree) {
13897
- this.addNodePath([insertPK], info.data);
13908
+ this.addNodePath([insertPK], info.data, options);
13898
13909
  } else {
13899
13910
  this.add(insertPK, info.data);
13900
13911
  }
@@ -13937,7 +13948,7 @@ var Indexer = class {
13937
13948
  const insertPK = toPrimaryKey(info.data);
13938
13949
  if (isTreeModeForNode) {
13939
13950
  const currentPath = [...parentPath, insertPK];
13940
- this.addNodePath(currentPath, info.data);
13951
+ this.addNodePath(currentPath, info.data, options);
13941
13952
  } else {
13942
13953
  this.add(insertPK, info.data);
13943
13954
  }
@@ -13967,7 +13978,7 @@ var Indexer = class {
13967
13978
  indexArray(children, parentPath);
13968
13979
  parentPath.pop();
13969
13980
  }
13970
- this.addNodePath(nodePath, item);
13981
+ this.addNodePath(nodePath, item, options);
13971
13982
  } else {
13972
13983
  this.add(pk, item);
13973
13984
  }
@@ -15326,7 +15337,16 @@ var DataSourceApiImpl = class {
15326
15337
  };
15327
15338
  this.getDataByNodePath = (nodePath) => {
15328
15339
  const { indexer } = this.getState();
15329
- return indexer.getDataForNodePath(nodePath) ?? null;
15340
+ const data = indexer.getDataForNodePath(nodePath);
15341
+ if (!data) {
15342
+ console.warn(
15343
+ `getDataByNodePath: no data found for nodePath: "${nodePath.join(
15344
+ " / "
15345
+ )}"`
15346
+ );
15347
+ return null;
15348
+ }
15349
+ return data;
15330
15350
  };
15331
15351
  /**
15332
15352
  * Replaces all data in the DataSource with the provided data.
@@ -15390,6 +15410,7 @@ var DataSourceApiImpl = class {
15390
15410
  }
15391
15411
  const nodesKey = this.getState().nodesKey;
15392
15412
  const dataChildren = data[nodesKey];
15413
+ debugger;
15393
15414
  const children = typeof childrenOrFn === "function" ? childrenOrFn(dataChildren, data) : childrenOrFn;
15394
15415
  return this.updateDataByNodePath(
15395
15416
  {
@@ -22219,7 +22240,7 @@ var useLicense = (licenseKey = "") => {
22219
22240
  }
22220
22241
  let valid2 = isValidLicense(licenseKey, {
22221
22242
  publishedAt: 1624970570587,
22222
- version: "6.0.12"
22243
+ version: "6.0.13"
22223
22244
  });
22224
22245
  if (!licenseKey && !valid2 && isInsidePlayground) {
22225
22246
  return true;
package/index.dev.mjs CHANGED
@@ -13807,9 +13807,20 @@ var Indexer = class {
13807
13807
  this.add = (primaryKey, data) => {
13808
13808
  this.primaryKeyToData.set(primaryKey, data);
13809
13809
  };
13810
- this.addNodePath = (nodePath, data) => {
13810
+ this.addNodePath = (nodePath, data, options) => {
13811
13811
  this.nodePathsToData.set(nodePath, data);
13812
13812
  this.add(nodePath[nodePath.length - 1], data);
13813
+ const children = options.getNodeChildren ? options.getNodeChildren(data) : options.nodesKey ? (
13814
+ //@ts-ignore
13815
+ data[options.nodesKey]
13816
+ ) : null;
13817
+ if (children && Array.isArray(children)) {
13818
+ for (let i = 0, len = children.length; i < len; i++) {
13819
+ const child = children[i];
13820
+ const childPath = [...nodePath, options.toPrimaryKey(child)];
13821
+ this.addNodePath(childPath, child, options);
13822
+ }
13823
+ }
13813
13824
  };
13814
13825
  this.clear = () => {
13815
13826
  this.primaryKeyToData.clear();
@@ -13843,7 +13854,7 @@ var Indexer = class {
13843
13854
  if (info.type === "insert") {
13844
13855
  const insertPK = toPrimaryKey(info.data);
13845
13856
  if (isTree) {
13846
- this.addNodePath([insertPK], info.data);
13857
+ this.addNodePath([insertPK], info.data, options);
13847
13858
  } else {
13848
13859
  this.add(insertPK, info.data);
13849
13860
  }
@@ -13886,7 +13897,7 @@ var Indexer = class {
13886
13897
  const insertPK = toPrimaryKey(info.data);
13887
13898
  if (isTreeModeForNode) {
13888
13899
  const currentPath = [...parentPath, insertPK];
13889
- this.addNodePath(currentPath, info.data);
13900
+ this.addNodePath(currentPath, info.data, options);
13890
13901
  } else {
13891
13902
  this.add(insertPK, info.data);
13892
13903
  }
@@ -13916,7 +13927,7 @@ var Indexer = class {
13916
13927
  indexArray(children, parentPath);
13917
13928
  parentPath.pop();
13918
13929
  }
13919
- this.addNodePath(nodePath, item);
13930
+ this.addNodePath(nodePath, item, options);
13920
13931
  } else {
13921
13932
  this.add(pk, item);
13922
13933
  }
@@ -15275,7 +15286,16 @@ var DataSourceApiImpl = class {
15275
15286
  };
15276
15287
  this.getDataByNodePath = (nodePath) => {
15277
15288
  const { indexer } = this.getState();
15278
- return indexer.getDataForNodePath(nodePath) ?? null;
15289
+ const data = indexer.getDataForNodePath(nodePath);
15290
+ if (!data) {
15291
+ console.warn(
15292
+ `getDataByNodePath: no data found for nodePath: "${nodePath.join(
15293
+ " / "
15294
+ )}"`
15295
+ );
15296
+ return null;
15297
+ }
15298
+ return data;
15279
15299
  };
15280
15300
  /**
15281
15301
  * Replaces all data in the DataSource with the provided data.
@@ -15339,6 +15359,7 @@ var DataSourceApiImpl = class {
15339
15359
  }
15340
15360
  const nodesKey = this.getState().nodesKey;
15341
15361
  const dataChildren = data[nodesKey];
15362
+ debugger;
15342
15363
  const children = typeof childrenOrFn === "function" ? childrenOrFn(dataChildren, data) : childrenOrFn;
15343
15364
  return this.updateDataByNodePath(
15344
15365
  {
@@ -22177,7 +22198,7 @@ var useLicense = (licenseKey = "") => {
22177
22198
  }
22178
22199
  let valid2 = isValidLicense(licenseKey, {
22179
22200
  publishedAt: 1624970570587,
22180
- version: "6.0.12"
22201
+ version: "6.0.13"
22181
22202
  });
22182
22203
  if (!licenseKey && !valid2 && isInsidePlayground) {
22183
22204
  return true;
package/index.js CHANGED
@@ -13858,9 +13858,20 @@ var Indexer = class {
13858
13858
  this.add = (primaryKey, data) => {
13859
13859
  this.primaryKeyToData.set(primaryKey, data);
13860
13860
  };
13861
- this.addNodePath = (nodePath, data) => {
13861
+ this.addNodePath = (nodePath, data, options) => {
13862
13862
  this.nodePathsToData.set(nodePath, data);
13863
13863
  this.add(nodePath[nodePath.length - 1], data);
13864
+ const children = options.getNodeChildren ? options.getNodeChildren(data) : options.nodesKey ? (
13865
+ //@ts-ignore
13866
+ data[options.nodesKey]
13867
+ ) : null;
13868
+ if (children && Array.isArray(children)) {
13869
+ for (let i = 0, len = children.length; i < len; i++) {
13870
+ const child = children[i];
13871
+ const childPath = [...nodePath, options.toPrimaryKey(child)];
13872
+ this.addNodePath(childPath, child, options);
13873
+ }
13874
+ }
13864
13875
  };
13865
13876
  this.clear = () => {
13866
13877
  this.primaryKeyToData.clear();
@@ -13894,7 +13905,7 @@ var Indexer = class {
13894
13905
  if (info.type === "insert") {
13895
13906
  const insertPK = toPrimaryKey(info.data);
13896
13907
  if (isTree) {
13897
- this.addNodePath([insertPK], info.data);
13908
+ this.addNodePath([insertPK], info.data, options);
13898
13909
  } else {
13899
13910
  this.add(insertPK, info.data);
13900
13911
  }
@@ -13937,7 +13948,7 @@ var Indexer = class {
13937
13948
  const insertPK = toPrimaryKey(info.data);
13938
13949
  if (isTreeModeForNode) {
13939
13950
  const currentPath = [...parentPath, insertPK];
13940
- this.addNodePath(currentPath, info.data);
13951
+ this.addNodePath(currentPath, info.data, options);
13941
13952
  } else {
13942
13953
  this.add(insertPK, info.data);
13943
13954
  }
@@ -13967,7 +13978,7 @@ var Indexer = class {
13967
13978
  indexArray(children, parentPath);
13968
13979
  parentPath.pop();
13969
13980
  }
13970
- this.addNodePath(nodePath, item);
13981
+ this.addNodePath(nodePath, item, options);
13971
13982
  } else {
13972
13983
  this.add(pk, item);
13973
13984
  }
@@ -15326,7 +15337,16 @@ var DataSourceApiImpl = class {
15326
15337
  };
15327
15338
  this.getDataByNodePath = (nodePath) => {
15328
15339
  const { indexer } = this.getState();
15329
- return indexer.getDataForNodePath(nodePath) ?? null;
15340
+ const data = indexer.getDataForNodePath(nodePath);
15341
+ if (!data) {
15342
+ console.warn(
15343
+ `getDataByNodePath: no data found for nodePath: "${nodePath.join(
15344
+ " / "
15345
+ )}"`
15346
+ );
15347
+ return null;
15348
+ }
15349
+ return data;
15330
15350
  };
15331
15351
  /**
15332
15352
  * Replaces all data in the DataSource with the provided data.
@@ -15390,6 +15410,7 @@ var DataSourceApiImpl = class {
15390
15410
  }
15391
15411
  const nodesKey = this.getState().nodesKey;
15392
15412
  const dataChildren = data[nodesKey];
15413
+ debugger;
15393
15414
  const children = typeof childrenOrFn === "function" ? childrenOrFn(dataChildren, data) : childrenOrFn;
15394
15415
  return this.updateDataByNodePath(
15395
15416
  {
@@ -22219,7 +22240,7 @@ var useLicense = (licenseKey = "") => {
22219
22240
  }
22220
22241
  let valid2 = isValidLicense(licenseKey, {
22221
22242
  publishedAt: 1624970570587,
22222
- version: "6.0.12"
22243
+ version: "6.0.13"
22223
22244
  });
22224
22245
  if (!licenseKey && !valid2 && isInsidePlayground) {
22225
22246
  return true;
package/index.mjs CHANGED
@@ -13807,9 +13807,20 @@ var Indexer = class {
13807
13807
  this.add = (primaryKey, data) => {
13808
13808
  this.primaryKeyToData.set(primaryKey, data);
13809
13809
  };
13810
- this.addNodePath = (nodePath, data) => {
13810
+ this.addNodePath = (nodePath, data, options) => {
13811
13811
  this.nodePathsToData.set(nodePath, data);
13812
13812
  this.add(nodePath[nodePath.length - 1], data);
13813
+ const children = options.getNodeChildren ? options.getNodeChildren(data) : options.nodesKey ? (
13814
+ //@ts-ignore
13815
+ data[options.nodesKey]
13816
+ ) : null;
13817
+ if (children && Array.isArray(children)) {
13818
+ for (let i = 0, len = children.length; i < len; i++) {
13819
+ const child = children[i];
13820
+ const childPath = [...nodePath, options.toPrimaryKey(child)];
13821
+ this.addNodePath(childPath, child, options);
13822
+ }
13823
+ }
13813
13824
  };
13814
13825
  this.clear = () => {
13815
13826
  this.primaryKeyToData.clear();
@@ -13843,7 +13854,7 @@ var Indexer = class {
13843
13854
  if (info.type === "insert") {
13844
13855
  const insertPK = toPrimaryKey(info.data);
13845
13856
  if (isTree) {
13846
- this.addNodePath([insertPK], info.data);
13857
+ this.addNodePath([insertPK], info.data, options);
13847
13858
  } else {
13848
13859
  this.add(insertPK, info.data);
13849
13860
  }
@@ -13886,7 +13897,7 @@ var Indexer = class {
13886
13897
  const insertPK = toPrimaryKey(info.data);
13887
13898
  if (isTreeModeForNode) {
13888
13899
  const currentPath = [...parentPath, insertPK];
13889
- this.addNodePath(currentPath, info.data);
13900
+ this.addNodePath(currentPath, info.data, options);
13890
13901
  } else {
13891
13902
  this.add(insertPK, info.data);
13892
13903
  }
@@ -13916,7 +13927,7 @@ var Indexer = class {
13916
13927
  indexArray(children, parentPath);
13917
13928
  parentPath.pop();
13918
13929
  }
13919
- this.addNodePath(nodePath, item);
13930
+ this.addNodePath(nodePath, item, options);
13920
13931
  } else {
13921
13932
  this.add(pk, item);
13922
13933
  }
@@ -15275,7 +15286,16 @@ var DataSourceApiImpl = class {
15275
15286
  };
15276
15287
  this.getDataByNodePath = (nodePath) => {
15277
15288
  const { indexer } = this.getState();
15278
- return indexer.getDataForNodePath(nodePath) ?? null;
15289
+ const data = indexer.getDataForNodePath(nodePath);
15290
+ if (!data) {
15291
+ console.warn(
15292
+ `getDataByNodePath: no data found for nodePath: "${nodePath.join(
15293
+ " / "
15294
+ )}"`
15295
+ );
15296
+ return null;
15297
+ }
15298
+ return data;
15279
15299
  };
15280
15300
  /**
15281
15301
  * Replaces all data in the DataSource with the provided data.
@@ -15339,6 +15359,7 @@ var DataSourceApiImpl = class {
15339
15359
  }
15340
15360
  const nodesKey = this.getState().nodesKey;
15341
15361
  const dataChildren = data[nodesKey];
15362
+ debugger;
15342
15363
  const children = typeof childrenOrFn === "function" ? childrenOrFn(dataChildren, data) : childrenOrFn;
15343
15364
  return this.updateDataByNodePath(
15344
15365
  {
@@ -22177,7 +22198,7 @@ var useLicense = (licenseKey = "") => {
22177
22198
  }
22178
22199
  let valid2 = isValidLicense(licenseKey, {
22179
22200
  publishedAt: 1624970570587,
22180
- version: "6.0.12"
22201
+ version: "6.0.13"
22181
22202
  });
22182
22203
  if (!licenseKey && !valid2 && isInsidePlayground) {
22183
22204
  return true;
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "bugs": {
26
26
  "url": "https://github.com/infinite-table/infinite-react/issues"
27
27
  },
28
- "version": "6.0.12",
28
+ "version": "6.0.13",
29
29
  "main": "index.js",
30
30
  "module": "index.mjs",
31
31
  "typings": "index.d.ts",
@@ -34,5 +34,5 @@
34
34
  },
35
35
  "license": "Commercial & Open Source",
36
36
  "//": "will be updated at build time",
37
- "publishedAt": 1731321598951
37
+ "publishedAt": 1731357157760
38
38
  }