@yamada-ui/menu 1.3.12 → 1.3.13-dev-20240917033401

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. package/dist/{chunk-5ZWRZF6M.mjs → chunk-DPC5A6DV.mjs} +2 -2
  2. package/dist/chunk-DPC5A6DV.mjs.map +1 -0
  3. package/dist/{chunk-AG6UJA7D.mjs → chunk-HVOHR2NQ.mjs} +2 -2
  4. package/dist/chunk-HVOHR2NQ.mjs.map +1 -0
  5. package/dist/{chunk-G4OMCC2Y.mjs → chunk-M4PPRRRC.mjs} +5 -3
  6. package/dist/chunk-M4PPRRRC.mjs.map +1 -0
  7. package/dist/chunk-NNSVX2GX.mjs +170 -0
  8. package/dist/chunk-NNSVX2GX.mjs.map +1 -0
  9. package/dist/{chunk-73KHS3JD.mjs → chunk-O5D4LR5P.mjs} +2 -2
  10. package/dist/chunk-O5D4LR5P.mjs.map +1 -0
  11. package/dist/chunk-OFCEMPQW.mjs +29 -0
  12. package/dist/chunk-OFCEMPQW.mjs.map +1 -0
  13. package/dist/{chunk-6YBKZRIZ.mjs → chunk-SI3WI4AI.mjs} +3 -3
  14. package/dist/chunk-SI3WI4AI.mjs.map +1 -0
  15. package/dist/chunk-T7CXLEBW.mjs +243 -0
  16. package/dist/chunk-T7CXLEBW.mjs.map +1 -0
  17. package/dist/chunk-ZUOFHOX6.mjs +43 -0
  18. package/dist/chunk-ZUOFHOX6.mjs.map +1 -0
  19. package/dist/chunk-ZV73JKM5.mjs +21 -0
  20. package/dist/chunk-ZV73JKM5.mjs.map +1 -0
  21. package/dist/context-menu-trigger.d.mts +2 -1
  22. package/dist/context-menu-trigger.d.ts +2 -1
  23. package/dist/context-menu-trigger.js +32 -17
  24. package/dist/context-menu-trigger.js.map +1 -1
  25. package/dist/context-menu-trigger.mjs +2 -2
  26. package/dist/context-menu.d.mts +4 -10
  27. package/dist/context-menu.d.ts +4 -10
  28. package/dist/context-menu.js +43 -264
  29. package/dist/context-menu.js.map +1 -1
  30. package/dist/context-menu.mjs +5 -5
  31. package/dist/index.d.mts +1 -2
  32. package/dist/index.d.ts +1 -2
  33. package/dist/index.js +259 -255
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +16 -11
  36. package/dist/menu-button.d.mts +4 -3
  37. package/dist/menu-button.d.ts +4 -3
  38. package/dist/menu-button.js +55 -58
  39. package/dist/menu-button.js.map +1 -1
  40. package/dist/menu-button.mjs +3 -2
  41. package/dist/menu-context.d.mts +210 -0
  42. package/dist/menu-context.d.ts +210 -0
  43. package/dist/menu-context.js +77 -0
  44. package/dist/menu-context.js.map +1 -0
  45. package/dist/menu-context.mjs +30 -0
  46. package/dist/menu-context.mjs.map +1 -0
  47. package/dist/menu-divider.d.mts +3 -2
  48. package/dist/menu-divider.d.ts +3 -2
  49. package/dist/menu-divider.js +26 -21
  50. package/dist/menu-divider.js.map +1 -1
  51. package/dist/menu-divider.mjs +2 -2
  52. package/dist/menu-group.d.mts +3 -3
  53. package/dist/menu-group.d.ts +3 -3
  54. package/dist/menu-group.js +17 -14
  55. package/dist/menu-group.js.map +1 -1
  56. package/dist/menu-group.mjs +2 -2
  57. package/dist/menu-item.d.mts +14 -19
  58. package/dist/menu-item.d.ts +14 -19
  59. package/dist/menu-item.js +40 -45
  60. package/dist/menu-item.js.map +1 -1
  61. package/dist/menu-item.mjs +4 -7
  62. package/dist/menu-list.d.mts +2 -2
  63. package/dist/menu-list.d.ts +2 -2
  64. package/dist/menu-list.js +23 -20
  65. package/dist/menu-list.js.map +1 -1
  66. package/dist/menu-list.mjs +2 -2
  67. package/dist/menu-option-group.d.mts +6 -7
  68. package/dist/menu-option-group.d.ts +6 -7
  69. package/dist/menu-option-group.js +97 -100
  70. package/dist/menu-option-group.js.map +1 -1
  71. package/dist/menu-option-group.mjs +4 -3
  72. package/dist/menu.d.mts +7 -87
  73. package/dist/menu.d.ts +7 -87
  74. package/dist/menu.js +41 -274
  75. package/dist/menu.js.map +1 -1
  76. package/dist/menu.mjs +4 -13
  77. package/package.json +11 -11
  78. package/dist/chunk-5ZWRZF6M.mjs.map +0 -1
  79. package/dist/chunk-6IPLI42Z.mjs +0 -447
  80. package/dist/chunk-6IPLI42Z.mjs.map +0 -1
  81. package/dist/chunk-6YBKZRIZ.mjs.map +0 -1
  82. package/dist/chunk-73KHS3JD.mjs.map +0 -1
  83. package/dist/chunk-AG6UJA7D.mjs.map +0 -1
  84. package/dist/chunk-G4OMCC2Y.mjs.map +0 -1
  85. package/dist/chunk-ZOUBZWDN.mjs +0 -27
  86. package/dist/chunk-ZOUBZWDN.mjs.map +0 -1
