@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,4 +1,4 @@
1
- import { type BaseProps } from "./~utils.js";
1
+ import type { BaseProps } from "./~utils.js";
2
2
  interface TextProps extends BaseProps {
3
3
  /**
4
4
  * The typography variant to use.
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Icon } from "./Icon.js";
3
- import { type FocusableProps, type BaseProps } from "./~utils.js";
3
+ import type { BaseProps, FocusableProps } from "./~utils.js";
4
4
  interface BaseInputProps extends FocusableProps<"input"> {
5
5
  }
6
6
  interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
@@ -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");
@@ -70,14 +70,12 @@ const TextBoxRoot = forwardRef(
70
70
  ...props,
71
71
  "data-kiwi-disabled": disabled,
72
72
  className: cx("\u{1F95D}-text-box", props.className),
73
- onPointerDown: (e) => {
74
- props.onPointerDown?.(e);
75
- if (e.defaultPrevented) return;
73
+ onPointerDown: useEventHandlers(props.onPointerDown, (e) => {
76
74
  if (disabled) return;
77
75
  if (e.target !== e.currentTarget) return;
78
76
  e.preventDefault();
79
77
  inputRef.current?.focus();
80
- },
78
+ }),
81
79
  ref: forwardedRef
82
80
  }
83
81
  )
@@ -1,4 +1,5 @@
1
- import { type BaseProps } from "./~utils.js";
1
+ import * as React from "react";
2
+ import type { BaseProps } from "./~utils.js";
2
3
  interface ToolbarProps extends BaseProps {
3
4
  /** Must be set to `"solid"` for now. */
4
5
  variant: "solid";
@@ -17,7 +18,7 @@ interface ToolbarProps extends BaseProps {
17
18
  * </Toolbar.Group>
18
19
  * ```
19
20
  */
20
- declare const ToolbarGroup: import("react").ForwardRefExoticComponent<ToolbarProps & import("react").RefAttributes<HTMLElement | HTMLDivElement>>;
21
+ declare const ToolbarGroup: React.ForwardRefExoticComponent<ToolbarProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
21
22
  interface ToolbarItemProps extends Omit<BaseProps<"button">, "render">, Required<Pick<BaseProps, "render">> {
22
23
  }
23
24
  /**
@@ -31,5 +32,5 @@ interface ToolbarItemProps extends Omit<BaseProps<"button">, "render">, Required
31
32
  * />
32
33
  * ```
33
34
  */
34
- declare const ToolbarItem: import("react").ForwardRefExoticComponent<ToolbarItemProps & import("react").RefAttributes<HTMLElement | HTMLButtonElement>>;
35
+ declare const ToolbarItem: React.ForwardRefExoticComponent<ToolbarItemProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
35
36
  export { ToolbarGroup as Group, ToolbarItem as Item };
@@ -1,16 +1,18 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import cx from "classnames";
3
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";
4
6
  import { forwardRef } from "./~utils.js";
5
7
  const ToolbarGroup = forwardRef((props, forwardedRef) => {
6
- return /* @__PURE__ */ jsx(
8
+ return /* @__PURE__ */ jsx(IconButtonContext, { value: React.useMemo(() => ({ iconSize: "large" }), []), children: /* @__PURE__ */ jsx(
7
9
  Toolbar.Toolbar,
8
10
  {
9
11
  ...props,
10
12
  className: cx("\u{1F95D}-toolbar", props.className),
11
13
  ref: forwardedRef
12
14
  }
13
- );
15
+ ) });
14
16
  });
15
17
  const ToolbarItem = forwardRef(
16
18
  (props, forwardedRef) => {
@@ -1,6 +1,6 @@
1
- import * as React from "react";
2
1
  import * as AkTooltip from "@ariakit/react/tooltip";
3
- import { type FocusableProps } from "./~utils.js";
2
+ import * as React from "react";
3
+ import type { FocusableProps } from "./~utils.js";
4
4
  interface TooltipProps extends Omit<FocusableProps<"div">, "content">, Pick<AkTooltip.TooltipProps, "open" | "unmountOnHide">, Pick<AkTooltip.TooltipProviderProps, "defaultOpen" | "setOpen"> {
5
5
  /**
6
6
  * The content to be displayed inside the tooltip when the trigger element is hovered or focused.
@@ -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,5 +1,5 @@
1
- import { type BaseProps } from "./~utils.js";
2
- import { Root as TreeItemRoot, Action as TreeItemAction } from "./TreeItem.js";
1
+ import { Action as TreeItemAction, Root as TreeItemRoot } from "./TreeItem.js";
2
+ import type { BaseProps } from "./~utils.js";
3
3
  interface TreeProps extends BaseProps {
4
4
  }
5
5
  /**
@@ -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,6 +1,6 @@
1
1
  import * as React from "react";
2
- import { type BaseProps } from "./~utils.js";
3
- interface TreeItemRootProps extends Omit<BaseProps, "content" | "children"> {
2
+ import type { BaseProps } from "./~utils.js";
3
+ interface TreeItemProps extends Omit<BaseProps, "content" | "children"> {
4
4
  /** Specifies the nesting level of the tree item. Nesting levels start at 1. */
5
5
  "aria-level": number;
6
6
  /** Defines tree item position in the current level of tree items. Integer greater than or equal to 1. */
@@ -128,7 +128,7 @@ interface TreeItemRootProps extends Omit<BaseProps, "content" | "children"> {
128
128
  *
129
129
  * Secondary actions can be passed into the `actions` prop.
130
130
  */
131
- declare const TreeItemRoot: React.ForwardRefExoticComponent<TreeItemRootProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
131
+ declare const TreeItem: React.NamedExoticComponent<TreeItemProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
132
132
  interface TreeItemActionProps extends Omit<BaseProps<"button">, "children"> {
133
133
  /**
134
134
  * Label for the action.
@@ -179,5 +179,5 @@ interface TreeItemActionProps extends Omit<BaseProps<"button">, "children"> {
179
179
  * By default, the action appears only when the treeitem has hover/focus or an error. This behavior can
180
180
  * be overridden using the `visible` prop.
181
181
  */
182
- declare const TreeItemAction: React.ForwardRefExoticComponent<TreeItemActionProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
183
- export { TreeItemRoot as Root, TreeItemAction as Action };
182
+ declare const TreeItemAction: React.NamedExoticComponent<TreeItemActionProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
183
+ export { TreeItem as Root, TreeItemAction as Action };
@@ -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,91 @@ 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
+ function TreeItemRootProvider(props) {
90
+ const {
91
+ actions,
92
+ label,
93
+ description,
94
+ icon: iconProp,
95
+ unstable_decorations: decorations,
96
+ error
97
+ } = props;
98
+ const labelId = React.useId();
99
+ const descriptionId = React.useId();
100
+ const decorationId = React.useId();
101
+ const icon = error ? /* @__PURE__ */ jsx(StatusWarning, {}) : iconProp;
102
+ const hasDecoration = icon || decorations;
103
+ return /* @__PURE__ */ jsx(TreeItemErrorContext.Provider, { value: error, children: /* @__PURE__ */ jsx(TreeItemActionsContext.Provider, { value: actions, children: /* @__PURE__ */ jsx(
104
+ TreeItemDecorationIdContext.Provider,
105
+ {
106
+ value: hasDecoration ? decorationId : void 0,
107
+ 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(
108
+ TreeItemDescriptionIdContext.Provider,
109
+ {
110
+ value: description ? descriptionId : void 0,
111
+ children: props.children
112
+ }
113
+ ) }) }) }) }) })
114
+ }
115
+ ) }) });
116
+ }
117
+ const TreeItemRoot = React.memo(
118
+ forwardRef((props, forwardedRef) => {
119
+ const {
120
+ style: styleProp,
121
+ "aria-level": level,
122
+ selected,
123
+ expanded,
124
+ ...rest
125
+ } = props;
126
+ const labelId = React.useContext(TreeItemLabelIdContext);
127
+ const decorationId = React.useContext(TreeItemDecorationIdContext);
128
+ const descriptionId = React.useContext(TreeItemDescriptionIdContext);
129
+ const error = React.useContext(TreeItemErrorContext);
54
130
  const errorId = typeof error === "string" ? error : void 0;
55
- const icon = error ? /* @__PURE__ */ jsx(StatusWarning, {}) : iconProp;
56
131
  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
- ]);
132
+ const ids = [];
133
+ if (descriptionId) ids.push(descriptionId);
134
+ if (decorationId) ids.push(decorationId);
135
+ if (errorId) ids.push(errorId);
136
+ return ids.length > 0 ? ids.join(" ") : void 0;
137
+ }, [decorationId, descriptionId, errorId]);
138
+ const style = React.useMemo(
139
+ () => ({
140
+ ...styleProp,
141
+ "--\u{1F95D}tree-item-level": level
142
+ }),
143
+ [styleProp, level]
144
+ );
70
145
  return /* @__PURE__ */ jsx(
71
- TreeItemContext.Provider,
146
+ CompositeItem,
72
147
  {
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,
148
+ render: /* @__PURE__ */ jsx(
149
+ Role,
84
150
  {
85
- render: /* @__PURE__ */ jsx(Role, { ...rest }),
86
- onClick: useEventHandlers(
87
- onClickProp,
88
- handleClick
89
- ),
90
- onKeyDown: useEventHandlers(
91
- onKeyDownProp,
92
- handleKeyDown
93
- ),
151
+ ...rest,
94
152
  role: "treeitem",
95
153
  "aria-expanded": expanded,
96
154
  "aria-selected": selected,
@@ -98,88 +156,112 @@ const TreeItemRoot = forwardRef(
98
156
  "aria-describedby": describedBy,
99
157
  "aria-level": level,
100
158
  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
- )
159
+ style,
160
+ ref: forwardedRef
150
161
  }
151
- )
162
+ ),
163
+ children: props.children
152
164
  }
