@infinite-table/infinite-react 6.0.13 → 6.0.15

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.dev.mjs CHANGED
@@ -5372,7 +5372,7 @@ var Icon = (props) => {
5372
5372
  // src/components/InfiniteTable/components/icons/IncludesOperatorIcon.tsx
5373
5373
  import * as React17 from "react";
5374
5374
  var IncludesOperatorIcon = (props) => {
5375
- return /* @__PURE__ */ React17.createElement(Icon, { ...props }, /* @__PURE__ */ React17.createElement("path", { d: "M5,4V7H10.5V19H13.5V7H19V4H5Z" }));
5375
+ return /* @__PURE__ */ React17.createElement(Icon, { ...props }, /* @__PURE__ */ React17.createElement("path", { d: "M11.14 4L6.43 16H8.36L9.32 13.43H14.67L15.64 16H17.57L12.86 4M12 6.29L14.03 11.71H9.96M20" }), /* @__PURE__ */ React17.createElement("path", { d: "M4 18V15H2V20H22V18Z" }), /* @__PURE__ */ React17.createElement("path", { d: "M20 14V18H2V20H22V14Z" }));
5376
5376
  };
5377
5377
 
5378
5378
  // src/components/InfiniteTable/components/icons/EndsWithOperatorIcon.tsx
@@ -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);
@@ -13893,14 +13929,20 @@ var Indexer = class {
13893
13929
  item = { ...item, ...info.data };
13894
13930
  arr2[i] = item;
13895
13931
  }
