@omer-x/tailwind-ui-kit 1.0.0-alpha.39 → 1.0.0-alpha.40
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 +100 -1
- package/dist/components/button/BaseButton.d.ts +2 -1
- package/dist/components/button/BaseButton.js +2 -24
- package/dist/components/button/BaseToggle.d.ts +35 -0
- package/dist/components/button/BaseToggle.js +23 -0
- package/dist/components/button/BaseToggleGroup.d.ts +26 -0
- package/dist/components/button/BaseToggleGroup.js +12 -0
- package/dist/components/button/buttonStyles.d.ts +3 -0
- package/dist/components/button/buttonStyles.js +29 -0
- package/dist/components/button/index.d.ts +3 -1
- package/dist/components/button/index.js +4 -1
- package/dist/components/menu/BaseMenubar.d.ts +187 -0
- package/dist/components/menu/BaseMenubar.js +18 -0
- package/dist/components/menu/index.d.ts +2 -1
- package/dist/components/menu/index.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -113,6 +113,61 @@ A Base UI [`Button`](https://base-ui.com/react/components/button) with sizes, a
|
|
|
113
113
|
<Button render={<Link href="/products/new" />} nativeButton={false}>New product</Button>
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
+
#### `BaseToggle`
|
|
117
|
+
|
|
118
|
+
A Base UI [`Toggle`](https://base-ui.com/react/components/toggle): a two-state button that is pressed or not. It shares `BaseButton`'s sizes and ripple effect.
|
|
119
|
+
|
|
120
|
+
| Prop | Type | Default | Description |
|
|
121
|
+
|------|------|---------|-------------|
|
|
122
|
+
| `pressed` | `boolean` | | Whether it's pressed, when controlled |
|
|
123
|
+
| `defaultPressed` | `boolean` | `false` | Whether it's pressed at first |
|
|
124
|
+
| `onPressedChange` | `(pressed: boolean, event: Event) => void` | | Called with the new state and the DOM event that changed it |
|
|
125
|
+
| `value` | `string` | | Identifies the toggle inside a `BaseToggleGroup` |
|
|
126
|
+
| `size` | `"lg" \| "md" \| "sm" \| "xs"` | `"md"` | Same heights, padding, font sizes and gaps as `BaseButton` |
|
|
127
|
+
| `iconOnly` | `boolean` | `false` | A square toggle for a single icon. Requires `aria-label` |
|
|
128
|
+
| `render` | `RenderProp<"button", ToggleState>` | | Render another element. The state is `{ pressed, disabled }` |
|
|
129
|
+
| `nativeButton` | `boolean` | `true` | Set to `false` when `render` doesn't render a `<button>` |
|
|
130
|
+
| …rest | `<button>` props | | `disabled`, `onClick`, `aria-label`, … (`type` is always `"button"`) |
|
|
131
|
+
|
|
132
|
+
It sets `aria-pressed`, plus `data-pressed` while pressed, `data-disabled` and `data-icon-only`. Style the pressed look with `data-pressed:`. The ripple is skipped when `onClick` calls `preventDefault()`.
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
<BaseToggle
|
|
136
|
+
iconOnly
|
|
137
|
+
aria-label="Favorite"
|
|
138
|
+
className="border border-neutral-400 data-pressed:bg-neutral-700 data-pressed:text-white"
|
|
139
|
+
>
|
|
140
|
+
<StarIcon />
|
|
141
|
+
</BaseToggle>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### `BaseToggleGroup`
|
|
145
|
+
|
|
146
|
+
A Base UI [`Toggle Group`](https://base-ui.com/react/components/toggle-group): shared state for the `BaseToggle`s inside it. Give every toggle a `value`. By default pressing one releases the others; arrow keys move focus between them.
|
|
147
|
+
|
|
148
|
+
| Prop | Type | Default | Description |
|
|
149
|
+
|------|------|---------|-------------|
|
|
150
|
+
| `value` | `readonly string[]` | | The `value`s of the pressed toggles, when controlled |
|
|
151
|
+
| `defaultValue` | `readonly string[]` | | The `value`s of the toggles pressed at first |
|
|
152
|
+
| `onValueChange` | `(value: string[], event: Event) => void` | | Called with the pressed `value`s and the DOM event that changed them |
|
|
153
|
+
| `multiple` | `boolean` | `false` | Lets several toggles be pressed at once |
|
|
154
|
+
| `disabled` | `boolean` | `false` | Disables every toggle in the group |
|
|
155
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Arrow-key direction, and the layout direction |
|
|
156
|
+
| `loopFocus` | `boolean` | `true` | Moves focus from the last toggle back to the first with the arrow keys |
|
|
157
|
+
| `className` | `string` | | Classes for the group `<div>` (default `flex`, `flex-col` when vertical) |
|
|
158
|
+
| `render` | `RenderProp<"div", ToggleGroupState>` | | Render another element for the group |
|
|
159
|
+
| …rest | `<div>` props | | Name the group with `aria-label` or `aria-labelledby` |
|
|
160
|
+
|
|
161
|
+
Render functions get `ToggleGroupState`: `{ disabled, multiple, orientation }`. The group has `role="group"` and sets `data-orientation`, `data-disabled` and `data-multiple`. Each toggle keeps its own `data-pressed` / `data-disabled`.
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
<BaseToggleGroup aria-label="Text alignment" defaultValue={["left"]} className="gap-1">
|
|
165
|
+
<Toggle value="left">Left</Toggle>
|
|
166
|
+
<Toggle value="center">Center</Toggle>
|
|
167
|
+
<Toggle value="right">Right</Toggle>
|
|
168
|
+
</BaseToggleGroup>
|
|
169
|
+
```
|
|
170
|
+
|
|
116
171
|
### `@omer-x/tailwind-ui-kit/form`
|
|
117
172
|
|
|
118
173
|
#### `BaseInput`
|
|
@@ -924,6 +979,50 @@ A `MenuHandle<Payload>` has `open(triggerId)`, `close()` and `isOpen`. Unlike th
|
|
|
924
979
|
- Calls are **ignored while the menu isn't mounted**. Keep the `BaseMenu` with the handle rendered.
|
|
925
980
|
- Call them **from event handlers or effects, never during render**.
|
|
926
981
|
|
|
982
|
+
#### `BaseMenubar`
|
|
983
|
+
|
|
984
|
+
A Base UI [`Menubar`](https://base-ui.com/react/components/menubar): an application menu bar holding several `BaseMenu`s. Once one menu is open, hovering another trigger switches to its menu, and the arrow keys move between the triggers. `BaseMenu` is attached as `BaseMenubar.Menu`, so one import is enough:
|
|
985
|
+
|
|
986
|
+
```tsx
|
|
987
|
+
import { BaseMenubar } from "@omer-x/tailwind-ui-kit/menu";
|
|
988
|
+
|
|
989
|
+
<BaseMenubar className="gap-1 rounded-md border p-1">
|
|
990
|
+
<BaseMenubar.Menu>
|
|
991
|
+
<BaseMenubar.Menu.Trigger className="rounded px-3 py-1 data-popup-open:bg-neutral-200">File</BaseMenubar.Menu.Trigger>
|
|
992
|
+
<BaseMenubar.Menu.Popup sideOffset={6} className="rounded-md border bg-white shadow-lg">
|
|
993
|
+
<BaseMenubar.Menu.Item className="data-highlighted:bg-neutral-100" onClick={save}>Save</BaseMenubar.Menu.Item>
|
|
994
|
+
</BaseMenubar.Menu.Popup>
|
|
995
|
+
</BaseMenubar.Menu>
|
|
996
|
+
<BaseMenubar.Menu>
|
|
997
|
+
<BaseMenubar.Menu.Trigger className="rounded px-3 py-1 data-popup-open:bg-neutral-200">Edit</BaseMenubar.Menu.Trigger>
|
|
998
|
+
<BaseMenubar.Menu.Popup sideOffset={6} className="rounded-md border bg-white shadow-lg">
|
|
999
|
+
<BaseMenubar.Menu.Item className="data-highlighted:bg-neutral-100" onClick={undo}>Undo</BaseMenubar.Menu.Item>
|
|
1000
|
+
</BaseMenubar.Menu.Popup>
|
|
1001
|
+
</BaseMenubar.Menu>
|
|
1002
|
+
</BaseMenubar>
|
|
1003
|
+
```
|
|
1004
|
+
|
|
1005
|
+
`<BaseMenu>` inside a `<BaseMenubar>` works the same. Every menu part (`Popup`, items, submenus, …) behaves as described for `BaseMenu`, with these differences:
|
|
1006
|
+
|
|
1007
|
+
- Triggers are items of the menubar (`role="menuitem"`), with one tab stop for the whole bar.
|
|
1008
|
+
- Popups open below a horizontal menubar's triggers and start-aligned (`side="bottom"`, `align="start"`), or beside a vertical one's.
|
|
1009
|
+
- The menubar's `modal` and `disabled` apply to every menu in it. `BaseMenu`'s own `modal` is ignored there.
|
|
1010
|
+
|
|
1011
|
+
| Part | Renders | Description |
|
|
1012
|
+
|------|---------|-------------|
|
|
1013
|
+
| `BaseMenubar` | `<div>` | The bar (`role="menubar"`, `flex`, `flex-col` when vertical). `data-orientation`, `data-modal`, `data-has-submenu-open` (one of its menus is open) |
|
|
1014
|
+
| `BaseMenubar.Menu` | nothing | `BaseMenu`, with all its parts (`BaseMenubar.Menu.Trigger`, `BaseMenubar.Menu.Popup`, …) |
|
|
1015
|
+
|
|
1016
|
+
`BaseMenubar` props:
|
|
1017
|
+
|
|
1018
|
+
| Prop | Type | Default | Description |
|
|
1019
|
+
|------|------|---------|-------------|
|
|
1020
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | The direction of the bar, and the arrow keys that move between its triggers |
|
|
1021
|
+
| `modal` | `boolean` | `true` | Locks page scroll and blocks outside pointer input while a menu is open |
|
|
1022
|
+
| `disabled` | `boolean` | `false` | Disables every menu (`data-disabled` on the triggers) |
|
|
1023
|
+
| `loopFocus` | `boolean` | `true` | Arrow keys wrap from the last trigger to the first |
|
|
1024
|
+
| `render` | `RenderProp<"div", MenubarState>` | | The state is `{ orientation, modal, hasSubmenuOpen }` |
|
|
1025
|
+
|
|
927
1026
|
### `@omer-x/tailwind-ui-kit/disclosure`
|
|
928
1027
|
|
|
929
1028
|
#### `BaseAccordion`
|
|
@@ -1252,7 +1351,7 @@ import { JustDiv } from "@omer-x/tailwind-ui-kit/elements";
|
|
|
1252
1351
|
|
|
1253
1352
|
#### `useRipples`
|
|
1254
1353
|
|
|
1255
|
-
The ripple effect of `BaseButton`, for your own clickable elements. Returns `[handleClick, ripples]`: call `handleClick` from `onClick` and render `ripples` inside the element.
|
|
1354
|
+
The ripple effect of `BaseButton` and `BaseToggle`, for your own clickable elements. Returns `[handleClick, ripples]`: call `handleClick` from `onClick` and render `ripples` inside the element.
|
|
1256
1355
|
|
|
1257
1356
|
- The element needs `relative` (the ripples are positioned absolutely and clipped to its rounded corners).
|
|
1258
1357
|
- Ripples use `bg-current`, so they follow the text color. They start from the center on keyboard clicks and are hidden when the user prefers reduced motion.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import { ButtonSize } from "./buttonStyles.js";
|
|
2
3
|
import { RenderProp } from "../../utils/render.js";
|
|
3
4
|
export type ButtonState = {
|
|
4
5
|
disabled: boolean;
|
|
@@ -12,7 +13,7 @@ type CommonProps = ComponentProps<"button"> & {
|
|
|
12
13
|
nativeButton?: boolean;
|
|
13
14
|
/** Keeps a disabled button focusable, so it stays in the tab order. */
|
|
14
15
|
focusableWhenDisabled?: boolean;
|
|
15
|
-
size?:
|
|
16
|
+
size?: ButtonSize;
|
|
16
17
|
/**
|
|
17
18
|
* Shows the spinner, blocks clicks and keeps the button focusable.
|
|
18
19
|
* A submit button is also pending while its form is submitting.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Button } from "@base-ui/react/button";
|
|
3
|
-
import { cn } from "cn";
|
|
4
3
|
import { use } from "react";
|
|
5
4
|
import { useFormStatus } from "react-dom";
|
|
6
5
|
import { useRipples } from "../../hooks/useRipples.js";
|
|
7
6
|
import { FormContext } from "../form/FormContext.js";
|
|
7
|
+
import { buttonClassName } from "./buttonStyles.js";
|
|
8
8
|
import { jsxs } from "react/jsx-runtime";
|
|
9
9
|
// src/components/button/BaseButton.tsx
|
|
10
10
|
const BaseButton = ({ size = "md", pending: pendingProp = false, spinner, iconOnly = false, type, disabled = false, focusableWhenDisabled = false, onClick, className, children, ...otherProps }) => {
|
|
@@ -25,29 +25,7 @@ const BaseButton = ({ size = "md", pending: pendingProp = false, spinner, iconOn
|
|
|
25
25
|
"aria-busy": pending || void 0,
|
|
26
26
|
"data-pending": pending ? "" : void 0,
|
|
27
27
|
"data-icon-only": iconOnly ? "" : void 0,
|
|
28
|
-
className:
|
|
29
|
-
"h-12 text-base leading-7 gap-3": size === "lg",
|
|
30
|
-
"h-10 text-sm leading-6 gap-3": size === "md",
|
|
31
|
-
"h-9 text-sm leading-5 gap-2": size === "sm",
|
|
32
|
-
"h-8 text-xs leading-4 gap-2": size === "xs",
|
|
33
|
-
"px-5": size === "lg" && !iconOnly,
|
|
34
|
-
"px-4": size === "md" && !iconOnly,
|
|
35
|
-
"px-3": size === "sm" && !iconOnly,
|
|
36
|
-
"px-2.5": size === "xs" && !iconOnly,
|
|
37
|
-
"aspect-square px-0": iconOnly
|
|
38
|
-
}, [
|
|
39
|
-
"relative",
|
|
40
|
-
"flex items-center justify-center",
|
|
41
|
-
"rounded-md",
|
|
42
|
-
"font-medium",
|
|
43
|
-
"select-none",
|
|
44
|
-
"outline-0",
|
|
45
|
-
"transition-colors",
|
|
46
|
-
"focus-visible:outline-2",
|
|
47
|
-
"focus-visible:outline-offset-2",
|
|
48
|
-
"cursor-pointer",
|
|
49
|
-
"data-disabled:cursor-default"
|
|
50
|
-
], className),
|
|
28
|
+
className: buttonClassName(size, iconOnly, className),
|
|
51
29
|
children: [
|
|
52
30
|
ripples,
|
|
53
31
|
pending && spinner,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { ButtonSize } from "./buttonStyles.js";
|
|
3
|
+
import { RenderProp } from "../../utils/render.js";
|
|
4
|
+
export type ToggleState = {
|
|
5
|
+
pressed: boolean;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
};
|
|
8
|
+
type CommonProps = Omit<ComponentProps<"button">, "value" | "defaultValue" | "onChange" | "type" | "form"> & {
|
|
9
|
+
render?: RenderProp<"button", ToggleState>;
|
|
10
|
+
/**
|
|
11
|
+
* Set to `false` when `render` doesn't render a `<button>`,
|
|
12
|
+
* so the toggle gets the attributes and keyboard handling a non-button element needs.
|
|
13
|
+
*/
|
|
14
|
+
nativeButton?: boolean;
|
|
15
|
+
size?: ButtonSize;
|
|
16
|
+
/** Whether the toggle is pressed, when controlled. */
|
|
17
|
+
pressed?: boolean;
|
|
18
|
+
/** Whether the toggle is pressed at first. */
|
|
19
|
+
defaultPressed?: boolean;
|
|
20
|
+
/** Called with the new state and the DOM event that changed it. */
|
|
21
|
+
onPressedChange?: (pressed: boolean, event: Event) => void;
|
|
22
|
+
/** Identifies the toggle inside a `BaseToggleGroup`. */
|
|
23
|
+
value?: string;
|
|
24
|
+
};
|
|
25
|
+
type TextToggleProps = {
|
|
26
|
+
iconOnly?: false;
|
|
27
|
+
};
|
|
28
|
+
type IconOnlyToggleProps = {
|
|
29
|
+
/** A square toggle whose only content is an icon. It needs an `aria-label`. */
|
|
30
|
+
"iconOnly": true;
|
|
31
|
+
"aria-label": string;
|
|
32
|
+
};
|
|
33
|
+
type BaseToggleProps = CommonProps & (TextToggleProps | IconOnlyToggleProps);
|
|
34
|
+
declare const BaseToggle: ({ size, iconOnly, onPressedChange, onClick, className, children, ...otherProps }: BaseToggleProps) => import("react").JSX.Element;
|
|
35
|
+
export { BaseToggle as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Toggle } from "@base-ui/react/toggle";
|
|
3
|
+
import "react";
|
|
4
|
+
import { useRipples } from "../../hooks/useRipples.js";
|
|
5
|
+
import { buttonClassName } from "./buttonStyles.js";
|
|
6
|
+
import { jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/components/button/BaseToggle.tsx
|
|
8
|
+
const BaseToggle = ({ size = "md", iconOnly = false, onPressedChange, onClick, className, children, ...otherProps }) => {
|
|
9
|
+
const [triggerRippleEffect, ripples] = useRipples();
|
|
10
|
+
const handleClick = (e) => {
|
|
11
|
+
onClick?.(e);
|
|
12
|
+
if (!e.defaultPrevented) triggerRippleEffect(e);
|
|
13
|
+
};
|
|
14
|
+
return /* @__PURE__ */ jsxs(Toggle, {
|
|
15
|
+
...otherProps,
|
|
16
|
+
onPressedChange: onPressedChange && ((pressed, details) => onPressedChange(pressed, details.event)),
|
|
17
|
+
onClick: handleClick,
|
|
18
|
+
"data-icon-only": iconOnly ? "" : void 0,
|
|
19
|
+
className: buttonClassName(size, iconOnly, className),
|
|
20
|
+
children: [ripples, children]
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
export { BaseToggle as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
export type ToggleGroupState = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
multiple: boolean;
|
|
6
|
+
orientation: "horizontal" | "vertical";
|
|
7
|
+
};
|
|
8
|
+
type BaseToggleGroupProps = Omit<ComponentProps<"div">, "defaultValue" | "onChange"> & {
|
|
9
|
+
render?: RenderProp<"div", ToggleGroupState>;
|
|
10
|
+
/** The `value`s of the pressed toggles, when controlled. */
|
|
11
|
+
value?: readonly string[];
|
|
12
|
+
/** The `value`s of the toggles pressed at first. */
|
|
13
|
+
defaultValue?: readonly string[];
|
|
14
|
+
/** Called with the `value`s of the pressed toggles and the DOM event that changed them. */
|
|
15
|
+
onValueChange?: (value: string[], event: Event) => void;
|
|
16
|
+
/** Lets several toggles be pressed at once. Otherwise pressing one releases the others. */
|
|
17
|
+
multiple?: boolean;
|
|
18
|
+
/** Disables every toggle in the group. */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** The direction of the arrow keys that move focus, and of the layout. */
|
|
21
|
+
orientation?: "horizontal" | "vertical";
|
|
22
|
+
/** Moves focus from the last toggle back to the first with the arrow keys (and the other way). */
|
|
23
|
+
loopFocus?: boolean;
|
|
24
|
+
};
|
|
25
|
+
declare const BaseToggleGroup: ({ onValueChange, className, ...otherProps }: BaseToggleGroupProps) => import("react").JSX.Element;
|
|
26
|
+
export { BaseToggleGroup as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ToggleGroup } from "@base-ui/react/toggle-group";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/button/BaseToggleGroup.tsx
|
|
7
|
+
const BaseToggleGroup = ({ onValueChange, className, ...otherProps }) => /* @__PURE__ */ jsx(ToggleGroup, {
|
|
8
|
+
...otherProps,
|
|
9
|
+
onValueChange: onValueChange && ((value, details) => onValueChange(value, details.event)),
|
|
10
|
+
className: cn("flex data-[orientation=vertical]:flex-col", className)
|
|
11
|
+
});
|
|
12
|
+
export { BaseToggleGroup as default };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { cn } from "cn";
|
|
2
|
+
// src/components/button/buttonStyles.ts
|
|
3
|
+
/** Layout, size, focus ring and cursor shared by every button-like component (`BaseButton`, `BaseToggle`). */
|
|
4
|
+
function buttonClassName(size, iconOnly, className) {
|
|
5
|
+
return cn({
|
|
6
|
+
"h-12 text-base leading-7 gap-3": size === "lg",
|
|
7
|
+
"h-10 text-sm leading-6 gap-3": size === "md",
|
|
8
|
+
"h-9 text-sm leading-5 gap-2": size === "sm",
|
|
9
|
+
"h-8 text-xs leading-4 gap-2": size === "xs",
|
|
10
|
+
"px-5": size === "lg" && !iconOnly,
|
|
11
|
+
"px-4": size === "md" && !iconOnly,
|
|
12
|
+
"px-3": size === "sm" && !iconOnly,
|
|
13
|
+
"px-2.5": size === "xs" && !iconOnly,
|
|
14
|
+
"aspect-square px-0": iconOnly
|
|
15
|
+
}, [
|
|
16
|
+
"relative",
|
|
17
|
+
"flex items-center justify-center",
|
|
18
|
+
"rounded-md",
|
|
19
|
+
"font-medium",
|
|
20
|
+
"select-none",
|
|
21
|
+
"outline-0",
|
|
22
|
+
"transition-colors",
|
|
23
|
+
"focus-visible:outline-2",
|
|
24
|
+
"focus-visible:outline-offset-2",
|
|
25
|
+
"cursor-pointer",
|
|
26
|
+
"data-disabled:cursor-default"
|
|
27
|
+
], className);
|
|
28
|
+
}
|
|
29
|
+
export { buttonClassName };
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import BaseButton, { ButtonState } from "./BaseButton.js";
|
|
2
|
-
|
|
2
|
+
import BaseToggle, { ToggleState } from "./BaseToggle.js";
|
|
3
|
+
import BaseToggleGroup, { ToggleGroupState } from "./BaseToggleGroup.js";
|
|
4
|
+
export { BaseButton, BaseToggle, BaseToggleGroup, type ButtonState, type ToggleGroupState, type ToggleState };
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { MenuRootSharedProps } from "./menuTypes.js";
|
|
2
|
+
import { MenuHandle } from "./createMenuHandle.js";
|
|
3
|
+
import { MenuTriggerState } from "./BaseMenuTrigger.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 { RenderProp } from "../../utils/render.js";
|
|
17
|
+
import { ComponentProps } from "react";
|
|
18
|
+
export type MenubarState = {
|
|
19
|
+
orientation: "horizontal" | "vertical";
|
|
20
|
+
/** Whether the menubar is modal. */
|
|
21
|
+
modal: boolean;
|
|
22
|
+
/** Whether one of its menus is open. */
|
|
23
|
+
hasSubmenuOpen: boolean;
|
|
24
|
+
};
|
|
25
|
+
type BaseMenubarProps = ComponentProps<"div"> & {
|
|
26
|
+
render?: RenderProp<"div", MenubarState>;
|
|
27
|
+
/**
|
|
28
|
+
* While a menu is open, page scroll is locked and the rest of the page ignores the pointer.
|
|
29
|
+
* Replaces the `modal` prop of the menus inside it.
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
modal?: boolean;
|
|
33
|
+
/** Disables every menu in the menubar. */
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The direction of the menubar, and the arrow keys that move between its triggers.
|
|
37
|
+
* @default "horizontal"
|
|
38
|
+
*/
|
|
39
|
+
orientation?: "horizontal" | "vertical";
|
|
40
|
+
/**
|
|
41
|
+
* Moves focus from the last trigger back to the first with the arrow keys, and the other way around.
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
loopFocus?: boolean;
|
|
45
|
+
};
|
|
46
|
+
declare const _default: (({ className, ...otherProps }: BaseMenubarProps) => import("react").JSX.Element) & {
|
|
47
|
+
Menu: (<Payload>(props: MenuRootSharedProps & {
|
|
48
|
+
onOpenChange?: (open: boolean, event: Event | undefined) => void;
|
|
49
|
+
modal?: boolean;
|
|
50
|
+
handle?: MenuHandle<Payload> | undefined;
|
|
51
|
+
triggerId?: string | null;
|
|
52
|
+
defaultTriggerId?: string | null;
|
|
53
|
+
children?: import("react").ReactNode | ((context: {
|
|
54
|
+
payload: Payload | undefined;
|
|
55
|
+
}) => import("react").ReactNode);
|
|
56
|
+
}) => import("react").JSX.Element) & {
|
|
57
|
+
Trigger: <Payload>({ handle, ...otherProps }: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
58
|
+
render?: RenderProp<"button", MenuTriggerState>;
|
|
59
|
+
handle?: MenuHandle<Payload> | undefined;
|
|
60
|
+
payload?: Payload | undefined;
|
|
61
|
+
openOnHover?: boolean;
|
|
62
|
+
delay?: number;
|
|
63
|
+
closeDelay?: number;
|
|
64
|
+
nativeButton?: boolean;
|
|
65
|
+
}) => import("react").JSX.Element;
|
|
66
|
+
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> & {
|
|
67
|
+
render?: RenderProp<"div", MenuPopupState>;
|
|
68
|
+
side?: MenuSide;
|
|
69
|
+
align?: MenuAlign;
|
|
70
|
+
sideOffset?: number | MenuOffsetFunction;
|
|
71
|
+
alignOffset?: number | MenuOffsetFunction;
|
|
72
|
+
collisionPadding?: number | {
|
|
73
|
+
top?: number;
|
|
74
|
+
right?: number;
|
|
75
|
+
bottom?: number;
|
|
76
|
+
left?: number;
|
|
77
|
+
};
|
|
78
|
+
collisionBoundary?: "clipping-ancestors" | Element | Element[] | {
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
width: number;
|
|
82
|
+
height: number;
|
|
83
|
+
};
|
|
84
|
+
collisionAvoidance?: MenuCollisionAvoidance;
|
|
85
|
+
anchor?: Element | import("react").RefObject<Element | null> | (() => Element | null) | null;
|
|
86
|
+
disableAnchorTracking?: boolean;
|
|
87
|
+
arrowPadding?: number;
|
|
88
|
+
sticky?: boolean;
|
|
89
|
+
positionMethod?: "absolute" | "fixed";
|
|
90
|
+
positionerClassName?: string;
|
|
91
|
+
renderPositioner?: RenderProp<"div", MenuPositionerState>;
|
|
92
|
+
finalFocus?: MenuFocusTarget;
|
|
93
|
+
container?: HTMLElement | ShadowRoot | import("react").RefObject<HTMLElement | ShadowRoot | null> | null;
|
|
94
|
+
keepMounted?: boolean;
|
|
95
|
+
backdrop?: boolean;
|
|
96
|
+
renderBackdrop?: RenderProp<"div", MenuBackdropState>;
|
|
97
|
+
}) => import("react").JSX.Element;
|
|
98
|
+
Arrow: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
99
|
+
render?: RenderProp<"div", MenuArrowState>;
|
|
100
|
+
}) => import("react").JSX.Element;
|
|
101
|
+
Viewport: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
102
|
+
render?: RenderProp<"div", MenuViewportState>;
|
|
103
|
+
}) => import("react").JSX.Element;
|
|
104
|
+
Item: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
105
|
+
render?: RenderProp<"div", MenuItemState>;
|
|
106
|
+
disabled?: boolean;
|
|
107
|
+
label?: string;
|
|
108
|
+
closeOnClick?: boolean;
|
|
109
|
+
nativeButton?: boolean;
|
|
110
|
+
}) => import("react").JSX.Element;
|
|
111
|
+
LinkItem: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLAnchorElement> & import("react").AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
112
|
+
render?: RenderProp<"a", MenuLinkItemState>;
|
|
113
|
+
label?: string;
|
|
114
|
+
closeOnClick?: boolean;
|
|
115
|
+
}) => import("react").JSX.Element;
|
|
116
|
+
CheckboxItem: ({ indicator, renderIndicator, keepIndicatorMounted, onCheckedChange, className, children, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "defaultChecked"> & {
|
|
117
|
+
render?: RenderProp<"div", MenuCheckboxItemState>;
|
|
118
|
+
checked?: boolean;
|
|
119
|
+
defaultChecked?: boolean;
|
|
120
|
+
onCheckedChange?: (checked: boolean, event: Event) => void;
|
|
121
|
+
indicator?: import("react").ReactNode;
|
|
122
|
+
renderIndicator?: RenderProp<"span", MenuCheckboxItemState>;
|
|
123
|
+
keepIndicatorMounted?: boolean;
|
|
124
|
+
disabled?: boolean;
|
|
125
|
+
label?: string;
|
|
126
|
+
closeOnClick?: boolean;
|
|
127
|
+
nativeButton?: boolean;
|
|
128
|
+
}) => import("react").JSX.Element;
|
|
129
|
+
RadioGroup: <Value>({ onValueChange, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "defaultValue"> & {
|
|
130
|
+
render?: RenderProp<"div", MenuRadioGroupState>;
|
|
131
|
+
value?: Value | undefined;
|
|
132
|
+
defaultValue?: Value | undefined;
|
|
133
|
+
onValueChange?: ((value: Value, event: Event) => void) | undefined;
|
|
134
|
+
disabled?: boolean;
|
|
135
|
+
}) => import("react").JSX.Element;
|
|
136
|
+
RadioItem: <Value>({ indicator, renderIndicator, keepIndicatorMounted, className, children, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
137
|
+
value: Value;
|
|
138
|
+
render?: RenderProp<"div", MenuRadioItemState>;
|
|
139
|
+
indicator?: import("react").ReactNode;
|
|
140
|
+
renderIndicator?: RenderProp<"span", MenuRadioItemState>;
|
|
141
|
+
keepIndicatorMounted?: boolean;
|
|
142
|
+
disabled?: boolean;
|
|
143
|
+
label?: string;
|
|
144
|
+
closeOnClick?: boolean;
|
|
145
|
+
nativeButton?: boolean;
|
|
146
|
+
}) => import("react").JSX.Element;
|
|
147
|
+
Group: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
148
|
+
render?: RenderProp<"div">;
|
|
149
|
+
}) => import("react").JSX.Element;
|
|
150
|
+
GroupLabel: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
151
|
+
render?: RenderProp<"div">;
|
|
152
|
+
}) => import("react").JSX.Element;
|
|
153
|
+
Separator: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
154
|
+
render?: RenderProp<"div", MenuSeparatorState>;
|
|
155
|
+
}) => import("react").JSX.Element;
|
|
156
|
+
Submenu: (props: MenuRootSharedProps & {
|
|
157
|
+
onOpenChange?: (open: boolean, event: Event | undefined) => void;
|
|
158
|
+
closeParentOnEsc?: boolean;
|
|
159
|
+
children?: import("react").ReactNode;
|
|
160
|
+
}) => import("react").JSX.Element;
|
|
161
|
+
SubmenuTrigger: ({ icon, iconClassName, className, children, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
162
|
+
render?: RenderProp<"div", MenuSubmenuTriggerState>;
|
|
163
|
+
icon?: import("react").ReactNode;
|
|
164
|
+
iconClassName?: string;
|
|
165
|
+
disabled?: boolean;
|
|
166
|
+
label?: string;
|
|
167
|
+
openOnHover?: boolean;
|
|
168
|
+
delay?: number;
|
|
169
|
+
closeDelay?: number;
|
|
170
|
+
nativeButton?: boolean;
|
|
171
|
+
}) => import("react").JSX.Element;
|
|
172
|
+
Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "value" | "defaultValue"> & {
|
|
173
|
+
render?: RenderProp<"input", MenuInputState>;
|
|
174
|
+
}) => import("react").JSX.Element;
|
|
175
|
+
Clear: (props: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
176
|
+
render?: RenderProp<"button", MenuClearState>;
|
|
177
|
+
nativeButton?: boolean;
|
|
178
|
+
}) => import("react").JSX.Element;
|
|
179
|
+
Empty: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
180
|
+
render?: RenderProp<"div">;
|
|
181
|
+
}) => import("react").JSX.Element;
|
|
182
|
+
List: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
183
|
+
render?: RenderProp<"div">;
|
|
184
|
+
}) => import("react").JSX.Element;
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
export { _default as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menubar } from "@base-ui/react/menubar";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import BaseMenu_default from "./BaseMenu.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/menu/BaseMenubar.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The container for an application's menus (`BaseMenu`, also attached as `BaseMenubar.Menu`).
|
|
9
|
+
* Once one menu is open, hovering another trigger opens its menu, and the arrow keys move between them.
|
|
10
|
+
* Renders a `<div>` (`role="menubar"`, `flex`, a column when vertical) with `data-orientation`,
|
|
11
|
+
* `data-modal` and `data-has-submenu-open` (while one of its menus is open).
|
|
12
|
+
*/
|
|
13
|
+
const BaseMenubar = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Menubar, {
|
|
14
|
+
...otherProps,
|
|
15
|
+
className: cn("flex", "data-[orientation=vertical]:flex-col", className)
|
|
16
|
+
});
|
|
17
|
+
var BaseMenubar_default = Object.assign(BaseMenubar, { Menu: BaseMenu_default });
|
|
18
|
+
export { BaseMenubar_default as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _default from "./BaseContextMenu.js";
|
|
2
2
|
import _default$1 from "./BaseMenu.js";
|
|
3
|
+
import _default$2, { MenubarState } from "./BaseMenubar.js";
|
|
3
4
|
import createMenuHandle, { MenuHandle } from "./createMenuHandle.js";
|
|
4
5
|
import { MenuActions, MenuHighlightReason } from "./menuTypes.js";
|
|
5
6
|
import { ContextMenuTriggerState } from "./BaseContextMenuTrigger.js";
|
|
@@ -16,4 +17,4 @@ import { MenuSubmenuTriggerState } from "./BaseMenuSubmenuTrigger.js";
|
|
|
16
17
|
import { MenuViewportState } from "./BaseMenuViewport.js";
|
|
17
18
|
import { MenuInputState } from "./BaseMenuInput.js";
|
|
18
19
|
import { MenuClearState } from "./BaseMenuClear.js";
|
|
19
|
-
export { _default as BaseContextMenu, _default$1 as BaseMenu, type ContextMenuTriggerState, type MenuActions, type MenuAlign, type MenuArrowState, type MenuBackdropState, type MenuCheckboxItemState, type MenuClearState, type MenuCollisionAvoidance, type MenuFocusTarget, type MenuHandle, type MenuHighlightReason, type MenuInputState, type MenuInteractionType, type MenuItemState, type MenuLinkItemState, type MenuOffsetFunction, type MenuPopupState, type MenuPositionerState, type MenuRadioGroupState, type MenuRadioItemState, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerState, type MenuTriggerState, type MenuViewportState, createMenuHandle };
|
|
20
|
+
export { _default as BaseContextMenu, _default$1 as BaseMenu, _default$2 as BaseMenubar, type ContextMenuTriggerState, type MenuActions, type MenuAlign, type MenuArrowState, type MenuBackdropState, type MenuCheckboxItemState, type MenuClearState, type MenuCollisionAvoidance, type MenuFocusTarget, type MenuHandle, type MenuHighlightReason, type MenuInputState, type MenuInteractionType, type MenuItemState, type MenuLinkItemState, type MenuOffsetFunction, type MenuPopupState, type MenuPositionerState, type MenuRadioGroupState, type MenuRadioItemState, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerState, type MenuTriggerState, type MenuViewportState, type MenubarState, createMenuHandle };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import BaseContextMenu_default from "./BaseContextMenu.js";
|
|
2
2
|
import BaseMenu_default from "./BaseMenu.js";
|
|
3
|
+
import BaseMenubar_default from "./BaseMenubar.js";
|
|
3
4
|
import createMenuHandle from "./createMenuHandle.js";
|
|
4
|
-
export { BaseContextMenu_default as BaseContextMenu, BaseMenu_default as BaseMenu, createMenuHandle };
|
|
5
|
+
export { BaseContextMenu_default as BaseContextMenu, BaseMenu_default as BaseMenu, BaseMenubar_default as BaseMenubar, createMenuHandle };
|