@infinite-table/infinite-react 6.0.14 → 6.0.16
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 +323 -85
- package/index.dev.mjs +323 -85
- package/index.js +323 -85
- package/index.mjs +323 -85
- package/package.json +2 -2
package/index.dev.js
CHANGED
|
@@ -2690,15 +2690,22 @@ var MatrixBrain = class extends Logger {
|
|
|
2690
2690
|
if (size <= 0) {
|
|
2691
2691
|
return 0;
|
|
2692
2692
|
}
|
|
2693
|
+
const fixedStart = direction === "horizontal" ? this.fixedColsStart : this.fixedRowsStart;
|
|
2694
|
+
const fixedEnd = direction === "horizontal" ? this.fixedColsEnd : this.fixedRowsEnd;
|
|
2693
2695
|
if (typeof itemSize === "function") {
|
|
2694
2696
|
const sizes = [];
|
|
2695
|
-
|
|
2697
|
+
let start = 0;
|
|
2698
|
+
let end = count;
|
|
2699
|
+
start += fixedStart;
|
|
2700
|
+
end -= fixedEnd;
|
|
2701
|
+
for (let i = start; i < end; i++) {
|
|
2696
2702
|
sizes.push(this.getItemSize(i, direction));
|
|
2697
2703
|
}
|
|
2698
2704
|
renderCount = getGreatestCountVisibleInSize(size, sizes);
|
|
2699
2705
|
} else {
|
|
2700
2706
|
renderCount = (itemSize ? Math.ceil(size / itemSize) : 0) + 1;
|
|
2701
2707
|
}
|
|
2708
|
+
renderCount += fixedStart + fixedEnd;
|
|
2702
2709
|
renderCount = Math.min(count, renderCount);
|
|
2703
2710
|
return renderCount;
|
|
2704
2711
|
}
|
|
@@ -4692,7 +4699,7 @@ var ActiveRowIndicatorFn = (props) => {
|
|
|
4692
4699
|
setInfiniteVarsOnNode(
|
|
4693
4700
|
{
|
|
4694
4701
|
scrollTopForActiveRow: `${-scrollPosition.scrollTop}px`,
|
|
4695
|
-
scrollLeftForActiveRowWhenHorizontalLayout: `${-scrollPosition.scrollLeft}px`
|
|
4702
|
+
scrollLeftForActiveRowWhenHorizontalLayout: brain.isHorizontalLayoutBrain ? `${-scrollPosition.scrollLeft}px` : "0px"
|
|
4696
4703
|
},
|
|
4697
4704
|
domRef.current
|
|
4698
4705
|
);
|
|
@@ -5423,7 +5430,7 @@ var Icon = (props) => {
|
|
|
5423
5430
|
// src/components/InfiniteTable/components/icons/IncludesOperatorIcon.tsx
|
|
5424
5431
|
var React17 = __toESM(require("react"));
|
|
5425
5432
|
var IncludesOperatorIcon = (props) => {
|
|
5426
|
-
return /* @__PURE__ */ React17.createElement(Icon, { ...props }, /* @__PURE__ */ React17.createElement("path", { d: "
|
|
5433
|
+
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
5434
|
};
|
|
5428
5435
|
|
|
5429
5436
|
// src/components/InfiniteTable/components/icons/EndsWithOperatorIcon.tsx
|
|
@@ -13980,6 +13987,19 @@ var Indexer = class {
|
|
|
13980
13987
|
item = { ...item, ...info.data };
|
|
13981
13988
|
arr2[i] = item;
|
|
13982
13989
|
}
|
|
13990
|
+
if (info.type === "update-children" && !deleted) {
|
|
13991
|
+
const children = info.children(
|
|
13992
|
+
item[nodesKey],
|
|
13993
|
+
item
|
|
13994
|
+
);
|
|
13995
|
+
item = { ...item };
|
|
13996
|
+
if (children !== void 0) {
|
|
13997
|
+
item[nodesKey] = children;
|
|
13998
|
+
} else {
|
|
13999
|
+
delete item[nodesKey];
|
|
14000
|
+
}
|
|
14001
|
+
arr2[i] = item;
|
|
14002
|
+
}
|
|
13983
14003
|
if (info.type === "insert") {
|
|
13984
14004
|
if (info.position === "before") {
|
|
13985
14005
|
arr2.splice(i, 0, info.data);
|
|
@@ -14279,7 +14299,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
14279
14299
|
// src/components/DataSource/DataSourceCache.ts
|
|
14280
14300
|
var CLEAR_SYMBOL = Symbol("CLEAR");
|
|
14281
14301
|
var DataSourceCache = class {
|
|
14282
|
-
constructor() {
|
|
14302
|
+
constructor(options) {
|
|
14283
14303
|
this.affectedFields = /* @__PURE__ */ new Set();
|
|
14284
14304
|
this.allFieldsAffected = false;
|
|
14285
14305
|
this.primaryKeyToData = /* @__PURE__ */ new Map();
|
|
@@ -14342,8 +14362,12 @@ var DataSourceCache = class {
|
|
|
14342
14362
|
};
|
|
14343
14363
|
this.update = (primaryKey, data, originalData, metadata) => {
|
|
14344
14364
|
if (!this.allFieldsAffected) {
|
|
14345
|
-
|
|
14346
|
-
|
|
14365
|
+
if (this.nodesKey && Array.isArray(data[this.nodesKey])) {
|
|
14366
|
+
this.allFieldsAffected = true;
|
|
14367
|
+
} else {
|
|
14368
|
+
const keys = Object.keys(data);
|
|
14369
|
+
keys.forEach((key) => this.affectedFields.add(key));
|
|
14370
|
+
}
|
|
14347
14371
|
}
|
|
14348
14372
|
const pk = primaryKey;
|
|
14349
14373
|
const value = this.primaryKeyToData.get(pk) || [];
|
|
@@ -14358,8 +14382,12 @@ var DataSourceCache = class {
|
|
|
14358
14382
|
};
|
|
14359
14383
|
this.updateNodePath = (nodePath, data, originalData, metadata) => {
|
|
14360
14384
|
if (!this.allFieldsAffected) {
|
|
14361
|
-
|
|
14362
|
-
|
|
14385
|
+
if (this.nodesKey && Array.isArray(data[this.nodesKey])) {
|
|
14386
|
+
this.allFieldsAffected = true;
|
|
14387
|
+
} else {
|
|
14388
|
+
const keys = Object.keys(data);
|
|
14389
|
+
keys.forEach((key) => this.affectedFields.add(key));
|
|
14390
|
+
}
|
|
14363
14391
|
}
|
|
14364
14392
|
const value = this.nodePathToData.get(nodePath) || [];
|
|
14365
14393
|
value.push({
|
|
@@ -14371,6 +14399,18 @@ var DataSourceCache = class {
|
|
|
14371
14399
|
});
|
|
14372
14400
|
this.nodePathToData.set(nodePath, value);
|
|
14373
14401
|
};
|
|
14402
|
+
this.updateChildren = (nodePath, children, originalData, metadata) => {
|
|
14403
|
+
this.allFieldsAffected = true;
|
|
14404
|
+
const value = this.nodePathToData.get(nodePath) || [];
|
|
14405
|
+
value.push({
|
|
14406
|
+
type: "update-children",
|
|
14407
|
+
nodePath,
|
|
14408
|
+
children,
|
|
14409
|
+
originalData,
|
|
14410
|
+
metadata
|
|
14411
|
+
});
|
|
14412
|
+
this.nodePathToData.set(nodePath, value);
|
|
14413
|
+
};
|
|
14374
14414
|
this.resetDataSource = (metadata) => {
|
|
14375
14415
|
this.clear();
|
|
14376
14416
|
this.allFieldsAffected = true;
|
|
@@ -14423,9 +14463,12 @@ var DataSourceCache = class {
|
|
|
14423
14463
|
this.getTreeMutationsArray = () => {
|
|
14424
14464
|
return Array.from(this.nodePathToData.values()).flat();
|
|
14425
14465
|
};
|
|
14466
|
+
this.nodesKey = options.nodesKey;
|
|
14426
14467
|
}
|
|
14427
14468
|
static clone(cache, { light = false } = {}) {
|
|
14428
|
-
const clone = new DataSourceCache(
|
|
14469
|
+
const clone = new DataSourceCache({
|
|
14470
|
+
nodesKey: cache.nodesKey
|
|
14471
|
+
});
|
|
14429
14472
|
clone.allFieldsAffected = cache.allFieldsAffected;
|
|
14430
14473
|
clone.affectedFields = new Set(cache.affectedFields);
|
|
14431
14474
|
clone.primaryKeyToData = light ? cache.primaryKeyToData : new Map(
|
|
@@ -15301,6 +15344,7 @@ var RowDisabledState = class extends BooleanCollectionState {
|
|
|
15301
15344
|
};
|
|
15302
15345
|
|
|
15303
15346
|
// src/components/DataSource/getDataSourceApi.ts
|
|
15347
|
+
var DEFAULT_NODE_PATH_WAIT_TIMEOUT = 1e3;
|
|
15304
15348
|
function getDataSourceApi(param) {
|
|
15305
15349
|
return new DataSourceApiImpl(param);
|
|
15306
15350
|
}
|
|
@@ -15364,15 +15408,20 @@ var DataSourceApiImpl = class {
|
|
|
15364
15408
|
const { indexer } = this.getState();
|
|
15365
15409
|
return indexer.getDataForPrimaryKey(id) ?? null;
|
|
15366
15410
|
};
|
|
15411
|
+
this.isNodePathAvailable = (nodePath) => {
|
|
15412
|
+
return this.getState().indexer.getDataForNodePath(nodePath) !== void 0;
|
|
15413
|
+
};
|
|
15367
15414
|
this.getDataByNodePath = (nodePath) => {
|
|
15368
15415
|
const { indexer } = this.getState();
|
|
15369
15416
|
const data = indexer.getDataForNodePath(nodePath);
|
|
15370
15417
|
if (!data) {
|
|
15371
|
-
|
|
15372
|
-
|
|
15373
|
-
|
|
15374
|
-
|
|
15375
|
-
|
|
15418
|
+
if (false) {
|
|
15419
|
+
console.warn(
|
|
15420
|
+
`getDataByNodePath: no data found for nodePath: "${nodePath.join(
|
|
15421
|
+
" / "
|
|
15422
|
+
)}"`
|
|
15423
|
+
);
|
|
15424
|
+
}
|
|
15376
15425
|
return null;
|
|
15377
15426
|
}
|
|
15378
15427
|
return data;
|
|
@@ -15432,25 +15481,84 @@ var DataSourceApiImpl = class {
|
|
|
15432
15481
|
}
|
|
15433
15482
|
return result;
|
|
15434
15483
|
};
|
|
15484
|
+
this.withWaitForNode = (nodePath, fn, options) => {
|
|
15485
|
+
const waitForNode = options?.waitForNode ?? true;
|
|
15486
|
+
if (waitForNode === true || typeof waitForNode === "number") {
|
|
15487
|
+
let timeout = waitForNode === true ? DEFAULT_NODE_PATH_WAIT_TIMEOUT : waitForNode;
|
|
15488
|
+
if (!isNaN(timeout)) {
|
|
15489
|
+
timeout = DEFAULT_NODE_PATH_WAIT_TIMEOUT;
|
|
15490
|
+
}
|
|
15491
|
+
return this.waitForNodePath(nodePath, { timeout }).then((okay) => {
|
|
15492
|
+
if (!okay) {
|
|
15493
|
+
const error2 = `Cannot find node path "${nodePath.join(
|
|
15494
|
+
"/"
|
|
15495
|
+
)}" (we waited for it ${timeout}ms)`;
|
|
15496
|
+
console.error(error2);
|
|
15497
|
+
return fn({
|
|
15498
|
+
error: error2,
|
|
15499
|
+
resolved: false
|
|
15500
|
+
});
|
|
15501
|
+
}
|
|
15502
|
+
return fn({
|
|
15503
|
+
resolved: true
|
|
15504
|
+
});
|
|
15505
|
+
});
|
|
15506
|
+
}
|
|
15507
|
+
const result = fn({
|
|
15508
|
+
resolved: void 0
|
|
15509
|
+
});
|
|
15510
|
+
return result instanceof Promise ? result : Promise.resolve(result);
|
|
15511
|
+
};
|
|
15435
15512
|
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
|
-
},
|
|
15513
|
+
return this.withWaitForNode(
|
|
15448
15514
|
nodePath,
|
|
15515
|
+
({ error: error2 }) => {
|
|
15516
|
+
if (error2) {
|
|
15517
|
+
return false;
|
|
15518
|
+
}
|
|
15519
|
+
return this.updateChildrenByNodePath_Internal(
|
|
15520
|
+
childrenOrFn,
|
|
15521
|
+
nodePath,
|
|
15522
|
+
options
|
|
15523
|
+
);
|
|
15524
|
+
},
|
|
15525
|
+
options
|
|
15526
|
+
);
|
|
15527
|
+
};
|
|
15528
|
+
this.updateChildrenByNodePath_Internal = (childrenOrFn, nodePath, options) => {
|
|
15529
|
+
const children = typeof childrenOrFn === "function" ? childrenOrFn : () => childrenOrFn;
|
|
15530
|
+
return this.updateDataArrayByNodePath_Internal(
|
|
15531
|
+
[
|
|
15532
|
+
{
|
|
15533
|
+
nodePath,
|
|
15534
|
+
children
|
|
15535
|
+
}
|
|
15536
|
+
],
|
|
15449
15537
|
options
|
|
15450
15538
|
);
|
|
15451
15539
|
};
|
|
15452
15540
|
this.updateDataByNodePath = (data, nodePath, options) => {
|
|
15453
|
-
|
|
15541
|
+
if (!this.isNodePathAvailable(nodePath)) {
|
|
15542
|
+
return this.withWaitForNode(
|
|
15543
|
+
nodePath,
|
|
15544
|
+
({ error: error2 }) => {
|
|
15545
|
+
if (error2) {
|
|
15546
|
+
return false;
|
|
15547
|
+
}
|
|
15548
|
+
return this.updateDataArrayByNodePath_Internal(
|
|
15549
|
+
[
|
|
15550
|
+
{
|
|
15551
|
+
data,
|
|
15552
|
+
nodePath
|
|
15553
|
+
}
|
|
15554
|
+
],
|
|
15555
|
+
options
|
|
15556
|
+
);
|
|
15557
|
+
},
|
|
15558
|
+
options
|
|
15559
|
+
);
|
|
15560
|
+
}
|
|
15561
|
+
return this.updateDataArrayByNodePath_Internal(
|
|
15454
15562
|
[
|
|
15455
15563
|
{
|
|
15456
15564
|
data,
|
|
@@ -15461,10 +15569,31 @@ var DataSourceApiImpl = class {
|
|
|
15461
15569
|
);
|
|
15462
15570
|
};
|
|
15463
15571
|
this.updateDataArrayByNodePath = (updateInfo, options) => {
|
|
15572
|
+
if (options && typeof options.waitForNode !== "undefined" && !options.waitForNode) {
|
|
15573
|
+
return this.updateDataArrayByNodePath_Internal(updateInfo, options);
|
|
15574
|
+
}
|
|
15575
|
+
const allNodePaths = updateInfo.map((info) => info.nodePath);
|
|
15576
|
+
const promiseWithAll = Promise.allSettled(
|
|
15577
|
+
allNodePaths.map((nodePath) => {
|
|
15578
|
+
return this.withWaitForNode(nodePath, ({ error: error2 }) => !error2, options);
|
|
15579
|
+
})
|
|
15580
|
+
);
|
|
15581
|
+
return promiseWithAll.then((allGood) => {
|
|
15582
|
+
if (!allGood.every(Boolean)) {
|
|
15583
|
+
return false;
|
|
15584
|
+
}
|
|
15585
|
+
return this.updateDataArrayByNodePath_Internal(updateInfo, options);
|
|
15586
|
+
});
|
|
15587
|
+
};
|
|
15588
|
+
this.updateDataArrayByNodePath_Internal = (updateInfo, options) => {
|
|
15464
15589
|
const data = [];
|
|
15465
15590
|
const nodePaths = [];
|
|
15466
15591
|
updateInfo.forEach((info) => {
|
|
15467
|
-
|
|
15592
|
+
if (info.data) {
|
|
15593
|
+
data.push(info.data);
|
|
15594
|
+
} else if (info.children) {
|
|
15595
|
+
data.push(info.children);
|
|
15596
|
+
}
|
|
15468
15597
|
nodePaths.push(info.nodePath);
|
|
15469
15598
|
});
|
|
15470
15599
|
const result = this.batchOperation({
|
|
@@ -15494,67 +15623,39 @@ var DataSourceApiImpl = class {
|
|
|
15494
15623
|
return result;
|
|
15495
15624
|
};
|
|
15496
15625
|
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;
|
|
15626
|
+
return this.batchDeleteNodePaths([nodePath], options);
|
|
15506
15627
|
};
|
|
15507
15628
|
this.removeData = (data, options) => {
|
|
15508
15629
|
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();
|
|
15630
|
+
if (isTree) {
|
|
15631
|
+
const nodePath = this.getNodePathById(this.toPrimaryKey(data));
|
|
15632
|
+
return this.removeDataByNodePath(nodePath, options);
|
|
15523
15633
|
}
|
|
15524
|
-
return
|
|
15634
|
+
return this.batchDeletePrimaryKeys([this.toPrimaryKey(data)], options);
|
|
15525
15635
|
};
|
|
15526
15636
|
this.removeDataArrayByPrimaryKeys = (ids, options) => {
|
|
15527
15637
|
const isTree = this.getState().isTree;
|
|
15528
|
-
|
|
15529
|
-
|
|
15530
|
-
|
|
15531
|
-
|
|
15638
|
+
if (isTree) {
|
|
15639
|
+
const nodePaths = ids.map((id) => this.getNodePathById(id) || []);
|
|
15640
|
+
return this.batchDeleteNodePaths(nodePaths, options);
|
|
15641
|
+
}
|
|
15642
|
+
return this.batchDeletePrimaryKeys(ids, options);
|
|
15643
|
+
};
|
|
15644
|
+
this.batchDeleteNodePaths = (nodePaths, options) => {
|
|
15645
|
+
const result = this.batchOperation({
|
|
15532
15646
|
type: "delete",
|
|
15533
15647
|
nodePaths: nodePaths || [],
|
|
15534
15648
|
metadata: options?.metadata
|
|
15535
|
-
}) : this.batchOperation({
|
|
15536
|
-
type: "delete",
|
|
15537
|
-
primaryKeys: ids,
|
|
15538
|
-
metadata: options?.metadata
|
|
15539
15649
|
});
|
|
15540
15650
|
if (options?.flush) {
|
|
15541
15651
|
this.commit();
|
|
15542
15652
|
}
|
|
15543
15653
|
return result;
|
|
15544
15654
|
};
|
|
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({
|
|
15655
|
+
this.batchDeletePrimaryKeys = (primaryKeys, options) => {
|
|
15656
|
+
const result = this.batchOperation({
|
|
15556
15657
|
type: "delete",
|
|
15557
|
-
primaryKeys
|
|
15658
|
+
primaryKeys,
|
|
15558
15659
|
metadata: options?.metadata
|
|
15559
15660
|
});
|
|
15560
15661
|
if (options?.flush) {
|
|
@@ -15562,6 +15663,17 @@ var DataSourceApiImpl = class {
|
|
|
15562
15663
|
}
|
|
15563
15664
|
return result;
|
|
15564
15665
|
};
|
|
15666
|
+
this.removeDataArray = (data, options) => {
|
|
15667
|
+
const isTree = this.getState().isTree;
|
|
15668
|
+
if (isTree) {
|
|
15669
|
+
const nodePaths = data.map((d) => {
|
|
15670
|
+
return this.getNodePathById(this.toPrimaryKey(d)) || [];
|
|
15671
|
+
});
|
|
15672
|
+
return this.batchDeleteNodePaths(nodePaths, options);
|
|
15673
|
+
}
|
|
15674
|
+
const primaryKeys = data.map(this.toPrimaryKey);
|
|
15675
|
+
return this.batchDeletePrimaryKeys(primaryKeys, options);
|
|
15676
|
+
};
|
|
15565
15677
|
this.addData = (data, options) => {
|
|
15566
15678
|
return this.addDataArray([data], options);
|
|
15567
15679
|
};
|
|
@@ -15575,9 +15687,33 @@ var DataSourceApiImpl = class {
|
|
|
15575
15687
|
return this.insertDataArray([data], options);
|
|
15576
15688
|
};
|
|
15577
15689
|
this.insertDataArray = (data, options) => {
|
|
15690
|
+
const isTree = this.getState().isTree;
|
|
15578
15691
|
let position2 = "before";
|
|
15579
15692
|
let primaryKey = void 0;
|
|
15580
15693
|
let nodePath = options.nodePath;
|
|
15694
|
+
if (isTree && nodePath?.length) {
|
|
15695
|
+
return this.withWaitForNode(
|
|
15696
|
+
nodePath,
|
|
15697
|
+
({ error: error2 }) => {
|
|
15698
|
+
if (error2) {
|
|
15699
|
+
return false;
|
|
15700
|
+
}
|
|
15701
|
+
if (options.position === "before" || options.position === "after") {
|
|
15702
|
+
return this.batchTreeInsert(
|
|
15703
|
+
data,
|
|
15704
|
+
options.position,
|
|
15705
|
+
nodePath,
|
|
15706
|
+
options
|
|
15707
|
+
);
|
|
15708
|
+
}
|
|
15709
|
+
const newChildren = (childrenOfNode) => {
|
|
15710
|
+
return options.position === "start" ? [...data, ...childrenOfNode || []] : [...childrenOfNode || [], ...data];
|
|
15711
|
+
};
|
|
15712
|
+
return this.updateChildrenByNodePath(newChildren, nodePath, options);
|
|
15713
|
+
},
|
|
15714
|
+
options
|
|
15715
|
+
);
|
|
15716
|
+
}
|
|
15581
15717
|
if (options.position === "before" || options.position === "after") {
|
|
15582
15718
|
position2 = options.position;
|
|
15583
15719
|
primaryKey = options.primaryKey;
|
|
@@ -15585,13 +15721,20 @@ var DataSourceApiImpl = class {
|
|
|
15585
15721
|
const arr = this.getOriginalDataArray();
|
|
15586
15722
|
if (options.position === "start") {
|
|
15587
15723
|
position2 = "before";
|
|
15588
|
-
|
|
15724
|
+
if (!arr.length) {
|
|
15725
|
+
primaryKey = void 0;
|
|
15726
|
+
} else {
|
|
15727
|
+
primaryKey = this.toPrimaryKey(arr[0]);
|
|
15728
|
+
}
|
|
15589
15729
|
} else {
|
|
15590
15730
|
position2 = "after";
|
|
15591
|
-
|
|
15731
|
+
if (!arr.length) {
|
|
15732
|
+
primaryKey = void 0;
|
|
15733
|
+
} else {
|
|
15734
|
+
primaryKey = this.toPrimaryKey(arr[arr.length - 1]);
|
|
15735
|
+
}
|
|
15592
15736
|
}
|
|
15593
15737
|
}
|
|
15594
|
-
const isTree = this.getState().isTree;
|
|
15595
15738
|
const result = isTree ? this.batchOperation({
|
|
15596
15739
|
type: "insert",
|
|
15597
15740
|
array: data,
|
|
@@ -15611,6 +15754,41 @@ var DataSourceApiImpl = class {
|
|
|
15611
15754
|
}
|
|
15612
15755
|
return result;
|
|
15613
15756
|
};
|
|
15757
|
+
this.batchTreeInsert = (data, position2, nodePath, options) => {
|
|
15758
|
+
if (nodePath.length && !this.isNodePathAvailable(nodePath)) {
|
|
15759
|
+
return this.withWaitForNode(
|
|
15760
|
+
nodePath,
|
|
15761
|
+
({ error: error2 }) => {
|
|
15762
|
+
if (error2) {
|
|
15763
|
+
return false;
|
|
15764
|
+
}
|
|
15765
|
+
const result2 = this.batchOperation({
|
|
15766
|
+
type: "insert",
|
|
15767
|
+
array: data,
|
|
15768
|
+
position: position2,
|
|
15769
|
+
metadata: options?.metadata,
|
|
15770
|
+
nodePath
|
|
15771
|
+
});
|
|
15772
|
+
if (options?.flush) {
|
|
15773
|
+
this.commit();
|
|
15774
|
+
}
|
|
15775
|
+
return result2;
|
|
15776
|
+
},
|
|
15777
|
+
options
|
|
15778
|
+
);
|
|
15779
|
+
}
|
|
15780
|
+
const result = this.batchOperation({
|
|
15781
|
+
type: "insert",
|
|
15782
|
+
array: data,
|
|
15783
|
+
position: position2,
|
|
15784
|
+
metadata: options?.metadata,
|
|
15785
|
+
nodePath
|
|
15786
|
+
});
|
|
15787
|
+
if (options?.flush) {
|
|
15788
|
+
this.commit();
|
|
15789
|
+
}
|
|
15790
|
+
return result;
|
|
15791
|
+
};
|
|
15614
15792
|
this.setSortInfo = (sortInfo) => {
|
|
15615
15793
|
const multiSort = this.getState().multiSort;
|
|
15616
15794
|
if (Array.isArray(sortInfo)) {
|
|
@@ -15687,6 +15865,9 @@ var DataSourceApiImpl = class {
|
|
|
15687
15865
|
this.actions = param.actions;
|
|
15688
15866
|
this.treeApi = new TreeApiImpl({ ...param, dataSourceApi: this });
|
|
15689
15867
|
}
|
|
15868
|
+
getPendingOperationPromise() {
|
|
15869
|
+
return this.pendingPromise;
|
|
15870
|
+
}
|
|
15690
15871
|
batchOperation(operation) {
|
|
15691
15872
|
if (!this.pendingPromise) {
|
|
15692
15873
|
this.pendingPromise = new Promise((resolve) => {
|
|
@@ -15716,7 +15897,8 @@ var DataSourceApiImpl = class {
|
|
|
15716
15897
|
return;
|
|
15717
15898
|
}
|
|
15718
15899
|
const currentCache = this.getState().cache;
|
|
15719
|
-
|
|
15900
|
+
const { isTree, nodesKey } = this.getState();
|
|
15901
|
+
let cache = currentCache ? DataSourceCache.clone(currentCache, { light: true }) : new DataSourceCache({ nodesKey: isTree ? nodesKey : void 0 });
|
|
15720
15902
|
operations.forEach((operation) => {
|
|
15721
15903
|
switch (operation.type) {
|
|
15722
15904
|
case "update":
|
|
@@ -15737,12 +15919,21 @@ var DataSourceApiImpl = class {
|
|
|
15737
15919
|
operation.nodePaths[index]
|
|
15738
15920
|
);
|
|
15739
15921
|
if (originalData) {
|
|
15740
|
-
|
|
15741
|
-
|
|
15742
|
-
|
|
15743
|
-
|
|
15744
|
-
|
|
15745
|
-
|
|
15922
|
+
if (typeof data === "function") {
|
|
15923
|
+
cache.updateChildren(
|
|
15924
|
+
operation.nodePaths[index],
|
|
15925
|
+
data,
|
|
15926
|
+
originalData,
|
|
15927
|
+
operation.metadata
|
|
15928
|
+
);
|
|
15929
|
+
} else {
|
|
15930
|
+
cache.updateNodePath(
|
|
15931
|
+
operation.nodePaths[index],
|
|
15932
|
+
data,
|
|
15933
|
+
originalData,
|
|
15934
|
+
operation.metadata
|
|
15935
|
+
);
|
|
15936
|
+
}
|
|
15746
15937
|
}
|
|
15747
15938
|
}
|
|
15748
15939
|
});
|
|
@@ -15775,7 +15966,7 @@ var DataSourceApiImpl = class {
|
|
|
15775
15966
|
if (nodePath) {
|
|
15776
15967
|
operation.array.forEach((data) => {
|
|
15777
15968
|
cache.insertNodePath(
|
|
15778
|
-
nodePath,
|
|
15969
|
+
[...nodePath],
|
|
15779
15970
|
data,
|
|
15780
15971
|
position2,
|
|
15781
15972
|
operation.metadata
|
|
@@ -15803,6 +15994,41 @@ var DataSourceApiImpl = class {
|
|
|
15803
15994
|
flush() {
|
|
15804
15995
|
return this.commit();
|
|
15805
15996
|
}
|
|
15997
|
+
waitForNodePath(nodePath, options) {
|
|
15998
|
+
const state = this.getState();
|
|
15999
|
+
if (this.isNodePathAvailable(nodePath)) {
|
|
16000
|
+
return Promise.resolve(true);
|
|
16001
|
+
}
|
|
16002
|
+
const timeout = options?.timeout ?? DEFAULT_NODE_PATH_WAIT_TIMEOUT;
|
|
16003
|
+
const result = state.waitForNodePathPromises.get(nodePath);
|
|
16004
|
+
if (result) {
|
|
16005
|
+
return result.promise;
|
|
16006
|
+
}
|
|
16007
|
+
const timestamp = Date.now();
|
|
16008
|
+
let resolve = () => {
|
|
16009
|
+
};
|
|
16010
|
+
const promise = new Promise((res) => {
|
|
16011
|
+
let resolved;
|
|
16012
|
+
let timeoutId;
|
|
16013
|
+
resolve = (value) => {
|
|
16014
|
+
clearTimeout(timeoutId);
|
|
16015
|
+
resolved = value;
|
|
16016
|
+
state.waitForNodePathPromises.delete(nodePath);
|
|
16017
|
+
res(value);
|
|
16018
|
+
};
|
|
16019
|
+
timeoutId = setTimeout(() => {
|
|
16020
|
+
if (resolved === void 0) {
|
|
16021
|
+
resolve(false);
|
|
16022
|
+
}
|
|
16023
|
+
}, timeout);
|
|
16024
|
+
});
|
|
16025
|
+
state.waitForNodePathPromises.set(nodePath, {
|
|
16026
|
+
timestamp,
|
|
16027
|
+
promise,
|
|
16028
|
+
resolve
|
|
16029
|
+
});
|
|
16030
|
+
return promise;
|
|
16031
|
+
}
|
|
15806
16032
|
commit() {
|
|
15807
16033
|
this.commitOperations(this.pendingOperations);
|
|
15808
16034
|
this.pendingOperations.length = 0;
|
|
@@ -16121,6 +16347,7 @@ function concludeReducer(params) {
|
|
|
16121
16347
|
}
|
|
16122
16348
|
const toPrimaryKey = state.toPrimaryKey;
|
|
16123
16349
|
const nodesKey = state.nodesKey;
|
|
16350
|
+
const isTree = state.isTree;
|
|
16124
16351
|
const getNodeChildren = nodesKey ? (node) => {
|
|
16125
16352
|
return node[nodesKey];
|
|
16126
16353
|
} : void 0;
|
|
@@ -16145,6 +16372,16 @@ function concludeReducer(params) {
|
|
|
16145
16372
|
nodesKey
|
|
16146
16373
|
}
|
|
16147
16374
|
);
|
|
16375
|
+
if (isTree) {
|
|
16376
|
+
state.waitForNodePathPromises.visit(({ value }, keys) => {
|
|
16377
|
+
if (!value) {
|
|
16378
|
+
return;
|
|
16379
|
+
}
|
|
16380
|
+
if (state.indexer.getDataForNodePath(keys) !== void 0) {
|
|
16381
|
+
value.resolve(true);
|
|
16382
|
+
}
|
|
16383
|
+
});
|
|
16384
|
+
}
|
|
16148
16385
|
}
|
|
16149
16386
|
}
|
|
16150
16387
|
if (cache) {
|
|
@@ -16166,7 +16403,6 @@ function concludeReducer(params) {
|
|
|
16166
16403
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray || cacheAffectedParts.sortInfo);
|
|
16167
16404
|
const groupBy = state.groupBy;
|
|
16168
16405
|
const pivotBy = state.pivotBy;
|
|
16169
|
-
const isTree = state.isTree;
|
|
16170
16406
|
const shouldGroup = !isTree && (groupBy.length > 0 || !!pivotBy);
|
|
16171
16407
|
const shouldTree = isTree;
|
|
16172
16408
|
const rowDisabledStateDepsChanged = haveDepsChanged(previousState, state, [
|
|
@@ -17249,6 +17485,7 @@ function initSetupState() {
|
|
|
17249
17485
|
idToIndexMap: /* @__PURE__ */ new Map(),
|
|
17250
17486
|
idToPathMap: /* @__PURE__ */ new Map(),
|
|
17251
17487
|
pathToIndexMap: new DeepMap(),
|
|
17488
|
+
waitForNodePathPromises: new DeepMap(),
|
|
17252
17489
|
getDataSourceMasterContextRef: { current: () => void 0 },
|
|
17253
17490
|
// TODO: cleanup cache on unmount
|
|
17254
17491
|
cache: void 0,
|
|
@@ -17321,6 +17558,7 @@ var cleanupDataSource = (state) => {
|
|
|
17321
17558
|
};
|
|
17322
17559
|
state.treeExpandState?.destroy();
|
|
17323
17560
|
state.treePaths?.clear();
|
|
17561
|
+
state.waitForNodePathPromises.clear();
|
|
17324
17562
|
state.pathToIndexMap?.clear();
|
|
17325
17563
|
state.rowDisabledState?.destroy();
|
|
17326
17564
|
state.groupRowsState?.destroy();
|
|
@@ -22268,7 +22506,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
22268
22506
|
}
|
|
22269
22507
|
let valid2 = isValidLicense(licenseKey, {
|
|
22270
22508
|
publishedAt: 1624970570587,
|
|
22271
|
-
version: "6.0.
|
|
22509
|
+
version: "6.0.16"
|
|
22272
22510
|
});
|
|
22273
22511
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
22274
22512
|
return true;
|