@@ -0,0 +1,43 @@
1
+ "use client"
2
+
3
+ // src/menu-context.ts
4
+ import { createDescendant } from "@yamada-ui/use-descendant";
5
+ import { createContext } from "@yamada-ui/utils";
6
+ var {
7
+ DescendantsContextProvider,
8
+ useDescendantsContext: useMenuDescendantsContext,
9
+ useDescendants,
10
+ useDescendant: useMenuDescendant
11
+ } = createDescendant();
12
+ var [MenuProvider, useMenu] = createContext({
13
+ name: "MenuContext",
14
+ errorMessage: `useMenu returned is 'undefined'. Seems you forgot to wrap the components in "<Menu />"`
15
+ });
16
+ var [ContextMenuProvider, useContextMenu] = createContext({
17
+ strict: false,
18
+ name: "ContextMenuContext"
19
+ });
20
+ var [UpstreamMenuProvider, useUpstreamMenu] = createContext({
21
+ strict: false,
22
+ name: "UpstreamMenuContext"
23
+ });
24
+ var [UpstreamMenuItemProvider, useUpstreamMenuItem] = createContext({
25
+ strict: false,
26
+ name: "UpstreamMenuItemContext"
27
+ });
28
+
29
+ export {
30
+ DescendantsContextProvider,
31
+ useMenuDescendantsContext,
32
+ useDescendants,
33
+ useMenuDescendant,
34
+ MenuProvider,
35
+ useMenu,
36
+ ContextMenuProvider,
37
+ useContextMenu,
38
+ UpstreamMenuProvider,
39
+ useUpstreamMenu,
40
+ UpstreamMenuItemProvider,
41
+ useUpstreamMenuItem
42
+ };
43
+ //# sourceMappingURL=chunk-ZUOFHOX6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/menu-context.ts"],"sourcesContent":["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":";;;AACA,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAUvB,IAAM;AAAA,EACX;AAAA,EACA,uBAAuB;AAAA,EACvB;AAAA,EACA,eAAe;AACjB,IAAI,iBAAiB;AAiBd,IAAM,CAAC,cAAc,OAAO,IAAI,cAA2B;AAAA,EAChE,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AAMM,IAAM,CAAC,qBAAqB,cAAc,IAC/C,cAAkC;AAAA,EAChC,QAAQ;AAAA,EACR,MAAM;AACR,CAAC;AAQI,IAAM,CAAC,sBAAsB,eAAe,IACjD,cAAmC;AAAA,EACjC,QAAQ;AAAA,EACR,MAAM;AACR,CAAC;AASI,IAAM,CAAC,0BAA0B,mBAAmB,IACzD,cAAuC;AAAA,EACrC,QAAQ;AAAA,EACR,MAAM;AACR,CAAC;","names":[]}
@@ -0,0 +1,21 @@
1
+ "use client"
2
+ import {
3
+ Menu
4
+ } from "./chunk-NNSVX2GX.mjs";
5
+ import {
6
+ ContextMenuProvider
7
+ } from "./chunk-ZUOFHOX6.mjs";
8
+
9
+ // src/context-menu.tsx
10
+ import { useComponentMultiStyle, omitThemeProps } from "@yamada-ui/core";
11
+ import { jsx } from "react/jsx-runtime";
12
+ var ContextMenu = (props) => {
13
+ const [styles, mergedProps] = useComponentMultiStyle("ContextMenu", props);
14
+ const { ...rest } = omitThemeProps(mergedProps);
15
+ return /* @__PURE__ */ jsx(ContextMenuProvider, { value: { styles }, children: /* @__PURE__ */ jsx(Menu, { trigger: "contextmenu", ...rest }) });
16
+ };
17
+
18
+ export {
19
+ ContextMenu
20
+ };
21
+ //# sourceMappingURL=chunk-ZV73JKM5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context-menu.tsx"],"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"],"mappings":";;;;;;;;;AACA,SAAS,wBAAwB,sBAAsB;AAqBjD;AANC,IAAM,cAAoC,CAAC,UAAU;AAC1D,QAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,eAAe,KAAK;AACzE,QAAM,EAAE,GAAG,KAAK,IAAI,eAAe,WAAW;AAE9C,SACE,oBAAC,uBAAoB,OAAO,EAAE,OAAO,GACnC,8BAAC,QAAK,SAAQ,eAAe,GAAG,MAAM,GACxC;AAEJ;","names":[]}
@@ -1,7 +1,8 @@
1
1
  import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps } from '@yamada-ui/core';
