@itwin/presentation-hierarchies-react 2.0.0-alpha.52 → 2.0.0-alpha.54
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/CHANGELOG.md +33 -0
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +62 -55
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +33 -29
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts +27 -16
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +181 -54
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +12 -6
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js +54 -49
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +7 -30
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +116 -74
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +67 -54
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +283 -226
- package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/Utils.js +44 -27
- package/lib/esm/presentation-hierarchies-react/Utils.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js +6 -7
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +271 -298
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +91 -82
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +3 -47
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +114 -151
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +32 -37
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +128 -101
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js +29 -44
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +24 -13
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +344 -67
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts +16 -15
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +78 -60
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +122 -117
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js +59 -38
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +16 -5
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +161 -35
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts +21 -17
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js +84 -31
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +22 -14
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +61 -26
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +15 -6
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +75 -25
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +16 -40
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +140 -61
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +14 -42
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +489 -121
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +58 -55
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +412 -181
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react.d.ts +17 -17
- package/lib/esm/presentation-hierarchies-react.js +15 -18
- package/package.json +17 -14
- package/lib/esm/presentation-hierarchies-react/Renderers.js +0 -6
- package/lib/esm/presentation-hierarchies-react/Renderers.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.js +0 -6
- package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts +0 -8
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -2
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -62
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react.js.map +0 -1
|
@@ -1,193 +1,424 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, } from "react";
|
|
7
|
-
import { Tree } from "@stratakit/structures";
|
|
8
|
-
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
9
|
-
import { useSelectionHandler } from "../UseSelectionHandler.js";
|
|
10
1
|
import { useEvent, useMergedRefs } from "../Utils.js";
|
|
11
|
-
import { isPlaceholderItem, useErrorNodes, useFlatTreeItems } from "./FlatTreeNode.js";
|
|
12
2
|
import { LocalizationContextProvider } from "./LocalizationContext.js";
|
|
13
|
-
import { TreeErrorRenderer } from "./TreeErrorRenderer.js";
|
|
14
3
|
import { TreeNodeRenameContextProvider, useTreeNodeRenameContextValue } from "./TreeNodeRenameAction.js";
|
|
4
|
+
import { useSelectionHandler } from "../UseSelectionHandler.js";
|
|
5
|
+
import { isPlaceholderItem, useErrorNodes, useFlatTreeItems } from "./FlatTreeNode.js";
|
|
6
|
+
import { TreeErrorRenderer } from "./TreeErrorRenderer.js";
|
|
15
7
|
import { PlaceholderNode, StrataKitTreeNodeRenderer } from "./TreeNodeRenderer.js";
|
|
8
|
+
import { c } from "react-compiler-runtime";
|
|
9
|
+
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { Tree } from "@stratakit/structures";
|
|
12
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
13
|
+
|
|
14
|
+
//#region src/presentation-hierarchies-react/stratakit/TreeRenderer.tsx
|
|
16
15
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
16
|
+
* A component that renders a tree using the `Tree` component from `@itwin/itwinui-react`. The tree nodes
|
|
17
|
+
* are rendered using `TreeNodeRenderer` component from this package.
|
|
18
|
+
*
|
|
19
|
+
* @see https://itwinui.bentley.com/docs/tree
|
|
20
|
+
* @alpha
|
|
21
|
+
*/
|
|
22
|
+
const StrataKitTreeRenderer = forwardRef(function StrataKitTreeRenderer(props, forwardedRef) {
|
|
23
|
+
const { id, rootNodes, selectNodes, selectionMode, expandNode, treeLabel, localizedStrings, getHierarchyLevelDetails, filterHierarchyLevel, reloadTree, isNodeSelected, errorRenderer, treeRootProps, getContextMenuActions, getEditingProps, getInlineActions, getMenuActions, getTreeItemProps } = props;
|
|
24
|
+
const { handleNodeSelect } = useSelectionHandler({
|
|
25
|
+
rootNodes,
|
|
26
|
+
selectNodes,
|
|
27
|
+
selectionMode: selectionMode ?? "single"
|
|
28
|
+
});
|
|
29
|
+
const flatItems = useFlatTreeItems(rootNodes);
|
|
30
|
+
const errorNodes = useErrorNodes(rootNodes);
|
|
31
|
+
const parentRef = useRef(null);
|
|
32
|
+
const virtualizer = useVirtualizer({
|
|
33
|
+
count: flatItems.length,
|
|
34
|
+
getScrollElement: () => parentRef.current,
|
|
35
|
+
getItemKey: useCallback((index) => flatItems[index].id, [flatItems]),
|
|
36
|
+
estimateSize: () => 28,
|
|
37
|
+
overscan: 10
|
|
38
|
+
});
|
|
39
|
+
const items = virtualizer.getVirtualItems();
|
|
40
|
+
const expandAndScrollToNode = useExpandAndScrollToNode({
|
|
41
|
+
rootNodes,
|
|
42
|
+
flatItems,
|
|
43
|
+
expandNode,
|
|
44
|
+
virtualizer
|
|
45
|
+
});
|
|
46
|
+
const renameContext = useTreeNodeRenameContextValue({ getEditingProps });
|
|
47
|
+
useImperativeHandle(forwardedRef, () => ({ renameNode: (nodePredicate) => expandAndScrollToNode({
|
|
48
|
+
nodePredicate,
|
|
49
|
+
onComplete: (targetNode) => {
|
|
50
|
+
requestAnimationFrame(() => renameContext.startRename(targetNode));
|
|
51
|
+
}
|
|
52
|
+
}) }));
|
|
53
|
+
const cancelRename = renameContext.cancelRename;
|
|
54
|
+
const isScrolling = virtualizer.isScrolling;
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (isScrolling) cancelRename();
|
|
57
|
+
}, [isScrolling, cancelRename]);
|
|
58
|
+
const errorRendererProps = {
|
|
59
|
+
treeLabel,
|
|
60
|
+
errorNodes,
|
|
61
|
+
scrollToNode: (node) => expandAndScrollToNode({ nodePredicate: (n) => n.id === node.id }),
|
|
62
|
+
getHierarchyLevelDetails,
|
|
63
|
+
filterHierarchyLevel,
|
|
64
|
+
reloadTree: useCallback(({ parentNodeId }) => reloadTree({
|
|
65
|
+
parentNodeId,
|
|
66
|
+
state: "reset"
|
|
67
|
+
}), [reloadTree])
|
|
68
|
+
};
|
|
69
|
+
const getSelectedNodes = useMemo(() => {
|
|
70
|
+
let calculatedSelectedNodes;
|
|
71
|
+
return () => {
|
|
72
|
+
if (calculatedSelectedNodes === void 0) calculatedSelectedNodes = flatItems.filter((item) => !isPlaceholderItem(item) && isNodeSelected(item.id)).map((item_0) => item_0.node);
|
|
73
|
+
return calculatedSelectedNodes;
|
|
74
|
+
};
|
|
75
|
+
}, [flatItems, isNodeSelected]);
|
|
76
|
+
return /* @__PURE__ */ jsxs(LocalizationContextProvider, {
|
|
77
|
+
localizedStrings,
|
|
78
|
+
children: [errorRenderer ? errorRenderer(errorRendererProps) : /* @__PURE__ */ jsx(TreeErrorRenderer, { ...errorRendererProps }), /* @__PURE__ */ jsx("div", {
|
|
79
|
+
id,
|
|
80
|
+
style: {
|
|
81
|
+
height: "100%",
|
|
82
|
+
width: "100%",
|
|
83
|
+
overflowY: "auto"
|
|
84
|
+
},
|
|
85
|
+
ref: parentRef,
|
|
86
|
+
children: /* @__PURE__ */ jsx(Tree.Root, {
|
|
87
|
+
...treeRootProps,
|
|
88
|
+
style: {
|
|
89
|
+
height: virtualizer.getTotalSize(),
|
|
90
|
+
minHeight: "100%",
|
|
91
|
+
width: "100%",
|
|
92
|
+
position: "relative",
|
|
93
|
+
overflow: "hidden"
|
|
94
|
+
},
|
|
95
|
+
children: /* @__PURE__ */ jsx(TreeNodeRenameContextProvider, {
|
|
96
|
+
value: renameContext,
|
|
97
|
+
children: items.map((virtualizedItem) => {
|
|
98
|
+
const item_1 = flatItems[virtualizedItem.index];
|
|
99
|
+
const selected = isNodeSelected(item_1.id);
|
|
100
|
+
return /* @__PURE__ */ jsx(VirtualTreeItem, {
|
|
101
|
+
ref: virtualizer.measureElement,
|
|
102
|
+
"data-index": virtualizedItem.index,
|
|
103
|
+
start: virtualizedItem.start,
|
|
104
|
+
item: item_1,
|
|
105
|
+
selected,
|
|
106
|
+
expandNode,
|
|
107
|
+
reloadTree,
|
|
108
|
+
handleNodeSelect,
|
|
109
|
+
getSelectedNodes,
|
|
110
|
+
getContextMenuActions,
|
|
111
|
+
getInlineActions,
|
|
112
|
+
getMenuActions,
|
|
113
|
+
getTreeItemProps
|
|
114
|
+
}, virtualizedItem.key);
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
})]
|
|
119
|
+
});
|
|
86
120
|
});
|
|
87
|
-
function useExpandAndScrollToNode(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
function useExpandAndScrollToNode(t0) {
|
|
122
|
+
const $ = c(11);
|
|
123
|
+
const { rootNodes, flatItems, expandNode, virtualizer } = t0;
|
|
124
|
+
let t1;
|
|
125
|
+
if ($[0] !== expandNode || $[1] !== rootNodes) {
|
|
126
|
+
t1 = (nodePredicate) => {
|
|
127
|
+
const pathToNode = findPathToNode(rootNodes, nodePredicate);
|
|
128
|
+
if (!pathToNode) return;
|
|
129
|
+
const targetNode = pathToNode.pop();
|
|
130
|
+
const collapsedNodes = pathToNode.filter(_temp);
|
|
131
|
+
collapsedNodes.forEach((node) => expandNode(node.id, true));
|
|
132
|
+
return {
|
|
133
|
+
targetNode,
|
|
134
|
+
didExpand: collapsedNodes.length > 0
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
$[0] = expandNode;
|
|
138
|
+
$[1] = rootNodes;
|
|
139
|
+
$[2] = t1;
|
|
140
|
+
} else t1 = $[2];
|
|
141
|
+
const expandToNode = t1;
|
|
142
|
+
const scrollToNode = useRef(void 0);
|
|
143
|
+
let t2;
|
|
144
|
+
let t3;
|
|
145
|
+
if ($[3] !== flatItems || $[4] !== virtualizer) {
|
|
146
|
+
t2 = () => {
|
|
147
|
+
if (scrollToNode.current === void 0) return;
|
|
148
|
+
const targetNodeId = scrollToNode.current.id;
|
|
149
|
+
const index = flatItems.findIndex((flatItem) => flatItem.id === targetNodeId);
|
|
150
|
+
if (index === -1) return;
|
|
151
|
+
virtualizer.scrollToIndex(index, { align: "auto" });
|
|
152
|
+
scrollToNode.current.onScrollComplete?.();
|
|
153
|
+
scrollToNode.current = void 0;
|
|
154
|
+
};
|
|
155
|
+
t3 = [flatItems, virtualizer];
|
|
156
|
+
$[3] = flatItems;
|
|
157
|
+
$[4] = virtualizer;
|
|
158
|
+
$[5] = t2;
|
|
159
|
+
$[6] = t3;
|
|
160
|
+
} else {
|
|
161
|
+
t2 = $[5];
|
|
162
|
+
t3 = $[6];
|
|
163
|
+
}
|
|
164
|
+
useEffect(t2, t3);
|
|
165
|
+
let t4;
|
|
166
|
+
if ($[7] !== expandToNode || $[8] !== flatItems || $[9] !== virtualizer) {
|
|
167
|
+
t4 = (t5) => {
|
|
168
|
+
const { nodePredicate: nodePredicate_0, onComplete } = t5;
|
|
169
|
+
const expandResult = expandToNode(nodePredicate_0);
|
|
170
|
+
if (!expandResult) return "node-not-found";
|
|
171
|
+
const { targetNode: targetNode_0, didExpand } = expandResult;
|
|
172
|
+
if (didExpand) scrollToNode.current = {
|
|
173
|
+
id: targetNode_0.id,
|
|
174
|
+
onScrollComplete: onComplete ? () => onComplete(targetNode_0) : void 0
|
|
175
|
+
};
|
|
176
|
+
else {
|
|
177
|
+
const index_0 = flatItems.findIndex((flatItem_0) => flatItem_0.id === targetNode_0.id);
|
|
178
|
+
virtualizer.scrollToIndex(index_0, { align: "auto" });
|
|
179
|
+
onComplete?.(targetNode_0);
|
|
180
|
+
}
|
|
181
|
+
return "success";
|
|
182
|
+
};
|
|
183
|
+
$[7] = expandToNode;
|
|
184
|
+
$[8] = flatItems;
|
|
185
|
+
$[9] = virtualizer;
|
|
186
|
+
$[10] = t4;
|
|
187
|
+
} else t4 = $[10];
|
|
188
|
+
return t4;
|
|
189
|
+
}
|
|
190
|
+
function _temp(pathNode) {
|
|
191
|
+
return !pathNode.isExpanded;
|
|
131
192
|
}
|
|
132
193
|
function findPathToNode(rootNodes, nodePredicate) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return [parent, ...childPath];
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return undefined;
|
|
194
|
+
for (const parent of rootNodes) {
|
|
195
|
+
if (nodePredicate(parent)) return [parent];
|
|
196
|
+
if (parent.children !== true) {
|
|
197
|
+
const childPath = findPathToNode(parent.children, nodePredicate);
|
|
198
|
+
if (childPath) return [parent, ...childPath];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
145
201
|
}
|
|
146
|
-
const VirtualTreeItem = memo(forwardRef(function VirtualTreeItem(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
202
|
+
const VirtualTreeItem = memo(forwardRef(function VirtualTreeItem(t0, forwardedRef) {
|
|
203
|
+
const $ = c(16);
|
|
204
|
+
let item;
|
|
205
|
+
let props;
|
|
206
|
+
let start;
|
|
207
|
+
if ($[0] !== t0) {
|
|
208
|
+
({start, item, ...props} = t0);
|
|
209
|
+
$[0] = t0;
|
|
210
|
+
$[1] = item;
|
|
211
|
+
$[2] = props;
|
|
212
|
+
$[3] = start;
|
|
213
|
+
} else {
|
|
214
|
+
item = $[1];
|
|
215
|
+
props = $[2];
|
|
216
|
+
start = $[3];
|
|
217
|
+
}
|
|
218
|
+
const t1 = `translateY(${start}px)`;
|
|
219
|
+
let t2;
|
|
220
|
+
if ($[4] !== t1) {
|
|
221
|
+
t2 = {
|
|
222
|
+
position: "absolute",
|
|
223
|
+
top: 0,
|
|
224
|
+
left: 0,
|
|
225
|
+
width: "100%",
|
|
226
|
+
transform: t1,
|
|
227
|
+
willChange: "transform"
|
|
228
|
+
};
|
|
229
|
+
$[4] = t1;
|
|
230
|
+
$[5] = t2;
|
|
231
|
+
} else t2 = $[5];
|
|
232
|
+
const style = t2;
|
|
233
|
+
if (isPlaceholderItem(item)) {
|
|
234
|
+
const t3 = props["data-index"];
|
|
235
|
+
let t4;
|
|
236
|
+
if ($[6] !== forwardedRef || $[7] !== item.level || $[8] !== style || $[9] !== t3) {
|
|
237
|
+
t4 = /* @__PURE__ */ jsx(PlaceholderNode, {
|
|
238
|
+
ref: forwardedRef,
|
|
239
|
+
"data-index": t3,
|
|
240
|
+
style,
|
|
241
|
+
"aria-level": item.level,
|
|
242
|
+
"aria-posinset": 1,
|
|
243
|
+
"aria-setsize": 1
|
|
244
|
+
});
|
|
245
|
+
$[6] = forwardedRef;
|
|
246
|
+
$[7] = item.level;
|
|
247
|
+
$[8] = style;
|
|
248
|
+
$[9] = t3;
|
|
249
|
+
$[10] = t4;
|
|
250
|
+
} else t4 = $[10];
|
|
251
|
+
return t4;
|
|
252
|
+
}
|
|
253
|
+
let t3;
|
|
254
|
+
if ($[11] !== forwardedRef || $[12] !== item || $[13] !== props || $[14] !== style) {
|
|
255
|
+
t3 = /* @__PURE__ */ jsx(HierarchyNodeItem, {
|
|
256
|
+
...props,
|
|
257
|
+
ref: forwardedRef,
|
|
258
|
+
style,
|
|
259
|
+
item
|
|
260
|
+
});
|
|
261
|
+
$[11] = forwardedRef;
|
|
262
|
+
$[12] = item;
|
|
263
|
+
$[13] = props;
|
|
264
|
+
$[14] = style;
|
|
265
|
+
$[15] = t3;
|
|
266
|
+
} else t3 = $[15];
|
|
267
|
+
return t3;
|
|
159
268
|
}));
|
|
160
|
-
const HierarchyNodeItem = memo(forwardRef(function HierarchyNodeItem(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
269
|
+
const HierarchyNodeItem = memo(forwardRef(function HierarchyNodeItem(t0, forwardedRef) {
|
|
270
|
+
const $ = c(49);
|
|
271
|
+
let getContextMenuActions;
|
|
272
|
+
let getInlineActions;
|
|
273
|
+
let getMenuActions;
|
|
274
|
+
let getSelectedNodes;
|
|
275
|
+
let getTreeItemProps;
|
|
276
|
+
let handleNodeSelect;
|
|
277
|
+
let item;
|
|
278
|
+
let rest;
|
|
279
|
+
let selected;
|
|
280
|
+
if ($[0] !== t0) {
|
|
281
|
+
({item, selected, getTreeItemProps, handleNodeSelect, getSelectedNodes, getMenuActions, getInlineActions, getContextMenuActions, ...rest} = t0);
|
|
282
|
+
$[0] = t0;
|
|
283
|
+
$[1] = getContextMenuActions;
|
|
284
|
+
$[2] = getInlineActions;
|
|
285
|
+
$[3] = getMenuActions;
|
|
286
|
+
$[4] = getSelectedNodes;
|
|
287
|
+
$[5] = getTreeItemProps;
|
|
288
|
+
$[6] = handleNodeSelect;
|
|
289
|
+
$[7] = item;
|
|
290
|
+
$[8] = rest;
|
|
291
|
+
$[9] = selected;
|
|
292
|
+
} else {
|
|
293
|
+
getContextMenuActions = $[1];
|
|
294
|
+
getInlineActions = $[2];
|
|
295
|
+
getMenuActions = $[3];
|
|
296
|
+
getSelectedNodes = $[4];
|
|
297
|
+
getTreeItemProps = $[5];
|
|
298
|
+
handleNodeSelect = $[6];
|
|
299
|
+
item = $[7];
|
|
300
|
+
rest = $[8];
|
|
301
|
+
selected = $[9];
|
|
302
|
+
}
|
|
303
|
+
const nodeRef = useRef(null);
|
|
304
|
+
const node = item.node;
|
|
305
|
+
let t1;
|
|
306
|
+
if ($[10] !== getTreeItemProps || $[11] !== node) {
|
|
307
|
+
t1 = getTreeItemProps?.(node);
|
|
308
|
+
$[10] = getTreeItemProps;
|
|
309
|
+
$[11] = node;
|
|
310
|
+
$[12] = t1;
|
|
311
|
+
} else t1 = $[12];
|
|
312
|
+
const treeItemProps = t1;
|
|
313
|
+
const isDisabled = treeItemProps?.["aria-disabled"] === true;
|
|
314
|
+
let t2;
|
|
315
|
+
if ($[13] !== getMenuActions || $[14] !== getSelectedNodes || $[15] !== node) {
|
|
316
|
+
t2 = getMenuActions ? getMenuActions({
|
|
317
|
+
targetNode: node,
|
|
318
|
+
selectedNodes: getSelectedNodes()
|
|
319
|
+
}) : void 0;
|
|
320
|
+
$[13] = getMenuActions;
|
|
321
|
+
$[14] = getSelectedNodes;
|
|
322
|
+
$[15] = node;
|
|
323
|
+
$[16] = t2;
|
|
324
|
+
} else t2 = $[16];
|
|
325
|
+
let t3;
|
|
326
|
+
if ($[17] !== getInlineActions || $[18] !== getSelectedNodes || $[19] !== node) {
|
|
327
|
+
t3 = getInlineActions ? getInlineActions({
|
|
328
|
+
targetNode: node,
|
|
329
|
+
selectedNodes: getSelectedNodes()
|
|
330
|
+
}) : void 0;
|
|
331
|
+
$[17] = getInlineActions;
|
|
332
|
+
$[18] = getSelectedNodes;
|
|
333
|
+
$[19] = node;
|
|
334
|
+
$[20] = t3;
|
|
335
|
+
} else t3 = $[20];
|
|
336
|
+
let t4;
|
|
337
|
+
if ($[21] !== getContextMenuActions || $[22] !== getSelectedNodes || $[23] !== node) {
|
|
338
|
+
t4 = getContextMenuActions ? getContextMenuActions({
|
|
339
|
+
targetNode: node,
|
|
340
|
+
selectedNodes: getSelectedNodes()
|
|
341
|
+
}) : void 0;
|
|
342
|
+
$[21] = getContextMenuActions;
|
|
343
|
+
$[22] = getSelectedNodes;
|
|
344
|
+
$[23] = node;
|
|
345
|
+
$[24] = t4;
|
|
346
|
+
} else t4 = $[24];
|
|
347
|
+
let t5;
|
|
348
|
+
if ($[25] !== t2 || $[26] !== t3 || $[27] !== t4) {
|
|
349
|
+
t5 = {
|
|
350
|
+
menuActions: t2,
|
|
351
|
+
inlineActions: t3,
|
|
352
|
+
contextMenuActions: t4
|
|
353
|
+
};
|
|
354
|
+
$[25] = t2;
|
|
355
|
+
$[26] = t3;
|
|
356
|
+
$[27] = t4;
|
|
357
|
+
$[28] = t5;
|
|
358
|
+
} else t5 = $[28];
|
|
359
|
+
const nodeActions = t5;
|
|
360
|
+
let t6;
|
|
361
|
+
if ($[29] !== handleNodeSelect || $[30] !== isDisabled || $[31] !== node || $[32] !== selected || $[33] !== treeItemProps) {
|
|
362
|
+
t6 = (e) => {
|
|
363
|
+
if (treeItemProps?.onClick) treeItemProps.onClick(e);
|
|
364
|
+
if (isDisabled || e.detail > 1) return;
|
|
365
|
+
handleNodeSelect({
|
|
366
|
+
nodeId: node.id,
|
|
367
|
+
isSelected: selected ?? false,
|
|
368
|
+
shiftDown: e.shiftKey,
|
|
369
|
+
ctrlDown: e.ctrlKey
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
$[29] = handleNodeSelect;
|
|
373
|
+
$[30] = isDisabled;
|
|
374
|
+
$[31] = node;
|
|
375
|
+
$[32] = selected;
|
|
376
|
+
$[33] = treeItemProps;
|
|
377
|
+
$[34] = t6;
|
|
378
|
+
} else t6 = $[34];
|
|
379
|
+
const onClick = useEvent(t6);
|
|
380
|
+
let t7;
|
|
381
|
+
if ($[35] !== treeItemProps) {
|
|
382
|
+
t7 = (e_0) => {
|
|
383
|
+
if (treeItemProps?.onMouseDown) treeItemProps.onMouseDown(e_0);
|
|
384
|
+
if (e_0.shiftKey) e_0.preventDefault();
|
|
385
|
+
};
|
|
386
|
+
$[35] = treeItemProps;
|
|
387
|
+
$[36] = t7;
|
|
388
|
+
} else t7 = $[36];
|
|
389
|
+
const onMouseDown = useEvent(t7);
|
|
390
|
+
const ref = useMergedRefs(forwardedRef, nodeRef);
|
|
391
|
+
let t8;
|
|
392
|
+
if ($[37] !== item.level || $[38] !== item.levelSize || $[39] !== item.node || $[40] !== item.posInLevel || $[41] !== nodeActions || $[42] !== onClick || $[43] !== onMouseDown || $[44] !== ref || $[45] !== rest || $[46] !== selected || $[47] !== treeItemProps) {
|
|
393
|
+
t8 = /* @__PURE__ */ jsx(StrataKitTreeNodeRenderer, {
|
|
394
|
+
...treeItemProps,
|
|
395
|
+
...rest,
|
|
396
|
+
...nodeActions,
|
|
397
|
+
ref,
|
|
398
|
+
"aria-level": item.level,
|
|
399
|
+
"aria-posinset": item.posInLevel,
|
|
400
|
+
"aria-setsize": item.levelSize,
|
|
401
|
+
node: item.node,
|
|
402
|
+
selected,
|
|
403
|
+
onClick,
|
|
404
|
+
onMouseDown
|
|
405
|
+
});
|
|
406
|
+
$[37] = item.level;
|
|
407
|
+
$[38] = item.levelSize;
|
|
408
|
+
$[39] = item.node;
|
|
409
|
+
$[40] = item.posInLevel;
|
|
410
|
+
$[41] = nodeActions;
|
|
411
|
+
$[42] = onClick;
|
|
412
|
+
$[43] = onMouseDown;
|
|
413
|
+
$[44] = ref;
|
|
414
|
+
$[45] = rest;
|
|
415
|
+
$[46] = selected;
|
|
416
|
+
$[47] = treeItemProps;
|
|
417
|
+
$[48] = t8;
|
|
418
|
+
} else t8 = $[48];
|
|
419
|
+
return t8;
|
|
191
420
|
}));
|
|
192
|
-
|
|
421
|
+
|
|
422
|
+
//#endregion
|
|
423
|
+
export { StrataKitTreeRenderer };
|
|
193
424
|
//# sourceMappingURL=TreeRenderer.js.map
|