@itwin/itwinui-react 5.0.0-alpha.7 → 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 (87) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +6 -6
  4. package/dist/DEV/bricks/Anchor.js +4 -9
  5. package/dist/DEV/bricks/Avatar.js +2 -2
  6. package/dist/DEV/bricks/Badge.js +2 -2
  7. package/dist/DEV/bricks/Button.js +10 -3
  8. package/dist/DEV/bricks/Checkbox.js +4 -2
  9. package/dist/DEV/bricks/Chip.js +2 -2
  10. package/dist/DEV/bricks/Divider.js +3 -2
  11. package/dist/DEV/bricks/DropdownMenu.js +83 -33
  12. package/dist/DEV/bricks/Field.js +21 -17
  13. package/dist/DEV/bricks/Icon.js +5 -5
  14. package/dist/DEV/bricks/IconButton.js +14 -6
  15. package/dist/DEV/bricks/Kbd.internal.js +19 -0
  16. package/dist/DEV/bricks/Kbd.js +3 -18
  17. package/dist/DEV/bricks/Label.js +2 -2
  18. package/dist/DEV/bricks/Radio.js +4 -2
  19. package/dist/DEV/bricks/Root.js +35 -4
  20. package/dist/DEV/bricks/Select.js +3 -3
  21. package/dist/DEV/bricks/Spinner.js +2 -2
  22. package/dist/DEV/bricks/Switch.js +4 -2
  23. package/dist/DEV/bricks/Table.js +7 -7
  24. package/dist/DEV/bricks/Tabs.js +5 -5
  25. package/dist/DEV/bricks/Text.js +2 -2
  26. package/dist/DEV/bricks/TextBox.js +8 -7
  27. package/dist/DEV/bricks/Tooltip.js +11 -22
  28. package/dist/DEV/bricks/Tree.js +8 -202
  29. package/dist/DEV/bricks/TreeItem.js +219 -0
  30. package/dist/DEV/bricks/VisuallyHidden.js +2 -2
  31. package/dist/DEV/bricks/styles.css.js +2 -2
  32. package/dist/DEV/bricks/~hooks.js +31 -0
  33. package/dist/DEV/bricks/~utils.GhostAligner.js +13 -0
  34. package/dist/DEV/bricks/{ListItem.js → ~utils.ListItem.js} +6 -4
  35. package/dist/DEV/foundations/styles.css.js +2 -2
  36. package/dist/bricks/Anchor.js +4 -9
  37. package/dist/bricks/Avatar.js +2 -2
  38. package/dist/bricks/Badge.js +2 -2
  39. package/dist/bricks/Button.js +10 -3
  40. package/dist/bricks/Checkbox.d.ts +2 -2
  41. package/dist/bricks/Checkbox.js +4 -2
  42. package/dist/bricks/Chip.js +2 -2
  43. package/dist/bricks/Divider.d.ts +2 -2
  44. package/dist/bricks/Divider.js +3 -2
  45. package/dist/bricks/DropdownMenu.d.ts +38 -23
  46. package/dist/bricks/DropdownMenu.js +81 -33
  47. package/dist/bricks/Field.d.ts +5 -5
  48. package/dist/bricks/Field.js +21 -17
  49. package/dist/bricks/Icon.js +5 -5
  50. package/dist/bricks/IconButton.d.ts +20 -4
  51. package/dist/bricks/IconButton.js +14 -6
  52. package/dist/bricks/Kbd.d.ts +2 -17
  53. package/dist/bricks/Kbd.internal.d.ts +17 -0
  54. package/dist/bricks/Kbd.internal.js +19 -0
  55. package/dist/bricks/Kbd.js +3 -18
  56. package/dist/bricks/Label.js +2 -2
  57. package/dist/bricks/Radio.d.ts +2 -2
  58. package/dist/bricks/Radio.js +4 -2
  59. package/dist/bricks/Root.js +35 -4
  60. package/dist/bricks/Select.d.ts +1 -2
  61. package/dist/bricks/Select.js +3 -3
  62. package/dist/bricks/Spinner.js +2 -2
  63. package/dist/bricks/Switch.d.ts +2 -2
  64. package/dist/bricks/Switch.js +4 -2
  65. package/dist/bricks/Table.js +7 -7
  66. package/dist/bricks/Tabs.d.ts +4 -4
  67. package/dist/bricks/Tabs.js +5 -5
  68. package/dist/bricks/Text.d.ts +1 -1
  69. package/dist/bricks/Text.js +2 -2
  70. package/dist/bricks/TextBox.js +8 -7
  71. package/dist/bricks/Tooltip.d.ts +2 -2
  72. package/dist/bricks/Tooltip.js +11 -22
  73. package/dist/bricks/Tree.d.ts +3 -108
  74. package/dist/bricks/Tree.js +8 -196
  75. package/dist/bricks/TreeItem.d.ts +123 -0
  76. package/dist/bricks/TreeItem.js +214 -0
  77. package/dist/bricks/VisuallyHidden.js +2 -2
  78. package/dist/bricks/styles.css.js +2 -2
  79. package/dist/bricks/~hooks.d.ts +31 -1
  80. package/dist/bricks/~hooks.js +31 -0
  81. package/dist/bricks/~utils.GhostAligner.d.ts +22 -0
  82. package/dist/bricks/~utils.GhostAligner.js +13 -0
  83. package/dist/bricks/{ListItem.d.ts → ~utils.ListItem.d.ts} +6 -6
  84. package/dist/bricks/{ListItem.js → ~utils.ListItem.js} +6 -4
  85. package/dist/bricks/~utils.d.ts +6 -3
  86. package/dist/foundations/styles.css.js +2 -2
  87. package/package.json +4 -4