3
3
 
4
- type ContextMenuTriggerProps = HTMLUIProps<"div">;
4
+ interface ContextMenuTriggerProps extends HTMLUIProps {
5
+ }
5
6
  declare const ContextMenuTrigger: _yamada_ui_core.Component<"div", ContextMenuTriggerProps>;
6
7
 
7
8
  export { ContextMenuTrigger, type ContextMenuTriggerProps };
@@ -1,7 +1,8 @@
1
1
  import * as _yamada_ui_core from '@yamada-ui/core';
2
2
  import { HTMLUIProps } from '@yamada-ui/core';
3
3
 
4
- type ContextMenuTriggerProps = HTMLUIProps<"div">;
4
+ interface ContextMenuTriggerProps extends HTMLUIProps {
5
+ }
5
6
  declare const ContextMenuTrigger: _yamada_ui_core.Component<"div", ContextMenuTriggerProps>;
6
7
 
7
8
  export { ContextMenuTrigger, type ContextMenuTriggerProps };
@@ -24,25 +24,40 @@ __export(context_menu_trigger_exports, {
24
24
  ContextMenuTrigger: () => ContextMenuTrigger
25
25
  });
26
26
  module.exports = __toCommonJS(context_menu_trigger_exports);
27
- var import_core2 = require("@yamada-ui/core");
27
+ var import_core = require("@yamada-ui/core");
28
28
  var import_popover = require("@yamada-ui/popover");
29
29
  var import_utils2 = require("@yamada-ui/utils");
30
30
  var import_react = require("react");
31
31
 
