@robert-stackflow/oneui 0.6.24 → 0.6.25
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/CHANGELOG.md +4 -0
- package/components/Menu.d.ts +4 -2
- package/components/Menu.js +18 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/components/Menu.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
2
|
-
export declare function Menu({ label, items, trigger, variant, className, iconOnly, }: {
|
|
1
|
+
import { type ReactNode, type Ref } from "react";
|
|
2
|
+
export declare function Menu({ label, items, trigger, variant, className, iconOnly, disabled, triggerRef, }: {
|
|
3
3
|
label: string;
|
|
4
4
|
trigger?: ReactNode;
|
|
5
5
|
variant?: "primary" | "secondary" | "ghost" | "danger";
|
|
6
6
|
className?: string;
|
|
7
7
|
iconOnly?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
triggerRef?: Ref<HTMLButtonElement>;
|
|
8
10
|
items: {
|
|
9
11
|
label: string;
|
|
10
12
|
icon?: ReactNode;
|
package/components/Menu.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useCallback,
|
|
5
|
+
useId
|
|
6
|
+
} from "react";
|
|
4
7
|
import { ChevronDown, MoreHorizontal } from "lucide-react";
|
|
5
8
|
import { Button } from "./Button.js";
|
|
6
9
|
import { IconButton } from "./IconButton.js";
|
|
@@ -13,14 +16,25 @@ function Menu({
|
|
|
13
16
|
trigger,
|
|
14
17
|
variant,
|
|
15
18
|
className,
|
|
16
|
-
iconOnly = false
|
|
19
|
+
iconOnly = false,
|
|
20
|
+
disabled = false,
|
|
21
|
+
triggerRef
|
|
17
22
|
}) {
|
|
18
|
-
const pop = usePopover(), id = useId();
|
|
23
|
+
const pop = usePopover(disabled), id = useId();
|
|
24
|
+
const setTrigger = useCallback(
|
|
25
|
+
(node) => {
|
|
26
|
+
pop.anchor.current = node;
|
|
27
|
+
if (typeof triggerRef === "function") triggerRef(node);
|
|
28
|
+
else if (triggerRef) triggerRef.current = node;
|
|
29
|
+
},
|
|
30
|
+
[pop.anchor, triggerRef]
|
|
31
|
+
);
|
|
19
32
|
const triggerProps = {
|
|
20
33
|
variant: variant ?? (iconOnly ? "ghost" : "secondary"),
|
|
21
34
|
className,
|
|
22
35
|
"aria-label": label,
|
|
23
|
-
ref:
|
|
36
|
+
ref: setTrigger,
|
|
37
|
+
disabled,
|
|
24
38
|
"aria-haspopup": "menu",
|
|
25
39
|
"aria-expanded": pop.open,
|
|
26
40
|
"aria-controls": id,
|