@itwin/presentation-hierarchies-react 2.0.0-alpha.6 → 2.0.0-alpha.60
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 +1137 -11
- package/README.md +93 -160
- package/lib/presentation-hierarchies-react/FlatTreeNode.d.ts +49 -0
- package/lib/presentation-hierarchies-react/FlatTreeNode.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/FlatTreeNode.js +93 -0
- package/lib/presentation-hierarchies-react/FlatTreeNode.js.map +1 -0
- package/lib/presentation-hierarchies-react/LocalizationContext.d.ts +24 -0
- package/lib/presentation-hierarchies-react/LocalizationContext.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/LocalizationContext.js +40 -0
- package/lib/presentation-hierarchies-react/LocalizationContext.js.map +1 -0
- package/lib/presentation-hierarchies-react/Renderers.d.ts +92 -0
- package/lib/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/TreeNode.d.ts +80 -0
- package/lib/presentation-hierarchies-react/TreeNode.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.d.ts +28 -15
- package/lib/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js +183 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts +30 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js +57 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts +23 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js +124 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseTree.d.ts +112 -0
- package/lib/presentation-hierarchies-react/UseTree.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseTree.js +297 -0
- package/lib/presentation-hierarchies-react/UseTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/Utils.js +56 -0
- package/lib/presentation-hierarchies-react/Utils.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js +10 -0
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts +9 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js +12 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeActions.js +294 -0
- package/lib/presentation-hierarchies-react/internal/TreeActions.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js +98 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.d.ts +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js +120 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +35 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js +141 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js +42 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +38 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +380 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +27 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +185 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts +49 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js +88 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +38 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +63 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +29 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +91 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +31 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +155 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.css +25 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +14 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +534 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +75 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +417 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react-extract.d.ts +17 -0
- package/lib/presentation-hierarchies-react-extract.js +16 -0
- package/lib/presentation-hierarchies-react-stratakit.d.ts +8 -0
- package/lib/presentation-hierarchies-react-stratakit.js +8 -0
- package/lib/presentation-hierarchies-react.d.ts +11 -0
- package/lib/presentation-hierarchies-react.js +8 -0
- package/lib/public/locales/en/PresentationHierarchies_1.0.json +26 -0
- package/package.json +78 -56
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +0 -75
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.js +0 -12
- package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts +0 -15
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js +0 -22
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +0 -62
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +0 -46
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +0 -98
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +0 -132
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +0 -242
- package/lib/esm/presentation-hierarchies-react/UseTree.js.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/DisposePolyfill.js +0 -11
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.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/TreeActions.js +0 -307
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -44
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +0 -94
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +0 -70
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +0 -153
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +0 -28
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +0 -128
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.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/internal/Utils.js +0 -58
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.d.ts +0 -21
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.js +0 -30
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts +0 -73
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js +0 -34
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts +0 -25
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js +0 -40
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts +0 -23
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js +0 -72
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +0 -40
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +0 -80
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +0 -30
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +0 -48
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react.d.ts +0 -13
- package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react.js +0 -16
- package/lib/esm/presentation-hierarchies-react.js.map +0 -1
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
import { useTranslation } from "../LocalizationContext.js";
|
|
2
|
+
import { TreeActionBase } from "./TreeAction.js";
|
|
3
|
+
import { useTreeNodeRenameContext } from "./TreeNodeRenameAction.js";
|
|
4
|
+
import { c } from "react-compiler-runtime";
|
|
5
|
+
import { cloneElement, forwardRef, isValidElement, memo, useEffect, useId, useRef, useState } from "react";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { DropdownMenu, Tree, unstable_Popover } from "@stratakit/structures";
|
|
8
|
+
import { Description, IconButton, Spinner, Text, TextBox } from "@stratakit/bricks";
|
|
9
|
+
import "./TreeNodeRenderer.css";
|
|
10
|
+
import checkmarkSvg from "@stratakit/icons/checkmark.svg";
|
|
11
|
+
import dismissSvg from "@stratakit/icons/dismiss.svg";
|
|
12
|
+
import refreshSvg from "@stratakit/icons/refresh.svg";
|
|
13
|
+
//#region src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.tsx
|
|
14
|
+
/**
|
|
15
|
+
* A component that renders a given `TreeNode` using the `Tree.Item` component from `@stratakit/structures`.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
const StrataKitTreeNodeRenderer = memo(forwardRef(function HierarchyNode(props, forwardedRef) {
|
|
20
|
+
const $ = c(64);
|
|
21
|
+
let contextMenuActions;
|
|
22
|
+
let decorations;
|
|
23
|
+
let expandNode;
|
|
24
|
+
let inlineActions;
|
|
25
|
+
let menuActions;
|
|
26
|
+
let node;
|
|
27
|
+
let reloadTree;
|
|
28
|
+
let treeItemProps;
|
|
29
|
+
if ($[0] !== props) {
|
|
30
|
+
({node, decorations, inlineActions, menuActions, contextMenuActions, expandNode, reloadTree, ...treeItemProps} = props);
|
|
31
|
+
$[0] = props;
|
|
32
|
+
$[1] = contextMenuActions;
|
|
33
|
+
$[2] = decorations;
|
|
34
|
+
$[3] = expandNode;
|
|
35
|
+
$[4] = inlineActions;
|
|
36
|
+
$[5] = menuActions;
|
|
37
|
+
$[6] = node;
|
|
38
|
+
$[7] = reloadTree;
|
|
39
|
+
$[8] = treeItemProps;
|
|
40
|
+
} else {
|
|
41
|
+
contextMenuActions = $[1];
|
|
42
|
+
decorations = $[2];
|
|
43
|
+
expandNode = $[3];
|
|
44
|
+
inlineActions = $[4];
|
|
45
|
+
menuActions = $[5];
|
|
46
|
+
node = $[6];
|
|
47
|
+
reloadTree = $[7];
|
|
48
|
+
treeItemProps = $[8];
|
|
49
|
+
}
|
|
50
|
+
const translate = useTranslation();
|
|
51
|
+
const renameContext = useTreeNodeRenameContext();
|
|
52
|
+
const [contextMenuProps, setContextMenuProps] = useState(void 0);
|
|
53
|
+
const label = treeItemProps.label ?? node.label;
|
|
54
|
+
let t0;
|
|
55
|
+
bb0: {
|
|
56
|
+
if (node.error !== void 0 && node.error.type === "ChildrenLoad") {
|
|
57
|
+
let t1;
|
|
58
|
+
if ($[9] !== translate) {
|
|
59
|
+
t1 = translate("retry");
|
|
60
|
+
$[9] = translate;
|
|
61
|
+
$[10] = t1;
|
|
62
|
+
} else t1 = $[10];
|
|
63
|
+
let t2;
|
|
64
|
+
if ($[11] !== node.id || $[12] !== reloadTree) {
|
|
65
|
+
t2 = () => reloadTree({
|
|
66
|
+
parentNodeId: node.id,
|
|
67
|
+
state: "reset"
|
|
68
|
+
});
|
|
69
|
+
$[11] = node.id;
|
|
70
|
+
$[12] = reloadTree;
|
|
71
|
+
$[13] = t2;
|
|
72
|
+
} else t2 = $[13];
|
|
73
|
+
let t3;
|
|
74
|
+
if ($[14] !== t1 || $[15] !== t2) {
|
|
75
|
+
t3 = [/* @__PURE__ */ jsx(TreeActionBase, {
|
|
76
|
+
label: t1,
|
|
77
|
+
onClick: t2,
|
|
78
|
+
visible: true,
|
|
79
|
+
icon: refreshSvg,
|
|
80
|
+
variant: "inline"
|
|
81
|
+
}, "retry")];
|
|
82
|
+
$[14] = t1;
|
|
83
|
+
$[15] = t2;
|
|
84
|
+
$[16] = t3;
|
|
85
|
+
} else t3 = $[16];
|
|
86
|
+
t0 = t3;
|
|
87
|
+
break bb0;
|
|
88
|
+
}
|
|
89
|
+
if (!inlineActions) {
|
|
90
|
+
t0 = void 0;
|
|
91
|
+
break bb0;
|
|
92
|
+
}
|
|
93
|
+
let t1;
|
|
94
|
+
if ($[17] !== inlineActions) {
|
|
95
|
+
t1 = injectActionVariant(inlineActions, "inline");
|
|
96
|
+
$[17] = inlineActions;
|
|
97
|
+
$[18] = t1;
|
|
98
|
+
} else t1 = $[18];
|
|
99
|
+
t0 = t1;
|
|
100
|
+
}
|
|
101
|
+
const inlineActionItems = t0;
|
|
102
|
+
let t1;
|
|
103
|
+
bb1: {
|
|
104
|
+
if (!menuActions) {
|
|
105
|
+
t1 = void 0;
|
|
106
|
+
break bb1;
|
|
107
|
+
}
|
|
108
|
+
let t2;
|
|
109
|
+
if ($[19] !== menuActions) {
|
|
110
|
+
t2 = injectActionVariant(menuActions, "default");
|
|
111
|
+
$[19] = menuActions;
|
|
112
|
+
$[20] = t2;
|
|
113
|
+
} else t2 = $[20];
|
|
114
|
+
t1 = t2;
|
|
115
|
+
}
|
|
116
|
+
const menuActionItems = t1;
|
|
117
|
+
let t2;
|
|
118
|
+
bb2: {
|
|
119
|
+
if (node.error && (node.error.type !== "Unknown" || !node.error.isNodeExpandable)) {
|
|
120
|
+
t2 = void 0;
|
|
121
|
+
break bb2;
|
|
122
|
+
}
|
|
123
|
+
if (node.children !== true && node.children.length === 0) {
|
|
124
|
+
t2 = void 0;
|
|
125
|
+
break bb2;
|
|
126
|
+
}
|
|
127
|
+
t2 = node.isExpanded;
|
|
128
|
+
}
|
|
129
|
+
const expanded = t2;
|
|
130
|
+
let t3;
|
|
131
|
+
if ($[21] !== renameContext) {
|
|
132
|
+
t3 = renameContext ?? {};
|
|
133
|
+
$[21] = renameContext;
|
|
134
|
+
$[22] = t3;
|
|
135
|
+
} else t3 = $[22];
|
|
136
|
+
const { renameParameters, cancelRename } = t3;
|
|
137
|
+
const t4 = renameParameters?.commit;
|
|
138
|
+
const t5 = renameParameters?.labelValidationHint;
|
|
139
|
+
const t6 = renameParameters?.validate;
|
|
140
|
+
let t7;
|
|
141
|
+
if ($[23] !== cancelRename || $[24] !== node.label || $[25] !== t4 || $[26] !== t5 || $[27] !== t6) {
|
|
142
|
+
t7 = /* @__PURE__ */ jsx(LabelEditor, {
|
|
143
|
+
initialLabel: node.label,
|
|
144
|
+
onChange: t4,
|
|
145
|
+
onCancel: cancelRename,
|
|
146
|
+
labelValidationHint: t5,
|
|
147
|
+
validate: t6
|
|
148
|
+
});
|
|
149
|
+
$[23] = cancelRename;
|
|
150
|
+
$[24] = node.label;
|
|
151
|
+
$[25] = t4;
|
|
152
|
+
$[26] = t5;
|
|
153
|
+
$[27] = t6;
|
|
154
|
+
$[28] = t7;
|
|
155
|
+
} else t7 = $[28];
|
|
156
|
+
const labelEditor = t7;
|
|
157
|
+
const t8 = renameParameters?.nodeId === node.id;
|
|
158
|
+
let t9;
|
|
159
|
+
if ($[29] !== expandNode || $[30] !== node.id) {
|
|
160
|
+
t9 = (isExpanded) => {
|
|
161
|
+
expandNode(node.id, isExpanded);
|
|
162
|
+
};
|
|
163
|
+
$[29] = expandNode;
|
|
164
|
+
$[30] = node.id;
|
|
165
|
+
$[31] = t9;
|
|
166
|
+
} else t9 = $[31];
|
|
167
|
+
const t10 = t9;
|
|
168
|
+
const t11 = node.error ? node.error.id : void 0;
|
|
169
|
+
let t12;
|
|
170
|
+
if ($[32] !== contextMenuActions || $[33] !== treeItemProps) {
|
|
171
|
+
t12 = (e) => {
|
|
172
|
+
if (treeItemProps.onContextMenu) treeItemProps.onContextMenu(e);
|
|
173
|
+
if (!contextMenuActions) return;
|
|
174
|
+
e.preventDefault();
|
|
175
|
+
const actions = injectActionVariant(contextMenuActions, "context-menu");
|
|
176
|
+
if (actions.length === 0) return;
|
|
177
|
+
setContextMenuProps({
|
|
178
|
+
position: {
|
|
179
|
+
x: e.clientX,
|
|
180
|
+
y: e.clientY
|
|
181
|
+
},
|
|
182
|
+
actions
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
$[32] = contextMenuActions;
|
|
186
|
+
$[33] = treeItemProps;
|
|
187
|
+
$[34] = t12;
|
|
188
|
+
} else t12 = $[34];
|
|
189
|
+
let t13;
|
|
190
|
+
if ($[35] !== decorations || $[36] !== expanded || $[37] !== forwardedRef || $[38] !== inlineActionItems || $[39] !== label || $[40] !== menuActionItems || $[41] !== t10 || $[42] !== t11 || $[43] !== t12 || $[44] !== treeItemProps) {
|
|
191
|
+
t13 = /* @__PURE__ */ jsx(Tree.Item, {
|
|
192
|
+
...treeItemProps,
|
|
193
|
+
ref: forwardedRef,
|
|
194
|
+
label,
|
|
195
|
+
expanded,
|
|
196
|
+
onExpandedChange: t10,
|
|
197
|
+
inlineActions: inlineActionItems,
|
|
198
|
+
actions: menuActionItems,
|
|
199
|
+
unstable_decorations: decorations,
|
|
200
|
+
error: t11,
|
|
201
|
+
onContextMenu: t12
|
|
202
|
+
});
|
|
203
|
+
$[35] = decorations;
|
|
204
|
+
$[36] = expanded;
|
|
205
|
+
$[37] = forwardedRef;
|
|
206
|
+
$[38] = inlineActionItems;
|
|
207
|
+
$[39] = label;
|
|
208
|
+
$[40] = menuActionItems;
|
|
209
|
+
$[41] = t10;
|
|
210
|
+
$[42] = t11;
|
|
211
|
+
$[43] = t12;
|
|
212
|
+
$[44] = treeItemProps;
|
|
213
|
+
$[45] = t13;
|
|
214
|
+
} else t13 = $[45];
|
|
215
|
+
let t14;
|
|
216
|
+
if ($[46] !== cancelRename || $[47] !== labelEditor || $[48] !== t13 || $[49] !== t8) {
|
|
217
|
+
t14 = /* @__PURE__ */ jsx(unstable_Popover, {
|
|
218
|
+
content: labelEditor,
|
|
219
|
+
placement: "bottom",
|
|
220
|
+
open: t8,
|
|
221
|
+
setOpen: cancelRename,
|
|
222
|
+
unmountOnHide: true,
|
|
223
|
+
children: t13
|
|
224
|
+
});
|
|
225
|
+
$[46] = cancelRename;
|
|
226
|
+
$[47] = labelEditor;
|
|
227
|
+
$[48] = t13;
|
|
228
|
+
$[49] = t8;
|
|
229
|
+
$[50] = t14;
|
|
230
|
+
} else t14 = $[50];
|
|
231
|
+
const t15 = contextMenuProps !== void 0;
|
|
232
|
+
let t16;
|
|
233
|
+
if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
|
|
234
|
+
t16 = (open) => {
|
|
235
|
+
if (!open) setContextMenuProps(void 0);
|
|
236
|
+
};
|
|
237
|
+
$[51] = t16;
|
|
238
|
+
} else t16 = $[51];
|
|
239
|
+
const t17 = `${node.id}-${contextMenuProps?.position.x ?? ""}-${contextMenuProps?.position.y ?? ""}`;
|
|
240
|
+
let t18;
|
|
241
|
+
if ($[52] !== contextMenuProps) {
|
|
242
|
+
t18 = contextMenuProps ? /* @__PURE__ */ jsx(DropdownMenu.Button, {
|
|
243
|
+
style: {
|
|
244
|
+
position: "fixed",
|
|
245
|
+
top: contextMenuProps.position.y,
|
|
246
|
+
left: contextMenuProps.position.x
|
|
247
|
+
},
|
|
248
|
+
render: /* @__PURE__ */ jsx("div", {})
|
|
249
|
+
}) : null;
|
|
250
|
+
$[52] = contextMenuProps;
|
|
251
|
+
$[53] = t18;
|
|
252
|
+
} else t18 = $[53];
|
|
253
|
+
const t19 = contextMenuProps?.actions;
|
|
254
|
+
let t20;
|
|
255
|
+
if ($[54] !== t19) {
|
|
256
|
+
t20 = /* @__PURE__ */ jsx(DropdownMenu.Content, {
|
|
257
|
+
focusable: true,
|
|
258
|
+
autoFocus: true,
|
|
259
|
+
children: t19
|
|
260
|
+
});
|
|
261
|
+
$[54] = t19;
|
|
262
|
+
$[55] = t20;
|
|
263
|
+
} else t20 = $[55];
|
|
264
|
+
let t21;
|
|
265
|
+
if ($[56] !== t15 || $[57] !== t17 || $[58] !== t18 || $[59] !== t20) {
|
|
266
|
+
t21 = /* @__PURE__ */ jsxs(DropdownMenu.Provider, {
|
|
267
|
+
open: t15,
|
|
268
|
+
setOpen: t16,
|
|
269
|
+
children: [t18, t20]
|
|
270
|
+
}, t17);
|
|
271
|
+
$[56] = t15;
|
|
272
|
+
$[57] = t17;
|
|
273
|
+
$[58] = t18;
|
|
274
|
+
$[59] = t20;
|
|
275
|
+
$[60] = t21;
|
|
276
|
+
} else t21 = $[60];
|
|
277
|
+
let t22;
|
|
278
|
+
if ($[61] !== t14 || $[62] !== t21) {
|
|
279
|
+
t22 = /* @__PURE__ */ jsxs(Fragment, { children: [t14, t21] });
|
|
280
|
+
$[61] = t14;
|
|
281
|
+
$[62] = t21;
|
|
282
|
+
$[63] = t22;
|
|
283
|
+
} else t22 = $[63];
|
|
284
|
+
return t22;
|
|
285
|
+
}));
|
|
286
|
+
const PlaceholderNode = memo(forwardRef(function PlaceholderNode(t0, forwardedRef) {
|
|
287
|
+
const $ = c(13);
|
|
288
|
+
let props;
|
|
289
|
+
if ($[0] !== t0) {
|
|
290
|
+
({...props} = t0);
|
|
291
|
+
$[0] = t0;
|
|
292
|
+
$[1] = props;
|
|
293
|
+
} else props = $[1];
|
|
294
|
+
const translate = useTranslation();
|
|
295
|
+
let t1;
|
|
296
|
+
if ($[2] !== translate) {
|
|
297
|
+
t1 = translate("loading");
|
|
298
|
+
$[2] = translate;
|
|
299
|
+
$[3] = t1;
|
|
300
|
+
} else t1 = $[3];
|
|
301
|
+
let t2;
|
|
302
|
+
if ($[4] !== translate) {
|
|
303
|
+
t2 = translate("loading");
|
|
304
|
+
$[4] = translate;
|
|
305
|
+
$[5] = t2;
|
|
306
|
+
} else t2 = $[5];
|
|
307
|
+
let t3;
|
|
308
|
+
if ($[6] !== t2) {
|
|
309
|
+
t3 = /* @__PURE__ */ jsx(Spinner, {
|
|
310
|
+
size: "small",
|
|
311
|
+
title: t2
|
|
312
|
+
});
|
|
313
|
+
$[6] = t2;
|
|
314
|
+
$[7] = t3;
|
|
315
|
+
} else t3 = $[7];
|
|
316
|
+
let t4;
|
|
317
|
+
if ($[8] !== forwardedRef || $[9] !== props || $[10] !== t1 || $[11] !== t3) {
|
|
318
|
+
t4 = /* @__PURE__ */ jsx(Tree.Item, {
|
|
319
|
+
...props,
|
|
320
|
+
ref: forwardedRef,
|
|
321
|
+
label: t1,
|
|
322
|
+
unstable_decorations: t3
|
|
323
|
+
});
|
|
324
|
+
$[8] = forwardedRef;
|
|
325
|
+
$[9] = props;
|
|
326
|
+
$[10] = t1;
|
|
327
|
+
$[11] = t3;
|
|
328
|
+
$[12] = t4;
|
|
329
|
+
} else t4 = $[12];
|
|
330
|
+
return t4;
|
|
331
|
+
}));
|
|
332
|
+
function LabelEditor(t0) {
|
|
333
|
+
const $ = c(49);
|
|
334
|
+
const { initialLabel, labelValidationHint, onChange, onCancel, validate } = t0;
|
|
335
|
+
const translate = useTranslation();
|
|
336
|
+
const inputRef = useRef(null);
|
|
337
|
+
const [newLabelValue, setNewLabelValue] = useState(initialLabel);
|
|
338
|
+
const [hasError, setHasError] = useState(false);
|
|
339
|
+
let t1;
|
|
340
|
+
if ($[0] !== initialLabel || $[1] !== newLabelValue || $[2] !== onCancel || $[3] !== onChange || $[4] !== validate) {
|
|
341
|
+
t1 = () => {
|
|
342
|
+
if (validate && !validate(newLabelValue)) {
|
|
343
|
+
setHasError(true);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
if (initialLabel !== newLabelValue) {
|
|
347
|
+
onChange?.(newLabelValue);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
onCancel?.();
|
|
351
|
+
};
|
|
352
|
+
$[0] = initialLabel;
|
|
353
|
+
$[1] = newLabelValue;
|
|
354
|
+
$[2] = onCancel;
|
|
355
|
+
$[3] = onChange;
|
|
356
|
+
$[4] = validate;
|
|
357
|
+
$[5] = t1;
|
|
358
|
+
} else t1 = $[5];
|
|
359
|
+
const handleLabelChange = t1;
|
|
360
|
+
let t2;
|
|
361
|
+
if ($[6] !== initialLabel || $[7] !== onCancel) {
|
|
362
|
+
t2 = () => {
|
|
363
|
+
setNewLabelValue(initialLabel);
|
|
364
|
+
onCancel?.();
|
|
365
|
+
};
|
|
366
|
+
$[6] = initialLabel;
|
|
367
|
+
$[7] = onCancel;
|
|
368
|
+
$[8] = t2;
|
|
369
|
+
} else t2 = $[8];
|
|
370
|
+
const cancelLabelChange = t2;
|
|
371
|
+
let t3;
|
|
372
|
+
let t4;
|
|
373
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
374
|
+
t3 = () => {
|
|
375
|
+
if (inputRef.current) {
|
|
376
|
+
inputRef.current.focus();
|
|
377
|
+
inputRef.current.select();
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
t4 = [];
|
|
381
|
+
$[9] = t3;
|
|
382
|
+
$[10] = t4;
|
|
383
|
+
} else {
|
|
384
|
+
t3 = $[9];
|
|
385
|
+
t4 = $[10];
|
|
386
|
+
}
|
|
387
|
+
useEffect(t3, t4);
|
|
388
|
+
const canRename = newLabelValue && newLabelValue !== initialLabel && !hasError;
|
|
389
|
+
const inputId = useId();
|
|
390
|
+
let t5;
|
|
391
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
392
|
+
t5 = { width: "100%" };
|
|
393
|
+
$[11] = t5;
|
|
394
|
+
} else t5 = $[11];
|
|
395
|
+
const t6 = hasError ? "with-error" : void 0;
|
|
396
|
+
let t7;
|
|
397
|
+
if ($[12] !== translate) {
|
|
398
|
+
t7 = translate("newLabel");
|
|
399
|
+
$[12] = translate;
|
|
400
|
+
$[13] = t7;
|
|
401
|
+
} else t7 = $[13];
|
|
402
|
+
let t8;
|
|
403
|
+
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
|
|
404
|
+
t8 = (event) => {
|
|
405
|
+
setNewLabelValue(event.target.value);
|
|
406
|
+
setHasError(false);
|
|
407
|
+
};
|
|
408
|
+
$[14] = t8;
|
|
409
|
+
} else t8 = $[14];
|
|
410
|
+
let t9;
|
|
411
|
+
if ($[15] !== cancelLabelChange || $[16] !== handleLabelChange) {
|
|
412
|
+
t9 = (event_0) => {
|
|
413
|
+
if (event_0.key === "Enter") handleLabelChange();
|
|
414
|
+
else if (event_0.key === "Escape") cancelLabelChange();
|
|
415
|
+
};
|
|
416
|
+
$[15] = cancelLabelChange;
|
|
417
|
+
$[16] = handleLabelChange;
|
|
418
|
+
$[17] = t9;
|
|
419
|
+
} else t9 = $[17];
|
|
420
|
+
let t10;
|
|
421
|
+
if ($[18] !== inputId || $[19] !== newLabelValue || $[20] !== t7 || $[21] !== t9) {
|
|
422
|
+
t10 = /* @__PURE__ */ jsx(TextBox.Input, {
|
|
423
|
+
id: inputId,
|
|
424
|
+
ref: inputRef,
|
|
425
|
+
"aria-label": t7,
|
|
426
|
+
value: newLabelValue,
|
|
427
|
+
onChange: t8,
|
|
428
|
+
onKeyUp: t9
|
|
429
|
+
});
|
|
430
|
+
$[18] = inputId;
|
|
431
|
+
$[19] = newLabelValue;
|
|
432
|
+
$[20] = t7;
|
|
433
|
+
$[21] = t9;
|
|
434
|
+
$[22] = t10;
|
|
435
|
+
} else t10 = $[22];
|
|
436
|
+
let t11;
|
|
437
|
+
if ($[23] !== t10 || $[24] !== t6) {
|
|
438
|
+
t11 = /* @__PURE__ */ jsx(TextBox.Root, {
|
|
439
|
+
style: t5,
|
|
440
|
+
className: t6,
|
|
441
|
+
children: t10
|
|
442
|
+
});
|
|
443
|
+
$[23] = t10;
|
|
444
|
+
$[24] = t6;
|
|
445
|
+
$[25] = t11;
|
|
446
|
+
} else t11 = $[25];
|
|
447
|
+
let t12;
|
|
448
|
+
if ($[26] !== translate) {
|
|
449
|
+
t12 = translate("cancel");
|
|
450
|
+
$[26] = translate;
|
|
451
|
+
$[27] = t12;
|
|
452
|
+
} else t12 = $[27];
|
|
453
|
+
let t13;
|
|
454
|
+
if ($[28] !== cancelLabelChange || $[29] !== t12) {
|
|
455
|
+
t13 = /* @__PURE__ */ jsx(IconButton, {
|
|
456
|
+
icon: dismissSvg,
|
|
457
|
+
label: t12,
|
|
458
|
+
onClick: cancelLabelChange
|
|
459
|
+
});
|
|
460
|
+
$[28] = cancelLabelChange;
|
|
461
|
+
$[29] = t12;
|
|
462
|
+
$[30] = t13;
|
|
463
|
+
} else t13 = $[30];
|
|
464
|
+
let t14;
|
|
465
|
+
if ($[31] !== translate) {
|
|
466
|
+
t14 = translate("confirm");
|
|
467
|
+
$[31] = translate;
|
|
468
|
+
$[32] = t14;
|
|
469
|
+
} else t14 = $[32];
|
|
470
|
+
const t15 = !canRename;
|
|
471
|
+
let t16;
|
|
472
|
+
if ($[33] !== handleLabelChange || $[34] !== t14 || $[35] !== t15) {
|
|
473
|
+
t16 = /* @__PURE__ */ jsx(IconButton, {
|
|
474
|
+
icon: checkmarkSvg,
|
|
475
|
+
label: t14,
|
|
476
|
+
onClick: handleLabelChange,
|
|
477
|
+
disabled: t15
|
|
478
|
+
});
|
|
479
|
+
$[33] = handleLabelChange;
|
|
480
|
+
$[34] = t14;
|
|
481
|
+
$[35] = t15;
|
|
482
|
+
$[36] = t16;
|
|
483
|
+
} else t16 = $[36];
|
|
484
|
+
let t17;
|
|
485
|
+
if ($[37] !== t11 || $[38] !== t13 || $[39] !== t16) {
|
|
486
|
+
t17 = /* @__PURE__ */ jsxs("div", {
|
|
487
|
+
className: "phr-node-label-editor-input-row",
|
|
488
|
+
children: [
|
|
489
|
+
t11,
|
|
490
|
+
t13,
|
|
491
|
+
t16
|
|
492
|
+
]
|
|
493
|
+
});
|
|
494
|
+
$[37] = t11;
|
|
495
|
+
$[38] = t13;
|
|
496
|
+
$[39] = t16;
|
|
497
|
+
$[40] = t17;
|
|
498
|
+
} else t17 = $[40];
|
|
499
|
+
let t18;
|
|
500
|
+
if ($[41] !== hasError || $[42] !== inputId || $[43] !== labelValidationHint) {
|
|
501
|
+
t18 = labelValidationHint !== void 0 ? /* @__PURE__ */ jsx(Description, {
|
|
502
|
+
id: inputId,
|
|
503
|
+
tone: hasError ? "critical" : "neutral",
|
|
504
|
+
style: { display: "flex" },
|
|
505
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
506
|
+
variant: "caption-lg",
|
|
507
|
+
children: labelValidationHint
|
|
508
|
+
})
|
|
509
|
+
}) : void 0;
|
|
510
|
+
$[41] = hasError;
|
|
511
|
+
$[42] = inputId;
|
|
512
|
+
$[43] = labelValidationHint;
|
|
513
|
+
$[44] = t18;
|
|
514
|
+
} else t18 = $[44];
|
|
515
|
+
let t19;
|
|
516
|
+
if ($[45] !== initialLabel || $[46] !== t17 || $[47] !== t18) {
|
|
517
|
+
t19 = /* @__PURE__ */ jsxs("div", {
|
|
518
|
+
className: "phr-node-label-editor",
|
|
519
|
+
children: [t17, t18]
|
|
520
|
+
}, initialLabel);
|
|
521
|
+
$[45] = initialLabel;
|
|
522
|
+
$[46] = t17;
|
|
523
|
+
$[47] = t18;
|
|
524
|
+
$[48] = t19;
|
|
525
|
+
} else t19 = $[48];
|
|
526
|
+
return t19;
|
|
527
|
+
}
|
|
528
|
+
function injectActionVariant(actions, variant) {
|
|
529
|
+
return actions.filter((action) => isValidElement(action)).map((action) => cloneElement(action, { variant }));
|
|
530
|
+
}
|
|
531
|
+
//#endregion
|
|
532
|
+
export { PlaceholderNode, StrataKitTreeNodeRenderer };
|
|
533
|
+
|
|
534
|
+
//# sourceMappingURL=TreeNodeRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeNodeRenderer.js","names":["cloneElement","forwardRef","isValidElement","memo","useCallback","useEffect","useId","useMemo","useRef","useState","Description","IconButton","Spinner","Text","TextBox","DropdownMenu","unstable_Popover","Popover","Tree","useTranslation","TreeActionBase","useTreeNodeRenameContext","checkmarkSvg","dismissSvg","refreshSvg","ComponentPropsWithoutRef","FC","PropsWithRef","ReactNode","RefAttributes","TreeRendererProps","TreeNode","TreeActionBaseAttributes","TreeNodeRendererOwnProps","Pick","node","menuActions","inlineActions","contextMenuActions","StrataKitTreeItemProps","Omit","Item","decorations","TreeNodeRendererProps","StrataKitTreeNodeRenderer","HTMLElement","HierarchyNode","props","forwardedRef","$","_c","expandNode","reloadTree","treeItemProps","translate","renameContext","contextMenuProps","setContextMenuProps","undefined","label","t0","bb0","error","type","t1","t2","id","parentNodeId","state","t3","injectActionVariant","inlineActionItems","bb1","menuActionItems","bb2","isNodeExpandable","children","length","isExpanded","expanded","renameParameters","cancelRename","t4","commit","t5","labelValidationHint","t6","validate","t7","labelEditor","t8","nodeId","t9","t10","t11","t12","e","onContextMenu","preventDefault","actions","position","x","clientX","y","clientY","t13","t14","t15","t16","Symbol","for","open","t17","t18","top","left","t19","t20","t21","t22","PlaceholderNode","LabelEditor","initialLabel","onChange","onCancel","inputRef","newLabelValue","setNewLabelValue","hasError","setHasError","handleLabelChange","cancelLabelChange","current","focus","select","canRename","inputId","width","event","target","value","event_0","key","display","variant","filter","action","map"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./TreeNodeRenderer.css\";\n\nimport {\n cloneElement,\n forwardRef,\n isValidElement,\n memo,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Description, IconButton, Spinner, Text, TextBox } from \"@stratakit/bricks\";\nimport { DropdownMenu, unstable_Popover as Popover, Tree } from \"@stratakit/structures\";\nimport { useTranslation } from \"../LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\nimport { useTreeNodeRenameContext } from \"./TreeNodeRenameAction.js\";\n\nimport checkmarkSvg from \"@stratakit/icons/checkmark.svg\";\nimport dismissSvg from \"@stratakit/icons/dismiss.svg\";\nimport refreshSvg from \"@stratakit/icons/refresh.svg\";\n\nimport type { ComponentPropsWithoutRef, FC, PropsWithRef, ReactNode, RefAttributes } from \"react\";\nimport type { TreeRendererProps } from \"../Renderers.js\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/** @internal */\ninterface TreeNodeRendererOwnProps extends Pick<TreeRendererProps, \"expandNode\" | \"reloadTree\"> {\n /** Node that is rendered. */\n node: TreeNode;\n /**\n * Menu actions for tree item.\n * Must be an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n menuActions?: ReactNode[];\n /**\n * Inline actions for tree item.\n * Must be an array of `<TreeActionBase />` elements.\n * Max 2 items.\n */\n inlineActions?: ReactNode[];\n /**\n * Context menu actions for tree item.\n * Must be an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n contextMenuActions?: ReactNode[];\n}\n\n/** @alpha */\nexport type StrataKitTreeItemProps = Omit<\n ComponentPropsWithoutRef<typeof Tree.Item>,\n \"actions\" | \"inlineActions\" | \"expanded\" | \"onExpandedChange\" | \"icon\" | \"unstable_decorations\" | \"error\"\n> & {\n /**\n * Used to render elements between expander and label.\n * E.g. icons, color picker, etc.\n */\n decorations?: ReactNode;\n};\n\n/** @internal */\nexport type TreeNodeRendererProps = StrataKitTreeItemProps & TreeNodeRendererOwnProps;\n\n/**\n * A component that renders a given `TreeNode` using the `Tree.Item` component from `@stratakit/structures`.\n *\n * @internal\n */\nexport const StrataKitTreeNodeRenderer: FC<PropsWithRef<TreeNodeRendererProps & RefAttributes<HTMLElement>>> = memo(\n forwardRef<HTMLElement, TreeNodeRendererProps>(function HierarchyNode(props, forwardedRef) {\n const {\n node,\n decorations,\n inlineActions,\n menuActions,\n contextMenuActions,\n expandNode,\n reloadTree,\n ...treeItemProps\n } = props;\n const translate = useTranslation();\n const renameContext = useTreeNodeRenameContext();\n const [contextMenuProps, setContextMenuProps] = useState<\n { position: { x: number; y: number }; actions: ReactNode[] } | undefined\n >(undefined);\n\n const label = treeItemProps.label ?? node.label;\n const inlineActionItems = useMemo(() => {\n if (node.error !== undefined && node.error.type === \"ChildrenLoad\") {\n return [\n <TreeActionBase\n key=\"retry\"\n label={translate(\"retry\")}\n onClick={() => reloadTree({ parentNodeId: node.id, state: \"reset\" })}\n visible={true}\n icon={refreshSvg}\n variant=\"inline\"\n />,\n ];\n }\n if (!inlineActions) {\n return undefined;\n }\n return injectActionVariant(inlineActions, \"inline\");\n }, [node, inlineActions, translate, reloadTree]);\n\n const menuActionItems = useMemo(() => {\n if (!menuActions) {\n return undefined;\n }\n return injectActionVariant(menuActions, \"default\");\n }, [menuActions]);\n\n const expanded = useMemo(() => {\n if (node.error && (node.error.type !== \"Unknown\" || !node.error.isNodeExpandable)) {\n return undefined;\n }\n\n // this is a leaf node\n if (node.children !== true && node.children.length === 0) {\n return undefined;\n }\n\n return node.isExpanded;\n }, [node]);\n\n const { renameParameters, cancelRename } = renameContext ?? {};\n const labelEditor = (\n <LabelEditor\n initialLabel={node.label}\n onChange={renameParameters?.commit}\n onCancel={cancelRename}\n labelValidationHint={renameParameters?.labelValidationHint}\n validate={renameParameters?.validate}\n />\n );\n\n return (\n <>\n <Popover\n content={labelEditor}\n placement=\"bottom\"\n open={renameParameters?.nodeId === node.id}\n setOpen={cancelRename}\n unmountOnHide\n >\n <Tree.Item\n {...treeItemProps}\n ref={forwardedRef}\n label={label}\n expanded={expanded}\n onExpandedChange={useCallback(\n (isExpanded: boolean) => {\n expandNode(node.id, isExpanded);\n },\n [node, expandNode],\n )}\n inlineActions={inlineActionItems}\n actions={menuActionItems}\n unstable_decorations={decorations}\n error={node.error ? node.error.id : undefined}\n onContextMenu={(e) => {\n if (treeItemProps.onContextMenu) {\n treeItemProps.onContextMenu(e);\n }\n\n if (!contextMenuActions) {\n return;\n }\n\n e.preventDefault();\n const actions = injectActionVariant(contextMenuActions, \"context-menu\");\n if (actions.length === 0) {\n return;\n }\n\n setContextMenuProps({ position: { x: e.clientX, y: e.clientY }, actions });\n }}\n />\n </Popover>\n <DropdownMenu.Provider\n open={contextMenuProps !== undefined}\n setOpen={(open) => {\n if (!open) {\n setContextMenuProps(undefined);\n }\n }}\n key={`${node.id}-${contextMenuProps?.position.x ?? \"\"}-${contextMenuProps?.position.y ?? \"\"}`}\n >\n {contextMenuProps ? (\n <DropdownMenu.Button\n style={{ position: \"fixed\", top: contextMenuProps.position.y, left: contextMenuProps.position.x }}\n render={<div />}\n />\n ) : null}\n {/* `autoFocus` prop is coming from ariakit and is not native HTML `autoFocus` prop. */}\n {/* `focusable` is needed for `autoFocus` to work. StrataKit exposes only `autoFocus` and does not set `focusable` internally. */}\n {/* eslint-disable jsx-a11y/no-autofocus */}\n {/* @ts-expect-error focusable is passed through */}\n <DropdownMenu.Content focusable autoFocus={true}>\n {contextMenuProps?.actions}\n </DropdownMenu.Content>\n </DropdownMenu.Provider>\n </>\n );\n }),\n);\n\nexport const PlaceholderNode: FC<\n PropsWithRef<\n Pick<StrataKitTreeItemProps, \"style\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\"> & RefAttributes<HTMLElement>\n >\n> = memo(\n forwardRef<HTMLElement, Pick<StrataKitTreeItemProps, \"style\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\">>(\n function PlaceholderNode({ ...props }, forwardedRef) {\n const translate = useTranslation();\n return (\n <Tree.Item\n {...props}\n ref={forwardedRef}\n label={translate(\"loading\")}\n unstable_decorations={<Spinner size={\"small\"} title={translate(\"loading\")} />}\n />\n );\n },\n ),\n);\n\nfunction LabelEditor({\n initialLabel,\n labelValidationHint,\n onChange,\n onCancel,\n validate,\n}: {\n initialLabel: string;\n labelValidationHint?: string;\n onChange?: (newLabel: string) => void;\n onCancel?: () => void;\n validate?: (newLabel: string) => boolean;\n}) {\n const translate = useTranslation();\n const inputRef = useRef<HTMLInputElement>(null);\n const [newLabelValue, setNewLabelValue] = useState(initialLabel);\n const [hasError, setHasError] = useState<boolean>(false);\n const handleLabelChange = () => {\n if (validate && !validate(newLabelValue)) {\n setHasError(true);\n return;\n }\n\n if (initialLabel !== newLabelValue) {\n onChange?.(newLabelValue);\n return;\n }\n onCancel?.();\n };\n\n const cancelLabelChange = () => {\n setNewLabelValue(initialLabel);\n onCancel?.();\n };\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.focus();\n inputRef.current.select();\n }\n }, []);\n\n const canRename = newLabelValue && newLabelValue !== initialLabel && !hasError;\n const inputId = useId();\n\n return (\n <div key={initialLabel} className=\"phr-node-label-editor\">\n <div className=\"phr-node-label-editor-input-row\">\n <TextBox.Root style={{ width: \"100%\" }} className={hasError ? \"with-error\" : undefined}>\n <TextBox.Input\n id={inputId}\n ref={inputRef}\n aria-label={translate(\"newLabel\")}\n value={newLabelValue}\n onChange={(event) => {\n setNewLabelValue(event.target.value);\n setHasError(false);\n }}\n onKeyUp={(event) => {\n if (event.key === \"Enter\") {\n handleLabelChange();\n } else if (event.key === \"Escape\") {\n cancelLabelChange();\n }\n }}\n />\n </TextBox.Root>\n <IconButton icon={dismissSvg} label={translate(\"cancel\")} onClick={cancelLabelChange} />\n <IconButton\n icon={checkmarkSvg}\n label={translate(\"confirm\")}\n onClick={handleLabelChange}\n disabled={!canRename}\n />\n </div>\n {labelValidationHint !== undefined ? (\n <Description id={inputId} tone={hasError ? \"critical\" : \"neutral\"} style={{ display: \"flex\" }}>\n <Text variant=\"caption-lg\">{labelValidationHint}</Text>\n </Description>\n ) : undefined}\n </div>\n );\n}\n\nfunction injectActionVariant(actions: ReactNode[], variant: TreeActionBaseAttributes[\"variant\"]) {\n return actions\n .filter((action) => isValidElement<TreeActionBaseAttributes>(action))\n .map((action) => cloneElement<TreeActionBaseAttributes>(action, { variant }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4EA,MAAa4C,4BAAkGzC,KAC7GF,WAA+C,SAAA6C,cAAAC,OAAAC,cAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAA,IAAAZ;CAAA,IAAAI;CAAA,IAAAS;CAAA,IAAAd;CAAA,IAAAD;CAAA,IAAAD;CAAA,IAAAiB;CAAA,IAAAC;AAAA,KAAAJ,EAAA,OAAAF,OAAA;AAC7C,GAAA,CAAAZ,MAAAO,aAAAL,eAAAD,aAAAE,oBAAAa,YAAAC,eAAAC,iBASIN;AAAME,IAAA,KAAAF;AAAAE,IAAA,KAAAX;AAAAW,IAAA,KAAAP;AAAAO,IAAA,KAAAE;AAAAF,IAAA,KAAAZ;AAAAY,IAAA,KAAAb;AAAAa,IAAA,KAAAd;AAAAc,IAAA,KAAAG;AAAAH,IAAA,KAAAI;QAAA;AAAAf,uBAAAW,EAAA;AAAAP,gBAAAO,EAAA;AAAAE,eAAAF,EAAA;AAAAZ,kBAAAY,EAAA;AAAAb,gBAAAa,EAAA;AAAAd,SAAAc,EAAA;AAAAG,eAAAH,EAAA;AAAAI,kBAAAJ,EAAA;;CACV,MAAAK,YAAkBnC,gBAAgB;CAClC,MAAAoC,gBAAsBlC,0BAA0B;CAChD,MAAA,CAAAmC,kBAAAC,uBAAgDhD,SAE9CiD,KAAAA,EAAU;CAEZ,MAAAC,QAAcN,cAAaM,SAAUxB,KAAIwB;CAAO,IAAAC;AAAAC,MAAA;AAE9C,MAAI1B,KAAI2B,UAAWJ,KAAAA,KAAavB,KAAI2B,MAAMC,SAAU,gBAAc;GAAA,IAAAC;AAAA,OAAAf,EAAA,OAAAK,WAAA;AAIrDU,SAAAV,UAAU,QAAQ;AAAAL,MAAA,KAAAK;AAAAL,MAAA,MAAAe;SAAAA,M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AAAgE,KAAA;AAjCfG,QAAA,qBAAA,OAAA;GAAkC,WAAA;aAAlC,CACEJ,KA4BCC,IAKG;KAlCIS,aAkCJ;AAAAzE,IAAA,MAAAyE;AAAAzE,IAAA,MAAA+D;AAAA/D,IAAA,MAAAgE;AAAAhE,IAAA,MAAAmE;OAAAA,OAAAnE,EAAA;AAAA,QAlCNmE;;AAsCJ,SAAS9C,oBAAoB6B,SAAsB6C,SAA8C;AAC/F,QAAO7C,QACJ8C,QAAQC,WAAWhJ,eAAyCgJ,OAAO,CAAC,CACpEC,KAAKD,WAAWlJ,aAAuCkJ,QAAQ,EAAEF,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { TreeNode } from "../TreeNode.js";
|
|
2
|
+
import { TreeRendererProps } from "../Renderers.js";
|
|
3
|
+
import { SelectionMode } from "../UseSelectionHandler.js";
|
|
4
|
+
import { TreeNodeEditingProps } from "./TreeNodeRenameAction.js";
|
|
5
|
+
import { TreeErrorRendererProps } from "./TreeErrorRenderer.js";
|
|
6
|
+
import { StrataKitTreeItemProps } from "./TreeNodeRenderer.js";
|
|
7
|
+
import { ComponentProps, FC, PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from "react";
|
|
8
|
+
import { Tree } from "@stratakit/structures";
|
|
9
|
+
|
|
10
|
+
//#region src/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts
|
|
11
|
+
/** @alpha */
|
|
12
|
+
interface TreeRendererOwnProps {
|
|
13
|
+
id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* A user friendly display label of the tree. Should be unique within the consuming application,
|
|
16
|
+
* as it's used for accessibility purposes.
|
|
17
|
+
*/
|
|
18
|
+
treeLabel: string;
|
|
19
|
+
/** Active selection mode used by the tree. Defaults to `"single"`. */
|
|
20
|
+
selectionMode?: SelectionMode;
|
|
21
|
+
/** A render function for errors' display component. Defaults to `<TreeErrorRenderer />`. */
|
|
22
|
+
errorRenderer?: (props: TreeErrorRendererProps) => ReactElement;
|
|
23
|
+
/** Props that defines if current node supports editing. */
|
|
24
|
+
getEditingProps?: (node: TreeNode) => TreeNodeEditingProps | undefined;
|
|
25
|
+
/** Custom props for the root Tree component. */
|
|
26
|
+
treeRootProps?: Partial<Omit<ComponentProps<typeof Tree.Root>, "style">>;
|
|
27
|
+
/** A callback that returns tree item props for specific node. */
|
|
28
|
+
getTreeItemProps?: (node: TreeNode) => Partial<Omit<StrataKitTreeItemProps, "selected" | "aria-level" | "aria-posinset" | "aria-setsize">>;
|
|
29
|
+
/**
|
|
30
|
+
* Callback that returns menu actions for tree item.
|
|
31
|
+
* Must return an array of `<TreeActionBase />` or `<Divider />` elements.
|
|
32
|
+
*/
|
|
33
|
+
getMenuActions?: (props: {
|
|
34
|
+
targetNode: TreeNode;
|
|
35
|
+
selectedNodes: TreeNode[];
|
|
36
|
+
}) => ReactNode[];
|
|
37
|
+
/**
|
|
38
|
+
* Callback that returns inline actions for tree item.
|
|
39
|
+
* Must return an array of `<TreeActionBase />` elements.
|
|
40
|
+
* Max 2 items.
|
|
41
|
+
*/
|
|
42
|
+
getInlineActions?: (props: {
|
|
43
|
+
targetNode: TreeNode;
|
|
44
|
+
selectedNodes: TreeNode[];
|
|
45
|
+
}) => ReactNode[];
|
|
46
|
+
/**
|
|
47
|
+
* Callback that returns actions for tree item context menu.
|
|
48
|
+
* Must return an array of `<TreeActionBase />` or `<Divider />` elements.
|
|
49
|
+
*/
|
|
50
|
+
getContextMenuActions?: (props: {
|
|
51
|
+
targetNode: TreeNode;
|
|
52
|
+
selectedNodes: TreeNode[];
|
|
53
|
+
}) => ReactNode[];
|
|
54
|
+
}
|
|
55
|
+
/** @alpha */
|
|
56
|
+
interface StrataKitTreeRendererAttributes {
|
|
57
|
+
/**
|
|
58
|
+
* Opens rename mode for the first node that matches the given predicate. Node must be already loaded in the tree.
|
|
59
|
+
* If the node is not visible (because its parent is collapsed), all parents will be expanded to make it visible and node will be scrolled into view.
|
|
60
|
+
*
|
|
61
|
+
* Returns "node-not-found" if no node matches the predicate, "success" if rename was initiated.
|
|
62
|
+
*/
|
|
63
|
+
renameNode: (nodePredicate: (node: TreeNode) => boolean) => "node-not-found" | "success";
|
|
64
|
+
}
|
|
65
|
+
/** @alpha */
|
|
66
|
+
type StrataKitTreeRendererProps = TreeRendererProps & Pick<TreeErrorRendererProps, "filterHierarchyLevel"> & TreeRendererOwnProps;
|
|
67
|
+
/**
|
|
68
|
+
* A component that renders a tree using the `Tree` component from `@stratakit/structures`.
|
|
69
|
+
*
|
|
70
|
+
* @alpha
|
|
71
|
+
*/
|
|
72
|
+
declare const StrataKitTreeRenderer: FC<PropsWithoutRef<StrataKitTreeRendererProps> & RefAttributes<StrataKitTreeRendererAttributes>>;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { StrataKitTreeRenderer, StrataKitTreeRendererAttributes };
|
|
75
|
+
//# sourceMappingURL=TreeRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeRenderer.tsx"],"mappings":";;;;;;;;;;;UAyBU,oBAAA;EACR,EAAA;EAD4B;;;;EAM5B,SAAA;EAMyB;EAJzB,aAAA,GAAgB,aAAA;EAOmC;EALnD,aAAA,IAAiB,KAAA,EAAO,sBAAA,KAA2B,YAAA;EAK3B;EAHxB,eAAA,IAAmB,IAAA,EAAM,QAAA,KAAa,oBAAA;EAO9B;EAJR,aAAA,GAAgB,OAAA,CAAQ,IAAA,CAAK,cAAA,QAAsB,IAAA,CAAK,IAAA;EAK3C;EAFb,gBAAA,IACE,IAAA,EAAM,QAAA,KACH,OAAA,CAAQ,IAAA,CAAK,sBAAA;EAMqB;;;;EAAvC,cAAA,IAAkB,KAAA;IAAS,UAAA,EAAY,QAAA;IAAU,aAAA,EAAe,QAAA;EAAA,MAAiB,SAAA;EAWO;;;;;EALxF,gBAAA,IAAoB,KAAA;IAAS,UAAA,EAAY,QAAA;IAAU,aAAA,EAAe,QAAA;EAAA,MAAiB,SAAA;EAtBlE;;;;EA2BjB,qBAAA,IAAyB,KAAA;IAAS,UAAA,EAAY,QAAA;IAAU,aAAA,EAAe,QAAA;EAAA,MAAiB,SAAA;AAAA;;UAIzE,+BAAA;EA1ByC;;;;;;EAiCxD,UAAA,GAAa,aAAA,GAAgB,IAAA,EAAM,QAAA;AAAA;;KAIhC,0BAAA,GAA6B,iBAAA,GAChC,IAAA,CAAK,sBAAA,4BACL,oBAAA;;;;;;cAOW,qBAAA,EAAuB,EAAA,CAClC,eAAA,CAAgB,0BAAA,IAA8B,aAAA,CAAc,+BAAA"}
|