32
- // src/context-menu.tsx
33
- var import_core = require("@yamada-ui/core");
32
+ // src/menu-context.ts
33
+ var import_use_descendant = require("@yamada-ui/use-descendant");
34
34
  var import_utils = require("@yamada-ui/utils");
35
- var import_jsx_runtime = require("react/jsx-runtime");
36
- var [ContextMenuProvider, useContextMenu] = (0, import_utils.createContext)(
37
- {
38
- strict: false,
39
- name: "ContextMenuContext"
40
- }
41
- );
35
+ var {
36
+ DescendantsContextProvider,
37
+ useDescendantsContext: useMenuDescendantsContext,
38
+ useDescendants,
39
+ useDescendant: useMenuDescendant
40
+ } = (0, import_use_descendant.createDescendant)();
41
+ var [MenuProvider, useMenu] = (0, import_utils.createContext)({
42
+ name: "MenuContext",
43
+ errorMessage: `useMenu returned is 'undefined'. Seems you forgot to wrap the components in "<Menu />"`
44
+ });
45
+ var [ContextMenuProvider, useContextMenu] = (0, import_utils.createContext)({
46
+ strict: false,
47
+ name: "ContextMenuContext"
48
+ });
49
+ var [UpstreamMenuProvider, useUpstreamMenu] = (0, import_utils.createContext)({
50
+ strict: false,
51
+ name: "UpstreamMenuContext"
52
+ });
53
+ var [UpstreamMenuItemProvider, useUpstreamMenuItem] = (0, import_utils.createContext)({
54
+ strict: false,
55
+ name: "UpstreamMenuItemContext"
56
+ });
42
57
 
43
58
  // src/context-menu-trigger.tsx
