@itwin/itwinui-react 5.0.0-alpha.0 → 5.0.0-alpha.10

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