@itwin/itwinui-react 5.0.0-alpha.1 → 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 (110) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +6 -6
  3. package/dist/DEV/bricks/Anchor.js +5 -10
  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 +11 -4
  7. package/dist/DEV/bricks/Checkbox.js +17 -9
  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 +3 -2
  11. package/dist/DEV/bricks/DropdownMenu.js +109 -30
  12. package/dist/DEV/bricks/Field.js +115 -14
  13. package/dist/DEV/bricks/Icon.js +70 -8
  14. package/dist/DEV/bricks/IconButton.js +14 -3
  15. package/dist/DEV/bricks/Kbd.internal.js +19 -0
  16. package/dist/DEV/bricks/Kbd.js +23 -6
  17. package/dist/DEV/bricks/Label.js +11 -8
  18. package/dist/DEV/bricks/ProgressBar.js +25 -0
  19. package/dist/DEV/bricks/Radio.js +17 -9
  20. package/dist/DEV/bricks/Root.js +35 -4
  21. package/dist/DEV/bricks/Select.js +17 -11
  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 +18 -10
  25. package/dist/DEV/bricks/Table.js +114 -0
  26. package/dist/DEV/bricks/Tabs.js +6 -6
  27. package/dist/DEV/bricks/Text.js +2 -2
  28. package/dist/DEV/bricks/TextBox.js +54 -16
  29. package/dist/DEV/bricks/Tooltip.js +17 -25
  30. package/dist/DEV/bricks/Tree.js +15 -107
  31. package/dist/DEV/bricks/TreeItem.js +224 -0
  32. package/dist/DEV/bricks/VisuallyHidden.js +2 -2
  33. package/dist/DEV/bricks/index.js +16 -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/{ListItem.js → ~utils.ListItem.js} +19 -3
  38. package/dist/DEV/foundations/styles.css.js +2 -2
  39. package/dist/bricks/Anchor.js +5 -10
  40. package/dist/bricks/Avatar.d.ts +47 -0
  41. package/dist/bricks/Avatar.js +23 -0
  42. package/dist/bricks/Badge.d.ts +28 -0
  43. package/dist/bricks/Badge.js +21 -0
  44. package/dist/bricks/Button.js +11 -4
  45. package/dist/bricks/Checkbox.d.ts +2 -2
  46. package/dist/bricks/Checkbox.js +17 -9
  47. package/dist/bricks/Chip.d.ts +31 -0
  48. package/dist/bricks/Chip.js +41 -0
  49. package/dist/bricks/Description.d.ts +19 -0
  50. package/dist/bricks/Description.js +29 -0
  51. package/dist/bricks/Divider.d.ts +2 -2
  52. package/dist/bricks/Divider.js +3 -2
  53. package/dist/bricks/DropdownMenu.d.ts +41 -14
  54. package/dist/bricks/DropdownMenu.js +106 -30
  55. package/dist/bricks/Field.d.ts +23 -1
  56. package/dist/bricks/Field.js +115 -14
  57. package/dist/bricks/Icon.d.ts +34 -3
  58. package/dist/bricks/Icon.js +68 -8
  59. package/dist/bricks/IconButton.d.ts +20 -4
  60. package/dist/bricks/IconButton.js +14 -3
  61. package/dist/bricks/Kbd.d.ts +15 -0
  62. package/dist/bricks/Kbd.internal.d.ts +17 -0
  63. package/dist/bricks/Kbd.internal.js +19 -0
  64. package/dist/bricks/Kbd.js +16 -6
  65. package/dist/bricks/Label.js +11 -8
  66. package/dist/bricks/ProgressBar.d.ts +31 -0
  67. package/dist/bricks/ProgressBar.js +24 -0
  68. package/dist/bricks/Radio.d.ts +2 -2
  69. package/dist/bricks/Radio.js +17 -9
  70. package/dist/bricks/Root.js +35 -4
  71. package/dist/bricks/Select.d.ts +9 -3
  72. package/dist/bricks/Select.js +17 -11
  73. package/dist/bricks/Skeleton.d.ts +25 -0
  74. package/dist/bricks/Skeleton.js +23 -0
  75. package/dist/bricks/Spinner.d.ts +31 -0
  76. package/dist/bricks/Spinner.js +39 -0
  77. package/dist/bricks/Switch.d.ts +2 -2
  78. package/dist/bricks/Switch.js +18 -10
  79. package/dist/bricks/Table.d.ts +115 -0
  80. package/dist/bricks/Table.js +108 -0
  81. package/dist/bricks/Tabs.d.ts +4 -4
  82. package/dist/bricks/Tabs.js +6 -6
  83. package/dist/bricks/Text.d.ts +1 -1
  84. package/dist/bricks/Text.js +2 -2
  85. package/dist/bricks/TextBox.d.ts +23 -2
  86. package/dist/bricks/TextBox.js +53 -16
  87. package/dist/bricks/Tooltip.d.ts +2 -2
  88. package/dist/bricks/Tooltip.js +17 -25
  89. package/dist/bricks/Tree.d.ts +19 -20
  90. package/dist/bricks/Tree.js +14 -102
  91. package/dist/bricks/TreeItem.d.ts +123 -0
  92. package/dist/bricks/TreeItem.js +219 -0
  93. package/dist/bricks/VisuallyHidden.js +2 -2
  94. package/dist/bricks/index.d.ts +8 -0
  95. package/dist/bricks/index.js +16 -0
  96. package/dist/bricks/styles.css.js +2 -2
  97. package/dist/bricks/~hooks.d.ts +55 -0
  98. package/dist/bricks/~hooks.js +55 -3
  99. package/dist/bricks/~utils.GhostAligner.d.ts +22 -0
  100. package/dist/bricks/~utils.GhostAligner.js +13 -0
  101. package/dist/bricks/~utils.ListItem.d.ts +14 -0
  102. package/dist/bricks/{ListItem.js → ~utils.ListItem.js} +18 -3
  103. package/dist/bricks/~utils.d.ts +6 -3
  104. package/dist/foundations/styles.css.js +2 -2
  105. package/package.json +14 -13
  106. package/CHANGELOG.md +0 -14
  107. package/dist/DEV/bricks/Textarea.js +0 -30
  108. package/dist/bricks/ListItem.d.ts +0 -10
  109. package/dist/bricks/Textarea.d.ts +0 -24
  110. package/dist/bricks/Textarea.js +0 -29
