@cytario/design 9.6.0 → 9.6.1

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
@@ -464,6 +464,10 @@ interface UseContextMenuResult {
464
464
  */
465
465
  triggerProps: {
466
466
  onPress: (event: PressEvent) => void;
467
+ onClick: (event: React.MouseEvent) => void;
468
+ "aria-haspopup": "menu";
469
+ "aria-expanded": boolean;
470
+ "aria-controls": string | undefined;
467
471
  };
468
472
  /** Render this wherever — it portals itself. */
469
473
  menu: ReactNode;
package/dist/index.js CHANGED
@@ -2204,14 +2204,14 @@ 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";
@@ -2220,6 +2220,7 @@ function useContextMenu({
2220
2220
  onAction,
2221
2221
  className
2222
2222
  }) {
2223
+ const popoverId = useId2();
2223
2224
  const [anchor, setAnchor] = useState7(null);
2224
2225
  const anchorRef = useRef5(null);
2225
2226
  const popoverRef = useRef5(null);
@@ -2264,25 +2265,28 @@ function useContextMenu({
2264
2265
  if (!open) close();
2265
2266
  },
2266
2267
  children: [
2267
- /* @__PURE__ */ jsx30(Pressable, { children: /* @__PURE__ */ jsx30(
2268
+ /* @__PURE__ */ jsx30(
2268
2269
  "span",
2269
2270
  {
2270
2271
  ref: anchorRef,
2271
2272
  "aria-hidden": true,
2273
+ tabIndex: -1,
2272
2274
  className: "pointer-events-none fixed h-0 w-0",
2273
2275
  style: { left: anchor?.x ?? 0, top: anchor?.y ?? 0 }
2274
2276
  }
2275
- ) }),
2277
+ ),
2276
2278
  /* @__PURE__ */ jsx30(
2277
2279
  Popover3,
2278
2280
  {
2279
2281
  isNonModal: true,
2282
+ triggerRef: anchorRef,
2280
2283
  placement: "bottom start",
2281
2284
  ref: popoverRef,
2282
2285
  className: twMerge16(popoverStyles, className),
2283
2286
  children: /* @__PURE__ */ jsx30(
2284
2287
  AriaMenu2,
2285
2288
  {
2289
+ id: popoverId,
2286
2290
  autoFocus: "first",
2287
2291
  onAction: (key) => {
2288
2292
  onAction?.(String(key));
@@ -2299,7 +2303,15 @@ function useContextMenu({
2299
2303
  );
2300
2304
  return {
2301
2305
  targetProps: { onContextMenu },
2302
- triggerProps: { onPress },
2306
+ triggerProps: {
2307
+ onPress,
2308
+ onClick: (e) => {
2309
+ e.preventDefault();
2310
+ },
2311
+ "aria-haspopup": "menu",
2312
+ "aria-expanded": isOpen,
2313
+ "aria-controls": isOpen ? popoverId : void 0
2314
+ },
2303
2315
  menu,
2304
2316
  isOpen,
2305
2317
  close