@omer-x/tailwind-ui-kit 1.0.0-alpha.36 → 1.0.0-alpha.38
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.
- package/README.md +182 -3
- package/dist/components/display/BaseMeter.d.ts +60 -0
- package/dist/components/display/BaseMeter.js +45 -0
- package/dist/components/display/BaseMeterIndicator.d.ts +9 -0
- package/dist/components/display/BaseMeterIndicator.js +12 -0
- package/dist/components/display/BaseMeterLabel.d.ts +9 -0
- package/dist/components/display/BaseMeterLabel.js +7 -0
- package/dist/components/display/BaseMeterTrack.d.ts +12 -0
- package/dist/components/display/BaseMeterTrack.js +12 -0
- package/dist/components/display/BaseMeterValue.d.ts +14 -0
- package/dist/components/display/BaseMeterValue.js +10 -0
- package/dist/components/display/barStyles.d.ts +5 -0
- package/dist/components/display/barStyles.js +20 -0
- package/dist/components/display/index.d.ts +2 -1
- package/dist/components/display/index.js +3 -1
- package/dist/components/form/BaseAutocomplete.d.ts +1 -1
- package/dist/components/menu/BaseContextMenu.d.ts +22 -12
- package/dist/components/menu/BaseMenu.d.ts +171 -0
- package/dist/components/menu/BaseMenu.js +62 -0
- package/dist/components/menu/BaseMenuClear.d.ts +16 -0
- package/dist/components/menu/BaseMenuClear.js +10 -0
- package/dist/components/menu/BaseMenuEmpty.d.ts +8 -0
- package/dist/components/menu/BaseMenuEmpty.js +7 -0
- package/dist/components/menu/BaseMenuInput.d.ts +15 -0
- package/dist/components/menu/BaseMenuInput.js +10 -0
- package/dist/components/menu/BaseMenuList.d.ts +11 -0
- package/dist/components/menu/BaseMenuList.js +14 -0
- package/dist/components/menu/BaseMenuPopup.d.ts +52 -6
- package/dist/components/menu/BaseMenuPopup.js +6 -1
- package/dist/components/menu/BaseMenuSubmenu.d.ts +3 -18
- package/dist/components/menu/BaseMenuSubmenu.js +16 -4
- package/dist/components/menu/BaseMenuTrigger.d.ts +26 -0
- package/dist/components/menu/BaseMenuTrigger.js +11 -0
- package/dist/components/menu/BaseMenuViewport.d.ts +18 -0
- package/dist/components/menu/BaseMenuViewport.js +11 -0
- package/dist/components/menu/createMenuHandle.d.ts +30 -0
- package/dist/components/menu/createMenuHandle.js +27 -0
- package/dist/components/menu/index.d.ts +9 -2
- package/dist/components/menu/index.js +4 -1
- package/dist/components/menu/menuTypes.d.ts +69 -0
- package/dist/components/menu/menuTypes.js +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { MenuTriggerState } from "./BaseMenuTrigger.js";
|
|
3
|
+
import "../../utils/index.js";
|
|
4
|
+
import { MenuAlign, MenuBackdropState, MenuCollisionAvoidance, MenuFocusTarget, MenuOffsetFunction, MenuPopupState, MenuPositionerState, MenuSide } from "./BaseMenuPopup.js";
|
|
5
|
+
import { MenuArrowState } from "./BaseMenuArrow.js";
|
|
6
|
+
import { MenuViewportState } from "./BaseMenuViewport.js";
|
|
7
|
+
import { MenuItemState } from "./BaseMenuItem.js";
|
|
8
|
+
import { MenuLinkItemState } from "./BaseMenuLinkItem.js";
|
|
9
|
+
import { MenuCheckboxItemState } from "./BaseMenuCheckboxItem.js";
|
|
10
|
+
import { MenuRadioGroupState } from "./BaseMenuRadioGroup.js";
|
|
11
|
+
import { MenuRadioItemState } from "./BaseMenuRadioItem.js";
|
|
12
|
+
import { MenuSeparatorState } from "./BaseMenuSeparator.js";
|
|
13
|
+
import { MenuSubmenuTriggerState } from "./BaseMenuSubmenuTrigger.js";
|
|
14
|
+
import { MenuInputState } from "./BaseMenuInput.js";
|
|
15
|
+
import { MenuClearState } from "./BaseMenuClear.js";
|
|
16
|
+
import { MenuHandle } from "./createMenuHandle.js";
|
|
17
|
+
import { MenuRootSharedProps } from "./menuTypes.js";
|
|
18
|
+
import { ReactNode } from "react";
|
|
19
|
+
type BaseMenuProps<Payload = unknown> = MenuRootSharedProps & {
|
|
20
|
+
/** Called with the new state and the DOM event that changed it (none when it was changed from code). */
|
|
21
|
+
onOpenChange?: (open: boolean, event: Event | undefined) => void;
|
|
22
|
+
/**
|
|
23
|
+
* - `true`: page scroll is locked and the rest of the page ignores the pointer.
|
|
24
|
+
* - `false`: the rest of the page stays usable.
|
|
25
|
+
*
|
|
26
|
+
* Menus opened by hover are never modal.
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
modal?: boolean;
|
|
30
|
+
/** Connects triggers placed outside the menu, and opens it from code. Create one with `createMenuHandle()`. */
|
|
31
|
+
handle?: MenuHandle<Payload>;
|
|
32
|
+
/** The `id` of the trigger the menu belongs to, for a controlled menu with several triggers. */
|
|
33
|
+
triggerId?: string | null;
|
|
34
|
+
/** The `id` of the trigger an initially open menu belongs to. */
|
|
35
|
+
defaultTriggerId?: string | null;
|
|
36
|
+
/** The menu's parts, or a function that gets the payload of the trigger that opened it. */
|
|
37
|
+
children?: ReactNode | ((context: {
|
|
38
|
+
payload: Payload | undefined;
|
|
39
|
+
}) => ReactNode);
|
|
40
|
+
};
|
|
41
|
+
declare const _default: (<Payload>(props: BaseMenuProps<Payload>) => import("react").JSX.Element) & {
|
|
42
|
+
Trigger: <Payload>({ handle, ...otherProps }: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
43
|
+
render?: RenderProp<"button", MenuTriggerState>;
|
|
44
|
+
handle?: MenuHandle<Payload> | undefined;
|
|
45
|
+
payload?: Payload | undefined;
|
|
46
|
+
openOnHover?: boolean;
|
|
47
|
+
delay?: number;
|
|
48
|
+
closeDelay?: number;
|
|
49
|
+
nativeButton?: boolean;
|
|
50
|
+
}) => import("react").JSX.Element;
|
|
51
|
+
Popup: ({ side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, disableAnchorTracking, arrowPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, backdrop, renderBackdrop, className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
52
|
+
render?: RenderProp<"div", MenuPopupState>;
|
|
53
|
+
side?: MenuSide;
|
|
54
|
+
align?: MenuAlign;
|
|
55
|
+
sideOffset?: number | MenuOffsetFunction;
|
|
56
|
+
alignOffset?: number | MenuOffsetFunction;
|
|
57
|
+
collisionPadding?: number | {
|
|
58
|
+
top?: number;
|
|
59
|
+
right?: number;
|
|
60
|
+
bottom?: number;
|
|
61
|
+
left?: number;
|
|
62
|
+
};
|
|
63
|
+
collisionBoundary?: "clipping-ancestors" | Element | Element[] | {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
};
|
|
69
|
+
collisionAvoidance?: MenuCollisionAvoidance;
|
|
70
|
+
anchor?: Element | import("react").RefObject<Element | null> | (() => Element | null) | null;
|
|
71
|
+
disableAnchorTracking?: boolean;
|
|
72
|
+
arrowPadding?: number;
|
|
73
|
+
sticky?: boolean;
|
|
74
|
+
positionMethod?: "absolute" | "fixed";
|
|
75
|
+
positionerClassName?: string;
|
|
76
|
+
renderPositioner?: RenderProp<"div", MenuPositionerState>;
|
|
77
|
+
finalFocus?: MenuFocusTarget;
|
|
78
|
+
container?: HTMLElement | ShadowRoot | import("react").RefObject<HTMLElement | ShadowRoot | null> | null;
|
|
79
|
+
keepMounted?: boolean;
|
|
80
|
+
backdrop?: boolean;
|
|
81
|
+
renderBackdrop?: RenderProp<"div", MenuBackdropState>;
|
|
82
|
+
}) => import("react").JSX.Element;
|
|
83
|
+
Arrow: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
84
|
+
render?: RenderProp<"div", MenuArrowState>;
|
|
85
|
+
}) => import("react").JSX.Element;
|
|
86
|
+
Viewport: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
87
|
+
render?: RenderProp<"div", MenuViewportState>;
|
|
88
|
+
}) => import("react").JSX.Element;
|
|
89
|
+
Item: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
90
|
+
render?: RenderProp<"div", MenuItemState>;
|
|
91
|
+
disabled?: boolean;
|
|
92
|
+
label?: string;
|
|
93
|
+
closeOnClick?: boolean;
|
|
94
|
+
nativeButton?: boolean;
|
|
95
|
+
}) => import("react").JSX.Element;
|
|
96
|
+
LinkItem: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLAnchorElement> & import("react").AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
97
|
+
render?: RenderProp<"a", MenuLinkItemState>;
|
|
98
|
+
label?: string;
|
|
99
|
+
closeOnClick?: boolean;
|
|
100
|
+
}) => import("react").JSX.Element;
|
|
101
|
+
CheckboxItem: ({ indicator, renderIndicator, keepIndicatorMounted, onCheckedChange, className, children, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "defaultChecked"> & {
|
|
102
|
+
render?: RenderProp<"div", MenuCheckboxItemState>;
|
|
103
|
+
checked?: boolean;
|
|
104
|
+
defaultChecked?: boolean;
|
|
105
|
+
onCheckedChange?: (checked: boolean, event: Event) => void;
|
|
106
|
+
indicator?: ReactNode;
|
|
107
|
+
renderIndicator?: RenderProp<"span", MenuCheckboxItemState>;
|
|
108
|
+
keepIndicatorMounted?: boolean;
|
|
109
|
+
disabled?: boolean;
|
|
110
|
+
label?: string;
|
|
111
|
+
closeOnClick?: boolean;
|
|
112
|
+
nativeButton?: boolean;
|
|
113
|
+
}) => import("react").JSX.Element;
|
|
114
|
+
RadioGroup: <Value>({ onValueChange, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "defaultValue"> & {
|
|
115
|
+
render?: RenderProp<"div", MenuRadioGroupState>;
|
|
116
|
+
value?: Value | undefined;
|
|
117
|
+
defaultValue?: Value | undefined;
|
|
118
|
+
onValueChange?: ((value: Value, event: Event) => void) | undefined;
|
|
119
|
+
disabled?: boolean;
|
|
120
|
+
}) => import("react").JSX.Element;
|
|
121
|
+
RadioItem: <Value>({ indicator, renderIndicator, keepIndicatorMounted, className, children, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
122
|
+
value: Value;
|
|
123
|
+
render?: RenderProp<"div", MenuRadioItemState>;
|
|
124
|
+
indicator?: ReactNode;
|
|
125
|
+
renderIndicator?: RenderProp<"span", MenuRadioItemState>;
|
|
126
|
+
keepIndicatorMounted?: boolean;
|
|
127
|
+
disabled?: boolean;
|
|
128
|
+
label?: string;
|
|
129
|
+
closeOnClick?: boolean;
|
|
130
|
+
nativeButton?: boolean;
|
|
131
|
+
}) => import("react").JSX.Element;
|
|
132
|
+
Group: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
133
|
+
render?: RenderProp<"div">;
|
|
134
|
+
}) => import("react").JSX.Element;
|
|
135
|
+
GroupLabel: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
136
|
+
render?: RenderProp<"div">;
|
|
137
|
+
}) => import("react").JSX.Element;
|
|
138
|
+
Separator: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
139
|
+
render?: RenderProp<"div", MenuSeparatorState>;
|
|
140
|
+
}) => import("react").JSX.Element;
|
|
141
|
+
Submenu: (props: MenuRootSharedProps & {
|
|
142
|
+
onOpenChange?: (open: boolean, event: Event | undefined) => void;
|
|
143
|
+
closeParentOnEsc?: boolean;
|
|
144
|
+
children?: ReactNode;
|
|
145
|
+
}) => import("react").JSX.Element;
|
|
146
|
+
SubmenuTrigger: ({ icon, iconClassName, className, children, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
147
|
+
render?: RenderProp<"div", MenuSubmenuTriggerState>;
|
|
148
|
+
icon?: ReactNode;
|
|
149
|
+
iconClassName?: string;
|
|
150
|
+
disabled?: boolean;
|
|
151
|
+
label?: string;
|
|
152
|
+
openOnHover?: boolean;
|
|
153
|
+
delay?: number;
|
|
154
|
+
closeDelay?: number;
|
|
155
|
+
nativeButton?: boolean;
|
|
156
|
+
}) => import("react").JSX.Element;
|
|
157
|
+
Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "value" | "defaultValue"> & {
|
|
158
|
+
render?: RenderProp<"input", MenuInputState>;
|
|
159
|
+
}) => import("react").JSX.Element;
|
|
160
|
+
Clear: (props: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
161
|
+
render?: RenderProp<"button", MenuClearState>;
|
|
162
|
+
nativeButton?: boolean;
|
|
163
|
+
}) => import("react").JSX.Element;
|
|
164
|
+
Empty: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
165
|
+
render?: RenderProp<"div">;
|
|
166
|
+
}) => import("react").JSX.Element;
|
|
167
|
+
List: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
168
|
+
render?: RenderProp<"div">;
|
|
169
|
+
}) => import("react").JSX.Element;
|
|
170
|
+
};
|
|
171
|
+
export { _default as default };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import BaseMenuArrow from "./BaseMenuArrow.js";
|
|
4
|
+
import BaseMenuCheckboxItem from "./BaseMenuCheckboxItem.js";
|
|
5
|
+
import BaseMenuClear from "./BaseMenuClear.js";
|
|
6
|
+
import BaseMenuEmpty from "./BaseMenuEmpty.js";
|
|
7
|
+
import BaseMenuGroup from "./BaseMenuGroup.js";
|
|
8
|
+
import BaseMenuGroupLabel from "./BaseMenuGroupLabel.js";
|
|
9
|
+
import BaseMenuInput from "./BaseMenuInput.js";
|
|
10
|
+
import BaseMenuItem from "./BaseMenuItem.js";
|
|
11
|
+
import BaseMenuLinkItem from "./BaseMenuLinkItem.js";
|
|
12
|
+
import BaseMenuList from "./BaseMenuList.js";
|
|
13
|
+
import BaseMenuPopup from "./BaseMenuPopup.js";
|
|
14
|
+
import BaseMenuRadioGroup from "./BaseMenuRadioGroup.js";
|
|
15
|
+
import BaseMenuRadioItem from "./BaseMenuRadioItem.js";
|
|
16
|
+
import BaseMenuSeparator from "./BaseMenuSeparator.js";
|
|
17
|
+
import BaseMenuSubmenu from "./BaseMenuSubmenu.js";
|
|
18
|
+
import BaseMenuSubmenuTrigger from "./BaseMenuSubmenuTrigger.js";
|
|
19
|
+
import BaseMenuTrigger from "./BaseMenuTrigger.js";
|
|
20
|
+
import BaseMenuViewport from "./BaseMenuViewport.js";
|
|
21
|
+
import { toBaseUIHandle } from "./createMenuHandle.js";
|
|
22
|
+
import { splitFilterProps } from "./menuTypes.js";
|
|
23
|
+
import { jsx } from "react/jsx-runtime";
|
|
24
|
+
// src/components/menu/BaseMenu.tsx
|
|
25
|
+
/** Groups the parts of a menu and holds its open state. Renders no element. */
|
|
26
|
+
const BaseMenu = (props) => {
|
|
27
|
+
const { filterProps, rootProps: { handle, onOpenChange, onItemHighlighted, ...otherProps } } = splitFilterProps(props);
|
|
28
|
+
const root = /* @__PURE__ */ jsx(Menu.Root, {
|
|
29
|
+
...otherProps,
|
|
30
|
+
handle: handle && toBaseUIHandle(handle),
|
|
31
|
+
onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event)),
|
|
32
|
+
onItemHighlighted: onItemHighlighted && ((item, details) => onItemHighlighted(item, {
|
|
33
|
+
reason: details.reason,
|
|
34
|
+
label: details.label
|
|
35
|
+
}))
|
|
36
|
+
});
|
|
37
|
+
return filterProps ? /* @__PURE__ */ jsx(Menu.FilterProvider, {
|
|
38
|
+
...filterProps,
|
|
39
|
+
children: root
|
|
40
|
+
}) : root;
|
|
41
|
+
};
|
|
42
|
+
var BaseMenu_default = Object.assign(BaseMenu, {
|
|
43
|
+
Trigger: BaseMenuTrigger,
|
|
44
|
+
Popup: BaseMenuPopup,
|
|
45
|
+
Arrow: BaseMenuArrow,
|
|
46
|
+
Viewport: BaseMenuViewport,
|
|
47
|
+
Item: BaseMenuItem,
|
|
48
|
+
LinkItem: BaseMenuLinkItem,
|
|
49
|
+
CheckboxItem: BaseMenuCheckboxItem,
|
|
50
|
+
RadioGroup: BaseMenuRadioGroup,
|
|
51
|
+
RadioItem: BaseMenuRadioItem,
|
|
52
|
+
Group: BaseMenuGroup,
|
|
53
|
+
GroupLabel: BaseMenuGroupLabel,
|
|
54
|
+
Separator: BaseMenuSeparator,
|
|
55
|
+
Submenu: BaseMenuSubmenu,
|
|
56
|
+
SubmenuTrigger: BaseMenuSubmenuTrigger,
|
|
57
|
+
Input: BaseMenuInput,
|
|
58
|
+
Clear: BaseMenuClear,
|
|
59
|
+
Empty: BaseMenuEmpty,
|
|
60
|
+
List: BaseMenuList
|
|
61
|
+
});
|
|
62
|
+
export { BaseMenu_default as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type MenuClearState = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
};
|
|
6
|
+
type BaseMenuClearProps = ComponentProps<"button"> & {
|
|
7
|
+
render?: RenderProp<"button", MenuClearState>;
|
|
8
|
+
/** Set to `false` when `render` doesn't render a `<button>`. */
|
|
9
|
+
nativeButton?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A button that clears the search box of a `filterable` menu. Renders a `<button>`, only while there's a query.
|
|
13
|
+
* It's a pointer shortcut: out of the tab order and hidden from assistive technology (`aria-hidden`).
|
|
14
|
+
*/
|
|
15
|
+
declare const BaseMenuClear: (props: BaseMenuClearProps) => import("react").JSX.Element;
|
|
16
|
+
export { BaseMenuClear 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/BaseMenuClear.tsx
|
|
5
|
+
/**
|
|
6
|
+
* A button that clears the search box of a `filterable` menu. Renders a `<button>`, only while there's a query.
|
|
7
|
+
* It's a pointer shortcut: out of the tab order and hidden from assistive technology (`aria-hidden`).
|
|
8
|
+
*/
|
|
9
|
+
const BaseMenuClear = (props) => /* @__PURE__ */ jsx(Menu.Clear, { ...props });
|
|
10
|
+
export { BaseMenuClear as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type BaseMenuEmptyProps = ComponentProps<"div"> & {
|
|
4
|
+
render?: RenderProp<"div">;
|
|
5
|
+
};
|
|
6
|
+
/** Shown only when no item of a `filterable` menu matches. Renders a `<div>` with `role="status"`, only then. */
|
|
7
|
+
declare const BaseMenuEmpty: (props: BaseMenuEmptyProps) => import("react").JSX.Element;
|
|
8
|
+
export { BaseMenuEmpty 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/BaseMenuEmpty.tsx
|
|
5
|
+
/** Shown only when no item of a `filterable` menu matches. Renders a `<div>` with `role="status"`, only then. */
|
|
6
|
+
const BaseMenuEmpty = (props) => /* @__PURE__ */ jsx(Menu.Empty, { ...props });
|
|
7
|
+
export { BaseMenuEmpty as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type MenuInputState = {
|
|
4
|
+
/** Whether the input shows its focus. Cleared while an item is highlighted with the arrow keys. */
|
|
5
|
+
highlighted: boolean;
|
|
6
|
+
};
|
|
7
|
+
type BaseMenuInputProps = Omit<ComponentProps<"input">, "value" | "defaultValue"> & {
|
|
8
|
+
render?: RenderProp<"input", MenuInputState>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The search box of a `filterable` menu: put it in the popup, outside the `List`. Typing filters the items.
|
|
12
|
+
* Renders an `<input>`, with `data-highlighted` while it has the visual focus.
|
|
13
|
+
*/
|
|
14
|
+
declare const BaseMenuInput: (props: BaseMenuInputProps) => import("react").JSX.Element;
|
|
15
|
+
export { BaseMenuInput 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/BaseMenuInput.tsx
|
|
5
|
+
/**
|
|
6
|
+
* The search box of a `filterable` menu: put it in the popup, outside the `List`. Typing filters the items.
|
|
7
|
+
* Renders an `<input>`, with `data-highlighted` while it has the visual focus.
|
|
8
|
+
*/
|
|
9
|
+
const BaseMenuInput = (props) => /* @__PURE__ */ jsx(Menu.Input, { ...props });
|
|
10
|
+
export { BaseMenuInput as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type BaseMenuListProps = ComponentProps<"div"> & {
|
|
4
|
+
render?: RenderProp<"div">;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Holds the items when the popup has other content too, like the search box of a `filterable` menu.
|
|
8
|
+
* Scrolls when the popup runs out of space. Renders a `<div>`.
|
|
9
|
+
*/
|
|
10
|
+
declare const BaseMenuList: ({ className, ...otherProps }: BaseMenuListProps) => import("react").JSX.Element;
|
|
11
|
+
export { BaseMenuList as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
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/BaseMenuList.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Holds the items when the popup has other content too, like the search box of a `filterable` menu.
|
|
8
|
+
* Scrolls when the popup runs out of space. Renders a `<div>`.
|
|
9
|
+
*/
|
|
10
|
+
const BaseMenuList = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Menu.List, {
|
|
11
|
+
...otherProps,
|
|
12
|
+
className: cn("min-h-0 flex-1 overflow-y-auto overscroll-contain", className)
|
|
13
|
+
});
|
|
14
|
+
export { BaseMenuList as default };
|
|
@@ -25,21 +25,67 @@ export type MenuInteractionType = "mouse" | "touch" | "pen" | "keyboard" | "";
|
|
|
25
25
|
* - a function: return an element, `true` / `null` for the default, or `false` / `undefined` to not move focus.
|
|
26
26
|
*/
|
|
27
27
|
export type MenuFocusTarget = boolean | RefObject<HTMLElement | null> | ((interactionType: MenuInteractionType) => boolean | HTMLElement | null | void);
|
|
28
|
+
/** Computes an offset from the popup's placement and the sizes of the anchor and the popup. */
|
|
29
|
+
export type MenuOffsetFunction = (data: {
|
|
30
|
+
side: MenuSide;
|
|
31
|
+
align: MenuAlign;
|
|
32
|
+
anchor: {
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
};
|
|
36
|
+
positioner: {
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
};
|
|
40
|
+
}) => number;
|
|
41
|
+
/** How the popup avoids the edges of `collisionBoundary`. */
|
|
42
|
+
export type MenuCollisionAvoidance = {
|
|
43
|
+
side?: "flip" | "none";
|
|
44
|
+
align?: "flip" | "shift" | "none";
|
|
45
|
+
fallbackAxisSide?: "start" | "end" | "none";
|
|
46
|
+
} | {
|
|
47
|
+
side?: "shift" | "none";
|
|
48
|
+
align?: "shift" | "none";
|
|
49
|
+
fallbackAxisSide?: "start" | "end" | "none";
|
|
50
|
+
};
|
|
51
|
+
type Rect = {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
};
|
|
28
57
|
type BaseMenuPopupProps = ComponentProps<"div"> & {
|
|
29
58
|
render?: RenderProp<"div", MenuPopupState>;
|
|
30
59
|
/** The side of the anchor the popup is placed on. It flips when there's no room. Submenus default to `"inline-end"`. */
|
|
31
60
|
side?: MenuSide;
|
|
32
61
|
/** How the popup is aligned to that side. Submenus default to `"start"`. */
|
|
33
62
|
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;
|
|
63
|
+
/** The gap between the anchor and the popup, in pixels, or a function of the placement and sizes. */
|
|
64
|
+
sideOffset?: number | MenuOffsetFunction;
|
|
65
|
+
/** Moves the popup along the anchor's side, in pixels, or a function of the placement and sizes. */
|
|
66
|
+
alignOffset?: number | MenuOffsetFunction;
|
|
38
67
|
/**
|
|
39
68
|
* The space kept between the popup and the edges of the viewport, in pixels.
|
|
40
69
|
* @default 5
|
|
41
70
|
*/
|
|
42
|
-
collisionPadding?: number
|
|
71
|
+
collisionPadding?: number | {
|
|
72
|
+
top?: number;
|
|
73
|
+
right?: number;
|
|
74
|
+
bottom?: number;
|
|
75
|
+
left?: number;
|
|
76
|
+
};
|
|
77
|
+
/** The area the popup stays inside. @default "clipping-ancestors" */
|
|
78
|
+
collisionBoundary?: "clipping-ancestors" | Element | Element[] | Rect;
|
|
79
|
+
collisionAvoidance?: MenuCollisionAvoidance;
|
|
80
|
+
/** The element the popup is placed against. Defaults to the trigger. */
|
|
81
|
+
anchor?: Element | RefObject<Element | null> | (() => Element | null) | null;
|
|
82
|
+
/** Stops following the anchor when it moves (e.g. on scroll). */
|
|
83
|
+
disableAnchorTracking?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The minimum distance between an `Arrow` and the popup's corners, in pixels.
|
|
86
|
+
* @default 5
|
|
87
|
+
*/
|
|
88
|
+
arrowPadding?: number;
|
|
43
89
|
/** Keeps the popup in view while its anchor scrolls out of view. */
|
|
44
90
|
sticky?: boolean;
|
|
45
91
|
/**
|
|
@@ -66,5 +112,5 @@ type BaseMenuPopupProps = ComponentProps<"div"> & {
|
|
|
66
112
|
* The menu's popup, with its portal and positioner (and an optional backdrop).
|
|
67
113
|
* Renders a `<div>` with `data-side`, `data-align`, `data-open` / `data-closed` and transition attributes.
|
|
68
114
|
*/
|
|
69
|
-
declare const BaseMenuPopup: ({ side, align, sideOffset, alignOffset, collisionPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, backdrop, renderBackdrop, className, ...otherProps }: BaseMenuPopupProps) => import("react").JSX.Element;
|
|
115
|
+
declare const BaseMenuPopup: ({ side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, disableAnchorTracking, arrowPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, backdrop, renderBackdrop, className, ...otherProps }: BaseMenuPopupProps) => import("react").JSX.Element;
|
|
70
116
|
export { BaseMenuPopup as default };
|
|
@@ -8,7 +8,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
* The menu's popup, with its portal and positioner (and an optional backdrop).
|
|
9
9
|
* Renders a `<div>` with `data-side`, `data-align`, `data-open` / `data-closed` and transition attributes.
|
|
10
10
|
*/
|
|
11
|
-
const BaseMenuPopup = ({ side, align, sideOffset, alignOffset, collisionPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, backdrop = false, renderBackdrop, className, ...otherProps }) => {
|
|
11
|
+
const BaseMenuPopup = ({ side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, disableAnchorTracking, arrowPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, backdrop = false, renderBackdrop, className, ...otherProps }) => {
|
|
12
12
|
const backdropElement = splitClassName(renderBackdrop);
|
|
13
13
|
const positionerElement = splitClassName(renderPositioner);
|
|
14
14
|
return /* @__PURE__ */ jsxs(Menu.Portal, {
|
|
@@ -23,6 +23,11 @@ const BaseMenuPopup = ({ side, align, sideOffset, alignOffset, collisionPadding,
|
|
|
23
23
|
sideOffset,
|
|
24
24
|
alignOffset,
|
|
25
25
|
collisionPadding,
|
|
26
|
+
collisionBoundary,
|
|
27
|
+
collisionAvoidance,
|
|
28
|
+
anchor,
|
|
29
|
+
disableAnchorTracking,
|
|
30
|
+
arrowPadding,
|
|
26
31
|
sticky,
|
|
27
32
|
positionMethod,
|
|
28
33
|
render: positionerElement.render,
|
|
@@ -1,28 +1,13 @@
|
|
|
1
|
+
import { MenuRootSharedProps } from "./menuTypes.js";
|
|
1
2
|
import { ReactNode } from "react";
|
|
2
|
-
type BaseMenuSubmenuProps = {
|
|
3
|
-
open?: boolean;
|
|
4
|
-
defaultOpen?: boolean;
|
|
3
|
+
type BaseMenuSubmenuProps = MenuRootSharedProps & {
|
|
5
4
|
/** Called with the new state and the DOM event that changed it (none when it was changed from code). */
|
|
6
5
|
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
6
|
/** Closes the whole menu on Escape, instead of only the submenu. */
|
|
22
7
|
closeParentOnEsc?: boolean;
|
|
23
8
|
/** A `SubmenuTrigger` and a `Popup`. */
|
|
24
9
|
children?: ReactNode;
|
|
25
10
|
};
|
|
26
11
|
/** Groups a submenu's trigger and popup. Put it among the items of a menu. Renders no element. */
|
|
27
|
-
declare const BaseMenuSubmenu: (
|
|
12
|
+
declare const BaseMenuSubmenu: (props: BaseMenuSubmenuProps) => import("react").JSX.Element;
|
|
28
13
|
export { BaseMenuSubmenu as default };
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { splitFilterProps } from "./menuTypes.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
// src/components/menu/BaseMenuSubmenu.tsx
|
|
5
6
|
/** Groups a submenu's trigger and popup. Put it among the items of a menu. Renders no element. */
|
|
6
|
-
const BaseMenuSubmenu = (
|
|
7
|
-
...otherProps
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const BaseMenuSubmenu = (props) => {
|
|
8
|
+
const { filterProps, rootProps: { onOpenChange, onItemHighlighted, ...otherProps } } = splitFilterProps(props);
|
|
9
|
+
const root = /* @__PURE__ */ jsx(Menu.SubmenuRoot, {
|
|
10
|
+
...otherProps,
|
|
11
|
+
onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event)),
|
|
12
|
+
onItemHighlighted: onItemHighlighted && ((item, details) => onItemHighlighted(item, {
|
|
13
|
+
reason: details.reason,
|
|
14
|
+
label: details.label
|
|
15
|
+
}))
|
|
16
|
+
});
|
|
17
|
+
return filterProps ? /* @__PURE__ */ jsx(Menu.FilterProvider, {
|
|
18
|
+
...filterProps,
|
|
19
|
+
children: root
|
|
20
|
+
}) : root;
|
|
21
|
+
};
|
|
10
22
|
export { BaseMenuSubmenu as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MenuHandle } from "./createMenuHandle.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
export type MenuTriggerState = {
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
/** Whether the menu is open and was opened by this trigger. */
|
|
7
|
+
open: boolean;
|
|
8
|
+
};
|
|
9
|
+
type BaseMenuTriggerProps<Payload = unknown> = ComponentProps<"button"> & {
|
|
10
|
+
render?: RenderProp<"button", MenuTriggerState>;
|
|
11
|
+
/** Connects a trigger placed outside its `BaseMenu`. Create one with `createMenuHandle()`. */
|
|
12
|
+
handle?: MenuHandle<Payload>;
|
|
13
|
+
/** Passed to the menu's function children when this trigger opens it. */
|
|
14
|
+
payload?: Payload;
|
|
15
|
+
/** Also opens the menu when the trigger is hovered. */
|
|
16
|
+
openOnHover?: boolean;
|
|
17
|
+
/** With `openOnHover`, the wait before opening, in milliseconds. @default 100 */
|
|
18
|
+
delay?: number;
|
|
19
|
+
/** With `openOnHover`, the wait before closing, in milliseconds. @default 0 */
|
|
20
|
+
closeDelay?: number;
|
|
21
|
+
/** Set to `false` when `render` doesn't render a `<button>`. */
|
|
22
|
+
nativeButton?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/** A button that opens the menu. Renders a `<button>`, with `data-popup-open` while its menu is open. */
|
|
25
|
+
declare const BaseMenuTrigger: <Payload>({ handle, ...otherProps }: BaseMenuTriggerProps<Payload>) => import("react").JSX.Element;
|
|
26
|
+
export { BaseMenuTrigger as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { toBaseUIHandle } from "./createMenuHandle.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/menu/BaseMenuTrigger.tsx
|
|
6
|
+
/** A button that opens the menu. Renders a `<button>`, with `data-popup-open` while its menu is open. */
|
|
7
|
+
const BaseMenuTrigger = ({ handle, ...otherProps }) => /* @__PURE__ */ jsx(Menu.Trigger, {
|
|
8
|
+
...otherProps,
|
|
9
|
+
handle: handle && toBaseUIHandle(handle)
|
|
10
|
+
});
|
|
11
|
+
export { BaseMenuTrigger as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type MenuViewportState = {
|
|
4
|
+
/** The direction the new trigger is in, relative to the previous one (e.g. `"right"`). */
|
|
5
|
+
activationDirection: string | undefined;
|
|
6
|
+
/** Whether the content is changing from one trigger's to another's. */
|
|
7
|
+
transitioning: boolean;
|
|
8
|
+
};
|
|
9
|
+
type BaseMenuViewportProps = ComponentProps<"div"> & {
|
|
10
|
+
render?: RenderProp<"div", MenuViewportState>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Animates the popup's content when one menu is opened by several triggers and its content depends
|
|
14
|
+
* on the trigger. Wrap the content in it, inside the popup. Renders a `<div>`, with
|
|
15
|
+
* `data-activation-direction` and `data-transitioning`.
|
|
16
|
+
*/
|
|
17
|
+
declare const BaseMenuViewport: (props: BaseMenuViewportProps) => import("react").JSX.Element;
|
|
18
|
+
export { BaseMenuViewport as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/menu/BaseMenuViewport.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Animates the popup's content when one menu is opened by several triggers and its content depends
|
|
7
|
+
* on the trigger. Wrap the content in it, inside the popup. Renders a `<div>`, with
|
|
8
|
+
* `data-activation-direction` and `data-transitioning`.
|
|
9
|
+
*/
|
|
10
|
+
const BaseMenuViewport = (props) => /* @__PURE__ */ jsx(Menu.Viewport, { ...props });
|
|
11
|
+
export { BaseMenuViewport as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Carries a handle's payload type. Type-only: it doesn't exist at runtime. */
|
|
2
|
+
declare const payloadType: unique symbol;
|
|
3
|
+
/**
|
|
4
|
+
* Opens and closes a menu from anywhere: from triggers outside the menu and from code.
|
|
5
|
+
* Create one with `createMenuHandle()` and pass it to `BaseMenu` and its triggers.
|
|
6
|
+
*
|
|
7
|
+
* A menu is placed against a trigger, so it can only be opened through one: there is no `openWithPayload`.
|
|
8
|
+
* Calls are ignored while no `BaseMenu` with this handle is mounted.
|
|
9
|
+
* Call the methods from event handlers or effects, never during render.
|
|
10
|
+
*/
|
|
11
|
+
export type MenuHandle<Payload = unknown> = {
|
|
12
|
+
/** Opens the menu as if the trigger with this `id` was pressed. The trigger must use the same handle. */
|
|
13
|
+
open: (triggerId: string) => void;
|
|
14
|
+
close: () => void;
|
|
15
|
+
/** Whether the menu is open. `false` while no `BaseMenu` with this handle is mounted. */
|
|
16
|
+
readonly isOpen: boolean;
|
|
17
|
+
/** Types the payload of triggers and of `BaseMenu`'s function children. Never set. */
|
|
18
|
+
readonly [payloadType]?: Payload;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Returns the Base UI handle behind a kit handle. Internal: not exported to apps.
|
|
22
|
+
* Its return type doesn't name Base UI so the declaration files don't either. Callers cast it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function toBaseUIHandle<Payload>(handle: MenuHandle<Payload>): object | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a handle to open a menu from triggers outside it, or from code.
|
|
27
|
+
* Pass the payload type to type the payload of triggers and of `BaseMenu`'s function children.
|
|
28
|
+
*/
|
|
29
|
+
export default function createMenuHandle<Payload = unknown>(): MenuHandle<Payload>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Menu } from "@base-ui/react/menu";
|
|
2
|
+
// src/components/menu/createMenuHandle.ts
|
|
3
|
+
const baseUIHandles = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
/**
|
|
5
|
+
* Returns the Base UI handle behind a kit handle. Internal: not exported to apps.
|
|
6
|
+
* Its return type doesn't name Base UI so the declaration files don't either. Callers cast it.
|
|
7
|
+
*/
|
|
8
|
+
function toBaseUIHandle(handle) {
|
|
9
|
+
return baseUIHandles.get(handle);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates a handle to open a menu from triggers outside it, or from code.
|
|
13
|
+
* Pass the payload type to type the payload of triggers and of `BaseMenu`'s function children.
|
|
14
|
+
*/
|
|
15
|
+
function createMenuHandle() {
|
|
16
|
+
const baseUIHandle = Menu.createHandle();
|
|
17
|
+
const handle = {
|
|
18
|
+
open: (triggerId) => baseUIHandle.open(triggerId),
|
|
19
|
+
close: () => baseUIHandle.close(),
|
|
20
|
+
get isOpen() {
|
|
21
|
+
return baseUIHandle.isOpen;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
baseUIHandles.set(handle, baseUIHandle);
|
|
25
|
+
return handle;
|
|
26
|
+
}
|
|
27
|
+
export { createMenuHandle as default, toBaseUIHandle };
|