@cytario/design 9.6.0 → 9.6.2

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/dist/index.d.ts CHANGED
@@ -448,6 +448,8 @@ declare function Menu({ items, content, children, onAction, selectionMode, selec
448
448
  interface UseContextMenuProps {
449
449
  /** Menu body — compose `MenuItem` / `MenuSeparator` / `MenuSection`. */
450
450
  content: ReactNode;
451
+ /** Accessible name for the menu (sets `aria-label` on the `<menu>`). */
452
+ label?: string;
451
453
  /** Called with the activated item key (fires alongside each item's own `onAction`). */
452
454
  onAction?: (key: string) => void;
453
455
  /** Extra classes for the menu popover. */
@@ -464,6 +466,10 @@ interface UseContextMenuResult {
464
466
  */
465
467
  triggerProps: {
466
468
  onPress: (event: PressEvent) => void;
469
+ onClick: (event: React.MouseEvent) => void;
470
+ "aria-haspopup": "menu";
471
+ "aria-expanded": boolean;
472
+ "aria-controls": string | undefined;
467
473
  };
468
474
  /** Render this wherever — it portals itself. */
469
475
  menu: ReactNode;
@@ -487,7 +493,7 @@ interface UseContextMenuResult {
487
493
  * the trigger's rect for keyboard opens) — React-Aria's positioning observes
488
494
  * the trigger with a `ResizeObserver`, so a plain virtual object won't do.
489
495
  */
490
- declare function useContextMenu({ content, onAction, className, }: UseContextMenuProps): UseContextMenuResult;
496
+ declare function useContextMenu({ content, label, onAction, className, }: UseContextMenuProps): UseContextMenuResult;
491
497
 
492
498
  interface MenuItemProps {
493
499
  id: string;
package/dist/index.js CHANGED
@@ -2204,22 +2204,24 @@ function Menu2({
2204
2204
  import {
2205
2205
  useCallback as useCallback3,
2206
2206
  useEffect as useEffect3,
2207
+ useId as useId2,
2207
2208
  useRef as useRef5,
2208
2209
  useState as useState7
2209
2210
  } from "react";
2210
2211
  import {
2211
2212
  Menu as AriaMenu2,
2212
2213
  MenuTrigger as MenuTrigger2,
2213
- Popover as Popover3,
2214
- Pressable
2214
+ Popover as Popover3
2215
2215
  } from "react-aria-components";
2216
2216
  import { twMerge as twMerge16 } from "tailwind-merge";
2217
2217
  import { jsx as jsx30, jsxs as jsxs19 } from "react/jsx-runtime";
2218
2218
  function useContextMenu({
2219
2219
  content,
2220
+ label,
2220
2221
  onAction,
2221
2222
  className
2222
2223
  }) {
2224
+ const popoverId = useId2();
2223
2225
  const [anchor, setAnchor] = useState7(null);
2224
2226
  const anchorRef = useRef5(null);
2225
2227
  const popoverRef = useRef5(null);
@@ -2264,25 +2266,29 @@ function useContextMenu({
2264
2266
  if (!open) close();
2265
2267
  },
2266
2268
  children: [
2267
- /* @__PURE__ */ jsx30(Pressable, { children: /* @__PURE__ */ jsx30(
2269
+ /* @__PURE__ */ jsx30(
2268
2270
  "span",
2269
2271
  {
2270
2272
  ref: anchorRef,
2271
2273
  "aria-hidden": true,
2274
+ tabIndex: -1,
2272
2275
  className: "pointer-events-none fixed h-0 w-0",
2273
2276
  style: { left: anchor?.x ?? 0, top: anchor?.y ?? 0 }
2274
2277
  }
2275
- ) }),
2278
+ ),
2276
2279
  /* @__PURE__ */ jsx30(
2277
2280
  Popover3,
2278
2281
  {
2279
2282
  isNonModal: true,
2283
+ triggerRef: anchorRef,
2280
2284
  placement: "bottom start",
2281
2285
  ref: popoverRef,
2282
2286
  className: twMerge16(popoverStyles, className),
2283
2287
  children: /* @__PURE__ */ jsx30(
2284
2288
  AriaMenu2,
2285
2289
  {
2290
+ id: popoverId,
2291
+ "aria-label": label,
2286
2292
  autoFocus: "first",
2287
2293
  onAction: (key) => {
2288
2294
  onAction?.(String(key));
@@ -2299,7 +2305,15 @@ function useContextMenu({
2299
2305
  );
2300
2306
  return {
2301
2307
  targetProps: { onContextMenu },
2302
- triggerProps: { onPress },
2308
+ triggerProps: {
2309
+ onPress,
2310
+ onClick: (e) => {
2311
+ e.preventDefault();
2312
+ },
2313
+ "aria-haspopup": "menu",
2314
+ "aria-expanded": isOpen,
2315
+ "aria-controls": isOpen ? popoverId : void 0
2316
+ },
2303
2317
  menu,
2304
2318
  isOpen,
2305
2319
  close