@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
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright © 2024 Bentley Systems, Incorporated. All rights reserved.
3
+ Copyright © 2025 Bentley Systems, Incorporated. All rights reserved.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @itwin/itwinui-react
2
2
 
3
- A React component library for the Kiwi design system.
3
+ A React component library for the next evolution of the iTwinUI design system.
4
4
 
5
5
  ## Usage
6
6
 
7
- To use components from the Kiwi design system in your app, you’ll need to wrap your app’s UI with Kiwi’s `<Root>` component, and specify the required `colorScheme` and `density` props:
7
+ To use components from the iTwinUI design system in your app, you’ll need to wrap your app’s UI with iTwinUI's `<Root>` component, and specify the required `colorScheme` and `density` props:
8
8
 
9
9
  ```jsx
10
10
  import { Root } from "@itwin/itwinui-react/bricks";
@@ -12,18 +12,18 @@ import { Root } from "@itwin/itwinui-react/bricks";
12
12
  export function App() {
13
13
  return (
14
14
  <Root colorScheme="dark" density="dense">
15
- {/* Use Kiwi design system components here */}
15
+ {/* Use design system components here */}
16
16
  </Root>
17
17
  );
18
18
  }
19
19
  ```
20
20
 
21
- This will ensure Kiwi’s styles are loaded to either the document or the encompassing shadow root.
21
+ This will ensure iTwinUI's styles are loaded to either the document or the encompassing shadow root.
22
22
 
23
23
  Once that’s in place you can import and use components from `@itwin/itwinui-react/bricks`.
24
24
 
25
25
  ## Contributing
26
26
 
