@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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.6.25
2
+
3
+ - Add Menu disabled state and triggerRef; blocked menus close and preserve dialog return focus through the native trigger.
4
+
1
5
  ## 0.6.24
2
6
 
3
7
  - Add native Segmented option counts without a separate badge surface.
@@ -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;
@@ -1,6 +1,9 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { useId } from "react";
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: pop.anchor,
36
+ ref: setTrigger,
37
+ disabled,
24
38
  "aria-haspopup": "menu",
25
39
  "aria-expanded": pop.open,
26
40
  "aria-controls": id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robert-stackflow/oneui",
3
- "version": "0.6.24",
3
+ "version": "0.6.25",
4
4
  "description": "OneUI React components, application shell and portable visual themes",
5
5
  "type": "module",
6
6
  "sideEffects": [