@stratakit/structures 0.4.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/dist/AccordionItem.d.ts +1 -1
- package/dist/AccordionItem.js +67 -124
- package/dist/Banner.js +146 -117
- package/dist/Chip.js +83 -58
- package/dist/DEV/Banner.js +7 -4
- package/dist/DEV/ErrorRegion.js +5 -4
- package/dist/DEV/NavigationRail.js +52 -20
- package/dist/DEV/Tabs.js +1 -1
- package/dist/DEV/styles.css.js +1 -1
- package/dist/Dialog.js +140 -132
- package/dist/DropdownMenu.js +206 -239
- package/dist/ErrorRegion.d.ts +31 -13
- package/dist/ErrorRegion.js +127 -153
- package/dist/NavigationRail.d.ts +36 -3
- package/dist/NavigationRail.js +215 -169
- package/dist/Table.js +116 -108
- package/dist/Tabs.d.ts +2 -0
- package/dist/Tabs.js +97 -62
- package/dist/Toolbar.js +23 -43
- package/dist/Tree.js +13 -12
- package/dist/TreeItem.js +394 -315
- package/dist/styles.css.js +1 -1
- package/dist/~utils.ListItem.js +21 -34
- package/dist/~utils.icons.js +26 -46
- package/package.json +13 -18
package/dist/TreeItem.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
+
import { c as _c } from "react-compiler-runtime";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
import { CompositeItem } from "@ariakit/react/composite";
|
|
4
5
|
import { Role } from "@ariakit/react/role";
|
|
5
6
|
import { Toolbar, ToolbarItem } from "@ariakit/react/toolbar";
|
|
6
7
|
import { IconButton } from "@stratakit/bricks";
|
|
7
|
-
import {
|
|
8
|
-
GhostAligner,
|
|
9
|
-
IconButtonPresentation
|
|
10
|
-
} from "@stratakit/bricks/secret-internals";
|
|
8
|
+
import { GhostAligner, IconButtonPresentation } from "@stratakit/bricks/secret-internals";
|
|
11
9
|
import { Icon } from "@stratakit/foundations";
|
|
12
|
-
import {
|
|
13
|
-
forwardRef,
|
|
14
|
-
useEventHandlers
|
|
15
|
-
} from "@stratakit/foundations/secret-internals";
|
|
10
|
+
import { forwardRef, useEventHandlers } from "@stratakit/foundations/secret-internals";
|
|
16
11
|
import cx from "classnames";
|
|
17
12
|
import { ChevronDown, MoreHorizontal, StatusIcon } from "./~utils.icons.js";
|
|
18
13
|
import * as ListItem from "./~utils.ListItem.js";
|
|
@@ -22,79 +17,66 @@ const TreeItemInlineActionsContext = React.createContext(void 0);
|
|
|
22
17
|
const TreeItemActionsContext = React.createContext(void 0);
|
|
23
18
|
const TreeItemDecorationsContext = React.createContext(void 0);
|
|
24
19
|
const TreeItemIconContext = React.createContext(void 0);
|
|
25
|
-
const TreeItemDecorationIdContext = React.createContext(
|
|
26
|
-
void 0
|
|
27
|
-
);
|
|
20
|
+
const TreeItemDecorationIdContext = React.createContext(void 0);
|
|
28
21
|
const TreeItemLabelContext = React.createContext(void 0);
|
|
29
|
-
const TreeItemLabelIdContext = React.createContext(
|
|
30
|
-
void 0
|
|
31
|
-
);
|
|
22
|
+
const TreeItemLabelIdContext = React.createContext(void 0);
|
|
32
23
|
const TreeItemDescriptionContext = React.createContext(void 0);
|
|
33
|
-
const TreeItemDescriptionIdContext = React.createContext(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
const TreeItemDescriptionIdContext = React.createContext(void 0);
|
|
25
|
+
const TreeItem = React.memo(forwardRef((props, forwardedRef) => {
|
|
26
|
+
const {
|
|
27
|
+
selected,
|
|
28
|
+
onSelectedChange,
|
|
29
|
+
expanded,
|
|
30
|
+
onExpandedChange,
|
|
31
|
+
icon: _icon,
|
|
32
|
+
unstable_decorations: _unstable_decorations,
|
|
33
|
+
label: _label,
|
|
34
|
+
description: _description,
|
|
35
|
+
inlineActions: _inlineActions,
|
|
36
|
+
actions: _actions,
|
|
37
|
+
error: _error,
|
|
38
|
+
onClick: onClickProp,
|
|
39
|
+
onKeyDown: onKeyDownProp,
|
|
40
|
+
...rest
|
|
41
|
+
} = props;
|
|
42
|
+
const onExpanderClick = useEventHandlers(() => {
|
|
43
|
+
if (expanded === void 0) return;
|
|
44
|
+
onExpandedChange?.(!expanded);
|
|
45
|
+
});
|
|
46
|
+
const handleClick = (event) => {
|
|
47
|
+
if (selected === void 0) return;
|
|
48
|
+
event.stopPropagation();
|
|
49
|
+
onSelectedChange?.(!selected);
|
|
50
|
+
};
|
|
51
|
+
const handleKeyDown = (event_0) => {
|
|
52
|
+
if (event_0.altKey || event_0.ctrlKey || event_0.metaKey || event_0.shiftKey) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (expanded === void 0) return;
|
|
56
|
+
if (event_0.key === "ArrowRight" || event_0.key === "ArrowLeft") {
|
|
57
|
+
event_0.preventDefault();
|
|
58
|
+
onExpandedChange?.(event_0.key === "ArrowRight");
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return /* @__PURE__ */ jsx(TreeItemRootProvider, {
|
|
62
|
+
...props,
|
|
63
|
+
children: /* @__PURE__ */ jsx(TreeItemRoot, {
|
|
64
|
+
...rest,
|
|
41
65
|
expanded,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
actions: _actions,
|
|
49
|
-
error: _error,
|
|
50
|
-
onClick: onClickProp,
|
|
51
|
-
onKeyDown: onKeyDownProp,
|
|
52
|
-
...rest
|
|
53
|
-
} = props;
|
|
54
|
-
const onExpanderClick = useEventHandlers(() => {
|
|
55
|
-
if (expanded === void 0) return;
|
|
56
|
-
onExpandedChange?.(!expanded);
|
|
57
|
-
});
|
|
58
|
-
const handleClick = (event) => {
|
|
59
|
-
if (selected === void 0) return;
|
|
60
|
-
event.stopPropagation();
|
|
61
|
-
onSelectedChange?.(!selected);
|
|
62
|
-
};
|
|
63
|
-
const handleKeyDown = (event) => {
|
|
64
|
-
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (expanded === void 0) return;
|
|
68
|
-
if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
|
|
69
|
-
event.preventDefault();
|
|
70
|
-
onExpandedChange?.(event.key === "ArrowRight");
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
return /* @__PURE__ */ jsx(TreeItemRootProvider, { ...props, children: /* @__PURE__ */ jsx(
|
|
74
|
-
TreeItemRoot,
|
|
75
|
-
{
|
|
76
|
-
...rest,
|
|
66
|
+
selected,
|
|
67
|
+
onClick: useEventHandlers(onClickProp, handleClick),
|
|
68
|
+
onKeyDown: useEventHandlers(onKeyDownProp, handleKeyDown),
|
|
69
|
+
ref: forwardedRef,
|
|
70
|
+
children: React.useMemo(() => /* @__PURE__ */ jsx(TreeItemNode, {
|
|
71
|
+
onExpanderClick,
|
|
77
72
|
expanded,
|
|
78
|
-
selected
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
() => /* @__PURE__ */ jsx(
|
|
84
|
-
TreeItemNode,
|
|
85
|
-
{
|
|
86
|
-
onExpanderClick,
|
|
87
|
-
expanded,
|
|
88
|
-
selected
|
|
89
|
-
}
|
|
90
|
-
),
|
|
91
|
-
[onExpanderClick, expanded, selected]
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
) });
|
|
95
|
-
})
|
|
96
|
-
);
|
|
73
|
+
selected
|
|
74
|
+
}), [onExpanderClick, expanded, selected])
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
}));
|
|
97
78
|
function TreeItemRootProvider(props) {
|
|
79
|
+
const $ = _c(12);
|
|
98
80
|
const {
|
|
99
81
|
inlineActions,
|
|
100
82
|
actions,
|
|
@@ -107,296 +89,393 @@ function TreeItemRootProvider(props) {
|
|
|
107
89
|
const labelId = React.useId();
|
|
108
90
|
const descriptionId = React.useId();
|
|
109
91
|
const decorationId = React.useId();
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
92
|
+
let t0;
|
|
93
|
+
if ($[0] !== actions || $[1] !== decorationId || $[2] !== decorations || $[3] !== description || $[4] !== descriptionId || $[5] !== error || $[6] !== iconProp || $[7] !== inlineActions || $[8] !== label || $[9] !== labelId || $[10] !== props.children) {
|
|
94
|
+
const icon = error ? jsx(StatusIcon, {
|
|
95
|
+
tone: "attention"
|
|
96
|
+
}) : iconProp;
|
|
97
|
+
const hasDecoration = icon || decorations;
|
|
98
|
+
t0 = jsx(TreeItemErrorContext.Provider, {
|
|
99
|
+
value: error,
|
|
100
|
+
children: jsx(TreeItemInlineActionsContext.Provider, {
|
|
101
|
+
value: inlineActions,
|
|
102
|
+
children: jsx(TreeItemActionsContext.Provider, {
|
|
103
|
+
value: actions,
|
|
104
|
+
children: jsx(TreeItemDisplayActionsMenuContext.Provider, {
|
|
105
|
+
value: actions ? actions.length > 0 : false,
|
|
106
|
+
children: jsx(TreeItemDecorationIdContext.Provider, {
|
|
107
|
+
value: hasDecoration ? decorationId : void 0,
|
|
108
|
+
children: jsx(TreeItemDecorationsContext.Provider, {
|
|
109
|
+
value: decorations,
|
|
110
|
+
children: jsx(TreeItemIconContext.Provider, {
|
|
111
|
+
value: icon,
|
|
112
|
+
children: jsx(TreeItemLabelIdContext.Provider, {
|
|
113
|
+
value: labelId,
|
|
114
|
+
children: jsx(TreeItemLabelContext.Provider, {
|
|
115
|
+
value: label,
|
|
116
|
+
children: jsx(TreeItemDescriptionContext.Provider, {
|
|
117
|
+
value: description,
|
|
118
|
+
children: jsx(TreeItemDescriptionIdContext.Provider, {
|
|
119
|
+
value: description ? descriptionId : void 0,
|
|
120
|
+
children: props.children
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
});
|
|
132
|
+
$[0] = actions;
|
|
133
|
+
$[1] = decorationId;
|
|
134
|
+
$[2] = decorations;
|
|
135
|
+
$[3] = description;
|
|
136
|
+
$[4] = descriptionId;
|
|
137
|
+
$[5] = error;
|
|
138
|
+
$[6] = iconProp;
|
|
139
|
+
$[7] = inlineActions;
|
|
140
|
+
$[8] = label;
|
|
141
|
+
$[9] = labelId;
|
|
142
|
+
$[10] = props.children;
|
|
143
|
+
$[11] = t0;
|
|
144
|
+
} else {
|
|
145
|
+
t0 = $[11];
|
|
146
|
+
}
|
|
147
|
+
return t0;
|
|
131
148
|
}
|
|
132
|
-
const TreeItemRoot = React.memo(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
149
|
+
const TreeItemRoot = React.memo(forwardRef((props, forwardedRef) => {
|
|
150
|
+
const {
|
|
151
|
+
style: styleProp,
|
|
152
|
+
"aria-level": level,
|
|
153
|
+
selected,
|
|
154
|
+
expanded,
|
|
155
|
+
...rest
|
|
156
|
+
} = props;
|
|
157
|
+
const labelId = React.useContext(TreeItemLabelIdContext);
|
|
158
|
+
const decorationId = React.useContext(TreeItemDecorationIdContext);
|
|
159
|
+
const descriptionId = React.useContext(TreeItemDescriptionIdContext);
|
|
160
|
+
const error = React.useContext(TreeItemErrorContext);
|
|
161
|
+
const errorId = typeof error === "string" ? error : void 0;
|
|
162
|
+
const describedBy = React.useMemo(() => {
|
|
163
|
+
const ids = [];
|
|
164
|
+
if (descriptionId) ids.push(descriptionId);
|
|
165
|
+
if (decorationId) ids.push(decorationId);
|
|
166
|
+
if (errorId) ids.push(errorId);
|
|
167
|
+
return ids.length > 0 ? ids.join(" ") : void 0;
|
|
168
|
+
}, [decorationId, descriptionId, errorId]);
|
|
169
|
+
const style = React.useMemo(() => ({
|
|
170
|
+
...styleProp,
|
|
171
|
+
"--\u{1F95D}TreeItem-level": level
|
|
172
|
+
}), [styleProp, level]);
|
|
173
|
+
return /* @__PURE__ */ jsx(CompositeItem, {
|
|
174
|
+
render: /* @__PURE__ */ jsx(Role, {
|
|
175
|
+
...rest,
|
|
176
|
+
role: "treeitem",
|
|
177
|
+
"aria-expanded": expanded,
|
|
178
|
+
"aria-selected": selected,
|
|
179
|
+
"aria-labelledby": labelId,
|
|
180
|
+
"aria-describedby": describedBy,
|
|
136
181
|
"aria-level": level,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const error = React.useContext(TreeItemErrorContext);
|
|
145
|
-
const errorId = typeof error === "string" ? error : void 0;
|
|
146
|
-
const describedBy = React.useMemo(() => {
|
|
147
|
-
const ids = [];
|
|
148
|
-
if (descriptionId) ids.push(descriptionId);
|
|
149
|
-
if (decorationId) ids.push(decorationId);
|
|
150
|
-
if (errorId) ids.push(errorId);
|
|
151
|
-
return ids.length > 0 ? ids.join(" ") : void 0;
|
|
152
|
-
}, [decorationId, descriptionId, errorId]);
|
|
153
|
-
const style = React.useMemo(
|
|
154
|
-
() => ({
|
|
155
|
-
...styleProp,
|
|
156
|
-
"--\u{1F95D}TreeItem-level": level
|
|
157
|
-
}),
|
|
158
|
-
[styleProp, level]
|
|
159
|
-
);
|
|
160
|
-
return /* @__PURE__ */ jsx(
|
|
161
|
-
CompositeItem,
|
|
162
|
-
{
|
|
163
|
-
render: /* @__PURE__ */ jsx(
|
|
164
|
-
Role,
|
|
165
|
-
{
|
|
166
|
-
...rest,
|
|
167
|
-
role: "treeitem",
|
|
168
|
-
"aria-expanded": expanded,
|
|
169
|
-
"aria-selected": selected,
|
|
170
|
-
"aria-labelledby": labelId,
|
|
171
|
-
"aria-describedby": describedBy,
|
|
172
|
-
"aria-level": level,
|
|
173
|
-
className: cx("\u{1F95D}TreeItem", props.className),
|
|
174
|
-
style,
|
|
175
|
-
ref: forwardedRef
|
|
176
|
-
}
|
|
177
|
-
),
|
|
178
|
-
children: props.children
|
|
179
|
-
}
|
|
180
|
-
);
|
|
181
|
-
})
|
|
182
|
-
);
|
|
182
|
+
className: cx("\u{1F95D}TreeItem", props.className),
|
|
183
|
+
style,
|
|
184
|
+
ref: forwardedRef
|
|
185
|
+
}),
|
|
186
|
+
children: props.children
|
|
187
|
+
});
|
|
188
|
+
}));
|
|
183
189
|
function useRenderActions() {
|
|
190
|
+
const $ = _c(5);
|
|
184
191
|
const ref = React.useRef(null);
|
|
185
192
|
const [renderActions, setRenderActions] = React.useState(false);
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
+
let t0;
|
|
194
|
+
let t1;
|
|
195
|
+
if ($[0] !== renderActions) {
|
|
196
|
+
t0 = () => {
|
|
197
|
+
const el = ref.current;
|
|
198
|
+
if (!el || renderActions) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const observer = new IntersectionObserver((t22) => {
|
|
202
|
+
const [entry] = t22;
|
|
203
|
+
if (!entry.isIntersecting) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
React.startTransition(() => {
|
|
207
|
+
setRenderActions(true);
|
|
208
|
+
});
|
|
193
209
|
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
210
|
+
observer.observe(el);
|
|
211
|
+
return () => {
|
|
212
|
+
observer.disconnect();
|
|
213
|
+
};
|
|
198
214
|
};
|
|
199
|
-
|
|
200
|
-
|
|
215
|
+
t1 = [renderActions];
|
|
216
|
+
$[0] = renderActions;
|
|
217
|
+
$[1] = t0;
|
|
218
|
+
$[2] = t1;
|
|
219
|
+
} else {
|
|
220
|
+
t0 = $[1];
|
|
221
|
+
t1 = $[2];
|
|
222
|
+
}
|
|
223
|
+
React.useEffect(t0, t1);
|
|
224
|
+
let t2;
|
|
225
|
+
if ($[3] !== renderActions) {
|
|
226
|
+
t2 = [ref, renderActions];
|
|
227
|
+
$[3] = renderActions;
|
|
228
|
+
$[4] = t2;
|
|
229
|
+
} else {
|
|
230
|
+
t2 = $[4];
|
|
231
|
+
}
|
|
232
|
+
return t2;
|
|
201
233
|
}
|
|
202
234
|
const TreeItemNode = React.memo((props) => {
|
|
203
|
-
const
|
|
235
|
+
const $ = _c(7);
|
|
236
|
+
const {
|
|
237
|
+
expanded,
|
|
238
|
+
selected,
|
|
239
|
+
onExpanderClick
|
|
240
|
+
} = props;
|
|
204
241
|
const error = React.useContext(TreeItemErrorContext);
|
|
205
242
|
const [ref, renderActions] = useRenderActions();
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
243
|
+
const t0 = error ? true : void 0;
|
|
244
|
+
let t1;
|
|
245
|
+
if ($[0] !== expanded || $[1] !== onExpanderClick || $[2] !== ref || $[3] !== renderActions || $[4] !== selected || $[5] !== t0) {
|
|
246
|
+
t1 = jsxs(ListItem.Root, {
|
|
209
247
|
"data-_sk-expanded": expanded,
|
|
210
248
|
"data-_sk-selected": selected,
|
|
211
|
-
"data-_sk-error":
|
|
249
|
+
"data-_sk-error": t0,
|
|
212
250
|
className: "\u{1F95D}TreeItemNode",
|
|
213
251
|
role: void 0,
|
|
214
252
|
ref,
|
|
215
|
-
children: [
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
253
|
+
children: [jsx(TreeItemDecorations, {
|
|
254
|
+
onExpanderClick
|
|
255
|
+
}), jsx(TreeItemContent, {}), jsx(TreeItemDescription, {}), renderActions && jsx(TreeItemActions, {})]
|
|
256
|
+
});
|
|
257
|
+
$[0] = expanded;
|
|
258
|
+
$[1] = onExpanderClick;
|
|
259
|
+
$[2] = ref;
|
|
260
|
+
$[3] = renderActions;
|
|
261
|
+
$[4] = selected;
|
|
262
|
+
$[5] = t0;
|
|
263
|
+
$[6] = t1;
|
|
264
|
+
} else {
|
|
265
|
+
t1 = $[6];
|
|
266
|
+
}
|
|
267
|
+
return t1;
|
|
223
268
|
});
|
|
224
269
|
const TreeItemDecorations = React.memo((props) => {
|
|
225
|
-
return /* @__PURE__ */ jsxs(ListItem.Decoration, {
|
|
226
|
-
/* @__PURE__ */ jsx(TreeItemExpander, {
|
|
227
|
-
|
|
228
|
-
|
|
270
|
+
return /* @__PURE__ */ jsxs(ListItem.Decoration, {
|
|
271
|
+
children: [/* @__PURE__ */ jsx(TreeItemExpander, {
|
|
272
|
+
onClick: props.onExpanderClick
|
|
273
|
+
}), /* @__PURE__ */ jsx(TreeItemDecoration, {})]
|
|
274
|
+
});
|
|
229
275
|
});
|
|
230
276
|
function TreeItemDecoration() {
|
|
277
|
+
const $ = _c(4);
|
|
231
278
|
const decorationId = React.useContext(TreeItemDecorationIdContext);
|
|
232
279
|
const decorations = React.useContext(TreeItemDecorationsContext);
|
|
233
280
|
const icon = React.useContext(TreeItemIconContext);
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
{
|
|
281
|
+
let t0;
|
|
282
|
+
if ($[0] !== decorationId || $[1] !== decorations || $[2] !== icon) {
|
|
283
|
+
t0 = icon || decorations ? jsx(Role, {
|
|
237
284
|
className: "\u{1F95D}TreeItemDecoration",
|
|
238
285
|
id: decorationId,
|
|
239
|
-
render: React.isValidElement(icon) ? icon : typeof icon === "string" ?
|
|
286
|
+
render: React.isValidElement(icon) ? icon : typeof icon === "string" ? jsx(Icon, {
|
|
287
|
+
href: icon
|
|
288
|
+
}) : void 0,
|
|
240
289
|
children: !icon ? decorations : null
|
|
241
|
-
}
|
|
242
|
-
|
|
290
|
+
}) : null;
|
|
291
|
+
$[0] = decorationId;
|
|
292
|
+
$[1] = decorations;
|
|
293
|
+
$[2] = icon;
|
|
294
|
+
$[3] = t0;
|
|
295
|
+
} else {
|
|
296
|
+
t0 = $[3];
|
|
297
|
+
}
|
|
298
|
+
return t0;
|
|
243
299
|
}
|
|
244
300
|
const TreeItemContent = React.memo(() => {
|
|
301
|
+
const $ = _c(3);
|
|
245
302
|
const labelId = React.useContext(TreeItemLabelIdContext);
|
|
246
303
|
const label = React.useContext(TreeItemLabelContext);
|
|
247
|
-
|
|
304
|
+
let t0;
|
|
305
|
+
if ($[0] !== label || $[1] !== labelId) {
|
|
306
|
+
t0 = jsx(ListItem.Content, {
|
|
307
|
+
id: labelId,
|
|
308
|
+
className: "\u{1F95D}TreeItemContent",
|
|
309
|
+
children: label
|
|
310
|
+
});
|
|
311
|
+
$[0] = label;
|
|
312
|
+
$[1] = labelId;
|
|
313
|
+
$[2] = t0;
|
|
314
|
+
} else {
|
|
315
|
+
t0 = $[2];
|
|
316
|
+
}
|
|
317
|
+
return t0;
|
|
248
318
|
});
|
|
249
319
|
const TreeItemDescription = React.memo(() => {
|
|
320
|
+
const $ = _c(3);
|
|
250
321
|
const description = React.useContext(TreeItemDescriptionContext);
|
|
251
322
|
const descriptionId = React.useContext(TreeItemDescriptionIdContext);
|
|
252
|
-
|
|
323
|
+
let t0;
|
|
324
|
+
if ($[0] !== description || $[1] !== descriptionId) {
|
|
325
|
+
t0 = description ? jsx(ListItem.Content, {
|
|
326
|
+
id: descriptionId,
|
|
327
|
+
className: "\u{1F95D}TreeItemDescription",
|
|
328
|
+
children: description
|
|
329
|
+
}) : void 0;
|
|
330
|
+
$[0] = description;
|
|
331
|
+
$[1] = descriptionId;
|
|
332
|
+
$[2] = t0;
|
|
333
|
+
} else {
|
|
334
|
+
t0 = $[2];
|
|
335
|
+
}
|
|
336
|
+
return t0;
|
|
253
337
|
});
|
|
254
|
-
const TreeItemActions = React.memo(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
render: /* @__PURE__ */ jsx(Toolbar, { focusLoop: false }),
|
|
268
|
-
children: [
|
|
269
|
-
/* @__PURE__ */ jsx(TreeItemInlineActionsRenderer, {}),
|
|
270
|
-
/* @__PURE__ */ jsx(TreeItemActionMenu, {})
|
|
271
|
-
]
|
|
272
|
-
}
|
|
273
|
-
);
|
|
274
|
-
})
|
|
275
|
-
);
|
|
338
|
+
const TreeItemActions = React.memo(forwardRef((props, forwardedRef) => {
|
|
339
|
+
return /* @__PURE__ */ jsxs(ListItem.Decoration, {
|
|
340
|
+
...props,
|
|
341
|
+
onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
|
|
342
|
+
onKeyDown: useEventHandlers(props.onKeyDown, (e_0) => e_0.stopPropagation()),
|
|
343
|
+
className: cx("\u{1F95D}TreeItemActionsContainer", props.className),
|
|
344
|
+
ref: forwardedRef,
|
|
345
|
+
render: /* @__PURE__ */ jsx(Toolbar, {
|
|
346
|
+
focusLoop: false
|
|
347
|
+
}),
|
|
348
|
+
children: [/* @__PURE__ */ jsx(TreeItemInlineActionsRenderer, {}), /* @__PURE__ */ jsx(TreeItemActionMenu, {})]
|
|
349
|
+
});
|
|
350
|
+
}));
|
|
276
351
|
function TreeItemInlineActionsRenderer() {
|
|
352
|
+
const $ = _c(2);
|
|
277
353
|
const actions = React.useContext(TreeItemInlineActionsContext) ?? [];
|
|
278
|
-
|
|
354
|
+
let t0;
|
|
355
|
+
if ($[0] !== actions) {
|
|
356
|
+
t0 = actions.slice(0, 2);
|
|
357
|
+
$[0] = actions;
|
|
358
|
+
$[1] = t0;
|
|
359
|
+
} else {
|
|
360
|
+
t0 = $[1];
|
|
361
|
+
}
|
|
362
|
+
const actionsToDisplay = t0;
|
|
279
363
|
return actionsToDisplay;
|
|
280
364
|
}
|
|
281
365
|
const arrowKeys = ["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"];
|
|
282
366
|
const TreeItemActionsMenuContext = React.createContext(false);
|
|
283
367
|
const TreeItemDisplayActionsMenuContext = React.createContext(false);
|
|
284
|
-
const TreeItemActionMenu = React.memo(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
),
|
|
320
|
-
/* @__PURE__ */ jsx(TreeItemMenuActionsContent, {})
|
|
321
|
-
]
|
|
322
|
-
}
|
|
323
|
-
);
|
|
324
|
-
})
|
|
325
|
-
);
|
|
368
|
+
const TreeItemActionMenu = React.memo(forwardRef((props, forwardedRef) => {
|
|
369
|
+
const [open, _setOpen] = React.useState(false);
|
|
370
|
+
const isArrowKeyPressed = React.useRef(false);
|
|
371
|
+
const displayMenu = React.useContext(TreeItemDisplayActionsMenuContext);
|
|
372
|
+
const setOpen = React.useCallback((value) => {
|
|
373
|
+
if (value && !isArrowKeyPressed.current) {
|
|
374
|
+
_setOpen(true);
|
|
375
|
+
} else {
|
|
376
|
+
_setOpen(false);
|
|
377
|
+
}
|
|
378
|
+
}, []);
|
|
379
|
+
if (!displayMenu) return null;
|
|
380
|
+
return /* @__PURE__ */ jsxs(DropdownMenu.Provider, {
|
|
381
|
+
open,
|
|
382
|
+
setOpen,
|
|
383
|
+
placement: "right-start",
|
|
384
|
+
children: [/* @__PURE__ */ jsx(DropdownMenu.Button, {
|
|
385
|
+
...props,
|
|
386
|
+
onKeyDown: (e) => {
|
|
387
|
+
if (arrowKeys.includes(e.key)) {
|
|
388
|
+
isArrowKeyPressed.current = true;
|
|
389
|
+
}
|
|
390
|
+
queueMicrotask(() => {
|
|
391
|
+
isArrowKeyPressed.current = false;
|
|
392
|
+
});
|
|
393
|
+
},
|
|
394
|
+
render: /* @__PURE__ */ jsx(TreeItemInlineAction, {
|
|
395
|
+
label: "More",
|
|
396
|
+
icon: /* @__PURE__ */ jsx(MoreHorizontal, {})
|
|
397
|
+
}),
|
|
398
|
+
ref: forwardedRef
|
|
399
|
+
}), /* @__PURE__ */ jsx(TreeItemMenuActionsContent, {})]
|
|
400
|
+
});
|
|
401
|
+
}));
|
|
326
402
|
function TreeItemMenuActionsContent() {
|
|
327
|
-
return /* @__PURE__ */ jsx(TreeItemActionsMenuContext.Provider, {
|
|
403
|
+
return /* @__PURE__ */ jsx(TreeItemActionsMenuContext.Provider, {
|
|
404
|
+
value: true,
|
|
405
|
+
children: /* @__PURE__ */ jsx(DropdownMenu.Content, {
|
|
406
|
+
children: /* @__PURE__ */ jsx(TreeItemActionsRenderer, {})
|
|
407
|
+
})
|
|
408
|
+
});
|
|
328
409
|
}
|
|
329
410
|
function TreeItemActionsRenderer() {
|
|
330
411
|
const actions = React.useContext(TreeItemActionsContext) ?? [];
|
|
331
412
|
return actions;
|
|
332
413
|
}
|
|
333
|
-
const TreeItemAction = React.memo(
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
unstable_dot: dot,
|
|
345
|
-
ref: forwardedRef
|
|
346
|
-
}
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
return /* @__PURE__ */ jsx(TreeItemInlineAction, { ...props, ref: forwardedRef });
|
|
350
|
-
})
|
|
351
|
-
);
|
|
352
|
-
const TreeItemInlineAction = React.memo(
|
|
353
|
-
forwardRef((props, forwardedRef) => {
|
|
354
|
-
const error = React.useContext(TreeItemErrorContext);
|
|
355
|
-
const generatedId = React.useId();
|
|
356
|
-
const {
|
|
357
|
-
id = generatedId,
|
|
358
|
-
visible = error ? true : void 0,
|
|
359
|
-
// visible by default during error state
|
|
414
|
+
const TreeItemAction = React.memo(forwardRef((props, forwardedRef) => {
|
|
415
|
+
const {
|
|
416
|
+
label,
|
|
417
|
+
icon,
|
|
418
|
+
dot,
|
|
419
|
+
...rest
|
|
420
|
+
} = props;
|
|
421
|
+
const actionsMenuContext = React.useContext(TreeItemActionsMenuContext);
|
|
422
|
+
if (actionsMenuContext) {
|
|
423
|
+
return /* @__PURE__ */ jsx(DropdownMenu.Item, {
|
|
424
|
+
...rest,
|
|
360
425
|
label,
|
|
361
426
|
icon,
|
|
362
|
-
dot,
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
return /* @__PURE__ */ jsx(
|
|
366
|
-
IconButton,
|
|
367
|
-
{
|
|
368
|
-
id,
|
|
369
|
-
label,
|
|
370
|
-
icon,
|
|
371
|
-
inert: visible === false ? "true" : void 0,
|
|
372
|
-
...rest,
|
|
373
|
-
render: /* @__PURE__ */ jsx(ToolbarItem, { render: props.render }),
|
|
374
|
-
dot,
|
|
375
|
-
variant: "ghost",
|
|
376
|
-
className: cx("\u{1F95D}TreeItemAction", props.className),
|
|
377
|
-
"data-_sk-visible": visible,
|
|
378
|
-
ref: forwardedRef
|
|
379
|
-
}
|
|
380
|
-
);
|
|
381
|
-
})
|
|
382
|
-
);
|
|
383
|
-
const TreeItemExpander = forwardRef(
|
|
384
|
-
(props, forwardedRef) => {
|
|
385
|
-
const descriptionId = React.useContext(TreeItemDescriptionIdContext);
|
|
386
|
-
return /* @__PURE__ */ jsx(GhostAligner, { align: descriptionId ? "block" : void 0, children: /* @__PURE__ */ jsx(
|
|
387
|
-
IconButtonPresentation,
|
|
388
|
-
{
|
|
389
|
-
"aria-hidden": "true",
|
|
390
|
-
...props,
|
|
391
|
-
onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
|
|
392
|
-
className: cx("\u{1F95D}TreeItemExpander", props.className),
|
|
393
|
-
variant: "ghost",
|
|
394
|
-
ref: forwardedRef,
|
|
395
|
-
children: /* @__PURE__ */ jsx(ChevronDown, {})
|
|
396
|
-
}
|
|
397
|
-
) });
|
|
427
|
+
unstable_dot: dot,
|
|
428
|
+
ref: forwardedRef
|
|
429
|
+
});
|
|
398
430
|
}
|
|
399
|
-
|
|
431
|
+
return /* @__PURE__ */ jsx(TreeItemInlineAction, {
|
|
432
|
+
...props,
|
|
433
|
+
ref: forwardedRef
|
|
434
|
+
});
|
|
435
|
+
}));
|
|
436
|
+
const TreeItemInlineAction = React.memo(forwardRef((props, forwardedRef) => {
|
|
437
|
+
const error = React.useContext(TreeItemErrorContext);
|
|
438
|
+
const generatedId = React.useId();
|
|
439
|
+
const {
|
|
440
|
+
id = generatedId,
|
|
441
|
+
visible = error ? true : void 0,
|
|
442
|
+
// visible by default during error state
|
|
443
|
+
label,
|
|
444
|
+
icon,
|
|
445
|
+
dot,
|
|
446
|
+
...rest
|
|
447
|
+
} = props;
|
|
448
|
+
return /* @__PURE__ */ jsx(IconButton, {
|
|
449
|
+
id,
|
|
450
|
+
label,
|
|
451
|
+
icon,
|
|
452
|
+
inert: visible === false ? "true" : void 0,
|
|
453
|
+
...rest,
|
|
454
|
+
render: /* @__PURE__ */ jsx(ToolbarItem, {
|
|
455
|
+
render: props.render
|
|
456
|
+
}),
|
|
457
|
+
dot,
|
|
458
|
+
variant: "ghost",
|
|
459
|
+
className: cx("\u{1F95D}TreeItemAction", props.className),
|
|
460
|
+
"data-_sk-visible": visible,
|
|
461
|
+
ref: forwardedRef
|
|
462
|
+
});
|
|
463
|
+
}));
|
|
464
|
+
const TreeItemExpander = forwardRef((props, forwardedRef) => {
|
|
465
|
+
const descriptionId = React.useContext(TreeItemDescriptionIdContext);
|
|
466
|
+
return /* @__PURE__ */ jsx(GhostAligner, {
|
|
467
|
+
align: descriptionId ? "block" : void 0,
|
|
468
|
+
children: /* @__PURE__ */ jsx(IconButtonPresentation, {
|
|
469
|
+
"aria-hidden": "true",
|
|
470
|
+
...props,
|
|
471
|
+
onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
|
|
472
|
+
className: cx("\u{1F95D}TreeItemExpander", props.className),
|
|
473
|
+
variant: "ghost",
|
|
474
|
+
ref: forwardedRef,
|
|
475
|
+
children: /* @__PURE__ */ jsx(ChevronDown, {})
|
|
476
|
+
})
|
|
477
|
+
});
|
|
478
|
+
});
|
|
400
479
|
export {
|
|
401
480
|
TreeItemAction as Action,
|
|
402
481
|
TreeItem as Root
|