153
165
  );
154
- }
166
+ })
155
167
  );
156
- const TreeItemActions = forwardRef((props, forwardedRef) => {
157
- const { children, ...rest } = props;
158
- const actions = React.Children.toArray(children).filter(Boolean);
159
- const { error } = useSafeContext(TreeItemContext);
160
- const limit = error ? 2 : 3;
168
+ const TreeItemNode = React.memo((props) => {
169
+ const { expanded, selected, onExpanderClick } = props;
170
+ const error = React.useContext(TreeItemErrorContext);
161
171
  return /* @__PURE__ */ jsxs(
162
- Toolbar,
172
+ ListItem.Root,
163
173
  {
164
- ...rest,
165
- onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
166
- onKeyDown: useEventHandlers(props.onKeyDown, (e) => e.stopPropagation()),
167
- className: cx("\u{1F95D}-tree-item-actions-container", props.className),
168
- focusLoop: false,
169
- ref: forwardedRef,
174
+ "data-kiwi-expanded": expanded,
175
+ "data-kiwi-selected": selected,
176
+ "data-kiwi-error": error ? true : void 0,
177
+ className: "\u{1F95D}-tree-item-node",
178
+ role: void 0,
170
179
  children: [
171
- actions.slice(0, limit - 1),
172
- actions.length === limit ? actions[limit - 1] : null,
173
- actions.length > limit ? /* @__PURE__ */ jsx(TreeItemActionsOverflowMenu, { children: actions.slice(limit - 1) }) : null
180
+ /* @__PURE__ */ jsx(TreeItemDecorations, { onExpanderClick }),
181
+ /* @__PURE__ */ jsx(TreeItemContent, {}),
182
+ /* @__PURE__ */ jsx(TreeItemDescription, {}),
183
+ /* @__PURE__ */ jsx(TreeItemActions, {})
174
184
  ]
175
185
  }
176
186
  );
177
187
  });
188
+ const TreeItemDecorations = React.memo((props) => {
189
+ return /* @__PURE__ */ jsxs(ListItem.Decoration, { children: [
190
+ /* @__PURE__ */ jsx(TreeItemExpander, { onClick: props.onExpanderClick }),
191
+ /* @__PURE__ */ jsx(TreeItemDecoration, {})
192
+ ] });
193
+ });
194
+ function TreeItemDecoration() {
195
+ const decorationId = React.useContext(TreeItemDecorationIdContext);
196
+ const decorations = React.useContext(TreeItemDecorationsContext);
197
+ const icon = React.useContext(TreeItemIconContext);
198
+ return icon || decorations ? /* @__PURE__ */ jsx(
199
+ Role,
200
+ {
201
+ className: "\u{1F95D}-tree-item-decoration",
202
+ id: decorationId,
203
+ render: React.isValidElement(icon) ? icon : typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : void 0,
204
+ children: !icon ? decorations : null
205
+ }
206
+ ) : null;
207
+ }
208
+ const TreeItemContent = React.memo(() => {
209
+ const labelId = React.useContext(TreeItemLabelIdContext);
210
+ const label = React.useContext(TreeItemLabelContext);
211
+ return /* @__PURE__ */ jsx(ListItem.Content, { id: labelId, className: "\u{1F95D}-tree-item-content", children: label });
212
+ });
213
+ const TreeItemDescription = React.memo(() => {
214
+ const description = React.useContext(TreeItemDescriptionContext);
215
+ const descriptionId = React.useContext(TreeItemDescriptionIdContext);
216
+ return description ? /* @__PURE__ */ jsx(ListItem.Content, { id: descriptionId, className: "\u{1F95D}-tree-item-description", children: description }) : void 0;
217
+ });
218
+ const TreeItemActions = React.memo(
219
+ forwardRef((props, forwardedRef) => {
220
+ return /* @__PURE__ */ jsx(TreeItemActionsProvider, { children: /* @__PURE__ */ jsx(
221
+ ListItem.Decoration,
222
+ {
223
+ ...props,
224
+ onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
225
+ onKeyDown: useEventHandlers(
226
+ props.onKeyDown,
227
+ (e) => e.stopPropagation()
228
+ ),
229
+ className: cx("\u{1F95D}-tree-item-actions-container", props.className),
230
+ ref: forwardedRef,
231
+ render: /* @__PURE__ */ jsxs(Toolbar, { focusLoop: false, children: [
232
+ /* @__PURE__ */ jsx(TreeItemInlineActions, {}),
233
+ /* @__PURE__ */ jsx(TreeItemActionsOverflowMenu, {})
234
+ ] })
235
+ }
236
+ ) });
237
+ })
238
+ );
239
+ function TreeItemActionsProvider(props) {
240
+ const actionsProp = React.useContext(TreeItemActionsContext);
241
+ const error = React.useContext(TreeItemErrorContext);
242
+ const actionsLimit = error ? 2 : 3;
243
+ const { inline, overflow } = React.useMemo(() => {
244
+ const actions = React.Children.toArray(actionsProp).filter(Boolean);
245
+ const inline2 = /* @__PURE__ */ jsxs(Fragment, { children: [
246
+ actions.slice(0, actionsLimit - 1),
247
+ actions.length === actionsLimit ? actions[actionsLimit - 1] : null
248
+ ] });
249
+ const overflow2 = actions.length > actionsLimit ? actions.slice(actionsLimit - 1) : void 0;
250
+ return { inline: inline2, overflow: overflow2 };
251
+ }, [actionsProp, actionsLimit]);
252
+ return /* @__PURE__ */ jsx(TreeItemInlineActionsContext.Provider, { value: inline, children: /* @__PURE__ */ jsx(TreeItemOverflowActionsContext.Provider, { value: overflow, children: /* @__PURE__ */ jsx(TreeItemHasOverflowActionsContext.Provider, { value: !!overflow, children: props.children }) }) });
253
+ }
254
+ function TreeItemInlineActions() {
255
+ const actions = React.useContext(TreeItemInlineActionsContext);
256
+ return actions;
257
+ }
178
258
  const arrowKeys = ["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"];
179
259
  const TreeItemActionsOverflowMenuContext = React.createContext(false);
180
- function TreeItemActionsOverflowMenu({ children }) {
260
+ function TreeItemActionsOverflowMenu() {
261
+ const overflow = React.useContext(TreeItemHasOverflowActionsContext);
181
262
  const [open, setOpen] = React.useState(false);
182
263
  const isArrowKeyPressed = React.useRef(false);
264
+ if (!overflow) return null;
183
265
  return /* @__PURE__ */ jsx(PopoverProvider, { placement: "right-start", children: /* @__PURE__ */ jsxs(
184
266
  DropdownMenu.Root,
185
267
  {
@@ -206,14 +288,18 @@ function TreeItemActionsOverflowMenu({ children }) {
206
288
  render: /* @__PURE__ */ jsx(TreeItemAction, { label: "More", icon: /* @__PURE__ */ jsx(MoreHorizontal, {}) })
207
289
  }
208
290
  ),
209
- /* @__PURE__ */ jsx(TreeItemActionsOverflowMenuContext.Provider, { value: true, children: /* @__PURE__ */ jsx(DropdownMenu.Content, { children }) })
291
+ /* @__PURE__ */ jsx(TreeItemActionsOverflowMenuContext.Provider, { value: true, children: /* @__PURE__ */ jsx(TreeItemActionsOverflowMenuContent, {}) })
210
292
  ]
211
293
  }
212
294
  ) });
213
295
  }
214
- const TreeItemAction = forwardRef(
215
- (props, forwardedRef) => {
216
- const { error } = useSafeContext(TreeItemContext);
296
+ function TreeItemActionsOverflowMenuContent() {
297
+ const actions = React.useContext(TreeItemOverflowActionsContext);
298
+ return /* @__PURE__ */ jsx(DropdownMenu.Content, { children: actions });
299
+ }
300
+ const TreeItemAction = React.memo(
301
+ forwardRef((props, forwardedRef) => {
302
+ const error = React.useContext(TreeItemErrorContext);
217
303
  const {
218
304
  visible = error ? true : void 0,
219
305
  // visible by default during error state
@@ -253,25 +339,24 @@ const TreeItemAction = forwardRef(
253
339
  )
254
340
  }
255
341
  );
256
- }
342
+ })
257
343
  );
258
344
  const TreeItemExpander = forwardRef(
259
345
  (props, forwardedRef) => {
346
+ const descriptionId = React.useContext(TreeItemDescriptionIdContext);
260
347
  return /* @__PURE__ */ jsx(
261
- Role.span,
348
+ IconButtonPresentation,
262
349
  {
263
350
  "aria-hidden": "true",
264
351
  ...props,
265
352
  onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
266
353
  className: cx(
267
- "\u{1F95D}-button",
268
- "\u{1F95D}-icon-button",
269
354
  "\u{1F95D}-ghost-aligner",
270
355
  "\u{1F95D}-tree-item-expander",
271
356
  props.className
272
357
  ),
273
- "data-kiwi-variant": "ghost",
274
- "data-kiwi-ghost-align": useGhostAlignment(),
358
+ variant: "ghost",
359
+ "data-kiwi-ghost-align": descriptionId ? "block" : void 0,
275
360
  ref: forwardedRef,
276
361
  children: /* @__PURE__ */ jsx(ChevronDown, {})
277
362
  }
@@ -280,5 +365,5 @@ const TreeItemExpander = forwardRef(
280
365
  );
281
366
  export {
282
367
  TreeItemAction as Action,
283
- TreeItemRoot as Root
368
+ TreeItem as Root
284
369
  };
@@ -1,4 +1,4 @@
1
- import { type BaseProps } from "./~utils.js";
1
+ import type { BaseProps } from "./~utils.js";
2
2
  interface VisuallyHiddenProps extends BaseProps<"span"> {
3
3
  }
4
4
  /**
@@ -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
  export {