@itwin/itwinui-react 5.0.0-alpha.12 → 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 (109) hide show
  1. package/CHANGELOG.md +24 -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 +23 -16
  12. package/dist/DEV/bricks/ErrorRegion.js +106 -0
  13. package/dist/DEV/bricks/Field.internal.js +2 -5
  14. package/dist/DEV/bricks/Field.js +17 -16
  15. package/dist/DEV/bricks/Icon.js +28 -7
  16. package/dist/DEV/bricks/IconButton.internal.js +23 -0
  17. package/dist/DEV/bricks/IconButton.js +24 -19
  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 +27 -0
  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 +254 -166
  31. package/dist/DEV/bricks/VisuallyHidden.js +10 -2
  32. package/dist/DEV/bricks/index.js +6 -2
  33. package/dist/DEV/bricks/styles.css.js +1 -1
  34. package/dist/DEV/bricks/~hooks.js +1 -1
  35. package/dist/DEV/bricks/~utils.Dot.js +22 -0
  36. package/dist/DEV/bricks/~utils.ListItem.js +2 -2
  37. package/dist/DEV/foundations/styles.css.js +1 -1
  38. package/dist/bricks/Anchor.d.ts +1 -1
  39. package/dist/bricks/Anchor.js +2 -2
  40. package/dist/bricks/Avatar.d.ts +1 -1
  41. package/dist/bricks/Avatar.js +1 -1
  42. package/dist/bricks/Badge.d.ts +1 -1
  43. package/dist/bricks/Badge.js +1 -1
  44. package/dist/bricks/Button.d.ts +1 -1
  45. package/dist/bricks/Button.js +2 -2
  46. package/dist/bricks/Checkbox.d.ts +2 -2
  47. package/dist/bricks/Checkbox.js +2 -4
  48. package/dist/bricks/Chip.d.ts +1 -1
  49. package/dist/bricks/Chip.js +3 -3
  50. package/dist/bricks/Description.d.ts +1 -1
  51. package/dist/bricks/Description.js +1 -1
  52. package/dist/bricks/Divider.d.ts +2 -2
  53. package/dist/bricks/Divider.js +1 -1
  54. package/dist/bricks/DropdownMenu.d.ts +5 -3
  55. package/dist/bricks/DropdownMenu.js +23 -16
  56. package/dist/bricks/ErrorRegion.d.ts +83 -0
  57. package/dist/bricks/ErrorRegion.js +104 -0
  58. package/dist/bricks/Field.d.ts +8 -2
  59. package/dist/bricks/Field.internal.d.ts +2 -1
  60. package/dist/bricks/Field.internal.js +2 -5
  61. package/dist/bricks/Field.js +17 -16
  62. package/dist/bricks/Icon.d.ts +4 -1
  63. package/dist/bricks/Icon.js +27 -7
  64. package/dist/bricks/IconButton.internal.d.ts +10 -0
  65. package/dist/bricks/IconButton.internal.js +22 -0
  66. package/dist/bricks/IconButton.js +24 -19
  67. package/dist/bricks/Kbd.d.ts +2 -2
  68. package/dist/bricks/Kbd.js +3 -3
  69. package/dist/bricks/Label.d.ts +1 -1
  70. package/dist/bricks/Label.js +1 -1
  71. package/dist/bricks/ProgressBar.d.ts +8 -2
  72. package/dist/bricks/Radio.d.ts +2 -2
  73. package/dist/bricks/Radio.js +2 -4
  74. package/dist/bricks/Root.d.ts +1 -1
  75. package/dist/bricks/Root.js +11 -11
  76. package/dist/bricks/Select.d.ts +1 -1
  77. package/dist/bricks/Select.js +4 -7
  78. package/dist/bricks/Skeleton.d.ts +1 -1
  79. package/dist/bricks/Spinner.d.ts +1 -1
  80. package/dist/bricks/Switch.d.ts +2 -2
  81. package/dist/bricks/Switch.js +2 -4
  82. package/dist/bricks/Table.d.ts +1 -1
  83. package/dist/bricks/Table.js +2 -2
  84. package/dist/bricks/Tabs.d.ts +1 -1
  85. package/dist/bricks/Tabs.js +1 -1
  86. package/dist/bricks/Text.d.ts +1 -1
  87. package/dist/bricks/TextBox.d.ts +1 -1
  88. package/dist/bricks/TextBox.js +6 -8
  89. package/dist/bricks/Toolbar.d.ts +36 -0
  90. package/dist/bricks/Toolbar.js +25 -0
  91. package/dist/bricks/Tooltip.d.ts +2 -2
  92. package/dist/bricks/Tooltip.js +4 -4
  93. package/dist/bricks/Tree.d.ts +2 -2
  94. package/dist/bricks/Tree.js +3 -3
  95. package/dist/bricks/TreeItem.d.ts +24 -8
  96. package/dist/bricks/TreeItem.js +243 -164
  97. package/dist/bricks/VisuallyHidden.d.ts +1 -1
  98. package/dist/bricks/VisuallyHidden.js +10 -2
  99. package/dist/bricks/index.d.ts +3 -1
  100. package/dist/bricks/index.js +6 -2
  101. package/dist/bricks/styles.css.js +1 -1
  102. package/dist/bricks/~hooks.js +1 -1
  103. package/dist/bricks/~utils.Dot.d.ts +11 -0
  104. package/dist/bricks/~utils.Dot.js +21 -0
  105. package/dist/bricks/~utils.ListItem.d.ts +1 -1
  106. package/dist/bricks/~utils.ListItem.js +2 -2
  107. package/dist/bricks/~utils.d.ts +1 -1
  108. package/dist/foundations/styles.css.js +1 -1
  109. package/package.json +1 -1