@@ -1,6 +1,5 @@
1
1
  import * as React from "react";
2
2
  import { Icon } from "./Icon.js";
3
- import { Textarea } from "./Textarea.js";
4
3
  import { type FocusableProps, type BaseProps } from "./~utils.js";
5
4
  interface BaseInputProps extends FocusableProps<"input"> {
6
5
  }
@@ -39,6 +38,28 @@ interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
39
38
  * For a multiline text input, use the `TextBox.Textarea` component.
40
39
  */
41
40
  declare const TextBoxInput: React.ForwardRefExoticComponent<TextBoxInputProps & React.RefAttributes<HTMLElement | HTMLInputElement>>;
41
+ interface TextareaProps extends FocusableProps<"textarea"> {
42
+ }
43
+ /**
44
+ * A styled textarea element that allows users to enter multiline text values.
45
+ *
46
+ * Example usage:
47
+ * ```tsx
48
+ * <TextBox.Textarea defaultValue="Hello" />
49
+ * ```
50
+ *
51
+ * Works well with the `Field` and `Label` components.
52
+ * ```tsx
53
+ * <Field>
54
+ * <Label>Leave a comment, be kind</Label>
55
+ * <TextBox.Textarea />
56
+ * </Field>
57
+ * ```
58
+ *
59
+ * Underneath, it's an HTML textarea, i.e. `<textarea>`, so it supports the same props, including
60
+ * `value`, `defaultValue`, `onChange`, and `disabled`.
61
+ */
62
+ declare const TextBoxTextarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLElement | HTMLTextAreaElement>>;
42
63
  interface TextBoxRootProps extends BaseProps {
43
64
  }
