@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.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: "
|
|
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
|
|
@@ -13929,6 +13929,19 @@ var Indexer = class {
|
|
|
13929
13929
|
item = { ...item, ...info.data };
|
|
13930
13930
|
arr2[i] = item;
|
|
13931
13931
|
}
|
|
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;
|
|
13940
|
+
} else {
|
|
13941
|
+
delete item[nodesKey];
|
|
13942
|
+
}
|
|
13943
|
+
arr2[i] = item;
|
|
13944
|
+
}
|
|
13932
13945
|
if (info.type === "insert") {
|
|
13933
13946
|
if (info.position === "before") {
|
|
13934
13947
|
arr2.splice(i, 0, info.data);
|
|
@@ -14228,7 +14241,7 @@ function getPivotColumnsAndColumnGroups({
|
|
|
14228
14241
|
// src/components/DataSource/DataSourceCache.ts
|
|
14229
14242
|
var CLEAR_SYMBOL = Symbol("CLEAR");
|
|
14230
14243
|
var DataSourceCache = class {
|
|
14231
|
-
constructor() {
|
|
14244
|
+
constructor(options) {
|
|
14232
14245
|
this.affectedFields = /* @__PURE__ */ new Set();
|
|
14233
14246
|
this.allFieldsAffected = false;
|
|
14234
14247
|
this.primaryKeyToData = /* @__PURE__ */ new Map();
|
|
@@ -14291,8 +14304,12 @@ var DataSourceCache = class {
|
|
|
14291
14304
|
};
|
|
14292
14305
|
this.update = (primaryKey, data, originalData, metadata) => {
|
|
14293
14306
|
if (!this.allFieldsAffected) {
|
|
14294
|
-
|
|
14295
|
-
|
|
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
|
+
}
|
|
14296
14313
|
}
|
|
14297
14314
|
const pk = primaryKey;
|
|
14298
14315
|
const value = this.primaryKeyToData.get(pk) || [];
|
|
@@ -14307,8 +14324,12 @@ var DataSourceCache = class {
|
|
|
14307
14324
|
};
|
|
14308
14325
|
this.updateNodePath = (nodePath, data, originalData, metadata) => {
|
|
14309
14326
|
if (!this.allFieldsAffected) {
|
|
14310
|
-
|
|
14311
|
-
|
|
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
|
+
}
|
|
14312
14333
|
}
|
|
14313
14334
|
const value = this.nodePathToData.get(nodePath) || [];
|
|
14314
14335
|
value.push({
|
|
@@ -14320,6 +14341,18 @@ var DataSourceCache = class {
|
|
|
14320
14341
|
});
|
|
14321
14342
|
this.nodePathToData.set(nodePath, value);
|
|
14322
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
|
+
};
|
|
14323
14356
|
this.resetDataSource = (metadata) => {
|
|
14324
14357
|
this.clear();
|
|
14325
14358
|
this.allFieldsAffected = true;
|
|
@@ -14372,9 +14405,12 @@ var DataSourceCache = class {
|
|
|
14372
14405
|
this.getTreeMutationsArray = () => {
|
|
14373
14406
|
return Array.from(this.nodePathToData.values()).flat();
|
|
14374
14407
|
};
|
|
14408
|
+
this.nodesKey = options.nodesKey;
|
|
14375
14409
|
}
|
|
14376
14410
|
static clone(cache, { light = false } = {}) {
|
|
14377
|
-
const clone = new DataSourceCache(
|
|
14411
|
+
const clone = new DataSourceCache({
|
|
14412
|
+
nodesKey: cache.nodesKey
|
|
14413
|
+
});
|
|
14378
14414
|
clone.allFieldsAffected = cache.allFieldsAffected;
|
|
14379
14415
|
clone.affectedFields = new Set(cache.affectedFields);
|
|
14380
14416
|
clone.primaryKeyToData = light ? cache.primaryKeyToData : new Map(
|
|
@@ -15250,6 +15286,7 @@ var RowDisabledState = class extends BooleanCollectionState {
|
|
|
15250
15286
|
};
|
|
15251
15287
|
|
|
15252
15288
|
// src/components/DataSource/getDataSourceApi.ts
|
|
15289
|
+
var DEFAULT_NODE_PATH_WAIT_TIMEOUT = 1e3;
|
|
15253
15290
|
function getDataSourceApi(param) {
|
|
15254
15291
|
return new DataSourceApiImpl(param);
|
|
15255
15292
|
}
|
|
@@ -15313,15 +15350,20 @@ var DataSourceApiImpl = class {
|
|
|
15313
15350
|
const { indexer } = this.getState();
|
|
15314
15351
|
return indexer.getDataForPrimaryKey(id) ?? null;
|
|
15315
15352
|
};
|
|
15353
|
+
this.isNodePathAvailable = (nodePath) => {
|
|
15354
|
+
return this.getState().indexer.getDataForNodePath(nodePath) !== void 0;
|
|
15355
|
+
};
|
|
15316
15356
|
this.getDataByNodePath = (nodePath) => {
|
|
15317
15357
|
const { indexer } = this.getState();
|
|
15318
15358
|
const data = indexer.getDataForNodePath(nodePath);
|
|
15319
15359
|
if (!data) {
|
|
15320
|
-
|
|
15321
|
-
|
|
15322
|
-
|
|
15323
|
-
|
|
15324
|
-
|
|
15360
|
+
if (false) {
|
|
15361
|
+
console.warn(
|
|
15362
|
+
`getDataByNodePath: no data found for nodePath: "${nodePath.join(
|
|
15363
|
+
" / "
|
|
15364
|
+
)}"`
|
|
15365
|
+
);
|
|
15366
|
+
}
|
|
15325
15367
|
return null;
|
|
15326
15368
|
}
|
|
15327
15369
|
return data;
|
|
@@ -15381,25 +15423,84 @@ var DataSourceApiImpl = class {
|
|
|
15381
15423
|
}
|
|
15382
15424
|
return result;
|
|
15383
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
|
+
};
|
|
15384
15454
|
this.updateChildrenByNodePath = (childrenOrFn, nodePath, options) => {
|
|
15385
|
-
|
|
15386
|
-
if (data == null) {
|
|
15387
|
-
return Promise.resolve(null);
|
|
15388
|
-
}
|
|
15389
|
-
const nodesKey = this.getState().nodesKey;
|
|
15390
|
-
const dataChildren = data[nodesKey];
|
|
15391
|
-
const children = typeof childrenOrFn === "function" ? childrenOrFn(dataChildren, data) : childrenOrFn;
|
|
15392
|
-
return this.updateDataByNodePath(
|
|
15393
|
-
{
|
|
15394
|
-
...data,
|
|
15395
|
-
[nodesKey]: children
|
|
15396
|
-
},
|
|
15455
|
+
return this.withWaitForNode(
|
|
15397
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
|
+
],
|
|
15398
15479
|
options
|
|
15399
15480
|
);
|
|
15400
15481
|
};
|
|
15401
15482
|
this.updateDataByNodePath = (data, nodePath, options) => {
|
|
15402
|
-
|
|
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(
|
|
15403
15504
|
[
|
|
15404
15505
|
{
|
|
15405
15506
|
data,
|
|
@@ -15410,10 +15511,31 @@ var DataSourceApiImpl = class {
|
|
|
15410
15511
|
);
|
|
15411
15512
|
};
|
|
15412
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) => {
|
|
15413
15531
|
const data = [];
|
|
15414
15532
|
const nodePaths = [];
|
|
15415
15533
|
updateInfo.forEach((info) => {
|
|
15416
|
-
|
|
15534
|
+
if (info.data) {
|
|
15535
|
+
data.push(info.data);
|
|
15536
|
+
} else if (info.children) {
|
|
15537
|
+
data.push(info.children);
|
|
15538
|
+
}
|
|
15417
15539
|
nodePaths.push(info.nodePath);
|
|
15418
15540
|
});
|
|
15419
15541
|
const result = this.batchOperation({
|
|
@@ -15443,67 +15565,39 @@ var DataSourceApiImpl = class {
|
|
|
15443
15565
|
return result;
|
|
15444
15566
|
};
|
|
15445
15567
|
this.removeDataByNodePath = (nodePath, options) => {
|
|
15446
|
-
|
|
15447
|
-
type: "delete",
|
|
15448
|
-
nodePaths: [nodePath],
|
|
15449
|
-
metadata: options?.metadata
|
|
15450
|
-
});
|
|
15451
|
-
if (options?.flush) {
|
|
15452
|
-
this.commit();
|
|
15453
|
-
}
|
|
15454
|
-
return result;
|
|
15568
|
+
return this.batchDeleteNodePaths([nodePath], options);
|
|
15455
15569
|
};
|
|
15456
15570
|
this.removeData = (data, options) => {
|
|
15457
15571
|
const isTree = this.getState().isTree;
|
|
15458
|
-
|
|
15459
|
-
|
|
15460
|
-
|
|
15461
|
-
const result = primaryKeys ? this.batchOperation({
|
|
15462
|
-
type: "delete",
|
|
15463
|
-
primaryKeys,
|
|
15464
|
-
metadata: options?.metadata
|
|
15465
|
-
}) : this.batchOperation({
|
|
15466
|
-
type: "delete",
|
|
15467
|
-
nodePaths: nodePaths || [],
|
|
15468
|
-
metadata: options?.metadata
|
|
15469
|
-
});
|
|
15470
|
-
if (options?.flush) {
|
|
15471
|
-
this.commit();
|
|
15572
|
+
if (isTree) {
|
|
15573
|
+
const nodePath = this.getNodePathById(this.toPrimaryKey(data));
|
|
15574
|
+
return this.removeDataByNodePath(nodePath, options);
|
|
15472
15575
|
}
|
|
15473
|
-
return
|
|
15576
|
+
return this.batchDeletePrimaryKeys([this.toPrimaryKey(data)], options);
|
|
15474
15577
|
};
|
|
15475
15578
|
this.removeDataArrayByPrimaryKeys = (ids, options) => {
|
|
15476
15579
|
const isTree = this.getState().isTree;
|
|
15477
|
-
|
|
15478
|
-
|
|
15479
|
-
|
|
15480
|
-
|
|
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({
|
|
15481
15588
|
type: "delete",
|
|
15482
15589
|
nodePaths: nodePaths || [],
|
|
15483
15590
|
metadata: options?.metadata
|
|
15484
|
-
}) : this.batchOperation({
|
|
15485
|
-
type: "delete",
|
|
15486
|
-
primaryKeys: ids,
|
|
15487
|
-
metadata: options?.metadata
|
|
15488
15591
|
});
|
|
15489
15592
|
if (options?.flush) {
|
|
15490
15593
|
this.commit();
|
|
15491
15594
|
}
|
|
15492
15595
|
return result;
|
|
15493
15596
|
};
|
|
15494
|
-
this.
|
|
15495
|
-
const
|
|
15496
|
-
const nodePaths = isTree ? data.map((d) => {
|
|
15497
|
-
return this.getNodePathById(this.toPrimaryKey(d)) || [];
|
|
15498
|
-
}) : null;
|
|
15499
|
-
const primaryKeys = !isTree ? data.map(this.toPrimaryKey) : void 0;
|
|
15500
|
-
const result = isTree ? this.batchOperation({
|
|
15501
|
-
type: "delete",
|
|
15502
|
-
nodePaths: nodePaths || [],
|
|
15503
|
-
metadata: options?.metadata
|
|
15504
|
-
}) : this.batchOperation({
|
|
15597
|
+
this.batchDeletePrimaryKeys = (primaryKeys, options) => {
|
|
15598
|
+
const result = this.batchOperation({
|
|
15505
15599
|
type: "delete",
|
|
15506
|
-
primaryKeys
|
|
15600
|
+
primaryKeys,
|
|
15507
15601
|
metadata: options?.metadata
|
|
15508
15602
|
});
|
|
15509
15603
|
if (options?.flush) {
|
|
@@ -15511,6 +15605,17 @@ var DataSourceApiImpl = class {
|
|
|
15511
15605
|
}
|
|
15512
15606
|
return result;
|
|
15513
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
|
+
};
|
|
15514
15619
|
this.addData = (data, options) => {
|
|
15515
15620
|
return this.addDataArray([data], options);
|
|
15516
15621
|
};
|
|
@@ -15524,9 +15629,33 @@ var DataSourceApiImpl = class {
|
|
|
15524
15629
|
return this.insertDataArray([data], options);
|
|
15525
15630
|
};
|
|
15526
15631
|
this.insertDataArray = (data, options) => {
|
|
15632
|
+
const isTree = this.getState().isTree;
|
|
15527
15633
|
let position2 = "before";
|
|
15528
15634
|
let primaryKey = void 0;
|
|
15529
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
|
+
}
|
|
15530
15659
|
if (options.position === "before" || options.position === "after") {
|
|
15531
15660
|
position2 = options.position;
|
|
15532
15661
|
primaryKey = options.primaryKey;
|
|
@@ -15534,13 +15663,20 @@ var DataSourceApiImpl = class {
|
|
|
15534
15663
|
const arr = this.getOriginalDataArray();
|
|
15535
15664
|
if (options.position === "start") {
|
|
15536
15665
|
position2 = "before";
|
|
15537
|
-
|
|
15666
|
+
if (!arr.length) {
|
|
15667
|
+
primaryKey = void 0;
|
|
15668
|
+
} else {
|
|
15669
|
+
primaryKey = this.toPrimaryKey(arr[0]);
|
|
15670
|
+
}
|
|
15538
15671
|
} else {
|
|
15539
15672
|
position2 = "after";
|
|
15540
|
-
|
|
15673
|
+
if (!arr.length) {
|
|
15674
|
+
primaryKey = void 0;
|
|
15675
|
+
} else {
|
|
15676
|
+
primaryKey = this.toPrimaryKey(arr[arr.length - 1]);
|
|
15677
|
+
}
|
|
15541
15678
|
}
|
|
15542
15679
|
}
|
|
15543
|
-
const isTree = this.getState().isTree;
|
|
15544
15680
|
const result = isTree ? this.batchOperation({
|
|
15545
15681
|
type: "insert",
|
|
15546
15682
|
array: data,
|
|
@@ -15560,6 +15696,41 @@ var DataSourceApiImpl = class {
|
|
|
15560
15696
|
}
|
|
15561
15697
|
return result;
|
|
15562
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
|
+
};
|
|
15563
15734
|
this.setSortInfo = (sortInfo) => {
|
|
15564
15735
|
const multiSort = this.getState().multiSort;
|
|
15565
15736
|
if (Array.isArray(sortInfo)) {
|
|
@@ -15636,6 +15807,9 @@ var DataSourceApiImpl = class {
|
|
|
15636
15807
|
this.actions = param.actions;
|
|
15637
15808
|
this.treeApi = new TreeApiImpl({ ...param, dataSourceApi: this });
|
|
15638
15809
|
}
|
|
15810
|
+
getPendingOperationPromise() {
|
|
15811
|
+
return this.pendingPromise;
|
|
15812
|
+
}
|
|
15639
15813
|
batchOperation(operation) {
|
|
15640
15814
|
if (!this.pendingPromise) {
|
|
15641
15815
|
this.pendingPromise = new Promise((resolve) => {
|
|
@@ -15665,7 +15839,8 @@ var DataSourceApiImpl = class {
|
|
|
15665
15839
|
return;
|
|
15666
15840
|
}
|
|
15667
15841
|
const currentCache = this.getState().cache;
|
|
15668
|
-
|
|
15842
|
+
const { isTree, nodesKey } = this.getState();
|
|
15843
|
+
let cache = currentCache ? DataSourceCache.clone(currentCache, { light: true }) : new DataSourceCache({ nodesKey: isTree ? nodesKey : void 0 });
|
|
15669
15844
|
operations.forEach((operation) => {
|
|
15670
15845
|
switch (operation.type) {
|
|
15671
15846
|
case "update":
|
|
@@ -15686,12 +15861,21 @@ var DataSourceApiImpl = class {
|
|
|
15686
15861
|
operation.nodePaths[index]
|
|
15687
15862
|
);
|
|
15688
15863
|
if (originalData) {
|
|
15689
|
-
|
|
15690
|
-
|
|
15691
|
-
|
|
15692
|
-
|
|
15693
|
-
|
|
15694
|
-
|
|
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
|
+
}
|
|
15695
15879
|
}
|
|
15696
15880
|
}
|
|
15697
15881
|
});
|
|
@@ -15724,7 +15908,7 @@ var DataSourceApiImpl = class {
|
|
|
15724
15908
|
if (nodePath) {
|
|
15725
15909
|
operation.array.forEach((data) => {
|
|
15726
15910
|
cache.insertNodePath(
|
|
15727
|
-
nodePath,
|
|
15911
|
+
[...nodePath],
|
|
15728
15912
|
data,
|
|
15729
15913
|
position2,
|
|
15730
15914
|
operation.metadata
|
|
@@ -15752,6 +15936,41 @@ var DataSourceApiImpl = class {
|
|
|
15752
15936
|
flush() {
|
|
15753
15937
|
return this.commit();
|
|
15754
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
|
+
}
|
|
15755
15974
|
commit() {
|
|
15756
15975
|
this.commitOperations(this.pendingOperations);
|
|
15757
15976
|
this.pendingOperations.length = 0;
|
|
@@ -16070,6 +16289,7 @@ function concludeReducer(params) {
|
|
|
16070
16289
|
}
|
|
16071
16290
|
const toPrimaryKey = state.toPrimaryKey;
|
|
16072
16291
|
const nodesKey = state.nodesKey;
|
|
16292
|
+
const isTree = state.isTree;
|
|
16073
16293
|
const getNodeChildren = nodesKey ? (node) => {
|
|
16074
16294
|
return node[nodesKey];
|
|
16075
16295
|
} : void 0;
|
|
@@ -16094,6 +16314,16 @@ function concludeReducer(params) {
|
|
|
16094
16314
|
nodesKey
|
|
16095
16315
|
}
|
|
16096
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
|
+
}
|
|
16097
16327
|
}
|
|
16098
16328
|
}
|
|
16099
16329
|
if (cache) {
|
|
@@ -16115,7 +16345,6 @@ function concludeReducer(params) {
|
|
|
16115
16345
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray || cacheAffectedParts.sortInfo);
|
|
16116
16346
|
const groupBy = state.groupBy;
|
|
16117
16347
|
const pivotBy = state.pivotBy;
|
|
16118
|
-
const isTree = state.isTree;
|
|
16119
16348
|
const shouldGroup = !isTree && (groupBy.length > 0 || !!pivotBy);
|
|
16120
16349
|
const shouldTree = isTree;
|
|
16121
16350
|
const rowDisabledStateDepsChanged = haveDepsChanged(previousState, state, [
|
|
@@ -17198,6 +17427,7 @@ function initSetupState() {
|
|
|
17198
17427
|
idToIndexMap: /* @__PURE__ */ new Map(),
|
|
17199
17428
|
idToPathMap: /* @__PURE__ */ new Map(),
|
|
17200
17429
|
pathToIndexMap: new DeepMap(),
|
|
17430
|
+
waitForNodePathPromises: new DeepMap(),
|
|
17201
17431
|
getDataSourceMasterContextRef: { current: () => void 0 },
|
|
17202
17432
|
// TODO: cleanup cache on unmount
|
|
17203
17433
|
cache: void 0,
|
|
@@ -17270,6 +17500,7 @@ var cleanupDataSource = (state) => {
|
|
|
17270
17500
|
};
|
|
17271
17501
|
state.treeExpandState?.destroy();
|
|
17272
17502
|
state.treePaths?.clear();
|
|
17503
|
+
state.waitForNodePathPromises.clear();
|
|
17273
17504
|
state.pathToIndexMap?.clear();
|
|
17274
17505
|
state.rowDisabledState?.destroy();
|
|
17275
17506
|
state.groupRowsState?.destroy();
|
|
@@ -22226,7 +22457,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
22226
22457
|
}
|
|
22227
22458
|
let valid2 = isValidLicense(licenseKey, {
|
|
22228
22459
|
publishedAt: 1624970570587,
|
|
22229
|
-
version: "6.0.
|
|
22460
|
+
version: "6.0.15"
|
|
22230
22461
|
});
|
|
22231
22462
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
22232
22463
|
return true;
|