@@ -1,10 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
+ import { Checkbox as AkCheckbox } from "@ariakit/react/checkbox";
2
3
  import cx from "classnames";
3
- import {
4
- Checkbox as AkCheckbox
5
- } from "@ariakit/react/checkbox";
6
- import { forwardRef } from "./~utils.js";
7
4
  import { useFieldControlType } from "./Field.internal.js";
5
+ import { forwardRef } from "./~utils.js";
8
6
  const Switch = forwardRef(
9
7
  (props, forwardedRef) => {
10
8
  useFieldControlType("checkable");
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Role } from "@ariakit/react/role";
3
- import * as React from "react";
4
3
  import cx from "classnames";
5
- import { forwardRef } from "./~utils.js";
4
+ import * as React from "react";
6
5
  import { useMergedRefs, useSafeContext } from "./~hooks.js";
6
+ import { forwardRef } from "./~utils.js";
7
7
  const TableContext = React.createContext(void 0);
8
8
  const TableHeaderContext = React.createContext(false);
9
9
  const HtmlTable = forwardRef((props, forwardedRef) => {
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import cx from "classnames";
3
2
  import * as AkTab from "@ariakit/react/tab";
3
+ import cx from "classnames";
4
4
  import { forwardRef } from "./~utils.js";
5
5
  function Tabs(props) {
6
6
  const {
@@ -1,12 +1,12 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import { Role } from "@ariakit/react/role";
4
2
  import { Focusable } from "@ariakit/react/focusable";
3
+ import { Role } from "@ariakit/react/role";
5
4
  import cx from "classnames";
5
+ import * as React from "react";
6
+ import { useFieldControlType } from "./Field.internal.js";
6
7
  import { Icon } from "./Icon.js";
7
- import { useMergedRefs } from "./~hooks.js";
8
+ import { useEventHandlers, useMergedRefs } from "./~hooks.js";
8
9
  import { forwardRef } from "./~utils.js";
9
- import { useFieldControlType } from "./Field.internal.js";
10
10
  const TextBoxInput = forwardRef(
11
11
  (props, forwardedRef) => {
12
12
  useFieldControlType("textlike");
@@ -72,14 +72,12 @@ const TextBoxRoot = forwardRef(
72
72
  ...props,
73
73
  "data-kiwi-disabled": disabled,
74
74
  className: cx("\u{1F95D}-text-box", props.className),
75
- onPointerDown: (e) => {
76
- props.onPointerDown?.(e);
77
- if (e.defaultPrevented) return;
75
+ onPointerDown: useEventHandlers(props.onPointerDown, (e) => {
78
76
  if (disabled) return;
79
77
  if (e.target !== e.currentTarget) return;
80
78
  e.preventDefault();
81
79
  inputRef.current?.focus();
82
- },
80
+ }),
83
81
  ref: forwardedRef
84
82
  }
85
83
  )
@@ -0,0 +1,27 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as Toolbar from "@ariakit/react/toolbar";
3
+ import cx from "classnames";
4
+ import * as React from "react";
5
+ import { IconButtonContext } from "./IconButton.internal.js";
6
+ import { forwardRef } from "./~utils.js";
7
+ const ToolbarGroup = forwardRef((props, forwardedRef) => {
8
+ return /* @__PURE__ */ jsx(IconButtonContext, { value: React.useMemo(() => ({ iconSize: "large" }), []), children: /* @__PURE__ */ jsx(
9
+ Toolbar.Toolbar,
10
+ {
11
+ ...props,
12
+ className: cx("\u{1F95D}-toolbar", props.className),
13
+ ref: forwardedRef
14
+ }
15
+ ) });
16
+ });
17
+ DEV: ToolbarGroup.displayName = "Toolbar.Group";
18
+ const ToolbarItem = forwardRef(
19
+ (props, forwardedRef) => {
20
+ return /* @__PURE__ */ jsx(Toolbar.ToolbarItem, { ...props, ref: forwardedRef });
21
+ }
22
+ );
23
+ DEV: ToolbarItem.displayName = "Toolbar.Item";
24
+ export {
25
+ ToolbarGroup as Group,
26
+ ToolbarItem as Item
27
+ };
@@ -1,10 +1,10 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import cx from "classnames";
4
- import * as AkTooltip from "@ariakit/react/tooltip";
5
2
  import { useStoreState } from "@ariakit/react/store";
6
- import { forwardRef } from "./~utils.js";
3
+ import * as AkTooltip from "@ariakit/react/tooltip";
4
+ import cx from "classnames";
5
+ import * as React from "react";
7
6
  import { usePopoverApi } from "./~hooks.js";
7
+ import { forwardRef } from "./~utils.js";
8
8
  const Tooltip = forwardRef(
9
9
  (props, forwardedRef) => {
10
10
  const generatedId = React.useId();
@@ -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";
9
- import { Toolbar } from "@ariakit/react/toolbar";
10
- import * as ListItem from "./~utils.ListItem.js";
11
- import { IconButton } from "./IconButton.js";
4
+ import { Role } from "@ariakit/react/role";
5
+ import { Toolbar, ToolbarItem } from "@ariakit/react/toolbar";
6
+ import cx from "classnames";
7
+ import * as React from "react";
12
8
  import * as DropdownMenu from "./DropdownMenu.js";
13
- import { 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,40 +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();
54
- const icon = error ? /* @__PURE__ */ jsx(StatusWarning, {}) : iconProp;
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);
132
+ const errorId = typeof error === "string" ? error : void 0;
55
133
  const describedBy = React.useMemo(() => {
56
- const idRefs = [];
57
- if (description) idRefs.push(descriptionId);
58
- if (unstable_decorations || icon) idRefs.push(decorationId);
59
- return idRefs.length > 0 ? idRefs.join(" ") : void 0;
60
- }, [unstable_decorations, icon, decorationId, description, descriptionId]);
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
+ );
61
147
  return /* @__PURE__ */ jsx(
62
- TreeItemContext.Provider,
148
+ CompositeItem,
63
149
  {
64
- value: React.useMemo(
65
- () => ({
66
- level,
67
- expanded,
68
- selected,
69
- error
70
- }),
71
- [level, expanded, selected, error]
72
- ),
73
- children: /* @__PURE__ */ jsx(
74
- CompositeItem,
150
+ render: /* @__PURE__ */ jsx(
151
+ Role,
75
152
  {
76
- render: /* @__PURE__ */ jsx(Role, { ...rest }),
77
- onClick: useEventHandlers(
78
- onClickProp,
79
- handleClick
80
- ),
81
- onKeyDown: useEventHandlers(
82
- onKeyDownProp,
83
- handleKeyDown
84
- ),
153
+ ...rest,
85
154
  role: "treeitem",
86
155
  "aria-expanded": expanded,
87
156
  "aria-selected": selected,
@@ -89,90 +158,121 @@ const TreeItemRoot = forwardRef(
89
158
  "aria-describedby": describedBy,
90
159
  "aria-level": level,
91
160
  className: cx("\u{1F95D}-tree-item", props.className),
92
- ref: forwardedRef,
93
- children: /* @__PURE__ */ jsxs(
94
- ListItem.Root,
95
- {
96
- "data-kiwi-expanded": expanded,
97
- "data-kiwi-selected": selected,
98
- "data-kiwi-error": error ? true : void 0,
99
- className: "\u{1F95D}-tree-item-node",
100
- style: { "--\u{1F95D}tree-item-level": level },
101
- role: void 0,
102
- children: [
103
- /* @__PURE__ */ jsxs(ListItem.Decoration, { children: [
104
- /* @__PURE__ */ jsx(GhostAligner, { align: description ? "block" : void 0, children: /* @__PURE__ */ jsx(
105
- TreeItemExpander,
106
- {
107
- onClick: () => {
108
- if (expanded === void 0) return;
109
- onExpandedChange?.(!expanded);
110
- }
111
- }
112
- ) }),
113
- icon || unstable_decorations ? /* @__PURE__ */ jsx(
114
- Role,
115
- {
116
- className: "\u{1F95D}-tree-item-decoration",
117
- id: decorationId,
118
- render: React.isValidElement(icon) ? icon : typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : void 0,
119
- children: !icon ? unstable_decorations : null
120
- }
121
- ) : null
122
- ] }),
123
- /* @__PURE__ */ jsx(ListItem.Content, { id: labelId, className: "\u{1F95D}-tree-item-content", children: label }),
124
- description ? /* @__PURE__ */ jsx(
125
- ListItem.Content,
126
- {
127
- id: descriptionId,
128
- className: "\u{1F95D}-tree-item-description",
129
- children: description
130
- }
131
- ) : void 0,
132
- /* @__PURE__ */ jsx(
133
- ListItem.Decoration,
134
- {
135
- render: /* @__PURE__ */ jsx(TreeItemActions, { children: actions })
136
- }
137
- )
138
- ]
139
- }
140
- )
161
+ style,
162
+ ref: forwardedRef
141
163
  }
142
- )
164
+ ),
165
+ children: props.children
143
166
  }
144
167
  );
145
- }
168
+ })
146
169
  );
147
- DEV: TreeItemRoot.displayName = "TreeItem.Root";
148
- const TreeItemActions = forwardRef((props, forwardedRef) => {
149
- const { children, ...rest } = props;
150
- const actions = React.Children.toArray(children).filter(Boolean);
151
- const { error } = useSafeContext(TreeItemContext);
152
- 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);
153
174
  return /* @__PURE__ */ jsxs(
154
- Toolbar,
175
+ ListItem.Root,
155
176
  {
156
- ...rest,
157
- onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
158
- onKeyDown: useEventHandlers(props.onKeyDown, (e) => e.stopPropagation()),
159
- className: cx("\u{1F95D}-tree-item-actions-container", props.className),
160
- focusLoop: false,
161
- 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,
162
182
  children: [
163
- actions.slice(0, limit - 1),
164
- actions.length === limit ? actions[limit - 1] : null,
165
- 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, {})
166
187
  ]
167
188
  }
168
189
  );
169
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
+ );
170
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";
171
269
  const arrowKeys = ["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"];
172
270
  const TreeItemActionsOverflowMenuContext = React.createContext(false);
173
- function TreeItemActionsOverflowMenu({ children }) {
271
+ function TreeItemActionsOverflowMenu() {
272
+ const overflow = React.useContext(TreeItemHasOverflowActionsContext);
174
273
  const [open, setOpen] = React.useState(false);
175
274
  const isArrowKeyPressed = React.useRef(false);
275
+ if (!overflow) return null;
176
276
  return /* @__PURE__ */ jsx(PopoverProvider, { placement: "right-start", children: /* @__PURE__ */ jsxs(
177
277
  DropdownMenu.Root,
178
278
  {
@@ -199,20 +299,26 @@ function TreeItemActionsOverflowMenu({ children }) {
199
299
  render: /* @__PURE__ */ jsx(TreeItemAction, { label: "More", icon: /* @__PURE__ */ jsx(MoreHorizontal, {}) })
200
300
  }
201
301
  ),
202
- /* @__PURE__ */ jsx(TreeItemActionsOverflowMenuContext.Provider, { value: true, children: /* @__PURE__ */ jsx(DropdownMenu.Content, { children }) })
302
+ /* @__PURE__ */ jsx(TreeItemActionsOverflowMenuContext.Provider, { value: true, children: /* @__PURE__ */ jsx(TreeItemActionsOverflowMenuContent, {}) })
203
303
  ]
204
304
  }
205
305
  ) });
206
306
  }
207
307
  DEV: TreeItemActionsOverflowMenu.displayName = "TreeItemActionsOverflowMenu";
208
- const TreeItemAction = forwardRef(
209
- (props, forwardedRef) => {
210
- 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);
211
316
  const {
212
317
  visible = error ? true : void 0,
213
318
  // visible by default during error state
214
319
  label,
215
320
  icon,
321
+ dot,
216
322
  ...rest
217
323
  } = props;
218
324
  if (React.useContext(TreeItemActionsOverflowMenuContext)) {
@@ -226,6 +332,7 @@ const TreeItemAction = forwardRef(
226
332
  ...rest,
227
333
  label,
228
334
  icon,
335
+ unstable_dot: dot,
229
336
  ref: forwardedRef
230
337
  }
231
338
  );
@@ -237,70 +344,51 @@ const TreeItemAction = forwardRef(
237
344
  );
238
345
  }
239
346
  return /* @__PURE__ */ jsx(
240
- IconButton,
347
+ ToolbarItem,
241
348
  {
242
- label,
243
- icon,
244
- inert: visible === false ? true : void 0,
245
- ...rest,
246
- variant: "ghost",
247
- className: cx("\u{1F95D}-tree-item-action", props.className),
248
- "data-kiwi-visible": visible,
249
- ref: forwardedRef
349
+ render: /* @__PURE__ */ jsx(
350
+ IconButton,
351
+ {
352
+ label,
353
+ icon,
354
+ inert: visible === false ? true : void 0,
355
+ ...rest,
356
+ dot,
357
+ variant: "ghost",
358
+ className: cx("\u{1F95D}-tree-item-action", props.className),
359
+ "data-kiwi-visible": visible,
360
+ ref: forwardedRef
361
+ }
362
+ )
250
363
  }
251
364
  );
252
- }
365
+ })
253
366
  );