27
- Are you interested in helping kiwi grow and expand? You can submit feature requests or bugs by creating [issues](https://github.com/iTwin/kiwi/issues).
27
+ Are you interested in helping iTwinUI grow and expand? You can submit feature requests or bugs by creating [issues](https://github.com/iTwin/design-system/issues).
28
28
 
29
- If you're interested in contributing code, please read [`CONTRIBUTING.md`](https://github.com/iTwin/kiwi/blob/main/CONTRIBUTING.md) for more information.
29
+ If you're interested in contributing code, please read [`CONTRIBUTING.md`](https://github.com/iTwin/design-system/blob/main/CONTRIBUTING.md) for more information.
@@ -1,28 +1,21 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import cx from "classnames";
4
- import * as Ariakit from "@ariakit/react";
5
- const Anchor = React.forwardRef(
6
- (props, forwardedRef) => {
7
- const { tone = "neutral", ...rest } = props;
8
- return /* @__PURE__ */ jsx(
9
- Ariakit.Role.a,
10
- {
11
- "data-kiwi-tone": tone,
12
- ...rest,
13
- className: cx("\u{1F95D}-anchor", props.className),
14
- render: /* @__PURE__ */ jsx(
15
- Ariakit.Focusable,
16
- {
17
- accessibleWhenDisabled: true,
18
- render: props.render || /* @__PURE__ */ jsx("a", {})
19
- }
20
- ),
21
- ref: forwardedRef
22
- }
23
- );
24
- }
25
- );
3
+ import { Role } from "@ariakit/react/role";
4
+ import { Focusable } from "@ariakit/react/focusable";
5
+ import { forwardRef } from "./~utils.js";
6
+ const Anchor = forwardRef((props, forwardedRef) => {
7
+ const { tone = "neutral", ...rest } = props;
8
+ return /* @__PURE__ */ jsx(
9
+ Role.a,
10
+ {
11
+ ...rest,
12
+ "data-kiwi-tone": tone,
13
+ className: cx("\u{1F95D}-anchor", props.className),
14
+ render: /* @__PURE__ */ jsx(Focusable, { accessibleWhenDisabled: true, render: props.render || /* @__PURE__ */ jsx("a", {}) }),
15
+ ref: forwardedRef
16
+ }
17
+ );
18
+ });
26
19
  DEV: Anchor.displayName = "Anchor";
27
20
  export {
28
21
  Anchor
@@ -0,0 +1,24 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import cx from "classnames";
3
+ import { Role } from "@ariakit/react/role";
4
+ import { forwardRef } from "./~utils.js";
5
+ const Avatar = forwardRef((props, forwardedRef) => {
6
+ const { size = "medium", initials, alt, image, children, ...rest } = props;
7
+ const isDecorative = !alt;
8
+ return /* @__PURE__ */ jsx(
9
+ Role.span,
10
+ {
11
+ role: isDecorative ? void 0 : "img",
12
+ "aria-label": isDecorative ? void 0 : alt,
13
+ ...rest,
14
+ "data-kiwi-size": size,
15
+ className: cx("\u{1F95D}-avatar", props.className),
16
+ ref: forwardedRef,
17
+ children: image ?? /* @__PURE__ */ jsx("abbr", { className: "\u{1F95D}-avatar-initials", "aria-hidden": "true", children: initials?.substring(0, 1) })
18
+ }
19
+ );
20
+ });
21
+ DEV: Avatar.displayName = "Avatar";
22
+ export {
23
+ Avatar
24
+ };
@@ -0,0 +1,22 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import cx from "classnames";
3
+ import { Role } from "@ariakit/react/role";
4
+ import { forwardRef } from "./~utils.js";
5
+ const Badge = forwardRef((props, forwardedRef) => {
6
+ const { tone = "neutral", variant = "solid", label, ...rest } = props;
7
+ return /* @__PURE__ */ jsx(
8
+ Role.span,
9
+ {
10
+ ...rest,
11
+ "data-kiwi-tone": tone,
12
+ "data-kiwi-variant": variant,
13
+ className: cx("\u{1F95D}-badge", props.className),
14
+ ref: forwardedRef,
15
+ children: label
16
+ }
17
+ );
18
+ });
19
+ DEV: Badge.displayName = "Badge";
20
+ export {
21
+ Badge
22
+ };
@@ -1,21 +1,30 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import cx from "classnames";
4
- import * as Ariakit from "@ariakit/react";
5
- const Button = React.forwardRef((props, forwardedRef) => {
6
- const { variant = "solid", tone = "neutral", ...rest } = props;
7
- return /* @__PURE__ */ jsx(
8
- Ariakit.Button,
9
- {
10
- accessibleWhenDisabled: true,
11
- "data-kiwi-variant": variant,
12
- "data-kiwi-tone": tone,
13
- ...rest,
14
- className: cx("\u{1F95D}-button", props.className),
15
- ref: forwardedRef
16
- }
17
- );
18
- });
3
+ import { Button as AkButton } from "@ariakit/react/button";
4
+ import { forwardRef } from "./~utils.js";
5
+ import { useGhostAlignment } from "./~utils.GhostAligner.js";
6
+ const Button = forwardRef(
7
+ (props, forwardedRef) => {
8
+ const { variant = "solid", tone = "neutral", ...rest } = props;
9
+ const ghostAlignment = useGhostAlignment();
10
+ return /* @__PURE__ */ jsx(
11
+ AkButton,
12
+ {
13
+ accessibleWhenDisabled: true,
14
+ ...rest,
15
+ "data-kiwi-variant": variant,
16
+ "data-kiwi-tone": tone,
17
+ "data-kiwi-ghost-align": variant === "ghost" ? ghostAlignment : void 0,
18
+ className: cx(
19
+ "\u{1F95D}-button",
20
+ { "\u{1F95D}-ghost-aligner": variant === "ghost" },
21
+ props.className
22
+ ),
23
+ ref: forwardedRef
24
+ }
25
+ );
26
+ }
27
+ );
19
28
  DEV: Button.displayName = "Button";
20
29
  export {
21
30
  Button
@@ -1,21 +1,31 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import cx from "classnames";
4
- import * as Ariakit from "@ariakit/react";
5
- import { useFieldId } from "./Field.js";
6
- const Checkbox = React.forwardRef((props, forwardedRef) => {
7
- const fieldId = useFieldId();
8
- return /* @__PURE__ */ jsx(
9
- Ariakit.Checkbox,
10
- {
11
- accessibleWhenDisabled: true,
12
- id: fieldId,
13
- ...props,
14
- className: cx("\u{1F95D}-checkbox", props.className),
15
- ref: forwardedRef
16
- }
17
- );
18
- });
3
+ import {
4
+ Checkbox as AkCheckbox
5
+ } from "@ariakit/react/checkbox";
6
+ import { FieldControl } from "./Field.js";
7
+ import { forwardRef } from "./~utils.js";
8
+ const Checkbox = forwardRef(
9
+ (props, forwardedRef) => {
10
+ const { id, ...rest } = props;
11
+ return /* @__PURE__ */ jsx(
12
+ FieldControl,
13
+ {
14
+ type: "checkable",
15
+ id,
16
+ render: /* @__PURE__ */ jsx(
17
+ AkCheckbox,
18
+ {
19
+ accessibleWhenDisabled: true,
20
+ ...rest,
21
+ className: cx("\u{1F95D}-checkbox", props.className),
22
+ ref: forwardedRef
23
+ }
24
+ )
25
+ }
26
+ );
27
+ }
28
+ );
19
29
  DEV: Checkbox.displayName = "Checkbox";
20
30
  export {
21
31
  Checkbox
@@ -0,0 +1,42 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import cx from "classnames";
3
+ import * as React from "react";
4
+ import { Role } from "@ariakit/react/role";
5
+ import { forwardRef } from "./~utils.js";
6
+ import { IconButton } from "./IconButton.js";
7
+ import { Dismiss } from "./Icon.js";
8
+ const Chip = forwardRef((props, forwardedRef) => {
9
+ const { variant = "solid", onDismiss, label, ...rest } = props;
10
+ const baseId = React.useId();
11
+ const labelId = `${baseId}-label`;
12
+ const dismissIconId = `${baseId}-dismiss`;
13
+ return /* @__PURE__ */ jsxs(
14
+ Role.div,
15
+ {
16
+ "data-kiwi-variant": variant,
17
+ ...rest,
18
+ className: cx("\u{1F95D}-chip", props.className),
19
+ ref: forwardedRef,
20
+ children: [
21
+ /* @__PURE__ */ jsx("span", { id: labelId, children: label }),
22
+ onDismiss && /* @__PURE__ */ jsx(
23
+ IconButton,
24
+ {
25
+ id: dismissIconId,
26
+ className: "\u{1F95D}-chip-dismiss-button",
27
+ variant: "ghost",
28
+ "aria-labelledby": `${dismissIconId} ${labelId}`,
29
+ label: "Dismiss",
30
+ labelVariant: "visually-hidden",
31
+ icon: /* @__PURE__ */ jsx(Dismiss, {}),
32
+ onClick: onDismiss
33
+ }
34
+ )
35
+ ]
36
+ }
37
+ );
38
+ });
39
+ DEV: Chip.displayName = "Chip";
40
+ export {
41
+ Chip
42
+ };
@@ -0,0 +1,29 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "./~utils.js";
3
+ import cx from "classnames";
4
+ import { Text } from "./Text.js";
5
+ import { FieldDescription } from "./Field.js";
6
+ const Description = forwardRef(
7
+ (props, forwardedRef) => {
8
+ const { id, tone, ...rest } = props;
9
+ return /* @__PURE__ */ jsx(
10
+ FieldDescription,
11
+ {
12
+ id,
13
+ render: /* @__PURE__ */ jsx(
14
+ Text,
15
+ {
16
+ ...rest,
17
+ variant: "caption-md",
18
+ "data-kiwi-tone": tone ?? "neutral",
19
+ className: cx("\u{1F95D}-description", props.className),
20
+ ref: forwardedRef
21
+ }
22
+ )
23
+ }
24
+ );
25
+ }
26
+ );
27
+ export {
28
+ Description
29
+ };
@@ -1,22 +1,21 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import cx from "classnames";
4
- import * as Ariakit from "@ariakit/react";
5
- const Divider = React.forwardRef(
6
- (props, forwardedRef) => {
7
- const { presentational, ...rest } = props;
8
- const Comp = presentational ? Ariakit.Role : Ariakit.Separator;
9
- return /* @__PURE__ */ jsx(
10
- Comp,
11
- {
12
- ...rest,
13
- className: cx("\u{1F95D}-divider", props.className),
14
- "data-kiwi-orientation": props.orientation,
15
- ref: forwardedRef
16
- }
17
- );
18
- }
19
- );
3
+ import { Role } from "@ariakit/react/role";
4
+ import { Separator } from "@ariakit/react/separator";
5
+ import { forwardRef } from "./~utils.js";
6
+ const Divider = forwardRef((props, forwardedRef) => {
7
+ const { presentational, ...rest } = props;
8
+ const Comp = presentational ? Role : Separator;
9
+ return /* @__PURE__ */ jsx(
10
+ Comp,
11
+ {
12
+ ...rest,
13
+ className: cx("\u{1F95D}-divider", props.className),
14
+ "data-kiwi-orientation": props.orientation,
15
+ ref: forwardedRef
16
+ }
17
+ );
18
+ });
20
19
  DEV: Divider.displayName = "Divider";
21
20
  export {
22
21
  Divider
@@ -1,11 +1,24 @@
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
- import { DisclosureArrow } from "./Icon.js";
8
- import { supportsPopover } from "./~utils.js";
6
+ import { Kbd } from "./Kbd.js";
7
+ import { Checkmark, DisclosureArrow, Icon } from "./Icon.js";
8
+ import {
9
+ forwardRef
10
+ } from "./~utils.js";
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 { useStoreState } from "@ariakit/react/store";
21
+ import { predefinedSymbols } from "./Kbd.internal.js";
9
22
  function DropdownMenu(props) {
10
23
  const {
11
24
  children,
@@ -14,21 +27,9 @@ function DropdownMenu(props) {
14
27
  setOpen: setOpenProp,
15
28
  defaultOpen: defaultOpenProp
16
29
  } = props;
17
- const store = Ariakit.useMenuStore();
18
- const open = Ariakit.useStoreState(store, (store2) => store2.open);
19
- const popover = Ariakit.useStoreState(store, (store2) => store2.popoverElement);
20
- React.useEffect(
21
- function syncPopoverWithOpenState() {
22
- if (popover?.isConnected) {
23
- popover?.togglePopover?.(open);
24
- }
25
- },
26
- [open, popover]
27
- );
28
30
  return /* @__PURE__ */ jsx(
29
- Ariakit.MenuProvider,
31
+ MenuProvider,
30
32
  {
31
- store,
32
33
  placement,
33
34
  defaultOpen: defaultOpenProp,
34
35
  open: openProp,
@@ -38,52 +39,146 @@ function DropdownMenu(props) {
38
39
  );
39
40
  }
40
41
  DEV: DropdownMenu.displayName = "DropdownMenu.Root";
41
- const DropdownMenuContent = React.forwardRef((props, forwardedRef) => {
42
- return /* @__PURE__ */ jsx(
43
- Ariakit.Menu,
44
- {
45
- portal: !supportsPopover,
46
- unmountOnHide: true,
47
- ...props,
48
- style: { zIndex: supportsPopover ? void 0 : 9999, ...props.style },
49
- wrapperProps: { popover: "manual" },
50
- className: cx("\u{1F95D}-dropdown-menu", props.className),
51
- ref: forwardedRef
52
- }
53
- );
54
- });
42
+ const DropdownMenuContent = forwardRef(
43
+ (props, forwardedRef) => {
44
+ const popover = usePopoverApi(useMenuContext());
45
+ return /* @__PURE__ */ jsx(
46
+ Menu,
47
+ {
48
+ portal: popover.portal,
49
+ unmountOnHide: true,
50
+ ...props,
51
+ gutter: 4,
52
+ style: { ...popover.style, ...props.style },
53
+ wrapperProps: popover.wrapperProps,
54
+ className: cx("\u{1F95D}-dropdown-menu", props.className),
55
+ ref: forwardedRef
56
+ }
57
+ );
58
+ }
59
+ );
55
60
  DEV: DropdownMenuContent.displayName = "DropdownMenu.Content";
56
- const DropdownMenuButton = React.forwardRef((props, forwardedRef) => {
57
- const { accessibleWhenDisabled = true, children, ...rest } = props;
61
+ const DropdownMenuButton = forwardRef(
62
+ (props, forwardedRef) => {
63
+ const { accessibleWhenDisabled = true, children, ...rest } = props;
64
+ const open = useStoreState(useMenuContext(), (state) => state?.open);
65
+ return /* @__PURE__ */ jsx(
66
+ MenuButton,
67
+ {
68
+ accessibleWhenDisabled: true,
69
+ render: /* @__PURE__ */ jsxs(Button, { accessibleWhenDisabled, children: [
70
+ children,
71
+ /* @__PURE__ */ jsx(DisclosureArrow, {})
72
+ ] }),
73
+ ...rest,
74
+ className: cx("\u{1F95D}-dropdown-menu-button", props.className),
75
+ "data-has-popover-open": open || void 0,
76
+ ref: forwardedRef
77
+ }
78
+ );
79
+ }
80
+ );
81
+ DEV: DropdownMenuButton.displayName = "DropdownMenu.Button";
82
+ const DropdownMenuItem = forwardRef(
83
+ (props, forwardedRef) => {
84
+ const { label, shortcuts, icon, ...rest } = props;
85
+ return /* @__PURE__ */ jsxs(
86
+ MenuItem,
87
+ {
88
+ accessibleWhenDisabled: true,
89
+ ...rest,
90
+ render: /* @__PURE__ */ jsx(ListItem.Root, { render: props.render }),
91
+ className: cx("\u{1F95D}-dropdown-menu-item", props.className),
92
+ ref: forwardedRef,
93
+ children: [
94
+ icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
95
+ /* @__PURE__ */ jsx(ListItem.Content, { children: label }),
96
+ shortcuts ? /* @__PURE__ */ jsx(DropdownMenuItemShortcuts, { shortcuts }) : null
97
+ ]
98
+ }
99
+ );
100
+ }
101
+ );
102
+ DEV: DropdownMenuItem.displayName = "DropdownMenu.Item";
103
+ const DropdownMenuItemShortcuts = forwardRef((props, forwardedRef) => {
104
+ const { shortcuts, ...rest } = props;
105
+ const shortcutKeys = React.useMemo(() => {
106
+ return shortcuts.split("+").map((key) => ({
107
+ key: key.trim(),
108
+ isSymbol: key in predefinedSymbols
109
+ }));
110
+ }, [shortcuts]);
58
111
  return /* @__PURE__ */ jsx(
59
- Ariakit.MenuButton,
112
+ ListItem.Decoration,
60
113
  {
61
- accessibleWhenDisabled: true,
62
- render: /* @__PURE__ */ jsxs(Button, { accessibleWhenDisabled, children: [
63
- children,
64
- /* @__PURE__ */ jsx(DisclosureArrow, {})
65
- ] }),
66
114
  ...rest,
67
- className: cx("\u{1F95D}-dropdown-menu-button", props.className),
68
- ref: forwardedRef
115
+ className: cx("\u{1F95D}-dropdown-menu-item-shortcuts", props.className),
116
+ ref: forwardedRef,
117
+ children: shortcutKeys.map(({ key, isSymbol }, index) => {
118
+ if (isSymbol) {
119
+ return /* @__PURE__ */ jsx(
120
+ Kbd,
121
+ {
122
+ variant: "ghost",
123
+ symbol: key
124
+ },
125
+ `${key + index}`
126
+ );
127
+ }
128
+ return /* @__PURE__ */ jsx(Kbd, { variant: "ghost", children: key }, `${key + index}`);
129
+ })
69
130
  }
70
131
  );
71
132
  });
72
- DEV: DropdownMenuButton.displayName = "DropdownMenu.Button";
73
- const DropdownMenuItem = React.forwardRef((props, forwardedRef) => {
74
- return /* @__PURE__ */ jsx(
75
- Ariakit.MenuItem,
133
+ DEV: DropdownMenuItemShortcuts.displayName = "DropdownMenuItemShortcuts";
134
+ const DropdownMenuIcon = forwardRef(
135
+ (props, forwardedRef) => {
136
+ const { icon, ...rest } = props;
137
+ return /* @__PURE__ */ jsx(
138
+ ListItem.Decoration,
139
+ {
140
+ render: /* @__PURE__ */ jsx(
141
+ Icon,
142
+ {
143
+ href: typeof icon === "string" ? icon : void 0,
144
+ render: React.isValidElement(icon) ? icon : void 0
145
+ }
146
+ ),
147
+ ...rest,
148
+ ref: forwardedRef
149
+ }
150
+ );
151
+ }
152
+ );
153
+ DEV: DropdownMenuIcon.displayName = "DropdownMenuIcon";
154
+ const DropdownMenuCheckboxItem = forwardRef((props, forwardedRef) => {
155
+ const { label, icon, ...rest } = props;
156
+ return /* @__PURE__ */ jsxs(
157
+ MenuItemCheckbox,
76
158
  {
77
159
  accessibleWhenDisabled: true,
78
- ...props,
160
+ value: props.defaultChecked ? "on" : void 0,
161
+ ...rest,
79
162
  render: /* @__PURE__ */ jsx(ListItem.Root, { render: props.render }),
80
- ref: forwardedRef
163
+ className: cx("\u{1F95D}-dropdown-menu-item", props.className),
164
+ ref: forwardedRef,
165
+ children: [
166
+ icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
167
+ /* @__PURE__ */ jsx(ListItem.Content, { children: label }),
168
+ /* @__PURE__ */ jsx(
169
+ ListItem.Decoration,
170
+ {
171
+ render: /* @__PURE__ */ jsx(Checkmark, { className: "\u{1F95D}-dropdown-menu-checkmark" })
172
+ }
173
+ )
174
+ ]
81
175
  }
82
176
  );
83
177
  });
84
- DEV: DropdownMenuItem.displayName = "DropdownMenu.Item";
178
+ DEV: DropdownMenuCheckboxItem.displayName = "DropdownMenu.CheckboxItem";
85
179
  export {
86
180
  DropdownMenuButton as Button,
181
+ DropdownMenuCheckboxItem as CheckboxItem,
87
182
  DropdownMenuContent as Content,
88
183
  DropdownMenuItem as Item,
89
184
  DropdownMenu as Root