@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.d.ts +143 -3
- package/index.dev.js +352 -93
- package/index.dev.mjs +352 -93
- package/index.js +352 -93
- package/index.mjs +352 -93
- 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
|
|
@@ -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.
|
|
13971
|
+
this.removeNodePath(nodePath, options);
|
|
13936
13972
|
} else {
|
|
13937
|
-
this.
|
|
13973
|
+
this.remove(pk);
|
|
13938
13974
|
}
|
|
13939
13975
|
deleted = true;
|
|
13940
13976
|
arr2.splice(i, 1);
|
|
@@ -13944,14 +13980,20 @@ var Indexer = class {
|
|
|
13944
13980
|
item = { ...item, ...info.data };
|
|
13945
13981
|
arr2[i] = item;
|
|
13946
13982
|
}
|
|
13947
|
-
if (info.type === "
|
|
13948
|
-
const
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
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;
|
|
13952
13991
|
} else {
|
|
13953
|
-
|
|
13992
|
+
delete item[nodesKey];
|
|
13954
13993
|
}
|
|
13994
|
+
arr2[i] = item;
|
|
13995
|
+
}
|
|
13996
|
+
if (info.type === "insert") {
|
|
13955
13997
|
if (info.position === "before") {
|
|
13956
13998
|
arr2.splice(i, 0, info.data);
|
|
13957
13999
|
i--;
|
|
@@ -13968,6 +14010,7 @@ var Indexer = class {
|
|
|
13968
14010
|
}
|
|
13969
14011
|
if (!deleted) {
|
|
13970
14012
|
if (isTreeModeForNode) {
|
|
14013
|
+
this.addNodePath(nodePath, item);
|
|
13971
14014
|
const isLeaf = isLeafNode(item);
|
|
13972
14015
|
let children = isLeaf ? null : getNodeChildren(item);
|
|
13973
14016
|
if (!isLeaf && Array.isArray(children)) {
|
|
@@ -13978,7 +14021,6 @@ var Indexer = class {
|
|
|
13978
14021
|
indexArray(children, parentPath);
|
|
13979
14022
|
parentPath.pop();
|
|
13980
14023
|
}
|
|
13981
|
-
this.addNodePath(nodePath, item, options);
|
|
13982
14024
|
} else {
|
|
13983
14025
|
this.add(pk, item);
|
|
13984
14026
|
}
|
|
@@ -14250,7 +14292,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
14250
14292
|
// src/components/DataSource/DataSourceCache.ts
|
|
14251
14293
|
var CLEAR_SYMBOL = Symbol("CLEAR");
|
|
14252
14294
|
var DataSourceCache = class {
|
|
14253
|
-
constructor() {
|
|
14295
|
+
constructor(options) {
|
|
14254
14296
|
this.affectedFields = /* @__PURE__ */ new Set();
|
|
14255
14297
|
this.allFieldsAffected = false;
|
|
14256
14298
|
this.primaryKeyToData = /* @__PURE__ */ new Map();
|
|
@@ -14313,8 +14355,12 @@ var DataSourceCache = class {
|
|
|
14313
14355
|
};
|
|
14314
14356
|
this.update = (primaryKey, data, originalData, metadata) => {
|
|
14315
14357
|
if (!this.allFieldsAffected) {
|
|
14316
|
-
|
|
14317
|
-
|
|
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
|
+
}
|
|
14318
14364
|
}
|
|
14319
14365
|
const pk = primaryKey;
|
|
14320
14366
|
const value = this.primaryKeyToData.get(pk) || [];
|
|
@@ -14329,8 +14375,12 @@ var DataSourceCache = class {
|
|
|
14329
14375
|
};
|
|
14330
14376
|
this.updateNodePath = (nodePath, data, originalData, metadata) => {
|
|
14331
14377
|
if (!this.allFieldsAffected) {
|
|
14332
|
-
|
|
14333
|
-
|
|
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
|
+
}
|
|
14334
14384
|
}
|
|
14335
14385
|
const value = this.nodePathToData.get(nodePath) || [];
|
|
14336
14386
|
value.push({
|
|
@@ -14342,6 +14392,18 @@ var DataSourceCache = class {
|
|
|
14342
14392
|
});
|
|
14343
14393
|
this.nodePathToData.set(nodePath, value);
|
|
14344
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
|
+
};
|
|
14345
14407
|
this.resetDataSource = (metadata) => {
|
|
14346
14408
|
this.clear();
|
|
14347
14409
|
this.allFieldsAffected = true;
|
|
@@ -14394,9 +14456,12 @@ var DataSourceCache = class {
|
|
|
14394
14456
|
this.getTreeMutationsArray = () => {
|
|
14395
14457
|
return Array.from(this.nodePathToData.values()).flat();
|
|
14396
14458
|
};
|
|
14459
|
+
this.nodesKey = options.nodesKey;
|
|
14397
14460
|
}
|
|
14398
14461
|
static clone(cache, { light = false } = {}) {
|
|
14399
|
-
const clone = new DataSourceCache(
|
|
14462
|
+
const clone = new DataSourceCache({
|
|
14463
|
+
nodesKey: cache.nodesKey
|
|
14464
|
+
});
|
|
14400
14465
|
clone.allFieldsAffected = cache.allFieldsAffected;
|
|
14401
14466
|
clone.affectedFields = new Set(cache.affectedFields);
|
|
14402
14467
|
clone.primaryKeyToData = light ? cache.primaryKeyToData : new Map(
|
|
@@ -15272,6 +15337,7 @@ var RowDisabledState = class extends BooleanCollectionState {
|
|
|
15272
15337
|
};
|
|
15273
15338
|
|
|
15274
15339
|
// src/components/DataSource/getDataSourceApi.ts
|
|
15340
|
+
var DEFAULT_NODE_PATH_WAIT_TIMEOUT = 1e3;
|
|
15275
15341
|
function getDataSourceApi(param) {
|
|
15276
15342
|
return new DataSourceApiImpl(param);
|
|
15277
15343
|
}
|
|
@@ -15335,15 +15401,20 @@ var DataSourceApiImpl = class {
|
|
|
15335
15401
|
const { indexer } = this.getState();
|
|
15336
15402
|
return indexer.getDataForPrimaryKey(id) ?? null;
|
|
15337
15403
|
};
|
|
15404
|
+
this.isNodePathAvailable = (nodePath) => {
|
|
15405
|
+
return this.getState().indexer.getDataForNodePath(nodePath) !== void 0;
|
|
15406
|
+
};
|
|
15338
15407
|
this.getDataByNodePath = (nodePath) => {
|
|
15339
15408
|
const { indexer } = this.getState();
|
|
15340
15409
|
const data = indexer.getDataForNodePath(nodePath);
|
|
15341
15410
|
if (!data) {
|
|
15342
|
-
|
|
15343
|
-
|
|
15344
|
-
|
|
15345
|
-
|
|
15346
|
-
|
|
15411
|
+
if (false) {
|
|
15412
|
+
console.warn(
|
|
15413
|
+
`getDataByNodePath: no data found for nodePath: "${nodePath.join(
|
|
15414
|
+
" / "
|
|
15415
|
+
)}"`
|
|
15416
|
+
);
|
|
15417
|
+
}
|
|
15347
15418
|
return null;
|
|
15348
15419
|
}
|
|
15349
15420
|
return data;
|
|
@@ -15403,26 +15474,84 @@ var DataSourceApiImpl = class {
|
|
|
15403
15474
|
}
|
|
15404
15475
|
return result;
|
|
15405
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
|
+
};
|
|
15406
15505
|
this.updateChildrenByNodePath = (childrenOrFn, nodePath, options) => {
|
|
15407
|
-
|
|
15408
|
-
if (data == null) {
|
|
15409
|
-
return Promise.resolve(null);
|
|
15410
|
-
}
|
|
15411
|
-
const nodesKey = this.getState().nodesKey;
|
|
15412
|
-
const dataChildren = data[nodesKey];
|
|
15413
|
-
debugger;
|
|
15414
|
-
const children = typeof childrenOrFn === "function" ? childrenOrFn(dataChildren, data) : childrenOrFn;
|
|
15415
|
-
return this.updateDataByNodePath(
|
|
15416
|
-
{
|
|
15417
|
-
...data,
|
|
15418
|
-
[nodesKey]: children
|
|
15419
|
-
},
|
|
15506
|
+
return this.withWaitForNode(
|
|
15420
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
|
+
],
|
|
15421
15530
|
options
|
|
15422
15531
|
);
|
|
15423
15532
|
};
|
|
15424
15533
|
this.updateDataByNodePath = (data, nodePath, options) => {
|
|
15425
|
-
|
|
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(
|
|
15426
15555
|
[
|
|
15427
15556
|
{
|
|
15428
15557
|
data,
|
|
@@ -15433,10 +15562,31 @@ var DataSourceApiImpl = class {
|
|
|
15433
15562
|
);
|
|
15434
15563
|
};
|
|
15435
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) => {
|
|
15436
15582
|
const data = [];
|
|
15437
15583
|
const nodePaths = [];
|
|
15438
15584
|
updateInfo.forEach((info) => {
|
|
15439
|
-
|
|
15585
|
+
if (info.data) {
|
|
15586
|
+
data.push(info.data);
|
|
15587
|
+
} else if (info.children) {
|
|
15588
|
+
data.push(info.children);
|
|
15589
|
+
}
|
|
15440
15590
|
nodePaths.push(info.nodePath);
|
|
15441
15591
|
});
|
|
15442
15592
|
const result = this.batchOperation({
|
|
@@ -15466,67 +15616,39 @@ var DataSourceApiImpl = class {
|
|
|
15466
15616
|
return result;
|
|
15467
15617
|
};
|
|
15468
15618
|
this.removeDataByNodePath = (nodePath, options) => {
|
|
15469
|
-
|
|
15470
|
-
type: "delete",
|
|
15471
|
-
nodePaths: [nodePath],
|
|
15472
|
-
metadata: options?.metadata
|
|
15473
|
-
});
|
|
15474
|
-
if (options?.flush) {
|
|
15475
|
-
this.commit();
|
|
15476
|
-
}
|
|
15477
|
-
return result;
|
|
15619
|
+
return this.batchDeleteNodePaths([nodePath], options);
|
|
15478
15620
|
};
|
|
15479
15621
|
this.removeData = (data, options) => {
|
|
15480
15622
|
const isTree = this.getState().isTree;
|
|
15481
|
-
|
|
15482
|
-
|
|
15483
|
-
|
|
15484
|
-
const result = primaryKeys ? this.batchOperation({
|
|
15485
|
-
type: "delete",
|
|
15486
|
-
primaryKeys,
|
|
15487
|
-
metadata: options?.metadata
|
|
15488
|
-
}) : this.batchOperation({
|
|
15489
|
-
type: "delete",
|
|
15490
|
-
nodePaths: nodePaths || [],
|
|
15491
|
-
metadata: options?.metadata
|
|
15492
|
-
});
|
|
15493
|
-
if (options?.flush) {
|
|
15494
|
-
this.commit();
|
|
15623
|
+
if (isTree) {
|
|
15624
|
+
const nodePath = this.getNodePathById(this.toPrimaryKey(data));
|
|
15625
|
+
return this.removeDataByNodePath(nodePath, options);
|
|
15495
15626
|
}
|
|
15496
|
-
return
|
|
15627
|
+
return this.batchDeletePrimaryKeys([this.toPrimaryKey(data)], options);
|
|
15497
15628
|
};
|
|
15498
15629
|
this.removeDataArrayByPrimaryKeys = (ids, options) => {
|
|
15499
15630
|
const isTree = this.getState().isTree;
|
|
15500
|
-
|
|
15501
|
-
|
|
15502
|
-
|
|
15503
|
-
|
|
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({
|
|
15504
15639
|
type: "delete",
|
|
15505
15640
|
nodePaths: nodePaths || [],
|
|
15506
15641
|
metadata: options?.metadata
|
|
15507
|
-
}) : this.batchOperation({
|
|
15508
|
-
type: "delete",
|
|
15509
|
-
primaryKeys: ids,
|
|
15510
|
-
metadata: options?.metadata
|
|
15511
15642
|
});
|
|
15512
15643
|
if (options?.flush) {
|
|
15513
15644
|
this.commit();
|
|
15514
15645
|
}
|
|
15515
15646
|
return result;
|
|
15516
15647
|
};
|
|
15517
|
-
this.
|
|
15518
|
-
const
|
|
15519
|
-
const nodePaths = isTree ? data.map((d) => {
|
|
15520
|
-
return this.getNodePathById(this.toPrimaryKey(d)) || [];
|
|
15521
|
-
}) : null;
|
|
15522
|
-
const primaryKeys = !isTree ? data.map(this.toPrimaryKey) : void 0;
|
|
15523
|
-
const result = isTree ? this.batchOperation({
|
|
15524
|
-
type: "delete",
|
|
15525
|
-
nodePaths: nodePaths || [],
|
|
15526
|
-
metadata: options?.metadata
|
|
15527
|
-
}) : this.batchOperation({
|
|
15648
|
+
this.batchDeletePrimaryKeys = (primaryKeys, options) => {
|
|
15649
|
+
const result = this.batchOperation({
|
|
15528
15650
|
type: "delete",
|
|
15529
|
-
primaryKeys
|
|
15651
|
+
primaryKeys,
|
|
15530
15652
|
metadata: options?.metadata
|
|
15531
15653
|
});
|
|
15532
15654
|
if (options?.flush) {
|
|
@@ -15534,6 +15656,17 @@ var DataSourceApiImpl = class {
|
|
|
15534
15656
|
}
|
|
15535
15657
|
return result;
|
|
15536
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
|
+
};
|
|
15537
15670
|
this.addData = (data, options) => {
|
|
15538
15671
|
return this.addDataArray([data], options);
|
|
15539
15672
|
};
|
|
@@ -15547,9 +15680,33 @@ var DataSourceApiImpl = class {
|
|
|
15547
15680
|
return this.insertDataArray([data], options);
|
|
15548
15681
|
};
|
|
15549
15682
|
this.insertDataArray = (data, options) => {
|
|
15683
|
+
const isTree = this.getState().isTree;
|
|
15550
15684
|
let position2 = "before";
|
|
15551
15685
|
let primaryKey = void 0;
|
|
15552
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
|
+
}
|
|
15553
15710
|
if (options.position === "before" || options.position === "after") {
|
|
15554
15711
|
position2 = options.position;
|
|
15555
15712
|
primaryKey = options.primaryKey;
|
|
@@ -15557,13 +15714,20 @@ var DataSourceApiImpl = class {
|
|
|
15557
15714
|
const arr = this.getOriginalDataArray();
|
|
15558
15715
|
if (options.position === "start") {
|
|
15559
15716
|
position2 = "before";
|
|
15560
|
-
|
|
15717
|
+
if (!arr.length) {
|
|
15718
|
+
primaryKey = void 0;
|
|
15719
|
+
} else {
|
|
15720
|
+
primaryKey = this.toPrimaryKey(arr[0]);
|
|
15721
|
+
}
|
|
15561
15722
|
} else {
|
|
15562
15723
|
position2 = "after";
|
|
15563
|
-
|
|
15724
|
+
if (!arr.length) {
|
|
15725
|
+
primaryKey = void 0;
|
|
15726
|
+
} else {
|
|
15727
|
+
primaryKey = this.toPrimaryKey(arr[arr.length - 1]);
|
|
15728
|
+
}
|
|
15564
15729
|
}
|
|
15565
15730
|
}
|
|
15566
|
-
const isTree = this.getState().isTree;
|
|
15567
15731
|
const result = isTree ? this.batchOperation({
|
|
15568
15732
|
type: "insert",
|
|
15569
15733
|
array: data,
|
|
@@ -15583,6 +15747,41 @@ var DataSourceApiImpl = class {
|
|
|
15583
15747
|
}
|
|
15584
15748
|
return result;
|
|
15585
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
|
+
};
|
|
15586
15785
|
this.setSortInfo = (sortInfo) => {
|
|
15587
15786
|
const multiSort = this.getState().multiSort;
|
|
15588
15787
|
if (Array.isArray(sortInfo)) {
|
|
@@ -15659,6 +15858,9 @@ var DataSourceApiImpl = class {
|
|
|
15659
15858
|
this.actions = param.actions;
|
|
15660
15859
|
this.treeApi = new TreeApiImpl({ ...param, dataSourceApi: this });
|
|
15661
15860
|
}
|
|
15861
|
+
getPendingOperationPromise() {
|
|
15862
|
+
return this.pendingPromise;
|
|
15863
|
+
}
|
|
15662
15864
|
batchOperation(operation) {
|
|
15663
15865
|
if (!this.pendingPromise) {
|
|
15664
15866
|
this.pendingPromise = new Promise((resolve) => {
|
|
@@ -15688,7 +15890,8 @@ var DataSourceApiImpl = class {
|
|
|
15688
15890
|
return;
|
|
15689
15891
|
}
|
|
15690
15892
|
const currentCache = this.getState().cache;
|
|
15691
|
-
|
|
15893
|
+
const { isTree, nodesKey } = this.getState();
|
|
15894
|
+
let cache = currentCache ? DataSourceCache.clone(currentCache, { light: true }) : new DataSourceCache({ nodesKey: isTree ? nodesKey : void 0 });
|
|
15692
15895
|
operations.forEach((operation) => {
|
|
15693
15896
|
switch (operation.type) {
|
|
15694
15897
|
case "update":
|
|
@@ -15709,12 +15912,21 @@ var DataSourceApiImpl = class {
|
|
|
15709
15912
|
operation.nodePaths[index]
|
|
15710
15913
|
);
|
|
15711
15914
|
if (originalData) {
|
|
15712
|
-
|
|
15713
|
-
|
|
15714
|
-
|
|
15715
|
-
|
|
15716
|
-
|
|
15717
|
-
|
|
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
|
+
}
|
|
15718
15930
|
}
|
|
15719
15931
|
}
|
|
15720
15932
|
});
|
|
@@ -15747,7 +15959,7 @@ var DataSourceApiImpl = class {
|
|
|
15747
15959
|
if (nodePath) {
|
|
15748
15960
|
operation.array.forEach((data) => {
|
|
15749
15961
|
cache.insertNodePath(
|
|
15750
|
-
nodePath,
|
|
15962
|
+
[...nodePath],
|
|
15751
15963
|
data,
|
|
15752
15964
|
position2,
|
|
15753
15965
|
operation.metadata
|
|
@@ -15775,6 +15987,41 @@ var DataSourceApiImpl = class {
|
|
|
15775
15987
|
flush() {
|
|
15776
15988
|
return this.commit();
|
|
15777
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
|
+
}
|
|
15778
16025
|
commit() {
|
|
15779
16026
|
this.commitOperations(this.pendingOperations);
|
|
15780
16027
|
this.pendingOperations.length = 0;
|
|
@@ -16093,6 +16340,7 @@ function concludeReducer(params) {
|
|
|
16093
16340
|
}
|
|
16094
16341
|
const toPrimaryKey = state.toPrimaryKey;
|
|
16095
16342
|
const nodesKey = state.nodesKey;
|
|
16343
|
+
const isTree = state.isTree;
|
|
16096
16344
|
const getNodeChildren = nodesKey ? (node) => {
|
|
16097
16345
|
return node[nodesKey];
|
|
16098
16346
|
} : void 0;
|
|
@@ -16117,6 +16365,16 @@ function concludeReducer(params) {
|
|
|
16117
16365
|
nodesKey
|
|
16118
16366
|
}
|
|
16119
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
|
+
}
|
|
16120
16378
|
}
|
|
16121
16379
|
}
|
|
16122
16380
|
if (cache) {
|
|
@@ -16138,7 +16396,6 @@ function concludeReducer(params) {
|
|
|
16138
16396
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray || cacheAffectedParts.sortInfo);
|
|
16139
16397
|
const groupBy = state.groupBy;
|
|
16140
16398
|
const pivotBy = state.pivotBy;
|
|
16141
|
-
const isTree = state.isTree;
|
|
16142
16399
|
const shouldGroup = !isTree && (groupBy.length > 0 || !!pivotBy);
|
|
16143
16400
|
const shouldTree = isTree;
|
|
16144
16401
|
const rowDisabledStateDepsChanged = haveDepsChanged(previousState, state, [
|
|
@@ -17221,6 +17478,7 @@ function initSetupState() {
|
|
|
17221
17478
|
idToIndexMap: /* @__PURE__ */ new Map(),
|
|
17222
17479
|
idToPathMap: /* @__PURE__ */ new Map(),
|
|
17223
17480
|
pathToIndexMap: new DeepMap(),
|
|
17481
|
+
waitForNodePathPromises: new DeepMap(),
|
|
17224
17482
|
getDataSourceMasterContextRef: { current: () => void 0 },
|
|
17225
17483
|
// TODO: cleanup cache on unmount
|
|
17226
17484
|
cache: void 0,
|
|
@@ -17293,6 +17551,7 @@ var cleanupDataSource = (state) => {
|
|
|
17293
17551
|
};
|
|
17294
17552
|
state.treeExpandState?.destroy();
|
|
17295
17553
|
state.treePaths?.clear();
|
|
17554
|
+
state.waitForNodePathPromises.clear();
|
|
17296
17555
|
state.pathToIndexMap?.clear();
|
|
17297
17556
|
state.rowDisabledState?.destroy();
|
|
17298
17557
|
state.groupRowsState?.destroy();
|
|
@@ -22240,7 +22499,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
22240
22499
|
}
|
|
22241
22500
|
let valid2 = isValidLicense(licenseKey, {
|
|
22242
22501
|
publishedAt: 1624970570587,
|
|
22243
|
-
version: "6.0.
|
|
22502
|
+
version: "6.0.15"
|
|
22244
22503
|
});
|
|
22245
22504
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
22246
22505
|
return true;
|