@itwin/itwinui-react 5.0.0-alpha.8 → 5.0.0-alpha.9

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 (83) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/LICENSE.md +1 -1
  3. package/dist/DEV/bricks/Anchor.js +4 -9
  4. package/dist/DEV/bricks/Avatar.js +2 -2
  5. package/dist/DEV/bricks/Badge.js +2 -2
  6. package/dist/DEV/bricks/Button.js +10 -3
  7. package/dist/DEV/bricks/Checkbox.js +4 -2
  8. package/dist/DEV/bricks/Chip.js +2 -2
  9. package/dist/DEV/bricks/Divider.js +3 -2
  10. package/dist/DEV/bricks/DropdownMenu.js +79 -19
  11. package/dist/DEV/bricks/Field.js +21 -17
  12. package/dist/DEV/bricks/Icon.js +5 -5
  13. package/dist/DEV/bricks/IconButton.js +14 -6
  14. package/dist/DEV/bricks/Kbd.internal.js +19 -0
  15. package/dist/DEV/bricks/Kbd.js +3 -18
  16. package/dist/DEV/bricks/Label.js +2 -2
  17. package/dist/DEV/bricks/Radio.js +4 -2
  18. package/dist/DEV/bricks/Root.js +35 -4
  19. package/dist/DEV/bricks/Select.js +3 -3
  20. package/dist/DEV/bricks/Spinner.js +2 -2
  21. package/dist/DEV/bricks/Switch.js +4 -2
  22. package/dist/DEV/bricks/Table.js +7 -7
  23. package/dist/DEV/bricks/Tabs.js +5 -5
  24. package/dist/DEV/bricks/Text.js +2 -2
  25. package/dist/DEV/bricks/TextBox.js +8 -7
  26. package/dist/DEV/bricks/Tooltip.js +5 -5
  27. package/dist/DEV/bricks/Tree.js +8 -195
  28. package/dist/DEV/bricks/TreeItem.js +219 -0
  29. package/dist/DEV/bricks/VisuallyHidden.js +2 -2
  30. package/dist/DEV/bricks/styles.css.js +1 -1
  31. package/dist/DEV/bricks/~hooks.js +11 -6
  32. package/dist/DEV/bricks/~utils.GhostAligner.js +13 -0
  33. package/dist/DEV/bricks/{ListItem.js → ~utils.ListItem.js} +3 -3
  34. package/dist/bricks/Anchor.js +4 -9
  35. package/dist/bricks/Avatar.js +2 -2
  36. package/dist/bricks/Badge.js +2 -2
  37. package/dist/bricks/Button.js +10 -3
  38. package/dist/bricks/Checkbox.d.ts +2 -2
  39. package/dist/bricks/Checkbox.js +4 -2
  40. package/dist/bricks/Chip.js +2 -2
  41. package/dist/bricks/Divider.d.ts +2 -2
  42. package/dist/bricks/Divider.js +3 -2
  43. package/dist/bricks/DropdownMenu.d.ts +38 -23
  44. package/dist/bricks/DropdownMenu.js +77 -19
  45. package/dist/bricks/Field.d.ts +5 -5
  46. package/dist/bricks/Field.js +21 -17
  47. package/dist/bricks/Icon.js +5 -5
  48. package/dist/bricks/IconButton.d.ts +18 -2
  49. package/dist/bricks/IconButton.js +14 -6
  50. package/dist/bricks/Kbd.d.ts +2 -17
  51. package/dist/bricks/Kbd.internal.d.ts +17 -0
  52. package/dist/bricks/Kbd.internal.js +19 -0
  53. package/dist/bricks/Kbd.js +3 -18
  54. package/dist/bricks/Label.js +2 -2
  55. package/dist/bricks/Radio.d.ts +2 -2
  56. package/dist/bricks/Radio.js +4 -2
  57. package/dist/bricks/Root.js +35 -4
  58. package/dist/bricks/Select.d.ts +1 -2
  59. package/dist/bricks/Select.js +3 -3
  60. package/dist/bricks/Spinner.js +2 -2
  61. package/dist/bricks/Switch.d.ts +2 -2
  62. package/dist/bricks/Switch.js +4 -2
  63. package/dist/bricks/Table.js +7 -7
  64. package/dist/bricks/Tabs.d.ts +4 -4
  65. package/dist/bricks/Tabs.js +5 -5
  66. package/dist/bricks/Text.js +2 -2
  67. package/dist/bricks/TextBox.js +8 -7
  68. package/dist/bricks/Tooltip.d.ts +2 -2
  69. package/dist/bricks/Tooltip.js +5 -5
  70. package/dist/bricks/Tree.d.ts +3 -110
  71. package/dist/bricks/Tree.js +8 -190
  72. package/dist/bricks/TreeItem.d.ts +123 -0
  73. package/dist/bricks/TreeItem.js +214 -0
  74. package/dist/bricks/VisuallyHidden.js +2 -2
  75. package/dist/bricks/styles.css.js +1 -1
  76. package/dist/bricks/~hooks.d.ts +11 -2
  77. package/dist/bricks/~hooks.js +11 -6
  78. package/dist/bricks/~utils.GhostAligner.d.ts +22 -0
  79. package/dist/bricks/~utils.GhostAligner.js +13 -0
  80. package/dist/bricks/{ListItem.d.ts → ~utils.ListItem.d.ts} +5 -5
  81. package/dist/bricks/{ListItem.js → ~utils.ListItem.js} +3 -3
  82. package/dist/bricks/~utils.d.ts +6 -3
  83. package/package.json +1 -1