44
- var import_jsx_runtime2 = require("react/jsx-runtime");
45
- var ContextMenuTrigger = (0, import_core2.forwardRef)(
59
+ var import_jsx_runtime = require("react/jsx-runtime");
60
+ var ContextMenuTrigger = (0, import_core.forwardRef)(
46
61
  ({ children, className, ...rest }, ref) => {
47
62
  const { styles } = useContextMenu();
48
63
  const [position, setPosition] = (0, import_react.useState)({ top: 0, left: 0 });
@@ -50,16 +65,16 @@ var ContextMenuTrigger = (0, import_core2.forwardRef)(
50
65
  const onContextMenu = (ev) => {
51
66
  setPosition({ top: ev.clientY, left: ev.clientX });
52
67
  };
53
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
54
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_popover.PopoverAnchor, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
55
- import_core2.ui.div,
68
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
69
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popover.PopoverAnchor, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
+ import_core.ui.div,
56
71
  {
57
72
  className: "ui-context-menu__anchor",
58
73
  style: { position: "absolute", ...position }
59
74
  }
60
75
  ) }),
61
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_popover.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
62
- import_core2.ui.div,
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popover.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
77
+ import_core.ui.div,
63
78
  {
64
79
  ref,
65
80
  className: (0, import_utils2.cx)("ui-context-menu", className),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context-menu-trigger.tsx","../src/context-menu.tsx"],"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 \"./context-menu\"\n\ntype Position = { top: number; left: number }\n\nexport type ContextMenuTriggerProps = HTMLUIProps<\"div\">\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.clientY, left: ev.clientX })\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, ThemeProps } from \"@yamada-ui/core\"\nimport { useMultiComponentStyle, omitThemeProps } from \"@yamada-ui/core\"\nimport { createContext } from \"@yamada-ui/utils\"\nimport type { FC } from \"react\"\nimport type { MenuProps } from \"./menu\"\nimport { Menu } from \"./menu\"\n\ntype ContextMenuContext = {\n styles: Record<string, CSSUIObject>\n}\n\nconst [ContextMenuProvider, useContextMenu] = createContext<ContextMenuContext>(\n {\n strict: false,\n name: \"ContextMenuContext\",\n },\n)\n\nexport { useContextMenu }\n\ntype ContextMenuOptions = {}\n\nexport type ContextMenuProps = Omit<MenuProps, \"trigger\"> &\n ThemeProps<\"ContextMenu\"> &\n ContextMenuOptions\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] = useMultiComponentStyle(\"ContextMenu\", props)\n const { ...rest } = omitThemeProps(mergedProps)\n\n return (\n <ContextMenuProvider value={{ styles }}>\n <Menu trigger=\"contextmenu\" {...rest} />\n </ContextMenuProvider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,eAA+B;AAC/B,qBAA8C;AAC9C,IAAAC,gBAA+B;AAE/B,mBAAyB;;;ACJzB,kBAAuD;AACvD,mBAA8B;AAmCxB;AA1BN,IAAM,CAAC,qBAAqB,cAAc,QAAI;AAAA,EAC5C;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,EACR;AACF;;;ADQM,IAAAC,sBAAA;AAZC,IAAM,yBAAqB;AAAA,EAChC,CAAC,EAAE,UAAU,WAAW,GAAG,KAAK,GAAG,QAAQ;AACzC,UAAM,EAAE,OAAO,IAAI,eAAe;AAClC,UAAM,CAAC,UAAU,WAAW,QAAI,uBAAmB,EAAE,KAAK,GAAG,MAAM,EAAE,CAAC;AAEtE,UAAM,MAAmB,EAAE,GAAG,OAAO,UAAU;AAE/C,UAAM,gBAAgB,CAAC,OAAmB;AACxC,kBAAY,EAAE,KAAK,GAAG,SAAS,MAAM,GAAG,QAAQ,CAAC;AAAA,IACnD;AAEA,WACE,8EACE;AAAA,mDAAC,gCACC;AAAA,QAAC,gBAAG;AAAA,QAAH;AAAA,UACC,WAAU;AAAA,UACV,OAAO,EAAE,UAAU,YAAY,GAAG,SAAS;AAAA;AAAA,MAC7C,GACF;AAAA,MAEA,6CAAC,iCACC;AAAA,QAAC,gBAAG;AAAA,QAAH;AAAA,UACC;AAAA,UACA,eAAW,kBAAG,mBAAmB,SAAS;AAAA,UAC1C,OAAO;AAAA,UACN,GAAG;AAAA,UACJ,mBAAe,0BAAW,KAAK,eAAe,aAAa;AAAA,UAE1D;AAAA;AAAA,MACH,GACF;AAAA,OACF;AAAA,EAEJ;AACF;","names":["import_core","import_utils","import_jsx_runtime"]}
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.clientY, left: ev.clientX })\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;AAAA,EACA,uBAAuB;AAAA,EACvB;AAAA,EACA,eAAe;AACjB,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,QAAQ;AAAA,EACR,MAAM;AACR,CAAC;AAQI,IAAM,CAAC,sBAAsB,eAAe,QACjD,4BAAmC;AAAA,EACjC,QAAQ;AAAA,EACR,MAAM;AACR,CAAC;AASI,IAAM,CAAC,0BAA0B,mBAAmB,QACzD,4BAAuC;AAAA,EACrC,QAAQ;AAAA,EACR,MAAM;AACR,CAAC;;;AD7CG;AAZC,IAAM,yBAAqB;AAAA,EAChC,CAAC,EAAE,UAAU,WAAW,GAAG,KAAK,GAAG,QAAQ;AACzC,UAAM,EAAE,OAAO,IAAI,eAAe;AAClC,UAAM,CAAC,UAAU,WAAW,QAAI,uBAAmB,EAAE,KAAK,GAAG,MAAM,EAAE,CAAC;AAEtE,UAAM,MAAmB,EAAE,GAAG,OAAO,UAAU;AAE/C,UAAM,gBAAgB,CAAC,OAAmB;AACxC,kBAAY,EAAE,KAAK,GAAG,SAAS,MAAM,GAAG,QAAQ,CAAC;AAAA,IACnD;AAEA,WACE,4EACE;AAAA,kDAAC,gCACC;AAAA,QAAC,eAAG;AAAA,QAAH;AAAA,UACC,WAAU;AAAA,UACV,OAAO,EAAE,UAAU,YAAY,GAAG,SAAS;AAAA;AAAA,MAC7C,GACF;AAAA,MAEA,4CAAC,iCACC;AAAA,QAAC,eAAG;AAAA,QAAH;AAAA,UACC;AAAA,UACA,eAAW,kBAAG,mBAAmB,SAAS;AAAA,UAC1C,OAAO;AAAA,UACN,GAAG;AAAA,UACJ,mBAAe,0BAAW,KAAK,eAAe,aAAa;AAAA,UAE1D;AAAA;AAAA,MACH,GACF;AAAA,OACF;AAAA,EAEJ;AACF;","names":["import_utils"]}
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
  import {
3
3
  ContextMenuTrigger
4
- } from "./chunk-5ZWRZF6M.mjs";
5
- import "./chunk-6IPLI42Z.mjs";
4
+ } from "./chunk-DPC5A6DV.mjs";
5
+ import "./chunk-ZUOFHOX6.mjs";
6
6
  export {
7
7
  ContextMenuTrigger
8
8
  };