@@ -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
+ Radio as AkRadio
5
+ } from "@ariakit/react/radio";
4
6
  import { FieldControl } from "./Field.js";
5
7
  import { forwardRef } from "./~utils.js";
6
8
  const Radio = forwardRef((props, forwardedRef) => {
@@ -11,7 +13,7 @@ const Radio = forwardRef((props, forwardedRef) => {
11
13
  type: "checkable",
12
14
  id,
13
15
  render: /* @__PURE__ */ jsx(
14
- Ariakit.Radio,
16
+ AkRadio,
15
17
  {
16
18
  accessibleWhenDisabled: true,
17
19
  ...rest,
@@ -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,8 +1,9 @@
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";
5
- import { forwardRef, supportsPopover } from "./~utils.js";
4
+ import * as AkTooltip from "@ariakit/react/tooltip";
5
+ import { forwardRef } from "./~utils.js";
6
+ import { usePopoverApi } from "./~hooks.js";
6
7
  const Tooltip = forwardRef(
7
8
  (props, forwardedRef) => {
8
9
  const generatedId = React.useId();
@@ -17,22 +18,10 @@ const Tooltip = forwardRef(
17
18
  unmountOnHide = type === "none",
18
19
  ...rest
19
20
  } = props;
20
- const store = Ariakit.useTooltipStore();
21
- const open = Ariakit.useStoreState(store, (state) => state.open);
22
- const popover = Ariakit.useStoreState(
23
- store,
24
- (state) => state.popoverElement
25
- );
26
- React.useEffect(
27
- function syncPopoverWithOpenState() {
28
- if (popover?.isConnected) {
29
- popover?.togglePopover?.(open);
30
- }
31
- },
32
- [open, popover]
33
- );
21
+ const store = AkTooltip.useTooltipStore();
22
+ const popover = usePopoverApi(store);
34
23
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
35
- Ariakit.TooltipProvider,
24
+ AkTooltip.TooltipProvider,
36
25
  {
37
26
  store,
38
27
  defaultOpen: defaultOpenProp,
@@ -40,7 +29,7 @@ const Tooltip = forwardRef(
40
29
  setOpen: setOpenProp,
41
30
  children: [
42
31
  /* @__PURE__ */ jsx(
43
- Ariakit.TooltipAnchor,
32
+ AkTooltip.TooltipAnchor,
44
33
  {
45
34
  render: children,
46
35
  ...type === "description" && { "aria-describedby": id },
@@ -48,7 +37,7 @@ const Tooltip = forwardRef(
48
37
  }
49
38
  ),
50
39
  /* @__PURE__ */ jsx(
51
- Ariakit.Tooltip,
40
+ AkTooltip.Tooltip,
52
41
  {
53
42
  "aria-hidden": "true",
54
43
  ...rest,
@@ -57,11 +46,11 @@ const Tooltip = forwardRef(
57
46
  ref: forwardedRef,
58
47
  id,
59
48
  style: {
60
- zIndex: supportsPopover ? void 0 : 9999,
49
+ ...popover.style,
61
50
  ...props.style
62
51
  },
63
- wrapperProps: { popover: "manual" },
64
- portal: !supportsPopover,
52
+ wrapperProps: popover.wrapperProps,
53
+ portal: popover.portal,
65
54
  children: content
66
55
  }
67
56
  )
@@ -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,199 +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
- children,
30
- expanded,
31
- icon,
32
- label,
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 contentId = React.useId();
56
- return /* @__PURE__ */ jsx(
57
- TreeItemContext.Provider,
58
- {
59
- value: React.useMemo(
60
- () => ({
61
- level,
62
- expanded,
63
- selected,
64
- contentId
65
- }),
66
- [level, expanded, selected, contentId]
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": contentId,
84
- "aria-level": level,
85
- className: cx("\u{1F95D}-tree-item", props.className),
86
- ref: forwardedRef,
87
- children: /* @__PURE__ */ jsxs(
88
- ListItem.Root,
89
- {
90
- "data-kiwi-expanded": expanded,
91
- "data-kiwi-selected": selected,
92
- className: "\u{1F95D}-tree-item-node",
93
- style: { "--\u{1F95D}tree-item-level": level },
94
- role: void 0,
95
- children: [
96
- /* @__PURE__ */ jsxs(ListItem.Decoration, { children: [
97
- /* @__PURE__ */ jsx(
98
- TreeItemExpander,
99
- {
100
- onClick: () => {
101
- if (expanded === void 0) return;
102
- onExpandedChange?.(!expanded);
103
- }
104
- }
105
- ),
106
- typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon
107
- ] }),
108
- /* @__PURE__ */ jsx(TreeItemContent, { label }),
109
- /* @__PURE__ */ jsx(
110
- ListItem.Decoration,
111
- {
112
- render: /* @__PURE__ */ jsx(TreeItemActions, { children: actions })
113
- }
114
- )
115
- ]
116
- }
117
- )
118
- }
119
- )
120
- }
121
- );
122
- });
123
- DEV: TreeItem.displayName = "Tree.Item";
124
- const TreeItemContent = forwardRef(
125
- (props, forwardedRef) => {
126
- const { label, ...rest } = props;
127
- const { contentId } = React.useContext(TreeItemContext) ?? {};
128
- return /* @__PURE__ */ jsx(
129
- ListItem.Content,
130
- {
131
- ...rest,
132
- id: contentId,
133
- className: cx("\u{1F95D}-tree-item-content", props.className),
134
- ref: forwardedRef,
135
- children: label
136
- }
137
- );
138
- }
139
- );
140
- DEV: TreeItemContent.displayName = "TreeItemContent";
141
- const TreeItemActions = forwardRef((props, forwardedRef) => {
142
- return /* @__PURE__ */ jsx(
143
- Ariakit.Toolbar,
144
- {
145
- ...props,
146
- onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
147
- className: cx("\u{1F95D}-tree-item-actions", props.className),
148
- ref: forwardedRef,
149
- children: props.children
150
- }
151
- );
152
- });
153
- DEV: TreeItemActions.displayName = "TreeItemActions";
154
- const TreeItemAction = forwardRef(
155
- (props, forwardedRef) => {
156
- const { visible, ...rest } = props;
157
- return /* @__PURE__ */ jsx(
158
- IconButton,
159
- {
160
- inert: visible === false ? true : void 0,
161
- ...rest,
162
- variant: "ghost",
163
- className: cx("\u{1F95D}-tree-item-action", props.className),
164
- "data-kiwi-visible": visible,
165
- ref: forwardedRef
166
- }
167
- );
168
- }
169
- );
170
- DEV: TreeItemAction.displayName = "Tree.ItemAction";
171
- const TreeItemExpander = forwardRef(
172
- (props, forwardedRef) => {
173
- return /* @__PURE__ */ jsx(
174
- IconButton,
175
- {
176
- tabIndex: -1,
177
- "aria-hidden": "true",
178
- icon: /* @__PURE__ */ jsx(TreeChevron, {}),
179
- label: "Toggle",
180
- ...props,
181
- onClick: useEventHandlers(props.onClick, (e) => e.stopPropagation()),
182
- className: cx("\u{1F95D}-tree-item-expander", props.className),
183
- variant: "ghost",
184
- labelVariant: "visually-hidden",
185
- ref: forwardedRef
186
- }
187
- );
188
- }
189
- );
190
- DEV: TreeItemExpander.displayName = "TreeItemExpander";
191
- const TreeChevron = forwardRef(
192
- (props, forwardedRef) => {
193
- return /* @__PURE__ */ jsx(
194
- Icon,
195
- {
196
- ...props,
197
- render: /* @__PURE__ */ jsx(
198
- Ariakit.Role.svg,
199
- {
200
- width: "16",
201
- height: "16",
202
- fill: "currentColor",
203
- viewBox: "0 0 16 16",
204
- render: props.render,
205
- 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" })
206
- }
207
- ),
208
- className: cx("\u{1F95D}-tree-chevron", props.className),
209
- ref: forwardedRef
210
- }
211
- );
212
- }
213
- );
214
- DEV: TreeChevron.displayName = "TreeChevron";
215
- const TreeItemContext = React.createContext(void 0);
216
22
  export {
217
- TreeItem as Item,
23
+ TreeItemRoot as Item,
218
24
  TreeItemAction as ItemAction,
219
25
  Tree as Root
220
26
  };