@@ -1,19 +1,30 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import * as Ariakit from "@ariakit/react";
3
+ import * as ReactDOM from "react-dom";
4
+ import { Role } from "@ariakit/react/role";
5
+ import { PortalContext } from "@ariakit/react/portal";
4
6
  import cx from "classnames";
5
7
  import foundationsCss from "../foundations/styles.css.js";
6
8
  import bricksCss from "./styles.css.js";
7
9
  import { forwardRef, isBrowser } from "./~utils.js";
8
- import { useMergedRefs } from "./~hooks.js";
10
+ import { useIsClient, useMergedRefs } from "./~hooks.js";
9
11
  const css = foundationsCss + bricksCss;
10
12
  const Root = forwardRef((props, forwardedRef) => {
11
13
  const { children, synchronizeColorScheme = false, ...rest } = props;
14
+ const [portalContainer, setPortalContainer] = React.useState(null);
12
15
  return /* @__PURE__ */ jsxs(RootInternal, { ...rest, ref: forwardedRef, children: [
13
16
  /* @__PURE__ */ jsx(Styles, {}),
14
17
  /* @__PURE__ */ jsx(Fonts, {}),
15
18
  synchronizeColorScheme ? /* @__PURE__ */ jsx(SynchronizeColorScheme, { colorScheme: props.colorScheme }) : null,
16
- children
19
+ /* @__PURE__ */ jsx(
20
+ PortalContainer,
21
+ {
22
+ colorScheme: props.colorScheme,
23
+ density: props.density,
24
+ ref: setPortalContainer
25
+ }
26
+ ),
27
+ /* @__PURE__ */ jsx(PortalContext.Provider, { value: portalContainer, children })
17
28
  ] });
18
29
  });
19
30
  DEV: Root.displayName = "Root";
@@ -32,7 +43,7 @@ const RootInternal = forwardRef(
32
43
  setRootNode(rootNode2);
33
44
  }, []);
