@infinite-table/infinite-react 7.2.5-canary.1 → 7.2.5
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 -36
- package/index.dev.js +178 -45
- package/index.dev.mjs +176 -44
- package/index.js +8 -8
- package/index.mjs +8 -8
- package/package.json +2 -2
package/index.dev.mjs
CHANGED
|
@@ -1416,13 +1416,17 @@ function AvoidReactDiffFn(props) {
|
|
|
1416
1416
|
cancelAnimationFrame(rafId.current);
|
|
1417
1417
|
}
|
|
1418
1418
|
rafId.current = requestAnimationFrame(() => {
|
|
1419
|
-
|
|
1420
|
-
|
|
1419
|
+
queueMicrotask(() => {
|
|
1420
|
+
flushSync(() => {
|
|
1421
|
+
setChildren(children2);
|
|
1422
|
+
});
|
|
1421
1423
|
});
|
|
1422
1424
|
});
|
|
1423
1425
|
} else {
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
+
queueMicrotask(() => {
|
|
1427
|
+
flushSync(() => {
|
|
1428
|
+
setChildren(children2);
|
|
1429
|
+
});
|
|
1426
1430
|
});
|
|
1427
1431
|
}
|
|
1428
1432
|
}
|
|
@@ -9462,6 +9466,15 @@ var getHeaderWrapperNodes = (root) => {
|
|
|
9462
9466
|
);
|
|
9463
9467
|
};
|
|
9464
9468
|
|
|
9469
|
+
// src/utils/isTargetInput.ts
|
|
9470
|
+
function isTargetInput(target) {
|
|
9471
|
+
if (!target) {
|
|
9472
|
+
return false;
|
|
9473
|
+
}
|
|
9474
|
+
const tagName = target.tagName;
|
|
9475
|
+
return tagName === "INPUT" || tagName === "BUTTON";
|
|
9476
|
+
}
|
|
9477
|
+
|
|
9465
9478
|
// src/components/InfiniteTable/hooks/useColumnPointerEvents.ts
|
|
9466
9479
|
var baseZIndexForCells2 = stripVar(InternalVars.baseZIndexForCells);
|
|
9467
9480
|
var equalPinning = (pinning1, pinning2) => {
|
|
@@ -9504,8 +9517,7 @@ var useColumnPointerEvents = ({
|
|
|
9504
9517
|
}, []);
|
|
9505
9518
|
const onPointerDown = useCallback9(
|
|
9506
9519
|
(e) => {
|
|
9507
|
-
|
|
9508
|
-
if (tagName === "INPUT" || tagName === "BUTTON") {
|
|
9520
|
+
if (isTargetInput(e.target)) {
|
|
9509
9521
|
return;
|
|
9510
9522
|
}
|
|
9511
9523
|
const { brain, draggableColumnsRestrictTo } = getState();
|
|
@@ -17011,52 +17023,103 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17011
17023
|
this.defaultSelection = false;
|
|
17012
17024
|
this.selectionMap = new DeepMap();
|
|
17013
17025
|
this.cache = new DeepMap();
|
|
17014
|
-
|
|
17026
|
+
this.correctnessChecks = false;
|
|
17027
|
+
const isTreeSelectionStateInstance = state instanceof Object.getPrototypeOf(this).constructor;
|
|
17028
|
+
const stateObject = isTreeSelectionStateInstance ? (
|
|
17015
17029
|
//@ts-ignore
|
|
17016
17030
|
state.getState()
|
|
17017
17031
|
) : state;
|
|
17018
|
-
this.
|
|
17032
|
+
this.setConfig(
|
|
17033
|
+
getConfig || (isTreeSelectionStateInstance ? state.config : {
|
|
17034
|
+
treePaths: new DeepMap()
|
|
17035
|
+
})
|
|
17036
|
+
);
|
|
17037
|
+
this.disableCorrectnessChecks();
|
|
17019
17038
|
this.update(stateObject);
|
|
17039
|
+
this.enableCorrectnessChecks();
|
|
17020
17040
|
}
|
|
17021
|
-
|
|
17022
|
-
|
|
17041
|
+
getTreePaths(treePaths) {
|
|
17042
|
+
if (treePaths) {
|
|
17043
|
+
if (Array.isArray(treePaths)) {
|
|
17044
|
+
return new DeepMap(treePaths.map((path) => [path, true]));
|
|
17045
|
+
}
|
|
17046
|
+
return treePaths;
|
|
17047
|
+
}
|
|
17048
|
+
return this.config.treePaths;
|
|
17049
|
+
}
|
|
17050
|
+
withTreePaths(fn, treePaths) {
|
|
17051
|
+
const initialTreePaths = this.config.treePaths;
|
|
17052
|
+
treePaths = this.getTreePaths(treePaths);
|
|
17053
|
+
const treePathsDifferent = treePaths !== initialTreePaths;
|
|
17054
|
+
if (treePathsDifferent) {
|
|
17055
|
+
this.xcache();
|
|
17056
|
+
}
|
|
17057
|
+
this.config.treePaths = treePaths;
|
|
17058
|
+
const result = fn(treePaths);
|
|
17059
|
+
this.config.treePaths = initialTreePaths;
|
|
17060
|
+
if (treePathsDifferent) {
|
|
17061
|
+
this.xcache();
|
|
17062
|
+
}
|
|
17063
|
+
return result;
|
|
17064
|
+
}
|
|
17065
|
+
getLeafNodePaths(rootNodePath = [], treePaths) {
|
|
17066
|
+
return this.withTreePaths((paths) => {
|
|
17067
|
+
return paths.getKeysForLeafNodesStartingWith(rootNodePath);
|
|
17068
|
+
}, treePaths);
|
|
17069
|
+
}
|
|
17070
|
+
forEachLeafNodePath(fn, rootNodePath = [], treePaths) {
|
|
17071
|
+
const selectedObj = { selected: false };
|
|
17072
|
+
this.withTreePaths((paths) => {
|
|
17073
|
+
paths.getLeafNodesStartingWith(rootNodePath, (pair) => {
|
|
17074
|
+
selectedObj.selected = this.isNodeSelected(pair.keys) === true;
|
|
17075
|
+
fn(pair.keys, selectedObj);
|
|
17076
|
+
});
|
|
17077
|
+
}, treePaths);
|
|
17023
17078
|
}
|
|
17024
17079
|
getSelectedLeafNodePaths(rootNodePath = [], treePaths) {
|
|
17025
|
-
treePaths = treePaths || this.getConfig().treePaths;
|
|
17026
17080
|
const selectedLeafPaths = [];
|
|
17027
|
-
|
|
17028
|
-
|
|
17029
|
-
|
|
17030
|
-
|
|
17031
|
-
|
|
17081
|
+
this.withTreePaths((paths) => {
|
|
17082
|
+
paths.getLeafNodesStartingWith(rootNodePath, (pair) => {
|
|
17083
|
+
if (this.isNodeSelected(pair.keys)) {
|
|
17084
|
+
selectedLeafPaths.push(pair.keys);
|
|
17085
|
+
}
|
|
17086
|
+
});
|
|
17087
|
+
}, treePaths);
|
|
17032
17088
|
return selectedLeafPaths;
|
|
17033
17089
|
}
|
|
17034
17090
|
getDeselectedLeafNodePaths(rootNodePath = [], treePaths) {
|
|
17035
|
-
treePaths = treePaths || this.getConfig().treePaths;
|
|
17036
17091
|
const deselectedLeafPaths = [];
|
|
17037
|
-
|
|
17038
|
-
|
|
17039
|
-
|
|
17040
|
-
|
|
17041
|
-
|
|
17092
|
+
this.withTreePaths((paths) => {
|
|
17093
|
+
paths.getLeafNodesStartingWith(rootNodePath, (pair) => {
|
|
17094
|
+
if (!this.isNodeSelected(pair.keys)) {
|
|
17095
|
+
deselectedLeafPaths.push(pair.keys);
|
|
17096
|
+
}
|
|
17097
|
+
});
|
|
17098
|
+
}, treePaths);
|
|
17042
17099
|
return deselectedLeafPaths;
|
|
17043
17100
|
}
|
|
17044
17101
|
isLeafNode(nodePath) {
|
|
17045
|
-
|
|
17102
|
+
const { treePaths } = this.config;
|
|
17103
|
+
if (!treePaths.has(nodePath)) {
|
|
17104
|
+
return null;
|
|
17105
|
+
}
|
|
17106
|
+
const keys = treePaths.getKeysForLeafNodesStartingWith(nodePath);
|
|
17107
|
+
if (keys.length === 1) {
|
|
17108
|
+
return true;
|
|
17109
|
+
}
|
|
17110
|
+
return false;
|
|
17046
17111
|
}
|
|
17047
17112
|
getLeafNodesCount(nodePath) {
|
|
17048
|
-
|
|
17049
|
-
const deepMapValue = treeDeepMap.get(nodePath);
|
|
17050
|
-
if (!deepMapValue) {
|
|
17051
|
-
return 1;
|
|
17052
|
-
}
|
|
17053
|
-
return deepMapValue.items.length;
|
|
17113
|
+
return this.config.treePaths.getKeysForLeafNodesStartingWith(nodePath).length;
|
|
17054
17114
|
}
|
|
17055
17115
|
static from(treeSelectionState, getConfig) {
|
|
17056
17116
|
return new _TreeSelectionState(treeSelectionState, getConfig);
|
|
17057
17117
|
}
|
|
17058
|
-
|
|
17059
|
-
|
|
17118
|
+
setConfig(getConfig) {
|
|
17119
|
+
const config = typeof getConfig === "function" ? getConfig() : getConfig;
|
|
17120
|
+
this.config = {
|
|
17121
|
+
treePaths: Array.isArray(config.treePaths) ? new DeepMap(config.treePaths.map((path) => [path, true])) : config.treePaths
|
|
17122
|
+
};
|
|
17060
17123
|
this.xcache();
|
|
17061
17124
|
}
|
|
17062
17125
|
xcache() {
|
|
@@ -17077,6 +17140,9 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17077
17140
|
this.xcache();
|
|
17078
17141
|
}
|
|
17079
17142
|
setSelectionForPath(nodePath, selected) {
|
|
17143
|
+
if (!this.isPathAvailable(nodePath)) {
|
|
17144
|
+
return;
|
|
17145
|
+
}
|
|
17080
17146
|
this.selectionMap.set(nodePath, selected);
|
|
17081
17147
|
}
|
|
17082
17148
|
getState() {
|
|
@@ -17109,6 +17175,19 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17109
17175
|
selectedPaths: []
|
|
17110
17176
|
});
|
|
17111
17177
|
}
|
|
17178
|
+
enableCorrectnessChecks() {
|
|
17179
|
+
this.correctnessChecks = true;
|
|
17180
|
+
}
|
|
17181
|
+
disableCorrectnessChecks() {
|
|
17182
|
+
this.correctnessChecks = false;
|
|
17183
|
+
}
|
|
17184
|
+
isPathAvailable(nodePath) {
|
|
17185
|
+
if (!this.correctnessChecks) {
|
|
17186
|
+
return true;
|
|
17187
|
+
}
|
|
17188
|
+
const { treePaths } = this.config;
|
|
17189
|
+
return treePaths.has(nodePath);
|
|
17190
|
+
}
|
|
17112
17191
|
isNodeSelected(nodePath) {
|
|
17113
17192
|
return this.isPathSelected(nodePath);
|
|
17114
17193
|
}
|
|
@@ -17124,7 +17203,7 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17124
17203
|
if (cachedResult) {
|
|
17125
17204
|
return cachedResult;
|
|
17126
17205
|
}
|
|
17127
|
-
if (this.isLeafNode(nodePath)) {
|
|
17206
|
+
if (this.isLeafNode(nodePath) !== false) {
|
|
17128
17207
|
const selected = this.isSelfSelected(nodePath);
|
|
17129
17208
|
if (selected !== null) {
|
|
17130
17209
|
return this.cacheIt(nodePath, {
|
|
@@ -17138,9 +17217,12 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17138
17217
|
const leafCount = this.getLeafNodesCount(nodePath);
|
|
17139
17218
|
let currentSelectionState = this.isSelfSelected(nodePath);
|
|
17140
17219
|
const { selectionMap } = this;
|
|
17141
|
-
|
|
17220
|
+
let childPaths = selectionMap.getKeysOfFirstChildOnEachBranchStartingWith(nodePath, {
|
|
17142
17221
|
excludeSelf: true
|
|
17143
17222
|
}).sort(shortestToLongest);
|
|
17223
|
+
if (this.correctnessChecks) {
|
|
17224
|
+
childPaths = childPaths.filter((path) => this.isPathAvailable(path));
|
|
17225
|
+
}
|
|
17144
17226
|
if (!childPaths.length) {
|
|
17145
17227
|
if (currentSelectionState !== null) {
|
|
17146
17228
|
const res2 = leafCount ? currentSelectionState : (
|
|
@@ -17214,6 +17296,9 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17214
17296
|
});
|
|
17215
17297
|
}
|
|
17216
17298
|
isPathSelected(nodePath) {
|
|
17299
|
+
if (!this.isPathAvailable(nodePath)) {
|
|
17300
|
+
return false;
|
|
17301
|
+
}
|
|
17217
17302
|
return this.getSelectionStateForNode(nodePath, true).selected;
|
|
17218
17303
|
}
|
|
17219
17304
|
getNodeBooleanSelectionStateFromParent(initialNodePath) {
|
|
@@ -17235,6 +17320,7 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17235
17320
|
if (!nodePath.length) {
|
|
17236
17321
|
return;
|
|
17237
17322
|
}
|
|
17323
|
+
this.xcache();
|
|
17238
17324
|
const keys = this.selectionMap.getKeysStartingWith(nodePath);
|
|
17239
17325
|
keys.forEach((nodePath2) => {
|
|
17240
17326
|
this.selectionMap.delete(nodePath2);
|
|
@@ -17274,7 +17360,7 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17274
17360
|
};
|
|
17275
17361
|
}
|
|
17276
17362
|
destroy() {
|
|
17277
|
-
this.
|
|
17363
|
+
this.config = void 0;
|
|
17278
17364
|
this.xcache();
|
|
17279
17365
|
this.selectionMap.clear();
|
|
17280
17366
|
}
|
|
@@ -17291,8 +17377,7 @@ function treeSelectionStateConfigGetter(stateOrStateGetter) {
|
|
|
17291
17377
|
return () => {
|
|
17292
17378
|
const state = typeof stateOrStateGetter === "function" ? stateOrStateGetter() : stateOrStateGetter;
|
|
17293
17379
|
return {
|
|
17294
|
-
treePaths: state.treePaths
|
|
17295
|
-
treeDeepMap: state.treeDeepMap
|
|
17380
|
+
treePaths: state.treePaths
|
|
17296
17381
|
};
|
|
17297
17382
|
};
|
|
17298
17383
|
}
|
|
@@ -17318,7 +17403,10 @@ var TreeApiImpl = class {
|
|
|
17318
17403
|
treeSelectionStateConfigGetter(this.getState)
|
|
17319
17404
|
);
|
|
17320
17405
|
treeSelectionState.setNodeSelection(nodePath, selected);
|
|
17321
|
-
this.getState().lastSelectionUpdatedNodePathRef.current =
|
|
17406
|
+
this.getState().lastSelectionUpdatedNodePathRef.current = {
|
|
17407
|
+
nodePath,
|
|
17408
|
+
selected
|
|
17409
|
+
};
|
|
17322
17410
|
this.actions.treeSelection = treeSelectionState;
|
|
17323
17411
|
};
|
|
17324
17412
|
this.getCallbackParam = (_nodePath) => {
|
|
@@ -17476,8 +17564,7 @@ var TreeApiImpl = class {
|
|
|
17476
17564
|
}
|
|
17477
17565
|
}
|
|
17478
17566
|
getNodeDataByPath(nodePath) {
|
|
17479
|
-
|
|
17480
|
-
if (!treeDeepMap || !nodePath.length) {
|
|
17567
|
+
if (!nodePath.length) {
|
|
17481
17568
|
return null;
|
|
17482
17569
|
}
|
|
17483
17570
|
const rowInfo = this.getRowInfoByPath(nodePath);
|
|
@@ -18960,6 +19047,14 @@ function concludeReducer(params) {
|
|
|
18960
19047
|
const shouldTreeAgain = shouldTree && (treeDepsChanged || cacheAffectedParts.tree || !state.lastTreeDataArray) || treeSelectionDepsChanged || rowDisabledStateDepsChanged || rowInfoReducersChanged;
|
|
18961
19048
|
const now = Date.now();
|
|
18962
19049
|
let dataArray = state.originalDataArray;
|
|
19050
|
+
if (shouldTree && shouldTreeAgain) {
|
|
19051
|
+
const treeParams = {
|
|
19052
|
+
isLeafNode,
|
|
19053
|
+
getNodeChildren,
|
|
19054
|
+
toKey: toPrimaryKey
|
|
19055
|
+
};
|
|
19056
|
+
state.unfilteredTreePaths = tree(treeParams, dataArray).treePaths;
|
|
19057
|
+
}
|
|
18963
19058
|
if (!shouldFilter) {
|
|
18964
19059
|
state.unfilteredCount = dataArray.length;
|
|
18965
19060
|
}
|
|
@@ -20258,6 +20353,7 @@ var cleanupDataSource = (state) => {
|
|
|
20258
20353
|
};
|
|
20259
20354
|
state.treeExpandState?.destroy();
|
|
20260
20355
|
state.treePaths?.clear();
|
|
20356
|
+
state.unfilteredTreePaths?.clear();
|
|
20261
20357
|
state.waitForNodePathPromises.clear();
|
|
20262
20358
|
state.pathToIndexMap?.clear();
|
|
20263
20359
|
state.rowDisabledState?.destroy();
|
|
@@ -20417,7 +20513,7 @@ function getTreeSelectionState(currentTreeSelection, selectionMode, state) {
|
|
|
20417
20513
|
}
|
|
20418
20514
|
const config = treeSelectionStateConfigGetter(state);
|
|
20419
20515
|
if (currentTreeSelection instanceof TreeSelectionState) {
|
|
20420
|
-
currentTreeSelection.
|
|
20516
|
+
currentTreeSelection.setConfig(config);
|
|
20421
20517
|
return currentTreeSelection;
|
|
20422
20518
|
}
|
|
20423
20519
|
if (currentTreeSelection === null || currentTreeSelection === void 0 || typeof currentTreeSelection != "object") {
|
|
@@ -20426,7 +20522,7 @@ function getTreeSelectionState(currentTreeSelection, selectionMode, state) {
|
|
|
20426
20522
|
const treeSelectionStateObject = currentTreeSelection ?? treeSelectionStateDefaultObject;
|
|
20427
20523
|
let instance = weakMap.get(treeSelectionStateObject);
|
|
20428
20524
|
if (instance) {
|
|
20429
|
-
instance.
|
|
20525
|
+
instance.setConfig(config);
|
|
20430
20526
|
}
|
|
20431
20527
|
instance = instance ?? new TreeSelectionState(treeSelectionStateObject, config);
|
|
20432
20528
|
weakMap.set(treeSelectionStateObject, instance);
|
|
@@ -20688,8 +20784,10 @@ function getMappedCallbacks() {
|
|
|
20688
20784
|
treeSelection2.getState(),
|
|
20689
20785
|
{
|
|
20690
20786
|
treeSelectionState: treeSelection2,
|
|
20787
|
+
prevTreeSelectionState: state.treeSelectionState,
|
|
20691
20788
|
selectionMode: "multi-row",
|
|
20692
|
-
|
|
20789
|
+
lastUpdatedNodeInfo: state.lastSelectionUpdatedNodePathRef.current,
|
|
20790
|
+
unfilteredTreePaths: state.unfilteredTreePaths,
|
|
20693
20791
|
dataSourceApi,
|
|
20694
20792
|
treeApi
|
|
20695
20793
|
}
|
|
@@ -25676,7 +25774,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
25676
25774
|
}
|
|
25677
25775
|
let valid2 = isValidLicense(licenseKey, {
|
|
25678
25776
|
publishedAt: 1624970570587,
|
|
25679
|
-
version: "7.2.5
|
|
25777
|
+
version: "7.2.5"
|
|
25680
25778
|
});
|
|
25681
25779
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
25682
25780
|
return true;
|
|
@@ -25778,6 +25876,9 @@ function onCellClick(context, event) {
|
|
|
25778
25876
|
context.getState().onCellClick?.(context, event);
|
|
25779
25877
|
}
|
|
25780
25878
|
function onCellDoubleClick(context, event) {
|
|
25879
|
+
if (isTargetInput(event.target)) {
|
|
25880
|
+
return;
|
|
25881
|
+
}
|
|
25781
25882
|
const { onCellDoubleClick: onCellDoubleClick2 } = context.getState();
|
|
25782
25883
|
let dblClickResult = {
|
|
25783
25884
|
preventEdit: false
|
|
@@ -30142,6 +30243,36 @@ import * as React78 from "react";
|
|
|
30142
30243
|
function TreeGrid(props) {
|
|
30143
30244
|
return /* @__PURE__ */ React78.createElement(InfiniteTable, { ...props });
|
|
30144
30245
|
}
|
|
30246
|
+
var withSelectedLeafNodesOnly = (callback) => {
|
|
30247
|
+
const onTreeSelectionChange = (_, {
|
|
30248
|
+
unfilteredTreePaths,
|
|
30249
|
+
treeSelectionState,
|
|
30250
|
+
prevTreeSelectionState,
|
|
30251
|
+
lastUpdatedNodeInfo
|
|
30252
|
+
}) => {
|
|
30253
|
+
const newTreeSelection = new TreeSelectionState(prevTreeSelectionState, {
|
|
30254
|
+
treePaths: unfilteredTreePaths
|
|
30255
|
+
});
|
|
30256
|
+
treeSelectionState.forEachLeafNodePath((nodePath, { selected }) => {
|
|
30257
|
+
newTreeSelection.setNodeSelection(nodePath, selected);
|
|
30258
|
+
});
|
|
30259
|
+
if (lastUpdatedNodeInfo) {
|
|
30260
|
+
treeSelectionState.forEachLeafNodePath((nodePath) => {
|
|
30261
|
+
newTreeSelection.setNodeSelection(
|
|
30262
|
+
nodePath,
|
|
30263
|
+
lastUpdatedNodeInfo.selected
|
|
30264
|
+
);
|
|
30265
|
+
}, lastUpdatedNodeInfo.nodePath);
|
|
30266
|
+
}
|
|
30267
|
+
const selectedPaths = newTreeSelection.getSelectedLeafNodePaths();
|
|
30268
|
+
const treeSelectionObject = {
|
|
30269
|
+
defaultSelection: false,
|
|
30270
|
+
selectedPaths
|
|
30271
|
+
};
|
|
30272
|
+
callback(treeSelectionObject);
|
|
30273
|
+
};
|
|
30274
|
+
return onTreeSelectionChange;
|
|
30275
|
+
};
|
|
30145
30276
|
|
|
30146
30277
|
// src/components/DataSource/DataLoader/DataQuery.ts
|
|
30147
30278
|
var DataQuery = class {
|
|
@@ -30900,6 +31031,7 @@ export {
|
|
|
30900
31031
|
useOverlayPortal,
|
|
30901
31032
|
usePrevious,
|
|
30902
31033
|
useRowInfoReducers,
|
|
30903
|
-
useVisibleColumnSizes
|
|
31034
|
+
useVisibleColumnSizes,
|
|
31035
|
+
withSelectedLeafNodesOnly
|
|
30904
31036
|
};
|
|
30905
31037
|
//!collapsed || lazyLoad;
|