44
65
  /**
@@ -76,4 +97,4 @@ interface TextBoxTextProps extends BaseProps<"span"> {
76
97
  * A static text decoration for the `TextBox.Root` component. Can be added before or after the `TextBox.Input`.
77
98
  */
78
99
  declare const TextBoxText: React.ForwardRefExoticComponent<TextBoxTextProps & React.RefAttributes<HTMLElement | HTMLSpanElement>>;
79
- export { TextBoxRoot as Root, TextBoxInput as Input, Textarea, TextBoxIcon as Icon, TextBoxText as Text, };
100
+ export { TextBoxRoot as Root, TextBoxInput as Input, TextBoxTextarea as Textarea, TextBoxIcon as Icon, TextBoxText as Text, };
@@ -1,34 +1,71 @@
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
9
  import { forwardRef } from "./~utils.js";
10
10
  const TextBoxInput = forwardRef(
11
11
  (props, forwardedRef) => {
12
- const fieldId = useFieldId();
12
+ const { id, ...rest } = props;
13
13
  const rootContext = React.useContext(TextBoxRootContext);
14
14
  const setDisabled = rootContext?.setDisabled;
15
15
  React.useEffect(() => {
16
16
  setDisabled?.(props.disabled);
17
17
  }, [setDisabled, props.disabled]);
18
18
  return /* @__PURE__ */ jsx(
19
- Ariakit.Role.input,
19
+ FieldControl,
20
20
  {
21
- id: fieldId,
22
- ...props,
23
- className: cx({ "\u{1F95D}-text-box": !rootContext }, props.className),
21
+ type: "textlike",
22
+ id,
24
23
  render: /* @__PURE__ */ jsx(
25
- Ariakit.Focusable,
24
+ Role.input,
26
25
  {
27
- accessibleWhenDisabled: true,
28
- render: props.render || /* @__PURE__ */ jsx("input", {})
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)
29
38
  }
30
- ),
31
- ref: useMergedRefs(rootContext?.inputRef, forwardedRef)
39
+ )
40
+ }
41
+ );
42
+ }
43
+ );
44
+ const TextBoxTextarea = forwardRef(
45
+ (props, forwardedRef) => {
46
+ const { id, ...rest } = props;
47
+ return /* @__PURE__ */ jsx(
48
+ FieldControl,
49
+ {
50
+ type: "textlike",
51
+ id,
52
+ render: /* @__PURE__ */ jsx(
53
+ Role.textarea,
54
+ {
55
+ readOnly: props.disabled,
56
+ ...rest,
57
+ className: cx("\u{1F95D}-text-box", props.className),
58
+ placeholder: props.placeholder ?? " ",
59
+ render: /* @__PURE__ */ jsx(
60
+ Focusable,
61
+ {
62
+ accessibleWhenDisabled: true,
63
+ render: props.render || /* @__PURE__ */ jsx("textarea", {})
64
+ }
65
+ ),
66
+ ref: forwardedRef
67
+ }
68
+ )
32
69
  }
33
70
  );
34
71
  }
@@ -42,7 +79,7 @@ const TextBoxRoot = forwardRef(
42
79
  {
43
80
  value: React.useMemo(() => ({ setDisabled, inputRef }), []),
44
81
  children: /* @__PURE__ */ jsx(
45
- Ariakit.Role.div,
82
+ Role.div,
46
83
  {
47
84
  ...props,
48
85
  "data-kiwi-disabled": disabled,
@@ -77,7 +114,7 @@ const TextBoxIcon = forwardRef(
77
114
  const TextBoxText = forwardRef(
78
115
  (props, forwardedRef) => {
79
116
  return /* @__PURE__ */ jsx(
80
- Ariakit.Role.span,
117
+ Role.span,
81
118
  {
82
119
  ...props,
83
120
  className: cx("\u{1F95D}-text-box-decoration", props.className),
@@ -92,5 +129,5 @@ export {
92
129
  TextBoxInput as Input,
93
130
  TextBoxRoot as Root,
94
131
  TextBoxText as Text,
95
- Textarea
132
+ TextBoxTextarea as Textarea
96
133
  };
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
- import * as Ariakit from "@ariakit/react";
2
+ import * as AkTooltip from "@ariakit/react/tooltip";
3
3
  import { type FocusableProps } from "./~utils.js";
4
- interface TooltipProps extends Omit<FocusableProps<"div">, "content">, Pick<Ariakit.TooltipProps, "open" | "unmountOnHide">, Pick<Ariakit.TooltipProviderProps, "defaultOpen" | "setOpen"> {
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.
7
7
  */
@@ -1,38 +1,29 @@
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 { useStoreState } from "@ariakit/react/store";
6
+ import { forwardRef } from "./~utils.js";
7
+ import { usePopoverApi } from "./~hooks.js";
6
8
  const Tooltip = forwardRef(
7
9
  (props, forwardedRef) => {
10
+ const generatedId = React.useId();
8
11
  const {
9
12
  content,
10
13
  children,
11
- className,
12
14
  type = "description",
13
- id = React.useId(),
15
+ id = generatedId,
14
16
  defaultOpen: defaultOpenProp,
15
17
  open: openProp,
16
18
  setOpen: setOpenProp,
17
19
  unmountOnHide = type === "none",
18
20
  ...rest
19
21
  } = 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
- );
22
+ const store = AkTooltip.useTooltipStore();
23
+ const open = useStoreState(store, (store2) => store2.open);
24
+ const popover = usePopoverApi(store);
34
25
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
35
- Ariakit.TooltipProvider,
26
+ AkTooltip.TooltipProvider,
36
27
  {
37
28
  store,
38
29
  defaultOpen: defaultOpenProp,
@@ -40,28 +31,29 @@ const Tooltip = forwardRef(
40
31
  setOpen: setOpenProp,
41
32
  children: [
42
33
  /* @__PURE__ */ jsx(
43
- Ariakit.TooltipAnchor,
34
+ AkTooltip.TooltipAnchor,
44
35
  {
45
36
  render: children,
37
+ "data-has-popover-open": open || void 0,
46
38
  ...type === "description" && { "aria-describedby": id },
47
39
  ...type === "label" && { "aria-labelledby": id }
48
40
  }
49
41
  ),
50
42
  /* @__PURE__ */ jsx(
51
- Ariakit.Tooltip,
43
+ AkTooltip.Tooltip,
52
44
  {
53
45
  "aria-hidden": "true",
54
46
  ...rest,
55
47
  unmountOnHide,
56
- className: cx("\u{1F95D}-tooltip", className),
48
+ className: cx("\u{1F95D}-tooltip", props.className),
57
49
  ref: forwardedRef,
58
50
  id,
59
51
  style: {
60
- zIndex: supportsPopover ? void 0 : 9999,
52
+ ...popover.style,
61
53
  ...props.style
62
54
  },
63
- wrapperProps: { popover: "manual" },
64
- portal: !supportsPopover,
55
+ wrapperProps: popover.wrapperProps,
56
+ portal: popover.portal,
65
57
  children: content
66
58
  }
67
59
  )
@@ -1,23 +1,22 @@
1
- import * as React from "react";
2
- import { IconButton } from "./IconButton.js";
3
1
  import { type BaseProps } from "./~utils.js";
2
+ import { Root as TreeItemRoot, Action as TreeItemAction } from "./TreeItem.js";
4
3
  interface TreeProps extends BaseProps {
5
4
  }
6
- declare const Tree: React.ForwardRefExoticComponent<TreeProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
7
- interface TreeItemProps extends Omit<BaseProps, "content"> {
8
- content?: React.ReactNode;
9
- selected?: boolean;
10
- /** Specifies if the tree item is expanded. Used to determine if a tree item is a parent node. Defaults to `undefined`. */
11
- expanded?: boolean;
12
- }
13
- declare const TreeItem: React.ForwardRefExoticComponent<TreeItemProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
14
- interface TreeItemContentProps extends BaseProps<"span"> {
15
- }
16
- declare const TreeItemContent: React.ForwardRefExoticComponent<TreeItemContentProps & React.RefAttributes<HTMLElement | HTMLSpanElement>>;
17
- type IconButtonProps = React.ComponentProps<typeof IconButton>;
18
- interface TreeItemExpanderProps extends Omit<IconButtonProps, "variant" | "label" | "icon"> {
19
- label?: IconButtonProps["label"];
20
- icon?: IconButtonProps["icon"];
21
- }
22
- declare const TreeItemExpander: React.ForwardRefExoticComponent<Omit<TreeItemExpanderProps, "ref"> & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
23
- export { Tree as Root, TreeItem as Item, TreeItemExpander as Expander, TreeItemContent as Content, };
5
+ /**
6
+ * A tree is a hierarchical list of items that can be expanded or collapsed, or optionally selected.
7
+ *
8
+ * `Tree.Root` is the root component for a tree. `Tree.Item`s are rendered as a flat list in the `Tree.Root` component to create a hierarchical tree structure.
9
+ *
10
+ * Example:
11
+ * ```tsx
12
+ * <Tree.Root>
13
+ * <Tree.Item label="Parent 1" aria-level={1} aria-posinset={1} aria-setsize={2} />
14
+ * <Tree.Item label="Child 1.1" aria-level={2} aria-posinset={1} aria-setsize={2} />
15
+ * <Tree.Item label="Child 1.2" aria-level={2} aria-posinset={2} aria-setsize={2} />
16
+ * <Tree.Item label="Parent 2" aria-level={1} aria-posinset={2} aria-setsize={2} />
17
+ * <Tree.Item label="Child 2.1" aria-level={2} aria-posinset={1} aria-setsize={1} />
18
+ * </Tree.Root>
19
+ * ```
20
+ */
21
+ declare const Tree: import("react").ForwardRefExoticComponent<TreeProps & import("react").RefAttributes<HTMLElement | HTMLDivElement>>;
22
+ export { Tree as Root, TreeItemRoot as Item, TreeItemAction as ItemAction };
@@ -1,113 +1,25 @@
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";
6
+ import { Root as TreeItemRoot, Action as TreeItemAction } from "./TreeItem.js";
9
7
  const Tree = forwardRef((props, forwardedRef) => {
10
- return /* @__PURE__ */ jsx(Ariakit.Role.div, { ...props, role: "list", ref: forwardedRef, children: props.children });
11
- });
12
- const TreeItem = forwardRef((props, forwardedRef) => {
13
- const { selected, content, children, className, expanded, style, ...rest } = props;
14
- const parentContext = React.useContext(TreeItemContext);
15
- const level = parentContext ? parentContext.level + 1 : 1;
16
- const firstSelected = !!selected && !parentContext?.selected;
8
+ const composite = useCompositeStore({ orientation: "vertical" });
17
9
  return /* @__PURE__ */ jsx(
18
- TreeItemContext.Provider,
10
+ Role.div,
19
11
  {
20
- value: React.useMemo(
21
- () => ({
22
- level,
23
- expanded,
24
- selected
25
- }),
26
- [level, expanded, selected]
27
- ),
28
- children: /* @__PURE__ */ jsxs("div", { role: "listitem", "aria-current": firstSelected ? true : void 0, children: [
29
- /* @__PURE__ */ jsx(
30
- ListItem.Root,
31
- {
32
- ...rest,
33
- "data-kiwi-expanded": expanded,
34
- "data-kiwi-selected": selected,
35
- "data-kiwi-parent-selected": parentContext?.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
- ] })
12
+ role: "tree",
13
+ ...props,
14
+ render: /* @__PURE__ */ jsx(Composite, { store: composite }),
15
+ className: cx("\u{1F95D}-tree", props.className),
16
+ ref: forwardedRef,
17
+ children: props.children
48
18
  }
49
19
  );
50
20
  });
51
- const TreeItemContent = forwardRef(
52
- (props, forwardedRef) => {
53
- const { children, ...rest } = props;
54
- return /* @__PURE__ */ jsx(
55
- ListItem.Content,
56
- {
57
- ...rest,
58
- className: cx("\u{1F95D}-tree-item-content", props.className),
59
- ref: forwardedRef,
60
- children: /* @__PURE__ */ jsx("button", { type: "button", children })
61
- }
62
- );
63
- }
64
- );
65
- const TreeItemExpander = forwardRef(
66
- (props, forwardedRef) => {
67
- const context = React.useContext(TreeItemContext);
68
- const expanded = context?.expanded;
69
- return /* @__PURE__ */ jsx(
70
- IconButton,
71
- {
72
- icon: /* @__PURE__ */ jsx(TreeChevron, {}),
73
- label: "Toggle",
74
- "aria-expanded": expanded === void 0 ? void 0 : expanded,
75
- ...props,
76
- className: cx("\u{1F95D}-tree-item-expander", props.className),
77
- variant: "ghost",
78
- labelVariant: "visually-hidden",
79
- ref: forwardedRef
80
- }
81
- );
82
- }
83
- );
84
- const TreeChevron = forwardRef(
85
- (props, forwardedRef) => {
86
- return /* @__PURE__ */ jsx(
87
- Icon,
88
- {
89
- ...props,
90
- render: /* @__PURE__ */ jsx(
91
- Ariakit.Role.svg,
92
- {
93
- width: "16",
94
- height: "16",
95
- fill: "currentColor",
96
- viewBox: "0 0 16 16",
97
- render: props.render,
98
- 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" })
99
- }
100
- ),
101
- className: cx("\u{1F95D}-tree-chevron", props.className),
102
- ref: forwardedRef
103
- }
104
- );
105
- }
106
- );
107
- const TreeItemContext = React.createContext(void 0);
108
21
  export {
109
- TreeItemContent as Content,
110
- TreeItemExpander as Expander,
111
- TreeItem as Item,
22
+ TreeItemRoot as Item,
23
+ TreeItemAction as ItemAction,
112
24
  Tree as Root
113
25
  };
@@ -0,0 +1,123 @@
1
+ import * as React from "react";
2
+ import { IconButton } from "./IconButton.js";
3
+ import { type BaseProps } from "./~utils.js";
4
+ interface TreeItemRootProps extends Omit<BaseProps, "content" | "children"> {
5
+ /** Specifies the nesting level of the tree item. Nesting levels start at 1. */
6
+ "aria-level": number;
7
+ /** Defines tree item position in the current level of tree items. Integer greater than or equal to 1. */
8
+ "aria-posinset": number;
9
+ /** Defines tree item set size of the current level. */
10
+ "aria-setsize": number;
11
+ /**
12
+ * Specifies if the tree item is selected.
13
+ *
14
+ * If `undefined`, the tree item is not selectable.
15
+ *
16
+ * @default undefined
17
+ */
18
+ selected?: boolean;
19
+ /**
20
+ * Callback fired when the tree item is selected.
21
+ *
22
+ * Should be used with the `selected` prop.
23
+ */
24
+ onSelectedChange?: (selected: boolean) => void;
25
+ /**
26
+ * Specifies if the tree item is expanded.
27
+ *
28
+ * Used to determine if a tree item is a parent node. If `undefined`, it is a leaf node (i.e. not expandable).
29
+ *
30
+ * @default undefined
31
+ * */
32
+ expanded?: boolean;
33
+ /**
34
+ * Callback fired when the tree item is expanded.
35
+ *
36
+ * Should be used with the `expanded` prop.
37
+ */
38
+ onExpandedChange?: (expanded: boolean) => void;
39
+ /**
40
+ * Icon to be displayed inside the tree item.
41
+ *
42
+ * Can be a URL of an SVG from the `@itwin/itwinui-icons` package, or a JSX element.
43
+ *
44
+ * For multiple icons/decorations, use the `unstable_decorations` prop.
45
+ */
46
+ icon?: string | React.JSX.Element;
47
+ /**
48
+ * Decoration(s) to be displayed inside the tree item.
49
+ *
50
+ * This is an alternative to the `icon` prop, and can be used to
51
+ * display multiple icons or other decorations before the label.
52
+ *
53
+ * Note: This should _not_ be used together with the `icon` prop.
54
+ *
55
+ * @experimental
56
+ */
57
+ unstable_decorations?: React.ReactNode;
58
+ /**
59
+ * The primary label that identifies the tree item and is displayed inside it.
60
+ */
61
+ label?: React.ReactNode;
62
+ /** Secondary line of text to display additional information about the tree item. */
63
+ description?: React.ReactNode;
64
+ /**
65
+ * The actions available for the tree item. Must be a list of `Tree.ItemAction` components.
66
+ *
67
+ * Example:
68
+ * ```tsx
69
+ * actions={[
70
+ * <Tree.ItemAction key={…} icon={…} label={…} />,
71
+ * <Tree.ItemAction key={…} icon={…} label={…} />,
72
+ * ]}
73
+ * ```
74
+ */
75
+ actions?: React.ReactNode[];
76
+ }
77
+ /**
78
+ * A treeitem is a node in a tree structure that may be expanded or collapsed to reveal or hide its descendants.
79
+ *
80
+ * `Tree.Item`s can be rendered inside a `Tree.Root`. Additional properties are specified to the `Tree.Item`s to create a hierarchical tree structure.
81
+ *
82
+ * Example:
83
+ * ```tsx
84
+ * <Tree.Root>
85
+ * <Tree.Item label="Parent" aria-level={1} aria-posinset={1} aria-setsize={1} />
86
+ * <Tree.Item label="Child 1" aria-level={2} aria-posinset={1} aria-setsize={2} />
87
+ * <Tree.Item label="Child 2" aria-level={2} aria-posinset={2} aria-setsize={2} />
88
+ * </Tree.Root>
89
+ * ```
90
+ *
91
+ * The `label` and `icon` props can be used to specify the treeitem's own content.
92
+ *
93
+ * The `aria-level` prop is used to specify the nesting level of the treeitem. Nesting levels start at 1.
94
+ *
95
+ * The `aria-posinset` and `aria-setsize` props are used to define the treeitem's position in the current level of tree items.
96
+ *
97
+ * The `expanded` and `onExpandedChange` props can be used to control the expansion state of a treeitem.
98
+ *
99
+ * The `selected` and `onSelectedChange` props can be used to control the selection state of a treeitem.
100
+ *
101
+ * Secondary actions can be passed into the `actions` prop.
102
+ */
103
+ declare const TreeItemRoot: React.ForwardRefExoticComponent<TreeItemRootProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
104
+ type IconButtonProps = React.ComponentProps<typeof IconButton>;
105
+ interface TreeItemActionProps extends BaseProps<"button">, Pick<IconButtonProps, "label" | "icon"> {
106
+ /**
107
+ * Controls the visibility of the action.
108
+ *
109
+ * If `true`, the action is always visible.
110
+ * If `false`, the action is hidden and becomes inaccessible, but still occupies space.
111
+ *
112
+ * By default, the action is shown only when the treeitem receives hover/focus.
113
+ */
114
+ visible?: boolean;
115
+ }
116
+ /**
117
+ * A secondary action for `<Tree.Item>`, to be passed into the `actions` prop. The action is typically
118
+ * displayed as an icon-button on the right end of the treeitem.
119
+ *
120
+ * By default, the action appears only on hover/focus. This can be controlled by the `visible` prop.
121
+ */
122
+ declare const TreeItemAction: React.ForwardRefExoticComponent<TreeItemActionProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
123
+ export { TreeItemRoot as Root, TreeItemAction as Action };