@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.
Files changed (106) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +31 -0
  3. package/dist/DEV/bricks/Anchor.js +2 -2
  4. package/dist/DEV/bricks/Avatar.js +1 -1
  5. package/dist/DEV/bricks/Badge.js +1 -1
  6. package/dist/DEV/bricks/Button.js +2 -2
  7. package/dist/DEV/bricks/Checkbox.js +2 -4
  8. package/dist/DEV/bricks/Chip.js +3 -3
  9. package/dist/DEV/bricks/Description.js +1 -1
  10. package/dist/DEV/bricks/Divider.js +1 -1
  11. package/dist/DEV/bricks/DropdownMenu.js +12 -14
  12. package/dist/DEV/bricks/ErrorRegion.js +12 -43
  13. package/dist/DEV/bricks/Field.internal.js +2 -5
  14. package/dist/DEV/bricks/Field.js +8 -11
  15. package/dist/DEV/bricks/Icon.js +3 -7
  16. package/dist/DEV/bricks/IconButton.internal.js +23 -0
  17. package/dist/DEV/bricks/IconButton.js +24 -16
  18. package/dist/DEV/bricks/Kbd.js +3 -3
  19. package/dist/DEV/bricks/Label.js +1 -1
  20. package/dist/DEV/bricks/Radio.js +2 -4
  21. package/dist/DEV/bricks/Root.js +11 -11
  22. package/dist/DEV/bricks/Select.js +4 -7
  23. package/dist/DEV/bricks/Switch.js +2 -4
  24. package/dist/DEV/bricks/Table.js +2 -2
  25. package/dist/DEV/bricks/Tabs.js +1 -1
  26. package/dist/DEV/bricks/TextBox.js +6 -8
  27. package/dist/DEV/bricks/Toolbar.js +5 -3
  28. package/dist/DEV/bricks/Tooltip.js +4 -4
  29. package/dist/DEV/bricks/Tree.js +3 -3
  30. package/dist/DEV/bricks/TreeItem.js +234 -139
  31. package/dist/DEV/bricks/VisuallyHidden.js +10 -2
  32. package/dist/DEV/bricks/styles.css.js +1 -1
  33. package/dist/DEV/bricks/~hooks.js +1 -1
  34. package/dist/DEV/bricks/~utils.Dot.js +2 -2
  35. package/dist/DEV/bricks/~utils.ListItem.js +2 -2
  36. package/dist/DEV/foundations/styles.css.js +1 -1
  37. package/dist/bricks/Anchor.d.ts +1 -1
  38. package/dist/bricks/Anchor.js +2 -2
  39. package/dist/bricks/Avatar.d.ts +1 -1
  40. package/dist/bricks/Avatar.js +1 -1
  41. package/dist/bricks/Badge.d.ts +1 -1
  42. package/dist/bricks/Badge.js +1 -1
  43. package/dist/bricks/Button.d.ts +1 -1
  44. package/dist/bricks/Button.js +2 -2
  45. package/dist/bricks/Checkbox.d.ts +2 -2
  46. package/dist/bricks/Checkbox.js +2 -4
  47. package/dist/bricks/Chip.d.ts +1 -1
  48. package/dist/bricks/Chip.js +3 -3
  49. package/dist/bricks/Description.d.ts +1 -1
  50. package/dist/bricks/Description.js +1 -1
  51. package/dist/bricks/Divider.d.ts +2 -2
  52. package/dist/bricks/Divider.js +1 -1
  53. package/dist/bricks/DropdownMenu.d.ts +3 -3
  54. package/dist/bricks/DropdownMenu.js +12 -14
  55. package/dist/bricks/ErrorRegion.d.ts +1 -6
  56. package/dist/bricks/ErrorRegion.js +12 -43
  57. package/dist/bricks/Field.d.ts +2 -2
  58. package/dist/bricks/Field.internal.d.ts +2 -1
  59. package/dist/bricks/Field.internal.js +2 -5
  60. package/dist/bricks/Field.js +8 -11
  61. package/dist/bricks/Icon.d.ts +1 -1
  62. package/dist/bricks/Icon.js +3 -7
  63. package/dist/bricks/IconButton.internal.d.ts +10 -0
  64. package/dist/bricks/IconButton.internal.js +22 -0
  65. package/dist/bricks/IconButton.js +24 -16
  66. package/dist/bricks/Kbd.d.ts +2 -2
  67. package/dist/bricks/Kbd.js +3 -3
  68. package/dist/bricks/Label.d.ts +1 -1
  69. package/dist/bricks/Label.js +1 -1
  70. package/dist/bricks/ProgressBar.d.ts +1 -1
  71. package/dist/bricks/Radio.d.ts +2 -2
  72. package/dist/bricks/Radio.js +2 -4
  73. package/dist/bricks/Root.d.ts +1 -1
  74. package/dist/bricks/Root.js +11 -11
  75. package/dist/bricks/Select.d.ts +1 -1
  76. package/dist/bricks/Select.js +4 -7
  77. package/dist/bricks/Skeleton.d.ts +1 -1
  78. package/dist/bricks/Spinner.d.ts +1 -1
  79. package/dist/bricks/Switch.d.ts +2 -2
  80. package/dist/bricks/Switch.js +2 -4
  81. package/dist/bricks/Table.d.ts +1 -1
  82. package/dist/bricks/Table.js +2 -2
  83. package/dist/bricks/Tabs.d.ts +1 -1
  84. package/dist/bricks/Tabs.js +1 -1
  85. package/dist/bricks/Text.d.ts +1 -1
  86. package/dist/bricks/TextBox.d.ts +1 -1
  87. package/dist/bricks/TextBox.js +6 -8
  88. package/dist/bricks/Toolbar.d.ts +4 -3
  89. package/dist/bricks/Toolbar.js +5 -3
  90. package/dist/bricks/Tooltip.d.ts +2 -2
  91. package/dist/bricks/Tooltip.js +4 -4
  92. package/dist/bricks/Tree.d.ts +2 -2
  93. package/dist/bricks/Tree.js +3 -3
  94. package/dist/bricks/TreeItem.d.ts +5 -5
  95. package/dist/bricks/TreeItem.js +223 -138
  96. package/dist/bricks/VisuallyHidden.d.ts +1 -1
  97. package/dist/bricks/VisuallyHidden.js +10 -2
  98. package/dist/bricks/styles.css.js +1 -1
  99. package/dist/bricks/~hooks.js +1 -1
  100. package/dist/bricks/~utils.Dot.d.ts +1 -1
  101. package/dist/bricks/~utils.Dot.js +2 -2
  102. package/dist/bricks/~utils.ListItem.d.ts +1 -1
  103. package/dist/bricks/~utils.ListItem.js +2 -2
  104. package/dist/bricks/~utils.d.ts +1 -1
  105. package/dist/foundations/styles.css.js +1 -1
  106. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import cx from "classnames";
