@yamada-ui/menu 1.3.15-dev-20241005224505 → 1.3.15-dev-20241006032009

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. package/dist/{chunk-ZUOFHOX6.mjs → chunk-EJHOFPF4.mjs} +11 -11
  2. package/dist/chunk-EJHOFPF4.mjs.map +1 -0
  3. package/dist/{chunk-ZV73JKM5.mjs → chunk-ELQD4RMJ.mjs} +4 -4
  4. package/dist/{chunk-ZV73JKM5.mjs.map → chunk-ELQD4RMJ.mjs.map} +1 -1
  5. package/dist/{chunk-T7CXLEBW.mjs → chunk-HEDZYLPX.mjs} +35 -35
  6. package/dist/chunk-HEDZYLPX.mjs.map +1 -0
  7. package/dist/{chunk-NNSVX2GX.mjs → chunk-I2KIZ6OI.mjs} +28 -28
  8. package/dist/{chunk-NNSVX2GX.mjs.map → chunk-I2KIZ6OI.mjs.map} +1 -1
  9. package/dist/{chunk-O5D4LR5P.mjs → chunk-I473RINV.mjs} +8 -8
  10. package/dist/{chunk-O5D4LR5P.mjs.map → chunk-I473RINV.mjs.map} +1 -1
  11. package/dist/{chunk-OFCEMPQW.mjs → chunk-KZAACFSL.mjs} +3 -3
  12. package/dist/{chunk-OFCEMPQW.mjs.map → chunk-KZAACFSL.mjs.map} +1 -1
  13. package/dist/{chunk-HVOHR2NQ.mjs → chunk-O7MHNHWF.mjs} +4 -4
  14. package/dist/{chunk-HVOHR2NQ.mjs.map → chunk-O7MHNHWF.mjs.map} +1 -1
  15. package/dist/{chunk-SI3WI4AI.mjs → chunk-OETJECD3.mjs} +8 -8
  16. package/dist/chunk-OETJECD3.mjs.map +1 -0
  17. package/dist/{chunk-WQ626PSA.mjs → chunk-T4SSYCLG.mjs} +9 -8
  18. package/dist/chunk-T4SSYCLG.mjs.map +1 -0
  19. package/dist/{chunk-M4PPRRRC.mjs → chunk-TM7BAARA.mjs} +14 -14
  20. package/dist/chunk-TM7BAARA.mjs.map +1 -0
  21. package/dist/context-menu-trigger.js +14 -13
  22. package/dist/context-menu-trigger.js.map +1 -1
  23. package/dist/context-menu-trigger.mjs +2 -2
  24. package/dist/context-menu.js +33 -33
  25. package/dist/context-menu.js.map +1 -1
  26. package/dist/context-menu.mjs +3 -3
  27. package/dist/index.d.mts +6 -6
  28. package/dist/index.d.ts +6 -6
  29. package/dist/index.js +275 -272
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.mjs +10 -10
  32. package/dist/menu-button.d.mts +2 -2
  33. package/dist/menu-button.d.ts +2 -2
  34. package/dist/menu-button.js +50 -50
  35. package/dist/menu-button.js.map +1 -1
  36. package/dist/menu-button.mjs +3 -3
  37. package/dist/menu-context.d.mts +116 -116
  38. package/dist/menu-context.d.ts +116 -116
  39. package/dist/menu-context.js +8 -8
  40. package/dist/menu-context.js.map +1 -1
  41. package/dist/menu-context.mjs +1 -1
  42. package/dist/menu-divider.js +8 -8
  43. package/dist/menu-divider.js.map +1 -1
  44. package/dist/menu-divider.mjs +2 -2
  45. package/dist/menu-group.js +9 -9
  46. package/dist/menu-group.js.map +1 -1
  47. package/dist/menu-group.mjs +2 -2
  48. package/dist/menu-item.d.mts +21 -21
  49. package/dist/menu-item.d.ts +21 -21
  50. package/dist/menu-item.js +40 -40
  51. package/dist/menu-item.js.map +1 -1
  52. package/dist/menu-item.mjs +2 -2
  53. package/dist/menu-list.js +14 -14
  54. package/dist/menu-list.js.map +1 -1
  55. package/dist/menu-list.mjs +2 -2
  56. package/dist/menu-option-group.d.mts +8 -8
  57. package/dist/menu-option-group.d.ts +8 -8
  58. package/dist/menu-option-group.js +46 -46
  59. package/dist/menu-option-group.js.map +1 -1
  60. package/dist/menu-option-group.mjs +4 -4
  61. package/dist/menu.js +33 -33
  62. package/dist/menu.js.map +1 -1
  63. package/dist/menu.mjs +2 -2
  64. package/package.json +11 -11
  65. package/dist/chunk-M4PPRRRC.mjs.map +0 -1
  66. package/dist/chunk-SI3WI4AI.mjs.map +0 -1
  67. package/dist/chunk-T7CXLEBW.mjs.map +0 -1
  68. package/dist/chunk-WQ626PSA.mjs.map +0 -1
  69. package/dist/chunk-ZUOFHOX6.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/menu-option-group.tsx"],"sourcesContent":["import type { ComponentArgs } from \"@yamada-ui/core\"\nimport type { ForwardedRef, ReactElement, RefAttributes } from \"react\"\nimport type { MenuGroupProps } from \"./menu-group\"\nimport { useControllableState } from \"@yamada-ui/use-controllable-state\"\nimport { cx, getValidChildren, isArray } from \"@yamada-ui/utils\"\nimport { cloneElement, forwardRef, useCallback } from \"react\"\nimport { MenuGroup } from \"./menu-group\"\nimport { MenuOptionItem } from \"./menu-item\"\n\ninterface MenuOptionGroupOptions<Y extends string | string[] = string> {\n /**\n * The type of the menu option group.\n *\n * @default 'checkbox'\n */\n type?: \"checkbox\" | \"radio\"\n /**\n * The initial value of the menu item group.\n */\n defaultValue?: Y\n /**\n * The value of the menu item group.\n */\n value?: Y\n /**\n * The callback fired when any children checkbox is checked or unchecked.\n */\n onChange?: (value: Y) => void\n}\n\nexport interface MenuOptionGroupProps<Y extends string | string[] = string>\n extends Omit<MenuGroupProps, keyof MenuOptionGroupOptions>,\n MenuOptionGroupOptions<Y> {}\n\nexport const MenuOptionGroup = forwardRef(\n <Y extends string | string[] = string>(\n {\n type,\n className,\n children,\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n ...rest\n }: MenuOptionGroupProps<Y>,\n ref: ForwardedRef<HTMLDivElement>,\n ) => {\n const isRadio = type === \"radio\"\n\n defaultValue ??= (isRadio ? \"\" : []) as Y\n\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n\n const onChange = useCallback(\n (selectedValue: string) => {\n if (isRadio && typeof value === \"string\") setValue(selectedValue as Y)\n\n if (!isRadio && isArray(value)) {\n const nextValue = value.includes(selectedValue)\n ? value.filter((item) => item !== selectedValue)\n : value.concat(selectedValue)\n\n setValue(nextValue as Y)\n }\n },\n [isRadio, value, setValue],\n )\n\n const validChildren = getValidChildren(children)\n\n const cloneChildren = validChildren.map((child) => {\n if (child.type !== MenuOptionItem) return child\n\n const onClick = (ev: MouseEvent) => {\n onChange(child.props.value)\n child.props.onClick?.(ev)\n }\n\n const isChecked =\n !isRadio && isArray(value)\n ? value.includes(child.props.value)\n : child.props.value === value\n\n return cloneElement(child, { type, isChecked, onClick })\n })\n\n return (\n <MenuGroup\n ref={ref}\n className={cx(\"ui-menu__item--group--option\", className)}\n {...rest}\n >\n {cloneChildren}\n </MenuGroup>\n )\n },\n) as {\n <Y extends string | string[] = string>(\n props: MenuOptionGroupProps<Y> & RefAttributes<HTMLDivElement>,\n ): ReactElement\n} & ComponentArgs\n\nMenuOptionGroup.displayName = \"MenuOptionGroup\"\n"],"mappings":";;;;;;;;;AAGA,SAAS,4BAA4B;AACrC,SAAS,IAAI,kBAAkB,eAAe;AAC9C,SAAS,cAAc,YAAY,mBAAmB;AAsFhD;AAzDC,IAAM,kBAAkB;AAAA,EAC7B,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,UAAU;AAAA,IACV,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,UAAU,SAAS;AAEzB,yDAAkB,UAAU,KAAK,CAAC;AAElC,UAAM,CAAC,OAAO,QAAQ,IAAI,qBAAqB;AAAA,MAC7C;AAAA,MACA,OAAO;AAAA,MACP,UAAU;AAAA,IACZ,CAAC;AAED,UAAM,WAAW;AAAA,MACf,CAAC,kBAA0B;AACzB,YAAI,WAAW,OAAO,UAAU,SAAU,UAAS,aAAkB;AAErE,YAAI,CAAC,WAAW,QAAQ,KAAK,GAAG;AAC9B,gBAAM,YAAY,MAAM,SAAS,aAAa,IAC1C,MAAM,OAAO,CAAC,SAAS,SAAS,aAAa,IAC7C,MAAM,OAAO,aAAa;AAE9B,mBAAS,SAAc;AAAA,QACzB;AAAA,MACF;AAAA,MACA,CAAC,SAAS,OAAO,QAAQ;AAAA,IAC3B;AAEA,UAAM,gBAAgB,iBAAiB,QAAQ;AAE/C,UAAM,gBAAgB,cAAc,IAAI,CAAC,UAAU;AACjD,UAAI,MAAM,SAAS,eAAgB,QAAO;AAE1C,YAAM,UAAU,CAAC,OAAmB;AA7E1C;AA8EQ,iBAAS,MAAM,MAAM,KAAK;AAC1B,0BAAM,OAAM,YAAZ,4BAAsB;AAAA,MACxB;AAEA,YAAM,YACJ,CAAC,WAAW,QAAQ,KAAK,IACrB,MAAM,SAAS,MAAM,MAAM,KAAK,IAChC,MAAM,MAAM,UAAU;AAE5B,aAAO,aAAa,OAAO,EAAE,MAAM,WAAW,QAAQ,CAAC;AAAA,IACzD,CAAC;AAED,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,WAAW,GAAG,gCAAgC,SAAS;AAAA,QACtD,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAMA,gBAAgB,cAAc;","names":[]}
