@infinite-table/infinite-react 7.2.5-canary.2 → 7.3.0
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 +3 -3
package/index.dev.js
CHANGED
|
@@ -128,7 +128,8 @@ __export(index_exports, {
|
|
|
128
128
|
useOverlayPortal: () => useOverlayPortal,
|
|
129
129
|
usePrevious: () => usePrevious,
|
|
130
130
|
useRowInfoReducers: () => useRowInfoReducers,
|
|
131
|
-
useVisibleColumnSizes: () => useVisibleColumnSizes
|
|
131
|
+
useVisibleColumnSizes: () => useVisibleColumnSizes,
|
|
132
|
+
withSelectedLeafNodesOnly: () => withSelectedLeafNodesOnly
|
|
132
133
|
});
|
|
133
134
|
module.exports = __toCommonJS(index_exports);
|
|
134
135
|
|
|
@@ -9525,6 +9526,15 @@ var getHeaderWrapperNodes = (root) => {
|
|
|
9525
9526
|
);
|
|
9526
9527
|
};
|
|
9527
9528
|
|
|
9529
|
+
// src/utils/isTargetInput.ts
|
|
9530
|
+
function isTargetInput(target) {
|
|
9531
|
+
if (!target) {
|
|
9532
|
+
return false;
|
|
9533
|
+
}
|
|
9534
|
+
const tagName = target.tagName;
|
|
9535
|
+
return tagName === "INPUT" || tagName === "BUTTON";
|
|
9536
|
+
}
|
|
9537
|
+
|
|
9528
9538
|
// src/components/InfiniteTable/hooks/useColumnPointerEvents.ts
|
|
9529
9539
|
var baseZIndexForCells2 = stripVar(InternalVars.baseZIndexForCells);
|
|
9530
9540
|
var equalPinning = (pinning1, pinning2) => {
|
|
@@ -9567,8 +9577,7 @@ var useColumnPointerEvents = ({
|
|
|
9567
9577
|
}, []);
|
|
9568
9578
|
const onPointerDown = (0, import_react21.useCallback)(
|
|
9569
9579
|
(e) => {
|
|
9570
|
-
|
|
9571
|
-
if (tagName === "INPUT" || tagName === "BUTTON") {
|
|
9580
|
+
if (isTargetInput(e.target)) {
|
|
9572
9581
|
return;
|
|
9573
9582
|
}
|
|
9574
9583
|
const { brain, draggableColumnsRestrictTo } = getState();
|
|
@@ -17074,52 +17083,103 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17074
17083
|
this.defaultSelection = false;
|
|
17075
17084
|
this.selectionMap = new DeepMap();
|
|
17076
17085
|
this.cache = new DeepMap();
|
|
17077
|
-
|
|
17086
|
+
this.correctnessChecks = false;
|
|
17087
|
+
const isTreeSelectionStateInstance = state instanceof Object.getPrototypeOf(this).constructor;
|
|
17088
|
+
const stateObject = isTreeSelectionStateInstance ? (
|
|
17078
17089
|
//@ts-ignore
|
|
17079
17090
|
state.getState()
|
|
17080
17091
|
) : state;
|
|
17081
|
-
this.
|
|
17092
|
+
this.setConfig(
|
|
17093
|
+
getConfig || (isTreeSelectionStateInstance ? state.config : {
|
|
17094
|
+
treePaths: new DeepMap()
|
|
17095
|
+
})
|
|
17096
|
+
);
|
|
17097
|
+
this.disableCorrectnessChecks();
|
|
17082
17098
|
this.update(stateObject);
|
|
17099
|
+
this.enableCorrectnessChecks();
|
|
17100
|
+
}
|
|
17101
|
+
getTreePaths(treePaths) {
|
|
17102
|
+
if (treePaths) {
|
|
17103
|
+
if (Array.isArray(treePaths)) {
|
|
17104
|
+
return new DeepMap(treePaths.map((path) => [path, true]));
|
|
17105
|
+
}
|
|
17106
|
+
return treePaths;
|
|
17107
|
+
}
|
|
17108
|
+
return this.config.treePaths;
|
|
17109
|
+
}
|
|
17110
|
+
withTreePaths(fn, treePaths) {
|
|
17111
|
+
const initialTreePaths = this.config.treePaths;
|
|
17112
|
+
treePaths = this.getTreePaths(treePaths);
|
|
17113
|
+
const treePathsDifferent = treePaths !== initialTreePaths;
|
|
17114
|
+
if (treePathsDifferent) {
|
|
17115
|
+
this.xcache();
|
|
17116
|
+
}
|
|
17117
|
+
this.config.treePaths = treePaths;
|
|
17118
|
+
const result = fn(treePaths);
|
|
17119
|
+
this.config.treePaths = initialTreePaths;
|
|
17120
|
+
if (treePathsDifferent) {
|
|
17121
|
+
this.xcache();
|
|
17122
|
+
}
|
|
17123
|
+
return result;
|
|
17083
17124
|
}
|
|
17084
|
-
|
|
17085
|
-
return this.
|
|
17125
|
+
getLeafNodePaths(rootNodePath = [], treePaths) {
|
|
17126
|
+
return this.withTreePaths((paths) => {
|
|
17127
|
+
return paths.getKeysForLeafNodesStartingWith(rootNodePath);
|
|
17128
|
+
}, treePaths);
|
|
17129
|
+
}
|
|
17130
|
+
forEachLeafNodePath(fn, rootNodePath = [], treePaths) {
|
|
17131
|
+
const selectedObj = { selected: false };
|
|
17132
|
+
this.withTreePaths((paths) => {
|
|
17133
|
+
paths.getLeafNodesStartingWith(rootNodePath, (pair) => {
|
|
17134
|
+
selectedObj.selected = this.isNodeSelected(pair.keys) === true;
|
|
17135
|
+
fn(pair.keys, selectedObj);
|
|
17136
|
+
});
|
|
17137
|
+
}, treePaths);
|
|
17086
17138
|
}
|
|
17087
17139
|
getSelectedLeafNodePaths(rootNodePath = [], treePaths) {
|
|
17088
|
-
treePaths = treePaths || this.getConfig().treePaths;
|
|
17089
17140
|
const selectedLeafPaths = [];
|
|
17090
|
-
|
|
17091
|
-
|
|
17092
|
-
|
|
17093
|
-
|
|
17094
|
-
|
|
17141
|
+
this.withTreePaths((paths) => {
|
|
17142
|
+
paths.getLeafNodesStartingWith(rootNodePath, (pair) => {
|
|
17143
|
+
if (this.isNodeSelected(pair.keys)) {
|
|
17144
|
+
selectedLeafPaths.push(pair.keys);
|
|
17145
|
+
}
|
|
17146
|
+
});
|
|
17147
|
+
}, treePaths);
|
|
17095
17148
|
return selectedLeafPaths;
|
|
17096
17149
|
}
|
|
17097
17150
|
getDeselectedLeafNodePaths(rootNodePath = [], treePaths) {
|
|
17098
|
-
treePaths = treePaths || this.getConfig().treePaths;
|
|
17099
17151
|
const deselectedLeafPaths = [];
|
|
17100
|
-
|
|
17101
|
-
|
|
17102
|
-
|
|
17103
|
-
|
|
17104
|
-
|
|
17152
|
+
this.withTreePaths((paths) => {
|
|
17153
|
+
paths.getLeafNodesStartingWith(rootNodePath, (pair) => {
|
|
17154
|
+
if (!this.isNodeSelected(pair.keys)) {
|
|
17155
|
+
deselectedLeafPaths.push(pair.keys);
|
|
17156
|
+
}
|
|
17157
|
+
});
|
|
17158
|
+
}, treePaths);
|
|
17105
17159
|
return deselectedLeafPaths;
|
|
17106
17160
|
}
|
|
17107
17161
|
isLeafNode(nodePath) {
|
|
17108
|
-
|
|
17162
|
+
const { treePaths } = this.config;
|
|
17163
|
+
if (!treePaths.has(nodePath)) {
|
|
17164
|
+
return null;
|
|
17165
|
+
}
|
|
17166
|
+
const keys = treePaths.getKeysForLeafNodesStartingWith(nodePath);
|
|
17167
|
+
if (keys.length === 1) {
|
|
17168
|
+
return true;
|
|
17169
|
+
}
|
|
17170
|
+
return false;
|
|
17109
17171
|
}
|
|
17110
17172
|
getLeafNodesCount(nodePath) {
|
|
17111
|
-
|
|
17112
|
-
const deepMapValue = treeDeepMap.get(nodePath);
|
|
17113
|
-
if (!deepMapValue) {
|
|
17114
|
-
return 1;
|
|
17115
|
-
}
|
|
17116
|
-
return deepMapValue.items.length;
|
|
17173
|
+
return this.config.treePaths.getKeysForLeafNodesStartingWith(nodePath).length;
|
|
17117
17174
|
}
|
|
17118
17175
|
static from(treeSelectionState, getConfig) {
|
|
17119
17176
|
return new _TreeSelectionState(treeSelectionState, getConfig);
|
|
17120
17177
|
}
|
|
17121
|
-
|
|
17122
|
-
|
|
17178
|
+
setConfig(getConfig) {
|
|
17179
|
+
const config = typeof getConfig === "function" ? getConfig() : getConfig;
|
|
17180
|
+
this.config = {
|
|
17181
|
+
treePaths: Array.isArray(config.treePaths) ? new DeepMap(config.treePaths.map((path) => [path, true])) : config.treePaths
|
|
17182
|
+
};
|
|
17123
17183
|
this.xcache();
|
|
17124
17184
|
}
|
|
17125
17185
|
xcache() {
|
|
@@ -17140,6 +17200,9 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17140
17200
|
this.xcache();
|
|
17141
17201
|
}
|
|
17142
17202
|
setSelectionForPath(nodePath, selected) {
|
|
17203
|
+
if (!this.isPathAvailable(nodePath)) {
|
|
17204
|
+
return;
|
|
17205
|
+
}
|
|
17143
17206
|
this.selectionMap.set(nodePath, selected);
|
|
17144
17207
|
}
|
|
17145
17208
|
getState() {
|
|
@@ -17172,6 +17235,19 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17172
17235
|
selectedPaths: []
|
|
17173
17236
|
});
|
|
17174
17237
|
}
|
|
17238
|
+
enableCorrectnessChecks() {
|
|
17239
|
+
this.correctnessChecks = true;
|
|
17240
|
+
}
|
|
17241
|
+
disableCorrectnessChecks() {
|
|
17242
|
+
this.correctnessChecks = false;
|
|
17243
|
+
}
|
|
17244
|
+
isPathAvailable(nodePath) {
|
|
17245
|
+
if (!this.correctnessChecks) {
|
|
17246
|
+
return true;
|
|
17247
|
+
}
|
|
17248
|
+
const { treePaths } = this.config;
|
|
17249
|
+
return treePaths.has(nodePath);
|
|
17250
|
+
}
|
|
17175
17251
|
isNodeSelected(nodePath) {
|
|
17176
17252
|
return this.isPathSelected(nodePath);
|
|
17177
17253
|
}
|
|
@@ -17187,7 +17263,7 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17187
17263
|
if (cachedResult) {
|
|
17188
17264
|
return cachedResult;
|
|
17189
17265
|
}
|
|
17190
|
-
if (this.isLeafNode(nodePath)) {
|
|
17266
|
+
if (this.isLeafNode(nodePath) !== false) {
|
|
17191
17267
|
const selected = this.isSelfSelected(nodePath);
|
|
17192
17268
|
if (selected !== null) {
|
|
17193
17269
|
return this.cacheIt(nodePath, {
|
|
@@ -17201,9 +17277,12 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17201
17277
|
const leafCount = this.getLeafNodesCount(nodePath);
|
|
17202
17278
|
let currentSelectionState = this.isSelfSelected(nodePath);
|
|
17203
17279
|
const { selectionMap } = this;
|
|
17204
|
-
|
|
17280
|
+
let childPaths = selectionMap.getKeysOfFirstChildOnEachBranchStartingWith(nodePath, {
|
|
17205
17281
|
excludeSelf: true
|
|
17206
17282
|
}).sort(shortestToLongest);
|
|
17283
|
+
if (this.correctnessChecks) {
|
|
17284
|
+
childPaths = childPaths.filter((path) => this.isPathAvailable(path));
|
|
17285
|
+
}
|
|
17207
17286
|
if (!childPaths.length) {
|
|
17208
17287
|
if (currentSelectionState !== null) {
|
|
17209
17288
|
const res2 = leafCount ? currentSelectionState : (
|
|
@@ -17277,6 +17356,9 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17277
17356
|
});
|
|
17278
17357
|
}
|
|
17279
17358
|
isPathSelected(nodePath) {
|
|
17359
|
+
if (!this.isPathAvailable(nodePath)) {
|
|
17360
|
+
return false;
|
|
17361
|
+
}
|
|
17280
17362
|
return this.getSelectionStateForNode(nodePath, true).selected;
|
|
17281
17363
|
}
|
|
17282
17364
|
getNodeBooleanSelectionStateFromParent(initialNodePath) {
|
|
@@ -17298,6 +17380,7 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17298
17380
|
if (!nodePath.length) {
|
|
17299
17381
|
return;
|
|
17300
17382
|
}
|
|
17383
|
+
this.xcache();
|
|
17301
17384
|
const keys = this.selectionMap.getKeysStartingWith(nodePath);
|
|
17302
17385
|
keys.forEach((nodePath2) => {
|
|
17303
17386
|
this.selectionMap.delete(nodePath2);
|
|
@@ -17337,7 +17420,7 @@ var TreeSelectionState = class _TreeSelectionState {
|
|
|
17337
17420
|
};
|
|
17338
17421
|
}
|
|
17339
17422
|
destroy() {
|
|
17340
|
-
this.
|
|
17423
|
+
this.config = void 0;
|
|
17341
17424
|
this.xcache();
|
|
17342
17425
|
this.selectionMap.clear();
|
|
17343
17426
|
}
|
|
@@ -17354,8 +17437,7 @@ function treeSelectionStateConfigGetter(stateOrStateGetter) {
|
|
|
17354
17437
|
return () => {
|
|
17355
17438
|
const state = typeof stateOrStateGetter === "function" ? stateOrStateGetter() : stateOrStateGetter;
|
|
17356
17439
|
return {
|
|
17357
|
-
treePaths: state.treePaths
|
|
17358
|
-
treeDeepMap: state.treeDeepMap
|
|
17440
|
+
treePaths: state.treePaths
|
|
17359
17441
|
};
|
|
17360
17442
|
};
|
|
17361
17443
|
}
|
|
@@ -17381,7 +17463,10 @@ var TreeApiImpl = class {
|
|
|
17381
17463
|
treeSelectionStateConfigGetter(this.getState)
|
|
17382
17464
|
);
|
|
17383
17465
|
treeSelectionState.setNodeSelection(nodePath, selected);
|
|
17384
|
-
this.getState().lastSelectionUpdatedNodePathRef.current =
|
|
17466
|
+
this.getState().lastSelectionUpdatedNodePathRef.current = {
|
|
17467
|
+
nodePath,
|
|
17468
|
+
selected
|
|
17469
|
+
};
|
|
17385
17470
|
this.actions.treeSelection = treeSelectionState;
|
|
17386
17471
|
};
|
|
17387
17472
|
this.getCallbackParam = (_nodePath) => {
|
|
@@ -17539,8 +17624,7 @@ var TreeApiImpl = class {
|
|
|
17539
17624
|
}
|
|
17540
17625
|
}
|
|
17541
17626
|
getNodeDataByPath(nodePath) {
|
|
17542
|
-
|
|
17543
|
-
if (!treeDeepMap || !nodePath.length) {
|
|
17627
|
+
if (!nodePath.length) {
|
|
17544
17628
|
return null;
|
|
17545
17629
|
}
|
|
17546
17630
|
const rowInfo = this.getRowInfoByPath(nodePath);
|
|
@@ -19023,6 +19107,14 @@ function concludeReducer(params) {
|
|
|
19023
19107
|
const shouldTreeAgain = shouldTree && (treeDepsChanged || cacheAffectedParts.tree || !state.lastTreeDataArray) || treeSelectionDepsChanged || rowDisabledStateDepsChanged || rowInfoReducersChanged;
|
|
19024
19108
|
const now = Date.now();
|
|
19025
19109
|
let dataArray = state.originalDataArray;
|
|
19110
|
+
if (shouldTree && shouldTreeAgain) {
|
|
19111
|
+
const treeParams = {
|
|
19112
|
+
isLeafNode,
|
|
19113
|
+
getNodeChildren,
|
|
19114
|
+
toKey: toPrimaryKey
|
|
19115
|
+
};
|
|
19116
|
+
state.unfilteredTreePaths = tree(treeParams, dataArray).treePaths;
|
|
19117
|
+
}
|
|
19026
19118
|
if (!shouldFilter) {
|
|
19027
19119
|
state.unfilteredCount = dataArray.length;
|
|
19028
19120
|
}
|
|
@@ -20321,6 +20413,7 @@ var cleanupDataSource = (state) => {
|
|
|
20321
20413
|
};
|
|
20322
20414
|
state.treeExpandState?.destroy();
|
|
20323
20415
|
state.treePaths?.clear();
|
|
20416
|
+
state.unfilteredTreePaths?.clear();
|
|
20324
20417
|
state.waitForNodePathPromises.clear();
|
|
20325
20418
|
state.pathToIndexMap?.clear();
|
|
20326
20419
|
state.rowDisabledState?.destroy();
|
|
@@ -20480,7 +20573,7 @@ function getTreeSelectionState(currentTreeSelection, selectionMode, state) {
|
|
|
20480
20573
|
}
|
|
20481
20574
|
const config = treeSelectionStateConfigGetter(state);
|
|
20482
20575
|
if (currentTreeSelection instanceof TreeSelectionState) {
|
|
20483
|
-
currentTreeSelection.
|
|
20576
|
+
currentTreeSelection.setConfig(config);
|
|
20484
20577
|
return currentTreeSelection;
|
|
20485
20578
|
}
|
|
20486
20579
|
if (currentTreeSelection === null || currentTreeSelection === void 0 || typeof currentTreeSelection != "object") {
|
|
@@ -20489,7 +20582,7 @@ function getTreeSelectionState(currentTreeSelection, selectionMode, state) {
|
|
|
20489
20582
|
const treeSelectionStateObject = currentTreeSelection ?? treeSelectionStateDefaultObject;
|
|
20490
20583
|
let instance = weakMap.get(treeSelectionStateObject);
|
|
20491
20584
|
if (instance) {
|
|
20492
|
-
instance.
|
|
20585
|
+
instance.setConfig(config);
|
|
20493
20586
|
}
|
|
20494
20587
|
instance = instance ?? new TreeSelectionState(treeSelectionStateObject, config);
|
|
20495
20588
|
weakMap.set(treeSelectionStateObject, instance);
|
|
@@ -20751,8 +20844,10 @@ function getMappedCallbacks() {
|
|
|
20751
20844
|
treeSelection2.getState(),
|
|
20752
20845
|
{
|
|
20753
20846
|
treeSelectionState: treeSelection2,
|
|
20847
|
+
prevTreeSelectionState: state.treeSelectionState,
|
|
20754
20848
|
selectionMode: "multi-row",
|
|
20755
|
-
|
|
20849
|
+
lastUpdatedNodeInfo: state.lastSelectionUpdatedNodePathRef.current,
|
|
20850
|
+
unfilteredTreePaths: state.unfilteredTreePaths,
|
|
20756
20851
|
dataSourceApi,
|
|
20757
20852
|
treeApi
|
|
20758
20853
|
}
|
|
@@ -25730,7 +25825,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
25730
25825
|
}
|
|
25731
25826
|
let valid2 = isValidLicense(licenseKey, {
|
|
25732
25827
|
publishedAt: 1624970570587,
|
|
25733
|
-
version: "7.
|
|
25828
|
+
version: "7.3.0"
|
|
25734
25829
|
});
|
|
25735
25830
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
25736
25831
|
return true;
|
|
@@ -25832,6 +25927,9 @@ function onCellClick(context, event) {
|
|
|
25832
25927
|
context.getState().onCellClick?.(context, event);
|
|
25833
25928
|
}
|
|
25834
25929
|
function onCellDoubleClick(context, event) {
|
|
25930
|
+
if (isTargetInput(event.target)) {
|
|
25931
|
+
return;
|
|
25932
|
+
}
|
|
25835
25933
|
const { onCellDoubleClick: onCellDoubleClick2 } = context.getState();
|
|
25836
25934
|
let dblClickResult = {
|
|
25837
25935
|
preventEdit: false
|
|
@@ -30186,6 +30284,36 @@ var React78 = __toESM(require("react"));
|
|
|
30186
30284
|
function TreeGrid(props) {
|
|
30187
30285
|
return /* @__PURE__ */ React78.createElement(InfiniteTable, { ...props });
|
|
30188
30286
|
}
|
|
30287
|
+
var withSelectedLeafNodesOnly = (callback) => {
|
|
30288
|
+
const onTreeSelectionChange = (_, {
|
|
30289
|
+
unfilteredTreePaths,
|
|
30290
|
+
treeSelectionState,
|
|
30291
|
+
prevTreeSelectionState,
|
|
30292
|
+
lastUpdatedNodeInfo
|
|
30293
|
+
}) => {
|
|
30294
|
+
const newTreeSelection = new TreeSelectionState(prevTreeSelectionState, {
|
|
30295
|
+
treePaths: unfilteredTreePaths
|
|
30296
|
+
});
|
|
30297
|
+
treeSelectionState.forEachLeafNodePath((nodePath, { selected }) => {
|
|
30298
|
+
newTreeSelection.setNodeSelection(nodePath, selected);
|
|
30299
|
+
});
|
|
30300
|
+
if (lastUpdatedNodeInfo) {
|
|
30301
|
+
treeSelectionState.forEachLeafNodePath((nodePath) => {
|
|
30302
|
+
newTreeSelection.setNodeSelection(
|
|
30303
|
+
nodePath,
|
|
30304
|
+
lastUpdatedNodeInfo.selected
|
|
30305
|
+
);
|
|
30306
|
+
}, lastUpdatedNodeInfo.nodePath);
|
|
30307
|
+
}
|
|
30308
|
+
const selectedPaths = newTreeSelection.getSelectedLeafNodePaths();
|
|
30309
|
+
const treeSelectionObject = {
|
|
30310
|
+
defaultSelection: false,
|
|
30311
|
+
selectedPaths
|
|
30312
|
+
};
|
|
30313
|
+
callback(treeSelectionObject);
|
|
30314
|
+
};
|
|
30315
|
+
return onTreeSelectionChange;
|
|
30316
|
+
};
|
|
30189
30317
|
|
|
30190
30318
|
// src/components/DataSource/DataLoader/DataQuery.ts
|
|
30191
30319
|
var DataQuery = class {
|
|
@@ -30945,6 +31073,7 @@ var components = {
|
|
|
30945
31073
|
useOverlayPortal,
|
|
30946
31074
|
usePrevious,
|
|
30947
31075
|
useRowInfoReducers,
|
|
30948
|
-
useVisibleColumnSizes
|
|
31076
|
+
useVisibleColumnSizes,
|
|
31077
|
+
withSelectedLeafNodesOnly
|
|
30949
31078
|
});
|
|
30950
31079
|
//!collapsed || lazyLoad;
|