@@ -1,16 +1,10 @@
1
- import { ThemeProps, CSSUIObject } from '@yamada-ui/core';
1
+ import { ThemeProps } from '@yamada-ui/core';
2
2
  import { FC } from 'react';
3
3
  import { MenuProps } from './menu.mjs';
4
- import '@yamada-ui/use-descendant';
5
4
  import '@yamada-ui/popover';
6
5
 
7
- type ContextMenuContext = {
8
- styles: Record<string, CSSUIObject>;
9
- };
10
- declare const useContextMenu: () => ContextMenuContext;
11
-
12
- type ContextMenuOptions = {};
13
- type ContextMenuProps = Omit<MenuProps, "trigger"> & ThemeProps<"ContextMenu"> & ContextMenuOptions;
6
+ interface ContextMenuProps extends Omit<MenuProps, "trigger">, ThemeProps<"ContextMenu"> {
7
+ }
14
8
  /**
15
9
  * `ContextMenu` is triggered by a right click and displays a menu at the pointer's position.
16
10
  *
@@ -18,4 +12,4 @@ type ContextMenuProps = Omit<MenuProps, "trigger"> & ThemeProps<"ContextMenu"> &
18
12
  */
19
13
  declare const ContextMenu: FC<ContextMenuProps>;
20
14
 
21
- export { ContextMenu, type ContextMenuProps, useContextMenu };
15
+ export { ContextMenu, type ContextMenuProps };
@@ -1,16 +1,10 @@
1
- import { ThemeProps, CSSUIObject } from '@yamada-ui/core';
1
+ import { ThemeProps } from '@yamada-ui/core';
2
2
  import { FC } from 'react';
3
3
  import { MenuProps } from './menu.js';
4
- import '@yamada-ui/use-descendant';
5
4
  import '@yamada-ui/popover';
6
5
 
7
- type ContextMenuContext = {
8
- styles: Record<string, CSSUIObject>;
9
- };
10
- declare const useContextMenu: () => ContextMenuContext;
11
-
12
- type ContextMenuOptions = {};
13
- type ContextMenuProps = Omit<MenuProps, "trigger"> & ThemeProps<"ContextMenu"> & ContextMenuOptions;
6
+ interface ContextMenuProps extends Omit<MenuProps, "trigger">, ThemeProps<"ContextMenu"> {
7
+ }
14
8
  /**
15
9
  * `ContextMenu` is triggered by a right click and displays a menu at the pointer's position.
16
10
  *
@@ -18,4 +12,4 @@ type ContextMenuProps = Omit<MenuProps, "trigger"> & ThemeProps<"ContextMenu"> &
18
12
  */
19
13
  declare const ContextMenu: FC<ContextMenuProps>;
20
14
 
21
- export { ContextMenu, type ContextMenuProps, useContextMenu };
15
+ export { ContextMenu, type ContextMenuProps };