@infinite-table/infinite-react 6.0.13 → 6.0.14

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
@@ -2310,6 +2310,8 @@ declare type IndexerOptions<DataType, PrimaryKeyType> = {
2310
2310
  declare class Indexer<DataType, PrimaryKeyType = string> {
2311
2311
  primaryKeyToData: Map<PrimaryKeyType, DataType>;
2312
2312
  nodePathsToData: DeepMap<PrimaryKeyType, DataType>;
2313
+ private removeNodePath;
2314
+ private remove;
2313
2315
  private add;
2314
2316
  private addNodePath;
2315
2317
  clear: () => void;
package/index.dev.js CHANGED
@@ -13855,12 +13855,48 @@ var Indexer = class {
13855
13855
  constructor() {
13856
13856
  this.primaryKeyToData = /* @__PURE__ */ new Map();
13857
13857
  this.nodePathsToData = new DeepMap();
13858
+ this.removeNodePath = (nodePath, options) => {
13859
+ this.nodePathsToData.delete(nodePath);
13860
+ this.remove(nodePath[nodePath.length - 1]);
13861
+ if (!options) {
13862
+ return;
13863
+ }
13864
+ const data = this.nodePathsToData.get(nodePath);
13865
+ if (data) {
13866
+ const children = options.getNodeChildren ? options.getNodeChildren(data) : options.nodesKey ? (
13867
+ //@ts-ignore
13868
+ data[options.nodesKey]
13869
+ ) : null;
13870
+ if (children && Array.isArray(children)) {
13871
+ for (let i = 0, len = children.length; i < len; i++) {
13872
+ const child = children[i];
13873
+ const childPath = [...nodePath, options.toPrimaryKey(child)];
13874
+ this.removeNodePath(childPath, options);
13875
+ }
13876
+ }
13877
+ }
13878
+ };
13879
+ this.remove = (primaryKey) => {
13880
+ this.primaryKeyToData.delete(primaryKey);
13881
+ };
13858
13882
  this.add = (primaryKey, data) => {
13859
13883
  this.primaryKeyToData.set(primaryKey, data);
13860
13884
  };
13861
13885
  this.addNodePath = (nodePath, data, options) => {
13886
+ if (false) {
13887
+ if (this.nodePathsToData.has(nodePath)) {
13888
+ console.warn(
13889
+ `There is a problem! The node at path [${nodePath.join(
13890
+ "/"
13891
+ )}] is already in the indexer! You're doing too much work!`
13892
+ );
13893
+ }
13894
+ }
13862
13895
  this.nodePathsToData.set(nodePath, data);
13863
13896
  this.add(nodePath[nodePath.length - 1], data);
13897
+ if (!options) {
13898
+ return;
13899
+ }
13864
13900
  const children = options.getNodeChildren ? options.getNodeChildren(data) : options.nodesKey ? (
13865
13901
  //@ts-ignore
13866
13902
  data[options.nodesKey]
@@ -13932,9 +13968,9 @@ var Indexer = class {
13932
13968
  const info = cacheInfo[cacheIndex];
13933
13969
  if (info.type === "delete" && !deleted) {
13934
13970
  if (isTreeModeForNode) {
13935
- this.nodePathsToData.delete(nodePath);
13971
+ this.removeNodePath(nodePath, options);
13936
13972
  } else {
13937
- this.primaryKeyToData.delete(pk);
13973
+ this.remove(pk);
13938
13974
  }
13939
13975
  deleted = true;
13940
13976
  arr2.splice(i, 1);
@@ -13945,13 +13981,6 @@ var Indexer = class {
13945
13981
  arr2[i] = item;
13946
13982
  }
13947
13983
  if (info.type === "insert") {
13948
- const insertPK = toPrimaryKey(info.data);
13949
- if (isTreeModeForNode) {
13950
- const currentPath = [...parentPath, insertPK];
13951
- this.addNodePath(currentPath, info.data, options);
13952
- } else {
13953
- this.add(insertPK, info.data);
13954
- }
13955
13984
  if (info.position === "before") {
13956
13985
  arr2.splice(i, 0, info.data);
13957
13986
  i--;
@@ -13968,6 +13997,7 @@ var Indexer = class {
13968
13997
  }
13969
13998
  if (!deleted) {
13970
13999
  if (isTreeModeForNode) {
14000
+ this.addNodePath(nodePath, item);
13971
14001
  const isLeaf = isLeafNode(item);
13972
14002
  let children = isLeaf ? null : getNodeChildren(item);
13973
14003
  if (!isLeaf && Array.isArray(children)) {
@@ -13978,7 +14008,6 @@ var Indexer = class {
13978
14008
  indexArray(children, parentPath);
13979
14009
  parentPath.pop();
13980
14010
  }
13981
- this.addNodePath(nodePath, item, options);
13982
14011
  } else {
13983
14012
  this.add(pk, item);
13984
14013
  }
@@ -15410,7 +15439,6 @@ var DataSourceApiImpl = class {
15410
15439
  }
15411
15440
  const nodesKey = this.getState().nodesKey;
15412
15441
  const dataChildren = data[nodesKey];
15413
- debugger;
15414
15442
  const children = typeof childrenOrFn === "function" ? childrenOrFn(dataChildren, data) : childrenOrFn;
15415
15443
  return this.updateDataByNodePath(
15416
15444
  {
@@ -22240,7 +22268,7 @@ var useLicense = (licenseKey = "") => {
22240
22268
  }
22241
22269
  let valid2 = isValidLicense(licenseKey, {
22242
22270
  publishedAt: 1624970570587,
22243
- version: "6.0.13"
22271
+ version: "6.0.14"
22244
22272
  });
22245
22273
  if (!licenseKey && !valid2 && isInsidePlayground) {
22246
22274
  return true;
package/index.dev.mjs CHANGED
@@ -13804,12 +13804,48 @@ var Indexer = class {
13804
13804
  constructor() {
13805
13805
  this.primaryKeyToData = /* @__PURE__ */ new Map();
13806
13806
  this.nodePathsToData = new DeepMap();
13807
+ this.removeNodePath = (nodePath, options) => {
13808
+ this.nodePathsToData.delete(nodePath);
13809
+ this.remove(nodePath[nodePath.length - 1]);
13810
+ if (!options) {
13811
+ return;
13812
+ }
13813
+ const data = this.nodePathsToData.get(nodePath);
13814
+ if (data) {
13815
+ const children = options.getNodeChildren ? options.getNodeChildren(data) : options.nodesKey ? (
13816
+ //@ts-ignore
13817
+ data[options.nodesKey]
13818
+ ) : null;
13819
+ if (children && Array.isArray(children)) {
13820
+ for (let i = 0, len = children.length; i < len; i++) {
13821
+ const child = children[i];
13822
+ const childPath = [...nodePath, options.toPrimaryKey(child)];
13823
+ this.removeNodePath(childPath, options);
13824
+ }
13825
+ }
13826
+ }
13827
+ };
13828
+ this.remove = (primaryKey) => {
13829
+ this.primaryKeyToData.delete(primaryKey);
13830
+ };
13807
13831
  this.add = (primaryKey, data) => {
13808
13832
  this.primaryKeyToData.set(primaryKey, data);
13809
13833
  };
13810
13834
  this.addNodePath = (nodePath, data, options) => {
13835
+ if (false) {
13836
+ if (this.nodePathsToData.has(nodePath)) {
13837
+ console.warn(
13838
+ `There is a problem! The node at path [${nodePath.join(
13839
+ "/"
13840
+ )}] is already in the indexer! You're doing too much work!`
13841
+ );
13842
+ }
13843
+ }
13811
13844
  this.nodePathsToData.set(nodePath, data);
13812
13845
  this.add(nodePath[nodePath.length - 1], data);
13846
+ if (!options) {
13847
+ return;
13848
+ }
13813
13849
  const children = options.getNodeChildren ? options.getNodeChildren(data) : options.nodesKey ? (
13814
13850
  //@ts-ignore
13815
13851
  data[options.nodesKey]
@@ -13881,9 +13917,9 @@ var Indexer = class {
13881
13917
  const info = cacheInfo[cacheIndex];
13882
13918
  if (info.type === "delete" && !deleted) {
13883
13919
  if (isTreeModeForNode) {
13884
- this.nodePathsToData.delete(nodePath);
13920
+ this.removeNodePath(nodePath, options);
13885
13921
  } else {
13886
- this.primaryKeyToData.delete(pk);
13922
+ this.remove(pk);
13887
13923
  }
13888
13924
  deleted = true;
13889
13925
  arr2.splice(i, 1);
@@ -13894,13 +13930,6 @@ var Indexer = class {
13894
13930
  arr2[i] = item;
13895
13931
  }
13896
13932
  if (info.type === "insert") {
13897
- const insertPK = toPrimaryKey(info.data);
13898
- if (isTreeModeForNode) {
13899
- const currentPath = [...parentPath, insertPK];
13900
- this.addNodePath(currentPath, info.data, options);
13901
- } else {
13902
- this.add(insertPK, info.data);
13903
- }
13904
13933
  if (info.position === "before") {
13905
13934
  arr2.splice(i, 0, info.data);
13906
13935
  i--;
@@ -13917,6 +13946,7 @@ var Indexer = class {
13917
13946
  }
13918
13947
  if (!deleted) {
13919
13948
  if (isTreeModeForNode) {
13949
+ this.addNodePath(nodePath, item);
13920
13950
  const isLeaf = isLeafNode(item);
13921
13951
  let children = isLeaf ? null : getNodeChildren(item);
13922
13952
  if (!isLeaf && Array.isArray(children)) {
@@ -13927,7 +13957,6 @@ var Indexer = class {
13927
13957
  indexArray(children, parentPath);
13928
13958
  parentPath.pop();
13929
13959
  }
13930
- this.addNodePath(nodePath, item, options);
13931
13960
  } else {
13932
13961
  this.add(pk, item);
13933
13962
  }
@@ -15359,7 +15388,6 @@ var DataSourceApiImpl = class {
15359
15388
  }
15360
15389
  const nodesKey = this.getState().nodesKey;
15361
15390
  const dataChildren = data[nodesKey];
15362
- debugger;
15363
15391
  const children = typeof childrenOrFn === "function" ? childrenOrFn(dataChildren, data) : childrenOrFn;
15364
15392
  return this.updateDataByNodePath(
15365
15393
  {
@@ -22198,7 +22226,7 @@ var useLicense = (licenseKey = "") => {
22198
22226
  }
22199
22227
  let valid2 = isValidLicense(licenseKey, {
22200
22228
  publishedAt: 1624970570587,
22201
- version: "6.0.13"
22229
+ version: "6.0.14"
22202
22230
  });
22203
22231
  if (!licenseKey && !valid2 && isInsidePlayground) {
22204
22232
  return true;
package/index.js CHANGED
@@ -13855,12 +13855,48 @@ var Indexer = class {
13855
13855
  constructor() {
13856
13856
  this.primaryKeyToData = /* @__PURE__ */ new Map();
13857
13857
  this.nodePathsToData = new DeepMap();
13858
+ this.removeNodePath = (nodePath, options) => {
13859
+ this.nodePathsToData.delete(nodePath);
13860
+ this.remove(nodePath[nodePath.length - 1]);
13861
+ if (!options) {
13862
+ return;
13863
+ }
13864
+ const data = this.nodePathsToData.get(nodePath);
13865
+ if (data) {
13866
+ const children = options.getNodeChildren ? options.getNodeChildren(data) : options.nodesKey ? (
13867
+ //@ts-ignore
13868
+ data[options.nodesKey]
13869
+ ) : null;
13870
+ if (children && Array.isArray(children)) {
13871
+ for (let i = 0, len = children.length; i < len; i++) {
13872
+ const child = children[i];
13873
+ const childPath = [...nodePath, options.toPrimaryKey(child)];
13874
+ this.removeNodePath(childPath, options);
13875
+ }
13876
+ }
13877
+ }
13878
+ };
13879
+ this.remove = (primaryKey) => {
13880
+ this.primaryKeyToData.delete(primaryKey);
13881
+ };
13858
13882
  this.add = (primaryKey, data) => {
13859
13883
  this.primaryKeyToData.set(primaryKey, data);
13860
13884
  };
13861
13885
  this.addNodePath = (nodePath, data, options) => {
13886
+ if (false) {
13887
+ if (this.nodePathsToData.has(nodePath)) {
13888
+ console.warn(
13889
+ `There is a problem! The node at path [${nodePath.join(
13890
+ "/"
13891
+ )}] is already in the indexer! You're doing too much work!`
13892
+ );
13893
+ }
13894
+ }
13862
13895
  this.nodePathsToData.set(nodePath, data);
13863
13896
  this.add(nodePath[nodePath.length - 1], data);
13897
+ if (!options) {
13898
+ return;
13899
+ }
13864
13900
  const children = options.getNodeChildren ? options.getNodeChildren(data) : options.nodesKey ? (
13865
13901
  //@ts-ignore
13866
13902
  data[options.nodesKey]
@@ -13932,9 +13968,9 @@ var Indexer = class {
13932
13968
  const info = cacheInfo[cacheIndex];
13933
13969
  if (info.type === "delete" && !deleted) {
13934
13970
  if (isTreeModeForNode) {
13935
- this.nodePathsToData.delete(nodePath);
13971
+ this.removeNodePath(nodePath, options);
13936
13972
  } else {
13937
- this.primaryKeyToData.delete(pk);
13973
+ this.remove(pk);
13938
13974
  }
13939
13975
  deleted = true;
13940
13976
  arr2.splice(i, 1);
@@ -13945,13 +13981,6 @@ var Indexer = class {
13945
13981
  arr2[i] = item;
13946
13982
  }
13947
13983
  if (info.type === "insert") {
13948
- const insertPK = toPrimaryKey(info.data);
13949
- if (isTreeModeForNode) {
13950
- const currentPath = [...parentPath, insertPK];
13951
- this.addNodePath(currentPath, info.data, options);
13952
- } else {
13953
- this.add(insertPK, info.data);
13954
- }
13955
13984
  if (info.position === "before") {
13956
13985
  arr2.splice(i, 0, info.data);
13957
13986
  i--;
@@ -13968,6 +13997,7 @@ var Indexer = class {
13968
13997
  }
13969
13998
  if (!deleted) {
13970
13999
  if (isTreeModeForNode) {
14000
+ this.addNodePath(nodePath, item);
13971
14001
  const isLeaf = isLeafNode(item);
13972
14002
  let children = isLeaf ? null : getNodeChildren(item);
13973
14003
  if (!isLeaf && Array.isArray(children)) {
@@ -13978,7 +14008,6 @@ var Indexer = class {
13978
14008
  indexArray(children, parentPath);
13979
14009
  parentPath.pop();
13980
14010
  }
13981
- this.addNodePath(nodePath, item, options);
13982
14011
  } else {
13983
14012
  this.add(pk, item);
13984
14013
  }
@@ -15410,7 +15439,6 @@ var DataSourceApiImpl = class {
15410
15439
  }
15411
15440
  const nodesKey = this.getState().nodesKey;
15412
15441
  const dataChildren = data[nodesKey];
15413
- debugger;
15414
15442
  const children = typeof childrenOrFn === "function" ? childrenOrFn(dataChildren, data) : childrenOrFn;
15415
15443
  return this.updateDataByNodePath(
15416
15444
  {
@@ -22240,7 +22268,7 @@ var useLicense = (licenseKey = "") => {
22240
22268
  }
22241
22269
  let valid2 = isValidLicense(licenseKey, {
22242
22270
  publishedAt: 1624970570587,
22243
- version: "6.0.13"
22271
+ version: "6.0.14"
22244
22272
  });
22245
22273
  if (!licenseKey && !valid2 && isInsidePlayground) {
22246
22274
  return true;
package/index.mjs CHANGED
@@ -13804,12 +13804,48 @@ var Indexer = class {
13804
13804
  constructor() {
13805
13805
  this.primaryKeyToData = /* @__PURE__ */ new Map();
13806
13806
  this.nodePathsToData = new DeepMap();
13807
+ this.removeNodePath = (nodePath, options) => {
13808
+ this.nodePathsToData.delete(nodePath);
13809
+ this.remove(nodePath[nodePath.length - 1]);
13810
+ if (!options) {
13811
+ return;
13812
+ }
13813
+ const data = this.nodePathsToData.get(nodePath);
13814
+ if (data) {
13815
+ const children = options.getNodeChildren ? options.getNodeChildren(data) : options.nodesKey ? (
13816
+ //@ts-ignore
13817
+ data[options.nodesKey]
13818
+ ) : null;
13819
+ if (children && Array.isArray(children)) {
13820
+ for (let i = 0, len = children.length; i < len; i++) {
13821
+ const child = children[i];
13822
+ const childPath = [...nodePath, options.toPrimaryKey(child)];
13823
+ this.removeNodePath(childPath, options);
13824
+ }
13825
+ }
13826
+ }
13827
+ };
13828
+ this.remove = (primaryKey) => {
13829
+ this.primaryKeyToData.delete(primaryKey);
13830
+ };
13807
13831
  this.add = (primaryKey, data) => {
13808
13832
  this.primaryKeyToData.set(primaryKey, data);
13809
13833
  };
13810
13834
  this.addNodePath = (nodePath, data, options) => {
13835
+ if (false) {
13836
+ if (this.nodePathsToData.has(nodePath)) {
13837
+ console.warn(
13838
+ `There is a problem! The node at path [${nodePath.join(
13839
+ "/"
13840
+ )}] is already in the indexer! You're doing too much work!`
13841
+ );
13842
+ }
13843
+ }
13811
13844
  this.nodePathsToData.set(nodePath, data);
13812
13845
  this.add(nodePath[nodePath.length - 1], data);
13846
+ if (!options) {
13847
+ return;
13848
+ }
13813
13849
  const children = options.getNodeChildren ? options.getNodeChildren(data) : options.nodesKey ? (
13814
13850
  //@ts-ignore
13815
13851
  data[options.nodesKey]
@@ -13881,9 +13917,9 @@ var Indexer = class {
13881
13917
  const info = cacheInfo[cacheIndex];
13882
13918
  if (info.type === "delete" && !deleted) {
13883
13919
  if (isTreeModeForNode) {
13884
- this.nodePathsToData.delete(nodePath);
13920
+ this.removeNodePath(nodePath, options);
13885
13921
  } else {
13886
- this.primaryKeyToData.delete(pk);
13922
+ this.remove(pk);
13887
13923
  }
13888
13924
  deleted = true;
13889
13925
  arr2.splice(i, 1);
@@ -13894,13 +13930,6 @@ var Indexer = class {
13894
13930
  arr2[i] = item;
13895
13931
  }
13896
13932
  if (info.type === "insert") {
13897
- const insertPK = toPrimaryKey(info.data);
13898
- if (isTreeModeForNode) {
13899
- const currentPath = [...parentPath, insertPK];
13900
- this.addNodePath(currentPath, info.data, options);
13901
- } else {
13902
- this.add(insertPK, info.data);
13903
- }
13904
13933
  if (info.position === "before") {
13905
13934
  arr2.splice(i, 0, info.data);
13906
13935
  i--;
@@ -13917,6 +13946,7 @@ var Indexer = class {
13917
13946
  }
13918
13947
  if (!deleted) {
13919
13948
  if (isTreeModeForNode) {
13949
+ this.addNodePath(nodePath, item);
13920
13950
  const isLeaf = isLeafNode(item);
13921
13951
  let children = isLeaf ? null : getNodeChildren(item);
13922
13952
  if (!isLeaf && Array.isArray(children)) {
@@ -13927,7 +13957,6 @@ var Indexer = class {
13927
13957
  indexArray(children, parentPath);
13928
13958
  parentPath.pop();
13929
13959
  }
13930
- this.addNodePath(nodePath, item, options);
13931
13960
  } else {
13932
13961
  this.add(pk, item);
13933
13962
  }
@@ -15359,7 +15388,6 @@ var DataSourceApiImpl = class {
15359
15388
  }
15360
15389
  const nodesKey = this.getState().nodesKey;
15361
15390
  const dataChildren = data[nodesKey];
15362
- debugger;
15363
15391
  const children = typeof childrenOrFn === "function" ? childrenOrFn(dataChildren, data) : childrenOrFn;
15364
15392
  return this.updateDataByNodePath(
15365
15393
  {
@@ -22198,7 +22226,7 @@ var useLicense = (licenseKey = "") => {
22198
22226
  }
22199
22227
  let valid2 = isValidLicense(licenseKey, {
22200
22228
  publishedAt: 1624970570587,
22201
- version: "6.0.13"
22229
+ version: "6.0.14"
22202
22230
  });
22203
22231
  if (!licenseKey && !valid2 && isInsidePlayground) {
22204
22232
  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.13",
28
+ "version": "6.0.14",
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": 1731357157760
37
+ "publishedAt": 1731510719445
38
38
  }