@omer-x/tailwind-ui-kit 1.0.0-alpha.35 → 1.0.0-alpha.36

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 (35) hide show
  1. package/README.md +93 -0
  2. package/dist/components/form/BaseAutocomplete.d.ts +1 -1
  3. package/dist/components/menu/BaseContextMenu.d.ts +140 -0
  4. package/dist/components/menu/BaseContextMenu.js +38 -0
  5. package/dist/components/menu/BaseContextMenuTrigger.d.ts +15 -0
  6. package/dist/components/menu/BaseContextMenuTrigger.js +10 -0
  7. package/dist/components/menu/BaseMenuArrow.d.ts +19 -0
  8. package/dist/components/menu/BaseMenuArrow.js +10 -0
  9. package/dist/components/menu/BaseMenuCheckboxItem.d.ts +37 -0
  10. package/dist/components/menu/BaseMenuCheckboxItem.js +25 -0
  11. package/dist/components/menu/BaseMenuGroup.d.ts +8 -0
  12. package/dist/components/menu/BaseMenuGroup.js +7 -0
  13. package/dist/components/menu/BaseMenuGroupLabel.d.ts +8 -0
  14. package/dist/components/menu/BaseMenuGroupLabel.js +11 -0
  15. package/dist/components/menu/BaseMenuItem.d.ts +24 -0
  16. package/dist/components/menu/BaseMenuItem.js +12 -0
  17. package/dist/components/menu/BaseMenuLinkItem.d.ts +20 -0
  18. package/dist/components/menu/BaseMenuLinkItem.js +12 -0
  19. package/dist/components/menu/BaseMenuPopup.d.ts +70 -0
  20. package/dist/components/menu/BaseMenuPopup.js +37 -0
  21. package/dist/components/menu/BaseMenuRadioGroup.d.ts +19 -0
  22. package/dist/components/menu/BaseMenuRadioGroup.js +10 -0
  23. package/dist/components/menu/BaseMenuRadioItem.d.ts +36 -0
  24. package/dist/components/menu/BaseMenuRadioItem.js +24 -0
  25. package/dist/components/menu/BaseMenuSeparator.d.ts +11 -0
  26. package/dist/components/menu/BaseMenuSeparator.js +11 -0
  27. package/dist/components/menu/BaseMenuSubmenu.d.ts +28 -0
  28. package/dist/components/menu/BaseMenuSubmenu.js +10 -0
  29. package/dist/components/menu/BaseMenuSubmenuTrigger.d.ts +43 -0
  30. package/dist/components/menu/BaseMenuSubmenuTrigger.js +20 -0
  31. package/dist/components/menu/index.d.ts +12 -0
  32. package/dist/components/menu/index.js +1 -0
  33. package/dist/components/menu/menuItemStyles.d.ts +6 -0
  34. package/dist/components/menu/menuItemStyles.js +27 -0
  35. package/package.json +5 -1
package/README.md CHANGED
@@ -652,6 +652,99 @@ const removeAlert = createAlertDialogHandle<{ id: string, name: string }>();
652
652
  </BaseAlertDialog>
