@itwin/presentation-hierarchies-react 2.0.0-alpha.64 → 2.0.0-alpha.66
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 +51 -0
- package/README.md +2 -8
- package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
- package/lib/presentation-hierarchies-react/UseTree.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +45 -39
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/{TreeNodeRenderer.css → LabelEditor.css} +3 -3
- package/lib/presentation-hierarchies-react/stratakit/LabelEditor.js +300 -0
- package/lib/presentation-hierarchies-react/stratakit/LabelEditor.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js +0 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeContextMenu.js +97 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeContextMenu.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +0 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +43 -351
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +34 -5
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -1
- package/package.json +31 -26
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { useTranslation } from "../LocalizationContext.js";
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { FormHelperText, IconButton, Popover, TextField, Typography } from "@mui/material";
|
|
6
|
+
import { Icon } from "@stratakit/mui";
|
|
7
|
+
import "./LabelEditor.css";
|
|
8
|
+
import checkmarkSvg from "@stratakit/icons/checkmark.svg";
|
|
9
|
+
import dismissSvg from "@stratakit/icons/dismiss.svg";
|
|
10
|
+
//#region src/presentation-hierarchies-react/stratakit/LabelEditor.tsx
|
|
11
|
+
/**
|
|
12
|
+
* Renders the label editor for the node whose rename is in progress. It's rendered once at the tree
|
|
13
|
+
* level as a popover anchored to an invisible element positioned at the renamed node's label location,
|
|
14
|
+
* so it doesn't depend on the virtualized row's DOM element.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
function TreeNodeLabelEditorOverlay(t0) {
|
|
19
|
+
const $ = c(18);
|
|
20
|
+
const { node, renameParameters, onCancel, style } = t0;
|
|
21
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[0] !== style) {
|
|
24
|
+
t1 = /* @__PURE__ */ jsx("div", {
|
|
25
|
+
ref: setAnchorEl,
|
|
26
|
+
style,
|
|
27
|
+
"aria-hidden": true
|
|
28
|
+
});
|
|
29
|
+
$[0] = style;
|
|
30
|
+
$[1] = t1;
|
|
31
|
+
} else t1 = $[1];
|
|
32
|
+
const t2 = anchorEl !== null;
|
|
33
|
+
let t3;
|
|
34
|
+
let t4;
|
|
35
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
36
|
+
t3 = {
|
|
37
|
+
vertical: "top",
|
|
38
|
+
horizontal: "left"
|
|
39
|
+
};
|
|
40
|
+
t4 = {
|
|
41
|
+
vertical: "top",
|
|
42
|
+
horizontal: "left"
|
|
43
|
+
};
|
|
44
|
+
$[2] = t3;
|
|
45
|
+
$[3] = t4;
|
|
46
|
+
} else {
|
|
47
|
+
t3 = $[2];
|
|
48
|
+
t4 = $[3];
|
|
49
|
+
}
|
|
50
|
+
let t5;
|
|
51
|
+
if ($[4] !== node.label || $[5] !== onCancel || $[6] !== renameParameters.commit || $[7] !== renameParameters.labelValidationHint || $[8] !== renameParameters.validate) {
|
|
52
|
+
t5 = /* @__PURE__ */ jsx(LabelEditor, {
|
|
53
|
+
initialLabel: node.label,
|
|
54
|
+
onChange: renameParameters.commit,
|
|
55
|
+
onCancel,
|
|
56
|
+
labelValidationHint: renameParameters.labelValidationHint,
|
|
57
|
+
validate: renameParameters.validate
|
|
58
|
+
});
|
|
59
|
+
$[4] = node.label;
|
|
60
|
+
$[5] = onCancel;
|
|
61
|
+
$[6] = renameParameters.commit;
|
|
62
|
+
$[7] = renameParameters.labelValidationHint;
|
|
63
|
+
$[8] = renameParameters.validate;
|
|
64
|
+
$[9] = t5;
|
|
65
|
+
} else t5 = $[9];
|
|
66
|
+
let t6;
|
|
67
|
+
if ($[10] !== anchorEl || $[11] !== onCancel || $[12] !== t2 || $[13] !== t5) {
|
|
68
|
+
t6 = /* @__PURE__ */ jsx(Popover, {
|
|
69
|
+
open: t2,
|
|
70
|
+
anchorEl,
|
|
71
|
+
onClose: onCancel,
|
|
72
|
+
anchorOrigin: t3,
|
|
73
|
+
transformOrigin: t4,
|
|
74
|
+
disableScrollLock: true,
|
|
75
|
+
children: t5
|
|
76
|
+
});
|
|
77
|
+
$[10] = anchorEl;
|
|
78
|
+
$[11] = onCancel;
|
|
79
|
+
$[12] = t2;
|
|
80
|
+
$[13] = t5;
|
|
81
|
+
$[14] = t6;
|
|
82
|
+
} else t6 = $[14];
|
|
83
|
+
let t7;
|
|
84
|
+
if ($[15] !== t1 || $[16] !== t6) {
|
|
85
|
+
t7 = /* @__PURE__ */ jsxs(Fragment, { children: [t1, t6] });
|
|
86
|
+
$[15] = t1;
|
|
87
|
+
$[16] = t6;
|
|
88
|
+
$[17] = t7;
|
|
89
|
+
} else t7 = $[17];
|
|
90
|
+
return t7;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* An editor for changing a tree node's label, rendered in a popover when node rename is initiated.
|
|
94
|
+
*
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
function LabelEditor(t0) {
|
|
98
|
+
const $ = c(49);
|
|
99
|
+
const { initialLabel, labelValidationHint, onChange, onCancel, validate } = t0;
|
|
100
|
+
const translate = useTranslation();
|
|
101
|
+
const inputRef = useRef(null);
|
|
102
|
+
const [newLabelValue, setNewLabelValue] = useState(initialLabel);
|
|
103
|
+
const [hasError, setHasError] = useState(false);
|
|
104
|
+
let t1;
|
|
105
|
+
if ($[0] !== initialLabel || $[1] !== newLabelValue || $[2] !== onCancel || $[3] !== onChange || $[4] !== validate) {
|
|
106
|
+
t1 = () => {
|
|
107
|
+
if (validate && !validate(newLabelValue)) {
|
|
108
|
+
setHasError(true);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (initialLabel !== newLabelValue) {
|
|
112
|
+
onChange?.(newLabelValue);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
onCancel?.();
|
|
116
|
+
};
|
|
117
|
+
$[0] = initialLabel;
|
|
118
|
+
$[1] = newLabelValue;
|
|
119
|
+
$[2] = onCancel;
|
|
120
|
+
$[3] = onChange;
|
|
121
|
+
$[4] = validate;
|
|
122
|
+
$[5] = t1;
|
|
123
|
+
} else t1 = $[5];
|
|
124
|
+
const handleLabelChange = t1;
|
|
125
|
+
let t2;
|
|
126
|
+
if ($[6] !== initialLabel || $[7] !== onCancel) {
|
|
127
|
+
t2 = () => {
|
|
128
|
+
setNewLabelValue(initialLabel);
|
|
129
|
+
onCancel?.();
|
|
130
|
+
};
|
|
131
|
+
$[6] = initialLabel;
|
|
132
|
+
$[7] = onCancel;
|
|
133
|
+
$[8] = t2;
|
|
134
|
+
} else t2 = $[8];
|
|
135
|
+
const cancelLabelChange = t2;
|
|
136
|
+
let t3;
|
|
137
|
+
let t4;
|
|
138
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
139
|
+
t3 = () => {
|
|
140
|
+
if (inputRef.current) {
|
|
141
|
+
inputRef.current.focus();
|
|
142
|
+
inputRef.current.select();
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
t4 = [];
|
|
146
|
+
$[9] = t3;
|
|
147
|
+
$[10] = t4;
|
|
148
|
+
} else {
|
|
149
|
+
t3 = $[9];
|
|
150
|
+
t4 = $[10];
|
|
151
|
+
}
|
|
152
|
+
useEffect(t3, t4);
|
|
153
|
+
const canRename = newLabelValue && newLabelValue !== initialLabel && !hasError;
|
|
154
|
+
const inputId = useId();
|
|
155
|
+
let t5;
|
|
156
|
+
if ($[11] !== translate) {
|
|
157
|
+
t5 = translate("newLabel");
|
|
158
|
+
$[11] = translate;
|
|
159
|
+
$[12] = t5;
|
|
160
|
+
} else t5 = $[12];
|
|
161
|
+
let t6;
|
|
162
|
+
if ($[13] !== t5) {
|
|
163
|
+
t6 = { htmlInput: { "aria-label": t5 } };
|
|
164
|
+
$[13] = t5;
|
|
165
|
+
$[14] = t6;
|
|
166
|
+
} else t6 = $[14];
|
|
167
|
+
let t7;
|
|
168
|
+
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
|
169
|
+
t7 = (event) => {
|
|
170
|
+
setNewLabelValue(event.target.value);
|
|
171
|
+
setHasError(false);
|
|
172
|
+
};
|
|
173
|
+
$[15] = t7;
|
|
174
|
+
} else t7 = $[15];
|
|
175
|
+
let t8;
|
|
176
|
+
if ($[16] !== cancelLabelChange || $[17] !== handleLabelChange) {
|
|
177
|
+
t8 = (event_0) => {
|
|
178
|
+
if (event_0.key === "Enter") handleLabelChange();
|
|
179
|
+
else if (event_0.key === "Escape") cancelLabelChange();
|
|
180
|
+
};
|
|
181
|
+
$[16] = cancelLabelChange;
|
|
182
|
+
$[17] = handleLabelChange;
|
|
183
|
+
$[18] = t8;
|
|
184
|
+
} else t8 = $[18];
|
|
185
|
+
let t9;
|
|
186
|
+
if ($[19] !== hasError || $[20] !== inputId || $[21] !== newLabelValue || $[22] !== t6 || $[23] !== t8) {
|
|
187
|
+
t9 = /* @__PURE__ */ jsx(TextField, {
|
|
188
|
+
fullWidth: true,
|
|
189
|
+
error: hasError,
|
|
190
|
+
size: "small",
|
|
191
|
+
id: inputId,
|
|
192
|
+
inputRef,
|
|
193
|
+
slotProps: t6,
|
|
194
|
+
value: newLabelValue,
|
|
195
|
+
onChange: t7,
|
|
196
|
+
onKeyDown: t8
|
|
197
|
+
});
|
|
198
|
+
$[19] = hasError;
|
|
199
|
+
$[20] = inputId;
|
|
200
|
+
$[21] = newLabelValue;
|
|
201
|
+
$[22] = t6;
|
|
202
|
+
$[23] = t8;
|
|
203
|
+
$[24] = t9;
|
|
204
|
+
} else t9 = $[24];
|
|
205
|
+
let t10;
|
|
206
|
+
if ($[25] !== translate) {
|
|
207
|
+
t10 = translate("cancel");
|
|
208
|
+
$[25] = translate;
|
|
209
|
+
$[26] = t10;
|
|
210
|
+
} else t10 = $[26];
|
|
211
|
+
let t11;
|
|
212
|
+
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
|
|
213
|
+
t11 = /* @__PURE__ */ jsx(Icon, { href: dismissSvg });
|
|
214
|
+
$[27] = t11;
|
|
215
|
+
} else t11 = $[27];
|
|
216
|
+
let t12;
|
|
217
|
+
if ($[28] !== cancelLabelChange || $[29] !== t10) {
|
|
218
|
+
t12 = /* @__PURE__ */ jsx(IconButton, {
|
|
219
|
+
"aria-label": t10,
|
|
220
|
+
onClick: cancelLabelChange,
|
|
221
|
+
size: "small",
|
|
222
|
+
children: t11
|
|
223
|
+
});
|
|
224
|
+
$[28] = cancelLabelChange;
|
|
225
|
+
$[29] = t10;
|
|
226
|
+
$[30] = t12;
|
|
227
|
+
} else t12 = $[30];
|
|
228
|
+
let t13;
|
|
229
|
+
if ($[31] !== translate) {
|
|
230
|
+
t13 = translate("confirm");
|
|
231
|
+
$[31] = translate;
|
|
232
|
+
$[32] = t13;
|
|
233
|
+
} else t13 = $[32];
|
|
234
|
+
const t14 = !canRename;
|
|
235
|
+
let t15;
|
|
236
|
+
if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
|
|
237
|
+
t15 = /* @__PURE__ */ jsx(Icon, { href: checkmarkSvg });
|
|
238
|
+
$[33] = t15;
|
|
239
|
+
} else t15 = $[33];
|
|
240
|
+
let t16;
|
|
241
|
+
if ($[34] !== handleLabelChange || $[35] !== t13 || $[36] !== t14) {
|
|
242
|
+
t16 = /* @__PURE__ */ jsx(IconButton, {
|
|
243
|
+
"aria-label": t13,
|
|
244
|
+
onClick: handleLabelChange,
|
|
245
|
+
disabled: t14,
|
|
246
|
+
size: "small",
|
|
247
|
+
children: t15
|
|
248
|
+
});
|
|
249
|
+
$[34] = handleLabelChange;
|
|
250
|
+
$[35] = t13;
|
|
251
|
+
$[36] = t14;
|
|
252
|
+
$[37] = t16;
|
|
253
|
+
} else t16 = $[37];
|
|
254
|
+
let t17;
|
|
255
|
+
if ($[38] !== t12 || $[39] !== t16 || $[40] !== t9) {
|
|
256
|
+
t17 = /* @__PURE__ */ jsxs("div", {
|
|
257
|
+
className: "phr-node-label-editor-input-row",
|
|
258
|
+
children: [
|
|
259
|
+
t9,
|
|
260
|
+
t12,
|
|
261
|
+
t16
|
|
262
|
+
]
|
|
263
|
+
});
|
|
264
|
+
$[38] = t12;
|
|
265
|
+
$[39] = t16;
|
|
266
|
+
$[40] = t9;
|
|
267
|
+
$[41] = t17;
|
|
268
|
+
} else t17 = $[41];
|
|
269
|
+
let t18;
|
|
270
|
+
if ($[42] !== hasError || $[43] !== labelValidationHint) {
|
|
271
|
+
t18 = labelValidationHint !== void 0 ? /* @__PURE__ */ jsx(FormHelperText, {
|
|
272
|
+
render: /* @__PURE__ */ jsx("div", {}),
|
|
273
|
+
error: hasError,
|
|
274
|
+
style: { display: "flex" },
|
|
275
|
+
children: /* @__PURE__ */ jsx(Typography, {
|
|
276
|
+
variant: "caption-md",
|
|
277
|
+
children: labelValidationHint
|
|
278
|
+
})
|
|
279
|
+
}) : void 0;
|
|
280
|
+
$[42] = hasError;
|
|
281
|
+
$[43] = labelValidationHint;
|
|
282
|
+
$[44] = t18;
|
|
283
|
+
} else t18 = $[44];
|
|
284
|
+
let t19;
|
|
285
|
+
if ($[45] !== initialLabel || $[46] !== t17 || $[47] !== t18) {
|
|
286
|
+
t19 = /* @__PURE__ */ jsxs("div", {
|
|
287
|
+
className: "phr-node-label-editor",
|
|
288
|
+
children: [t17, t18]
|
|
289
|
+
}, initialLabel);
|
|
290
|
+
$[45] = initialLabel;
|
|
291
|
+
$[46] = t17;
|
|
292
|
+
$[47] = t18;
|
|
293
|
+
$[48] = t19;
|
|
294
|
+
} else t19 = $[48];
|
|
295
|
+
return t19;
|
|
296
|
+
}
|
|
297
|
+
//#endregion
|
|
298
|
+
export { LabelEditor, TreeNodeLabelEditorOverlay };
|
|
299
|
+
|
|
300
|
+
//# sourceMappingURL=LabelEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LabelEditor.js","names":["useEffect","useId","useRef","useState","FormHelperText","IconButton","Popover","TextField","Typography","Icon","useTranslation","checkmarkSvg","dismissSvg","CSSProperties","TreeNode","RenameParameters","TreeNodeLabelEditorOverlay","t0","$","_c","node","renameParameters","onCancel","style","anchorEl","setAnchorEl","t1","t2","t3","t4","Symbol","for","vertical","horizontal","t5","label","commit","labelValidationHint","validate","t6","t7","LabelEditorProps","initialLabel","onChange","newLabel","LabelEditor","translate","inputRef","newLabelValue","setNewLabelValue","hasError","setHasError","handleLabelChange","cancelLabelChange","current","focus","select","canRename","inputId","htmlInput","event","target","value","t8","event_0","key","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","undefined","display","t19"],"sources":["../../../src/presentation-hierarchies-react/stratakit/LabelEditor.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 \"./LabelEditor.css\";\n\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport { FormHelperText, IconButton, Popover, TextField, Typography } from \"@mui/material\";\nimport { Icon } from \"@stratakit/mui\";\nimport { useTranslation } from \"../LocalizationContext.js\";\n\nimport checkmarkSvg from \"@stratakit/icons/checkmark.svg\";\nimport dismissSvg from \"@stratakit/icons/dismiss.svg\";\n\nimport type { CSSProperties } from \"react\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { RenameParameters } from \"./TreeNodeRenameAction.js\";\n\n/**\n * Renders the label editor for the node whose rename is in progress. It's rendered once at the tree\n * level as a popover anchored to an invisible element positioned at the renamed node's label location,\n * so it doesn't depend on the virtualized row's DOM element.\n *\n * @internal\n */\nexport function TreeNodeLabelEditorOverlay({\n node,\n renameParameters,\n onCancel,\n style,\n}: {\n node: TreeNode;\n renameParameters: RenameParameters;\n onCancel?: () => void;\n /** Placement of the anchor, generally an offset to the renamed node's label within the tree. */\n style?: CSSProperties;\n}) {\n const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(null);\n return (\n <>\n <div ref={setAnchorEl} style={style} aria-hidden />\n <Popover\n open={anchorEl !== null}\n anchorEl={anchorEl}\n onClose={onCancel}\n anchorOrigin={{ vertical: \"top\", horizontal: \"left\" }}\n transformOrigin={{ vertical: \"top\", horizontal: \"left\" }}\n disableScrollLock\n >\n <LabelEditor\n initialLabel={node.label}\n onChange={renameParameters.commit}\n onCancel={onCancel}\n labelValidationHint={renameParameters.labelValidationHint}\n validate={renameParameters.validate}\n />\n </Popover>\n </>\n );\n}\n\ninterface LabelEditorProps {\n initialLabel: string;\n labelValidationHint?: string;\n onChange?: (newLabel: string) => void;\n onCancel?: () => void;\n validate?: (newLabel: string) => boolean;\n}\n\n/**\n * An editor for changing a tree node's label, rendered in a popover when node rename is initiated.\n *\n * @internal\n */\nexport function LabelEditor({ initialLabel, labelValidationHint, onChange, onCancel, validate }: LabelEditorProps) {\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 <TextField\n fullWidth\n error={hasError}\n size=\"small\"\n id={inputId}\n inputRef={inputRef}\n slotProps={{ htmlInput: { \"aria-label\": translate(\"newLabel\") } }}\n value={newLabelValue}\n onChange={(event) => {\n setNewLabelValue(event.target.value);\n setHasError(false);\n }}\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n handleLabelChange();\n } else if (event.key === \"Escape\") {\n cancelLabelChange();\n }\n }}\n />\n <IconButton aria-label={translate(\"cancel\")} onClick={cancelLabelChange} size=\"small\">\n <Icon href={dismissSvg} />\n </IconButton>\n <IconButton aria-label={translate(\"confirm\")} onClick={handleLabelChange} disabled={!canRename} size=\"small\">\n <Icon href={checkmarkSvg} />\n </IconButton>\n </div>\n {labelValidationHint !== undefined ? (\n <FormHelperText render={<div />} error={hasError} style={{ display: \"flex\" }}>\n <Typography variant=\"caption-md\">{labelValidationHint}</Typography>\n </FormHelperText>\n ) : undefined}\n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QAAAgC,YAAAhC,EAAA,QAAAmB,qBAAA;EACLsC,MAAAtC,wBAAwBuC,KAAAA,IACvB,oBAAC,gBAAD;GAAwB,QAAA,oBAAA,OAAA,CAAO,CAAA;GAAS1B,OAAAA;GAAiB,OAAA,EAAA2B,SAAW,OAAO;GACzE,UAAA,oBAAC,YAAD;IAAoB,SAAA;IAAcxC,UAAAA;GAAvB,CAAA;EADE,CAAA,IADhBuC,KAAAA;EAIY1D,EAAA,MAAAgC;EAAAhC,EAAA,MAAAmB;EAAAnB,EAAA,MAAAyD;CAAA,OAAAA,MAAAzD,EAAA;CAAA,IAAA4D;CAAA,IAAA5D,EAAA,QAAAwB,gBAAAxB,EAAA,QAAAwD,OAAAxD,EAAA,QAAAyD,KAAA;EAjCfG,MAAA,qBAAA,OAAA;GAAkC,WAAA;GAAlC,UAAA,CACEJ,KA4BCC,GAKG;EAlCIjC,GAAAA,YAkCJ;EAAAxB,EAAA,MAAAwB;EAAAxB,EAAA,MAAAwD;EAAAxD,EAAA,MAAAyD;EAAAzD,EAAA,MAAA4D;CAAA,OAAAA,MAAA5D,EAAA;CAAA,OAlCN4D;AAkCM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeAction.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeAction.tsx"],"mappings":";;;;;;;;UAiBiB;;;;;;;;EAQf;;;;;EAKA;;;KAIU,sBAAsB,KAAK,gCAAgC,KAAK,0BAC1E;;EAEE;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"TreeAction.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeAction.tsx"],"mappings":";;;;;;;;UAiBiB;;;;;;;;EAQf;;;;;EAKA;;;KAIU,sBAAsB,KAAK,gCAAgC,KAAK,0BAC1E;;EAEE;;;;;;;;;;;;;;;;;;;;;cAuBS,gBAAgB,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeAction.js","names":["memo","ListItemIcon","MenuItem","Typography","Icon","Tree","ComponentPropsWithoutRef","NamedExoticComponent","TreeActionBaseAttributes","variant","hide","TreeActionBaseProps","Omit","ItemAction","onClick","TreeActionBase","t0","$","_c","actionProps","dot","t1","visible","undefined","t2","label","icon","t3","t4"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeAction.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 { memo } from \"react\";\nimport { ListItemIcon, MenuItem, Typography } from \"@mui/material\";\nimport { Icon } from \"@stratakit/mui\";\nimport { Tree } from \"@stratakit/structures\";\n\nimport type { ComponentPropsWithoutRef, NamedExoticComponent } from \"react\";\n\n/**\n * Attributes used to decide how to render tree actions. They allow to differentiate action style based on the context\n * where that action is used.\n * @alpha\n */\nexport interface TreeActionBaseAttributes {\n /**\n * Specifies action variant supported by tree nodes:\n *\n * - \"default\" - standard action displayed in the dropdown menu accessible through the ellipsis button on the node.\n * - \"inline\" - actions displayed directly on the tree node.\n * - \"context-menu\" - actions displayed in the context menu opened by right-clicking the tree node.\n */\n variant?: \"default\" | \"inline\" | \"context-menu\";\n /**\n * Indicates that the actions is not applicable for current tree node and should be hidden.\n * When set to true, the action will not be rendered at all.\n */\n hide?: boolean;\n}\n\n/** @alpha */\nexport type TreeActionBaseProps = Omit<ComponentPropsWithoutRef<typeof Tree.ItemAction>, \"onClick\"> &\n TreeActionBaseAttributes & {\n /** Callback invoked when the action is clicked. */\n onClick?: () => void;\n };\n\n/**\n * Base component used to render tree actions. It is designed to allow rendering same action in different contexts: inline, dropdown, context menu.\n * Should be used together with `StrataKitTreeNodeRenderer` and returned from `getInlineActions`, `getMenuActions` and `getContextMenuActions` callbacks.\n *\n * When implementing custom action that returns this component, make sure to forward `TreeActionBaseAttributes` props to it. Example:\n *\n * ```tsx\n * interface MyCustomTreeActionProps extends TreeActionBaseAttributes {\n * myProp: string\n * }\n *\n * function MyCustomTreeAction({ myProp, ...attributes }: MyCustomTreeActionProps) {\n * // custom button logic goes here\n * return <TreeActionBase {...attributes} icon={...} onClick={...} />\n * }\n * ```\n *\n * @alpha\n */\nexport const TreeActionBase: NamedExoticComponent<TreeActionBaseProps> = memo(function TreeActionBase({\n hide,\n variant = \"default\",\n dot,\n visible,\n ...actionProps\n}: TreeActionBaseProps) {\n if (hide) {\n return variant === \"inline\" ? <Tree.ItemAction {...actionProps} visible={false} /> : undefined;\n }\n\n if (variant === \"context-menu\") {\n const { label, icon, onClick } = actionProps;\n return (\n <MenuItem
|
|
1
|
+
{"version":3,"file":"TreeAction.js","names":["memo","ListItemIcon","MenuItem","Typography","Icon","Tree","ComponentPropsWithoutRef","NamedExoticComponent","TreeActionBaseAttributes","variant","hide","TreeActionBaseProps","Omit","ItemAction","onClick","TreeActionBase","t0","$","_c","actionProps","dot","t1","visible","undefined","t2","label","icon","t3","t4"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeAction.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 { memo } from \"react\";\nimport { ListItemIcon, MenuItem, Typography } from \"@mui/material\";\nimport { Icon } from \"@stratakit/mui\";\nimport { Tree } from \"@stratakit/structures\";\n\nimport type { ComponentPropsWithoutRef, NamedExoticComponent } from \"react\";\n\n/**\n * Attributes used to decide how to render tree actions. They allow to differentiate action style based on the context\n * where that action is used.\n * @alpha\n */\nexport interface TreeActionBaseAttributes {\n /**\n * Specifies action variant supported by tree nodes:\n *\n * - \"default\" - standard action displayed in the dropdown menu accessible through the ellipsis button on the node.\n * - \"inline\" - actions displayed directly on the tree node.\n * - \"context-menu\" - actions displayed in the context menu opened by right-clicking the tree node.\n */\n variant?: \"default\" | \"inline\" | \"context-menu\";\n /**\n * Indicates that the actions is not applicable for current tree node and should be hidden.\n * When set to true, the action will not be rendered at all.\n */\n hide?: boolean;\n}\n\n/** @alpha */\nexport type TreeActionBaseProps = Omit<ComponentPropsWithoutRef<typeof Tree.ItemAction>, \"onClick\"> &\n TreeActionBaseAttributes & {\n /** Callback invoked when the action is clicked. */\n onClick?: () => void;\n };\n\n/**\n * Base component used to render tree actions. It is designed to allow rendering same action in different contexts: inline, dropdown, context menu.\n * Should be used together with `StrataKitTreeNodeRenderer` and returned from `getInlineActions`, `getMenuActions` and `getContextMenuActions` callbacks.\n *\n * When implementing custom action that returns this component, make sure to forward `TreeActionBaseAttributes` props to it. Example:\n *\n * ```tsx\n * interface MyCustomTreeActionProps extends TreeActionBaseAttributes {\n * myProp: string\n * }\n *\n * function MyCustomTreeAction({ myProp, ...attributes }: MyCustomTreeActionProps) {\n * // custom button logic goes here\n * return <TreeActionBase {...attributes} icon={...} onClick={...} />\n * }\n * ```\n *\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-shadow\nexport const TreeActionBase: NamedExoticComponent<TreeActionBaseProps> = memo(function TreeActionBase({\n hide,\n variant = \"default\",\n dot,\n visible,\n ...actionProps\n}: TreeActionBaseProps) {\n if (hide) {\n return variant === \"inline\" ? <Tree.ItemAction {...actionProps} visible={false} /> : undefined;\n }\n\n if (variant === \"context-menu\") {\n const { label, icon, onClick } = actionProps;\n return (\n <MenuItem onClick={onClick}>\n {icon ? <ListItemIcon>{typeof icon === \"string\" ? <Icon href={icon} /> : icon}</ListItemIcon> : null}\n <Typography variant=\"caption\">{label}</Typography>\n </MenuItem>\n );\n }\n\n return <Tree.ItemAction {...actionProps} dot={dot} visible={variant === \"inline\" ? visible : undefined} />;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAae,iBAA4Df,KAAK,SAAAe,eAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAC;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EAAA;EAAA,IAAAW;EAAA,IAAAX,EAAA,QAAAH,WAAAG,EAAA,QAAAO,MAAAP,EAAA,QAAAU,IAAA;GAFpDC,KAAA,qBAAC,UAAD;IAAmBd;IAAnB,UAAA,CACGU,IACDG,EAFO;;GAGEV,EAAA,MAAAH;GAAAG,EAAA,MAAAO;GAAAP,EAAA,MAAAU;GAAAV,EAAA,MAAAW;EAAA,OAAAA,KAAAX,EAAA;EAAA,OAHXW;CAGW;CAI6C,MAAAJ,KAAAf,YAAY,WAAZa,UAAAC,KAAAA;CAA0C,IAAAI;CAAA,IAAAV,EAAA,QAAAE,eAAAF,EAAA,QAAAG,OAAAH,EAAA,QAAAO,IAAA;EAA/FG,KAAA,oBAAA,KAAA,YAAA;GAAA,GAAqBR;GAAkBC;GAAc,SAAAI;EAA0C,CAAA;EAAIP,EAAA,MAAAE;EAAAF,EAAA,MAAAG;EAAAH,EAAA,MAAAO;EAAAP,EAAA,MAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAAnGU;AAAmG,CAC3G"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useTranslation } from "../LocalizationContext.js";
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { createContext, useContext, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Menu } from "@mui/material";
|
|
6
|
+
//#region src/presentation-hierarchies-react/stratakit/TreeContextMenu.tsx
|
|
7
|
+
const TreeContextMenuContext = createContext({ openContextMenu: () => {} });
|
|
8
|
+
/** @internal */
|
|
9
|
+
function useTreeContextMenu() {
|
|
10
|
+
return useContext(TreeContextMenuContext);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Renders a single context menu shared by all tree items, avoiding the cost of mounting a `Menu` per row.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
function TreeContextMenuProvider(t0) {
|
|
18
|
+
const $ = c(16);
|
|
19
|
+
const { children } = t0;
|
|
20
|
+
const translate = useTranslation();
|
|
21
|
+
const [menuProps, setMenuProps] = useState(void 0);
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
24
|
+
t1 = { openContextMenu: setMenuProps };
|
|
25
|
+
$[0] = t1;
|
|
26
|
+
} else t1 = $[0];
|
|
27
|
+
const contextValue = t1;
|
|
28
|
+
const t2 = !!menuProps;
|
|
29
|
+
let t3;
|
|
30
|
+
let t4;
|
|
31
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
32
|
+
t3 = () => setMenuProps(void 0);
|
|
33
|
+
t4 = (e) => {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
setMenuProps(void 0);
|
|
36
|
+
};
|
|
37
|
+
$[1] = t3;
|
|
38
|
+
$[2] = t4;
|
|
39
|
+
} else {
|
|
40
|
+
t3 = $[1];
|
|
41
|
+
t4 = $[2];
|
|
42
|
+
}
|
|
43
|
+
let t5;
|
|
44
|
+
if ($[3] !== menuProps) {
|
|
45
|
+
t5 = menuProps ? {
|
|
46
|
+
top: menuProps.position.y,
|
|
47
|
+
left: menuProps.position.x
|
|
48
|
+
} : void 0;
|
|
49
|
+
$[3] = menuProps;
|
|
50
|
+
$[4] = t5;
|
|
51
|
+
} else t5 = $[4];
|
|
52
|
+
let t6;
|
|
53
|
+
if ($[5] !== translate) {
|
|
54
|
+
t6 = translate("more");
|
|
55
|
+
$[5] = translate;
|
|
56
|
+
$[6] = t6;
|
|
57
|
+
} else t6 = $[6];
|
|
58
|
+
let t7;
|
|
59
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
60
|
+
t7 = () => setMenuProps(void 0);
|
|
61
|
+
$[7] = t7;
|
|
62
|
+
} else t7 = $[7];
|
|
63
|
+
const t8 = menuProps?.actions;
|
|
64
|
+
let t9;
|
|
65
|
+
if ($[8] !== t2 || $[9] !== t5 || $[10] !== t6 || $[11] !== t8) {
|
|
66
|
+
t9 = /* @__PURE__ */ jsx(Menu, {
|
|
67
|
+
open: t2,
|
|
68
|
+
onClose: t3,
|
|
69
|
+
onContextMenu: t4,
|
|
70
|
+
anchorReference: "anchorPosition",
|
|
71
|
+
anchorPosition: t5,
|
|
72
|
+
"aria-label": t6,
|
|
73
|
+
onClick: t7,
|
|
74
|
+
children: t8
|
|
75
|
+
});
|
|
76
|
+
$[8] = t2;
|
|
77
|
+
$[9] = t5;
|
|
78
|
+
$[10] = t6;
|
|
79
|
+
$[11] = t8;
|
|
80
|
+
$[12] = t9;
|
|
81
|
+
} else t9 = $[12];
|
|
82
|
+
let t10;
|
|
83
|
+
if ($[13] !== children || $[14] !== t9) {
|
|
84
|
+
t10 = /* @__PURE__ */ jsxs(TreeContextMenuContext.Provider, {
|
|
85
|
+
value: contextValue,
|
|
86
|
+
children: [children, t9]
|
|
87
|
+
});
|
|
88
|
+
$[13] = children;
|
|
89
|
+
$[14] = t9;
|
|
90
|
+
$[15] = t10;
|
|
91
|
+
} else t10 = $[15];
|
|
92
|
+
return t10;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
export { TreeContextMenuProvider, useTreeContextMenu };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=TreeContextMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeContextMenu.js","names":["createContext","useContext","useMemo","useState","Menu","useTranslation","PropsWithChildren","ReactNode","TreeContextMenuContextValue","openContextMenu","props","position","x","y","actions","TreeContextMenuContext","useTreeContextMenu","TreeContextMenuProvider","t0","$","_c","children","translate","menuProps","setMenuProps","undefined","t1","Symbol","for","contextValue","t2","t3","t4","e","preventDefault","t5","top","left","t6","t7","t8","t9","t10"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeContextMenu.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 { createContext, useContext, useMemo, useState } from \"react\";\nimport { Menu } from \"@mui/material\";\nimport { useTranslation } from \"../LocalizationContext.js\";\n\nimport type { PropsWithChildren, ReactNode } from \"react\";\n\ninterface TreeContextMenuContextValue {\n openContextMenu: (props: { position: { x: number; y: number }; actions: ReactNode[] }) => void;\n}\n\nconst TreeContextMenuContext = createContext<TreeContextMenuContextValue>({ openContextMenu: () => {} });\n\n/** @internal */\nexport function useTreeContextMenu() {\n return useContext(TreeContextMenuContext);\n}\n\n/**\n * Renders a single context menu shared by all tree items, avoiding the cost of mounting a `Menu` per row.\n *\n * @internal\n */\nexport function TreeContextMenuProvider({ children }: PropsWithChildren) {\n const translate = useTranslation();\n const [menuProps, setMenuProps] = useState<{ position: { x: number; y: number }; actions: ReactNode[] } | undefined>(\n undefined,\n );\n const contextValue = useMemo<TreeContextMenuContextValue>(() => ({ openContextMenu: setMenuProps }), []);\n return (\n <TreeContextMenuContext.Provider value={contextValue}>\n {children}\n <Menu\n open={!!menuProps}\n onClose={() => setMenuProps(undefined)}\n onContextMenu={(e) => {\n e.preventDefault();\n setMenuProps(undefined);\n }}\n anchorReference=\"anchorPosition\"\n anchorPosition={menuProps ? { top: menuProps.position.y, left: menuProps.position.x } : undefined}\n aria-label={translate(\"more\")}\n onClick={() => setMenuProps(undefined)}\n >\n {menuProps?.actions}\n </Menu>\n </TreeContextMenuContext.Provider>\n );\n}\n"],"mappings":";;;;;;AAeA,MAAMe,yBAAyBf,cAA2C,EAAES,uBAAuB,CAAC,EAAE,CAAC;;AAGvG,SAAOO,qBAAA;CAAA,OACEf,WAAWc,sBAAsB;AAAC;;;;;;AAQ3C,SAAOE,wBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAiC,MAAA,EAAAC,aAAAH;CACtC,MAAAI,YAAkBjB,eAAe;CACjC,MAAA,CAAAkB,WAAAC,gBAAkCrB,SAChCsB,KAAAA,CACF;CAAE,I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ACA,gBAAAG;GACJ,cAAAG;GACH,SAAAC;GAERC,UAAAA;EAZE,CAAA;EAaErB,EAAA,KAAAW;EAAAX,EAAA,KAAAgB;EAAAhB,EAAA,MAAAmB;EAAAnB,EAAA,MAAAqB;EAAArB,EAAA,MAAAsB;CAAA,OAAAA,KAAAtB,EAAA;CAAA,IAAAuB;CAAA,IAAAvB,EAAA,QAAAE,YAAAF,EAAA,QAAAsB,IAAA;EAfTC,MAAA,qBAAA,uBAAA,UAAA;GAAwCb,OAAAA;GAAxC,UAAA,CACGR,UACDoB,EAcF;;EAAkCtB,EAAA,MAAAE;EAAAF,EAAA,MAAAsB;EAAAtB,EAAA,MAAAuB;CAAA,OAAAA,MAAAvB,EAAA;CAAA,OAhBlCuB;AAgBkC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeFilterAction.js","names":["memo","useCallback","useTranslation","TreeActionBase","filterSvg","NamedExoticComponent","HierarchyLevelDetails","TreeRendererProps","TreeNode","TreeActionBaseAttributes","TreeNodeFilterActionProps","onFilter","hierarchyLevelDetails","Pick","TreeNodeFilterAction","node","t0","$","_c","actionAttributes","getHierarchyLevelDetails","translate","t1","filterHierarchyLevel","t2","filterHierarchyLevelActiveDescription","t3","id","handleClick","t4","isFiltered","undefined","t5","t6","isFilterable","t7"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.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 { memo, useCallback } from \"react\";\nimport { useTranslation } from \"../LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\n\nimport filterSvg from \"@stratakit/icons/filter.svg\";\n\nimport type { NamedExoticComponent } from \"react\";\nimport type { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/** @alpha */\ntype TreeNodeFilterActionProps = {\n /**\n * Action to perform when the filter button is clicked for this node.\n */\n onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n} & TreeActionBaseAttributes &\n Pick<TreeRendererProps, \"getHierarchyLevelDetails\">;\n\n/**\n * React component that renders a filter action for a tree item.\n *\n * The action calls the `onFilter` callback prop when clicked.\n *\n * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action\n * to tree items.\n *\n * @alpha\n */\nexport const TreeNodeFilterAction: NamedExoticComponent<TreeNodeFilterActionProps & { node: TreeNode }> = memo(\n function TreeNodeFilterAction({\n node,\n onFilter,\n getHierarchyLevelDetails,\n ...actionAttributes\n }: TreeNodeFilterActionProps & { node: TreeNode }) {\n const translate = useTranslation();\n const filterHierarchyLevel = translate(\"filterHierarchyLevel\");\n const filterHierarchyLevelActiveDescription = translate(\"filterHierarchyLevelActiveDescription\");\n\n const handleClick = useCallback(() => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(node.id);\n hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);\n }, [node, getHierarchyLevelDetails, onFilter]);\n\n return (\n <TreeActionBase\n {...actionAttributes}\n label={filterHierarchyLevel}\n onClick={handleClick}\n icon={filterSvg}\n visible={node.isFiltered ? true : undefined}\n dot={node.isFiltered ? filterHierarchyLevelActiveDescription : undefined}\n hide={!onFilter || !node.isFilterable}\n />\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,MAAac,uBAA6Fd,
|
|
1
|
+
{"version":3,"file":"TreeNodeFilterAction.js","names":["memo","useCallback","useTranslation","TreeActionBase","filterSvg","NamedExoticComponent","HierarchyLevelDetails","TreeRendererProps","TreeNode","TreeActionBaseAttributes","TreeNodeFilterActionProps","onFilter","hierarchyLevelDetails","Pick","TreeNodeFilterAction","node","t0","$","_c","actionAttributes","getHierarchyLevelDetails","translate","t1","filterHierarchyLevel","t2","filterHierarchyLevelActiveDescription","t3","id","handleClick","t4","isFiltered","undefined","t5","t6","isFilterable","t7"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.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 { memo, useCallback } from \"react\";\nimport { useTranslation } from \"../LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\n\nimport filterSvg from \"@stratakit/icons/filter.svg\";\n\nimport type { NamedExoticComponent } from \"react\";\nimport type { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/** @alpha */\ntype TreeNodeFilterActionProps = {\n /**\n * Action to perform when the filter button is clicked for this node.\n */\n onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n} & TreeActionBaseAttributes &\n Pick<TreeRendererProps, \"getHierarchyLevelDetails\">;\n\n/**\n * React component that renders a filter action for a tree item.\n *\n * The action calls the `onFilter` callback prop when clicked.\n *\n * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action\n * to tree items.\n *\n * @alpha\n */\nexport const TreeNodeFilterAction: NamedExoticComponent<TreeNodeFilterActionProps & { node: TreeNode }> = memo(\n // eslint-disable-next-line @typescript-eslint/no-shadow\n function TreeNodeFilterAction({\n node,\n onFilter,\n getHierarchyLevelDetails,\n ...actionAttributes\n }: TreeNodeFilterActionProps & { node: TreeNode }) {\n const translate = useTranslation();\n const filterHierarchyLevel = translate(\"filterHierarchyLevel\");\n const filterHierarchyLevelActiveDescription = translate(\"filterHierarchyLevelActiveDescription\");\n\n const handleClick = useCallback(() => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(node.id);\n hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);\n }, [node, getHierarchyLevelDetails, onFilter]);\n\n return (\n <TreeActionBase\n {...actionAttributes}\n label={filterHierarchyLevel}\n onClick={handleClick}\n icon={filterSvg}\n visible={node.isFiltered ? true : undefined}\n dot={node.isFiltered ? filterHierarchyLevelActiveDescription : undefined}\n hide={!onFilter || !node.isFilterable}\n />\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,MAAac,uBAA6Fd,KAExG,SAAAc,qBAAAE,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAL;CAAA,IAAAJ;CAAA,IAAAM,EAAA,OAAAD,IAAA;EAA8B,CAAA,CAAAD,MAAAJ,UAAAS,0BAAA,GAAAD,oBAAAH;EAKmBC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAF;EAAAE,EAAA,KAAAN;CAAA,OAAA;EAAAQ,mBAAAF,EAAA;EAAAG,2BAAAH,EAAA;EAAAF,OAAAE,EAAA;EAAAN,WAAAM,EAAA;CAAA;CAC/C,MAAAI,YAAkBnB,eAAe;CAAE,IAAAoB;CAAA,IAAAL,EAAA,OAAAI,WAAA;EACNC,KAAAD,UAAU,sBAAsB;EAACJ,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAA9D,MAAAM,uBAA6BD;CAAkC,IAAAE;CAAA,IAAAP,EAAA,OAAAI,WAAA;EACjBG,KAAAH,UAAU,uCAAuC;EAACJ,EAAA,KAAAI;EAAAJ,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAhG,MAAAQ,wCAA8CD;CAAmD,IAAAE;CAAA,IAAAT,EAAA,OAAAG,4BAAAH,EAAA,QAAAF,KAAAY,MAAAV,EAAA,QAAAN,UAAA;EAEjEe,WAAA;GAC9B,MAAAd,wBAA8BQ,yBAAyBL,KAAIY,EAAG;GAC9Df,yBAAyBD,WAAWC,qBAAqB;EAAC;EAC3DK,EAAA,KAAAG;EAAAH,EAAA,MAAAF,KAAAY;EAAAV,EAAA,MAAAN;EAAAM,EAAA,MAAAS;CAAA,OAAAA,KAAAT,EAAA;CAHD,MAAAW,cAAoBF;CAWP,MAAAG,KAAAd,KAAIe,aAAJ,OAAAC,KAAAA;CACJ,MAAAC,KAAAjB,KAAIe,aAAJL,wCAAAM,KAAAA;CACC,MAAAE,KAAA,CAACtB,YAAD,CAAcI,KAAImB;CAAa,IAAAC;CAAA,IAAAlB,EAAA,QAAAE,oBAAAF,EAAA,QAAAM,wBAAAN,EAAA,QAAAW,eAAAX,EAAA,QAAAY,MAAAZ,EAAA,QAAAe,MAAAf,EAAA,QAAAgB,IAAA;EAPvCE,KAAA,oBAAC,gBAAD;GAAe,GACThB;GACGI,OAAAA;GACEK,SAAAA;GACHxB,MAAAA;GACG,SAAAyB;GACJ,KAAAG;GACC,MAAAC;EAA+B,CAAA;EACrChB,EAAA,MAAAE;EAAAF,EAAA,MAAAM;EAAAN,EAAA,MAAAW;EAAAX,EAAA,MAAAY;EAAAZ,EAAA,MAAAe;EAAAf,EAAA,MAAAgB;EAAAhB,EAAA,MAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAAA,OARFkB;AAQE,CAGR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenameAction.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.tsx"],"mappings":";;;;;;;;;;;;;;;cA0Ba,sBAAsB,qBAAqB;EAA6B,MAAM;;;
|
|
1
|
+
{"version":3,"file":"TreeNodeRenameAction.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.tsx"],"mappings":";;;;;;;;;;;;;;;cA0Ba,sBAAsB,qBAAqB;EAA6B,MAAM;;;UAoB1E;;;;;EAKf,iBAAiB;EACjB;EACA,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenameAction.js","names":["createContext","memo","useCallback","useContext","useMemo","useState","useTranslation","TreeActionBase","renameSvg","NamedExoticComponent","PropsWithChildren","TreeNode","TreeActionBaseAttributes","TreeNodeRenameAction","node","t0","$","_c","actionAttributes","translate","context","useTreeNodeRenameContext","t1","rename","t2","canRename","startRename","t3","handleClick","t4","t5","TreeNodeEditingProps","onLabelChanged","newLabel","labelValidationHint","validate","RenameParameters","nodeId","commit","TreeNodeRenameContext","renameParameters","cancelRename","treeNodeRenameContext","undefined","TreeNodeRenameContextProvider","value","children","useTreeNodeRenameContextValue","getEditingProps","setRenameParameters","id","Symbol","for","node_0"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.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 { createContext, memo, useCallback, useContext, useMemo, useState } from \"react\";\nimport { useTranslation } from \"../LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\n\nimport renameSvg from \"@stratakit/icons/rename.svg\";\n\nimport type { NamedExoticComponent, PropsWithChildren } from \"react\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/**\n * React component that renders a rename action for a tree item.\n *\n * The tree component must have `getEditingProps.onLabelChanged` prop set to enable renaming functionality. When\n * rename is completed, the `onLabelChanged` function is called to make the actual data update.\n *\n * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action\n * to tree items.\n *\n * @alpha\n */\nexport const TreeNodeRenameAction: NamedExoticComponent<TreeActionBaseAttributes & { node: TreeNode }> = memo(\n function TreeNodeRenameAction({ node, ...actionAttributes }: TreeActionBaseAttributes & { node: TreeNode }) {\n const translate = useTranslation();\n const context = useTreeNodeRenameContext();\n const rename = translate(\"rename\");\n\n const canRename = context?.canRename(node) ?? false;\n const startRename = context?.startRename;\n const handleClick = useCallback(() => {\n startRename?.(node);\n }, [startRename, node]);\n\n return (\n <TreeActionBase {...actionAttributes} label={rename} onClick={handleClick} icon={renameSvg} hide={!canRename} />\n );\n },\n);\n\n/** @alpha */\nexport interface TreeNodeEditingProps {\n /**\n * A callback that is invoked when node label is changed. Should be used together\n * with `<TreeNodeRenameAction />` to enter label editing mode.\n */\n onLabelChanged: (newLabel: string) => void;\n labelValidationHint?: string;\n validate?: (newLabel: string) => boolean;\n}\n\n/** @internal */\nexport interface RenameParameters {\n nodeId: string;\n commit: (newLabel: string) => void;\n labelValidationHint?: string;\n validate?: (newLabel: string) => boolean;\n}\n\ninterface TreeNodeRenameContext {\n renameParameters?: RenameParameters;\n startRename: (node: TreeNode) => void;\n canRename: (node: TreeNode) => boolean;\n cancelRename: () => void;\n}\n\nconst treeNodeRenameContext = createContext<TreeNodeRenameContext | undefined>(undefined);\n\n/** @internal */\nexport const useTreeNodeRenameContext = () => {\n return useContext(treeNodeRenameContext);\n};\n\n/** @internal */\nexport function TreeNodeRenameContextProvider({\n value,\n children,\n}: PropsWithChildren<{ value: TreeNodeRenameContext }>) {\n return <treeNodeRenameContext.Provider value={value}>{children}</treeNodeRenameContext.Provider>;\n}\n\n/** @internal */\nexport function useTreeNodeRenameContextValue({\n getEditingProps,\n}: {\n getEditingProps?: (node: TreeNode) => TreeNodeEditingProps | undefined;\n}) {\n const [renameParameters, setRenameParameters] = useState<RenameParameters | undefined>(undefined);\n\n const startRename = useCallback(\n (node: TreeNode) => {\n const { onLabelChanged, labelValidationHint, validate } = getEditingProps?.(node) ?? {};\n if (onLabelChanged) {\n setRenameParameters({\n nodeId: node.id,\n commit: (newLabel) => {\n onLabelChanged(newLabel);\n setRenameParameters(undefined);\n },\n labelValidationHint,\n validate,\n });\n }\n },\n [getEditingProps],\n );\n\n const cancelRename = useCallback(() => {\n setRenameParameters(undefined);\n }, []);\n\n const canRename = useCallback(\n (node: TreeNode) => {\n return getEditingProps?.(node)?.onLabelChanged !== undefined;\n },\n [getEditingProps],\n );\n\n return useMemo(\n () => ({ renameParameters, cancelRename, startRename, canRename }),\n [renameParameters, canRename, startRename, cancelRename],\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,MAAaa,uBAA4FZ,
|
|
1
|
+
{"version":3,"file":"TreeNodeRenameAction.js","names":["createContext","memo","useCallback","useContext","useMemo","useState","useTranslation","TreeActionBase","renameSvg","NamedExoticComponent","PropsWithChildren","TreeNode","TreeActionBaseAttributes","TreeNodeRenameAction","node","t0","$","_c","actionAttributes","translate","context","useTreeNodeRenameContext","t1","rename","t2","canRename","startRename","t3","handleClick","t4","t5","TreeNodeEditingProps","onLabelChanged","newLabel","labelValidationHint","validate","RenameParameters","nodeId","commit","TreeNodeRenameContext","renameParameters","cancelRename","treeNodeRenameContext","undefined","TreeNodeRenameContextProvider","value","children","useTreeNodeRenameContextValue","getEditingProps","setRenameParameters","id","Symbol","for","node_0"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.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 { createContext, memo, useCallback, useContext, useMemo, useState } from \"react\";\nimport { useTranslation } from \"../LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\n\nimport renameSvg from \"@stratakit/icons/rename.svg\";\n\nimport type { NamedExoticComponent, PropsWithChildren } from \"react\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/**\n * React component that renders a rename action for a tree item.\n *\n * The tree component must have `getEditingProps.onLabelChanged` prop set to enable renaming functionality. When\n * rename is completed, the `onLabelChanged` function is called to make the actual data update.\n *\n * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action\n * to tree items.\n *\n * @alpha\n */\nexport const TreeNodeRenameAction: NamedExoticComponent<TreeActionBaseAttributes & { node: TreeNode }> = memo(\n // eslint-disable-next-line @typescript-eslint/no-shadow\n function TreeNodeRenameAction({ node, ...actionAttributes }: TreeActionBaseAttributes & { node: TreeNode }) {\n const translate = useTranslation();\n const context = useTreeNodeRenameContext();\n const rename = translate(\"rename\");\n\n const canRename = context?.canRename(node) ?? false;\n const startRename = context?.startRename;\n const handleClick = useCallback(() => {\n startRename?.(node);\n }, [startRename, node]);\n\n return (\n <TreeActionBase {...actionAttributes} label={rename} onClick={handleClick} icon={renameSvg} hide={!canRename} />\n );\n },\n);\n\n/** @alpha */\nexport interface TreeNodeEditingProps {\n /**\n * A callback that is invoked when node label is changed. Should be used together\n * with `<TreeNodeRenameAction />` to enter label editing mode.\n */\n onLabelChanged: (newLabel: string) => void;\n labelValidationHint?: string;\n validate?: (newLabel: string) => boolean;\n}\n\n/** @internal */\nexport interface RenameParameters {\n nodeId: string;\n commit: (newLabel: string) => void;\n labelValidationHint?: string;\n validate?: (newLabel: string) => boolean;\n}\n\ninterface TreeNodeRenameContext {\n renameParameters?: RenameParameters;\n startRename: (node: TreeNode) => void;\n canRename: (node: TreeNode) => boolean;\n cancelRename: () => void;\n}\n\nconst treeNodeRenameContext = createContext<TreeNodeRenameContext | undefined>(undefined);\n\n/** @internal */\nexport const useTreeNodeRenameContext = () => {\n return useContext(treeNodeRenameContext);\n};\n\n/** @internal */\nexport function TreeNodeRenameContextProvider({\n value,\n children,\n}: PropsWithChildren<{ value: TreeNodeRenameContext }>) {\n return <treeNodeRenameContext.Provider value={value}>{children}</treeNodeRenameContext.Provider>;\n}\n\n/** @internal */\nexport function useTreeNodeRenameContextValue({\n getEditingProps,\n}: {\n getEditingProps?: (node: TreeNode) => TreeNodeEditingProps | undefined;\n}) {\n const [renameParameters, setRenameParameters] = useState<RenameParameters | undefined>(undefined);\n\n const startRename = useCallback(\n (node: TreeNode) => {\n const { onLabelChanged, labelValidationHint, validate } = getEditingProps?.(node) ?? {};\n if (onLabelChanged) {\n setRenameParameters({\n nodeId: node.id,\n commit: (newLabel) => {\n onLabelChanged(newLabel);\n setRenameParameters(undefined);\n },\n labelValidationHint,\n validate,\n });\n }\n },\n [getEditingProps],\n );\n\n const cancelRename = useCallback(() => {\n setRenameParameters(undefined);\n }, []);\n\n const canRename = useCallback(\n (node: TreeNode) => {\n return getEditingProps?.(node)?.onLabelChanged !== undefined;\n },\n [getEditingProps],\n );\n\n return useMemo(\n () => ({ renameParameters, cancelRename, startRename, canRename }),\n [renameParameters, canRename, startRename, cancelRename],\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,MAAaa,uBAA4FZ,KAEvG,SAAAY,qBAAAE,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAJ;CAAA,IAAAE,EAAA,OAAAD,IAAA;EAA8B,CAAA,CAAAD,MAAA,GAAAI,oBAAAH;EAA4EC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAF;CAAA,OAAA;EAAAI,mBAAAF,EAAA;EAAAF,OAAAE,EAAA;CAAA;CACxG,MAAAG,YAAkBb,eAAe;CACjC,MAAAc,UAAgBC,yBAAyB;CAAE,IAAAC;CAAA,IAAAN,EAAA,OAAAG,WAAA;EAC5BG,KAAAH,UAAU,QAAQ;EAACH,EAAA,KAAAG;EAAAH,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAlC,MAAAO,SAAeD;CAAoB,IAAAE;CAAA,IAAAR,EAAA,OAAAI,WAAAJ,EAAA,OAAAF,MAAA;EAEjBU,KAAAJ,SAAOK,UAAYX,IAAa,KAAhC;EAAiCE,EAAA,KAAAI;EAAAJ,EAAA,KAAAF;EAAAE,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAnD,MAAAS,YAAkBD;CAClB,MAAAE,cAAoBN,SAAOM;CAAc,IAAA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4
|
import { Tree } from "@stratakit/structures";
|
|
5
|
-
import "./TreeNodeRenderer.css";
|
|
6
5
|
//#region src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts
|
|
7
6
|
/** @alpha */
|
|
8
7
|
type StrataKitTreeItemProps = Omit<ComponentPropsWithoutRef<typeof Tree.Item>, "actions" | "inlineActions" | "expanded" | "onExpandedChange" | "icon" | "unstable_decorations" | "error"> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TreeNodeRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.tsx"],"mappings":";;;;;;KA0CY,yBAAyB,KACnC,gCAAgC,KAAK;;;;;EAOrC,cAAc"}
|