@infinite-table/infinite-react 6.0.14 → 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.d.ts +141 -3
- package/index.dev.js +314 -83
- package/index.dev.mjs +314 -83
- package/index.js +314 -83
- package/index.mjs +314 -83
- package/package.json +2 -2
package/index.dev.js
CHANGED
|
@@ -5423,7 +5423,7 @@ var Icon = (props) => {
|
|
|
5423
5423
|
// src/components/InfiniteTable/components/icons/IncludesOperatorIcon.tsx
|
|
5424
5424
|
var React17 = __toESM(require("react"));
|
|
5425
5425
|
var IncludesOperatorIcon = (props) => {
|
|
5426
|
-
return /* @__PURE__ */ React17.createElement(Icon, { ...props }, /* @__PURE__ */ React17.createElement("path", { d: "
|
|
5426
|
+
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" }));
|
|
5427
5427
|
};
|
|
5428
5428
|
|
|
5429
5429
|
// src/components/InfiniteTable/components/icons/EndsWithOperatorIcon.tsx
|
|
@@ -13980,6 +13980,19 @@ var Indexer = class {
|
|
|
13980
13980
|
item = { ...item, ...info.data };
|
|
13981
13981
|
arr2[i] = item;
|
|
13982
13982
|
}
|
|
13983
|
+
if (info.type === "update-children" && !deleted) {
|
|
13984
|
+
const children = info.children(
|
|
13985
|
+
item[nodesKey],
|
|
13986
|
+
item
|
|
13987
|
+
);
|
|
13988
|
+
item = { ...item };
|
|
13989
|
+
if (children !== void 0) {
|
|
13990
|
+
item[nodesKey] = children;
|
|
13991
|
+
} else {
|
|
13992
|
+
delete item[nodesKey];
|
|
13993
|
+
}
|
|
13994
|
+
arr2[i] = item;
|
|
13995
|
+
}
|
|
13983
13996
|
if (info.type === "insert") {
|
|
13984
13997
|
if (info.position === "before") {
|
|
13985
13998
|
arr2.splice(i, 0, info.data);
|
|
@@ -14279,7 +14292,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
14279
14292
|
// src/components/DataSource/DataSourceCache.ts
|
|
14280
14293
|
var CLEAR_SYMBOL = Symbol("CLEAR");
|
|
14281
14294
|
var DataSourceCache = class {
|
|
14282
|
-
constructor() {
|
|
14295
|
+
constructor(options) {
|
|
14283
14296
|
this.affectedFields = /* @__PURE__ */ new Set();
|
|
14284
14297
|
this.allFieldsAffected = false;
|
|
14285
14298
|
this.primaryKeyToData = /* @__PURE__ */ new Map();
|
|
@@ -14342,8 +14355,12 @@ var DataSourceCache = class {
|
|
|
14342
14355
|
};
|
|
14343
14356
|
this.update = (primaryKey, data, originalData, metadata) => {
|
|
14344
14357
|
if (!this.allFieldsAffected) {
|
|
14345
|
-
|
|
14346
|
-
|
|
14358
|
+
if (this.nodesKey && Array.isArray(data[this.nodesKey])) {
|
|
14359
|
+
this.allFieldsAffected = true;
|
|
14360
|
+
} else {
|
|
14361
|
+
const keys = Object.keys(data);
|
|
14362
|
+
keys.forEach((key) => this.affectedFields.add(key));
|
|
14363
|
+
}
|
|
14347
14364
|
}
|
|
14348
14365
|
const pk = primaryKey;
|
|
14349
14366
|
const value = this.primaryKeyToData.get(pk) || [];
|
|
@@ -14358,8 +14375,12 @@ var DataSourceCache = class {
|
|
|
14358
14375
|
};
|
|
14359
14376
|
this.updateNodePath = (nodePath, data, originalData, metadata) => {
|
|
14360
14377
|
if (!this.allFieldsAffected) {
|
|
14361
|
-
|
|
14362
|
-
|
|
14378
|
+
if (this.nodesKey && Array.isArray(data[this.nodesKey])) {
|
|
14379
|
+
this.allFieldsAffected = true;
|
|
14380
|
+
} else {
|
|
14381
|
+
const keys = Object.keys(data);
|
|
14382
|
+
keys.forEach((key) => this.affectedFields.add(key));
|
|
14383
|
+
}
|
|
14363
14384
|
}
|
|
14364
14385
|
const value = this.nodePathToData.get(nodePath) || [];
|
|
14365
14386
|
value.push({
|
|
@@ -14371,6 +14392,18 @@ var DataSourceCache = class {
|
|
|
14371
14392
|
});
|
|
14372
14393
|
this.nodePathToData.set(nodePath, value);
|
|
14373
14394
|
};
|
|
14395
|
+
this.updateChildren = (nodePath, children, originalData, metadata) => {
|
|
14396
|
+
this.allFieldsAffected = true;
|
|
14397
|
+
const value = this.nodePathToData.get(nodePath) || [];
|
|
14398
|
+
value.push({
|
|
14399
|
+
type: "update-children",
|
|
14400
|
+
nodePath,
|
|
14401
|
+
children,
|
|
14402
|
+
originalData,
|
|
14403
|
+
metadata
|
|
14404
|
+
});
|
|
14405
|
+
this.nodePathToData.set(nodePath, value);
|
|
14406
|
+
};
|
|
14374
14407
|
this.resetDataSource = (metadata) => {
|
|
14375
14408
|
this.clear();
|
|
14376
14409
|
this.allFieldsAffected = true;
|
|
@@ -14423,9 +14456,12 @@ var DataSourceCache = class {
|
|
|
14423
14456
|
this.getTreeMutationsArray = () => {
|
|
14424
14457
|
return Array.from(this.nodePathToData.values()).flat();
|
|
14425
14458
|
};
|
|
14459
|
+
this.nodesKey = options.nodesKey;
|
|
14426
14460
|
}
|
|
14427
14461
|
static clone(cache, { light = false } = {}) {
|
|
14428
|
-
const clone = new DataSourceCache(
|
|
14462
|
+
const clone = new DataSourceCache({
|
|
14463
|
+
nodesKey: cache.nodesKey
|
|
14464
|
+
});
|
|
14429
14465
|
clone.allFieldsAffected = cache.allFieldsAffected;
|
|
14430
14466
|
clone.affectedFields = new Set(cache.affectedFields);
|
|
14431
14467
|
clone.primaryKeyToData = light ? cache.primaryKeyToData : new Map(
|
|
@@ -15301,6 +15337,7 @@ var RowDisabledState = class extends BooleanCollectionState {
|
|
|
15301
15337
|
};
|
|
15302
15338
|
|
|
15303
15339
|
// src/components/DataSource/getDataSourceApi.ts
|
|
15340
|
+
var DEFAULT_NODE_PATH_WAIT_TIMEOUT = 1e3;
|
|
15304
15341
|
function getDataSourceApi(param) {
|
|
15305
15342
|
return new DataSourceApiImpl(param);
|
|
15306
15343
|
}
|
|
@@ -15364,15 +15401,20 @@ var DataSourceApiImpl = class {
|
|
|
15364
15401
|
const { indexer } = this.getState();
|
|
15365
15402
|
return indexer.getDataForPrimaryKey(id) ?? null;
|
|
15366
15403
|
};
|
|
15404
|
+
this.isNodePathAvailable = (nodePath) => {
|
|
15405
|
+
return this.getState().indexer.getDataForNodePath(nodePath) !== void 0;
|
|
15406
|
+
};
|
|
15367
15407
|
this.getDataByNodePath = (nodePath) => {
|
|
15368
15408
|
const { indexer } = this.getState();
|
|
15369
15409
|
const data = indexer.getDataForNodePath(nodePath);
|
|
15370
15410
|
if (!data) {
|
|
15371
|
-
|
|
15372
|
-
|
|
15373
|
-
|
|
15374
|
-
|
|
15375
|
-
|
|
15411
|
+
if (false) {
|
|
15412
|
+
console.warn(
|
|
15413
|
+
`getDataByNodePath: no data found for nodePath: "${nodePath.join(
|
|
15414
|
+
" / "
|
|
15415
|
+
)}"`
|
|
15416
|
+
);
|
|
15417
|
+
}
|
|
15376
15418
|
return null;
|
|
15377
15419
|
}
|
|
15378
15420
|
return data;
|
|
@@ -15432,25 +15474,84 @@ var DataSourceApiImpl = class {
|
|
|
15432
15474
|
}
|
|
15433
15475
|
return result;
|
|
15434
15476
|
};
|
|
15477
|
+
this.withWaitForNode = (nodePath, fn, options) => {
|
|
15478
|
+
const waitForNode = options?.waitForNode ?? true;
|
|
15479
|
+
if (waitForNode === true || typeof waitForNode === "number") {
|
|
15480
|
+
let timeout = waitForNode === true ? DEFAULT_NODE_PATH_WAIT_TIMEOUT : waitForNode;
|
|
15481
|
+
if (!isNaN(timeout)) {
|
|
15482
|
+
timeout = DEFAULT_NODE_PATH_WAIT_TIMEOUT;
|
|
15483
|
+
}
|
|
15484
|
+
return this.waitForNodePath(nodePath, { timeout }).then((okay) => {
|
|
15485
|
+
if (!okay) {
|
|
15486
|
+
const error2 = `Cannot find node path "${nodePath.join(
|
|
15487
|
+
"/"
|
|
15488
|
+
)}" (we waited for it ${timeout}ms)`;
|
|
15489
|
+
console.error(error2);
|
|
15490
|
+
return fn({
|
|
15491
|
+
error: error2,
|
|
15492
|
+
resolved: false
|
|
15493
|
+
});
|
|
15494
|
+
}
|
|
15495
|
+
return fn({
|
|
15496
|
+
resolved: true
|
|
15497
|
+
});
|
|
15498
|
+
});
|
|
15499
|
+
}
|
|
15500
|
+
const result = fn({
|
|
15501
|
+
resolved: void 0
|
|
15502
|
+
});
|
|
15503
|
+
return result instanceof Promise ? result : Promise.resolve(result);
|
|
15504
|
+
};
|
|
15435
15505
|
this.updateChildrenByNodePath = (childrenOrFn, nodePath, options) => {
|
|
15436
|
-
|
|
15437
|
-
if (data == null) {
|
|
15438
|
-
return Promise.resolve(null);
|
|
15439
|
-
}
|
|
15440
|
-
const nodesKey = this.getState().nodesKey;
|
|
15441
|
-
const dataChildren = data[nodesKey];
|
|
15442
|
-
const children = typeof childrenOrFn === "function" ? childrenOrFn(dataChildren, data) : childrenOrFn;
|
|
15443
|
-
return this.updateDataByNodePath(
|
|
15444
|
-
{
|
|
15445
|
-
...data,
|
|
15446
|
-
[nodesKey]: children
|
|
15447
|
-
},
|
|
15506
|
+
return this.withWaitForNode(
|
|
15448
15507
|
nodePath,
|
|
15508
|
+
({ error: error2 }) => {
|
|
15509
|
+
if (error2) {
|
|
15510
|
+
return false;
|
|
15511
|
+
}
|
|
15512
|
+
return this.updateChildrenByNodePath_Internal(
|
|
15513
|
+
childrenOrFn,
|
|
15514
|
+
nodePath,
|
|
15515
|
+
options
|
|
15516
|
+
);
|
|
15517
|
+
},
|
|
15518
|
+
options
|
|
15519
|
+
);
|
|
15520
|
+
};
|
|
15521
|
+
this.updateChildrenByNodePath_Internal = (childrenOrFn, nodePath, options) => {
|
|
15522
|
+
const children = typeof childrenOrFn === "function" ? childrenOrFn : () => childrenOrFn;
|
|
15523
|
+
return this.updateDataArrayByNodePath_Internal(
|
|
15524
|
+
[
|
|
15525
|
+
{
|
|
15526
|
+
nodePath,
|
|
15527
|
+
children
|
|
15528
|
+
}
|
|
15529
|
+
],
|
|
15449
15530
|
options
|
|
15450
15531
|
);
|
|
15451
15532
|
};
|
|
15452
15533
|
this.updateDataByNodePath = (data, nodePath, options) => {
|
|
15453
|
-
|
|
15534
|
+
if (!this.isNodePathAvailable(nodePath)) {
|
|
15535
|
+
return this.withWaitForNode(
|
|
15536
|
+
nodePath,
|
|
15537
|
+
({ error: error2 }) => {
|
|
15538
|
+
if (error2) {
|
|
15539
|
+
return false;
|
|
15540
|
+
}
|
|
15541
|
+
return this.updateDataArrayByNodePath_Internal(
|
|
15542
|
+
[
|
|
15543
|
+
{
|
|
15544
|
+
data,
|
|
15545
|
+
nodePath
|
|
15546
|
+
}
|
|
15547
|
+
],
|
|
15548
|
+
options
|
|
15549
|
+
);
|
|
15550
|
+
},
|
|
15551
|
+
options
|
|
15552
|
+
);
|
|
15553
|
+
}
|
|
15554
|
+
return this.updateDataArrayByNodePath_Internal(
|
|
15454
15555
|
[
|
|
15455
15556
|
{
|
|
15456
15557
|
data,
|
|
@@ -15461,10 +15562,31 @@ var DataSourceApiImpl = class {
|
|
|
15461
15562
|
);
|
|
15462
15563
|
};
|
|
15463
15564
|
this.updateDataArrayByNodePath = (updateInfo, options) => {
|
|
15565
|
+
if (options && typeof options.waitForNode !== "undefined" && !options.waitForNode) {
|
|
15566
|
+
return this.updateDataArrayByNodePath_Internal(updateInfo, options);
|
|
15567
|
+
}
|
|
15568
|
+
const allNodePaths = updateInfo.map((info) => info.nodePath);
|
|
15569
|
+
const promiseWithAll = Promise.allSettled(
|
|
15570
|
+
allNodePaths.map((nodePath) => {
|
|
15571
|
+
return this.withWaitForNode(nodePath, ({ error: error2 }) => !error2, options);
|
|
15572
|
+
})
|
|
15573
|
+
);
|
|
15574
|
+
return promiseWithAll.then((allGood) => {
|
|
15575
|
+
if (!allGood.every(Boolean)) {
|
|
15576
|
+
return false;
|
|
15577
|
+
}
|
|
15578
|
+
return this.updateDataArrayByNodePath_Internal(updateInfo, options);
|
|
15579
|
+
});
|
|
15580
|
+
};
|
|
15581
|
+
this.updateDataArrayByNodePath_Internal = (updateInfo, options) => {
|
|
15464
15582
|
const data = [];
|
|
15465
15583
|
const nodePaths = [];
|
|
15466
15584
|
updateInfo.forEach((info) => {
|
|
15467
|
-
|
|
15585
|
+
if (info.data) {
|
|
15586
|
+
data.push(info.data);
|
|
15587
|
+
} else if (info.children) {
|
|
15588
|
+
data.push(info.children);
|
|
15589
|
+
}
|
|
15468
15590
|
nodePaths.push(info.nodePath);
|
|
15469
15591
|
});
|
|
15470
15592
|
const result = this.batchOperation({
|
|
@@ -15494,67 +15616,39 @@ var DataSourceApiImpl = class {
|
|
|
15494
15616
|
return result;
|
|
15495
15617
|
};
|
|
15496
15618
|
this.removeDataByNodePath = (nodePath, options) => {
|
|
15497
|
-
|
|
15498
|
-
type: "delete",
|
|
15499
|
-
nodePaths: [nodePath],
|
|
15500
|
-
metadata: options?.metadata
|
|
15501
|
-
});
|
|
15502
|
-
if (options?.flush) {
|
|
15503
|
-
this.commit();
|
|
15504
|
-
}
|
|
15505
|
-
return result;
|
|
15619
|
+
return this.batchDeleteNodePaths([nodePath], options);
|
|
15506
15620
|
};
|
|
15507
15621
|
this.removeData = (data, options) => {
|
|
15508
15622
|
const isTree = this.getState().isTree;
|
|
15509
|
-
|
|
15510
|
-
|
|
15511
|
-
|
|
15512
|
-
const result = primaryKeys ? this.batchOperation({
|
|
15513
|
-
type: "delete",
|
|
15514
|
-
primaryKeys,
|
|
15515
|
-
metadata: options?.metadata
|
|
15516
|
-
}) : this.batchOperation({
|
|
15517
|
-
type: "delete",
|
|
15518
|
-
nodePaths: nodePaths || [],
|
|
15519
|
-
metadata: options?.metadata
|
|
15520
|
-
});
|
|
15521
|
-
if (options?.flush) {
|
|
15522
|
-
this.commit();
|
|
15623
|
+
if (isTree) {
|
|
15624
|
+
const nodePath = this.getNodePathById(this.toPrimaryKey(data));
|
|
15625
|
+
return this.removeDataByNodePath(nodePath, options);
|
|
15523
15626
|
}
|
|
15524
|
-
return
|
|
15627
|
+
return this.batchDeletePrimaryKeys([this.toPrimaryKey(data)], options);
|
|
15525
15628
|
};
|
|
15526
15629
|
this.removeDataArrayByPrimaryKeys = (ids, options) => {
|
|
15527
15630
|
const isTree = this.getState().isTree;
|
|
15528
|
-
|
|
15529
|
-
|
|
15530
|
-
|
|
15531
|
-
|
|
15631
|
+
if (isTree) {
|
|
15632
|
+
const nodePaths = ids.map((id) => this.getNodePathById(id) || []);
|
|
15633
|
+
return this.batchDeleteNodePaths(nodePaths, options);
|
|
15634
|
+
}
|
|
15635
|
+
return this.batchDeletePrimaryKeys(ids, options);
|
|
15636
|
+
};
|
|
15637
|
+
this.batchDeleteNodePaths = (nodePaths, options) => {
|
|
15638
|
+
const result = this.batchOperation({
|
|
15532
15639
|
type: "delete",
|
|
15533
15640
|
nodePaths: nodePaths || [],
|
|
15534
15641
|
metadata: options?.metadata
|
|
15535
|
-
}) : this.batchOperation({
|
|
15536
|
-
type: "delete",
|
|
15537
|
-
primaryKeys: ids,
|
|
15538
|
-
metadata: options?.metadata
|
|
15539
15642
|
});
|
|
15540
15643
|
if (options?.flush) {
|
|
15541
15644
|
this.commit();
|
|
15542
15645
|
}
|
|
15543
15646
|
return result;
|
|
15544
15647
|
};
|
|
15545
|
-
this.
|
|
15546
|
-
const
|
|
15547
|
-
const nodePaths = isTree ? data.map((d) => {
|
|
15548
|
-
return this.getNodePathById(this.toPrimaryKey(d)) || [];
|
|
15549
|
-
}) : null;
|
|
15550
|
-
const primaryKeys = !isTree ? data.map(this.toPrimaryKey) : void 0;
|
|
15551
|
-
const result = isTree ? this.batchOperation({
|
|
15552
|
-
type: "delete",
|
|
15553
|
-
nodePaths: nodePaths || [],
|
|
15554
|
-
metadata: options?.metadata
|
|
15555
|
-
}) : this.batchOperation({
|
|
15648
|
+
this.batchDeletePrimaryKeys = (primaryKeys, options) => {
|
|
15649
|
+
const result = this.batchOperation({
|
|
15556
15650
|
type: "delete",
|
|
15557
|
-
primaryKeys
|
|
15651
|
+
primaryKeys,
|
|
15558
15652
|
metadata: options?.metadata
|
|
15559
15653
|
});
|
|
15560
15654
|
if (options?.flush) {
|
|
@@ -15562,6 +15656,17 @@ var DataSourceApiImpl = class {
|
|
|
15562
15656
|
}
|
|
15563
15657
|
return result;
|
|
15564
15658
|
};
|
|
15659
|
+
this.removeDataArray = (data, options) => {
|
|
15660
|
+
const isTree = this.getState().isTree;
|
|
15661
|
+
if (isTree) {
|
|
15662
|
+
const nodePaths = data.map((d) => {
|
|
15663
|
+
return this.getNodePathById(this.toPrimaryKey(d)) || [];
|
|
15664
|
+
});
|
|
15665
|
+
return this.batchDeleteNodePaths(nodePaths, options);
|
|
15666
|
+
}
|
|
15667
|
+
const primaryKeys = data.map(this.toPrimaryKey);
|
|
15668
|
+
return this.batchDeletePrimaryKeys(primaryKeys, options);
|
|
15669
|
+
};
|
|
15565
15670
|
this.addData = (data, options) => {
|
|
15566
15671
|
return this.addDataArray([data], options);
|
|
15567
15672
|
};
|
|
@@ -15575,9 +15680,33 @@ var DataSourceApiImpl = class {
|
|
|
15575
15680
|
return this.insertDataArray([data], options);
|
|
15576
15681
|
};
|
|
15577
15682
|
this.insertDataArray = (data, options) => {
|
|
15683
|
+
const isTree = this.getState().isTree;
|
|
15578
15684
|
let position2 = "before";
|
|
15579
15685
|
let primaryKey = void 0;
|
|
15580
15686
|
let nodePath = options.nodePath;
|
|
15687
|
+
if (isTree && nodePath?.length) {
|
|
15688
|
+
return this.withWaitForNode(
|
|
15689
|
+
nodePath,
|
|
15690
|
+
({ error: error2 }) => {
|
|
15691
|
+
if (error2) {
|
|
15692
|
+
return false;
|
|
15693
|
+
}
|
|
15694
|
+
if (options.position === "before" || options.position === "after") {
|
|
15695
|
+
return this.batchTreeInsert(
|
|
15696
|
+
data,
|
|
15697
|
+
options.position,
|
|
15698
|
+
nodePath,
|
|
15699
|
+
options
|
|
15700
|
+
);
|
|
15701
|
+
}
|
|
15702
|
+
const newChildren = (childrenOfNode) => {
|
|
15703
|
+
return options.position === "start" ? [...data, ...childrenOfNode || []] : [...childrenOfNode || [], ...data];
|
|
15704
|
+
};
|
|
15705
|
+
return this.updateChildrenByNodePath(newChildren, nodePath, options);
|
|
15706
|
+
},
|
|
15707
|
+
options
|
|
15708
|
+
);
|
|
15709
|
+
}
|
|
15581
15710
|
if (options.position === "before" || options.position === "after") {
|
|
15582
15711
|
position2 = options.position;
|
|
15583
15712
|
primaryKey = options.primaryKey;
|
|
@@ -15585,13 +15714,20 @@ var DataSourceApiImpl = class {
|
|
|
15585
15714
|
const arr = this.getOriginalDataArray();
|
|
15586
15715
|
if (options.position === "start") {
|
|
15587
15716
|
position2 = "before";
|
|
15588
|
-
|
|
15717
|
+
if (!arr.length) {
|
|
15718
|
+
primaryKey = void 0;
|
|
15719
|
+
} else {
|
|
15720
|
+
primaryKey = this.toPrimaryKey(arr[0]);
|
|
15721
|
+
}
|
|
15589
15722
|
} else {
|
|
15590
15723
|
position2 = "after";
|
|
15591
|
-
|
|
15724
|
+
if (!arr.length) {
|
|
15725
|
+
primaryKey = void 0;
|
|
15726
|
+
} else {
|
|
15727
|
+
primaryKey = this.toPrimaryKey(arr[arr.length - 1]);
|
|
15728
|
+
}
|
|
15592
15729
|
}
|
|
15593
15730
|
}
|
|
15594
|
-
const isTree = this.getState().isTree;
|
|
15595
15731
|
const result = isTree ? this.batchOperation({
|
|
15596
15732
|
type: "insert",
|
|
15597
15733
|
array: data,
|
|
@@ -15611,6 +15747,41 @@ var DataSourceApiImpl = class {
|
|
|
15611
15747
|
}
|
|
15612
15748
|
return result;
|
|
15613
15749
|
};
|
|
15750
|
+
this.batchTreeInsert = (data, position2, nodePath, options) => {
|
|
15751
|
+
if (nodePath.length && !this.isNodePathAvailable(nodePath)) {
|
|
15752
|
+
return this.withWaitForNode(
|
|
15753
|
+
nodePath,
|
|
15754
|
+
({ error: error2 }) => {
|
|
15755
|
+
if (error2) {
|
|
15756
|
+
return false;
|
|
15757
|
+
}
|
|
15758
|
+
const result2 = this.batchOperation({
|
|
15759
|
+
type: "insert",
|
|
15760
|
+
array: data,
|
|
15761
|
+
position: position2,
|
|
15762
|
+
metadata: options?.metadata,
|
|
15763
|
+
nodePath
|
|
15764
|
+
});
|
|
15765
|
+
if (options?.flush) {
|
|
15766
|
+
this.commit();
|
|
15767
|
+
}
|
|
15768
|
+
return result2;
|
|
15769
|
+
},
|
|
15770
|
+
options
|
|
15771
|
+
);
|
|
15772
|
+
}
|
|
15773
|
+
const result = this.batchOperation({
|
|
15774
|
+
type: "insert",
|
|
15775
|
+
array: data,
|
|
15776
|
+
position: position2,
|
|
15777
|
+
metadata: options?.metadata,
|
|
15778
|
+
nodePath
|
|
15779
|
+
});
|
|
15780
|
+
if (options?.flush) {
|
|
15781
|
+
this.commit();
|
|
15782
|
+
}
|
|
15783
|
+
return result;
|
|
15784
|
+
};
|
|
15614
15785
|
this.setSortInfo = (sortInfo) => {
|
|
15615
15786
|
const multiSort = this.getState().multiSort;
|
|
15616
15787
|
if (Array.isArray(sortInfo)) {
|
|
@@ -15687,6 +15858,9 @@ var DataSourceApiImpl = class {
|
|
|
15687
15858
|
this.actions = param.actions;
|
|
15688
15859
|
this.treeApi = new TreeApiImpl({ ...param, dataSourceApi: this });
|
|
15689
15860
|
}
|
|
15861
|
+
getPendingOperationPromise() {
|
|
15862
|
+
return this.pendingPromise;
|
|
15863
|
+
}
|
|
15690
15864
|
batchOperation(operation) {
|
|
15691
15865
|
if (!this.pendingPromise) {
|
|
15692
15866
|
this.pendingPromise = new Promise((resolve) => {
|
|
@@ -15716,7 +15890,8 @@ var DataSourceApiImpl = class {
|
|
|
15716
15890
|
return;
|
|
15717
15891
|
}
|
|
15718
15892
|
const currentCache = this.getState().cache;
|
|
15719
|
-
|
|
15893
|
+
const { isTree, nodesKey } = this.getState();
|
|
15894
|
+
let cache = currentCache ? DataSourceCache.clone(currentCache, { light: true }) : new DataSourceCache({ nodesKey: isTree ? nodesKey : void 0 });
|
|
15720
15895
|
operations.forEach((operation) => {
|
|
15721
15896
|
switch (operation.type) {
|
|
15722
15897
|
case "update":
|
|
@@ -15737,12 +15912,21 @@ var DataSourceApiImpl = class {
|
|
|
15737
15912
|
operation.nodePaths[index]
|
|
15738
15913
|
);
|
|
15739
15914
|
if (originalData) {
|
|
15740
|
-
|
|
15741
|
-
|
|
15742
|
-
|
|
15743
|
-
|
|
15744
|
-
|
|
15745
|
-
|
|
15915
|
+
if (typeof data === "function") {
|
|
15916
|
+
cache.updateChildren(
|
|
15917
|
+
operation.nodePaths[index],
|
|
15918
|
+
data,
|
|
15919
|
+
originalData,
|
|
15920
|
+
operation.metadata
|
|
15921
|
+
);
|
|
15922
|
+
} else {
|
|
15923
|
+
cache.updateNodePath(
|
|
15924
|
+
operation.nodePaths[index],
|
|
15925
|
+
data,
|
|
15926
|
+
originalData,
|
|
15927
|
+
operation.metadata
|
|
15928
|
+
);
|
|
15929
|
+
}
|
|
15746
15930
|
}
|
|
15747
15931
|
}
|
|
15748
15932
|
});
|
|
@@ -15775,7 +15959,7 @@ var DataSourceApiImpl = class {
|
|
|
15775
15959
|
if (nodePath) {
|
|
15776
15960
|
operation.array.forEach((data) => {
|
|
15777
15961
|
cache.insertNodePath(
|
|
15778
|
-
nodePath,
|
|
15962
|
+
[...nodePath],
|
|
15779
15963
|
data,
|
|
15780
15964
|
position2,
|
|
15781
15965
|
operation.metadata
|
|
@@ -15803,6 +15987,41 @@ var DataSourceApiImpl = class {
|
|
|
15803
15987
|
flush() {
|
|
15804
15988
|
return this.commit();
|
|
15805
15989
|
}
|
|
15990
|
+
waitForNodePath(nodePath, options) {
|
|
15991
|
+
const state = this.getState();
|
|
15992
|
+
if (this.isNodePathAvailable(nodePath)) {
|
|
15993
|
+
return Promise.resolve(true);
|
|
15994
|
+
}
|
|
15995
|
+
const timeout = options?.timeout ?? DEFAULT_NODE_PATH_WAIT_TIMEOUT;
|
|
15996
|
+
const result = state.waitForNodePathPromises.get(nodePath);
|
|
15997
|
+
if (result) {
|
|
15998
|
+
return result.promise;
|
|
15999
|
+
}
|
|
16000
|
+
const timestamp = Date.now();
|
|
16001
|
+
let resolve = () => {
|
|
16002
|
+
};
|
|
16003
|
+
const promise = new Promise((res) => {
|
|
16004
|
+
let resolved;
|
|
16005
|
+
let timeoutId;
|
|
16006
|
+
resolve = (value) => {
|
|
16007
|
+
clearTimeout(timeoutId);
|
|
16008
|
+
resolved = value;
|
|
16009
|
+
state.waitForNodePathPromises.delete(nodePath);
|
|
16010
|
+
res(value);
|
|
16011
|
+
};
|
|
16012
|
+
timeoutId = setTimeout(() => {
|
|
16013
|
+
if (resolved === void 0) {
|
|
16014
|
+
resolve(false);
|
|
16015
|
+
}
|
|
16016
|
+
}, timeout);
|
|
16017
|
+
});
|
|
16018
|
+
state.waitForNodePathPromises.set(nodePath, {
|
|
16019
|
+
timestamp,
|
|
16020
|
+
promise,
|
|
16021
|
+
resolve
|
|
16022
|
+
});
|
|
16023
|
+
return promise;
|
|
16024
|
+
}
|
|
15806
16025
|
commit() {
|
|
15807
16026
|
this.commitOperations(this.pendingOperations);
|
|
15808
16027
|
this.pendingOperations.length = 0;
|
|
@@ -16121,6 +16340,7 @@ function concludeReducer(params) {
|
|
|
16121
16340
|
}
|
|
16122
16341
|
const toPrimaryKey = state.toPrimaryKey;
|
|
16123
16342
|
const nodesKey = state.nodesKey;
|
|
16343
|
+
const isTree = state.isTree;
|
|
16124
16344
|
const getNodeChildren = nodesKey ? (node) => {
|
|
16125
16345
|
return node[nodesKey];
|
|
16126
16346
|
} : void 0;
|
|
@@ -16145,6 +16365,16 @@ function concludeReducer(params) {
|
|
|
16145
16365
|
nodesKey
|
|
16146
16366
|
}
|
|
16147
16367
|
);
|
|
16368
|
+
if (isTree) {
|
|
16369
|
+
state.waitForNodePathPromises.visit(({ value }, keys) => {
|
|
16370
|
+
if (!value) {
|
|
16371
|
+
return;
|
|
16372
|
+
}
|
|
16373
|
+
if (state.indexer.getDataForNodePath(keys) !== void 0) {
|
|
16374
|
+
value.resolve(true);
|
|
16375
|
+
}
|
|
16376
|
+
});
|
|
16377
|
+
}
|
|
16148
16378
|
}
|
|
16149
16379
|
}
|
|
16150
16380
|
if (cache) {
|
|
@@ -16166,7 +16396,6 @@ function concludeReducer(params) {
|
|
|
16166
16396
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray || cacheAffectedParts.sortInfo);
|
|
16167
16397
|
const groupBy = state.groupBy;
|
|
16168
16398
|
const pivotBy = state.pivotBy;
|
|
16169
|
-
const isTree = state.isTree;
|
|
16170
16399
|
const shouldGroup = !isTree && (groupBy.length > 0 || !!pivotBy);
|
|
16171
16400
|
const shouldTree = isTree;
|
|
16172
16401
|
const rowDisabledStateDepsChanged = haveDepsChanged(previousState, state, [
|
|
@@ -17249,6 +17478,7 @@ function initSetupState() {
|
|
|
17249
17478
|
idToIndexMap: /* @__PURE__ */ new Map(),
|
|
17250
17479
|
idToPathMap: /* @__PURE__ */ new Map(),
|
|
17251
17480
|
pathToIndexMap: new DeepMap(),
|
|
17481
|
+
waitForNodePathPromises: new DeepMap(),
|
|
17252
17482
|
getDataSourceMasterContextRef: { current: () => void 0 },
|
|
17253
17483
|
// TODO: cleanup cache on unmount
|
|
17254
17484
|
cache: void 0,
|
|
@@ -17321,6 +17551,7 @@ var cleanupDataSource = (state) => {
|
|
|
17321
17551
|
};
|
|
17322
17552
|
state.treeExpandState?.destroy();
|
|
17323
17553
|
state.treePaths?.clear();
|
|
17554
|
+
state.waitForNodePathPromises.clear();
|
|
17324
17555
|
state.pathToIndexMap?.clear();
|
|
17325
17556
|
state.rowDisabledState?.destroy();
|
|
17326
17557
|
state.groupRowsState?.destroy();
|
|
@@ -22268,7 +22499,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
22268
22499
|
}
|
|
22269
22500
|
let valid2 = isValidLicense(licenseKey, {
|
|
22270
22501
|
publishedAt: 1624970570587,
|
|
22271
|
-
version: "6.0.
|
|
22502
|
+
version: "6.0.15"
|
|
22272
22503
|
});
|
|
22273
22504
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
22274
22505
|
return true;
|