254
367
  DEV: TreeItemAction.displayName = "TreeItem.Action";
255
368
  const TreeItemExpander = forwardRef(
256
369
  (props, forwardedRef) => {
370
+ const descriptionId = React.useContext(TreeItemDescriptionIdContext);
257
371
  return /* @__PURE__ */ jsx(
258
- Role.span,
372
+ IconButtonPresentation,
259
373
  {
260
374
  "aria-hidden": "true",
261
375
  ...props,
262
376
  onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
263
377
  className: cx(
264
- "\u{1F95D}-button",
265
- "\u{1F95D}-icon-button",
266
378
  "\u{1F95D}-ghost-aligner",
267
379
  "\u{1F95D}-tree-item-expander",
268
380
  props.className
269
381
  ),
270
- "data-kiwi-variant": "ghost",
271
- "data-kiwi-ghost-align": useGhostAlignment(),
382
+ variant: "ghost",
383
+ "data-kiwi-ghost-align": descriptionId ? "block" : void 0,
272
384
  ref: forwardedRef,
273
- children: /* @__PURE__ */ jsx(TreeChevron, {})
385
+ children: /* @__PURE__ */ jsx(ChevronDown, {})
274
386
  }
275
387
  );
276
388
  }
277
389
  );
278
390
  DEV: TreeItemExpander.displayName = "TreeItemExpander";
279
- const TreeChevron = forwardRef(
280
- (props, forwardedRef) => {
281
- return /* @__PURE__ */ jsx(
282
- Icon,
283
- {
284
- ...props,
285
- render: /* @__PURE__ */ jsx(
286
- Role.svg,
287
- {
288
- width: "16",
289
- height: "16",
290
- fill: "currentColor",
291
- viewBox: "0 0 16 16",
292
- render: props.render,
293
- children: /* @__PURE__ */ jsx("path", { d: "M4.146 6.146a.5.5 0 0 1 .708 0L8 9.293l3.146-3.147a.5.5 0 0 1 .708.708l-3.5 3.5a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 0 1 0-.708Z" })
294
- }
295
- ),
296
- className: cx("\u{1F95D}-tree-chevron", props.className),
297
- ref: forwardedRef
298
- }
299
- );
300
- }
301
- );
302
- DEV: TreeChevron.displayName = "TreeChevron";
303
391
  export {
304
392
  TreeItemAction as Action,
305
- TreeItemRoot as Root
393
+ TreeItem as Root
306
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";