@@ -1,21 +1,22 @@
1
1
  "use client"
2
2
  import {
3
3
  useContextMenu
4
- } from "./chunk-ZUOFHOX6.mjs";
4
+ } from "./chunk-EJHOFPF4.mjs";
5
5
 
6
6
  // src/context-menu-trigger.tsx
7
- import { ui, forwardRef } from "@yamada-ui/core";
7
+ import { forwardRef, ui } from "@yamada-ui/core";
8
8
  import { PopoverAnchor, PopoverTrigger } from "@yamada-ui/popover";
9
9
  import { cx, handlerAll } from "@yamada-ui/utils";
10
10
  import { useState } from "react";
11
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
12
  var ContextMenuTrigger = forwardRef(
13
- ({ children, className, ...rest }, ref) => {
14
- const { styles } = useContextMenu();
15
- const [position, setPosition] = useState({ top: 0, left: 0 });
16
- const css = { ...styles.container };
13
+ ({ className, children, ...rest }, ref) => {
14
+ var _a;
15
+ const { styles } = (_a = useContextMenu()) != null ? _a : {};
16
+ const [position, setPosition] = useState({ left: 0, top: 0 });
17
+ const css = { ...styles == null ? void 0 : styles.container };
17
18
  const onContextMenu = (ev) => {
18
- setPosition({ top: ev.pageY, left: ev.pageX });
19
+ setPosition({ left: ev.pageX, top: ev.pageY });
19
20
  };
20
21
  return /* @__PURE__ */ jsxs(Fragment, { children: [
21
22
  /* @__PURE__ */ jsx(PopoverAnchor, { children: /* @__PURE__ */ jsx(
@@ -43,4 +44,4 @@ var ContextMenuTrigger = forwardRef(
43
44
  export {
44
45
  ContextMenuTrigger
45
46
  };
46
- //# sourceMappingURL=chunk-WQ626PSA.mjs.map
47
+ //# sourceMappingURL=chunk-T4SSYCLG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context-menu-trigger.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport type { MouseEvent } from \"react\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { PopoverAnchor, PopoverTrigger } from \"@yamada-ui/popover\"\nimport { cx, handlerAll } from \"@yamada-ui/utils\"\nimport { useState } from \"react\"\nimport { useContextMenu } from \"./menu-context\"\n\ninterface Position {\n left: number\n top: number\n}\n\nexport interface ContextMenuTriggerProps extends HTMLUIProps {}\n\nexport const ContextMenuTrigger = forwardRef<ContextMenuTriggerProps, \"div\">(\n ({ className, children, ...rest }, ref) => {\n const { styles } = useContextMenu() ?? {}\n const [position, setPosition] = useState<Position>({ left: 0, top: 0 })\n\n const css: CSSUIObject = { ...styles?.container }\n\n const onContextMenu = (ev: MouseEvent) => {\n setPosition({ left: ev.pageX, top: ev.pageY })\n }\n\n return (\n <>\n <PopoverAnchor>\n <ui.div\n className=\"ui-context-menu__anchor\"\n style={{ position: \"absolute\", ...position }}\n />\n </PopoverAnchor>\n\n <PopoverTrigger>\n <ui.div\n ref={ref}\n className={cx(\"ui-context-menu\", className)}\n __css={css}\n {...rest}\n onContextMenu={handlerAll(rest.onContextMenu, onContextMenu)}\n >\n {children}\n </ui.div>\n </PopoverTrigger>\n </>\n )\n },\n)\n"],"mappings":";;;;;;AAEA,SAAS,YAAY,UAAU;AAC/B,SAAS,eAAe,sBAAsB;AAC9C,SAAS,IAAI,kBAAkB;AAC/B,SAAS,gBAAgB;AAsBnB,mBAEI,KAFJ;AAZC,IAAM,qBAAqB;AAAA,EAChC,CAAC,EAAE,WAAW,UAAU,GAAG,KAAK,GAAG,QAAQ;AAhB7C;AAiBI,UAAM,EAAE,OAAO,KAAI,oBAAe,MAAf,YAAoB,CAAC;AACxC,UAAM,CAAC,UAAU,WAAW,IAAI,SAAmB,EAAE,MAAM,GAAG,KAAK,EAAE,CAAC;AAEtE,UAAM,MAAmB,EAAE,GAAG,iCAAQ,UAAU;AAEhD,UAAM,gBAAgB,CAAC,OAAmB;AACxC,kBAAY,EAAE,MAAM,GAAG,OAAO,KAAK,GAAG,MAAM,CAAC;AAAA,IAC/C;AAEA,WACE,iCACE;AAAA,0BAAC,iBACC;AAAA,QAAC,GAAG;AAAA,QAAH;AAAA,UACC,WAAU;AAAA,UACV,OAAO,EAAE,UAAU,YAAY,GAAG,SAAS;AAAA;AAAA,MAC7C,GACF;AAAA,MAEA,oBAAC,kBACC;AAAA,QAAC,GAAG;AAAA,QAAH;AAAA,UACC;AAAA,UACA,WAAW,GAAG,mBAAmB,SAAS;AAAA,UAC1C,OAAO;AAAA,UACN,GAAG;AAAA,UACJ,eAAe,WAAW,KAAK,eAAe,aAAa;AAAA,UAE1D;AAAA;AAAA,MACH,GACF;AAAA,OACF;AAAA,EAEJ;AACF;","names":[]}
@@ -1,30 +1,30 @@
1
1
  "use client"
2
2
  import {
3
3
  MenuIcon
4
- } from "./chunk-T7CXLEBW.mjs";
4
+ } from "./chunk-HEDZYLPX.mjs";
5
5
  import {
6
6
  useMenu,
7
7
  useUpstreamMenuItem
8
- } from "./chunk-ZUOFHOX6.mjs";
8
+ } from "./chunk-EJHOFPF4.mjs";
9
9
 
10
10
  // src/menu-button.tsx
11
- import { ui, forwardRef } from "@yamada-ui/core";
11
+ import { forwardRef, ui } from "@yamada-ui/core";
12
12
  import { ChevronIcon } from "@yamada-ui/icon";
13
13
  import { PopoverTrigger } from "@yamada-ui/popover";
14
14
  import { assignRef, cx, dataAttr, funcAll, handlerAll } from "@yamada-ui/utils";
15
15
  import { useCallback, useMemo } from "react";
16
16
  import { jsx, jsxs } from "react/jsx-runtime";
17
17
  var MenuButton = forwardRef(
18
- ({ className, children, as, ...rest }, ref) => {
18
+ ({ as, className, children, ...rest }, ref) => {
19
19
  var _a;
20
20
  const { onKeyDownRef, onUpstreamRestoreFocus } = (_a = useUpstreamMenuItem()) != null ? _a : {};
21
- const { isOpen, onOpen, onClose, onFocusFirstItem, onFocusLastItem } = useMenu();
21
+ const { isOpen, onClose, onFocusFirstItem, onFocusLastItem, onOpen } = useMenu();
22
22
  const onKeyDown = useCallback(
23
23
  (ev) => {
24
24
  const actions = {
25
- Enter: funcAll(onOpen, onFocusFirstItem),
26
25
  ArrowDown: funcAll(onOpen, onFocusFirstItem),
27
- ArrowUp: funcAll(onOpen, onFocusLastItem)
26
+ ArrowUp: funcAll(onOpen, onFocusLastItem),
27
+ Enter: funcAll(onOpen, onFocusFirstItem)
28
28
  };
29
29
  const action = actions[ev.key];
30
30
  if (!action) return;
@@ -36,8 +36,8 @@ var MenuButton = forwardRef(
36
36
  const onItemKeyDown = useCallback(
37
37
  (ev) => {
38
38
  const actions = {
39
- ArrowRight: !isOpen ? funcAll(onOpen, onFocusFirstItem) : void 0,
40
- ArrowLeft: isOpen ? funcAll(onUpstreamRestoreFocus, onClose) : void 0
39
+ ArrowLeft: isOpen ? funcAll(onUpstreamRestoreFocus, onClose) : void 0,
40
+ ArrowRight: !isOpen ? funcAll(onOpen, onFocusFirstItem) : void 0
41
41
  };
42
42
  const action = actions[ev.key];
43
43
  if (!action) return;
@@ -53,8 +53,8 @@ var MenuButton = forwardRef(
53
53
  {
54
54
  ref,
55
55
  className: cx("ui-menu", className),
56
- "aria-haspopup": "menu",
57
56
  "aria-expanded": isOpen,
57
+ "aria-haspopup": "menu",
58
58
  ...rest,
59
59
  "data-active": dataAttr(isOpen),
60
60
  onKeyDown: handlerAll(rest.onKeyDown, onKeyDown),
@@ -66,16 +66,16 @@ var MenuButton = forwardRef(
66
66
  var Button = forwardRef((rest, ref) => {
67
67
  const { styles } = useMenu();
68
68
  const css = {
69
- display: "inline-flex",
70
- appearance: "none",
71
69
  alignItems: "center",
70
+ appearance: "none",
71
+ display: "inline-flex",
72
72
  outline: 0,
73
73
  ...styles.button
74
74
  };
75
75
  return /* @__PURE__ */ jsx(ui.button, { ref, __css: css, ...rest });
76
76
  });
77
77
  var MenuItemButton = forwardRef(
78
- ({ className, children, innerProps, icon, iconProps, ...rest }, ref) => {
78
+ ({ className, children, icon, iconProps, innerProps, ...rest }, ref) => {
79
79
  return /* @__PURE__ */ jsxs(
80
80
  MenuButton,
81
81
  {
@@ -96,4 +96,4 @@ export {
96
96
  MenuButton,
97
97
  MenuItemButton
98
98
  };
99
- //# sourceMappingURL=chunk-M4PPRRRC.mjs.map
99
+ //# sourceMappingURL=chunk-TM7BAARA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/menu-button.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport type { KeyboardEvent, ReactNode } from \"react\"\nimport type { MenuIconProps } from \"./menu-item\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { ChevronIcon } from \"@yamada-ui/icon\"\nimport { PopoverTrigger } from \"@yamada-ui/popover\"\nimport { assignRef, cx, dataAttr, funcAll, handlerAll } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo } from \"react\"\nimport { useMenu, useUpstreamMenuItem } from \"./menu-context\"\nimport { MenuIcon } from \"./menu-item\"\n\nexport interface MenuButtonProps extends HTMLUIProps<\"button\"> {}\n\nexport const MenuButton = forwardRef<MenuButtonProps, \"button\">(\n ({ as, className, children, ...rest }, ref) => {\n const { onKeyDownRef, onUpstreamRestoreFocus } = useUpstreamMenuItem() ?? {}\n const { isOpen, onClose, onFocusFirstItem, onFocusLastItem, onOpen } =\n useMenu()\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent) => {\n const actions: { [key: string]: Function } = {\n ArrowDown: funcAll(onOpen, onFocusFirstItem),\n ArrowUp: funcAll(onOpen, onFocusLastItem),\n Enter: funcAll(onOpen, onFocusFirstItem),\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n\n action()\n },\n [onFocusFirstItem, onFocusLastItem, onOpen],\n )\n\n const onItemKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLLIElement>) => {\n const actions: { [key: string]: Function | undefined } = {\n ArrowLeft: isOpen\n ? funcAll(onUpstreamRestoreFocus, onClose)\n : undefined,\n ArrowRight: !isOpen ? funcAll(onOpen, onFocusFirstItem) : undefined,\n }\n\n const action = actions[ev.key]\n\n if (!action) return\n\n ev.preventDefault()\n\n action()\n },\n [isOpen, onOpen, onFocusFirstItem, onUpstreamRestoreFocus, onClose],\n )\n\n assignRef(onKeyDownRef, onItemKeyDown)\n\n const Component = useMemo(() => (as ? ui(as) : Button), [as])\n\n return (\n <PopoverTrigger>\n <Component\n ref={ref}\n className={cx(\"ui-menu\", className)}\n aria-expanded={isOpen}\n aria-haspopup=\"menu\"\n {...rest}\n data-active={dataAttr(isOpen)}\n onKeyDown={handlerAll(rest.onKeyDown, onKeyDown)}\n >\n {children}\n </Component>\n </PopoverTrigger>\n )\n },\n)\n\nconst Button = forwardRef<MenuButtonProps, \"button\">((rest, ref) => {\n const { styles } = useMenu()\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n appearance: \"none\",\n display: \"inline-flex\",\n outline: 0,\n ...styles.button,\n }\n\n return <ui.button ref={ref} __css={css} {...rest} />\n})\n\nexport interface MenuItemButtonProps extends MenuButtonProps {\n icon?: ReactNode\n iconProps?: MenuIconProps\n innerProps?: HTMLUIProps<\"span\">\n}\n\nexport const MenuItemButton = forwardRef<MenuItemButtonProps, \"button\">(\n ({ className, children, icon, iconProps, innerProps, ...rest }, ref) => {\n return (\n <MenuButton\n ref={ref}\n className={cx(\"ui-menu__item-button\", className)}\n flex=\"1\"\n {...rest}\n >\n <ui.span as=\"span\" flex=\"1\" {...innerProps}>\n {children}\n </ui.span>\n\n <MenuIcon {...iconProps}>\n {icon ?? <ChevronIcon fontSize=\"1.5em\" transform=\"rotate(-90deg)\" />}\n </MenuIcon>\n </MenuButton>\n )\n },\n)\n"],"mappings":";;;;;;;;;;AAGA,SAAS,YAAY,UAAU;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,WAAW,IAAI,UAAU,SAAS,kBAAkB;AAC7D,SAAS,aAAa,eAAe;AAyD7B,cAuCF,YAvCE;AAnDD,IAAM,aAAa;AAAA,EACxB,CAAC,EAAE,IAAI,WAAW,UAAU,GAAG,KAAK,GAAG,QAAQ;AAdjD;AAeI,UAAM,EAAE,cAAc,uBAAuB,KAAI,yBAAoB,MAApB,YAAyB,CAAC;AAC3E,UAAM,EAAE,QAAQ,SAAS,kBAAkB,iBAAiB,OAAO,IACjE,QAAQ;AAEV,UAAM,YAAY;AAAA,MAChB,CAAC,OAAsB;AACrB,cAAM,UAAuC;AAAA,UAC3C,WAAW,QAAQ,QAAQ,gBAAgB;AAAA,UAC3C,SAAS,QAAQ,QAAQ,eAAe;AAAA,UACxC,OAAO,QAAQ,QAAQ,gBAAgB;AAAA,QACzC;AAEA,cAAM,SAAS,QAAQ,GAAG,GAAG;AAE7B,YAAI,CAAC,OAAQ;AAEb,WAAG,eAAe;AAElB,eAAO;AAAA,MACT;AAAA,MACA,CAAC,kBAAkB,iBAAiB,MAAM;AAAA,IAC5C;AAEA,UAAM,gBAAgB;AAAA,MACpB,CAAC,OAAqC;AACpC,cAAM,UAAmD;AAAA,UACvD,WAAW,SACP,QAAQ,wBAAwB,OAAO,IACvC;AAAA,UACJ,YAAY,CAAC,SAAS,QAAQ,QAAQ,gBAAgB,IAAI;AAAA,QAC5D;AAEA,cAAM,SAAS,QAAQ,GAAG,GAAG;AAE7B,YA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-34,36 +34,37 @@ var import_use_descendant = require("@yamada-ui/use-descendant");
34
34
  var import_utils = require("@yamada-ui/utils");
35
35
  var {
36
36
  DescendantsContextProvider,
37
- useDescendantsContext: useMenuDescendantsContext,
37
+ useDescendant: useMenuDescendant,
38
38
  useDescendants,
39
- useDescendant: useMenuDescendant
39
+ useDescendantsContext: useMenuDescendantsContext
40
40
  } = (0, import_use_descendant.createDescendant)();
41
41
  var [MenuProvider, useMenu] = (0, import_utils.createContext)({
42
42
  name: "MenuContext",
43
43
  errorMessage: `useMenu returned is 'undefined'. Seems you forgot to wrap the components in "<Menu />"`
44
44
  });
45
45
  var [ContextMenuProvider, useContextMenu] = (0, import_utils.createContext)({
46
- strict: false,
47
- name: "ContextMenuContext"
46
+ name: "ContextMenuContext",
47
+ strict: false
48
48
  });
49
49
  var [UpstreamMenuProvider, useUpstreamMenu] = (0, import_utils.createContext)({
50
- strict: false,
51
- name: "UpstreamMenuContext"
50
+ name: "UpstreamMenuContext",
51
+ strict: false
52
52
  });
53
53
  var [UpstreamMenuItemProvider, useUpstreamMenuItem] = (0, import_utils.createContext)({
54
- strict: false,
55
- name: "UpstreamMenuItemContext"
54
+ name: "UpstreamMenuItemContext",
55
+ strict: false
56
56
  });
57
57
 
58
58
  // src/context-menu-trigger.tsx
59
59
  var import_jsx_runtime = require("react/jsx-runtime");
60
60
  var ContextMenuTrigger = (0, import_core.forwardRef)(
61
- ({ children, className, ...rest }, ref) => {
62
- const { styles } = useContextMenu();
63
- const [position, setPosition] = (0, import_react.useState)({ top: 0, left: 0 });
64
- const css = { ...styles.container };
61
+ ({ className, children, ...rest }, ref) => {
62
+ var _a;
63
+ const { styles } = (_a = useContextMenu()) != null ? _a : {};
64
+ const [position, setPosition] = (0, import_react.useState)({ left: 0, top: 0 });
65
+ const css = { ...styles == null ? void 0 : styles.container };
65
66
  const onContextMenu = (ev) => {
66
- setPosition({ top: ev.pageY, left: ev.pageX });
67
+ setPosition({ left: ev.pageX, top: ev.pageY });
67
68
  };
68
69
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
69
70
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popover.PopoverAnchor, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context-menu-trigger.tsx","../src/menu-context.ts"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport { ui, forwardRef } from \"@yamada-ui/core\"\nimport { PopoverAnchor, PopoverTrigger } from \"@yamada-ui/popover\"\nimport { cx, handlerAll } from \"@yamada-ui/utils\"\nimport type { MouseEvent } from \"react\"\nimport { useState } from \"react\"\nimport { useContextMenu } from \"./menu-context\"\n\ninterface Position {\n top: number\n left: number\n}\n\nexport interface ContextMenuTriggerProps extends HTMLUIProps {}\n\nexport const ContextMenuTrigger = forwardRef<ContextMenuTriggerProps, \"div\">(\n ({ children, className, ...rest }, ref) => {\n const { styles } = useContextMenu()\n const [position, setPosition] = useState<Position>({ top: 0, left: 0 })\n\n const css: CSSUIObject = { ...styles.container }\n\n const onContextMenu = (ev: MouseEvent) => {\n setPosition({ top: ev.pageY, left: ev.pageX })\n }\n\n return (\n <>\n <PopoverAnchor>\n <ui.div\n className=\"ui-context-menu__anchor\"\n style={{ position: \"absolute\", ...position }}\n />\n </PopoverAnchor>\n\n <PopoverTrigger>\n <ui.div\n ref={ref}\n className={cx(\"ui-context-menu\", className)}\n __css={css}\n {...rest}\n onContextMenu={handlerAll(rest.onContextMenu, onContextMenu)}\n >\n {children}\n </ui.div>\n </PopoverTrigger>\n </>\n )\n },\n)\n","import type { CSSUIObject } from \"@yamada-ui/core\"\nimport { createDescendant } from \"@yamada-ui/use-descendant\"\nimport { createContext } from \"@yamada-ui/utils\"\nimport type {\n Dispatch,\n KeyboardEventHandler,\n MutableRefObject,\n RefObject,\n SetStateAction,\n} from \"react\"\nimport type { MenuOptions } from \"./menu\"\n\nexport const {\n DescendantsContextProvider,\n useDescendantsContext: useMenuDescendantsContext,\n useDescendants,\n useDescendant: useMenuDescendant,\n} = createDescendant()\n\ninterface MenuContext extends MenuOptions {\n isOpen: boolean\n onOpen: () => void\n onClose: () => void\n onUpstreamClose?: () => void\n onFocusFirstItem: () => void\n onFocusLastItem: () => void\n focusedIndex: number\n setFocusedIndex: Dispatch<SetStateAction<number>>\n menuRef: RefObject<HTMLDivElement>\n requestAnimationFrameId: MutableRefObject<number | null>\n isNested: boolean\n styles: { [key: string]: CSSUIObject }\n}\n\nexport const [MenuProvider, useMenu] = createContext<MenuContext>({\n name: \"MenuContext\",\n errorMessage: `useMenu returned is 'undefined'. Seems you forgot to wrap the components in \"<Menu />\"`,\n})\n\ninterface ContextMenuContext {\n styles: { [key: string]: CSSUIObject }\n}\n\nexport const [ContextMenuProvider, useContextMenu] =\n createContext<ContextMenuContext>({\n strict: false,\n name: \"ContextMenuContext\",\n })\n\ninterface UpstreamMenuContext {\n relatedRef: RefObject<HTMLElement>\n onDownstreamCloseMapRef: MutableRefObject<Map<string, () => void>>\n onUpstreamClose: () => void\n}\n\nexport const [UpstreamMenuProvider, useUpstreamMenu] =\n createContext<UpstreamMenuContext>({\n strict: false,\n name: \"UpstreamMenuContext\",\n })\n\ninterface UpstreamMenuItemContext {\n onUpstreamRestoreFocus: () => void\n onKeyDownRef: RefObject<KeyboardEventHandler<HTMLLIElement>>\n setDownstreamOpen: Dispatch<SetStateAction<boolean>>\n hasDownstreamRef: MutableRefObject<boolean>\n}\n\nexport const [UpstreamMenuItemProvider, useUpstreamMenuItem] =\n createContext<UpstreamMenuItemContext>({\n strict: false,\n name: \"UpstreamMenuItemContext\",\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA+B;AAC/B,qBAA8C;AAC9C,IAAAA,gBAA+B;AAE/B,mBAAyB;;;ACJzB,4BAAiC;AACjC,mBAA8B;AAUvB,IAAM;AAAA,EACX;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version":3,"sources":["../src/context-menu-trigger.tsx","../src/menu-context.ts"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport type { MouseEvent } from \"react\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { PopoverAnchor, PopoverTrigger } from \"@yamada-ui/popover\"\nimport { cx, handlerAll } from \"@yamada-ui/utils\"\nimport { useState } from \"react\"\nimport { useContextMenu } from \"./menu-context\"\n\ninterface Position {\n left: number\n top: number\n}\n\nexport interface ContextMenuTriggerProps extends HTMLUIProps {}\n\nexport const ContextMenuTrigger = forwardRef<ContextMenuTriggerProps, \"div\">(\n ({ className, children, ...rest }, ref) => {\n const { styles } = useContextMenu() ?? {}\n const [position, setPosition] = useState<Position>({ left: 0, top: 0 })\n\n const css: CSSUIObject = { ...styles?.container }\n\n const onContextMenu = (ev: MouseEvent) => {\n setPosition({ left: ev.pageX, top: ev.pageY })\n }\n\n return (\n <>\n <PopoverAnchor>\n <ui.div\n className=\"ui-context-menu__anchor\"\n style={{ position: \"absolute\", ...position }}\n />\n </PopoverAnchor>\n\n <PopoverTrigger>\n <ui.div\n ref={ref}\n className={cx(\"ui-context-menu\", className)}\n __css={css}\n {...rest}\n onContextMenu={handlerAll(rest.onContextMenu, onContextMenu)}\n >\n {children}\n </ui.div>\n </PopoverTrigger>\n </>\n )\n },\n)\n","import type { CSSUIObject } from \"@yamada-ui/core\"\nimport type {\n Dispatch,\n KeyboardEventHandler,\n MutableRefObject,\n RefObject,\n SetStateAction,\n} from \"react\"\nimport type { MenuOptions } from \"./menu\"\nimport { createDescendant } from \"@yamada-ui/use-descendant\"\nimport { createContext } from \"@yamada-ui/utils\"\n\nexport const {\n DescendantsContextProvider,\n useDescendant: useMenuDescendant,\n useDescendants,\n useDescendantsContext: useMenuDescendantsContext,\n} = createDescendant()\n\ninterface MenuContext extends MenuOptions {\n focusedIndex: number\n isNested: boolean\n isOpen: boolean\n menuRef: RefObject<HTMLDivElement>\n requestAnimationFrameId: MutableRefObject<null | number>\n setFocusedIndex: Dispatch<SetStateAction<number>>\n styles: { [key: string]: CSSUIObject | undefined }\n onClose: () => void\n onFocusFirstItem: () => void\n onFocusLastItem: () => void\n onOpen: () => void\n onUpstreamClose?: () => void\n}\n\nexport const [MenuProvider, useMenu] = createContext<MenuContext>({\n name: \"MenuContext\",\n errorMessage: `useMenu returned is 'undefined'. Seems you forgot to wrap the components in \"<Menu />\"`,\n})\n\ninterface ContextMenuContext {\n styles: { [key: string]: CSSUIObject | undefined }\n}\n\nexport const [ContextMenuProvider, useContextMenu] =\n createContext<ContextMenuContext>({\n name: \"ContextMenuContext\",\n strict: false,\n })\n\ninterface UpstreamMenuContext {\n relatedRef: RefObject<HTMLElement>\n onDownstreamCloseMapRef: MutableRefObject<Map<string, () => void>>\n onUpstreamClose: () => void\n}\n\nexport const [UpstreamMenuProvider, useUpstreamMenu] =\n createContext<UpstreamMenuContext>({\n name: \"UpstreamMenuContext\",\n strict: false,\n })\n\ninterface UpstreamMenuItemContext {\n hasDownstreamRef: MutableRefObject<boolean>\n setDownstreamOpen: Dispatch<SetStateAction<boolean>>\n onKeyDownRef: RefObject<KeyboardEventHandler<HTMLLIElement>>\n onUpstreamRestoreFocus: () => void\n}\n\nexport const [UpstreamMenuItemProvider, useUpstreamMenuItem] =\n createContext<UpstreamMenuItemContext>({\n name: \"UpstreamMenuItemContext\",\n strict: false,\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAA+B;AAC/B,qBAA8C;AAC9C,IAAAA,gBAA+B;AAC/B,mBAAyB;;;ACIzB,4BAAiC;AACjC,mBAA8B;AAEvB,IAAM;AAAA,EACX;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA,uBAAuB;AACzB,QAAI,wCAAiB;AAiBd,IAAM,CAAC,cAAc,OAAO,QAAI,4BAA2B;AAAA,EAChE,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AAMM,IAAM,C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
5
+ import "./chunk-EJHOFPF4.mjs";
6
6
  export {
7
7
  ContextMenuTrigger
8
8
  };
@@ -38,25 +38,25 @@ var import_use_descendant = require("@yamada-ui/use-descendant");
38
38
  var import_utils = require("@yamada-ui/utils");
39
39
  var {
40
40
  DescendantsContextProvider,
41
- useDescendantsContext: useMenuDescendantsContext,
41
+ useDescendant: useMenuDescendant,
42
42
  useDescendants,
43
- useDescendant: useMenuDescendant
43
+ useDescendantsContext: useMenuDescendantsContext
44
44
  } = (0, import_use_descendant.createDescendant)();
45
45
  var [MenuProvider, useMenu] = (0, import_utils.createContext)({
46
46
  name: "MenuContext",
47
47
  errorMessage: `useMenu returned is 'undefined'. Seems you forgot to wrap the components in "<Menu />"`
48
48
  });
49
49
  var [ContextMenuProvider, useContextMenu] = (0, import_utils.createContext)({
50
- strict: false,
51
- name: "ContextMenuContext"
50
+ name: "ContextMenuContext",
51
+ strict: false
52
52
  });
53
53
  var [UpstreamMenuProvider, useUpstreamMenu] = (0, import_utils.createContext)({
54
- strict: false,
55
- name: "UpstreamMenuContext"
54
+ name: "UpstreamMenuContext",
55
+ strict: false
56
56
  });
57
57
  var [UpstreamMenuItemProvider, useUpstreamMenuItem] = (0, import_utils.createContext)({
58
- strict: false,
59
- name: "UpstreamMenuItemContext"
58
+ name: "UpstreamMenuItemContext",
59
+ strict: false
60
60
  });
61
61
 
62
62
  // src/menu.tsx
@@ -69,18 +69,18 @@ var Menu = (props) => {
69
69
  styles: contextMenuStyles
70
70
  });
71
71
  let {
72
- initialFocusRef,
73
- closeOnSelect = true,
74
72
  closeOnBlur,
75
- placement,
73
+ closeOnSelect = true,
76
74
  duration = 0.2,
75
+ initialFocusRef,
77
76
  offset,
78
- onOpen: onOpenProp,
77
+ placement,
79
78
  onClose: onCloseProp,
79
+ onOpen: onOpenProp,
80
80
  ...rest
81
81
  } = (0, import_core.omitThemeProps)(mergedProps);
82
- const { relatedRef, onUpstreamClose, onDownstreamCloseMapRef } = (_b = useUpstreamMenu()) != null ? _b : {};
83
- const { setDownstreamOpen, hasDownstreamRef } = (_c = useUpstreamMenuItem()) != null ? _c : {};
82
+ const { relatedRef, onDownstreamCloseMapRef, onUpstreamClose } = (_b = useUpstreamMenu()) != null ? _b : {};
83
+ const { hasDownstreamRef, setDownstreamOpen } = (_c = useUpstreamMenuItem()) != null ? _c : {};
84
84
  const isNested = !!relatedRef;
85
85
  if (isNested) {
86
86
  placement != null ? placement : placement = "right-start";
@@ -130,10 +130,10 @@ var Menu = (props) => {
130
130
  }
131
131
  }, [onCloseProp]);
132
132
  const id = (0, import_react.useId)();
133
- const { isOpen, onOpen, onClose } = (0, import_use_disclosure.useDisclosure)({
133
+ const { isOpen, onClose, onOpen } = (0, import_use_disclosure.useDisclosure)({
134
134
  ...props,
135
- onOpen: onOpenInternal,
136
- onClose: onCloseInternal
135
+ onClose: onCloseInternal,
136
+ onOpen: onOpenInternal
137
137
  });
138
138
  (0, import_react.useEffect)(() => {
139
139
  const onCloseMap = onDownstreamCloseMapRef == null ? void 0 : onDownstreamCloseMapRef.current;
@@ -170,19 +170,19 @@ var Menu = (props) => {
170
170
  MenuProvider,
171
171
  {
172
172
  value: {
173
- isOpen,
174
- onOpen,
175
- onClose,
176
- onUpstreamClose,
177
- onFocusFirstItem,
178
- onFocusLastItem,
179
173
  closeOnSelect,
180
174
  focusedIndex,
181
- setFocusedIndex,
175
+ isNested,
176
+ isOpen,
182
177
  menuRef,
183
178
  requestAnimationFrameId,
184
- isNested,
185
- styles
179
+ setFocusedIndex,
180
+ styles,
181
+ onClose,
182
+ onFocusFirstItem,
183
+ onFocusLastItem,
184
+ onOpen,
185
+ onUpstreamClose
186
186
  },
187
187
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
188
188
  import_popover.Popover,
@@ -190,16 +190,16 @@ var Menu = (props) => {
190
190
  ...{
191
191
  trigger: isNested ? "hover" : "click",
192
192
  ...rest,
193
- isOpen,
194
- onOpen,
195
- onClose,
196
- placement,
197
- offset,
193
+ closeOnBlur,
194
+ closeOnButton: false,
198
195
  duration,
199
196
  initialFocusRef,
197
+ isOpen,
198
+ offset,
199
+ placement,
200
200
  relatedRef,
201
- closeOnButton: false,
202
- closeOnBlur
201
+ onClose,
202
+ onOpen
203
203
  }
204
204
  }
205
205
  )
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context-menu.tsx","../src/menu.tsx","../src/menu-context.ts"],"sourcesContent":["import type { ThemeProps } from \"@yamada-ui/core\"\nimport { useComponentMultiStyle, omitThemeProps } from \"@yamada-ui/core\"\nimport type { FC } from \"react\"\nimport type { MenuProps } from \"./menu\"\nimport { Menu } from \"./menu\"\nimport { ContextMenuProvider } from \"./menu-context\"\n\nexport interface ContextMenuProps\n extends Omit<MenuProps, \"trigger\">,\n ThemeProps<\"ContextMenu\"> {}\n\n/**\n * `ContextMenu` is triggered by a right click and displays a menu at the pointer's position.\n *\n * @see Docs https://yamada-ui.com/components/overlay/context-menu\n */\nexport const ContextMenu: FC<ContextMenuProps> = (props) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"ContextMenu\", props)\n const { ...rest } = omitThemeProps(mergedProps)\n\n return (\n <ContextMenuProvider value={{ styles }}>\n <Menu trigger=\"contextmenu\" {...rest} />\n </ContextMenuProvider>\n )\n}\n","import type { ThemeProps } from \"@yamada-ui/core\"\nimport { useComponentMultiStyle, omitThemeProps } from \"@yamada-ui/core\"\nimport type { PopoverProps } from \"@yamada-ui/popover\"\nimport { Popover } from \"@yamada-ui/popover\"\nimport { useDisclosure } from \"@yamada-ui/use-disclosure\"\nimport { funcAll, useUnmountEffect, useUpdateEffect } from \"@yamada-ui/utils\"\nimport type { FC } from \"react\"\nimport { useCallback, useEffect, useId, useRef, useState } from \"react\"\nimport {\n DescendantsContextProvider,\n MenuProvider,\n UpstreamMenuProvider,\n useContextMenu,\n useDescendants,\n useUpstreamMenu,\n useUpstreamMenuItem,\n} from \"./menu-context\"\n\nexport interface MenuOptions {\n /**\n * If `true`, the list element will be closed when value is selected.\n *\n * @default true\n */\n closeOnSelect?: boolean\n}\n\nexport interface MenuProps\n extends ThemeProps<\"Menu\">,\n Omit<PopoverProps, \"closeOnButton\" | \"relatedRef\">,\n MenuOptions {}\n\n/**\n * `Menu` is a component that displays a common dropdown menu.\n *\n * @see Docs https://yamada-ui.com/components/overlay/menu\n */\nexport const Menu: FC<MenuProps> = (props) => {\n const { styles: contextMenuStyles } = useContextMenu() ?? {}\n const [styles, mergedProps] = useComponentMultiStyle(\"Menu\", props, {\n isProcessSkip: !!contextMenuStyles,\n styles: contextMenuStyles,\n })\n let {\n initialFocusRef,\n closeOnSelect = true,\n closeOnBlur,\n placement,\n duration = 0.2,\n offset,\n onOpen: onOpenProp,\n onClose: onCloseProp,\n ...rest\n } = omitThemeProps(mergedProps)\n const { relatedRef, onUpstreamClose, onDownstreamCloseMapRef } =\n useUpstreamMenu() ?? {}\n const { setDownstreamOpen, hasDownstreamRef } = useUpstreamMenuItem() ?? {}\n const isNested = !!relatedRef\n\n if (isNested) {\n placement ??= \"right-start\"\n offset ??= [-8, 8]\n closeOnBlur ??= false\n } else {\n placement ??= \"bottom-start\"\n }\n\n const descendants = useDescendants()\n\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n\n const menuRef = useRef<HTMLDivElement>(null)\n const timeoutIds = useRef<Set<any>>(new Set([]))\n const requestAnimationFrameId = useRef<number | null>(null)\n const onCloseMapRef = useRef<Map<string, () => void>>(new Map())\n\n const onFocusMenu = useCallback(() => {\n requestAnimationFrame(() =>\n menuRef.current?.focus({ preventScroll: false }),\n )\n }, [])\n\n const onFocusFirstItem = useCallback(() => {\n const id = setTimeout(() => {\n if (initialFocusRef) return\n\n const first = descendants.enabledFirstValue()\n\n if (first) setFocusedIndex(first.index)\n })\n\n timeoutIds.current.add(id)\n }, [descendants, initialFocusRef])\n\n const onFocusLastItem = useCallback(() => {\n const id = setTimeout(() => {\n if (initialFocusRef) return\n\n const last = descendants.enabledLastValue()\n\n if (last) setFocusedIndex(last.index)\n })\n\n timeoutIds.current.add(id)\n }, [descendants, initialFocusRef])\n\n const onOpenInternal = useCallback(() => {\n onOpenProp?.()\n\n if (!isNested) onFocusMenu()\n }, [onOpenProp, isNested, onFocusMenu])\n\n const onCloseInternal = useCallback(() => {\n onCloseProp?.()\n\n for (const onClose of onCloseMapRef.current.values()) {\n onClose()\n }\n }, [onCloseProp])\n\n const id = useId()\n const { isOpen, onOpen, onClose } = useDisclosure({\n ...props,\n onOpen: onOpenInternal,\n onClose: onCloseInternal,\n })\n\n useEffect(() => {\n const onCloseMap = onDownstreamCloseMapRef?.current\n\n onCloseMap?.set(id, onClose)\n\n return () => {\n onCloseMap?.delete(id)\n }\n }, [id, onClose, onDownstreamCloseMapRef])\n\n useEffect(() => {\n if (setDownstreamOpen) setDownstreamOpen(isOpen)\n }, [setDownstreamOpen, isOpen])\n\n useEffect(() => {\n if (hasDownstreamRef) hasDownstreamRef.current = true\n\n return () => {\n if (hasDownstreamRef) hasDownstreamRef.current = false\n }\n })\n\n useUpdateEffect(() => {\n if (!isOpen) setFocusedIndex(-1)\n }, [isOpen])\n\n useUnmountEffect(() => {\n timeoutIds.current.forEach((id) => clearTimeout(id))\n timeoutIds.current.clear()\n })\n\n return (\n <DescendantsContextProvider value={descendants}>\n <UpstreamMenuProvider\n value={{\n relatedRef: menuRef,\n onDownstreamCloseMapRef: onCloseMapRef,\n onUpstreamClose: funcAll(onUpstreamClose, onClose),\n }}\n >\n <MenuProvider\n value={{\n isOpen,\n onOpen,\n onClose,\n onUpstreamClose,\n onFocusFirstItem,\n onFocusLastItem,\n closeOnSelect,\n focusedIndex,\n setFocusedIndex,\n menuRef,\n requestAnimationFrameId,\n isNested,\n styles,\n }}\n >\n <Popover\n {...{\n trigger: isNested ? \"hover\" : \"click\",\n ...rest,\n isOpen,\n onOpen,\n onClose,\n placement,\n offset,\n duration,\n initialFocusRef,\n relatedRef,\n closeOnButton: false,\n closeOnBlur,\n }}\n />\n </MenuProvider>\n </UpstreamMenuProvider>\n </DescendantsContextProvider>\n )\n}\n","import type { CSSUIObject } from \"@yamada-ui/core\"\nimport { createDescendant } from \"@yamada-ui/use-descendant\"\nimport { createContext } from \"@yamada-ui/utils\"\nimport type {\n Dispatch,\n KeyboardEventHandler,\n MutableRefObject,\n RefObject,\n SetStateAction,\n} from \"react\"\nimport type { MenuOptions } from \"./menu\"\n\nexport const {\n DescendantsContextProvider,\n useDescendantsContext: useMenuDescendantsContext,\n useDescendants,\n useDescendant: useMenuDescendant,\n} = createDescendant()\n\ninterface MenuContext extends MenuOptions {\n isOpen: boolean\n onOpen: () => void\n onClose: () => void\n onUpstreamClose?: () => void\n onFocusFirstItem: () => void\n onFocusLastItem: () => void\n focusedIndex: number\n setFocusedIndex: Dispatch<SetStateAction<number>>\n menuRef: RefObject<HTMLDivElement>\n requestAnimationFrameId: MutableRefObject<number | null>\n isNested: boolean\n styles: { [key: string]: CSSUIObject }\n}\n\nexport const [MenuProvider, useMenu] = createContext<MenuContext>({\n name: \"MenuContext\",\n errorMessage: `useMenu returned is 'undefined'. Seems you forgot to wrap the components in \"<Menu />\"`,\n})\n\ninterface ContextMenuContext {\n styles: { [key: string]: CSSUIObject }\n}\n\nexport const [ContextMenuProvider, useContextMenu] =\n createContext<ContextMenuContext>({\n strict: false,\n name: \"ContextMenuContext\",\n })\n\ninterface UpstreamMenuContext {\n relatedRef: RefObject<HTMLElement>\n onDownstreamCloseMapRef: MutableRefObject<Map<string, () => void>>\n onUpstreamClose: () => void\n}\n\nexport const [UpstreamMenuProvider, useUpstreamMenu] =\n createContext<UpstreamMenuContext>({\n strict: false,\n name: \"UpstreamMenuContext\",\n })\n\ninterface UpstreamMenuItemContext {\n onUpstreamRestoreFocus: () => void\n onKeyDownRef: RefObject<KeyboardEventHandler<HTMLLIElement>>\n setDownstreamOpen: Dispatch<SetStateAction<boolean>>\n hasDownstreamRef: MutableRefObject<boolean>\n}\n\nexport const [UpstreamMenuItemProvider, useUpstreamMenuItem] =\n createContext<UpstreamMenuIt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AA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,UAEA;AAAA,YAAC;AAAA;AAAA,cACE,GAAG;AAAA,gBACF,SAAS,WAAW,UAAU;AAAA,gBAC9B,GAAG;AAAA,gBACH;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,eAAe;AAAA,gBACf;AAAA,cACF;AAAA;AAAA,UACF;AAAA;AAAA,MACF;AAAA;AAAA,EACF,GACF;AAEJ;;;ADtLM,IAAAE,sBAAA;AANC,IAAM,cAAoC,CAAC,UAAU;AAC1D,QAAM,CAAC,QAAQ,WAAW,QAAI,qCAAuB,eAAe,KAAK;AACzE,QAAM,EAAE,GAAG,KAAK,QAAI,6BAAe,WAAW;AAE9C,SACE,6CAAC,uBAAoB,OAAO,EAAE,OAAO,GACnC,uDAAC,QAAK,SAAQ,eAAe,GAAG,MAAM,GACxC;AAEJ;","names":["import_core","import_utils","_a","id","onClose","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../src/context-menu.tsx","../src/menu.tsx","../src/menu-context.ts"],"sourcesContent":["import type { ThemeProps } from \"@yamada-ui/core\"\nimport type { FC } from \"react\"\nimport type { MenuProps } from \"./menu\"\nimport { omitThemeProps, useComponentMultiStyle } from \"@yamada-ui/core\"\nimport { Menu } from \"./menu\"\nimport { ContextMenuProvider } from \"./menu-context\"\n\nexport interface ContextMenuProps\n extends Omit<MenuProps, \"trigger\">,\n ThemeProps<\"ContextMenu\"> {}\n\n/**\n * `ContextMenu` is triggered by a right click and displays a menu at the pointer's position.\n *\n * @see Docs https://yamada-ui.com/components/overlay/context-menu\n */\nexport const ContextMenu: FC<ContextMenuProps> = (props) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"ContextMenu\", props)\n const { ...rest } = omitThemeProps(mergedProps)\n\n return (\n <ContextMenuProvider value={{ styles }}>\n <Menu trigger=\"contextmenu\" {...rest} />\n </ContextMenuProvider>\n )\n}\n","import type { ThemeProps } from \"@yamada-ui/core\"\nimport type { PopoverProps } from \"@yamada-ui/popover\"\nimport type { FC } from \"react\"\nimport { omitThemeProps, useComponentMultiStyle } from \"@yamada-ui/core\"\nimport { Popover } from \"@yamada-ui/popover\"\nimport { useDisclosure } from \"@yamada-ui/use-disclosure\"\nimport { funcAll, useUnmountEffect, useUpdateEffect } from \"@yamada-ui/utils\"\nimport { useCallback, useEffect, useId, useRef, useState } from \"react\"\nimport {\n DescendantsContextProvider,\n MenuProvider,\n UpstreamMenuProvider,\n useContextMenu,\n useDescendants,\n useUpstreamMenu,\n useUpstreamMenuItem,\n} from \"./menu-context\"\n\nexport interface MenuOptions {\n /**\n * If `true`, the list element will be closed when value is selected.\n *\n * @default true\n */\n closeOnSelect?: boolean\n}\n\nexport interface MenuProps\n extends ThemeProps<\"Menu\">,\n Omit<PopoverProps, \"closeOnButton\" | \"relatedRef\">,\n MenuOptions {}\n\n/**\n * `Menu` is a component that displays a common dropdown menu.\n *\n * @see Docs https://yamada-ui.com/components/overlay/menu\n */\nexport const Menu: FC<MenuProps> = (props) => {\n const { styles: contextMenuStyles } = useContextMenu() ?? {}\n const [styles, mergedProps] = useComponentMultiStyle(\"Menu\", props, {\n isProcessSkip: !!contextMenuStyles,\n styles: contextMenuStyles,\n })\n let {\n closeOnBlur,\n closeOnSelect = true,\n duration = 0.2,\n initialFocusRef,\n offset,\n placement,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n ...rest\n } = omitThemeProps(mergedProps)\n const { relatedRef, onDownstreamCloseMapRef, onUpstreamClose } =\n useUpstreamMenu() ?? {}\n const { hasDownstreamRef, setDownstreamOpen } = useUpstreamMenuItem() ?? {}\n const isNested = !!relatedRef\n\n if (isNested) {\n placement ??= \"right-start\"\n offset ??= [-8, 8]\n closeOnBlur ??= false\n } else {\n placement ??= \"bottom-start\"\n }\n\n const descendants = useDescendants()\n\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n\n const menuRef = useRef<HTMLDivElement>(null)\n const timeoutIds = useRef<Set<any>>(new Set([]))\n const requestAnimationFrameId = useRef<null | number>(null)\n const onCloseMapRef = useRef<Map<string, () => void>>(new Map())\n\n const onFocusMenu = useCallback(() => {\n requestAnimationFrame(() =>\n menuRef.current?.focus({ preventScroll: false }),\n )\n }, [])\n\n const onFocusFirstItem = useCallback(() => {\n const id = setTimeout(() => {\n if (initialFocusRef) return\n\n const first = descendants.enabledFirstValue()\n\n if (first) setFocusedIndex(first.index)\n })\n\n timeoutIds.current.add(id)\n }, [descendants, initialFocusRef])\n\n const onFocusLastItem = useCallback(() => {\n const id = setTimeout(() => {\n if (initialFocusRef) return\n\n const last = descendants.enabledLastValue()\n\n if (last) setFocusedIndex(last.index)\n })\n\n timeoutIds.current.add(id)\n }, [descendants, initialFocusRef])\n\n const onOpenInternal = useCallback(() => {\n onOpenProp?.()\n\n if (!isNested) onFocusMenu()\n }, [onOpenProp, isNested, onFocusMenu])\n\n const onCloseInternal = useCallback(() => {\n onCloseProp?.()\n\n for (const onClose of onCloseMapRef.current.values()) {\n onClose()\n }\n }, [onCloseProp])\n\n const id = useId()\n const { isOpen, onClose, onOpen } = useDisclosure({\n ...props,\n onClose: onCloseInternal,\n onOpen: onOpenInternal,\n })\n\n useEffect(() => {\n const onCloseMap = onDownstreamCloseMapRef?.current\n\n onCloseMap?.set(id, onClose)\n\n return () => {\n onCloseMap?.delete(id)\n }\n }, [id, onClose, onDownstreamCloseMapRef])\n\n useEffect(() => {\n if (setDownstreamOpen) setDownstreamOpen(isOpen)\n }, [setDownstreamOpen, isOpen])\n\n useEffect(() => {\n if (hasDownstreamRef) hasDownstreamRef.current = true\n\n return () => {\n if (hasDownstreamRef) hasDownstreamRef.current = false\n }\n })\n\n useUpdateEffect(() => {\n if (!isOpen) setFocusedIndex(-1)\n }, [isOpen])\n\n useUnmountEffect(() => {\n timeoutIds.current.forEach((id) => clearTimeout(id))\n timeoutIds.current.clear()\n })\n\n return (\n <DescendantsContextProvider value={descendants}>\n <UpstreamMenuProvider\n value={{\n relatedRef: menuRef,\n onDownstreamCloseMapRef: onCloseMapRef,\n onUpstreamClose: funcAll(onUpstreamClose, onClose),\n }}\n >\n <MenuProvider\n value={{\n closeOnSelect,\n focusedIndex,\n isNested,\n isOpen,\n menuRef,\n requestAnimationFrameId,\n setFocusedIndex,\n styles,\n onClose,\n onFocusFirstItem,\n onFocusLastItem,\n onOpen,\n onUpstreamClose,\n }}\n >\n <Popover\n {...{\n trigger: isNested ? \"hover\" : \"click\",\n ...rest,\n closeOnBlur,\n closeOnButton: false,\n duration,\n initialFocusRef,\n isOpen,\n offset,\n placement,\n relatedRef,\n onClose,\n onOpen,\n }}\n />\n </MenuProvider>\n </UpstreamMenuProvider>\n </DescendantsContextProvider>\n )\n}\n","import type { CSSUIObject } from \"@yamada-ui/core\"\nimport type {\n Dispatch,\n KeyboardEventHandler,\n MutableRefObject,\n RefObject,\n SetStateAction,\n} from \"react\"\nimport type { MenuOptions } from \"./menu\"\nimport { createDescendant } from \"@yamada-ui/use-descendant\"\nimport { createContext } from \"@yamada-ui/utils\"\n\nexport const {\n DescendantsContextProvider,\n useDescendant: useMenuDescendant,\n useDescendants,\n useDescendantsContext: useMenuDescendantsContext,\n} = createDescendant()\n\ninterface MenuContext extends MenuOptions {\n focusedIndex: number\n isNested: boolean\n isOpen: boolean\n menuRef: RefObject<HTMLDivElement>\n requestAnimationFrameId: MutableRefObject<null | number>\n setFocusedIndex: Dispatch<SetStateAction<number>>\n styles: { [key: string]: CSSUIObject | undefined }\n onClose: () => void\n onFocusFirstItem: () => void\n onFocusLastItem: () => void\n onOpen: () => void\n onUpstreamClose?: () => void\n}\n\nexport const [MenuProvider, useMenu] = createContext<MenuContext>({\n name: \"MenuContext\",\n errorMessage: `useMenu returned is 'undefined'. Seems you forgot to wrap the components in \"<Menu />\"`,\n})\n\ninterface ContextMenuContext {\n styles: { [key: string]: CSSUIObject | undefined }\n}\n\nexport const [ContextMenuProvider, useContextMenu] =\n createContext<ContextMenuContext>({\n name: \"ContextMenuContext\",\n strict: false,\n })\n\ninterface UpstreamMenuContext {\n relatedRef: RefObject<HTMLElement>\n onDownstreamCloseMapRef: MutableRefObject<Map<string, () => void>>\n onUpstreamClose: () => void\n}\n\nexport const [UpstreamMenuProvider, useUpstreamMenu] =\n createContext<UpstreamMenuContext>({\n name: \"UpstreamMenuContext\",\n strict: false,\n })\n\ninterface UpstreamMenuItemContext {\n hasDownstreamRef: MutableRefObject<boolean>\n setDownstreamOpen: Dispatch<SetStateAction<boolean>>\n onKeyDownRef: RefObject<KeyboardEventHandler<HTMLLIElement>>\n onUpstreamRestoreFocus: () => void\n}\n\nexport const [UpstreamMenuItemProvider, useUpstreamMenuItem] =\n createContext<UpstreamMenuItemContext>({\n name: \"UpstreamMenuItemContext\",\n strict: false,\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAAA,eAAuD;;;ACAvD,kBAAuD;AACvD,qBAAwB;AACxB,4BAA8B;AAC9B,IAAAC,gBAA2D;AAC3D,mBAAgE;;;ACEhE,4BAAiC;AACjC,mBAA8B;AAEvB,IAAM;AAAA,EACX;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA,uBAAuB;AACzB,QAAI,wCAAiB;AAiBd,IAAM,CAAC,cAAc,OAAO,QAAI,4BAA2B;AAAA,EAChE,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AAMM,IAAM,CAAC,qBAAqB,cAAc,QAC/C,4BAAkC;AAAA,EAChC,MAAM;AAAA,EACN,QAAQ;AACV,CAAC;AAQI,IAAM,CAAC,sBAAsB,eAAe,QACjD,4BAAmC;AAAA,EACjC,MAAM;AAAA,EACN,QAAQ;AACV,CAAC;AASI,IAAM,CAAC,0BAA0B,mBAAmB,QACzD,4BAAuC;AAAA,EACrC,MAAM;AAAA,EACN,QAAQ;AACV,C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9 @@
1
1
  "use client"
2
2
  import {
3
3
  ContextMenu
4
- } from "./chunk-ZV73JKM5.mjs";
5
- import "./chunk-NNSVX2GX.mjs";
6
- import "./chunk-ZUOFHOX6.mjs";
4
+ } from "./chunk-ELQD4RMJ.mjs";
5
+ import "./chunk-I2KIZ6OI.mjs";
6
+ import "./chunk-EJHOFPF4.mjs";
7
7
  export {
8
8
  ContextMenu
9
9
  };
package/dist/index.d.mts CHANGED
@@ -1,13 +1,13 @@
1
+ export { ContextMenu, ContextMenuProps } from './context-menu.mjs';
2
+ export { ContextMenuTrigger, ContextMenuTriggerProps } from './context-menu-trigger.mjs';
1
3
  export { Menu, MenuProps } from './menu.mjs';
2
4
  export { MenuButton, MenuButtonProps, MenuItemButton, MenuItemButtonProps } from './menu-button.mjs';
3
- export { MenuList, MenuListProps } from './menu-list.mjs';
4
- export { MenuCommand, MenuCommandProps, MenuIcon, MenuIconProps, MenuItem, MenuItemProps, MenuOptionItem, MenuOptionItemProps } from './menu-item.mjs';
5
+ export { MenuDivider, MenuDividerProps } from './menu-divider.mjs';
5
6
  export { MenuGroup, MenuGroupProps } from './menu-group.mjs';
7
+ export { MenuCommand, MenuCommandProps, MenuIcon, MenuIconProps, MenuItem, MenuItemProps, MenuOptionItem, MenuOptionItemProps } from './menu-item.mjs';
8
+ export { MenuList, MenuListProps } from './menu-list.mjs';
6
9
  export { MenuOptionGroup, MenuOptionGroupProps } from './menu-option-group.mjs';
7
- export { MenuDivider, MenuDividerProps } from './menu-divider.mjs';
8
- export { ContextMenu, ContextMenuProps } from './context-menu.mjs';
9
- export { ContextMenuTrigger, ContextMenuTriggerProps } from './context-menu-trigger.mjs';
10
10
  import '@yamada-ui/core';
11
- import '@yamada-ui/popover';
12
11
  import 'react';
12
+ import '@yamada-ui/popover';
13
13
  import '@yamada-ui/motion';
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
+ export { ContextMenu, ContextMenuProps } from './context-menu.js';
2
+ export { ContextMenuTrigger, ContextMenuTriggerProps } from './context-menu-trigger.js';
1
3
  export { Menu, MenuProps } from './menu.js';
2
4
  export { MenuButton, MenuButtonProps, MenuItemButton, MenuItemButtonProps } from './menu-button.js';
3
- export { MenuList, MenuListProps } from './menu-list.js';
4
- export { MenuCommand, MenuCommandProps, MenuIcon, MenuIconProps, MenuItem, MenuItemProps, MenuOptionItem, MenuOptionItemProps } from './menu-item.js';
5
+ export { MenuDivider, MenuDividerProps } from './menu-divider.js';
5
6
  export { MenuGroup, MenuGroupProps } from './menu-group.js';
7
+ export { MenuCommand, MenuCommandProps, MenuIcon, MenuIconProps, MenuItem, MenuItemProps, MenuOptionItem, MenuOptionItemProps } from './menu-item.js';
8
+ export { MenuList, MenuListProps } from './menu-list.js';
6
9
  export { MenuOptionGroup, MenuOptionGroupProps } from './menu-option-group.js';
7
- export { MenuDivider, MenuDividerProps } from './menu-divider.js';
8
- export { ContextMenu, ContextMenuProps } from './context-menu.js';
9
- export { ContextMenuTrigger, ContextMenuTriggerProps } from './context-menu-trigger.js';
10
10
  import '@yamada-ui/core';
11
- import '@yamada-ui/popover';
12
11
  import 'react';
12
+ import '@yamada-ui/popover';
13
13
  import '@yamada-ui/motion';