653
653
  ```
654
654
 
655
+ ### `@omer-x/tailwind-ui-kit/menu`
656
+
657
+ #### `BaseContextMenu`
658
+
659
+ A Base UI [`Context Menu`](https://base-ui.com/react/components/context-menu): a menu that opens at the pointer on right click or long press. `Popup` brings its portal and positioner, so a simple context menu needs no more than this:
660
+
661
+ ```tsx
662
+ import { BaseContextMenu } from "@omer-x/tailwind-ui-kit/menu";
663
+
664
+ <BaseContextMenu>
665
+ <BaseContextMenu.Trigger className="h-40 rounded border border-dashed">Right click here</BaseContextMenu.Trigger>
666
+ <BaseContextMenu.Popup className="rounded-md border bg-white shadow-lg">
667
+ <BaseContextMenu.Item className="data-highlighted:bg-neutral-100" onClick={reload}>Reload</BaseContextMenu.Item>
668
+ <BaseContextMenu.Separator className="bg-neutral-200" />
669
+ <BaseContextMenu.LinkItem className="data-highlighted:bg-neutral-100" href="/help">Help</BaseContextMenu.LinkItem>
670
+ </BaseContextMenu.Popup>
671
+ </BaseContextMenu>
672
+ ```
673
+
674
+ Like `BaseDialog`, the parts use dot notation, so build menus in a `"use client"` file. Every part except the root and `Trigger` is shared with the upcoming `BaseMenu`, so one set of popup and item styles themes both.
675
+
676
+ | Part | Renders | Description |
677
+ |------|---------|-------------|
678
+ | `BaseContextMenu` | nothing | Groups the parts and holds the open state |
679
+ | `BaseContextMenu.Trigger` | `<div>` | The area that opens the menu on right click or long press. `data-popup-open` while the menu is open |
680
+ | `BaseContextMenu.Popup` | `<div>` | The menu, portaled and placed at the pointer (or next to its submenu trigger), with scale and fade transitions. Scrolls when taller than the viewport. Optional backdrop |
681
+ | `BaseContextMenu.Arrow` | `<div>` | An arrow pointing at the anchor, inside `Popup`. Draw it yourself |
682
+ | `BaseContextMenu.Item` | `<div>` | An action. Closes the menu when clicked (`closeOnClick`, default `true`) |
683
+ | `BaseContextMenu.LinkItem` | `<a>` | A link. Use `render` for your router's link. Doesn't close the menu (`closeOnClick`, default `false`) |
684
+ | `BaseContextMenu.Separator` | `<div>` | A `1px` line between items (`my-1 h-px`). Give it a color with `className` |
685
+ | `BaseContextMenu.Group` | `<div>` | Groups related items, labelled by the `GroupLabel` inside it |
686
+ | `BaseContextMenu.GroupLabel` | `<div>` | The group's name (`text-xs font-medium`) |
687
+ | `BaseContextMenu.RadioGroup` | `<div>` | Holds `RadioItem`s: `value` / `defaultValue`, `onValueChange(value, event)`, `disabled` |
688
+ | `BaseContextMenu.RadioItem` | `<div>` | An option of a `RadioGroup` (`value`) |
689
+ | `BaseContextMenu.CheckboxItem` | `<div>` | A toggle: `checked` / `defaultChecked`, `onCheckedChange(checked, event)` |
690
+ | `BaseContextMenu.Submenu` | nothing | Holds a `SubmenuTrigger` and a nested `Popup`. Takes `open` / `defaultOpen`, `onOpenChange`, `onOpenChangeComplete`, `disabled`, `loopFocus`, `highlightItemOnHover` and `closeParentOnEsc` |
691
+ | `BaseContextMenu.SubmenuTrigger` | `<div>` | The item that opens its submenu, on click or hover (`openOnHover`, `delay`, `closeDelay`). `icon` is shown at the end (e.g. a chevron), with `iconClassName` for its `<span>` |
692
+
693
+ Every part that renders an element takes `className` and `render`.
694
+
695
+ Items (`Item`, `LinkItem`, `SubmenuTrigger`, `CheckboxItem`, `RadioItem`) share one layout: `flex items-center gap-2 px-3 py-1.5 text-sm`, no outline, faded and inert while disabled. They take `label` (the text for keyboard text navigation), and the `<div>` ones take `disabled` and `nativeButton` (set it to `true` when `render` renders a `<button>`). Style the highlighted item with `data-highlighted:`.
696
+
697
+ `CheckboxItem` and `RadioItem` put their indicator in a first `1rem` column, so labels line up whether it shows or not. Indicator props:
698
+
699
+ | Prop | Type | Description |
700
+ |------|------|-------------|
701
+ | `indicator` | `ReactNode` | Shown when checked, e.g. a check mark or a dot. Nothing by default |
702
+ | `renderIndicator` | `RenderProp<"span", State>` | Style or replace the indicator's `<span>` |
703
+ | `keepIndicatorMounted` | `boolean` | Keeps the indicator in the DOM when unchecked, e.g. to animate it out |
704
+ | `closeOnClick` | `boolean` | Closes the menu when clicked. Default `false` |
705
+
706
+ `BaseContextMenu` props:
707
+
708
+ | Prop | Type | Default | Description |
709
+ |------|------|---------|-------------|
710
+ | `open` / `defaultOpen` | `boolean` | `false` | Controlled / initial open state |
711
+ | `onOpenChange` | `(open, event) => void` | | Called with the new state and the DOM event that changed it (`undefined` when changed from code) |
712
+ | `onOpenChangeComplete` | `(open) => void` | | Called after the open or close transition ends |
713
+ | `disabled` | `boolean` | `false` | Doesn't open, so the browser's own context menu shows |
714
+ | `loopFocus` | `boolean` | `true` | Arrow keys wrap from the last item to the first |
715
+ | `highlightItemOnHover` | `boolean` | `true` | Highlights items under the pointer. Turn it off to style `:hover` apart from `data-highlighted` |
716
+ | `orientation` | `"vertical" \| "horizontal"` | `"vertical"` | Which arrow keys move between items |
717
+
718
+ `BaseContextMenu.Popup` props:
719
+
720
+ | Prop | Type | Default | Description |
721
+ |------|------|---------|-------------|
722
+ | `side` / `align` | `MenuSide` / `MenuAlign` | at the pointer | Where the popup sits against its anchor (`"top"`, `"bottom"`, `"left"`, `"right"`, `"inline-start"`, `"inline-end"` / `"start"`, `"center"`, `"end"`). Submenus default to `"inline-end"` / `"start"` |
723
+ | `sideOffset` / `alignOffset` | `number` | | Offsets from the anchor, in pixels |
724
+ | `collisionPadding` | `number` | `5` | Space kept from the viewport edges |
725
+ | `sticky` | `boolean` | `false` | Stays in view while the anchor scrolls away |
726
+ | `positionMethod` | `"absolute" \| "fixed"` | `"absolute"` | Use `"fixed"` when the anchor is inside a fixed container |
727
+ | `positionerClassName` / `renderPositioner` | `string` / `RenderProp<"div", MenuPositionerState>` | | Style or replace the positioner, the `<div>` around the popup that places it (`z-50`) |
728
+ | `finalFocus` | `MenuFocusTarget` | `true` | The element focused on close: `true` (default), `false` (don't move focus), a ref, or a function of the interaction type |
729
+ | `container` | `HTMLElement \| ShadowRoot \| RefObject \| null` | `<body>` | Where the popup is portaled to |
730
+ | `keepMounted` | `boolean` | `false` | Keeps the popup in the DOM while closed |
731
+ | `backdrop` | `boolean` | `false` | Renders a transparent full-screen backdrop (`fixed inset-0`) behind the popup |
732
+ | `renderBackdrop` | `RenderProp<"div", MenuBackdropState>` | | Style or replace the backdrop. A `className` on the element wins over the kit's conflicting classes |
733
+ | `render` | `RenderProp<"div", MenuPopupState>` | | The state is `{ open, side, align, nested }` |
734
+
735
+ Data attributes: the popup has `data-open` / `data-closed`, `data-side`, `data-align`, `data-nested` (in a submenu) and `data-starting-style` / `data-ending-style` during transitions. Items have `data-highlighted` and `data-disabled`; checkbox and radio items and their indicators also have `data-checked` / `data-unchecked`.
736
+
737
+ **Submenus:** put a `Submenu` among the items, with a `SubmenuTrigger` and another `Popup` inside:
738
+
739
+ ```tsx
740
+ <BaseContextMenu.Submenu>
741
+ <BaseContextMenu.SubmenuTrigger icon={<ChevronRight />}>Share</BaseContextMenu.SubmenuTrigger>
742
+ <BaseContextMenu.Popup className="rounded-md border bg-white shadow-lg">
743
+ <BaseContextMenu.Item>Email</BaseContextMenu.Item>
744
+ </BaseContextMenu.Popup>
745
+ </BaseContextMenu.Submenu>
746
+ ```
747
+
655
748
  ### `@omer-x/tailwind-ui-kit/disclosure`
656
749
 
657
750
  #### `BaseAccordion`
@@ -108,7 +108,7 @@ declare const _default: (<Item>({ onValueChange, onOpenChange, onItemHighlighted
108
108
  InputGroup: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
109
109
  render?: RenderProp<"div", AutocompleteInputState>;
110
110
  }) => import("react").JSX.Element;
111
- Input: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "value" | "defaultValue" | "size"> & {
111
+ Input: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "size" | "value"> & {
112
112
  size?: InputSize;
113
113
  render?: RenderProp<"input", AutocompleteInputState>;
114
114
  }) => import("react").JSX.Element;
@@ -0,0 +1,140 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ContextMenuTriggerState } from "./BaseContextMenuTrigger.js";
3
+ import "../../utils/index.js";
4
+ import { MenuAlign, MenuBackdropState, MenuFocusTarget, MenuPopupState, MenuPositionerState, MenuSide } from "./BaseMenuPopup.js";
5
+ import { MenuArrowState } from "./BaseMenuArrow.js";
6
+ import { MenuItemState } from "./BaseMenuItem.js";
7
+ import { MenuLinkItemState } from "./BaseMenuLinkItem.js";
8
+ import { MenuSeparatorState } from "./BaseMenuSeparator.js";
9
+ import { MenuRadioGroupState } from "./BaseMenuRadioGroup.js";
10
+ import { MenuRadioItemState } from "./BaseMenuRadioItem.js";
11
+ import { MenuCheckboxItemState } from "./BaseMenuCheckboxItem.js";
12
+ import { MenuSubmenuTriggerState } from "./BaseMenuSubmenuTrigger.js";
13
+ import { ReactNode } from "react";
14
+ type BaseContextMenuProps = {
15
+ open?: boolean;
16
+ defaultOpen?: boolean;
17
+ /** Called with the new state and the DOM event that changed it (none when it was changed from code). */
18
+ onOpenChange?: (open: boolean, event: Event | undefined) => void;
19
+ /** Called after the open or close transition ends. */
20
+ onOpenChangeComplete?: (open: boolean) => void;
21
+ /** Keeps the menu from opening, so the browser's own context menu shows. */
22
+ disabled?: boolean;
23
+ /**
24
+ * Moves focus from the last item back to the first with the arrow keys, and the other way around.
25
+ * @default true
26
+ */
27
+ loopFocus?: boolean;
28
+ /**
29
+ * Highlights items under the pointer. Turn it off to style `:hover` apart from `data-highlighted`.
30
+ * @default true
31
+ */
32
+ highlightItemOnHover?: boolean;
33
+ /**
34
+ * The arrow keys that move between items: up / down for `"vertical"`, left / right for `"horizontal"`.
35
+ * @default "vertical"
36
+ */
37
+ orientation?: "vertical" | "horizontal";
38
+ /** A `Trigger` and a `Popup`. */
39
+ children?: ReactNode;
40
+ };
41
+ declare const _default: (({ onOpenChange, ...otherProps }: BaseContextMenuProps) => import("react").JSX.Element) & {
42
+ Trigger: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
43
+ render?: RenderProp<"div", ContextMenuTriggerState>;
44
+ }) => import("react").JSX.Element;
45
+ Popup: ({ side, align, sideOffset, alignOffset, collisionPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, backdrop, renderBackdrop, className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
46
+ render?: RenderProp<"div", MenuPopupState>;
47
+ side?: MenuSide;
48
+ align?: MenuAlign;
49
+ sideOffset?: number;
50
+ alignOffset?: number;
51
+ collisionPadding?: number;
52
+ sticky?: boolean;
53
+ positionMethod?: "absolute" | "fixed";
54
+ positionerClassName?: string;
55
+ renderPositioner?: RenderProp<"div", MenuPositionerState>;
56
+ finalFocus?: MenuFocusTarget;
57
+ container?: HTMLElement | ShadowRoot | import("react").RefObject<HTMLElement | ShadowRoot | null> | null;
58
+ keepMounted?: boolean;
59
+ backdrop?: boolean;
60
+ renderBackdrop?: RenderProp<"div", MenuBackdropState>;
61
+ }) => import("react").JSX.Element;
62
+ Arrow: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
63
+ render?: RenderProp<"div", MenuArrowState>;
64
+ }) => import("react").JSX.Element;
65
+ Item: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
66
+ render?: RenderProp<"div", MenuItemState>;
67
+ disabled?: boolean;
68
+ label?: string;
69
+ closeOnClick?: boolean;
70
+ nativeButton?: boolean;
71
+ }) => import("react").JSX.Element;
72
+ LinkItem: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLAnchorElement> & import("react").AnchorHTMLAttributes<HTMLAnchorElement> & {
73
+ render?: RenderProp<"a", MenuLinkItemState>;
74
+ label?: string;
75
+ closeOnClick?: boolean;
76
+ }) => import("react").JSX.Element;
77
+ Separator: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
78
+ render?: RenderProp<"div", MenuSeparatorState>;
79
+ }) => import("react").JSX.Element;
80
+ Group: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
81
+ render?: RenderProp<"div">;
82
+ }) => import("react").JSX.Element;
83
+ GroupLabel: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
84
+ render?: RenderProp<"div">;
85
+ }) => import("react").JSX.Element;
86
+ RadioGroup: <Value>({ onValueChange, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "defaultValue"> & {
87
+ render?: RenderProp<"div", MenuRadioGroupState>;
88
+ value?: Value | undefined;
89
+ defaultValue?: Value | undefined;
90
+ onValueChange?: ((value: Value, event: Event) => void) | undefined;
91
+ disabled?: boolean;
92
+ }) => import("react").JSX.Element;
93
+ RadioItem: <Value>({ indicator, renderIndicator, keepIndicatorMounted, className, children, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
94
+ value: Value;
95
+ render?: RenderProp<"div", MenuRadioItemState>;
96
+ indicator?: ReactNode;
97
+ renderIndicator?: RenderProp<"span", MenuRadioItemState>;
98
+ keepIndicatorMounted?: boolean;
99
+ disabled?: boolean;
100
+ label?: string;
101
+ closeOnClick?: boolean;
102
+ nativeButton?: boolean;
103
+ }) => import("react").JSX.Element;
104
+ CheckboxItem: ({ indicator, renderIndicator, keepIndicatorMounted, onCheckedChange, className, children, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "defaultChecked"> & {
105
+ render?: RenderProp<"div", MenuCheckboxItemState>;
106
+ checked?: boolean;
107
+ defaultChecked?: boolean;
108
+ onCheckedChange?: (checked: boolean, event: Event) => void;
109
+ indicator?: ReactNode;
110
+ renderIndicator?: RenderProp<"span", MenuCheckboxItemState>;
111
+ keepIndicatorMounted?: boolean;
112
+ disabled?: boolean;
113
+ label?: string;
114
+ closeOnClick?: boolean;
115
+ nativeButton?: boolean;
116
+ }) => import("react").JSX.Element;
117
+ Submenu: ({ onOpenChange, ...otherProps }: {
118
+ open?: boolean;
119
+ defaultOpen?: boolean;
120
+ onOpenChange?: (open: boolean, event: Event | undefined) => void;
121
+ onOpenChangeComplete?: (open: boolean) => void;
122
+ disabled?: boolean;
123
+ loopFocus?: boolean;
124
+ highlightItemOnHover?: boolean;
125
+ closeParentOnEsc?: boolean;
126
+ children?: ReactNode;
127
+ }) => import("react").JSX.Element;
128
+ SubmenuTrigger: ({ icon, iconClassName, className, children, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
129
+ render?: RenderProp<"div", MenuSubmenuTriggerState>;
130
+ icon?: ReactNode;
131
+ iconClassName?: string;
132
+ disabled?: boolean;
133
+ label?: string;
134
+ openOnHover?: boolean;
135
+ delay?: number;
136
+ closeDelay?: number;
137
+ nativeButton?: boolean;
138
+ }) => import("react").JSX.Element;
139
+ };
140
+ export { _default as default };
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import { ContextMenu } from "@base-ui/react/context-menu";
3
+ import BaseContextMenuTrigger from "./BaseContextMenuTrigger.js";
4
+ import BaseMenuArrow from "./BaseMenuArrow.js";
5
+ import BaseMenuCheckboxItem from "./BaseMenuCheckboxItem.js";
6
+ import BaseMenuGroup from "./BaseMenuGroup.js";
7
+ import BaseMenuGroupLabel from "./BaseMenuGroupLabel.js";
8
+ import BaseMenuItem from "./BaseMenuItem.js";
9
+ import BaseMenuLinkItem from "./BaseMenuLinkItem.js";
10
+ import BaseMenuPopup from "./BaseMenuPopup.js";
11
+ import BaseMenuRadioGroup from "./BaseMenuRadioGroup.js";
12
+ import BaseMenuRadioItem from "./BaseMenuRadioItem.js";
13
+ import BaseMenuSeparator from "./BaseMenuSeparator.js";
14
+ import BaseMenuSubmenu from "./BaseMenuSubmenu.js";
15
+ import BaseMenuSubmenuTrigger from "./BaseMenuSubmenuTrigger.js";
16
+ import { jsx } from "react/jsx-runtime";
17
+ // src/components/menu/BaseContextMenu.tsx
18
+ /** Groups the parts of a context menu, a menu that opens at the pointer on right click or long press. Renders no element. */
19
+ const BaseContextMenu = ({ onOpenChange, ...otherProps }) => /* @__PURE__ */ jsx(ContextMenu.Root, {
20
+ ...otherProps,
21
+ onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event))
22
+ });
23
+ var BaseContextMenu_default = Object.assign(BaseContextMenu, {
24
+ Trigger: BaseContextMenuTrigger,
25
+ Popup: BaseMenuPopup,
26
+ Arrow: BaseMenuArrow,
27
+ Item: BaseMenuItem,
28
+ LinkItem: BaseMenuLinkItem,
29
+ Separator: BaseMenuSeparator,
30
+ Group: BaseMenuGroup,
31
+ GroupLabel: BaseMenuGroupLabel,
32
+ RadioGroup: BaseMenuRadioGroup,
33
+ RadioItem: BaseMenuRadioItem,
34
+ CheckboxItem: BaseMenuCheckboxItem,
35
+ Submenu: BaseMenuSubmenu,
36
+ SubmenuTrigger: BaseMenuSubmenuTrigger
37
+ });
38
+ export { BaseContextMenu_default as default };
@@ -0,0 +1,15 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ export type ContextMenuTriggerState = {
4
+ /** Whether the context menu is open. */
5
+ open: boolean;
6
+ };
7
+ type BaseContextMenuTriggerProps = ComponentProps<"div"> & {
8
+ render?: RenderProp<"div", ContextMenuTriggerState>;
9
+ };
10
+ /**
11
+ * The area that opens the context menu on right click or long press.
12
+ * Renders a `<div>`, with `data-popup-open` while its menu is open.
13
+ */
14
+ declare const BaseContextMenuTrigger: (props: BaseContextMenuTriggerProps) => import("react").JSX.Element;
15
+ export { BaseContextMenuTrigger as default };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { ContextMenu } from "@base-ui/react/context-menu";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/menu/BaseContextMenuTrigger.tsx
5
+ /**
6
+ * The area that opens the context menu on right click or long press.
7
+ * Renders a `<div>`, with `data-popup-open` while its menu is open.
8
+ */
9
+ const BaseContextMenuTrigger = (props) => /* @__PURE__ */ jsx(ContextMenu.Trigger, { ...props });
10
+ export { BaseContextMenuTrigger as default };
@@ -0,0 +1,19 @@
1
+ import { MenuSide } from "./BaseMenuPopup.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ export type MenuArrowState = {
5
+ open: boolean;
6
+ side: MenuSide;
7
+ align: "start" | "center" | "end";
8
+ /** Whether the arrow can't point at the center of the anchor. */
9
+ uncentered: boolean;
10
+ };
11
+ type BaseMenuArrowProps = ComponentProps<"div"> & {
12
+ render?: RenderProp<"div", MenuArrowState>;
13
+ };
14
+ /**
15
+ * An arrow that points at the anchor. Put it inside `Popup`.
16
+ * Renders a `<div>` with `data-side` and `data-align`. Size and draw it with `className` or `children`.
17
+ */
18
+ declare const BaseMenuArrow: (props: BaseMenuArrowProps) => import("react").JSX.Element;
19
+ export { BaseMenuArrow as default };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/menu/BaseMenuArrow.tsx
5
+ /**
6
+ * An arrow that points at the anchor. Put it inside `Popup`.
7
+ * Renders a `<div>` with `data-side` and `data-align`. Size and draw it with `className` or `children`.
8
+ */
9
+ const BaseMenuArrow = (props) => /* @__PURE__ */ jsx(Menu.Arrow, { ...props });
10
+ export { BaseMenuArrow as default };
@@ -0,0 +1,37 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps, ReactNode } from "react";
3
+ export type MenuCheckboxItemState = {
4
+ checked: boolean;
5
+ disabled: boolean;
6
+ /** Whether the item is highlighted by the pointer or the keyboard. */
7
+ highlighted: boolean;
8
+ };
9
+ type BaseMenuCheckboxItemProps = Omit<ComponentProps<"div">, "defaultChecked"> & {
10
+ render?: RenderProp<"div", MenuCheckboxItemState>;
11
+ checked?: boolean;
12
+ defaultChecked?: boolean;
13
+ /** Called with the new state and the DOM event that changed it. */
14
+ onCheckedChange?: (checked: boolean, event: Event) => void;
15
+ /** Shown before the text when checked, e.g. a check mark. */
16
+ indicator?: ReactNode;
17
+ renderIndicator?: RenderProp<"span", MenuCheckboxItemState>;
18
+ /** Keeps the indicator in the DOM when unchecked, e.g. to animate it out with CSS. */
19
+ keepIndicatorMounted?: boolean;
20
+ /** Ignores user interaction. */
21
+ disabled?: boolean;
22
+ /** The text used by keyboard text navigation. Defaults to the item's text. */
23
+ label?: string;
24
+ /**
25
+ * Closes the menu when the item is clicked.
26
+ * @default false
27
+ */
28
+ closeOnClick?: boolean;
29
+ /** Set to `true` when `render` renders a `<button>`. */
30
+ nativeButton?: boolean;
31
+ };
32
+ /**
33
+ * An item that toggles a setting. Renders a `<div>` with `role="menuitemcheckbox"`,
34
+ * `data-checked` / `data-unchecked`, `data-highlighted` and `data-disabled`.
35
+ */
36
+ declare const BaseMenuCheckboxItem: ({ indicator, renderIndicator, keepIndicatorMounted, onCheckedChange, className, children, ...otherProps }: BaseMenuCheckboxItemProps) => import("react").JSX.Element;
37
+ export { BaseMenuCheckboxItem as default };
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import { cn } from "cn";
4
+ import { menuIndicatorClassNames, menuIndicatorItemClassNames, menuIndicatorLabelClassNames, menuItemClassNames } from "./menuItemStyles.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/menu/BaseMenuCheckboxItem.tsx
7
+ /**
8
+ * An item that toggles a setting. Renders a `<div>` with `role="menuitemcheckbox"`,
9
+ * `data-checked` / `data-unchecked`, `data-highlighted` and `data-disabled`.
10
+ */
11
+ const BaseMenuCheckboxItem = ({ indicator, renderIndicator, keepIndicatorMounted, onCheckedChange, className, children, ...otherProps }) => /* @__PURE__ */ jsxs(Menu.CheckboxItem, {
12
+ ...otherProps,
13
+ onCheckedChange: onCheckedChange && ((checked, details) => onCheckedChange(checked, details.event)),
14
+ className: cn(menuItemClassNames, menuIndicatorItemClassNames, className),
15
+ children: [/* @__PURE__ */ jsx(Menu.CheckboxItemIndicator, {
16
+ keepMounted: keepIndicatorMounted,
17
+ render: renderIndicator,
18
+ className: cn(menuIndicatorClassNames),
19
+ children: indicator
20
+ }), /* @__PURE__ */ jsx("span", {
21
+ className: cn(menuIndicatorLabelClassNames),
22
+ children
23
+ })]
24
+ });
25
+ export { BaseMenuCheckboxItem as default };
@@ -0,0 +1,8 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ type BaseMenuGroupProps = ComponentProps<"div"> & {
4
+ render?: RenderProp<"div">;
5
+ };
6
+ /** Groups related items. Label it with a `GroupLabel` inside. Renders a `<div>` with `role="group"`. */
7
+ declare const BaseMenuGroup: (props: BaseMenuGroupProps) => import("react").JSX.Element;
8
+ export { BaseMenuGroup as default };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/menu/BaseMenuGroup.tsx
5
+ /** Groups related items. Label it with a `GroupLabel` inside. Renders a `<div>` with `role="group"`. */
6
+ const BaseMenuGroup = (props) => /* @__PURE__ */ jsx(Menu.Group, { ...props });
7
+ export { BaseMenuGroup as default };
@@ -0,0 +1,8 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ type BaseMenuGroupLabelProps = ComponentProps<"div"> & {
4
+ render?: RenderProp<"div">;
5
+ };
6
+ /** Names the group it's in. Renders a `<div>`. */
7
+ declare const BaseMenuGroupLabel: ({ className, ...otherProps }: BaseMenuGroupLabelProps) => import("react").JSX.Element;
8
+ export { BaseMenuGroupLabel as default };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/menu/BaseMenuGroupLabel.tsx
6
+ /** Names the group it's in. Renders a `<div>`. */
7
+ const BaseMenuGroupLabel = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Menu.GroupLabel, {
8
+ ...otherProps,
9
+ className: cn("px-3", "py-1.5", "text-xs", "font-medium", "select-none", className)
10
+ });
11
+ export { BaseMenuGroupLabel as default };
@@ -0,0 +1,24 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ export type MenuItemState = {
4
+ disabled: boolean;
5
+ /** Whether the item is highlighted by the pointer or the keyboard. */
6
+ highlighted: boolean;
7
+ };
8
+ type BaseMenuItemProps = ComponentProps<"div"> & {
9
+ render?: RenderProp<"div", MenuItemState>;
10
+ /** Ignores user interaction. */
11
+ disabled?: boolean;
12
+ /** The text used by keyboard text navigation. Defaults to the item's text. */
13
+ label?: string;
14
+ /**
15
+ * Closes the menu when the item is clicked.
16
+ * @default true
17
+ */
18
+ closeOnClick?: boolean;
19
+ /** Set to `true` when `render` renders a `<button>`. */
20
+ nativeButton?: boolean;
21
+ };
22
+ /** An action in a menu. Renders a `<div>`, with `data-highlighted` and `data-disabled`. */
23
+ declare const BaseMenuItem: ({ className, ...otherProps }: BaseMenuItemProps) => import("react").JSX.Element;
24
+ export { BaseMenuItem as default };
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import { cn } from "cn";
4
+ import { menuItemClassNames } from "./menuItemStyles.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ // src/components/menu/BaseMenuItem.tsx
7
+ /** An action in a menu. Renders a `<div>`, with `data-highlighted` and `data-disabled`. */
8
+ const BaseMenuItem = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Menu.Item, {
9
+ ...otherProps,
10
+ className: cn(menuItemClassNames, className)
11
+ });
12
+ export { BaseMenuItem as default };
@@ -0,0 +1,20 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ export type MenuLinkItemState = {
4
+ /** Whether the item is highlighted by the pointer or the keyboard. */
5
+ highlighted: boolean;
6
+ };
7
+ type BaseMenuLinkItemProps = ComponentProps<"a"> & {
8
+ /** Replaces the `<a>`, e.g. with your router's link component. */
9
+ render?: RenderProp<"a", MenuLinkItemState>;
10
+ /** The text used by keyboard text navigation. Defaults to the item's text. */
11
+ label?: string;
12
+ /**
13
+ * Closes the menu when the link is clicked.
14
+ * @default false
15
+ */
16
+ closeOnClick?: boolean;
17
+ };
18
+ /** A link in a menu. Renders an `<a>`, with `data-highlighted`. */
19
+ declare const BaseMenuLinkItem: ({ className, ...otherProps }: BaseMenuLinkItemProps) => import("react").JSX.Element;
20
+ export { BaseMenuLinkItem as default };
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import { cn } from "cn";
4
+ import { menuItemClassNames } from "./menuItemStyles.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ // src/components/menu/BaseMenuLinkItem.tsx
7
+ /** A link in a menu. Renders an `<a>`, with `data-highlighted`. */
8
+ const BaseMenuLinkItem = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Menu.LinkItem, {
9
+ ...otherProps,
10
+ className: cn(menuItemClassNames, className)
11
+ });
12
+ export { BaseMenuLinkItem as default };
@@ -0,0 +1,70 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps, RefObject } from "react";
3
+ export type MenuSide = "top" | "bottom" | "left" | "right" | "inline-start" | "inline-end";
4
+ export type MenuAlign = "start" | "center" | "end";
5
+ export type MenuPopupState = {
6
+ open: boolean;
7
+ side: MenuSide;
8
+ align: MenuAlign;
9
+ /** Whether the popup belongs to a submenu. */
10
+ nested: boolean;
11
+ };
12
+ export type MenuPositionerState = MenuPopupState & {
13
+ /** Whether the anchor is scrolled out of view. */
14
+ anchorHidden: boolean;
15
+ };
16
+ export type MenuBackdropState = {
17
+ open: boolean;
18
+ };
19
+ /** How the menu was closed. Empty when it's unknown. */
20
+ export type MenuInteractionType = "mouse" | "touch" | "pen" | "keyboard" | "";
21
+ /**
22
+ * - `true`: the default (the trigger, or the element focused before the menu opened).
23
+ * - `false`: don't move focus.
24
+ * - a ref: focus that element.
25
+ * - a function: return an element, `true` / `null` for the default, or `false` / `undefined` to not move focus.
26
+ */
27
+ export type MenuFocusTarget = boolean | RefObject<HTMLElement | null> | ((interactionType: MenuInteractionType) => boolean | HTMLElement | null | void);
28
+ type BaseMenuPopupProps = ComponentProps<"div"> & {
29
+ render?: RenderProp<"div", MenuPopupState>;
30
+ /** The side of the anchor the popup is placed on. It flips when there's no room. Submenus default to `"inline-end"`. */
31
+ side?: MenuSide;
32
+ /** How the popup is aligned to that side. Submenus default to `"start"`. */
33
+ align?: MenuAlign;
34
+ /** The gap between the anchor and the popup, in pixels. */
35
+ sideOffset?: number;
36
+ /** Moves the popup along the anchor's side, in pixels. */
37
+ alignOffset?: number;
38
+ /**
39
+ * The space kept between the popup and the edges of the viewport, in pixels.
40
+ * @default 5
41
+ */
42
+ collisionPadding?: number;
43
+ /** Keeps the popup in view while its anchor scrolls out of view. */
44
+ sticky?: boolean;
45
+ /**
46
+ * The CSS `position` of the positioner. Use `"fixed"` when the anchor is inside a fixed container.
47
+ * @default "absolute"
48
+ */
49
+ positionMethod?: "absolute" | "fixed";
50
+ /** Classes for the positioner, the `<div>` around the popup that places it. */
51
+ positionerClassName?: string;
52
+ /** Style or replace the positioner. A `className` on the element wins over the kit's conflicting classes. */
53
+ renderPositioner?: RenderProp<"div", MenuPositionerState>;
54
+ /** The element focused when the menu closes. */
55
+ finalFocus?: MenuFocusTarget;
56
+ /** Where the popup is portaled to. Defaults to `<body>`. */
57
+ container?: HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null;
58
+ /** Keeps the popup in the DOM while the menu is closed. */
59
+ keepMounted?: boolean;
60
+ /** Renders a backdrop behind the popup. It is a transparent full-screen layer until you style it. */
61
+ backdrop?: boolean;
62
+ /** Style or replace the backdrop. A `className` on the element wins over the kit's conflicting classes. */
63
+ renderBackdrop?: RenderProp<"div", MenuBackdropState>;
64
+ };
65
+ /**
66
+ * The menu's popup, with its portal and positioner (and an optional backdrop).
67
+ * Renders a `<div>` with `data-side`, `data-align`, `data-open` / `data-closed` and transition attributes.
68
+ */
69
+ declare const BaseMenuPopup: ({ side, align, sideOffset, alignOffset, collisionPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, backdrop, renderBackdrop, className, ...otherProps }: BaseMenuPopupProps) => import("react").JSX.Element;
70
+ export { BaseMenuPopup as default };
@@ -0,0 +1,37 @@
1
+ "use client";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import { cn } from "cn";
4
+ import { splitClassName } from "../../utils/split-class-name.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/menu/BaseMenuPopup.tsx
7
+ /**
8
+ * The menu's popup, with its portal and positioner (and an optional backdrop).
9
+ * Renders a `<div>` with `data-side`, `data-align`, `data-open` / `data-closed` and transition attributes.
10
+ */
11
+ const BaseMenuPopup = ({ side, align, sideOffset, alignOffset, collisionPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, backdrop = false, renderBackdrop, className, ...otherProps }) => {
12
+ const backdropElement = splitClassName(renderBackdrop);
13
+ const positionerElement = splitClassName(renderPositioner);
14
+ return /* @__PURE__ */ jsxs(Menu.Portal, {
15
+ container,
16
+ keepMounted,
17
+ children: [backdrop && /* @__PURE__ */ jsx(Menu.Backdrop, {
18
+ render: backdropElement.render,
19
+ className: cn("fixed", "inset-0", backdropElement.className)
20
+ }), /* @__PURE__ */ jsx(Menu.Positioner, {
21
+ side,
22
+ align,
23
+ sideOffset,
24
+ alignOffset,
25
+ collisionPadding,
26
+ sticky,
27
+ positionMethod,
28
+ render: positionerElement.render,
29
+ className: cn("z-50", "outline-hidden", positionerClassName, positionerElement.className),
30
+ children: /* @__PURE__ */ jsx(Menu.Popup, {
31
+ ...otherProps,
32
+ className: cn("max-h-(--available-height)", "min-w-32", "origin-(--transform-origin)", "overflow-y-auto", "py-1", "outline-hidden", "transition-[scale,opacity]", "duration-100", "ease-out", "data-ending-style:scale-95", "data-ending-style:opacity-0", "data-starting-style:scale-95", "data-starting-style:opacity-0", className)
33
+ })
34
+ })]
35
+ });
36
+ };
37
+ export { BaseMenuPopup as default };
@@ -0,0 +1,19 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ export type MenuRadioGroupState = {
4
+ disabled: boolean;
5
+ };
6
+ type BaseMenuRadioGroupProps<Value = unknown> = Omit<ComponentProps<"div">, "defaultValue"> & {
7
+ render?: RenderProp<"div", MenuRadioGroupState>;
8
+ /** The value of the selected item (controlled). */
9
+ value?: Value;
10
+ /** The value of the item selected at first. */
11
+ defaultValue?: Value;
12
+ /** Called with the selected item's value and the DOM event that selected it. */
13
+ onValueChange?: (value: Value, event: Event) => void;
14
+ /** Ignores user interaction on every item. */
15
+ disabled?: boolean;
16
+ };
17
+ /** Groups `RadioItem`s, of which one is selected. Renders a `<div>` with `role="group"`. */
18
+ declare const BaseMenuRadioGroup: <Value>({ onValueChange, ...otherProps }: BaseMenuRadioGroupProps<Value>) => import("react").JSX.Element;
19
+ export { BaseMenuRadioGroup as default };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/menu/BaseMenuRadioGroup.tsx
5
+ /** Groups `RadioItem`s, of which one is selected. Renders a `<div>` with `role="group"`. */
6
+ const BaseMenuRadioGroup = ({ onValueChange, ...otherProps }) => /* @__PURE__ */ jsx(Menu.RadioGroup, {
7
+ ...otherProps,
8
+ onValueChange: onValueChange && ((value, details) => onValueChange(value, details.event))
9
+ });
10
+ export { BaseMenuRadioGroup as default };
@@ -0,0 +1,36 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps, ReactNode } from "react";
3
+ export type MenuRadioItemState = {
4
+ /** Whether the item is the selected one. */
5
+ checked: boolean;
6
+ disabled: boolean;
7
+ /** Whether the item is highlighted by the pointer or the keyboard. */
8
+ highlighted: boolean;
9
+ };
10
+ type BaseMenuRadioItemProps<Value = unknown> = ComponentProps<"div"> & {
11
+ /** The value the `RadioGroup` gets when this item is selected. */
12
+ value: Value;
13
+ render?: RenderProp<"div", MenuRadioItemState>;
14
+ /** Shown before the text when selected, e.g. a dot. */
15
+ indicator?: ReactNode;
16
+ renderIndicator?: RenderProp<"span", MenuRadioItemState>;
17
+ /** Keeps the indicator in the DOM when not selected, e.g. to animate it out with CSS. */
18
+ keepIndicatorMounted?: boolean;
19
+ /** Ignores user interaction. */
20
+ disabled?: boolean;
21
+ /** The text used by keyboard text navigation. Defaults to the item's text. */
22
+ label?: string;
23
+ /**
24
+ * Closes the menu when the item is clicked.
25
+ * @default false
26
+ */
27
+ closeOnClick?: boolean;
28
+ /** Set to `true` when `render` renders a `<button>`. */
29
+ nativeButton?: boolean;
30
+ };
31
+ /**
32
+ * An option in a `RadioGroup`. Renders a `<div>` with `role="menuitemradio"`,
33
+ * `data-checked` / `data-unchecked`, `data-highlighted` and `data-disabled`.
34
+ */
35
+ declare const BaseMenuRadioItem: <Value>({ indicator, renderIndicator, keepIndicatorMounted, className, children, ...otherProps }: BaseMenuRadioItemProps<Value>) => import("react").JSX.Element;
36
+ export { BaseMenuRadioItem as default };
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import { cn } from "cn";
4
+ import { menuIndicatorClassNames, menuIndicatorItemClassNames, menuIndicatorLabelClassNames, menuItemClassNames } from "./menuItemStyles.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/menu/BaseMenuRadioItem.tsx
7
+ /**
8
+ * An option in a `RadioGroup`. Renders a `<div>` with `role="menuitemradio"`,
9
+ * `data-checked` / `data-unchecked`, `data-highlighted` and `data-disabled`.
10
+ */
11
+ const BaseMenuRadioItem = ({ indicator, renderIndicator, keepIndicatorMounted, className, children, ...otherProps }) => /* @__PURE__ */ jsxs(Menu.RadioItem, {
12
+ ...otherProps,
13
+ className: cn(menuItemClassNames, menuIndicatorItemClassNames, className),
14
+ children: [/* @__PURE__ */ jsx(Menu.RadioItemIndicator, {
15
+ keepMounted: keepIndicatorMounted,
16
+ render: renderIndicator,
17
+ className: cn(menuIndicatorClassNames),
18
+ children: indicator
19
+ }), /* @__PURE__ */ jsx("span", {
20
+ className: cn(menuIndicatorLabelClassNames),
21
+ children
22
+ })]
23
+ });
24
+ export { BaseMenuRadioItem as default };
@@ -0,0 +1,11 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ export type MenuSeparatorState = {
4
+ orientation: "horizontal" | "vertical";
5
+ };
6
+ type BaseMenuSeparatorProps = ComponentProps<"div"> & {
7
+ render?: RenderProp<"div", MenuSeparatorState>;
8
+ };
9
+ /** A line between items. Renders a `<div>` with `role="separator"`. Give it a color with `className`. */
10
+ declare const BaseMenuSeparator: ({ className, ...otherProps }: BaseMenuSeparatorProps) => import("react").JSX.Element;
11
+ export { BaseMenuSeparator as default };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { Separator } from "@base-ui/react/separator";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/menu/BaseMenuSeparator.tsx
6
+ /** A line between items. Renders a `<div>` with `role="separator"`. Give it a color with `className`. */
7
+ const BaseMenuSeparator = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Separator, {
8
+ ...otherProps,
9
+ className: cn("my-1", "h-px", className)
10
+ });
11
+ export { BaseMenuSeparator as default };
@@ -0,0 +1,28 @@
1
+ import { ReactNode } from "react";
2
+ type BaseMenuSubmenuProps = {
3
+ open?: boolean;
4
+ defaultOpen?: boolean;
5
+ /** Called with the new state and the DOM event that changed it (none when it was changed from code). */
6
+ onOpenChange?: (open: boolean, event: Event | undefined) => void;
7
+ /** Called after the open or close transition ends. */
8
+ onOpenChangeComplete?: (open: boolean) => void;
9
+ /** Ignores user interaction. */
10
+ disabled?: boolean;
11
+ /**
12
+ * Moves focus from the last item back to the first with the arrow keys, and the other way around.
13
+ * @default true
14
+ */
15
+ loopFocus?: boolean;
16
+ /**
17
+ * Highlights items under the pointer. Turn it off to style `:hover` apart from `data-highlighted`.
18
+ * @default true
19
+ */
20
+ highlightItemOnHover?: boolean;
21
+ /** Closes the whole menu on Escape, instead of only the submenu. */
22
+ closeParentOnEsc?: boolean;
23
+ /** A `SubmenuTrigger` and a `Popup`. */
24
+ children?: ReactNode;
25
+ };
26
+ /** Groups a submenu's trigger and popup. Put it among the items of a menu. Renders no element. */
27
+ declare const BaseMenuSubmenu: ({ onOpenChange, ...otherProps }: BaseMenuSubmenuProps) => import("react").JSX.Element;
28
+ export { BaseMenuSubmenu as default };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/menu/BaseMenuSubmenu.tsx
5
+ /** Groups a submenu's trigger and popup. Put it among the items of a menu. Renders no element. */
6
+ const BaseMenuSubmenu = ({ onOpenChange, ...otherProps }) => /* @__PURE__ */ jsx(Menu.SubmenuRoot, {
7
+ ...otherProps,
8
+ onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event))
9
+ });
10
+ export { BaseMenuSubmenu as default };
@@ -0,0 +1,43 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps, ReactNode } from "react";
3
+ export type MenuSubmenuTriggerState = {
4
+ disabled: boolean;
5
+ /** Whether the item is highlighted by the pointer or the keyboard. */
6
+ highlighted: boolean;
7
+ /** Whether its submenu is open. */
8
+ open: boolean;
9
+ };
10
+ type BaseMenuSubmenuTriggerProps = ComponentProps<"div"> & {
11
+ render?: RenderProp<"div", MenuSubmenuTriggerState>;
12
+ /** Shown at the end of the item, e.g. a chevron. */
13
+ icon?: ReactNode;
14
+ /** Classes for the `<span>` around the icon. */
15
+ iconClassName?: string;
16
+ /** Ignores user interaction. */
17
+ disabled?: boolean;
18
+ /** The text used by keyboard text navigation. Defaults to the item's text. */
19
+ label?: string;
20
+ /**
21
+ * Opens the submenu when the pointer rests on the item.
22
+ * @default true
23
+ */
24
+ openOnHover?: boolean;
25
+ /**
26
+ * How long the pointer rests on the item before the submenu opens, in milliseconds.
27
+ * @default 100
28
+ */
29
+ delay?: number;
30
+ /**
31
+ * How long the submenu stays open after the pointer leaves, in milliseconds.
32
+ * @default 0
33
+ */
34
+ closeDelay?: number;
35
+ /** Set to `true` when `render` renders a `<button>`. */
36
+ nativeButton?: boolean;
37
+ };
38
+ /**
39
+ * The item that opens a submenu. Put it inside a `Submenu`.
40
+ * Renders a `<div>` with `data-popup-open` while the submenu is open, `data-highlighted` and `data-disabled`.
41
+ */
42
+ declare const BaseMenuSubmenuTrigger: ({ icon, iconClassName, className, children, ...otherProps }: BaseMenuSubmenuTriggerProps) => import("react").JSX.Element;
43
+ export { BaseMenuSubmenuTrigger as default };
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { Menu } from "@base-ui/react/menu";
3
+ import { cn } from "cn";
4
+ import { menuItemClassNames } from "./menuItemStyles.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/menu/BaseMenuSubmenuTrigger.tsx
7
+ /**
8
+ * The item that opens a submenu. Put it inside a `Submenu`.
9
+ * Renders a `<div>` with `data-popup-open` while the submenu is open, `data-highlighted` and `data-disabled`.
10
+ */
11
+ const BaseMenuSubmenuTrigger = ({ icon, iconClassName, className, children, ...otherProps }) => /* @__PURE__ */ jsxs(Menu.SubmenuTrigger, {
12
+ ...otherProps,
13
+ className: cn(menuItemClassNames, className),
14
+ children: [children, icon && /* @__PURE__ */ jsx("span", {
15
+ "aria-hidden": "true",
16
+ className: cn("ml-auto", "flex", "shrink-0", iconClassName),
17
+ children: icon
18
+ })]
19
+ });
20
+ export { BaseMenuSubmenuTrigger as default };
@@ -0,0 +1,12 @@
1
+ import _default from "./BaseContextMenu.js";
2
+ import { ContextMenuTriggerState } from "./BaseContextMenuTrigger.js";
3
+ import { MenuArrowState } from "./BaseMenuArrow.js";
4
+ import { MenuCheckboxItemState } from "./BaseMenuCheckboxItem.js";
5
+ import { MenuItemState } from "./BaseMenuItem.js";
6
+ import { MenuLinkItemState } from "./BaseMenuLinkItem.js";
7
+ import { MenuAlign, MenuBackdropState, MenuFocusTarget, MenuInteractionType, MenuPopupState, MenuPositionerState, MenuSide } from "./BaseMenuPopup.js";
8
+ import { MenuRadioGroupState } from "./BaseMenuRadioGroup.js";
9
+ import { MenuRadioItemState } from "./BaseMenuRadioItem.js";
10
+ import { MenuSeparatorState } from "./BaseMenuSeparator.js";
11
+ import { MenuSubmenuTriggerState } from "./BaseMenuSubmenuTrigger.js";
12
+ export { _default as BaseContextMenu, type ContextMenuTriggerState, type MenuAlign, type MenuArrowState, type MenuBackdropState, type MenuCheckboxItemState, type MenuFocusTarget, type MenuInteractionType, type MenuItemState, type MenuLinkItemState, type MenuPopupState, type MenuPositionerState, type MenuRadioGroupState, type MenuRadioItemState, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerState };
@@ -0,0 +1 @@
1
+ export { default as BaseContextMenu } from "./BaseContextMenu.js";
@@ -0,0 +1,6 @@
1
+ /** Layout shared by every menu item (`Item`, `LinkItem`, `SubmenuTrigger`, `CheckboxItem`, `RadioItem`). */
2
+ export declare const menuItemClassNames: string[];
3
+ /** Checkbox and radio items put their indicator in a first column, so labels line up whether it's shown or not. */
4
+ export declare const menuIndicatorItemClassNames: string[];
5
+ export declare const menuIndicatorClassNames: string[];
6
+ export declare const menuIndicatorLabelClassNames: string[];
@@ -0,0 +1,27 @@
1
+ // src/components/menu/menuItemStyles.ts
2
+ /** Layout shared by every menu item (`Item`, `LinkItem`, `SubmenuTrigger`, `CheckboxItem`, `RadioItem`). */
3
+ const menuItemClassNames = [
4
+ "flex",
5
+ "cursor-default",
6
+ "items-center",
7
+ "gap-2",
8
+ "px-3",
9
+ "py-1.5",
10
+ "text-sm",
11
+ "outline-hidden",
12
+ "select-none",
13
+ "data-disabled:pointer-events-none",
14
+ "data-disabled:opacity-50"
15
+ ];
16
+ /** Checkbox and radio items put their indicator in a first column, so labels line up whether it's shown or not. */
17
+ const menuIndicatorItemClassNames = ["grid", "grid-cols-[1rem_1fr]"];
18
+ const menuIndicatorClassNames = [
19
+ "col-start-1",
20
+ "row-start-1",
21
+ "flex",
22
+ "size-4",
23
+ "items-center",
24
+ "justify-center"
25
+ ];
26
+ const menuIndicatorLabelClassNames = ["col-start-2", "row-start-1"];
27
+ export { menuIndicatorClassNames, menuIndicatorItemClassNames, menuIndicatorLabelClassNames, menuItemClassNames };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omer-x/tailwind-ui-kit",
3
- "version": "1.0.0-alpha.35",
3
+ "version": "1.0.0-alpha.36",
4
4
  "description": "Tailwind CSS-based React component library for building user interfaces",
5
5
  "keywords": [
6
6
  "tailwind",
@@ -46,6 +46,10 @@
46
46
  "types": "./dist/components/dialog/index.d.ts",
47
47
  "import": "./dist/components/dialog/index.js"
48
48
  },
49
+ "./menu": {
50
+ "types": "./dist/components/menu/index.d.ts",
51
+ "import": "./dist/components/menu/index.js"
52
+ },
49
53
  "./disclosure": {
50
54
  "types": "./dist/components/disclosure/index.d.ts",
51
55
  "import": "./dist/components/disclosure/index.js"