@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,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 Checkbox = forwardRef(
@@ -12,7 +14,7 @@ const Checkbox = 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,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import cx from "classnames";
3
3
  import * as React from "react";
4
- import * as Ariakit from "@ariakit/react";
4
+ import { Role } from "@ariakit/react/role";
5
5
  import { forwardRef } from "./~utils.js";
6
6
  import { IconButton } from "./IconButton.js";
7
7
  import { Dismiss } from "./Icon.js";
@@ -11,7 +11,7 @@ const Chip = forwardRef((props, forwardedRef) => {
11
11
  const labelId = `${baseId}-label`;
12
12
  const dismissIconId = `${baseId}-dismiss`;
13
13
  return /* @__PURE__ */ jsxs(
14
- Ariakit.Role.div,
14
+ Role.div,
15
15
  {
16
16
  "data-kiwi-variant": variant,
17
17
  ...rest,
@@ -1,6 +1,6 @@
1
- import * as Ariakit from "@ariakit/react";
1
+ import { type SeparatorProps } from "@ariakit/react/separator";
2
2
  import { type BaseProps } from "./~utils.js";
3
- interface DividerProps extends BaseProps<"hr">, Pick<Ariakit.SeparatorProps, "orientation"> {
3
+ interface DividerProps extends BaseProps<"hr">, Pick<SeparatorProps, "orientation"> {
4
4
  /**
5
5
  * If true, the divider will be purely presentational and will not have any associated semantics.
6
6
  *
@@ -1,10 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import cx from "classnames";
3
- import * as Ariakit from "@ariakit/react";
3
+ import { Role } from "@ariakit/react/role";
4
+ import { Separator } from "@ariakit/react/separator";
4
5
  import { forwardRef } from "./~utils.js";
5
6
  const Divider = forwardRef((props, forwardedRef) => {
6
7
  const { presentational, ...rest } = props;
7
- const Comp = presentational ? Ariakit.Role : Ariakit.Separator;
8
+ const Comp = presentational ? Role : Separator;
8
9
  return /* @__PURE__ */ jsx(
9
10
  Comp,
10
11
  {
@@ -1,7 +1,8 @@
1
1
  import * as React from "react";
2
- import * as Ariakit from "@ariakit/react";
3
- import { type FocusableProps } from "./~utils.js";
4
- interface DropdownMenuProps extends Pick<Ariakit.MenuProviderProps, "children" | "placement" | "open" | "setOpen" | "defaultOpen"> {
2
+ import { type AnyString, type BaseProps, type FocusableProps } from "./~utils.js";
3
+ import { type MenuItemCheckboxProps, type MenuProviderProps } from "@ariakit/react/menu";
4
+ import { type PredefinedSymbol } from "./Kbd.internal.js";
5
+ interface DropdownMenuProps extends Pick<MenuProviderProps, "children" | "placement" | "open" | "setOpen" | "defaultOpen"> {
5
6
  }
6
7
  /**
7
8
  * A dropdown menu displays a list of actions or commands when the menu button is clicked.
@@ -14,9 +15,9 @@ interface DropdownMenuProps extends Pick<Ariakit.MenuProviderProps, "children" |
14
15
  * <DropdownMenu.Button>Actions</DropdownMenu.Button>
15
16
  *
16
17
  * <DropdownMenu.Content>
17
- * <DropdownMenu.Item>Add</DropdownMenu.Item>
18
- * <DropdownMenu.Item>Edit</DropdownMenu.Item>
19
- * <DropdownMenu.Item>Delete</DropdownMenu.Item>
18
+ * <DropdownMenu.Item label="Add" />
19
+ * <DropdownMenu.Item label="Edit" />
20
+ * <DropdownMenu.Item label="Delete" />
20
21
  * </DropdownMenu.Content>
21
22
  * </DropdownMenu.Root>
22
23
  * ```
@@ -55,7 +56,21 @@ interface DropdownMenuButtonProps extends FocusableProps<"button"> {
55
56
  * ```
56
57
  */
57
58
  declare const DropdownMenuButton: React.ForwardRefExoticComponent<DropdownMenuButtonProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
58
- interface DropdownMenuItemProps extends FocusableProps {
59
+ interface DropdownMenuItemProps extends Omit<FocusableProps, "children">, Partial<Pick<DropdownMenuItemShortcutsProps, "shortcuts"> & Pick<DropdownMenuIconProps, "icon">> {
60
+ /** The primary text label for the menu-item. */
61
+ label: React.ReactNode;
62
+ }
63
+ /**
64
+ * A single menu item within the dropdown menu. Should be used as a child of `DropdownMenu.Content`.
65
+ *
66
+ * Example:
67
+ * ```tsx
68
+ * <DropdownMenu.Item label="Add" />
69
+ * <DropdownMenu.Item label="Edit" />
70
+ * ```
71
+ */
72
+ declare const DropdownMenuItem: React.ForwardRefExoticComponent<DropdownMenuItemProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
73
+ interface DropdownMenuItemShortcutsProps extends BaseProps {
59
74
  /**
60
75
  * A string defining the keyboard shortcut(s) associated with the menu item.
61
76
  *
@@ -63,33 +78,33 @@ interface DropdownMenuItemProps extends FocusableProps {
63
78
  * shortcuts="S" // A single key shortcut
64
79
  * ```
65
80
  *
66
- * Multiple keys should be separated by the '+' character.
81
+ * Multiple keys should be separated by the `+` character. If one of the keys is
82
+ * recognized as a symbol name or a modifier key, it will be displayed as a symbol.
67
83
  *
68
84
  * ```tsx
69
- * shortcuts="Ctrl+Shift+S" // A multi-key combination
85
+ * shortcuts="Control+Enter" // A multi-key shortcut, displayed as "Ctrl ⏎"
70
86
  * ```
71
87
  */
72
- shortcuts?: string;
88
+ shortcuts: AnyString | `${PredefinedSymbol}+${AnyString}`;
73
89
  }
74
- /**
75
- * A single menu item within the dropdown menu. Should be used as a child of `DropdownMenu.Content`.
76
- *
77
- * Example:
78
- * ```tsx
79
- * <DropdownMenu.Item>Add</DropdownMenu.Item>
80
- * <DropdownMenu.Item>Edit</DropdownMenu.Item>
81
- * ```
82
- */
83
- declare const DropdownMenuItem: React.ForwardRefExoticComponent<DropdownMenuItemProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
84
- interface DropdownMenuCheckboxItemProps extends Omit<FocusableProps, "onChange">, Pick<Ariakit.MenuItemCheckboxProps, "checked" | "onChange" | "name" | "value"> {
90
+ interface DropdownMenuIconProps extends BaseProps {
91
+ /**
92
+ * An optional icon displayed before the menu-item label.
93
+ *
94
+ * Can be a URL of an SVG from the `@itwin/itwinui-icons` package,
95
+ * or a custom JSX icon.
96
+ */
97
+ icon?: string | React.JSX.Element;
98
+ }
99
+ interface DropdownMenuCheckboxItemProps extends Omit<FocusableProps, "onChange" | "children">, Pick<MenuItemCheckboxProps, "checked" | "onChange" | "name" | "value">, Pick<DropdownMenuItemProps, "label" | "icon"> {
85
100
  }
86
101
  /**
87
102
  * A single menu item within the dropdown menu. Should be used as a child of `DropdownMenu.Content`.
88
103
  *
89
104
  * Example:
90
105
  * ```tsx
91
- * <DropdownMenu.CheckboxItem name="add">Add</DropdownMenu.Item>
92
- * <DropdownMenu.CheckboxItem name="edit">Edit</DropdownMenu.Item>
106
+ * <DropdownMenu.CheckboxItem name="add" label="Add" />
107
+ * <DropdownMenu.CheckboxItem name="edit" label="Edit" />
93
108
  * ```
94
109
  */
95
110
  declare const DropdownMenuCheckboxItem: React.ForwardRefExoticComponent<DropdownMenuCheckboxItemProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
@@ -1,13 +1,23 @@
1
1
  import { 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 * as ListItem from "./ListItem.js";
4
+ import * as ListItem from "./~utils.ListItem.js";
6
5
  import { Button } from "./Button.js";
7
6
  import { Kbd } from "./Kbd.js";
8
- import { Checkmark, DisclosureArrow } from "./Icon.js";
9
- import { forwardRef } from "./~utils.js";
7
+ import { Checkmark, DisclosureArrow, Icon } from "./Icon.js";
8
+ import {
9
+ forwardRef
10
+ } from "./~utils.js";
10
11
  import { usePopoverApi } from "./~hooks.js";
12
+ import {
13
+ MenuProvider,
14
+ useMenuContext,
15
+ Menu,
16
+ MenuButton,
17
+ MenuItem,
18
+ MenuItemCheckbox
19
+ } from "@ariakit/react/menu";
20
+ import { predefinedSymbols } from "./Kbd.internal.js";
11
21
  function DropdownMenu(props) {
12
22
  const {
13
23
  children,
@@ -17,7 +27,7 @@ function DropdownMenu(props) {
17
27
  defaultOpen: defaultOpenProp
18
28
  } = props;
19
29
  return /* @__PURE__ */ jsx(
20
- Ariakit.MenuProvider,
30
+ MenuProvider,
21
31
  {
22
32
  placement,
23
33
  defaultOpen: defaultOpenProp,
@@ -29,9 +39,9 @@ function DropdownMenu(props) {
29
39
  }
30
40
  const DropdownMenuContent = forwardRef(
31
41
  (props, forwardedRef) => {
32
- const popover = usePopoverApi(Ariakit.useMenuContext());
42
+ const popover = usePopoverApi(useMenuContext());
33
43
  return /* @__PURE__ */ jsx(
34
- Ariakit.Menu,
44
+ Menu,
35
45
  {
36
46
  portal: popover.portal,
37
47
  unmountOnHide: true,
@@ -49,7 +59,7 @@ const DropdownMenuButton = forwardRef(
49
59
  (props, forwardedRef) => {
50
60
  const { accessibleWhenDisabled = true, children, ...rest } = props;
51
61
  return /* @__PURE__ */ jsx(
52
- Ariakit.MenuButton,
62
+ MenuButton,
53
63
  {
54
64
  accessibleWhenDisabled: true,
55
65
  render: /* @__PURE__ */ jsxs(Button, { accessibleWhenDisabled, children: [
@@ -65,13 +75,9 @@ const DropdownMenuButton = forwardRef(
65
75
  );
66
76
  const DropdownMenuItem = forwardRef(
67
77
  (props, forwardedRef) => {
68
- const { shortcuts, ...rest } = props;
69
- const shortcutKeys = React.useMemo(() => {
70
- return typeof shortcuts === "string" ? shortcuts.split("+").map((key) => key.trim()) : [];
71
- }, [shortcuts]);
72
- const hasShortcuts = shortcutKeys.length > 0;
78
+ const { label, shortcuts, icon, ...rest } = props;
73
79
  return /* @__PURE__ */ jsxs(
74
- Ariakit.MenuItem,
80
+ MenuItem,
75
81
  {
76
82
  accessibleWhenDisabled: true,
77
83
  ...rest,
@@ -79,25 +85,77 @@ const DropdownMenuItem = forwardRef(
79
85
  className: cx("\u{1F95D}-dropdown-menu-item", props.className),
80
86
  ref: forwardedRef,
81
87
  children: [
82
- /* @__PURE__ */ jsx(ListItem.Content, { children: props.children }),
83
- hasShortcuts && /* @__PURE__ */ jsx(ListItem.Decoration, { className: "\u{1F95D}-dropdown-menu-item-shortcuts", children: shortcutKeys.map((key, index) => /* @__PURE__ */ jsx(Kbd, { variant: "ghost", children: key }, `${key + index}`)) })
88
+ icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
89
+ /* @__PURE__ */ jsx(ListItem.Content, { children: label }),
90
+ shortcuts ? /* @__PURE__ */ jsx(DropdownMenuItemShortcuts, { shortcuts }) : null
84
91
  ]
85
92
  }
86
93
  );
87
94
  }
88
95
  );
96
+ const DropdownMenuItemShortcuts = forwardRef((props, forwardedRef) => {
97
+ const { shortcuts, ...rest } = props;
98
+ const shortcutKeys = React.useMemo(() => {
99
+ return shortcuts.split("+").map((key) => ({
100
+ key: key.trim(),
101
+ isSymbol: key in predefinedSymbols
102
+ }));
103
+ }, [shortcuts]);
104
+ return /* @__PURE__ */ jsx(
105
+ ListItem.Decoration,
106
+ {
107
+ ...rest,
108
+ className: cx("\u{1F95D}-dropdown-menu-item-shortcuts", props.className),
109
+ ref: forwardedRef,
110
+ children: shortcutKeys.map(({ key, isSymbol }, index) => {
111
+ if (isSymbol) {
112
+ return /* @__PURE__ */ jsx(
113
+ Kbd,
114
+ {
115
+ variant: "ghost",
116
+ symbol: key
117
+ },
118
+ `${key + index}`
119
+ );
120
+ }
121
+ return /* @__PURE__ */ jsx(Kbd, { variant: "ghost", children: key }, `${key + index}`);
122
+ })
123
+ }
124
+ );
125
+ });
126
+ const DropdownMenuIcon = forwardRef(
127
+ (props, forwardedRef) => {
128
+ const { icon, ...rest } = props;
129
+ return /* @__PURE__ */ jsx(
130
+ ListItem.Decoration,
131
+ {
132
+ render: /* @__PURE__ */ jsx(
133
+ Icon,
134
+ {
135
+ href: typeof icon === "string" ? icon : void 0,
136
+ render: React.isValidElement(icon) ? icon : void 0
137
+ }
138
+ ),
139
+ ...rest,
140
+ ref: forwardedRef
141
+ }
142
+ );
143
+ }
144
+ );
89
145
  const DropdownMenuCheckboxItem = forwardRef((props, forwardedRef) => {
146
+ const { label, icon, ...rest } = props;
90
147
  return /* @__PURE__ */ jsxs(
91
- Ariakit.MenuItemCheckbox,
148
+ MenuItemCheckbox,
92
149
  {
93
150
  accessibleWhenDisabled: true,
94
151
  value: props.defaultChecked ? "on" : void 0,
95
- ...props,
152
+ ...rest,
96
153
  render: /* @__PURE__ */ jsx(ListItem.Root, { render: props.render }),
97
154
  className: cx("\u{1F95D}-dropdown-menu-item", props.className),
98
155
  ref: forwardedRef,
99
156
  children: [
100
- /* @__PURE__ */ jsx(ListItem.Content, { children: props.children }),
157
+ icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
158
+ /* @__PURE__ */ jsx(ListItem.Content, { children: label }),
101
159
  /* @__PURE__ */ jsx(
102
160
  ListItem.Decoration,
103
161
  {
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import * as Ariakit from "@ariakit/react";
2
+ import { useCollectionStore, type CollectionItemProps } from "@ariakit/react/collection";
3
3
  import { type BaseProps } from "./~utils.js";
4
4
  interface FieldProps extends BaseProps {
5
5
  /**
@@ -28,14 +28,14 @@ interface FieldProps extends BaseProps {
28
28
  * - `Switch`
29
29
  */
30
30
  export declare const Field: React.ForwardRefExoticComponent<FieldProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
31
- type CollectionStoreItem = NonNullable<ReturnType<ReturnType<typeof Ariakit.useCollectionStore>["item"]>>;
31
+ type CollectionStoreItem = NonNullable<ReturnType<ReturnType<typeof useCollectionStore>["item"]>>;
32
32
  interface FieldCollectionStoreItem extends CollectionStoreItem {
33
33
  /** The type of field element being tracked */
34
34
  elementType: "label" | "control" | "description";
35
35
  /** If a control, the type of control. */
36
36
  controlType?: "textlike" | "checkable";
37
37
  }
38
- interface FieldCollectionItemControlProps extends Pick<Ariakit.CollectionItemProps, "render" | "id"> {
38
+ interface FieldCollectionItemControlProps extends Pick<CollectionItemProps, "render" | "id"> {
39
39
  type: FieldCollectionStoreItem["controlType"];
40
40
  }
41
41
  /**
@@ -45,9 +45,9 @@ export declare function FieldControl(props: FieldCollectionItemControlProps): im
45
45
  /**
46
46
  * An element tracked as a label in the `Field`’s collection.
47
47
  */
48
- export declare function FieldLabel(props: Pick<Ariakit.CollectionItemProps, "render">): import("react/jsx-runtime").JSX.Element;
48
+ export declare function FieldLabel(props: Pick<CollectionItemProps, "render">): import("react/jsx-runtime").JSX.Element;
49
49
  /**
50
50
  * An element tracked as a description in the `Field`’s collection.
51
51
  */
52
- export declare function FieldDescription(props: Pick<Ariakit.CollectionItemProps, "render" | "id">): import("react/jsx-runtime").JSX.Element;
52
+ export declare function FieldDescription(props: Pick<CollectionItemProps, "render" | "id">): import("react/jsx-runtime").JSX.Element;
53
53
  export {};
@@ -1,7 +1,14 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import * as Ariakit from "@ariakit/react";
4
3
  import cx from "classnames";
4
+ import { Role } from "@ariakit/react/role";
5
+ import {
6
+ useCollectionStore,
7
+ Collection,
8
+ useCollectionContext,
9
+ CollectionItem
10
+ } from "@ariakit/react/collection";
11
+ import { useStoreState } from "@ariakit/react/store";
5
12
  import { forwardRef } from "./~utils.js";
6
13
  const Field = forwardRef((props, forwardedRef) => {
7
14
  const { layout, ...rest } = props;
@@ -9,7 +16,7 @@ const Field = forwardRef((props, forwardedRef) => {
9
16
  FieldCollection,
10
17
  {
11
18
  render: /* @__PURE__ */ jsx(
12
- Ariakit.Role.div,
19
+ Role.div,
13
20
  {
14
21
  ...rest,
15
22
  className: cx("\u{1F95D}-field", props.className),
@@ -21,13 +28,10 @@ const Field = forwardRef((props, forwardedRef) => {
21
28
  );
22
29
  });
23
30
  function FieldCollection(props) {
24
- const fieldElementCollection = Ariakit.useCollectionStore({
31
+ const fieldElementCollection = useCollectionStore({
25
32
  defaultItems: []
26
33
  });
27
- const renderedItems = Ariakit.useStoreState(
28
- fieldElementCollection,
29
- "renderedItems"
30
- );
34
+ const renderedItems = useStoreState(fieldElementCollection, "renderedItems");
31
35
  const [controlType, controlIndex] = React.useMemo(() => {
32
36
  const controlIndex2 = renderedItems.findIndex(
33
37
  (item) => item.elementType === "control"
@@ -42,7 +46,7 @@ function FieldCollection(props) {
42
46
  return labelIndex < controlIndex ? "before" : "after";
43
47
  }, [renderedItems, controlIndex]);
44
48
  return /* @__PURE__ */ jsx(
45
- Ariakit.Collection,
49
+ Collection,
46
50
  {
47
51
  ...props,
48
52
  store: fieldElementCollection,
@@ -52,10 +56,10 @@ function FieldCollection(props) {
52
56
  );
53
57
  }
54
58
  function FieldControl(props) {
55
- const store = Ariakit.useCollectionContext();
59
+ const store = useCollectionContext();
56
60
  const generatedId = React.useId();
57
61
  const { id = store ? generatedId : void 0, type, ...rest } = props;
58
- const renderedItems = Ariakit.useStoreState(store, "renderedItems");
62
+ const renderedItems = useStoreState(store, "renderedItems");
59
63
  const describedBy = React.useMemo(() => {
60
64
  const idRefList = renderedItems?.filter(
61
65
  (item) => item.elementType === "description"
@@ -71,17 +75,17 @@ function FieldControl(props) {
71
75
  [type]
72
76
  );
73
77
  return /* @__PURE__ */ jsx(
74
- Ariakit.CollectionItem,
78
+ CollectionItem,
75
79
  {
76
80
  id,
77
81
  getItem: getData,
78
- render: /* @__PURE__ */ jsx(Ariakit.Role, { ...rest, "aria-describedby": describedBy })
82
+ render: /* @__PURE__ */ jsx(Role, { ...rest, "aria-describedby": describedBy })
79
83
  }
80
84
  );
81
85
  }
82
86
  function FieldLabel(props) {
83
- const store = Ariakit.useCollectionContext();
84
- const renderedItems = Ariakit.useStoreState(store, "renderedItems");
87
+ const store = useCollectionContext();
88
+ const renderedItems = useStoreState(store, "renderedItems");
85
89
  const fieldId = React.useMemo(
86
90
  () => renderedItems?.find(
87
91
  (item) => item.elementType === "control"
@@ -96,10 +100,10 @@ function FieldLabel(props) {
96
100
  []
97
101
  );
98
102
  return /* @__PURE__ */ jsx(
99
- Ariakit.CollectionItem,
103
+ CollectionItem,
100
104
  {
101
105
  getItem: getData,
102
- render: /* @__PURE__ */ jsx(Ariakit.Role.label, { ...props, htmlFor: fieldId })
106
+ render: /* @__PURE__ */ jsx(Role.label, { ...props, htmlFor: fieldId })
103
107
  }
104
108
  );
105
109
  }
@@ -113,7 +117,7 @@ function FieldDescription(props) {
113
117
  }),
114
118
  []
115
119
  );
116
- return /* @__PURE__ */ jsx(Ariakit.CollectionItem, { ...rest, id, getItem: getData });
120
+ return /* @__PURE__ */ jsx(CollectionItem, { ...rest, id, getItem: getData });
117
121
  }
118
122
  export {
119
123
  Field,
@@ -1,14 +1,14 @@
1
1
  import { jsx } 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 { forwardRef } from "./~utils.js";
6
6
  const Icon = forwardRef((props, forwardedRef) => {
7
7
  const { href, size, alt, ...rest } = props;
8
8
  const iconId = toIconId(size);
9
9
  const isDecorative = !alt;
10
10
  return /* @__PURE__ */ jsx(
11
- Ariakit.Role.svg,
11
+ Role.svg,
12
12
  {
13
13
  "aria-hidden": isDecorative ? "true" : void 0,
14
14
  role: isDecorative ? void 0 : "img",
@@ -41,7 +41,7 @@ const DisclosureArrow = forwardRef(
41
41
  {
42
42
  ...rest,
43
43
  render: /* @__PURE__ */ jsx(
44
- Ariakit.Role.svg,
44
+ Role.svg,
45
45
  {
46
46
  width: "16",
47
47
  height: "16",
@@ -64,7 +64,7 @@ const Checkmark = forwardRef(
64
64
  {
65
65
  ...props,
66
66
  render: /* @__PURE__ */ jsx(
67
- Ariakit.Role.svg,
67
+ Role.svg,
68
68
  {
69
69
  width: "16",
70
70
  height: "16",
@@ -93,7 +93,7 @@ const Dismiss = forwardRef(
93
93
  {
94
94
  ...props,
95
95
  render: /* @__PURE__ */ jsx(
96
- Ariakit.Role.svg,
96
+ Role.svg,
97
97
  {
98
98
  width: "16",
99
99
  height: "16",
@@ -1,3 +1,4 @@
1
+ import * as React from "react";
1
2
  import { Button } from "./Button.js";
2
3
  interface IconButtonBaseProps extends Omit<React.ComponentProps<typeof Button>, "children" | "tone"> {
3
4
  /**
@@ -23,6 +24,21 @@ interface IconButtonBaseProps extends Omit<React.ComponentProps<typeof Button>,
23
24
  * @default "tooltip"
24
25
  */
25
26
  labelVariant?: "tooltip" | "visually-hidden";
27
+ /**
28
+ * A small dot displayed in the corner of the icon.
29
+ *
30
+ * The value of this prop gets used as the button's "accessible description".
31
+ *
32
+ * Example:
33
+ * ```tsx
34
+ * <IconButton
35
+ * label="Messages"
36
+ * dot="You have unread messages"
37
+ * icon={…}
38
+ * />
39
+ * ```
40
+ */
41
+ dot?: string;
26
42
  }
27
43
  /**
28
44
  * An icon-only button, with a required accessible name.
@@ -56,7 +72,7 @@ interface IconButtonBaseProps extends Omit<React.ComponentProps<typeof Button>,
56
72
  * />
57
73
  * ```
58
74
  */
59
- export declare const IconButton: import("react").ForwardRefExoticComponent<(Omit<IconButtonBaseProps & {
75
+ export declare const IconButton: React.ForwardRefExoticComponent<(Omit<IconButtonBaseProps & {
60
76
  variant: "ghost";
61
77
  /**
62
78
  * Whether the button is in a toggled state and currently "active" (toggled on).
@@ -75,5 +91,5 @@ export declare const IconButton: import("react").ForwardRefExoticComponent<(Omit
75
91
  }, "ref"> | Omit<IconButtonBaseProps & {
76
92
  variant?: Omit<React.ComponentProps<typeof Button>["variant"], "ghost">;
77
93
  isActive?: never;
78
- }, "ref">) & import("react").RefAttributes<HTMLElement | HTMLButtonElement>>;
94
+ }, "ref">) & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
79
95
  export {};
@@ -1,6 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
2
3
  import cx from "classnames";
3
- import * as Ariakit from "@ariakit/react";
4
+ import { useToolbarContext, ToolbarItem } from "@ariakit/react/toolbar";
4
5
  import { Button } from "./Button.js";
5
6
  import { VisuallyHidden } from "./VisuallyHidden.js";
6
7
  import { Icon } from "./Icon.js";
@@ -8,19 +9,26 @@ import { Tooltip } from "./Tooltip.js";
8
9
  import { forwardRef } from "./~utils.js";
9
10
  const IconButton = forwardRef(
10
11
  (props, forwardedRef) => {
11
- const { label, icon, isActive, labelVariant, ...rest } = props;
12
- const toolbar = Ariakit.useToolbarContext();
12
+ const { label, icon, isActive, labelVariant, dot, ...rest } = props;
13
+ const baseId = React.useId();
14
+ const labelId = `${baseId}-label`;
15
+ const dotId = `${baseId}-dot`;
16
+ const toolbar = useToolbarContext();
13
17
  const button = /* @__PURE__ */ jsxs(
14
18
  Button,
15
19
  {
16
20
  "aria-pressed": isActive,
21
+ "aria-labelledby": labelId,
22
+ "aria-describedby": dot ? dotId : void 0,
17
23
  ...rest,
18
- render: toolbar ? /* @__PURE__ */ jsx(Ariakit.ToolbarItem, { render: props.render }) : props.render,
24
+ "data-kiwi-dot": dot ? "true" : void 0,
25
+ render: toolbar ? /* @__PURE__ */ jsx(ToolbarItem, { render: props.render }) : props.render,
19
26
  className: cx("\u{1F95D}-icon-button", props.className),
20
27
  ref: forwardedRef,
21
28
  children: [
22
- /* @__PURE__ */ jsx(VisuallyHidden, { children: label }),
23
- typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon
29
+ /* @__PURE__ */ jsx(VisuallyHidden, { id: labelId, children: label }),
30
+ typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon,
31
+ dot ? /* @__PURE__ */ jsx(VisuallyHidden, { id: dotId, "aria-hidden": "true", children: dot }) : null
24
32
  ]
25
33
  }
26
34
  );
@@ -1,20 +1,5 @@
1
1
  import { type BaseProps } from "./~utils.js";
2
- declare const predefinedSymbols: {
3
- readonly Backspace: "⌫";
4
- readonly Command: "⌘";
5
- readonly Control: "Ctrl";
6
- readonly Down: "↓";
7
- readonly Eject: "⏏";
8
- readonly Enter: "↵";
9
- readonly Escape: "Esc";
10
- readonly Left: "←";
11
- readonly Option: "⌥";
12
- readonly Right: "→";
13
- readonly Shift: "⇧";
14
- readonly Space: "␣";
15
- readonly Tab: "Tab";
16
- readonly Up: "↑";
17
- };
2
+ import { type PredefinedSymbol } from "./Kbd.internal.js";
18
3
  interface KbdProps extends BaseProps<"kbd"> {
19
4
  /** @default "solid" */
20
5
  variant?: "solid" | "muted" | "ghost";
@@ -27,7 +12,7 @@ interface KbdProps extends BaseProps<"kbd"> {
27
12
  * <Kbd symbol="Control" />
28
13
  * ```
29
14
  */
30
- symbol?: keyof typeof predefinedSymbols;
15
+ symbol?: PredefinedSymbol;
31
16
  }
32
17
  /**
33
18
  * A styled wrapper over the HTML `<kbd>` element. This is typically
@@ -0,0 +1,17 @@
1
+ export type PredefinedSymbol = keyof typeof predefinedSymbols;
2
+ export declare const predefinedSymbols: {
3
+ readonly Backspace: "⌫";
4
+ readonly Command: "⌘";
5
+ readonly Control: "Ctrl";
6
+ readonly Down: "↓";
7
+ readonly Eject: "⏏";
8
+ readonly Enter: "↵";
9
+ readonly Escape: "Esc";
10
+ readonly Left: "←";
11
+ readonly Option: "⌥";
12
+ readonly Right: "→";
13
+ readonly Shift: "⇧";
14
+ readonly Space: "␣";
15
+ readonly Tab: "Tab";
16
+ readonly Up: "↑";
17
+ };
@@ -0,0 +1,19 @@
1
+ const predefinedSymbols = {
2
+ Backspace: "\u232B",
3
+ Command: "\u2318",
4
+ Control: "Ctrl",
5
+ Down: "\u2193",
6
+ Eject: "\u23CF",
7
+ Enter: "\u21B5",
8
+ Escape: "Esc",
9
+ Left: "\u2190",
10
+ Option: "\u2325",
11
+ Right: "\u2192",
12
+ Shift: "\u21E7",
13
+ Space: "\u2423",
14
+ Tab: "Tab",
15
+ Up: "\u2191"
16
+ };
17
+ export {
18
+ predefinedSymbols
19
+ };