34
45
  return /* @__PURE__ */ jsx(
35
- Ariakit.Role,
46
+ Role,
36
47
  {
37
48
  ...rest,
38
49
  className: cx("\u{1F95D}-root", props.className),
@@ -60,6 +71,26 @@ function SynchronizeColorScheme({
60
71
  }, [rootNode, colorScheme]);
61
72
  return null;
62
73
  }
74
+ const PortalContainer = forwardRef((props, forwardedRef) => {
75
+ const isClient = useIsClient();
76
+ const rootNode = useRootNode();
77
+ if (!isClient) return null;
78
+ const destination = rootNode && isDocument(rootNode) ? rootNode.body : rootNode;
79
+ if (!destination) return null;
80
+ return ReactDOM.createPortal(
81
+ /* @__PURE__ */ jsx(
82
+ "div",
83
+ {
84
+ className: "\u{1F95D}-root",
85
+ "data-kiwi-theme": props.colorScheme,
86
+ "data-kiwi-density": props.density,
87
+ style: { display: "contents" },
88
+ ref: forwardedRef
89
+ }
90
+ ),
91
+ destination
92
+ );
93
+ });
63
94
  function Styles() {
64
95
  const rootNode = useRootNode();
65
96
  useLayoutEffect(() => {
@@ -1,7 +1,7 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import cx from "classnames";
4
- import * as Ariakit from "@ariakit/react";
4
+ import { Role } from "@ariakit/react/role";
5
5
  import {
6
6
  forwardRef,
7
7
  isBrowser
@@ -14,7 +14,7 @@ const HtmlSelectContext = React.createContext(() => {
14
14
  const SelectRoot = forwardRef((props, forwardedRef) => {
15
15
  const [isHtmlSelect, setIsHtmlSelect] = React.useState(false);
16
16
  return /* @__PURE__ */ jsx(HtmlSelectContext.Provider, { value: setIsHtmlSelect, children: /* @__PURE__ */ jsx(
17
- Ariakit.Role.div,
17
+ Role.div,
18
18
  {
19
19
  ...props,
20
20
  className: cx("\u{1F95D}-select-root", props.className),
@@ -40,7 +40,7 @@ const HtmlSelect = forwardRef(
40
40
  type: "textlike",
41
41
  id,
42
42
  render: /* @__PURE__ */ jsx(
43
- Ariakit.Role.select,
43
+ Role.select,
44
44
  {
45
45
  ...rest,
46
46
  className: cx("\u{1F95D}-button", "\u{1F95D}-select", props.className),
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import * as Ariakit from "@ariakit/react";
2
+ import { Role } from "@ariakit/react/role";
3
3
  import cx from "classnames";
4
4
  import { VisuallyHidden } from "./VisuallyHidden.js";
5
5
  import { forwardRef } from "./~utils.js";
@@ -12,7 +12,7 @@ const Spinner = forwardRef(
12
12
  ...rest
13
13
  } = props;
14
14
  return /* @__PURE__ */ jsxs(
15
- Ariakit.Role,
15
+ Role,
16
16
  {
17
17
  ...rest,
18
18
  "data-kiwi-size": size,
@@ -1,6 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import cx from "classnames";
3
- import * as Ariakit from "@ariakit/react";
3
+ import {
4
+ Checkbox as AkCheckbox
5
+ } from "@ariakit/react/checkbox";
4
6
  import { FieldControl } from "./Field.js";
5
7
  import { forwardRef } from "./~utils.js";
6
8
  const Switch = forwardRef(
@@ -12,7 +14,7 @@ const Switch = forwardRef(
12
14
  type: "checkable",
13
15
  id,
14
16
  render: /* @__PURE__ */ jsx(
15
- Ariakit.Checkbox,
17
+ AkCheckbox,
16
18
  {
17
19
  accessibleWhenDisabled: true,
18
20
  ...rest,
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as Ariakit from "@ariakit/react";
2
+ import { Role } from "@ariakit/react/role";
3
3
  import * as React from "react";
4
4
  import cx from "classnames";
5
5
  import { forwardRef } from "./~utils.js";
@@ -12,7 +12,7 @@ const Table = forwardRef((props, forwardedRef) => {
12
12
  const [captionId, setCaptionId] = React.useState();
13
13
  const tableContext = React.useMemo(() => ({ setCaptionId }), []);
14
14
  return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContext, children: /* @__PURE__ */ jsx(
15
- Ariakit.Role,
15
+ Role,
16
16
  {
17
17
  ...props,
18
18
  className: cx("\u{1F95D}-table", props.className),
@@ -28,7 +28,7 @@ const TableHeaderContext = React.createContext(false);
28
28
  const TableHeader = forwardRef(
29
29
  (props, forwardedRef) => {
30
30
  return /* @__PURE__ */ jsx(TableHeaderContext.Provider, { value: true, children: /* @__PURE__ */ jsx(
31
- Ariakit.Role.div,
31
+ Role.div,
32
32
  {
33
33
  ...props,
34
34
  className: cx("\u{1F95D}-table-header", props.className),
@@ -42,7 +42,7 @@ const TableHeader = forwardRef(
42
42
  DEV: TableHeader.displayName = "Table.Header";
43
43
  const TableBody = forwardRef((props, forwardedRef) => {
44
44
  return /* @__PURE__ */ jsx(
45
- Ariakit.Role.div,
45
+ Role.div,
46
46
  {
47
47
  ...props,
48
48
  className: cx("\u{1F95D}-table-body", props.className),
@@ -55,7 +55,7 @@ DEV: TableBody.displayName = "Table.Body";
55
55
  const TableRow = forwardRef((props, forwardedRef) => {
56
56
  const { children, ...rest } = props;
57
57
  return /* @__PURE__ */ jsx(
58
- Ariakit.Role.div,
58
+ Role.div,
59
59
  {
60
60
  ...rest,
61
61
  className: cx("\u{1F95D}-table-row", props.className),
@@ -78,7 +78,7 @@ const TableCaption = forwardRef(
78
78
  [id, setCaptionId]
79
79
  );
80
80
  return /* @__PURE__ */ jsx(
81
- Ariakit.Role,
81
+ Role,
82
82
  {
83
83
  ...rest,
84
84
  id,
@@ -93,7 +93,7 @@ DEV: TableCaption.displayName = "Table.Caption";
93
93
  const TableCell = forwardRef((props, forwardedRef) => {
94
94
  const isWithinTableHeader = React.useContext(TableHeaderContext);
95
95
  return /* @__PURE__ */ jsx(
96
- Ariakit.Role.span,
96
+ Role.span,
97
97
  {
98
98
  ...props,
99
99
  className: cx("\u{1F95D}-table-cell", props.className),
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import * as ReactDOM from "react-dom";
4
4
  import cx from "classnames";
5
- import * as Ariakit from "@ariakit/react";
5
+ import * as AkTab from "@ariakit/react/tab";
6
6
  import { useControlledState } from "./~hooks.js";
7
7
  import { forwardRef } from "./~utils.js";
8
8
  function Tabs(props) {
@@ -19,7 +19,7 @@ function Tabs(props) {
19
19
  setSelectedIdProp
20
20
  );
21
21
  return /* @__PURE__ */ jsx(
22
- Ariakit.TabProvider,
22
+ AkTab.TabProvider,
23
23
  {
24
24
  selectedId,
25
25
  setSelectedId: React.useCallback(
@@ -46,7 +46,7 @@ const TabList = forwardRef((props, forwardedRef) => {
46
46
  const { tone = "neutral", ...rest } = props;
47
47
  const viewTransitionName = `\u{1F95D}active-stripe-${React.useId().replaceAll(":", "_")}`;
48
48
  return /* @__PURE__ */ jsx(
49
- Ariakit.TabList,
49
+ AkTab.TabList,
50
50
  {
51
51
  ...rest,
52
52
  "data-kiwi-tone": tone,
@@ -62,7 +62,7 @@ const TabList = forwardRef((props, forwardedRef) => {
62
62
  DEV: TabList.displayName = "Tabs.TabList";
63
63
  const Tab = forwardRef((props, forwardedRef) => {
64
64
  return /* @__PURE__ */ jsx(
65
- Ariakit.Tab,
65
+ AkTab.Tab,
66
66
  {
67
67
  accessibleWhenDisabled: true,
68
68
  ...props,
@@ -74,7 +74,7 @@ const Tab = forwardRef((props, forwardedRef) => {
74
74
  DEV: Tab.displayName = "Tabs.Tab";
75
75
  const TabPanel = forwardRef((props, forwardedRef) => {
76
76
  return /* @__PURE__ */ jsx(
77
- Ariakit.TabPanel,
77
+ AkTab.TabPanel,
78
78
  {
79
79
  ...props,
80
80
  className: cx("\u{1F95D}-tab-panel", props.className),
@@ -1,11 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as Ariakit from "@ariakit/react";
2
+ import { Role } from "@ariakit/react/role";
3
3
  import cx from "classnames";
4
4
  import { forwardRef } from "./~utils.js";
5
5
  const Text = forwardRef((props, forwardedRef) => {
6
6
  const { variant, ...rest } = props;
7
7
  return /* @__PURE__ */ jsx(
8
- Ariakit.Role,
8
+ Role,
9
9
  {
10
10
  ...rest,
11
11
  className: cx("\u{1F95D}-text", props.className),
@@ -1,6 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import * as Ariakit from "@ariakit/react";
3
+ import { Role } from "@ariakit/react/role";
4
+ import { Focusable } from "@ariakit/react/focusable";
4
5
  import cx from "classnames";
5
6
  import { FieldControl } from "./Field.js";
6
7
  import { Icon } from "./Icon.js";
@@ -20,14 +21,14 @@ const TextBoxInput = forwardRef(
20
21
  type: "textlike",
21
22
  id,
22
23
  render: /* @__PURE__ */ jsx(
23
- Ariakit.Role.input,
24
+ Role.input,
24
25
  {
25
26
  readOnly: props.disabled,
26
27
  ...rest,
27
28
  className: cx({ "\u{1F95D}-text-box": !rootContext }, props.className),
28
29
  placeholder: props.placeholder ?? " ",
29
30
  render: /* @__PURE__ */ jsx(
30
- Ariakit.Focusable,
31
+ Focusable,
31
32
  {
32
33
  accessibleWhenDisabled: true,
33
34
  render: props.render || /* @__PURE__ */ jsx("input", {})
@@ -50,14 +51,14 @@ const TextBoxTextarea = forwardRef(
50
51
  type: "textlike",
51
52
  id,
52
53
  render: /* @__PURE__ */ jsx(
53
- Ariakit.Role.textarea,
54
+ Role.textarea,
54
55
  {
55
56
  readOnly: props.disabled,
56
57
  ...rest,
57
58
  className: cx("\u{1F95D}-text-box", props.className),
58
59
  placeholder: props.placeholder ?? " ",
59
60
  render: /* @__PURE__ */ jsx(
60
- Ariakit.Focusable,
61
+ Focusable,
61
62
  {
62
63
  accessibleWhenDisabled: true,
63
64
  render: props.render || /* @__PURE__ */ jsx("textarea", {})
@@ -80,7 +81,7 @@ const TextBoxRoot = forwardRef(
80
81
  {
81
82
  value: React.useMemo(() => ({ setDisabled, inputRef }), []),
82
83
  children: /* @__PURE__ */ jsx(
83
- Ariakit.Role.div,
84
+ Role.div,
84
85
  {
85
86
  ...props,
86
87
  "data-kiwi-disabled": disabled,
@@ -117,7 +118,7 @@ DEV: TextBoxIcon.displayName = "TextBox.Icon";
117
118
  const TextBoxText = forwardRef(
118
119
  (props, forwardedRef) => {
119
120
  return /* @__PURE__ */ jsx(
120
- Ariakit.Role.span,
121
+ Role.span,
121
122
  {
122
123
  ...props,
123
124
  className: cx("\u{1F95D}-text-box-decoration", props.className),
@@ -1,7 +1,7 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import cx from "classnames";
4
- import * as Ariakit from "@ariakit/react";
4
+ import * as AkTooltip from "@ariakit/react/tooltip";
5
5
  import { forwardRef } from "./~utils.js";
6
6
  import { usePopoverApi } from "./~hooks.js";
7
7
  const Tooltip = forwardRef(
@@ -18,10 +18,10 @@ const Tooltip = forwardRef(
18
18
  unmountOnHide = type === "none",
19
19
  ...rest
20
20
  } = props;
21
- const store = Ariakit.useTooltipStore();
21
+ const store = AkTooltip.useTooltipStore();
22
22
  const popover = usePopoverApi(store);
23
23
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
24
- Ariakit.TooltipProvider,
24
+ AkTooltip.TooltipProvider,
25
25
  {
26
26
  store,
27
27
  defaultOpen: defaultOpenProp,
@@ -29,7 +29,7 @@ const Tooltip = forwardRef(
29
29
  setOpen: setOpenProp,
30
30
  children: [
31
31
  /* @__PURE__ */ jsx(
32
- Ariakit.TooltipAnchor,
32
+ AkTooltip.TooltipAnchor,
33
33
  {
34
34
  render: children,
35
35
  ...type === "description" && { "aria-describedby": id },
@@ -37,7 +37,7 @@ const Tooltip = forwardRef(
37
37
  }
38
38
  ),
39
39
  /* @__PURE__ */ jsx(
40
- Ariakit.Tooltip,
40
+ AkTooltip.Tooltip,
41
41
  {
42
42
  "aria-hidden": "true",
43
43
  ...rest,
@@ -1,20 +1,17 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
1
+ import { jsx } from "react/jsx-runtime";
3
2
  import cx from "classnames";
4
- import * as Ariakit from "@ariakit/react";
5
- import * as ListItem from "./ListItem.js";
6
- import { IconButton } from "./IconButton.js";
7
- import { Icon } from "./Icon.js";
3
+ import { Role } from "@ariakit/react/role";
4
+ import { useCompositeStore, Composite } from "@ariakit/react/composite";
8
5
  import { forwardRef } from "./~utils.js";
9
- import { useEventHandlers } from "./~hooks.js";
6
+ import { Root as TreeItemRoot, Action as TreeItemAction } from "./TreeItem.js";
10
7
  const Tree = forwardRef((props, forwardedRef) => {
11
- const composite = Ariakit.useCompositeStore({ orientation: "vertical" });
8
+ const composite = useCompositeStore({ orientation: "vertical" });
12
9
  return /* @__PURE__ */ jsx(
13
- Ariakit.Role.div,
10
+ Role.div,
14
11
  {
15
12
  role: "tree",
16
13
  ...props,
17
- render: /* @__PURE__ */ jsx(Ariakit.Composite, { store: composite }),
14
+ render: /* @__PURE__ */ jsx(Composite, { store: composite }),
18
15
  className: cx("\u{1F95D}-tree", props.className),
19
16
  ref: forwardedRef,
20
17
  children: props.children
@@ -22,192 +19,8 @@ const Tree = forwardRef((props, forwardedRef) => {
22
19
  );
23
20
  });
24
21
  DEV: Tree.displayName = "Tree.Root";
25
- const TreeItem = forwardRef((props, forwardedRef) => {
26
- const {
27
- "aria-level": level,
28
- selected,
29
- expanded,
30
- icon,
31
- label,
32
- description,
33
- actions,
34
- onSelectedChange,
35
- onExpandedChange,
36
- onClick: onClickProp,
37
- onKeyDown: onKeyDownProp,
38
- ...rest
39
- } = props;
40
- const handleClick = (event) => {
41
- if (selected === void 0) return;
42
- event.stopPropagation();
43
- onSelectedChange?.(!selected);
44
- };
45
- const handleKeyDown = (event) => {
46
- if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
47
- return;
48
- }
49
- if (expanded === void 0) return;
50
- if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
51
- event.preventDefault();
52
- onExpandedChange?.(event.key === "ArrowRight");
53
- }
54
- };
55
- const labelId = React.useId();
56
- const descriptionId = React.useId();
57
- return /* @__PURE__ */ jsx(
58
- TreeItemContext.Provider,
59
- {
60
- value: React.useMemo(
61
- () => ({
62
- level,
63
- expanded,
64
- selected
65
- }),
66
- [level, expanded, selected]
67
- ),
68
- children: /* @__PURE__ */ jsx(
69
- Ariakit.CompositeItem,
70
- {
71
- render: /* @__PURE__ */ jsx(Ariakit.Role, { ...rest }),
72
- onClick: useEventHandlers(
73
- onClickProp,
74
- handleClick
75
- ),
76
- onKeyDown: useEventHandlers(
77
- onKeyDownProp,
78
- handleKeyDown
79
- ),
80
- role: "treeitem",
81
- "aria-expanded": expanded,
82
- "aria-selected": selected,
83
- "aria-labelledby": labelId,
84
- "aria-describedby": description ? descriptionId : void 0,
85
- "aria-level": level,
86
- className: cx("\u{1F95D}-tree-item", props.className),
87
- ref: forwardedRef,
88
- children: /* @__PURE__ */ jsxs(
89
- ListItem.Root,
90
- {
91
- "data-kiwi-expanded": expanded,
92
- "data-kiwi-selected": selected,
93
- className: "\u{1F95D}-tree-item-node",
94
- style: { "--\u{1F95D}tree-item-level": level },
95
- role: void 0,
96
- children: [
97
- /* @__PURE__ */ jsxs(ListItem.Decoration, { children: [
98
- /* @__PURE__ */ jsx(
99
- TreeItemExpander,
100
- {
101
- "data-kiwi-description": description ? true : void 0,
102
- onClick: () => {
103
- if (expanded === void 0) return;
104
- onExpandedChange?.(!expanded);
105
- }
106
- }
107
- ),
108
- typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon
109
- ] }),
110
- /* @__PURE__ */ jsx(ListItem.Content, { id: labelId, className: "\u{1F95D}-tree-item-content", children: label }),
111
- description ? /* @__PURE__ */ jsx(
112
- ListItem.Content,
113
- {
114
- id: descriptionId,
115
- className: "\u{1F95D}-tree-item-description",
116
- children: description
117
- }
118
- ) : void 0,
119
- /* @__PURE__ */ jsx(
120
- ListItem.Decoration,
121
- {
122
- render: /* @__PURE__ */ jsx(TreeItemActions, { children: actions })
123
- }
124
- )
125
- ]
126
- }
127
- )
128
- }
129
- )
130
- }
131
- );
132
- });
133
- DEV: TreeItem.displayName = "Tree.Item";
134
- const TreeItemActions = forwardRef((props, forwardedRef) => {
135
- return /* @__PURE__ */ jsx(
136
- Ariakit.Toolbar,
137
- {
138
- ...props,
139
- onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
140
- className: cx("\u{1F95D}-tree-item-actions", props.className),
141
- ref: forwardedRef,
142
- children: props.children
143
- }
144
- );
145
- });
146
- DEV: TreeItemActions.displayName = "TreeItemActions";
147
- const TreeItemAction = forwardRef(
148
- (props, forwardedRef) => {
149
- const { visible, ...rest } = props;
150
- return /* @__PURE__ */ jsx(
151
- IconButton,
152
- {
153
- inert: visible === false ? true : void 0,
154
- ...rest,
155
- variant: "ghost",
156
- className: cx("\u{1F95D}-tree-item-action", props.className),
157
- "data-kiwi-visible": visible,
158
- ref: forwardedRef
159
- }
160
- );
161
- }
162
- );
163
- DEV: TreeItemAction.displayName = "Tree.ItemAction";
164
- const TreeItemExpander = forwardRef(
165
- (props, forwardedRef) => {
166
- return /* @__PURE__ */ jsx(
167
- IconButton,
168
- {
169
- tabIndex: -1,
170
- "aria-hidden": "true",
171
- icon: /* @__PURE__ */ jsx(TreeChevron, {}),
172
- label: "Toggle",
173
- ...props,
174
- onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
175
- className: cx("\u{1F95D}-tree-item-expander", props.className),
176
- variant: "ghost",
177
- labelVariant: "visually-hidden",
178
- ref: forwardedRef
179
- }
180
- );
181
- }
182
- );
183
- DEV: TreeItemExpander.displayName = "TreeItemExpander";
184
- const TreeChevron = forwardRef(
185
- (props, forwardedRef) => {
186
- return /* @__PURE__ */ jsx(
187
- Icon,
188
- {
189
- ...props,
190
- render: /* @__PURE__ */ jsx(
191
- Ariakit.Role.svg,
192
- {
193
- width: "16",
194
- height: "16",
195
- fill: "currentColor",
196
- viewBox: "0 0 16 16",
197
- render: props.render,
198
- 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" })
199
- }
200
- ),
201
- className: cx("\u{1F95D}-tree-chevron", props.className),
202
- ref: forwardedRef
203
- }
204
- );
205
- }
206
- );
207
- DEV: TreeChevron.displayName = "TreeChevron";
208
- const TreeItemContext = React.createContext(void 0);
209
22
  export {
210
- TreeItem as Item,
23
+ TreeItemRoot as Item,
211
24
  TreeItemAction as ItemAction,
212
25
  Tree as Root
213
26
  };