@itwin/itwinui-react 5.0.0-alpha.13 → 5.0.0-alpha.14
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 +14 -0
- package/README.md +31 -0
- package/dist/DEV/bricks/Anchor.js +2 -2
- package/dist/DEV/bricks/Avatar.js +1 -1
- package/dist/DEV/bricks/Badge.js +1 -1
- package/dist/DEV/bricks/Button.js +2 -2
- package/dist/DEV/bricks/Checkbox.js +2 -4
- package/dist/DEV/bricks/Chip.js +3 -3
- package/dist/DEV/bricks/Description.js +1 -1
- package/dist/DEV/bricks/Divider.js +1 -1
- package/dist/DEV/bricks/DropdownMenu.js +12 -14
- package/dist/DEV/bricks/ErrorRegion.js +12 -43
- package/dist/DEV/bricks/Field.internal.js +2 -5
- package/dist/DEV/bricks/Field.js +8 -11
- package/dist/DEV/bricks/Icon.js +3 -7
- package/dist/DEV/bricks/IconButton.internal.js +23 -0
- package/dist/DEV/bricks/IconButton.js +24 -16
- package/dist/DEV/bricks/Kbd.js +3 -3
- package/dist/DEV/bricks/Label.js +1 -1
- package/dist/DEV/bricks/Radio.js +2 -4
- package/dist/DEV/bricks/Root.js +11 -11
- package/dist/DEV/bricks/Select.js +4 -7
- package/dist/DEV/bricks/Switch.js +2 -4
- package/dist/DEV/bricks/Table.js +2 -2
- package/dist/DEV/bricks/Tabs.js +1 -1
- package/dist/DEV/bricks/TextBox.js +6 -8
- package/dist/DEV/bricks/Toolbar.js +5 -3
- package/dist/DEV/bricks/Tooltip.js +4 -4
- package/dist/DEV/bricks/Tree.js +3 -3
- package/dist/DEV/bricks/TreeItem.js +234 -139
- package/dist/DEV/bricks/VisuallyHidden.js +10 -2
- package/dist/DEV/bricks/styles.css.js +1 -1
- package/dist/DEV/bricks/~hooks.js +1 -1
- package/dist/DEV/bricks/~utils.Dot.js +2 -2
- package/dist/DEV/bricks/~utils.ListItem.js +2 -2
- package/dist/DEV/foundations/styles.css.js +1 -1
- package/dist/bricks/Anchor.d.ts +1 -1
- package/dist/bricks/Anchor.js +2 -2
- package/dist/bricks/Avatar.d.ts +1 -1
- package/dist/bricks/Avatar.js +1 -1
- package/dist/bricks/Badge.d.ts +1 -1
- package/dist/bricks/Badge.js +1 -1
- package/dist/bricks/Button.d.ts +1 -1
- package/dist/bricks/Button.js +2 -2
- package/dist/bricks/Checkbox.d.ts +2 -2
- package/dist/bricks/Checkbox.js +2 -4
- package/dist/bricks/Chip.d.ts +1 -1
- package/dist/bricks/Chip.js +3 -3
- package/dist/bricks/Description.d.ts +1 -1
- package/dist/bricks/Description.js +1 -1
- package/dist/bricks/Divider.d.ts +2 -2
- package/dist/bricks/Divider.js +1 -1
- package/dist/bricks/DropdownMenu.d.ts +3 -3
- package/dist/bricks/DropdownMenu.js +12 -14
- package/dist/bricks/ErrorRegion.d.ts +1 -6
- package/dist/bricks/ErrorRegion.js +12 -43
- package/dist/bricks/Field.d.ts +2 -2
- package/dist/bricks/Field.internal.d.ts +2 -1
- package/dist/bricks/Field.internal.js +2 -5
- package/dist/bricks/Field.js +8 -11
- package/dist/bricks/Icon.d.ts +1 -1
- package/dist/bricks/Icon.js +3 -7
- package/dist/bricks/IconButton.internal.d.ts +10 -0
- package/dist/bricks/IconButton.internal.js +22 -0
- package/dist/bricks/IconButton.js +24 -16
- package/dist/bricks/Kbd.d.ts +2 -2
- package/dist/bricks/Kbd.js +3 -3
- package/dist/bricks/Label.d.ts +1 -1
- package/dist/bricks/Label.js +1 -1
- package/dist/bricks/ProgressBar.d.ts +1 -1
- package/dist/bricks/Radio.d.ts +2 -2
- package/dist/bricks/Radio.js +2 -4
- package/dist/bricks/Root.d.ts +1 -1
- package/dist/bricks/Root.js +11 -11
- package/dist/bricks/Select.d.ts +1 -1
- package/dist/bricks/Select.js +4 -7
- package/dist/bricks/Skeleton.d.ts +1 -1
- package/dist/bricks/Spinner.d.ts +1 -1
- package/dist/bricks/Switch.d.ts +2 -2
- package/dist/bricks/Switch.js +2 -4
- package/dist/bricks/Table.d.ts +1 -1
- package/dist/bricks/Table.js +2 -2
- package/dist/bricks/Tabs.d.ts +1 -1
- package/dist/bricks/Tabs.js +1 -1
- package/dist/bricks/Text.d.ts +1 -1
- package/dist/bricks/TextBox.d.ts +1 -1
- package/dist/bricks/TextBox.js +6 -8
- package/dist/bricks/Toolbar.d.ts +4 -3
- package/dist/bricks/Toolbar.js +5 -3
- package/dist/bricks/Tooltip.d.ts +2 -2
- package/dist/bricks/Tooltip.js +4 -4
- package/dist/bricks/Tree.d.ts +2 -2
- package/dist/bricks/Tree.js +3 -3
- package/dist/bricks/TreeItem.d.ts +5 -5
- package/dist/bricks/TreeItem.js +223 -138
- package/dist/bricks/VisuallyHidden.d.ts +1 -1
- package/dist/bricks/VisuallyHidden.js +10 -2
- package/dist/bricks/styles.css.js +1 -1
- package/dist/bricks/~hooks.js +1 -1
- package/dist/bricks/~utils.Dot.d.ts +1 -1
- package/dist/bricks/~utils.Dot.js +2 -2
- package/dist/bricks/~utils.ListItem.d.ts +1 -1
- package/dist/bricks/~utils.ListItem.js +2 -2
- package/dist/bricks/~utils.d.ts +1 -1
- package/dist/foundations/styles.css.js +1 -1
- package/package.json +1 -1
package/dist/DEV/bricks/Tree.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { Composite, useCompositeStore } from "@ariakit/react/composite";
|
|
3
3
|
import { Role } from "@ariakit/react/role";
|
|
4
|
-
import
|
|
4
|
+
import cx from "classnames";
|
|
5
|
+
import { Action as TreeItemAction, Root as TreeItemRoot } from "./TreeItem.js";
|
|
5
6
|
import { forwardRef } from "./~utils.js";
|
|
6
|
-
import { Root as TreeItemRoot, Action as TreeItemAction } from "./TreeItem.js";
|
|
7
7
|
const Tree = forwardRef((props, forwardedRef) => {
|
|
8
8
|
const composite = useCompositeStore({ orientation: "vertical" });
|
|
9
9
|
return /* @__PURE__ */ jsx(
|
|
@@ -1,38 +1,54 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import cx from "classnames";
|
|
4
|
-
import { Role } from "@ariakit/react/role";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CompositeItem } from "@ariakit/react/composite";
|
|
5
3
|
import { PopoverProvider } from "@ariakit/react/popover";
|
|
6
|
-
import {
|
|
7
|
-
CompositeItem
|
|
8
|
-
} from "@ariakit/react/composite";
|
|
4
|
+
import { Role } from "@ariakit/react/role";
|
|
9
5
|
import { Toolbar, ToolbarItem } from "@ariakit/react/toolbar";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
6
|
+
import cx from "classnames";
|
|
7
|
+
import * as React from "react";
|
|
12
8
|
import * as DropdownMenu from "./DropdownMenu.js";
|
|
13
|
-
import { ChevronDown, Icon,
|
|
9
|
+
import { ChevronDown, Icon, MoreHorizontal, StatusWarning } from "./Icon.js";
|
|
10
|
+
import { IconButtonPresentation } from "./IconButton.internal.js";
|
|
11
|
+
import { IconButton } from "./IconButton.js";
|
|
12
|
+
import { useEventHandlers } from "./~hooks.js";
|
|
13
|
+
import * as ListItem from "./~utils.ListItem.js";
|
|
14
14
|
import { forwardRef } from "./~utils.js";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
15
|
+
const TreeItemErrorContext = React.createContext(void 0);
|
|
16
|
+
const TreeItemActionsContext = React.createContext(void 0);
|
|
17
|
+
const TreeItemDecorationsContext = React.createContext(void 0);
|
|
18
|
+
const TreeItemIconContext = React.createContext(void 0);
|
|
19
|
+
const TreeItemDecorationIdContext = React.createContext(
|
|
20
|
+
void 0
|
|
21
|
+
);
|
|
22
|
+
const TreeItemLabelContext = React.createContext(void 0);
|
|
23
|
+
const TreeItemLabelIdContext = React.createContext(
|
|
24
|
+
void 0
|
|
25
|
+
);
|
|
26
|
+
const TreeItemDescriptionContext = React.createContext(void 0);
|
|
27
|
+
const TreeItemDescriptionIdContext = React.createContext(
|
|
28
|
+
void 0
|
|
29
|
+
);
|
|
30
|
+
const TreeItemInlineActionsContext = React.createContext(void 0);
|
|
31
|
+
const TreeItemOverflowActionsContext = React.createContext(void 0);
|
|
32
|
+
const TreeItemHasOverflowActionsContext = React.createContext(false);
|
|
33
|
+
const TreeItem = React.memo(
|
|
34
|
+
forwardRef((props, forwardedRef) => {
|
|
35
|
+
const { expanded, selected } = props;
|
|
20
36
|
const {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
icon: iconProp,
|
|
37
|
+
onSelectedChange,
|
|
38
|
+
onExpandedChange,
|
|
39
|
+
icon,
|
|
25
40
|
unstable_decorations,
|
|
26
41
|
label,
|
|
27
42
|
description,
|
|
28
43
|
actions,
|
|
29
|
-
error,
|
|
30
|
-
onSelectedChange,
|
|
31
|
-
onExpandedChange,
|
|
32
44
|
onClick: onClickProp,
|
|
33
45
|
onKeyDown: onKeyDownProp,
|
|
34
46
|
...rest
|
|
35
47
|
} = props;
|
|
48
|
+
const onExpanderClick = useEventHandlers(() => {
|
|
49
|
+
if (expanded === void 0) return;
|
|
50
|
+
onExpandedChange?.(!expanded);
|
|
51
|
+
});
|
|
36
52
|
const handleClick = (event) => {
|
|
37
53
|
if (selected === void 0) return;
|
|
38
54
|
event.stopPropagation();
|
|
@@ -48,49 +64,93 @@ const TreeItemRoot = forwardRef(
|
|
|
48
64
|
onExpandedChange?.(event.key === "ArrowRight");
|
|
49
65
|
}
|
|
50
66
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
return /* @__PURE__ */ jsx(TreeItemRootProvider, { ...props, children: /* @__PURE__ */ jsx(
|
|
68
|
+
TreeItemRoot,
|
|
69
|
+
{
|
|
70
|
+
...rest,
|
|
71
|
+
onClick: useEventHandlers(onClickProp, handleClick),
|
|
72
|
+
onKeyDown: useEventHandlers(onKeyDownProp, handleKeyDown),
|
|
73
|
+
ref: forwardedRef,
|
|
74
|
+
children: React.useMemo(
|
|
75
|
+
() => /* @__PURE__ */ jsx(
|
|
76
|
+
TreeItemNode,
|
|
77
|
+
{
|
|
78
|
+
onExpanderClick,
|
|
79
|
+
expanded,
|
|
80
|
+
selected
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
[onExpanderClick, expanded, selected]
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
) });
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
DEV: TreeItem.displayName = "Tree.Item";
|
|
90
|
+
function TreeItemRootProvider(props) {
|
|
91
|
+
const {
|
|
92
|
+
actions,
|
|
93
|
+
label,
|
|
94
|
+
description,
|
|
95
|
+
icon: iconProp,
|
|
96
|
+
unstable_decorations: decorations,
|
|
97
|
+
error
|
|
98
|
+
} = props;
|
|
99
|
+
const labelId = React.useId();
|
|
100
|
+
const descriptionId = React.useId();
|
|
101
|
+
const decorationId = React.useId();
|
|
102
|
+
const icon = error ? /* @__PURE__ */ jsx(StatusWarning, {}) : iconProp;
|
|
103
|
+
const hasDecoration = icon || decorations;
|
|
104
|
+
return /* @__PURE__ */ jsx(TreeItemErrorContext.Provider, { value: error, children: /* @__PURE__ */ jsx(TreeItemActionsContext.Provider, { value: actions, children: /* @__PURE__ */ jsx(
|
|
105
|
+
TreeItemDecorationIdContext.Provider,
|
|
106
|
+
{
|
|
107
|
+
value: hasDecoration ? decorationId : void 0,
|
|
108
|
+
children: /* @__PURE__ */ jsx(TreeItemDecorationsContext.Provider, { value: decorations, children: /* @__PURE__ */ jsx(TreeItemIconContext.Provider, { value: icon, children: /* @__PURE__ */ jsx(TreeItemLabelIdContext.Provider, { value: labelId, children: /* @__PURE__ */ jsx(TreeItemLabelContext.Provider, { value: label, children: /* @__PURE__ */ jsx(TreeItemDescriptionContext.Provider, { value: description, children: /* @__PURE__ */ jsx(
|
|
109
|
+
TreeItemDescriptionIdContext.Provider,
|
|
110
|
+
{
|
|
111
|
+
value: description ? descriptionId : void 0,
|
|
112
|
+
children: props.children
|
|
113
|
+
}
|
|
114
|
+
) }) }) }) }) })
|
|
115
|
+
}
|
|
116
|
+
) }) });
|
|
117
|
+
}
|
|
118
|
+
DEV: TreeItemRootProvider.displayName = "TreeItemRootProvider";
|
|
119
|
+
const TreeItemRoot = React.memo(
|
|
120
|
+
forwardRef((props, forwardedRef) => {
|
|
121
|
+
const {
|
|
122
|
+
style: styleProp,
|
|
123
|
+
"aria-level": level,
|
|
124
|
+
selected,
|
|
125
|
+
expanded,
|
|
126
|
+
...rest
|
|
127
|
+
} = props;
|
|
128
|
+
const labelId = React.useContext(TreeItemLabelIdContext);
|
|
129
|
+
const decorationId = React.useContext(TreeItemDecorationIdContext);
|
|
130
|
+
const descriptionId = React.useContext(TreeItemDescriptionIdContext);
|
|
131
|
+
const error = React.useContext(TreeItemErrorContext);
|
|
54
132
|
const errorId = typeof error === "string" ? error : void 0;
|
|
55
|
-
const icon = error ? /* @__PURE__ */ jsx(StatusWarning, {}) : iconProp;
|
|
56
133
|
const describedBy = React.useMemo(() => {
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
if (
|
|
60
|
-
if (errorId)
|
|
61
|
-
return
|
|
62
|
-
}, [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
134
|
+
const ids = [];
|
|
135
|
+
if (descriptionId) ids.push(descriptionId);
|
|
136
|
+
if (decorationId) ids.push(decorationId);
|
|
137
|
+
if (errorId) ids.push(errorId);
|
|
138
|
+
return ids.length > 0 ? ids.join(" ") : void 0;
|
|
139
|
+
}, [decorationId, descriptionId, errorId]);
|
|
140
|
+
const style = React.useMemo(
|
|
141
|
+
() => ({
|
|
142
|
+
...styleProp,
|
|
143
|
+
"--\u{1F95D}tree-item-level": level
|
|
144
|
+
}),
|
|
145
|
+
[styleProp, level]
|
|
146
|
+
);
|
|
70
147
|
return /* @__PURE__ */ jsx(
|
|
71
|
-
|
|
148
|
+
CompositeItem,
|
|
72
149
|
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
level,
|
|
76
|
-
expanded,
|
|
77
|
-
selected,
|
|
78
|
-
error
|
|
79
|
-
}),
|
|
80
|
-
[level, expanded, selected, error]
|
|
81
|
-
),
|
|
82
|
-
children: /* @__PURE__ */ jsx(
|
|
83
|
-
CompositeItem,
|
|
150
|
+
render: /* @__PURE__ */ jsx(
|
|
151
|
+
Role,
|
|
84
152
|
{
|
|
85
|
-
|
|
86
|
-
onClick: useEventHandlers(
|
|
87
|
-
onClickProp,
|
|
88
|
-
handleClick
|
|
89
|
-
),
|
|
90
|
-
onKeyDown: useEventHandlers(
|
|
91
|
-
onKeyDownProp,
|
|
92
|
-
handleKeyDown
|
|
93
|
-
),
|
|
153
|
+
...rest,
|
|
94
154
|
role: "treeitem",
|
|
95
155
|
"aria-expanded": expanded,
|
|
96
156
|
"aria-selected": selected,
|
|
@@ -98,90 +158,121 @@ const TreeItemRoot = forwardRef(
|
|
|
98
158
|
"aria-describedby": describedBy,
|
|
99
159
|
"aria-level": level,
|
|
100
160
|
className: cx("\u{1F95D}-tree-item", props.className),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
ListItem.Root,
|
|
104
|
-
{
|
|
105
|
-
"data-kiwi-expanded": expanded,
|
|
106
|
-
"data-kiwi-selected": selected,
|
|
107
|
-
"data-kiwi-error": error ? true : void 0,
|
|
108
|
-
className: "\u{1F95D}-tree-item-node",
|
|
109
|
-
style: { "--\u{1F95D}tree-item-level": level },
|
|
110
|
-
role: void 0,
|
|
111
|
-
children: [
|
|
112
|
-
/* @__PURE__ */ jsxs(ListItem.Decoration, { children: [
|
|
113
|
-
/* @__PURE__ */ jsx(GhostAligner, { align: description ? "block" : void 0, children: /* @__PURE__ */ jsx(
|
|
114
|
-
TreeItemExpander,
|
|
115
|
-
{
|
|
116
|
-
onClick: () => {
|
|
117
|
-
if (expanded === void 0) return;
|
|
118
|
-
onExpandedChange?.(!expanded);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
) }),
|
|
122
|
-
icon || unstable_decorations ? /* @__PURE__ */ jsx(
|
|
123
|
-
Role,
|
|
124
|
-
{
|
|
125
|
-
className: "\u{1F95D}-tree-item-decoration",
|
|
126
|
-
id: decorationId,
|
|
127
|
-
render: React.isValidElement(icon) ? icon : typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : void 0,
|
|
128
|
-
children: !icon ? unstable_decorations : null
|
|
129
|
-
}
|
|
130
|
-
) : null
|
|
131
|
-
] }),
|
|
132
|
-
/* @__PURE__ */ jsx(ListItem.Content, { id: labelId, className: "\u{1F95D}-tree-item-content", children: label }),
|
|
133
|
-
description ? /* @__PURE__ */ jsx(
|
|
134
|
-
ListItem.Content,
|
|
135
|
-
{
|
|
136
|
-
id: descriptionId,
|
|
137
|
-
className: "\u{1F95D}-tree-item-description",
|
|
138
|
-
children: description
|
|
139
|
-
}
|
|
140
|
-
) : void 0,
|
|
141
|
-
/* @__PURE__ */ jsx(
|
|
142
|
-
ListItem.Decoration,
|
|
143
|
-
{
|
|
144
|
-
render: /* @__PURE__ */ jsx(TreeItemActions, { children: actions })
|
|
145
|
-
}
|
|
146
|
-
)
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
)
|
|
161
|
+
style,
|
|
162
|
+
ref: forwardedRef
|
|
150
163
|
}
|
|
151
|
-
)
|
|
164
|
+
),
|
|
165
|
+
children: props.children
|
|
152
166
|
}
|
|
153
167
|
);
|
|
154
|
-
}
|
|
168
|
+
})
|
|
155
169
|
);
|
|
156
|
-
DEV: TreeItemRoot.displayName = "
|
|
157
|
-
const
|
|
158
|
-
const {
|
|
159
|
-
const
|
|
160
|
-
const { error } = useSafeContext(TreeItemContext);
|
|
161
|
-
const limit = error ? 2 : 3;
|
|
170
|
+
DEV: TreeItemRoot.displayName = "TreeItemRoot";
|
|
171
|
+
const TreeItemNode = React.memo((props) => {
|
|
172
|
+
const { expanded, selected, onExpanderClick } = props;
|
|
173
|
+
const error = React.useContext(TreeItemErrorContext);
|
|
162
174
|
return /* @__PURE__ */ jsxs(
|
|
163
|
-
|
|
175
|
+
ListItem.Root,
|
|
164
176
|
{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
className:
|
|
169
|
-
|
|
170
|
-
ref: forwardedRef,
|
|
177
|
+
"data-kiwi-expanded": expanded,
|
|
178
|
+
"data-kiwi-selected": selected,
|
|
179
|
+
"data-kiwi-error": error ? true : void 0,
|
|
180
|
+
className: "\u{1F95D}-tree-item-node",
|
|
181
|
+
role: void 0,
|
|
171
182
|
children: [
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
183
|
+
/* @__PURE__ */ jsx(TreeItemDecorations, { onExpanderClick }),
|
|
184
|
+
/* @__PURE__ */ jsx(TreeItemContent, {}),
|
|
185
|
+
/* @__PURE__ */ jsx(TreeItemDescription, {}),
|
|
186
|
+
/* @__PURE__ */ jsx(TreeItemActions, {})
|
|
175
187
|
]
|
|
176
188
|
}
|
|
177
189
|
);
|
|
178
190
|
});
|
|
191
|
+
DEV: TreeItemNode.displayName = "TreeItemNode";
|
|
192
|
+
const TreeItemDecorations = React.memo((props) => {
|
|
193
|
+
return /* @__PURE__ */ jsxs(ListItem.Decoration, { children: [
|
|
194
|
+
/* @__PURE__ */ jsx(TreeItemExpander, { onClick: props.onExpanderClick }),
|
|
195
|
+
/* @__PURE__ */ jsx(TreeItemDecoration, {})
|
|
196
|
+
] });
|
|
197
|
+
});
|
|
198
|
+
DEV: TreeItemDecorations.displayName = "TreeItemDecorations";
|
|
199
|
+
function TreeItemDecoration() {
|
|
200
|
+
const decorationId = React.useContext(TreeItemDecorationIdContext);
|
|
201
|
+
const decorations = React.useContext(TreeItemDecorationsContext);
|
|
202
|
+
const icon = React.useContext(TreeItemIconContext);
|
|
203
|
+
return icon || decorations ? /* @__PURE__ */ jsx(
|
|
204
|
+
Role,
|
|
205
|
+
{
|
|
206
|
+
className: "\u{1F95D}-tree-item-decoration",
|
|
207
|
+
id: decorationId,
|
|
208
|
+
render: React.isValidElement(icon) ? icon : typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : void 0,
|
|
209
|
+
children: !icon ? decorations : null
|
|
210
|
+
}
|
|
211
|
+
) : null;
|
|
212
|
+
}
|
|
213
|
+
DEV: TreeItemDecoration.displayName = "TreeItemDecoration";
|
|
214
|
+
const TreeItemContent = React.memo(() => {
|
|
215
|
+
const labelId = React.useContext(TreeItemLabelIdContext);
|
|
216
|
+
const label = React.useContext(TreeItemLabelContext);
|
|
217
|
+
return /* @__PURE__ */ jsx(ListItem.Content, { id: labelId, className: "\u{1F95D}-tree-item-content", children: label });
|
|
218
|
+
});
|
|
219
|
+
DEV: TreeItemContent.displayName = "TreeItemContent";
|
|
220
|
+
const TreeItemDescription = React.memo(() => {
|
|
221
|
+
const description = React.useContext(TreeItemDescriptionContext);
|
|
222
|
+
const descriptionId = React.useContext(TreeItemDescriptionIdContext);
|
|
223
|
+
return description ? /* @__PURE__ */ jsx(ListItem.Content, { id: descriptionId, className: "\u{1F95D}-tree-item-description", children: description }) : void 0;
|
|
224
|
+
});
|
|
225
|
+
DEV: TreeItemDescription.displayName = "TreeItemDescription";
|
|
226
|
+
const TreeItemActions = React.memo(
|
|
227
|
+
forwardRef((props, forwardedRef) => {
|
|
228
|
+
return /* @__PURE__ */ jsx(TreeItemActionsProvider, { children: /* @__PURE__ */ jsx(
|
|
229
|
+
ListItem.Decoration,
|
|
230
|
+
{
|
|
231
|
+
...props,
|
|
232
|
+
onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
|
|
233
|
+
onKeyDown: useEventHandlers(
|
|
234
|
+
props.onKeyDown,
|
|
235
|
+
(e) => e.stopPropagation()
|
|
236
|
+
),
|
|
237
|
+
className: cx("\u{1F95D}-tree-item-actions-container", props.className),
|
|
238
|
+
ref: forwardedRef,
|
|
239
|
+
render: /* @__PURE__ */ jsxs(Toolbar, { focusLoop: false, children: [
|
|
240
|
+
/* @__PURE__ */ jsx(TreeItemInlineActions, {}),
|
|
241
|
+
/* @__PURE__ */ jsx(TreeItemActionsOverflowMenu, {})
|
|
242
|
+
] })
|
|
243
|
+
}
|
|
244
|
+
) });
|
|
245
|
+
})
|
|
246
|
+
);
|
|
179
247
|
DEV: TreeItemActions.displayName = "TreeItemActions";
|
|
248
|
+
function TreeItemActionsProvider(props) {
|
|
249
|
+
const actionsProp = React.useContext(TreeItemActionsContext);
|
|
250
|
+
const error = React.useContext(TreeItemErrorContext);
|
|
251
|
+
const actionsLimit = error ? 2 : 3;
|
|
252
|
+
const { inline, overflow } = React.useMemo(() => {
|
|
253
|
+
const actions = React.Children.toArray(actionsProp).filter(Boolean);
|
|
254
|
+
const inline2 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
255
|
+
actions.slice(0, actionsLimit - 1),
|
|
256
|
+
actions.length === actionsLimit ? actions[actionsLimit - 1] : null
|
|
257
|
+
] });
|
|
258
|
+
const overflow2 = actions.length > actionsLimit ? actions.slice(actionsLimit - 1) : void 0;
|
|
259
|
+
return { inline: inline2, overflow: overflow2 };
|
|
260
|
+
}, [actionsProp, actionsLimit]);
|
|
261
|
+
return /* @__PURE__ */ jsx(TreeItemInlineActionsContext.Provider, { value: inline, children: /* @__PURE__ */ jsx(TreeItemOverflowActionsContext.Provider, { value: overflow, children: /* @__PURE__ */ jsx(TreeItemHasOverflowActionsContext.Provider, { value: !!overflow, children: props.children }) }) });
|
|
262
|
+
}
|
|
263
|
+
DEV: TreeItemActionsProvider.displayName = "TreeItemActionsProvider";
|
|
264
|
+
function TreeItemInlineActions() {
|
|
265
|
+
const actions = React.useContext(TreeItemInlineActionsContext);
|
|
266
|
+
return actions;
|
|
267
|
+
}
|
|
268
|
+
DEV: TreeItemInlineActions.displayName = "TreeItemInlineActions";
|
|
180
269
|
const arrowKeys = ["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"];
|
|
181
270
|
const TreeItemActionsOverflowMenuContext = React.createContext(false);
|
|
182
|
-
function TreeItemActionsOverflowMenu(
|
|
271
|
+
function TreeItemActionsOverflowMenu() {
|
|
272
|
+
const overflow = React.useContext(TreeItemHasOverflowActionsContext);
|
|
183
273
|
const [open, setOpen] = React.useState(false);
|
|
184
274
|
const isArrowKeyPressed = React.useRef(false);
|
|
275
|
+
if (!overflow) return null;
|
|
185
276
|
return /* @__PURE__ */ jsx(PopoverProvider, { placement: "right-start", children: /* @__PURE__ */ jsxs(
|
|
186
277
|
DropdownMenu.Root,
|
|
187
278
|
{
|
|
@@ -208,15 +299,20 @@ function TreeItemActionsOverflowMenu({ children }) {
|
|
|
208
299
|
render: /* @__PURE__ */ jsx(TreeItemAction, { label: "More", icon: /* @__PURE__ */ jsx(MoreHorizontal, {}) })
|
|
209
300
|
}
|
|
210
301
|
),
|
|
211
|
-
/* @__PURE__ */ jsx(TreeItemActionsOverflowMenuContext.Provider, { value: true, children: /* @__PURE__ */ jsx(
|
|
302
|
+
/* @__PURE__ */ jsx(TreeItemActionsOverflowMenuContext.Provider, { value: true, children: /* @__PURE__ */ jsx(TreeItemActionsOverflowMenuContent, {}) })
|
|
212
303
|
]
|
|
213
304
|
}
|
|
214
305
|
) });
|
|
215
306
|
}
|
|
216
307
|
DEV: TreeItemActionsOverflowMenu.displayName = "TreeItemActionsOverflowMenu";
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
308
|
+
function TreeItemActionsOverflowMenuContent() {
|
|
309
|
+
const actions = React.useContext(TreeItemOverflowActionsContext);
|
|
310
|
+
return /* @__PURE__ */ jsx(DropdownMenu.Content, { children: actions });
|
|
311
|
+
}
|
|
312
|
+
DEV: TreeItemActionsOverflowMenu.displayName = "TreeItemActionsOverflowMenu";
|
|
313
|
+
const TreeItemAction = React.memo(
|
|
314
|
+
forwardRef((props, forwardedRef) => {
|
|
315
|
+
const error = React.useContext(TreeItemErrorContext);
|
|
220
316
|
const {
|
|
221
317
|
visible = error ? true : void 0,
|
|
222
318
|
// visible by default during error state
|
|
@@ -266,26 +362,25 @@ const TreeItemAction = forwardRef(
|
|
|
266
362
|
)
|
|
267
363
|
}
|
|
268
364
|
);
|
|
269
|
-
}
|
|
365
|
+
})
|
|
270
366
|
);
|
|
271
367
|
DEV: TreeItemAction.displayName = "TreeItem.Action";
|
|
272
368
|
const TreeItemExpander = forwardRef(
|
|
273
369
|
(props, forwardedRef) => {
|
|
370
|
+
const descriptionId = React.useContext(TreeItemDescriptionIdContext);
|
|
274
371
|
return /* @__PURE__ */ jsx(
|
|
275
|
-
|
|
372
|
+
IconButtonPresentation,
|
|
276
373
|
{
|
|
277
374
|
"aria-hidden": "true",
|
|
278
375
|
...props,
|
|
279
376
|
onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
|
|
280
377
|
className: cx(
|
|
281
|
-
"\u{1F95D}-button",
|
|
282
|
-
"\u{1F95D}-icon-button",
|
|
283
378
|
"\u{1F95D}-ghost-aligner",
|
|
284
379
|
"\u{1F95D}-tree-item-expander",
|
|
285
380
|
props.className
|
|
286
381
|
),
|
|
287
|
-
|
|
288
|
-
"data-kiwi-ghost-align":
|
|
382
|
+
variant: "ghost",
|
|
383
|
+
"data-kiwi-ghost-align": descriptionId ? "block" : void 0,
|
|
289
384
|
ref: forwardedRef,
|
|
290
385
|
children: /* @__PURE__ */ jsx(ChevronDown, {})
|
|
291
386
|
}
|
|
@@ -295,5 +390,5 @@ const TreeItemExpander = forwardRef(
|
|
|
295
390
|
DEV: TreeItemExpander.displayName = "TreeItemExpander";
|
|
296
391
|
export {
|
|
297
392
|
TreeItemAction as Action,
|
|
298
|
-
|
|
393
|
+
TreeItem as Root
|
|
299
394
|
};
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Role } from "@ariakit/react/role";
|
|
3
|
+
import cx from "classnames";
|
|
3
4
|
import { forwardRef } from "./~utils.js";
|
|
4
5
|
const VisuallyHidden = forwardRef(
|
|
5
6
|
(props, forwardedRef) => {
|
|
6
|
-
return /* @__PURE__ */ jsx(
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
Role.span,
|
|
9
|
+
{
|
|
10
|
+
...props,
|
|
11
|
+
className: cx("\u{1F95D}-visually-hidden", props.className),
|
|
12
|
+
ref: forwardedRef
|
|
13
|
+
}
|
|
14
|
+
);
|
|
7
15
|
}
|
|
8
16
|
);
|
|
9
17
|
DEV: VisuallyHidden.displayName = "VisuallyHidden";
|