13896
- 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);
13932
+ if (info.type === "update-children" && !deleted) {
13933
+ const children = info.children(
13934
+ item[nodesKey],
13935
+ item
13936
+ );
13937
+ item = { ...item };
13938
+ if (children !== void 0) {
13939
+ item[nodesKey] = children;
13901
13940
  } else {
13902
- this.add(insertPK, info.data);
13941
+ delete item[nodesKey];
13903
13942
  }
13943
+ arr2[i] = item;
13944
+ }
13945
+ if (info.type === "insert") {
13904
13946
  if (info.position === "before") {
13905
13947
  arr2.splice(i, 0, info.data);
13906
13948
  i--;
@@ -13917,6 +13959,7 @@ var Indexer = class {
13917
13959
  }
13918
13960
  if (!deleted) {
13919
13961
  if (isTreeModeForNode) {
13962
+ this.addNodePath(nodePath, item);
13920
13963
  const isLeaf = isLeafNode(item);
13921
13964
  let children = isLeaf ? null : getNodeChildren(item);
13922
13965
  if (!isLeaf && Array.isArray(children)) {
@@ -13927,7 +13970,6 @@ var Indexer = class {
13927
13970
  indexArray(children, parentPath);
13928
13971
  parentPath.pop();
13929
13972
  }
13930
- this.addNodePath(nodePath, item, options);
13931
13973
  } else {
13932
13974
  this.add(pk, item);
13933
13975
  }
@@ -14199,7 +14241,7 @@ function getPivotColumnsAndColumnGroups({
14199
14241
  // src/components/DataSource/DataSourceCache.ts
14200
14242
  var CLEAR_SYMBOL = Symbol("CLEAR");
14201
14243
  var DataSourceCache = class {
14202
- constructor() {
14244
+ constructor(options) {
14203
14245
  this.affectedFields = /* @__PURE__ */ new Set();
14204
14246
  this.allFieldsAffected = false;
14205
14247
  this.primaryKeyToData = /* @__PURE__ */ new Map();
@@ -14262,8 +14304,12 @@ var DataSourceCache = class {
14262
14304
  };
14263
14305
  this.update = (primaryKey, data, originalData, metadata) => {
14264
14306
  if (!this.allFieldsAffected) {
14265
- const keys = Object.keys(data);
14266
- keys.forEach((key) => this.affectedFields.add(key));
14307
+ if (this.nodesKey && Array.isArray(data[this.nodesKey])) {
14308
+ this.allFieldsAffected = true;
14309
+ } else {
14310
+ const keys = Object.keys(data);
14311
+ keys.forEach((key) => this.affectedFields.add(key));
14312
+ }
14267
14313
  }
14268
14314
  const pk = primaryKey;
14269
14315
  const value = this.primaryKeyToData.get(pk) || [];
@@ -14278,8 +14324,12 @@ var DataSourceCache = class {
14278
14324
  };
14279
14325
  this.updateNodePath = (nodePath, data, originalData, metadata) => {
14280
14326
  if (!this.allFieldsAffected) {
14281
- const keys = Object.keys(data);
14282
- keys.forEach((key) => this.affectedFields.add(key));
14327
+ if (this.nodesKey && Array.isArray(data[this.nodesKey])) {
14328
+ this.allFieldsAffected = true;
14329
+ } else {
14330
+ const keys = Object.keys(data);
14331
+ keys.forEach((key) => this.affectedFields.add(key));
14332
+ }
14283
14333
  }
14284
14334
  const value = this.nodePathToData.get(nodePath) || [];
14285
14335
  value.push({
@@ -14291,6 +14341,18 @@ var DataSourceCache = class {
14291
14341
  });
14292
14342
  this.nodePathToData.set(nodePath, value);
14293
14343
  };
14344
+ this.updateChildren = (nodePath, children, originalData, metadata) => {
14345
+ this.allFieldsAffected = true;
14346
+ const value = this.nodePathToData.get(nodePath) || [];
14347
+ value.push({
14348
+ type: "update-children",
14349
+ nodePath,
14350
+ children,
14351
+ originalData,
14352
+ metadata
14353
+ });
14354
+ this.nodePathToData.set(nodePath, value);
14355
+ };
14294
14356
  this.resetDataSource = (metadata) => {
14295
14357
  this.clear();
14296
14358
  this.allFieldsAffected = true;
@@ -14343,9 +14405,12 @@ var DataSourceCache = class {
14343
14405
  this.getTreeMutationsArray = () => {
14344
14406
  return Array.from(this.nodePathToData.values()).flat();
14345
14407
  };
14408
+ this.nodesKey = options.nodesKey;
14346
14409
  }
14347
14410
  static clone(cache, { light = false } = {}) {
14348
- const clone = new DataSourceCache();
14411
+ const clone = new DataSourceCache({
14412
+ nodesKey: cache.nodesKey
14413
+ });
14349
14414
  clone.allFieldsAffected = cache.allFieldsAffected;
14350
14415
  clone.affectedFields = new Set(cache.affectedFields);
14351
14416
  clone.primaryKeyToData = light ? cache.primaryKeyToData : new Map(
@@ -15221,6 +15286,7 @@ var RowDisabledState = class extends BooleanCollectionState {
15221
15286
  };
15222
15287
 
15223
15288
  // src/components/DataSource/getDataSourceApi.ts
15289
+ var DEFAULT_NODE_PATH_WAIT_TIMEOUT = 1e3;
15224
15290
  function getDataSourceApi(param) {
15225
15291
  return new DataSourceApiImpl(param);
15226
15292
  }
@@ -15284,15 +15350,20 @@ var DataSourceApiImpl = class {
15284
15350
  const { indexer } = this.getState();
15285
15351
  return indexer.getDataForPrimaryKey(id) ?? null;
15286
15352
  };
15353
+ this.isNodePathAvailable = (nodePath) => {
15354
+ return this.getState().indexer.getDataForNodePath(nodePath) !== void 0;
15355
+ };
15287
15356
  this.getDataByNodePath = (nodePath) => {
15288
15357
  const { indexer } = this.getState();
15289
15358
  const data = indexer.getDataForNodePath(nodePath);
15290
15359
  if (!data) {
15291
- console.warn(
15292
- `getDataByNodePath: no data found for nodePath: "${nodePath.join(
15293
- " / "
15294
- )}"`
15295
- );
15360
+ if (false) {
15361
+ console.warn(
15362
+ `getDataByNodePath: no data found for nodePath: "${nodePath.join(
15363
+ " / "
15364
+ )}"`
15365
+ );
15366
+ }
15296
15367
  return null;
15297
15368
  }
15298
15369
  return data;
@@ -15352,26 +15423,84 @@ var DataSourceApiImpl = class {
15352
15423
  }
15353
15424
  return result;
15354
15425
  };
15426
+ this.withWaitForNode = (nodePath, fn, options) => {
15427
+ const waitForNode = options?.waitForNode ?? true;
15428
+ if (waitForNode === true || typeof waitForNode === "number") {
15429
+ let timeout = waitForNode === true ? DEFAULT_NODE_PATH_WAIT_TIMEOUT : waitForNode;
15430
+ if (!isNaN(timeout)) {
15431
+ timeout = DEFAULT_NODE_PATH_WAIT_TIMEOUT;
15432
+ }
15433
+ return this.waitForNodePath(nodePath, { timeout }).then((okay) => {
15434
+ if (!okay) {
15435
+ const error2 = `Cannot find node path "${nodePath.join(
15436
+ "/"
15437
+ )}" (we waited for it ${timeout}ms)`;
15438
+ console.error(error2);
15439
+ return fn({
15440
+ error: error2,
15441
+ resolved: false
15442
+ });
15443
+ }
15444
+ return fn({
15445
+ resolved: true
15446
+ });
15447
+ });
15448
+ }
15449
+ const result = fn({
15450
+ resolved: void 0
15451
+ });
15452
+ return result instanceof Promise ? result : Promise.resolve(result);
15453
+ };
15355
15454
  this.updateChildrenByNodePath = (childrenOrFn, nodePath, options) => {
15356
- const data = this.getDataByNodePath(nodePath);
15357
- if (data == null) {
15358
- return Promise.resolve(null);
15359
- }
15360
- const nodesKey = this.getState().nodesKey;
15361
- const dataChildren = data[nodesKey];
15362
- debugger;
15363
- const children = typeof childrenOrFn === "function" ? childrenOrFn(dataChildren, data) : childrenOrFn;
15364
- return this.updateDataByNodePath(
15365
- {
15366
- ...data,
15367
- [nodesKey]: children
15368
- },
15455
+ return this.withWaitForNode(
15369
15456
  nodePath,
15457
+ ({ error: error2 }) => {
15458
+ if (error2) {
15459
+ return false;
15460
+ }
15461
+ return this.updateChildrenByNodePath_Internal(
15462
+ childrenOrFn,
15463
+ nodePath,
15464
+ options
15465
+ );
15466
+ },
15467
+ options
15468
+ );
15469
+ };
15470
+ this.updateChildrenByNodePath_Internal = (childrenOrFn, nodePath, options) => {
15471
+ const children = typeof childrenOrFn === "function" ? childrenOrFn : () => childrenOrFn;
15472
+ return this.updateDataArrayByNodePath_Internal(
15473
+ [
15474
+ {
15475
+ nodePath,
15476
+ children
15477
+ }
15478
+ ],
15370
15479
  options
15371
15480
  );
15372
15481
  };
15373
15482
  this.updateDataByNodePath = (data, nodePath, options) => {
15374
- return this.updateDataArrayByNodePath(
15483
+ if (!this.isNodePathAvailable(nodePath)) {
15484
+ return this.withWaitForNode(
15485
+ nodePath,
15486
+ ({ error: error2 }) => {
15487
+ if (error2) {
15488
+ return false;
15489
+ }
15490
+ return this.updateDataArrayByNodePath_Internal(
15491
+ [
15492
+ {
15493
+ data,
15494
+ nodePath
15495
+ }
15496
+ ],
15497
+ options
15498
+ );
15499
+ },
15500
+ options
15501
+ );
15502
+ }
15503
+ return this.updateDataArrayByNodePath_Internal(
15375
15504
  [
15376
15505
  {
15377
15506
  data,
@@ -15382,10 +15511,31 @@ var DataSourceApiImpl = class {
15382
15511
  );
15383
15512
  };
15384
15513
  this.updateDataArrayByNodePath = (updateInfo, options) => {
15514
+ if (options && typeof options.waitForNode !== "undefined" && !options.waitForNode) {
15515
+ return this.updateDataArrayByNodePath_Internal(updateInfo, options);
15516
+ }
15517
+ const allNodePaths = updateInfo.map((info) => info.nodePath);
15518
+ const promiseWithAll = Promise.allSettled(
15519
+ allNodePaths.map((nodePath) => {
15520
+ return this.withWaitForNode(nodePath, ({ error: error2 }) => !error2, options);
15521
+ })
15522
+ );
15523
+ return promiseWithAll.then((allGood) => {
15524
+ if (!allGood.every(Boolean)) {
15525
+ return false;
15526
+ }
15527
+ return this.updateDataArrayByNodePath_Internal(updateInfo, options);
15528
+ });
15529
+ };
15530
+ this.updateDataArrayByNodePath_Internal = (updateInfo, options) => {
15385
15531
  const data = [];
15386
15532
  const nodePaths = [];
15387
15533
  updateInfo.forEach((info) => {
15388
- data.push(info.data);
15534
+ if (info.data) {
15535
+ data.push(info.data);
15536
+ } else if (info.children) {
15537
+ data.push(info.children);
15538
+ }
15389
15539
  nodePaths.push(info.nodePath);
15390
15540
  });
15391
15541
  const result = this.batchOperation({
@@ -15415,67 +15565,39 @@ var DataSourceApiImpl = class {
15415
15565
  return result;
15416
15566
  };
15417
15567
  this.removeDataByNodePath = (nodePath, options) => {
15418
- const result = this.batchOperation({
15419
- type: "delete",
15420
- nodePaths: [nodePath],
15421
- metadata: options?.metadata
15422
- });
15423
- if (options?.flush) {
15424
- this.commit();
15425
- }
15426
- return result;
15568
+ return this.batchDeleteNodePaths([nodePath], options);
15427
15569
  };
15428
15570
  this.removeData = (data, options) => {
15429
15571
  const isTree = this.getState().isTree;
15430
- let primaryKeys = !isTree ? [this.toPrimaryKey(data)] : void 0;
15431
- const nodePath = isTree ? this.getNodePathById(this.toPrimaryKey(data)) : null;
15432
- let nodePaths = isTree && nodePath ? [nodePath] : void 0;
15433
- const result = primaryKeys ? this.batchOperation({
15434
- type: "delete",
15435
- primaryKeys,
15436
- metadata: options?.metadata
15437
- }) : this.batchOperation({
15438
- type: "delete",
15439
- nodePaths: nodePaths || [],
15440
- metadata: options?.metadata
15441
- });
15442
- if (options?.flush) {
15443
- this.commit();
15572
+ if (isTree) {
15573
+ const nodePath = this.getNodePathById(this.toPrimaryKey(data));
15574
+ return this.removeDataByNodePath(nodePath, options);
15444
15575
  }
15445
- return result;
15576
+ return this.batchDeletePrimaryKeys([this.toPrimaryKey(data)], options);
15446
15577
  };
15447
15578
  this.removeDataArrayByPrimaryKeys = (ids, options) => {
15448
15579
  const isTree = this.getState().isTree;
15449
- const nodePaths = isTree ? ids.map((id) => {
15450
- return this.getNodePathById(id) || [];
15451
- }) : null;
15452
- const result = isTree ? this.batchOperation({
15580
+ if (isTree) {
15581
+ const nodePaths = ids.map((id) => this.getNodePathById(id) || []);
15582
+ return this.batchDeleteNodePaths(nodePaths, options);
15583
+ }
15584
+ return this.batchDeletePrimaryKeys(ids, options);
15585
+ };
15586
+ this.batchDeleteNodePaths = (nodePaths, options) => {
15587
+ const result = this.batchOperation({
15453
15588
  type: "delete",
15454
15589
  nodePaths: nodePaths || [],
15455
15590
  metadata: options?.metadata
15456
- }) : this.batchOperation({
15457
- type: "delete",
15458
- primaryKeys: ids,
15459
- metadata: options?.metadata
15460
15591
  });
15461
15592
  if (options?.flush) {
15462
15593
  this.commit();
15463
15594
  }
15464
15595
  return result;
15465
15596
  };
15466
- this.removeDataArray = (data, options) => {
15467
- const isTree = this.getState().isTree;
15468
- const nodePaths = isTree ? data.map((d) => {
15469
- return this.getNodePathById(this.toPrimaryKey(d)) || [];
15470
- }) : null;
15471
- const primaryKeys = !isTree ? data.map(this.toPrimaryKey) : void 0;
15472
- const result = isTree ? this.batchOperation({
15473
- type: "delete",
15474
- nodePaths: nodePaths || [],
15475
- metadata: options?.metadata
15476
- }) : this.batchOperation({
15597
+ this.batchDeletePrimaryKeys = (primaryKeys, options) => {
15598
+ const result = this.batchOperation({
15477
15599
  type: "delete",
15478
- primaryKeys: primaryKeys || [],
15600
+ primaryKeys,
15479
15601
  metadata: options?.metadata
15480
15602
  });
15481
15603
  if (options?.flush) {
@@ -15483,6 +15605,17 @@ var DataSourceApiImpl = class {
15483
15605
  }
15484
15606
  return result;
15485
15607
  };
15608
+ this.removeDataArray = (data, options) => {
15609
+ const isTree = this.getState().isTree;
15610
+ if (isTree) {
15611
+ const nodePaths = data.map((d) => {
15612
+ return this.getNodePathById(this.toPrimaryKey(d)) || [];
15613
+ });
15614
+ return this.batchDeleteNodePaths(nodePaths, options);
15615
+ }
15616
+ const primaryKeys = data.map(this.toPrimaryKey);
15617
+ return this.batchDeletePrimaryKeys(primaryKeys, options);
15618
+ };
15486
15619
  this.addData = (data, options) => {
15487
15620
  return this.addDataArray([data], options);
15488
15621
  };
@@ -15496,9 +15629,33 @@ var DataSourceApiImpl = class {
15496
15629
  return this.insertDataArray([data], options);
15497
15630
  };
15498
15631
  this.insertDataArray = (data, options) => {
15632
+ const isTree = this.getState().isTree;
15499
15633
  let position2 = "before";
15500
15634
  let primaryKey = void 0;
15501
15635
  let nodePath = options.nodePath;
15636
+ if (isTree && nodePath?.length) {
15637
+ return this.withWaitForNode(
15638
+ nodePath,
15639
+ ({ error: error2 }) => {
15640
+ if (error2) {
15641
+ return false;
15642
+ }
15643
+ if (options.position === "before" || options.position === "after") {
15644
+ return this.batchTreeInsert(
15645
+ data,
15646
+ options.position,
15647
+ nodePath,
15648
+ options
15649
+ );
15650
+ }
15651
+ const newChildren = (childrenOfNode) => {
15652
+ return options.position === "start" ? [...data, ...childrenOfNode || []] : [...childrenOfNode || [], ...data];
15653
+ };
15654
+ return this.updateChildrenByNodePath(newChildren, nodePath, options);
15655
+ },
15656
+ options
15657
+ );
15658
+ }
15502
15659
  if (options.position === "before" || options.position === "after") {
15503
15660
  position2 = options.position;
15504
15661
  primaryKey = options.primaryKey;
@@ -15506,13 +15663,20 @@ var DataSourceApiImpl = class {
15506
15663
  const arr = this.getOriginalDataArray();
15507
15664
  if (options.position === "start") {
15508
15665
  position2 = "before";
15509
- primaryKey = !arr.length ? void 0 : this.toPrimaryKey(arr[0]);
15666
+ if (!arr.length) {
15667
+ primaryKey = void 0;
15668
+ } else {
15669
+ primaryKey = this.toPrimaryKey(arr[0]);
15670
+ }
15510
15671
  } else {
15511
15672
  position2 = "after";
15512
- primaryKey = !arr.length ? void 0 : this.toPrimaryKey(arr[arr.length - 1]);
15673
+ if (!arr.length) {
15674
+ primaryKey = void 0;
15675
+ } else {
15676
+ primaryKey = this.toPrimaryKey(arr[arr.length - 1]);
15677
+ }
15513
15678
  }
15514
15679
  }
15515
- const isTree = this.getState().isTree;
15516
15680
  const result = isTree ? this.batchOperation({
15517
15681
  type: "insert",
15518
15682
  array: data,
@@ -15532,6 +15696,41 @@ var DataSourceApiImpl = class {
15532
15696
  }
15533
15697
  return result;
15534
15698
  };
15699
+ this.batchTreeInsert = (data, position2, nodePath, options) => {
15700
+ if (nodePath.length && !this.isNodePathAvailable(nodePath)) {
15701
+ return this.withWaitForNode(
15702
+ nodePath,
15703
+ ({ error: error2 }) => {
15704
+ if (error2) {
15705
+ return false;
15706
+ }
15707
+ const result2 = this.batchOperation({
15708
+ type: "insert",
15709
+ array: data,
15710
+ position: position2,
15711
+ metadata: options?.metadata,
15712
+ nodePath
15713
+ });
15714
+ if (options?.flush) {
15715
+ this.commit();
15716
+ }
15717
+ return result2;
15718
+ },
15719
+ options
15720
+ );
15721
+ }
15722
+ const result = this.batchOperation({
15723
+ type: "insert",
15724
+ array: data,
15725
+ position: position2,
15726
+ metadata: options?.metadata,
15727
+ nodePath
15728
+ });
15729
+ if (options?.flush) {
15730
+ this.commit();
15731
+ }
15732
+ return result;
15733
+ };
15535
15734
  this.setSortInfo = (sortInfo) => {
15536
15735
  const multiSort = this.getState().multiSort;
15537
15736
  if (Array.isArray(sortInfo)) {
@@ -15608,6 +15807,9 @@ var DataSourceApiImpl = class {
15608
15807
  this.actions = param.actions;
15609
15808
  this.treeApi = new TreeApiImpl({ ...param, dataSourceApi: this });
15610
15809
  }
15810
+ getPendingOperationPromise() {
15811
+ return this.pendingPromise;
15812
+ }
15611
15813
  batchOperation(operation) {
15612
15814
  if (!this.pendingPromise) {
15613
15815
  this.pendingPromise = new Promise((resolve) => {
@@ -15637,7 +15839,8 @@ var DataSourceApiImpl = class {
15637
15839
  return;
15638
15840
  }
15639
15841
  const currentCache = this.getState().cache;
15640
- let cache = currentCache ? DataSourceCache.clone(currentCache, { light: true }) : new DataSourceCache();
15842
+ const { isTree, nodesKey } = this.getState();
15843
+ let cache = currentCache ? DataSourceCache.clone(currentCache, { light: true }) : new DataSourceCache({ nodesKey: isTree ? nodesKey : void 0 });
15641
15844
  operations.forEach((operation) => {
15642
15845
  switch (operation.type) {
15643
15846
  case "update":
@@ -15658,12 +15861,21 @@ var DataSourceApiImpl = class {
15658
15861
  operation.nodePaths[index]
15659
15862
  );
15660
15863
  if (originalData) {
15661
- cache.updateNodePath(
15662
- operation.nodePaths[index],
15663
- data,
15664
- originalData,
15665
- operation.metadata
15666
- );
15864
+ if (typeof data === "function") {
15865
+ cache.updateChildren(
15866
+ operation.nodePaths[index],
15867
+ data,
15868
+ originalData,
15869
+ operation.metadata
15870
+ );
15871
+ } else {
15872
+ cache.updateNodePath(
15873
+ operation.nodePaths[index],
15874
+ data,
15875
+ originalData,
15876
+ operation.metadata
15877
+ );
15878
+ }
15667
15879
  }
15668
15880
  }
15669
15881
  });
@@ -15696,7 +15908,7 @@ var DataSourceApiImpl = class {
15696
15908
  if (nodePath) {
15697
15909
  operation.array.forEach((data) => {
15698
15910
  cache.insertNodePath(
15699
- nodePath,
15911
+ [...nodePath],
15700
15912
  data,
15701
15913
  position2,
15702
15914
  operation.metadata
@@ -15724,6 +15936,41 @@ var DataSourceApiImpl = class {
15724
15936
  flush() {
15725
15937
  return this.commit();
15726
15938
  }
15939
+ waitForNodePath(nodePath, options) {
15940
+ const state = this.getState();
15941
+ if (this.isNodePathAvailable(nodePath)) {
15942
+ return Promise.resolve(true);
15943
+ }
15944
+ const timeout = options?.timeout ?? DEFAULT_NODE_PATH_WAIT_TIMEOUT;
15945
+ const result = state.waitForNodePathPromises.get(nodePath);
15946
+ if (result) {
15947
+ return result.promise;
15948
+ }
15949
+ const timestamp = Date.now();
15950
+ let resolve = () => {
15951
+ };
15952
+ const promise = new Promise((res) => {
15953
+ let resolved;
15954
+ let timeoutId;
15955
+ resolve = (value) => {
15956
+ clearTimeout(timeoutId);
15957
+ resolved = value;
15958
+ state.waitForNodePathPromises.delete(nodePath);
15959
+ res(value);
15960
+ };
15961
+ timeoutId = setTimeout(() => {
15962
+ if (resolved === void 0) {
15963
+ resolve(false);
15964
+ }
15965
+ }, timeout);
15966
+ });
15967
+ state.waitForNodePathPromises.set(nodePath, {
15968
+ timestamp,
15969
+ promise,
15970
+ resolve
15971
+ });
15972
+ return promise;
15973
+ }
15727
15974
  commit() {
15728
15975
  this.commitOperations(this.pendingOperations);
15729
15976
  this.pendingOperations.length = 0;
@@ -16042,6 +16289,7 @@ function concludeReducer(params) {
16042
16289
  }
16043
16290
  const toPrimaryKey = state.toPrimaryKey;
16044
16291
  const nodesKey = state.nodesKey;
16292
+ const isTree = state.isTree;
16045
16293
  const getNodeChildren = nodesKey ? (node) => {
16046
16294
  return node[nodesKey];
16047
16295
  } : void 0;
@@ -16066,6 +16314,16 @@ function concludeReducer(params) {
16066
16314
  nodesKey
16067
16315
  }
16068
16316
  );
16317
+ if (isTree) {
16318
+ state.waitForNodePathPromises.visit(({ value }, keys) => {
16319
+ if (!value) {
16320
+ return;
16321
+ }
16322
+ if (state.indexer.getDataForNodePath(keys) !== void 0) {
16323
+ value.resolve(true);
16324
+ }
16325
+ });
16326
+ }
16069
16327
  }
16070
16328
  }
16071
16329
  if (cache) {
@@ -16087,7 +16345,6 @@ function concludeReducer(params) {
16087
16345
  const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray || cacheAffectedParts.sortInfo);
16088
16346
  const groupBy = state.groupBy;
16089
16347
  const pivotBy = state.pivotBy;
16090
- const isTree = state.isTree;
16091
16348
  const shouldGroup = !isTree && (groupBy.length > 0 || !!pivotBy);
16092
16349
  const shouldTree = isTree;
16093
16350
  const rowDisabledStateDepsChanged = haveDepsChanged(previousState, state, [
@@ -17170,6 +17427,7 @@ function initSetupState() {
17170
17427
  idToIndexMap: /* @__PURE__ */ new Map(),
17171
17428
  idToPathMap: /* @__PURE__ */ new Map(),
17172
17429
  pathToIndexMap: new DeepMap(),
17430
+ waitForNodePathPromises: new DeepMap(),
17173
17431
  getDataSourceMasterContextRef: { current: () => void 0 },
17174
17432
  // TODO: cleanup cache on unmount
17175
17433
  cache: void 0,
@@ -17242,6 +17500,7 @@ var cleanupDataSource = (state) => {
17242
17500
  };
17243
17501
  state.treeExpandState?.destroy();
17244
17502
  state.treePaths?.clear();
17503
+ state.waitForNodePathPromises.clear();
17245
17504
  state.pathToIndexMap?.clear();
17246
17505
  state.rowDisabledState?.destroy();
17247
17506
  state.groupRowsState?.destroy();
@@ -22198,7 +22457,7 @@ var useLicense = (licenseKey = "") => {
22198
22457
  }
22199
22458
  let valid2 = isValidLicense(licenseKey, {
22200
22459
  publishedAt: 1624970570587,
22201
- version: "6.0.13"
22460
+ version: "6.0.15"
22202
22461
  });
22203
22462
  if (!licenseKey && !valid2 && isInsidePlayground) {
22204
22463
  return true;