@infinite-table/infinite-react 7.2.5-canary.2 → 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 +170 -41
- package/index.dev.mjs +168 -40
- package/index.js +8 -8
- package/index.mjs +8 -8
- package/package.json +2 -2
package/index.dev.mjs
CHANGED
|
@@ -9466,6 +9466,15 @@ var getHeaderWrapperNodes = (root) => {
|
|
|
9466
9466
|
);
|
|
9467
9467
|
};
|
|
9468
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
|
+
|
|
9469
9478
|
// src/components/InfiniteTable/hooks/useColumnPointerEvents.ts
|
|
9470
9479
|
var baseZIndexForCells2 = stripVar(InternalVars.baseZIndexForCells);
|
|
9471
9480
|
var equalPinning = (pinning1, pinning2) => {
|
|
@@ -9508,8 +9517,7 @@ var useColumnPointerEvents = ({
|
|
|
9508
9517
|
}, []);
|
|
9509
9518
|
const onPointerDown = useCallback9(
|
|
9510
9519
|
(e) => {
|
|
9511
|
-
|
|
9512
|
-
if (tagName === "INPUT" || tagName === "BUTTON") {
|
|
9520
|
+
if (isTargetInput(e.target)) {
|
|
9513
9521
|
return;
|
|
9514
9522
|
}
|
|
9515
9523
|
const { brain, draggableColumnsRestrictTo } = getState();
|
|
@@ -17015,52 +17023,103 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17015
17023
|
this.defaultSelection = false;
|
|
17016
17024
|
this.selectionMap = new DeepMap();
|
|
17017
17025
|
this.cache = new DeepMap();
|
|
17018
|
-
|
|
17026
|
+
this.correctnessChecks = false;
|
|
17027
|
+
const isTreeSelectionStateInstance = state instanceof Object.getPrototypeOf(this).constructor;
|
|
17028
|
+
const stateObject = isTreeSelectionStateInstance ? (
|
|
17019
17029
|
//@ts-ignore
|
|
17020
17030
|
state.getState()
|
|
17021
17031
|
) : state;
|
|
17022
|
-
this.
|
|
17032
|
+
this.setConfig(
|
|
17033
|
+
getConfig || (isTreeSelectionStateInstance ? state.config : {
|
|
17034
|
+
treePaths: new DeepMap()
|
|
17035
|
+
})
|
|
17036
|
+
);
|
|
17037
|
+
this.disableCorrectnessChecks();
|
|
17023
17038
|
this.update(stateObject);
|
|
17039
|
+
this.enableCorrectnessChecks();
|
|
17040
|
+
}
|
|
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;
|
|
17024
17064
|
}
|
|
17025
|
-
|
|
17026
|
-
return this.
|
|
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);
|
|
17027
17078
|
}
|
|
17028
17079
|
getSelectedLeafNodePaths(rootNodePath = [], treePaths) {
|
|
17029
|
-
treePaths = treePaths || this.getConfig().treePaths;
|
|
17030
17080
|
const selectedLeafPaths = [];
|
|
17031
|
-
|
|
17032
|
-
|
|
17033
|
-
|
|
17034
|
-
|
|
17035
|
-
|
|
17081
|
+
this.withTreePaths((paths) => {
|
|
17082
|
+
paths.getLeafNodesStartingWith(rootNodePath, (pair) => {
|
|
17083
|
+
if (this.isNodeSelected(pair.keys)) {
|
|
17084
|
+
selectedLeafPaths.push(pair.keys);
|
|
17085
|
+
}
|
|
17086
|
+
});
|
|
17087
|
+
}, treePaths);
|
|
17036
17088
|
return selectedLeafPaths;
|
|
17037
17089
|
}
|
|
17038
17090
|
getDeselectedLeafNodePaths(rootNodePath = [], treePaths) {
|
|
17039
|
-
treePaths = treePaths || this.getConfig().treePaths;
|
|
17040
17091
|
const deselectedLeafPaths = [];
|
|
17041
|
-
|
|
17042
|
-
|
|
17043
|
-
|
|
17044
|
-
|
|
17045
|
-
|
|
17092
|
+
this.withTreePaths((paths) => {
|
|
17093
|
+
paths.getLeafNodesStartingWith(rootNodePath, (pair) => {
|
|
17094
|
+
if (!this.isNodeSelected(pair.keys)) {
|
|
17095
|
+
deselectedLeafPaths.push(pair.keys);
|
|
17096
|
+
}
|
|
17097
|
+
});
|
|
17098
|
+
}, treePaths);
|
|
17046
17099
|
return deselectedLeafPaths;
|
|
17047
17100
|
}
|
|
17048
17101
|
isLeafNode(nodePath) {
|
|
17049
|
-
|
|
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;
|
|
17050
17111
|
}
|
|
17051
17112
|
getLeafNodesCount(nodePath) {
|
|
17052
|
-
|
|
17053
|
-
const deepMapValue = treeDeepMap.get(nodePath);
|
|
17054
|
-
if (!deepMapValue) {
|
|
17055
|
-
return 1;
|
|
17056
|
-
}
|
|
17057
|
-
return deepMapValue.items.length;
|
|
17113
|
+
return this.config.treePaths.getKeysForLeafNodesStartingWith(nodePath).length;
|
|
17058
17114
|
}
|
|
17059
17115
|
static from(treeSelectionState, getConfig) {
|
|
17060
17116
|
return new _TreeSelectionState(treeSelectionState, getConfig);
|
|
17061
17117
|
}
|
|
17062
|
-
|
|
17063
|
-
|
|
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
|
+
};
|
|
17064
17123
|
this.xcache();
|
|
17065
17124
|
}
|
|
17066
17125
|
xcache() {
|
|
@@ -17081,6 +17140,9 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17081
17140
|
this.xcache();
|
|
17082
17141
|
}
|
|
17083
17142
|
setSelectionForPath(nodePath, selected) {
|
|
17143
|
+
if (!this.isPathAvailable(nodePath)) {
|
|
17144
|
+
return;
|
|
17145
|
+
}
|
|
17084
17146
|
this.selectionMap.set(nodePath, selected);
|
|
17085
17147
|
}
|
|
17086
17148
|
getState() {
|
|
@@ -17113,6 +17175,19 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17113
17175
|
selectedPaths: []
|
|
17114
17176
|
});
|
|
17115
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
|
+
}
|
|
17116
17191
|
isNodeSelected(nodePath) {
|
|
17117
17192
|
return this.isPathSelected(nodePath);
|
|
17118
17193
|
}
|
|
@@ -17128,7 +17203,7 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17128
17203
|
if (cachedResult) {
|
|
17129
17204
|
return cachedResult;
|
|
17130
17205
|
}
|
|
17131
|
-
if (this.isLeafNode(nodePath)) {
|
|
17206
|
+
if (this.isLeafNode(nodePath) !== false) {
|
|
17132
17207
|
const selected = this.isSelfSelected(nodePath);
|
|
17133
17208
|
if (selected !== null) {
|
|
17134
17209
|
return this.cacheIt(nodePath, {
|
|
@@ -17142,9 +17217,12 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17142
17217
|
const leafCount = this.getLeafNodesCount(nodePath);
|
|
17143
17218
|
let currentSelectionState = this.isSelfSelected(nodePath);
|
|
17144
17219
|
const { selectionMap } = this;
|
|
17145
|
-
|
|
17220
|
+
let childPaths = selectionMap.getKeysOfFirstChildOnEachBranchStartingWith(nodePath, {
|
|
17146
17221
|
excludeSelf: true
|
|
17147
17222
|
}).sort(shortestToLongest);
|
|
17223
|
+
if (this.correctnessChecks) {
|
|
17224
|
+
childPaths = childPaths.filter((path) => this.isPathAvailable(path));
|
|
17225
|
+
}
|
|
17148
17226
|
if (!childPaths.length) {
|
|
17149
17227
|
if (currentSelectionState !== null) {
|
|
17150
17228
|
const res2 = leafCount ? currentSelectionState : (
|
|
@@ -17218,6 +17296,9 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17218
17296
|
});
|
|
17219
17297
|
}
|
|
17220
17298
|
isPathSelected(nodePath) {
|
|
17299
|
+
if (!this.isPathAvailable(nodePath)) {
|
|
17300
|
+
return false;
|
|
17301
|
+
}
|
|
17221
17302
|
return this.getSelectionStateForNode(nodePath, true).selected;
|
|
17222
17303
|
}
|
|
17223
17304
|
getNodeBooleanSelectionStateFromParent(initialNodePath) {
|
|
@@ -17239,6 +17320,7 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17239
17320
|
if (!nodePath.length) {
|
|
17240
17321
|
return;
|
|
17241
17322
|
}
|
|
17323
|
+
this.xcache();
|
|
17242
17324
|
const keys = this.selectionMap.getKeysStartingWith(nodePath);
|
|
17243
17325
|
keys.forEach((nodePath2) => {
|
|
17244
17326
|
this.selectionMap.delete(nodePath2);
|
|
@@ -17278,7 +17360,7 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17278
17360
|
};
|
|
17279
17361
|
}
|
|
17280
17362
|
destroy() {
|
|
17281
|
-
this.
|
|
17363
|
+
this.config = void 0;
|
|
17282
17364
|
this.xcache();
|
|
17283
17365
|
this.selectionMap.clear();
|
|
17284
17366
|
}
|
|
@@ -17295,8 +17377,7 @@ function treeSelectionStateConfigGetter(stateOrStateGetter) {
|
|
|
17295
17377
|
return () => {
|
|
17296
17378
|
const state = typeof stateOrStateGetter === "function" ? stateOrStateGetter() : stateOrStateGetter;
|
|
17297
17379
|
return {
|
|
17298
|
-
treePaths: state.treePaths
|
|
17299
|
-
treeDeepMap: state.treeDeepMap
|
|
17380
|
+
treePaths: state.treePaths
|
|
17300
17381
|
};
|
|
17301
17382
|
};
|
|
17302
17383
|
}
|
|
@@ -17322,7 +17403,10 @@ var TreeApiImpl = class {
|
|
|
17322
17403
|
treeSelectionStateConfigGetter(this.getState)
|
|
17323
17404
|
);
|
|
17324
17405
|
treeSelectionState.setNodeSelection(nodePath, selected);
|
|
17325
|
-
this.getState().lastSelectionUpdatedNodePathRef.current =
|
|
17406
|
+
this.getState().lastSelectionUpdatedNodePathRef.current = {
|
|
17407
|
+
nodePath,
|
|
17408
|
+
selected
|
|
17409
|
+
};
|
|
17326
17410
|
this.actions.treeSelection = treeSelectionState;
|
|
17327
17411
|
};
|
|
17328
17412
|
this.getCallbackParam = (_nodePath) => {
|
|
@@ -17480,8 +17564,7 @@ var TreeApiImpl = class {
|
|
|
17480
17564
|
}
|
|
17481
17565
|
}
|
|
17482
17566
|
getNodeDataByPath(nodePath) {
|
|
17483
|
-
|
|
17484
|
-
if (!treeDeepMap || !nodePath.length) {
|
|
17567
|
+
if (!nodePath.length) {
|
|
17485
17568
|
return null;
|
|
17486
17569
|
}
|
|
17487
17570
|
const rowInfo = this.getRowInfoByPath(nodePath);
|
|
@@ -18964,6 +19047,14 @@ function concludeReducer(params) {
|
|
|
18964
19047
|
const shouldTreeAgain = shouldTree && (treeDepsChanged || cacheAffectedParts.tree || !state.lastTreeDataArray) || treeSelectionDepsChanged || rowDisabledStateDepsChanged || rowInfoReducersChanged;
|
|
18965
19048
|
const now = Date.now();
|
|
18966
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
|
+
}
|
|
18967
19058
|
if (!shouldFilter) {
|
|
18968
19059
|
state.unfilteredCount = dataArray.length;
|
|
18969
19060
|
}
|
|
@@ -20262,6 +20353,7 @@ var cleanupDataSource = (state) => {
|
|
|
20262
20353
|
};
|
|
20263
20354
|
state.treeExpandState?.destroy();
|
|
20264
20355
|
state.treePaths?.clear();
|
|
20356
|
+
state.unfilteredTreePaths?.clear();
|
|
20265
20357
|
state.waitForNodePathPromises.clear();
|
|
20266
20358
|
state.pathToIndexMap?.clear();
|
|
20267
20359
|
state.rowDisabledState?.destroy();
|
|
@@ -20421,7 +20513,7 @@ function getTreeSelectionState(currentTreeSelection, selectionMode, state) {
|
|
|
20421
20513
|
}
|
|
20422
20514
|
const config = treeSelectionStateConfigGetter(state);
|
|
20423
20515
|
if (currentTreeSelection instanceof TreeSelectionState) {
|
|
20424
|
-
currentTreeSelection.
|
|
20516
|
+
currentTreeSelection.setConfig(config);
|
|
20425
20517
|
return currentTreeSelection;
|
|
20426
20518
|
}
|
|
20427
20519
|
if (currentTreeSelection === null || currentTreeSelection === void 0 || typeof currentTreeSelection != "object") {
|
|
@@ -20430,7 +20522,7 @@ function getTreeSelectionState(currentTreeSelection, selectionMode, state) {
|
|
|
20430
20522
|
const treeSelectionStateObject = currentTreeSelection ?? treeSelectionStateDefaultObject;
|
|
20431
20523
|
let instance = weakMap.get(treeSelectionStateObject);
|
|
20432
20524
|
if (instance) {
|
|
20433
|
-
instance.
|
|
20525
|
+
instance.setConfig(config);
|
|
20434
20526
|
}
|
|
20435
20527
|
instance = instance ?? new TreeSelectionState(treeSelectionStateObject, config);
|
|
20436
20528
|
weakMap.set(treeSelectionStateObject, instance);
|
|
@@ -20692,8 +20784,10 @@ function getMappedCallbacks() {
|
|
|
20692
20784
|
treeSelection2.getState(),
|
|
20693
20785
|
{
|
|
20694
20786
|
treeSelectionState: treeSelection2,
|
|
20787
|
+
prevTreeSelectionState: state.treeSelectionState,
|
|
20695
20788
|
selectionMode: "multi-row",
|
|
20696
|
-
|
|
20789
|
+
lastUpdatedNodeInfo: state.lastSelectionUpdatedNodePathRef.current,
|
|
20790
|
+
unfilteredTreePaths: state.unfilteredTreePaths,
|
|
20697
20791
|
dataSourceApi,
|
|
20698
20792
|
treeApi
|
|
20699
20793
|
}
|
|
@@ -25680,7 +25774,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
25680
25774
|
}
|
|
25681
25775
|
let valid2 = isValidLicense(licenseKey, {
|
|
25682
25776
|
publishedAt: 1624970570587,
|
|
25683
|
-
version: "7.2.5
|
|
25777
|
+
version: "7.2.5"
|
|
25684
25778
|
});
|
|
25685
25779
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
25686
25780
|
return true;
|
|
@@ -25782,6 +25876,9 @@ function onCellClick(context, event) {
|
|
|
25782
25876
|
context.getState().onCellClick?.(context, event);
|
|
25783
25877
|
}
|
|
25784
25878
|
function onCellDoubleClick(context, event) {
|
|
25879
|
+
if (isTargetInput(event.target)) {
|
|
25880
|
+
return;
|
|
25881
|
+
}
|
|
25785
25882
|
const { onCellDoubleClick: onCellDoubleClick2 } = context.getState();
|
|
25786
25883
|
let dblClickResult = {
|
|
25787
25884
|
preventEdit: false
|
|
@@ -30146,6 +30243,36 @@ import * as React78 from "react";
|
|
|
30146
30243
|
function TreeGrid(props) {
|
|
30147
30244
|
return /* @__PURE__ */ React78.createElement(InfiniteTable, { ...props });
|
|
30148
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
|
+
};
|
|
30149
30276
|
|
|
30150
30277
|
// src/components/DataSource/DataLoader/DataQuery.ts
|
|
30151
30278
|
var DataQuery = class {
|
|
@@ -30904,6 +31031,7 @@ export {
|
|
|
30904
31031
|
useOverlayPortal,
|
|
30905
31032
|
usePrevious,
|
|
30906
31033
|
useRowInfoReducers,
|
|
30907
|
-
useVisibleColumnSizes
|
|
31034
|
+
useVisibleColumnSizes,
|
|
31035
|
+
withSelectedLeafNodesOnly
|
|
30908
31036
|
};
|
|
30909
31037
|
//!collapsed || lazyLoad;
|