2
+ import { Composite, useCompositeStore } from "@ariakit/react/composite";
3
3
  import { Role } from "@ariakit/react/role";
4
- import { useCompositeStore, Composite } from "@ariakit/react/composite";
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 * as React from "react";
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 * as ListItem from "./~utils.ListItem.js";
11
- import { IconButton } from "./IconButton.js";
6
+ import cx from "classnames";
7
+ import * as React from "react";
12
8
  import * as DropdownMenu from "./DropdownMenu.js";
13
- import { ChevronDown, Icon, StatusWarning, MoreHorizontal } from "./Icon.js";
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
- import { useEventHandlers, useSafeContext } from "./~hooks.js";
16
- import { GhostAligner, useGhostAlignment } from "./~utils.GhostAligner.js";
17
- const TreeItemContext = React.createContext(void 0);
18
- const TreeItemRoot = forwardRef(
19
- (props, forwardedRef) => {
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
- "aria-level": level,
22
- selected,
23
- expanded,
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
- const labelId = React.useId();
52
- const descriptionId = React.useId();
53
- const decorationId = React.useId();
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 idRefs = [];
58
- if (description) idRefs.push(descriptionId);
59
- if (unstable_decorations || icon) idRefs.push(decorationId);
60
- if (errorId) idRefs.push(errorId);
61
- return idRefs.length > 0 ? idRefs.join(" ") : void 0;
62
- }, [
63
- unstable_decorations,
64
- icon,
65
- decorationId,
66
- description,
67
- descriptionId,
68
- errorId
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
- TreeItemContext.Provider,
148
+ CompositeItem,
72
149
  {
73
- value: React.useMemo(
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
- render: /* @__PURE__ */ jsx(Role, { ...rest }),
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
- ref: forwardedRef,
102
- children: /* @__PURE__ */ jsxs(
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 = "TreeItem.Root";
157
- const TreeItemActions = forwardRef((props, forwardedRef) => {
158
- const { children, ...rest } = props;
159
- const actions = React.Children.toArray(children).filter(Boolean);
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
- Toolbar,
175
+ ListItem.Root,
164
176
  {
165
- ...rest,
166
- onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
167
- onKeyDown: useEventHandlers(props.onKeyDown, (e) => e.stopPropagation()),
168
- className: cx("\u{1F95D}-tree-item-actions-container", props.className),
169
- focusLoop: false,
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
- actions.slice(0, limit - 1),
173
- actions.length === limit ? actions[limit - 1] : null,
174
- actions.length > limit ? /* @__PURE__ */ jsx(TreeItemActionsOverflowMenu, { children: actions.slice(limit - 1) }) : null
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({ children }) {
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(DropdownMenu.Content, { children }) })
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
- const TreeItemAction = forwardRef(
218
- (props, forwardedRef) => {
219
- const { error } = useSafeContext(TreeItemContext);
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
- Role.span,
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
- "data-kiwi-variant": "ghost",
288
- "data-kiwi-ghost-align": useGhostAlignment(),
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
- TreeItemRoot as Root
393
+ TreeItem as Root
299
394
  };
@@ -1,9 +1,17 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { VisuallyHidden as AkVisuallyHidden } from "@ariakit/react/visually-hidden";
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(AkVisuallyHidden, { ...props, ref: forwardedRef });
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";