@basic-ui/core 0.0.47 → 0.0.48

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.
@@ -1,13 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["as", "id", "onContextMenu", "disabled"];
3
+ var _excluded = ["as", "innerAs", "id", "onContextMenu", "disabled"];
4
4
  import { forwardRef, useId } from 'react';
5
5
  import { useMenuContext } from './context';
6
6
  import { wrapEvent } from '../utils/wrap-event';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
- export var ContextMenuTrigger = /*#__PURE__*/forwardRef(function MenuButton(props, forwardedRef) {
8
+ export var ContextMenuTrigger = /*#__PURE__*/forwardRef(function ContextMenuTrigger(props, forwardedRef) {
9
9
  var _props$as = props.as,
10
10
  Comp = _props$as === void 0 ? 'div' : _props$as,
11
+ innerAs = props.innerAs,
11
12
  preferredId = props.id,
12
13
  onContextMenu = props.onContextMenu,
13
14
  disabled = props.disabled,
@@ -18,7 +19,7 @@ export var ContextMenuTrigger = /*#__PURE__*/forwardRef(function MenuButton(prop
18
19
  open = _useMenuContext.open,
19
20
  buttonRef = _useMenuContext.buttonRef,
20
21
  onChange = _useMenuContext.onChange,
21
- offset = _useMenuContext.offset,
22
+ setOffsetFn = _useMenuContext.setOffsetFn,
22
23
  isContextMenu = _useMenuContext.isContextMenu;
23
24
 
24
25
  var idGenerated = useId();
@@ -30,15 +31,23 @@ export var ContextMenuTrigger = /*#__PURE__*/forwardRef(function MenuButton(prop
30
31
  }
31
32
 
32
33
  var rect = e.currentTarget.getBoundingClientRect();
33
- offset.current = [e.nativeEvent.x - rect.x, e.nativeEvent.y - rect.y];
34
34
  isContextMenu.current = true;
35
35
  buttonRef.current = e.currentTarget;
36
- onChange && onChange(e, !open);
36
+ onChange(e, true);
37
+ var mouseX = e.nativeEvent.x;
38
+ var mouseY = e.nativeEvent.y;
39
+ setOffsetFn(function () {
40
+ return function (_ref) {
41
+ var reference = _ref.reference;
42
+ return [mouseX - rect.x, mouseY - rect.y - reference.height];
43
+ };
44
+ });
37
45
  e.preventDefault();
38
46
  };
39
47
 
40
48
  return /*#__PURE__*/_jsx(Comp, _extends({
41
49
  ref: forwardedRef,
50
+ as: innerAs,
42
51
  id: id,
43
52
  "aria-haspopup": true,
44
53
  "aria-controls": menuListIdRef.current,
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenuTrigger.js","names":["forwardRef","useId","useMenuContext","wrapEvent","ContextMenuTrigger","MenuButton","props","forwardedRef","as","Comp","preferredId","id","onContextMenu","disabled","otherProps","menuListIdRef","open","buttonRef","onChange","offset","isContextMenu","idGenerated","handleContextMenu","e","rect","currentTarget","getBoundingClientRect","current","nativeEvent","x","y","preventDefault","undefined"],"sources":["../../../src/Menu/ContextMenuTrigger.tsx"],"sourcesContent":["import type {\n ElementType,\n HTMLAttributes,\n MouseEvent as ReactMouseEvent,\n} from 'react';\nimport { forwardRef, useId } from 'react';\n\nimport { useMenuContext } from './context';\nimport { wrapEvent } from '../utils/wrap-event';\n\nexport type ContextMenuTriggerProps = HTMLAttributes<HTMLElement> & {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n disabled?: boolean;\n};\n\nexport const ContextMenuTrigger = forwardRef<\n HTMLElement,\n ContextMenuTriggerProps\n>(function MenuButton(props, forwardedRef) {\n const {\n as: Comp = 'div',\n id: preferredId,\n onContextMenu,\n disabled,\n ...otherProps\n } = props;\n const { menuListIdRef, open, buttonRef, onChange, offset, isContextMenu } =\n useMenuContext();\n\n const idGenerated = useId();\n const id = preferredId || idGenerated;\n\n const handleContextMenu = (e: ReactMouseEvent<HTMLElement>) => {\n if (disabled) {\n return;\n }\n const rect = e.currentTarget.getBoundingClientRect();\n offset.current = [\n (e.nativeEvent as MouseEvent).x - rect.x,\n (e.nativeEvent as MouseEvent).y - rect.y,\n ];\n isContextMenu.current = true;\n\n buttonRef.current = e.currentTarget;\n onChange && onChange(e, !open);\n e.preventDefault();\n };\n\n return (\n <Comp\n ref={forwardedRef}\n id={id}\n aria-haspopup={true}\n aria-controls={menuListIdRef.current}\n aria-expanded={open ? true : undefined}\n data-menu-trigger=\"\"\n onContextMenu={wrapEvent(onContextMenu, handleContextMenu)}\n disabled={disabled}\n {...otherProps}\n />\n );\n});\n"],"mappings":";;;AAKA,SAASA,UAAT,EAAqBC,KAArB,QAAkC,OAAlC;AAEA,SAASC,cAAT,QAA+B,WAA/B;AACA,SAASC,SAAT,QAA0B,qBAA1B;;AAQA,OAAO,IAAMC,kBAAkB,gBAAGJ,UAAU,CAG1C,SAASK,UAAT,CAAoBC,KAApB,EAA2BC,YAA3B,EAAyC;EACzC,gBAMID,KANJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,KADb;EAAA,IAEMC,WAFN,GAMIJ,KANJ,CAEEK,EAFF;EAAA,IAGEC,aAHF,GAMIN,KANJ,CAGEM,aAHF;EAAA,IAIEC,QAJF,GAMIP,KANJ,CAIEO,QAJF;EAAA,IAKKC,UALL,4BAMIR,KANJ;;EAOA,sBACEJ,cAAc,EADhB;EAAA,IAAQa,aAAR,mBAAQA,aAAR;EAAA,IAAuBC,IAAvB,mBAAuBA,IAAvB;EAAA,IAA6BC,SAA7B,mBAA6BA,SAA7B;EAAA,IAAwCC,QAAxC,mBAAwCA,QAAxC;EAAA,IAAkDC,MAAlD,mBAAkDA,MAAlD;EAAA,IAA0DC,aAA1D,mBAA0DA,aAA1D;;EAGA,IAAMC,WAAW,GAAGpB,KAAK,EAAzB;EACA,IAAMU,EAAE,GAAGD,WAAW,IAAIW,WAA1B;;EAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,CAAD,EAAqC;IAC7D,IAAIV,QAAJ,EAAc;MACZ;IACD;;IACD,IAAMW,IAAI,GAAGD,CAAC,CAACE,aAAF,CAAgBC,qBAAhB,EAAb;IACAP,MAAM,CAACQ,OAAP,GAAiB,CACdJ,CAAC,CAACK,WAAH,CAA8BC,CAA9B,GAAkCL,IAAI,CAACK,CADxB,EAEdN,CAAC,CAACK,WAAH,CAA8BE,CAA9B,GAAkCN,IAAI,CAACM,CAFxB,CAAjB;IAIAV,aAAa,CAACO,OAAd,GAAwB,IAAxB;IAEAV,SAAS,CAACU,OAAV,GAAoBJ,CAAC,CAACE,aAAtB;IACAP,QAAQ,IAAIA,QAAQ,CAACK,CAAD,EAAI,CAACP,IAAL,CAApB;IACAO,CAAC,CAACQ,cAAF;EACD,CAdD;;EAgBA,oBACE,KAAC,IAAD;IACE,GAAG,EAAExB,YADP;IAEE,EAAE,EAAEI,EAFN;IAGE,iBAAe,IAHjB;IAIE,iBAAeI,aAAa,CAACY,OAJ/B;IAKE,iBAAeX,IAAI,GAAG,IAAH,GAAUgB,SAL/B;IAME,qBAAkB,EANpB;IAOE,aAAa,EAAE7B,SAAS,CAACS,aAAD,EAAgBU,iBAAhB,CAP1B;IAQE,QAAQ,EAAET;EARZ,GASMC,UATN,EADF;AAaD,CA9C2C,CAArC"}
1
+ {"version":3,"file":"ContextMenuTrigger.js","names":["forwardRef","useId","useMenuContext","wrapEvent","ContextMenuTrigger","props","forwardedRef","as","Comp","innerAs","preferredId","id","onContextMenu","disabled","otherProps","menuListIdRef","open","buttonRef","onChange","setOffsetFn","isContextMenu","idGenerated","handleContextMenu","e","rect","currentTarget","getBoundingClientRect","current","mouseX","nativeEvent","x","mouseY","y","reference","height","preventDefault","undefined"],"sources":["../../../src/Menu/ContextMenuTrigger.tsx"],"sourcesContent":["import type {\n ElementType,\n HTMLAttributes,\n MouseEvent as ReactMouseEvent,\n} from 'react';\nimport { forwardRef, useId } from 'react';\n\nimport { useMenuContext } from './context';\nimport { wrapEvent } from '../utils/wrap-event';\nimport type { OffsetsFunction } from '../Popper';\n\nexport type ContextMenuTriggerProps = HTMLAttributes<HTMLElement> & {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n disabled?: boolean;\n};\n\nexport const ContextMenuTrigger = forwardRef<\n HTMLElement,\n ContextMenuTriggerProps\n>(function ContextMenuTrigger(props, forwardedRef) {\n const {\n as: Comp = 'div',\n innerAs,\n id: preferredId,\n onContextMenu,\n disabled,\n ...otherProps\n } = props;\n const {\n menuListIdRef,\n open,\n buttonRef,\n onChange,\n setOffsetFn,\n isContextMenu,\n } = useMenuContext();\n\n const idGenerated = useId();\n const id = preferredId || idGenerated;\n\n const handleContextMenu = (e: ReactMouseEvent<HTMLElement>) => {\n if (disabled) {\n return;\n }\n const rect = e.currentTarget.getBoundingClientRect();\n isContextMenu.current = true;\n\n buttonRef.current = e.currentTarget;\n onChange(e, true);\n\n const mouseX = e.nativeEvent.x;\n const mouseY = e.nativeEvent.y;\n setOffsetFn(\n (): OffsetsFunction =>\n ({ reference }) =>\n [mouseX - rect.x, mouseY - rect.y - reference.height]\n );\n e.preventDefault();\n };\n\n return (\n <Comp\n ref={forwardedRef}\n as={innerAs}\n id={id}\n aria-haspopup={true}\n aria-controls={menuListIdRef.current}\n aria-expanded={open ? true : undefined}\n data-menu-trigger=\"\"\n onContextMenu={wrapEvent(onContextMenu, handleContextMenu)}\n disabled={disabled}\n {...otherProps}\n />\n );\n});\n"],"mappings":";;;AAKA,SAASA,UAAT,EAAqBC,KAArB,QAAkC,OAAlC;AAEA,SAASC,cAAT,QAA+B,WAA/B;AACA,SAASC,SAAT,QAA0B,qBAA1B;;AASA,OAAO,IAAMC,kBAAkB,gBAAGJ,UAAU,CAG1C,SAASI,kBAAT,CAA4BC,KAA5B,EAAmCC,YAAnC,EAAiD;EACjD,gBAOID,KAPJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,KADb;EAAA,IAEEC,OAFF,GAOIJ,KAPJ,CAEEI,OAFF;EAAA,IAGMC,WAHN,GAOIL,KAPJ,CAGEM,EAHF;EAAA,IAIEC,aAJF,GAOIP,KAPJ,CAIEO,aAJF;EAAA,IAKEC,QALF,GAOIR,KAPJ,CAKEQ,QALF;EAAA,IA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E,aAAa,EAAEjC,SAAS,CAACS,aAAD,EAAgBU,iBAAhB,CAR1B;IASE,QAAQ,EAAET;EATZ,GAUMC,UAVN,EADF;AAcD,CA1D2C,CAArC"}
@@ -1,14 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["as", "open", "defaultOpen", "onChange"];
5
- import { useCallback, forwardRef, useRef, Fragment, useId } from 'react';
4
+ var _excluded = ["as", "innerAs", "open", "defaultOpen", "onChange"];
5
+ import { useState, forwardRef, useRef, Fragment, useId } from 'react';
6
6
  import { MenuProvider } from './context';
7
7
  import { useControlledState } from '../hooks';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  export var Menu = /*#__PURE__*/forwardRef(function Menu(props, forwardedRef) {
10
10
  var _props$as = props.as,
11
11
  Comp = _props$as === void 0 ? Fragment : _props$as,
12
+ innerAs = props.innerAs,
12
13
  openProp = props.open,
13
14
  _props$defaultOpen = props.defaultOpen,
14
15
  defaultOpen = _props$defaultOpen === void 0 ? false : _props$defaultOpen,
@@ -28,26 +29,33 @@ export var Menu = /*#__PURE__*/forwardRef(function Menu(props, forwardedRef) {
28
29
  open = _useControlledState2[0],
29
30
  onChange = _useControlledState2[1];
30
31
 
32
+ var _useState = useState(undefined),
33
+ _useState2 = _slicedToArray(_useState, 2),
34
+ offsetFn = _useState2[0],
35
+ setOffsetFn = _useState2[1];
36
+
31
37
  menuListIdRef.current = useId();
32
- var offset = useRef([0, 0]);
33
- var offsetFn = useCallback(function (_ref) {
34
- var reference = _ref.reference;
35
- return [offset.current[0], offset.current[1] - reference.height];
36
- }, []);
37
38
  var isContextMenu = useRef(false);
39
+
40
+ if (!open && offsetFn) {
41
+ setOffsetFn(undefined);
42
+ }
43
+
38
44
  var value = {
39
45
  menuListIdRef: menuListIdRef,
40
46
  openWithArrowKeyRef: openWithArrowKeyRef,
41
47
  open: open,
42
48
  onChange: onChange,
43
49
  buttonRef: buttonRef,
44
- offset: offset,
45
50
  offsetFn: offsetFn,
51
+ setOffsetFn: setOffsetFn,
46
52
  isContextMenu: isContextMenu
47
53
  };
48
54
  return /*#__PURE__*/_jsx(MenuProvider, {
49
55
  value: value,
50
- children: /*#__PURE__*/_jsx(Comp, _extends({
56
+ children: /*#__PURE__*/_jsx(Comp, _extends(_extends({}, Comp !== Fragment ? {
57
+ as: innerAs
58
+ } : {}), {}, {
51
59
  ref: forwardedRef
52
60
  }, otherProps))
53
61
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.js","names":["useCallback","forwardRef","useRef","Fragment","useId","MenuProvider","useControlledState","Menu","props","forwardedRef","as","Comp","openProp","open","defaultOpen","onChangeProp","onChange","otherProps","menuListIdRef","openWithArrowKeyRef","buttonRef","setState","e","isOpen","current","offset","offsetFn","reference","height","isContextMenu","value"],"sources":["../../../src/Menu/Menu.tsx"],"sourcesContent":["import type {\n KeyboardEvent,\n MouseEvent,\n PointerEvent,\n ReactNode,\n ElementType,\n} from 'react';\nimport { useCallback, forwardRef, useRef, Fragment, useId } from 'react';\n\nimport type { MenuContextProps } from './context';\nimport { MenuProvider } from './context';\nimport { useControlledState } from '../hooks';\nimport type { OffsetsFunction } from '../Popper';\n\nexport interface MenuProps {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n onChange?: (\n e:\n | KeyboardEvent<HTMLElement>\n | MouseEvent<HTMLElement>\n | PointerEvent<HTMLElement>,\n isOpen: boolean\n ) => void;\n open?: boolean;\n defaultOpen?: boolean;\n}\n\nexport const Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu(\n props,\n forwardedRef\n) {\n const {\n as: Comp = Fragment,\n open: openProp,\n defaultOpen = false,\n onChange: onChangeProp,\n ...otherProps\n } = props;\n const menuListIdRef = useRef<string>();\n const openWithArrowKeyRef = useRef<'ArrowUp' | 'ArrowDown' | null>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [open, onChange] = useControlledState(\n openProp,\n onChangeProp,\n defaultOpen,\n (setState) => (e, isOpen) => {\n setState(isOpen);\n }\n );\n\n menuListIdRef.current = useId();\n const offset = useRef<[number, number]>([0, 0]);\n const offsetFn = useCallback<OffsetsFunction>(\n ({ reference }) => [\n offset.current[0],\n offset.current[1] - reference.height,\n ],\n []\n );\n const isContextMenu = useRef(false);\n\n const value: MenuContextProps = {\n menuListIdRef,\n openWithArrowKeyRef,\n open,\n onChange,\n buttonRef,\n offset,\n offsetFn,\n isContextMenu,\n };\n\n return (\n <MenuProvider value={value}>\n <Comp ref={forwardedRef} {...otherProps} />\n </MenuProvider>\n );\n});\n"],"mappings":";;;;AAOA,SAASA,WAAT,EAAsBC,UAAtB,EAAkCC,MAAlC,EAA0CC,QAA1C,EAAoDC,KAApD,QAAiE,OAAjE;AAGA,SAASC,YAAT,QAA6B,WAA7B;AACA,SAASC,kBAAT,QAAmC,UAAnC;;AAkBA,OAAO,IAAMC,IAAI,gBAAGN,UAAU,CAA4B,SAASM,IAAT,CACxDC,KADwD,EAExDC,YAFwD,EAGxD;EACA,gBAMID,KANJ,CACEE,EADF;EAAA,IACMC,IADN,0BACaR,QADb;EAAA,IAEQS,QAFR,GAMIJ,KANJ,CAEEK,IAFF;EAAA,yBAMIL,KANJ,CAGEM,WAHF;EAAA,IAGEA,WAHF,mCAGgB,KAHhB;EAAA,IAIYC,YAJZ,GAMIP,KANJ,CAIEQ,QAJF;EAAA,IAKKC,UALL,4BAMIT,KANJ;;EAOA,IAAMU,aAAa,GAAGhB,MAAM,EAA5B;EACA,IAAMiB,mBAAmB,GAAGjB,MAAM,CAAiC,IAAjC,CAAlC;EACA,IAAMkB,SAAS,GAAGlB,MAAM,CAAoB,IAApB,CAAxB;;EACA,0BAAyBI,kBAAkB,CACzCM,QADyC,EAEzCG,YAFyC,EAGzCD,WAHyC,EAIzC,UAACO,QAAD;IAAA,OAAc,UAACC,CAAD,EAAIC,MAAJ,EAAe;MAC3BF,QAAQ,CAACE,MAAD,CAAR;IACD,CAFD;EAAA,CAJyC,CAA3C;EAAA;EAAA,IAAOV,IAAP;EAAA,IAAaG,QAAb;;EASAE,aAAa,CAACM,OAAd,GAAwBpB,KAAK,EAA7B;EACA,IAAMqB,MAAM,GAAGvB,MAAM,CAAmB,CAAC,CAAD,EAAI,CAAJ,CAAnB,CAArB;EACA,IAAMwB,QAAQ,GAAG1B,WAAW,CAC1B;IAAA,IAAG2B,SAAH,QAAGA,SAAH;IAAA,OAAmB,CACjBF,MAAM,CAACD,OAAP,CAAe,CAAf,CADiB,EAEjBC,MAAM,CAACD,OAAP,CAAe,CAAf,IAAoBG,SAAS,CAACC,MAFb,CAAnB;EAAA,CAD0B,EAK1B,EAL0B,CAA5B;EAOA,IAAMC,aAAa,GAAG3B,MAAM,CAAC,KAAD,CAA5B;EAEA,IAAM4B,KAAuB,GAAG;IAC9BZ,aAAa,EAAbA,aAD8B;IAE9BC,mBAAmB,EAAnBA,mBAF8B;IAG9BN,IAAI,EAAJA,IAH8B;IAI9BG,QAAQ,EAARA,QAJ8B;IAK9BI,SAAS,EAATA,SAL8B;IAM9BK,MAAM,EAANA,MAN8B;IAO9BC,QAAQ,EAARA,QAP8B;IAQ9BG,aAAa,EAAbA;EAR8B,CAAhC;EAWA,oBACE,KAAC,YAAD;IAAc,KAAK,EAAEC,KAArB;IAAA,uBACE,KAAC,IAAD;MAAM,GAAG,EAAErB;IAAX,GAA6BQ,UAA7B;EADF,EADF;AAKD,CAlD6B,CAAvB"}
1
+ {"version":3,"file":"Menu.js","names":["useState","forwardRef","useRef","Fragment","useId","MenuProvider","useControlledState","Menu","props","forwardedRef","as","Comp","innerAs","openProp","open","defaultOpen","onChangeProp","onChange","otherProps","menuListIdRef","openWithArrowKeyRef","buttonRef","setState","e","isOpen","undefined","offsetFn","setOffsetFn","current","isContextMenu","value"],"sources":["../../../src/Menu/Menu.tsx"],"sourcesContent":["import type {\n KeyboardEvent,\n MouseEvent,\n PointerEvent,\n ReactNode,\n ElementType,\n} from 'react';\nimport { useState, forwardRef, useRef, Fragment, useId } from 'react';\n\nimport type { MenuContextProps } from './context';\nimport { MenuProvider } from './context';\nimport { useControlledState } from '../hooks';\nimport type { OffsetsFunction } from '../Popper';\n\nexport interface MenuProps {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n onChange?: (\n e:\n | KeyboardEvent<HTMLElement>\n | MouseEvent<HTMLElement>\n | PointerEvent<HTMLElement>,\n isOpen: boolean\n ) => void;\n open?: boolean;\n defaultOpen?: boolean;\n}\n\nexport const Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu(\n props,\n forwardedRef\n) {\n const {\n as: Comp = Fragment,\n innerAs,\n open: openProp,\n defaultOpen = false,\n onChange: onChangeProp,\n ...otherProps\n } = props;\n const menuListIdRef = useRef<string>();\n const openWithArrowKeyRef = useRef<'ArrowUp' | 'ArrowDown' | null>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [open, onChange] = useControlledState(\n openProp,\n onChangeProp,\n defaultOpen,\n (setState) => (e, isOpen) => {\n setState(isOpen);\n }\n );\n const [offsetFn, setOffsetFn] = useState<OffsetsFunction | undefined>(\n undefined\n );\n menuListIdRef.current = useId();\n const isContextMenu = useRef(false);\n\n if (!open && offsetFn) {\n setOffsetFn(undefined);\n }\n\n const value: MenuContextProps = {\n menuListIdRef,\n openWithArrowKeyRef,\n open,\n onChange,\n buttonRef,\n offsetFn,\n setOffsetFn,\n isContextMenu,\n };\n\n return (\n <MenuProvider value={value}>\n <Comp\n {...(Comp !== Fragment ? { as: innerAs } : {})}\n ref={forwardedRef}\n {...otherProps}\n />\n </MenuProvider>\n );\n});\n"],"mappings":";;;;AAOA,SAASA,QAAT,EAAmBC,UAAnB,EAA+BC,MAA/B,EAAuCC,QAAvC,EAAiDC,KAAjD,QAA8D,OAA9D;AAGA,SAASC,YAAT,QAA6B,WAA7B;AACA,SAASC,kBAAT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;IAK9BI,SAAS,EAATA,SAL8B;IAM9BK,QAAQ,EAARA,QAN8B;IAO9BC,WAAW,EAAXA,WAP8B;IAQ9BE,aAAa,EAAbA;EAR8B,CAAhC;EAWA,oBACE,KAAC,YAAD;IAAc,KAAK,EAAEC,KAArB;IAAA,uBACE,KAAC,IAAD,wBACOnB,IAAI,KAAKR,QAAT,GAAoB;MAAEO,EAAE,EAAEE;IAAN,CAApB,GAAsC,EAD7C;MAEE,GAAG,EAAEH;IAFP,GAGMS,UAHN;EADF,EADF;AASD,CArD6B,CAAvB"}
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["as", "id", "onClick", "onKeyDown", "disabled"];
3
+ var _excluded = ["as", "innerAs", "id", "onClick", "onKeyDown", "disabled"];
4
4
  import { forwardRef, useId } from 'react';
5
5
  import { useMenuContext } from './context';
6
6
  import { wrapEvent } from '../utils/wrap-event';
@@ -8,6 +8,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
8
8
  export var MenuButton = /*#__PURE__*/forwardRef(function MenuButton(props, forwardedRef) {
9
9
  var _props$as = props.as,
10
10
  Comp = _props$as === void 0 ? 'button' : _props$as,
11
+ innerAs = props.innerAs,
11
12
  preferredId = props.id,
12
13
  onClick = props.onClick,
13
14
  onKeyDown = props.onKeyDown,
@@ -47,7 +48,7 @@ export var MenuButton = /*#__PURE__*/forwardRef(function MenuButton(props, forwa
47
48
  openWithArrowKeyRef.current = e.key;
48
49
  }
49
50
 
50
- onChange && onChange(e, true);
51
+ onChange(e, true);
51
52
  e.preventDefault();
52
53
  }
53
54
  };
@@ -58,11 +59,12 @@ export var MenuButton = /*#__PURE__*/forwardRef(function MenuButton(props, forwa
58
59
  }
59
60
 
60
61
  buttonRef.current = e.currentTarget;
61
- onChange && onChange(e, !open);
62
+ onChange(e, !open);
62
63
  };
63
64
 
64
65
  return /*#__PURE__*/_jsx(Comp, _extends({
65
66
  ref: forwardedRef,
67
+ as: innerAs,
66
68
  id: buttonId,
67
69
  role: "button",
68
70
  type: "button",
@@ -1 +1 @@
1
- {"version":3,"file":"MenuButton.js","names":["forwardRef","useId","useMenuContext","wrapEvent","MenuButton","props","forwardedRef","as","Comp","preferredId","id","onClick","onKeyDown","disabled","otherProps","menuListIdRef","openWithArrowKeyRef","open","buttonRef","onChange","buttonIdGenerated","buttonId","handleKeyDown","e","current","currentTarget","isArrowKey","includes","key","isEnterKey","openedWithArrow","preventDefault","handleClick","undefined"],"sources":["../../../src/Menu/MenuButton.tsx"],"sourcesContent":["import type {\n ButtonHTMLAttributes,\n ElementType,\n KeyboardEvent,\n MouseEvent,\n} from 'react';\nimport { forwardRef, useId } from 'react';\n\nimport { useMenuContext } from './context';\nimport { wrapEvent } from '../utils/wrap-event';\n\nexport type MenuButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onClick?: (\n e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>\n ) => void;\n};\n\nexport const MenuButton = forwardRef<HTMLButtonElement, MenuButtonProps>(\n function MenuButton(props, forwardedRef) {\n const {\n as: Comp = 'button',\n id: preferredId,\n onClick,\n onKeyDown,\n disabled,\n ...otherProps\n } = props;\n const { menuListIdRef, openWithArrowKeyRef, open, buttonRef, onChange } =\n useMenuContext();\n\n const buttonIdGenerated = useId();\n const buttonId = preferredId || buttonIdGenerated;\n\n const handleKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n buttonRef.current = e.currentTarget;\n\n const isArrowKey = () => ['ArrowUp', 'ArrowDown'].includes(e.key);\n const isEnterKey = () => [' ', 'Enter'].includes(e.key);\n\n const openedWithArrow = isArrowKey();\n if (openedWithArrow || isEnterKey()) {\n if (openedWithArrow) {\n // Used to make it open at the end or begining of the list\n openWithArrowKeyRef.current = e.key;\n }\n onChange && onChange(e, true);\n e.preventDefault();\n }\n };\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n buttonRef.current = e.currentTarget;\n\n onChange && onChange(e, !open);\n };\n\n return (\n <Comp\n ref={forwardedRef}\n id={buttonId}\n role=\"button\"\n type=\"button\"\n aria-haspopup={true}\n aria-controls={menuListIdRef.current}\n aria-expanded={open ? true : undefined}\n data-menu-button=\"\"\n onClick={wrapEvent(onClick, handleClick)}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n disabled={disabled}\n {...otherProps}\n />\n );\n }\n);\n"],"mappings":";;;AAMA,SAASA,UAAT,EAAqBC,KAArB,QAAkC,OAAlC;AAEA,SAASC,cAAT,QAA+B,WAA/B;AACA,SAASC,SAAT,QAA0B,qBAA1B;;AAUA,OAAO,IAAMC,UAAU,gBAAGJ,UAAU,CAClC,SAASI,UAAT,CAAoBC,KAApB,EAA2BC,YAA3B,EAAyC;EACvC,gBAOID,KAPJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,QADb;EAAA,IAEMC,WAFN,GAOIJ,KAPJ,CAEEK,EAFF;EAAA,IAGEC,OAHF,GAOIN,KAPJ,CAGEM,OAHF;EAAA,IAIEC,SAJF,GAOIP,KAPJ,CAIEO,SAJF;EAAA,IAKEC,QALF,GAOIR,KAPJ,CAKEQ,QALF;EAAA,IAMKC,UANL,4BAOIT,KAPJ;;EAQA,sBACEH,cAAc,EADhB;EAAA,IAAQa,aAAR,mBAAQA,aAAR;EAAA,IAAuBC,mBAAvB,mBAAuBA,mBAAvB;EAAA,IAA4CC,IAA5C,mBAA4CA,IAA5C;EAAA,IAAkDC,SAAlD,mBAAkDA,SAAlD;EAAA,IAA6DC,QAA7D,mBAA6DA,QAA7D;;EAGA,IAAMC,iBAAiB,GAAGnB,KAAK,EAA/B;EACA,IAAMoB,QAAQ,GAAGZ,WAAW,IAAIW,iBAAhC;;EAEA,IAAME,aAAa,GAAG,SAAhBA,aAAgB,CAACC,CAAD,EAAy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VtB;IAWE,QAAQ,EAAET;EAXZ,GAYMC,UAZN,EADF;AAgBD,CA7DiC,CAA7B"}
1
+ {"version":3,"file":"MenuButton.js","names":["forwardRef","useId","useMenuContext","wrapEvent","MenuButton","props","forwardedRef","as","Comp","innerAs","preferredId","id","onClick","onKeyDown","disabled","otherProps","menuListIdRef","openWithArrowKeyRef","open","buttonRef","onChange","buttonIdGenerated","buttonId","handleKeyDown","e","current","currentTarget","isArrowKey","includes","key","isEnterKey","openedWithArrow","preventDefault","handleClick","undefined"],"sources":["../../../src/Menu/MenuButton.tsx"],"sourcesContent":["import type {\n ButtonHTMLAttributes,\n ElementType,\n KeyboardEvent,\n MouseEvent,\n} from 'react';\nimport { forwardRef, useId } from 'react';\n\nimport { useMenuContext } from './context';\nimport { wrapEvent } from '../utils/wrap-event';\n\nexport type MenuButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onClick?: (\n e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>\n ) => void;\n};\n\nexport const MenuButton = forwardRef<HTMLButtonElement, MenuButtonProps>(\n function MenuButton(props, forwardedRef) {\n const {\n as: Comp = 'button',\n innerAs,\n id: preferredId,\n onClick,\n onKeyDown,\n disabled,\n ...otherProps\n } = props;\n const { menuListIdRef, openWithArrowKeyRef, open, buttonRef, onChange } =\n useMenuContext();\n\n const buttonIdGenerated = useId();\n const buttonId = preferredId || buttonIdGenerated;\n\n const handleKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n buttonRef.current = e.currentTarget;\n\n const isArrowKey = () => ['ArrowUp', 'ArrowDown'].includes(e.key);\n const isEnterKey = () => [' ', 'Enter'].includes(e.key);\n\n const openedWithArrow = isArrowKey();\n if (openedWithArrow || isEnterKey()) {\n if (openedWithArrow) {\n // Used to make it open at the end or begining of the list\n openWithArrowKeyRef.current = e.key;\n }\n onChange(e, true);\n e.preventDefault();\n }\n };\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n return;\n }\n buttonRef.current = e.currentTarget;\n onChange(e, !open);\n };\n\n return (\n <Comp\n ref={forwardedRef}\n as={innerAs}\n id={buttonId}\n role=\"button\"\n type=\"button\"\n aria-haspopup={true}\n aria-controls={menuListIdRef.current}\n aria-expanded={open ? true : undefined}\n data-menu-button=\"\"\n onClick={wrapEvent(onClick, handleClick)}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n disabled={disabled}\n {...otherProps}\n />\n );\n }\n);\n"],"mappings":";;;AAMA,SAASA,UAAT,EAAqBC,KAArB,QAAkC,OAAlC;AAEA,SAASC,cAAT,QAA+B,WAA/B;AACA,SAASC,SAAT,QAA0B,qBAA1B;;AAUA,OAAO,IAAMC,UAAU,gBAAGJ,UAAU,CAClC,SAASI,UAAT,CAAoBC,KAApB,EAA2BC,YAA3B,EAAyC;EACvC,gBAQID,KARJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,QADb;EAAA,IAEEC,OAFF,GAQIJ,KARJ,CAEEI,OAFF;EAAA,IAGMC,WAHN,GAQIL,KARJ,CAGEM,EAHF;EAAA,IAIEC,OAJF,GAQIP,KARJ,CAIEO,OAJF;EAAA,IAKEC,SALF,GAQIR,KARJ,CAKEQ,SALF;EAAA,IAMEC,QANF,GAQIT,KARJ,CAMES,QANF;EAAA,IAOKC,UAPL,4BAQIV,KARJ;;EASA,sBACEH,cAAc,EADhB;EAAA,IAAQc,aAAR,mBAAQA,aAAR;EAAA,IAAuBC,mBAAvB,mBAAuBA,mBAAvB;EAAA,IAA4CC,IAA5C,mBAA4CA,IAA5C;EAAA,IAAkDC,SAAlD,mBAAkDA,SAAlD;EAAA,IAA6DC,QAA7D,mBAA6DA,QAA7D;;EAGA,IAAMC,iBAAiB,GAAGpB,KAAK,EAA/B;EACA,IAAMqB,QAAQ,GAAGZ,WAAW,IAAIW,iBAAhC;;EAEA,IAAME,aAAa,GAAG,SAAhBA,aA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EAAYU,aAAZ,CAXtB;IAYE,QAAQ,EAAET;EAZZ,GAaMC,UAbN,EADF;AAiBD,CA9DiC,CAA7B"}
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["as", "disabled", "onSelect", "onClick", "onKeyDown"];
3
+ var _excluded = ["as", "innerAs", "disabled", "onSelect", "onClick", "onKeyDown"];
4
4
  import { forwardRef, useRef, useId } from 'react';
5
5
  import { useMenuContext, useMenuListContext } from './context';
6
6
  import { assignMultipleRefs } from '../utils/assign-ref';
@@ -9,6 +9,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
9
9
  export var MenuItem = /*#__PURE__*/forwardRef(function MenuItem(props, forwardedRef) {
10
10
  var _props$as = props.as,
11
11
  Comp = _props$as === void 0 ? 'li' : _props$as,
12
+ innerAs = props.innerAs,
12
13
  disabled = props.disabled,
13
14
  onSelect = props.onSelect,
14
15
  onClick = props.onClick,
@@ -29,7 +30,7 @@ export var MenuItem = /*#__PURE__*/forwardRef(function MenuItem(props, forwarded
29
30
  var handleSelect = wrapEvent(onSelect, function (e) {
30
31
  var _buttonRef$current;
31
32
 
32
- onChange && onChange(e, false);
33
+ onChange(e, false);
33
34
  (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
34
35
  e.preventDefault();
35
36
  });
@@ -55,6 +56,7 @@ export var MenuItem = /*#__PURE__*/forwardRef(function MenuItem(props, forwarded
55
56
 
56
57
  return /*#__PURE__*/_jsx(Comp, _extends({
57
58
  ref: assignMultipleRefs(ref, forwardedRef),
59
+ as: innerAs,
58
60
  id: disabled ? undefined : itemId,
59
61
  "data-menu-item": "",
60
62
  "data-highlighted": isActive ? '' : undefined,
@@ -1 +1 @@
1
- {"version":3,"file":"MenuItem.js","names":["forwardRef","useRef","useId","useMenuContext","useMenuListContext","assignMultipleRefs","wrapEvent","MenuItem","props","forwardedRef","as","Comp","disabled","onSelect","onClick","onKeyDown","otherProps","onChange","buttonRef","navigationItem","onNavigate","ref","itemId","isActive","current","handleSelect","e","focus","preventDefault","handleClick","handleKeyDown","key","undefined"],"sources":["../../../src/Menu/MenuItem.tsx"],"sourcesContent":["import type {\n LiHTMLAttributes,\n ElementType,\n MouseEvent,\n KeyboardEvent,\n KeyboardEventHandler,\n} from 'react';\nimport { forwardRef, useRef, useId } from 'react';\n\nimport { useMenuContext, useMenuListContext } from './context';\nimport { assignMultipleRefs } from '../utils/assign-ref';\nimport { wrapEvent } from '../utils';\n\nexport interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onSelect?: (\n e: MouseEvent<HTMLLIElement> | KeyboardEvent<HTMLLIElement>\n ) => void;\n disabled?: boolean;\n}\n\nexport const MenuItem = forwardRef<any, MenuItemProps>(function MenuItem(\n props,\n forwardedRef\n) {\n const {\n as: Comp = 'li',\n disabled,\n onSelect,\n onClick,\n onKeyDown,\n ...otherProps\n } = props;\n const { onChange, buttonRef } = useMenuContext();\n const { navigationItem, onNavigate } = useMenuListContext();\n const ref = useRef<HTMLLIElement>();\n const itemId = useId();\n\n const isActive = ref.current && ref.current === navigationItem;\n\n const handleSelect = wrapEvent(\n onSelect,\n (e: KeyboardEvent<HTMLLIElement> | MouseEvent<HTMLLIElement>) => {\n onChange && onChange(e, false);\n buttonRef.current?.focus();\n e.preventDefault();\n }\n );\n\n const handleClick = (e: MouseEvent<HTMLLIElement>) => {\n if (!disabled) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n onNavigate && onNavigate(ref.current!);\n handleSelect(e);\n }\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLLIElement> = (e) => {\n switch (e.key) {\n case 'Enter':\n if (!disabled) {\n handleSelect(e);\n }\n break;\n }\n };\n\n return (\n <Comp\n ref={assignMultipleRefs(ref, forwardedRef)}\n id={disabled ? undefined : itemId}\n data-menu-item=\"\"\n data-highlighted={isActive ? '' : undefined}\n role=\"menuitem\"\n onClick={wrapEvent(onClick, handleClick)}\n tabIndex={disabled ? -1 : 0}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n data-disabled={disabled ? '' : undefined}\n aria-disabled={disabled ? '' : undefined}\n disabled={disabled}\n {...otherProps}\n />\n );\n});\n"],"mappings":";;;AAOA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,KAA7B,QAA0C,OAA1C;AAEA,SAASC,cAAT,EAAyBC,kBAAzB,QAAmD,WAAnD;AACA,SAASC,kBAAT,QAAmC,qBAAnC;AACA,SAASC,SAAT,QAA0B,UAA1B;;AAWA,OAAO,IAAMC,QAAQ,gBAAGP,UAAU,CAAqB,SAASO,QAAT,CACrDC,KADqD,EAErDC,YAFqD,EAGrD;EACA,gBAOID,KAPJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,IADb;EAAA,IAEEC,QAFF,GAOIJ,KAPJ,CAEEI,QAFF;EAAA,IAGEC,QAHF,GAOIL,KAPJ,CAGEK,QAHF;EAAA,IAIEC,OAJF,GAOIN,KAPJ,CAIEM,OAJF;EAAA,IAKEC,SALF,GAOIP,KAPJ,CAKEO,SALF;EAAA,IAMKC,UANL,4BAOIR,KAPJ;;EAQA,sBAAgCL,cAAc,EAA9C;EAAA,IAAQc,QAAR,mBAAQA,QAAR;EAAA,IAAkBC,SAAlB,mBAAkBA,SAAlB;;EACA,0BAAuCd,kBAAkB,EAAzD;EAAA,IAAQe,cAAR,uBAAQA,cAAR;EAAA,IAAwBC,UAAxB,uBAAwBA,UAAxB;;EACA,IAAMC,GAAG,GAAGpB,MAAM,EAAlB;EACA,IAAMqB,MAAM,GAAGpB,KAAK,EAApB;EAEA,IAAMqB,QAAQ,GAAGF,GAAG,CAACG,OAAJ,IAAeH,GAAG,CAACG,OAAJ,KAAgBL,cAAhD;EAEA,IAAMM,YAAY,GAAGnB,SAAS,CAC5BO,QAD4B,EAE5B,UAACa,CAAD,EAAiE;IAAA;;IAC/DT,QAAQ,IAAIA,QAAQ,CAACS,CAAD,EAAI,KAAJ,CAApB;IACA,sBAAAR,SAAS,CAACM,OAAV,0EAAmBG,KAAnB;IACAD,CAAC,CAACE,cAAF;EACD,CAN2B,CAA9B;;EASA,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAACH,CAAD,EAAkC;IACpD,IAAI,CAACd,QAAL,EAAe;MACb;MACAQ,UAAU,IAAIA,UAAU,CAACC,GAAG,CAACG,OAAL,CAAxB;MACAC,YAAY,CAACC,CAAD,CAAZ;IACD;EACF,CAND;;EAQA,IAAMI,aAAkD,GAAG,SAArDA,aAAqD,CAACJ,CAAD,EAAO;IAChE,QAAQA,CAAC,CAACK,GAAV;MACE,KAAK,OAAL;QACE,IAAI,CAACnB,QAAL,EAAe;UACba,YAAY,CAACC,CAAD,CAAZ;QACD;;QACD;IALJ;EAOD,CARD;;EAUA,oBACE,KAAC,IAAD;IACE,GAAG,EAAErB,kBAAkB,CAACgB,GAAD,EAAMZ,YAAN,CADzB;IAEE,EAAE,EAAEG,QAAQ,GAAGoB,SAAH,GAAeV,MAF7B;IAGE,kBAAe,EAHjB;IAIE,oBAAkBC,QAAQ,GAAG,EAAH,GAAQS,SAJpC;IAKE,IAAI,EAAC,UALP;IAME,OAAO,EAAE1B,SAAS,CAACQ,OAAD,EAAUe,WAAV,CANpB;IAOE,QAAQ,EAAEjB,QAAQ,GAAG,CAAC,CAAJ,GAAQ,CAP5B;IAQE,SAAS,EAAEN,SAAS,CAACS,SAAD,EAAYe,aAAZ,CARtB;IASE,iBAAelB,QAAQ,GAAG,EAAH,GAAQoB,SATjC;IAUE,iBAAepB,QAAQ,GAAG,EAAH,GAAQoB,SAVjC;IAWE,QAAQ,EAAEpB;EAXZ,GAYMI,UAZN,EADF;AAgBD,CA9DiC,CAA3B"}
1
+ {"version":3,"file":"MenuItem.js","names":["forwardRef","useRef","useId","useMenuContext","useMenuListContext","assignMultipleRefs","wrapEvent","MenuItem","props","forwardedRef","as","Comp","innerAs","disabled","onSelect","onClick","onKeyDown","otherProps","onChange","buttonRef","navigationItem","onNavigate","ref","itemId","isActive","current","handleSelect","e","focus","preventDefault","handleClick","handleKeyDown","key","undefined"],"sources":["../../../src/Menu/MenuItem.tsx"],"sourcesContent":["import type {\n LiHTMLAttributes,\n ElementType,\n MouseEvent,\n KeyboardEvent,\n KeyboardEventHandler,\n} from 'react';\nimport { forwardRef, useRef, useId } from 'react';\n\nimport { useMenuContext, useMenuListContext } from './context';\nimport { assignMultipleRefs } from '../utils/assign-ref';\nimport { wrapEvent } from '../utils';\n\nexport interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n onSelect?: (\n e: MouseEvent<HTMLLIElement> | KeyboardEvent<HTMLLIElement>\n ) => void;\n disabled?: boolean;\n}\n\nexport const MenuItem = forwardRef<any, MenuItemProps>(function MenuItem(\n props,\n forwardedRef\n) {\n const {\n as: Comp = 'li',\n innerAs,\n disabled,\n onSelect,\n onClick,\n onKeyDown,\n ...otherProps\n } = props;\n const { onChange, buttonRef } = useMenuContext();\n const { navigationItem, onNavigate } = useMenuListContext();\n const ref = useRef<HTMLLIElement>();\n const itemId = useId();\n\n const isActive = ref.current && ref.current === navigationItem;\n\n const handleSelect = wrapEvent(\n onSelect,\n (e: KeyboardEvent<HTMLLIElement> | MouseEvent<HTMLLIElement>) => {\n onChange(e, false);\n buttonRef.current?.focus();\n e.preventDefault();\n }\n );\n\n const handleClick = (e: MouseEvent<HTMLLIElement>) => {\n if (!disabled) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n onNavigate && onNavigate(ref.current!);\n handleSelect(e);\n }\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLLIElement> = (e) => {\n switch (e.key) {\n case 'Enter':\n if (!disabled) {\n handleSelect(e);\n }\n break;\n }\n };\n\n return (\n <Comp\n ref={assignMultipleRefs(ref, forwardedRef)}\n as={innerAs}\n id={disabled ? undefined : itemId}\n data-menu-item=\"\"\n data-highlighted={isActive ? '' : undefined}\n role=\"menuitem\"\n onClick={wrapEvent(onClick, handleClick)}\n tabIndex={disabled ? -1 : 0}\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n data-disabled={disabled ? '' : undefined}\n aria-disabled={disabled ? '' : undefined}\n disabled={disabled}\n {...otherProps}\n />\n );\n});\n"],"mappings":";;;AAOA,SAASA,UAAT,EAAqBC,MAArB,EAA6BC,KAA7B,QAA0C,OAA1C;AAEA,SAASC,cAAT,EAAyBC,kBAAzB,QAAmD,WAAnD;AACA,SAASC,kBAAT,QAAmC,qBAAnC;AACA,SAASC,SAAT,QAA0B,UAA1B;;AAWA,OAAO,IAAMC,QAAQ,gBAAGP,UAAU,CAAqB,SAASO,QAAT,CACrDC,KADqD,EAErDC,YAFqD,EAGrD;EACA,gBAQID,KARJ,CACEE,EADF;EAAA,IACMC,IADN,0BACa,IADb;EAAA,IAEEC,OAFF,GAQIJ,KARJ,CAEEI,OAFF;EAAA,IAGEC,QAHF,GAQIL,KARJ,CAGEK,QAHF;EAAA,IAIEC,QAJF,GAQIN,KARJ,CAIEM,QAJF;EAAA,IAKEC,OALF,GAQIP,KARJ,CAKEO,OALF;EAAA,IAMEC,SANF,GAQIR,KARJ,CAMEQ,SANF;EAAA,IAOKC,UAPL,4BAQIT,KARJ;;EASA,sBAAgCL,cAAc,EAA9C;EAAA,IAAQe,QAAR,mBAAQA,QAAR;EAAA,IAAkBC,SAAlB,mBAAkBA,SAAlB;;EACA,0BAAuCf,kBAAkB,EAAzD;EAAA,IAAQgB,cAAR,uBAAQA,cAAR;EAAA,IAAwBC,UAAxB,uBAAwBA,UAAxB;;EACA,IAAMC,GAAG,GAAGrB,MAAM,EAAlB;EACA,IAAMsB,MAAM,GAAGrB,KAAK,EAApB;EAEA,IAAMsB,QAAQ,GAAGF,GAAG,CAACG,OAAJ,IAAeH,GAAG,CAACG,OAAJ,KAAgBL,cAAhD;EAE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 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["as", "onKeyDown", "id", "defaultActiveItemValue"];
5
- import { forwardRef, useEffect, useRef, useState, useLayoutEffect } from 'react';
4
+ var _excluded = ["as", "innerAs", "onKeyDown", "id", "defaultActiveItemValue"];
5
+ import { useCallback, forwardRef, useEffect, useRef, useState, useLayoutEffect } from 'react';
6
6
  import { useMenuContext, MenuListProvider } from './context';
7
7
  import { assignMultipleRefs } from '../utils/assign-ref';
8
8
  import { useOnClickOutside } from '../hooks/useOnClickOutside';
@@ -16,11 +16,13 @@ export var MenuList = /*#__PURE__*/forwardRef(function MenuList(props, forwarded
16
16
 
17
17
  var _props$as = props.as,
18
18
  Comp = _props$as === void 0 ? 'ul' : _props$as,
19
+ innerAs = props.innerAs,
19
20
  onKeyDown = props.onKeyDown,
20
21
  preferredId = props.id,
21
22
  defaultActiveItemValue = props.defaultActiveItemValue,
22
23
  otherProps = _objectWithoutProperties(props, _excluded);
23
24
 
25
+ var interactedOutside = useRef(false);
24
26
  var itemSearchStr = useRef('');
25
27
  var itemSearchClearTimeout = useRef();
26
28
 
@@ -73,17 +75,29 @@ export var MenuList = /*#__PURE__*/forwardRef(function MenuList(props, forwarded
73
75
  openWithArrowKeyRef.current = null;
74
76
  setMounted(true);
75
77
  }, [mounted, navigationItem, onNavigate, openWithArrowKeyRef, scope, defaultActiveItemValue]);
76
- useOnClickOutside(menuListRef, function (e) {
77
- var _buttonRef$current;
78
+ var handleClickOutside = useCallback(function (e) {
79
+ if (!interactedOutside.current) {
80
+ // First interaction should be ignored, because
81
+ // this is what triggered the context menu to open
82
+ interactedOutside.current = true;
83
+ return;
84
+ }
78
85
 
79
- console.log(isContextMenu.current);
86
+ if (isContextMenu.current) {
87
+ if (e.button === 0) {
88
+ onChange(e, false);
89
+ }
90
+ } else {
91
+ var _buttonRef$current;
80
92
 
81
- if (isContextMenu.current || e.target instanceof HTMLElement && e.target !== buttonRef.current && !((_buttonRef$current = buttonRef.current) !== null && _buttonRef$current !== void 0 && _buttonRef$current.contains(e.target))) {
82
- onChange && onChange(e, false);
93
+ if (e.target instanceof HTMLElement && e.target !== buttonRef.current && !((_buttonRef$current = buttonRef.current) !== null && _buttonRef$current !== void 0 && _buttonRef$current.contains(e.target))) {
94
+ onChange(e, false);
95
+ }
83
96
  }
84
97
 
85
98
  e.preventDefault();
86
- }, true);
99
+ }, [buttonRef, isContextMenu, onChange]);
100
+ useOnClickOutside(menuListRef, handleClickOutside, open);
87
101
 
88
102
  function handleKeyDown(e) {
89
103
  switch (e.key) {
@@ -92,7 +106,7 @@ export var MenuList = /*#__PURE__*/forwardRef(function MenuList(props, forwarded
92
106
  {
93
107
  var _buttonRef$current2;
94
108
 
95
- onChange && onChange(e, false);
109
+ onChange(e, false);
96
110
  e.preventDefault(); // prevents focusing on next element, because we will be handling it
97
111
 
98
112
  itemSearchStr.current = '';
@@ -187,6 +201,7 @@ export var MenuList = /*#__PURE__*/forwardRef(function MenuList(props, forwarded
187
201
  }
188
202
 
189
203
  if (!open) {
204
+ interactedOutside.current = false;
190
205
  return null;
191
206
  }
192
207
 
@@ -197,6 +212,7 @@ export var MenuList = /*#__PURE__*/forwardRef(function MenuList(props, forwarded
197
212
  },
198
213
  children: /*#__PURE__*/_jsx(Comp, _extends({
199
214
  ref: assignMultipleRefs(forwardedRef, menuListRef),
215
+ as: innerAs,
200
216
  id: menuListIdRef.current,
201
217
  role: "menu",
202
218
  "aria-labelledby": (_buttonRef$current3 = buttonRef.current) === null || _buttonRef$current3 === void 0 ? void 0 : _buttonRef$current3.id,
@@ -1 +1 @@
1
- {"version":3,"file":"MenuList.js","names":["forwardRef","useEffect","useRef","useState","useLayoutEffect","useMenuContext","MenuListProvider","assignMultipleRefs","useOnClickOutside","useScope","queryScope","getCircularIndex","wrapEvent","useEnhancedEffect","window","MenuList","props","forwardedRef","as","Comp","onKeyDown","preferredId","id","defaultActiveItemValue","otherProps","itemSearchStr","itemSearchClearTimeout","menuListIdRef","buttonRef","onChange","openWithArrowKeyRef","open","isContextMenu","navigationItem","setNavigationItem","mounted","setMounted","menuListRef","scope","onNavigate","el","focus","current","allItems","queryAllNodes","index","length","i","dataset","value","e","console","log","target","HTMLElement","contains","preventDefault","handleKeyDown","key","currentIndex","findIndex","nextIndex","ctrlKey","altKey","slice","clearTimeout","setTimeout","searchStr","idx","dom","domText","innerText","toLowerCase","startsWith"],"sources":["../../../src/Menu/MenuList.tsx"],"sourcesContent":["import type { HTMLAttributes, ElementType, KeyboardEvent } from 'react';\nimport {\n forwardRef,\n useEffect,\n useRef,\n useState,\n useLayoutEffect,\n} from 'react';\n\nimport { useMenuContext, MenuListProvider } from './context';\nimport { assignMultipleRefs } from '../utils/assign-ref';\nimport { useOnClickOutside } from '../hooks/useOnClickOutside';\nimport { useScope } from '../hooks';\nimport { queryScope } from './scope';\nimport { getCircularIndex, wrapEvent } from '../utils';\n\nconst useEnhancedEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nexport interface MenuListProps extends HTMLAttributes<HTMLUListElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n defaultActiveItemValue?: string;\n}\n\nexport const MenuList = forwardRef<HTMLUListElement, MenuListProps>(\n function MenuList(props, forwardedRef) {\n const {\n as: Comp = 'ul',\n onKeyDown,\n id: preferredId,\n defaultActiveItemValue,\n ...otherProps\n } = props;\n\n const itemSearchStr = useRef('');\n const itemSearchClearTimeout = useRef<ReturnType<typeof setTimeout>>();\n\n const {\n menuListIdRef,\n buttonRef,\n onChange,\n openWithArrowKeyRef,\n open,\n isContextMenu,\n } = useMenuContext();\n\n const [navigationItem, setNavigationItem] = useState<\n HTMLElement | undefined\n >();\n\n const [mounted, setMounted] = useState(false);\n\n const menuListRef = useRef<HTMLUListElement>();\n\n const scope = useScope<HTMLLIElement, HTMLUListElement>(menuListRef);\n\n const onNavigate = (el: HTMLElement) => {\n el.focus();\n setNavigationItem(el);\n };\n\n menuListIdRef.current = preferredId || menuListIdRef.current;\n\n useEnhancedEffect(() => {\n if (!mounted) {\n const allItems = scope.current.queryAllNodes(queryScope);\n let index = getCircularIndex(\n openWithArrowKeyRef.current === 'ArrowUp' ? -1 : 0,\n allItems.length\n );\n\n if (defaultActiveItemValue) {\n for (let i = 0; i < allItems.length; i++) {\n if (allItems[i].dataset.value === defaultActiveItemValue) {\n index = i;\n break;\n }\n }\n }\n\n if (index !== null) {\n onNavigate && onNavigate(allItems[index]);\n }\n }\n\n openWithArrowKeyRef.current = null;\n setMounted(true);\n }, [\n mounted,\n navigationItem,\n onNavigate,\n openWithArrowKeyRef,\n scope,\n defaultActiveItemValue,\n ]);\n\n useOnClickOutside(\n menuListRef,\n (e) => {\n console.log(isContextMenu.current);\n if (\n isContextMenu.current ||\n (e.target instanceof HTMLElement &&\n e.target !== buttonRef.current &&\n !buttonRef.current?.contains(e.target))\n ) {\n onChange && onChange(e as any, false);\n }\n e.preventDefault();\n },\n true\n );\n\n function handleKeyDown(e: KeyboardEvent<HTMLUListElement>) {\n switch (e.key) {\n case 'Escape':\n case 'Tab': {\n onChange && onChange(e, false);\n e.preventDefault(); // prevents focusing on next element, because we will be handling it\n itemSearchStr.current = '';\n buttonRef.current?.focus();\n break;\n }\n case 'Home':\n case 'End':\n case 'ArrowDown':\n case 'ArrowUp':\n e.preventDefault();\n itemSearchStr.current = '';\n const allItems = scope ? scope.current.queryAllNodes(queryScope) : [];\n const currentIndex = allItems.findIndex((e) => e === navigationItem);\n if (allItems.length === 0) {\n return;\n }\n let nextIndex: number = currentIndex;\n switch (e.key) {\n case 'ArrowUp':\n nextIndex += -1;\n break;\n case 'ArrowDown':\n nextIndex += 1;\n break;\n case 'Home':\n nextIndex = 0;\n break;\n case 'End':\n nextIndex = -1;\n break;\n }\n // We already checked if allItems.length = 0 above\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n nextIndex = getCircularIndex(nextIndex, allItems.length)!;\n onNavigate && onNavigate(allItems[nextIndex]);\n break;\n default: {\n if (e.key.length === 1 && !e.ctrlKey && !e.altKey) {\n // A-Z\n e.preventDefault();\n\n if (\n itemSearchStr.current.length === 0 ||\n itemSearchStr.current.slice(-1) !== e.key\n ) {\n itemSearchStr.current = itemSearchStr.current + e.key;\n }\n clearTimeout(itemSearchClearTimeout.current as any);\n itemSearchClearTimeout.current = setTimeout(() => {\n itemSearchStr.current = '';\n }, 500);\n\n const allItems = scope\n ? scope.current.queryAllNodes(queryScope)\n : [];\n const currentIndex = allItems.findIndex(\n (e) => e === navigationItem\n );\n const searchStr = itemSearchStr.current;\n let nextIndex = -1;\n for (\n let i = searchStr.length === 1 ? 1 : 0;\n i < allItems.length;\n i++\n ) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const idx = getCircularIndex(currentIndex + i, allItems.length)!;\n const dom = allItems[idx];\n const domText = dom.innerText.toLowerCase();\n if (domText.length > 0 && domText.startsWith(searchStr)) {\n nextIndex = idx;\n break;\n }\n }\n if (nextIndex >= 0 && nextIndex < allItems.length) {\n onNavigate && onNavigate(allItems[nextIndex]);\n }\n }\n }\n }\n }\n\n if (!open) {\n return null;\n }\n\n return (\n <MenuListProvider\n value={{\n navigationItem,\n onNavigate,\n }}\n >\n <Comp\n ref={assignMultipleRefs(forwardedRef, menuListRef)}\n id={menuListIdRef.current}\n role=\"menu\"\n aria-labelledby={buttonRef.current?.id}\n data-menu-list=\"\"\n tabIndex=\"-1\"\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\n {...otherProps}\n />\n </MenuListProvider>\n );\n }\n);\n"],"mappings":";;;;AACA,SACEA,UADF,EAEEC,SAFF,EAGEC,MAHF,EAIEC,QAJF,EAKEC,eALF,QAMO,OANP;AAQA,SAASC,cAAT,EAAyBC,gBAAzB,QAAiD,WAAjD;AACA,SAASC,kBAAT,QAAmC,qBAAnC;AACA,SAASC,iBAAT,QAA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AHH,EAIE;cACA;cACA,IAAMqB,GAAG,GAAGzD,gBAAgB,CAACgD,aAAY,GAAGZ,CAAhB,EAAmBJ,SAAQ,CAACG,MAA5B,CAA5B;cACA,IAAMuB,GAAG,GAAG1B,SAAQ,CAACyB,GAAD,CAApB;cACA,IAAME,OAAO,GAAGD,GAAG,CAACE,SAAJ,CAAcC,WAAd,EAAhB;;cACA,IAAIF,OAAO,CAACxB,MAAR,GAAiB,CAAjB,IAAsBwB,OAAO,CAACG,UAAR,CAAmBN,SAAnB,CAA1B,EAAyD;gBACvDN,UAAS,GAAGO,GAAZ;gBACA;cACD;YACF;;YACD,IAAIP,UAAS,IAAI,CAAb,IAAkBA,UAAS,GAAGlB,SAAQ,CAACG,MAA3C,EAAmD;cACjDP,UAAU,IAAIA,UAAU,CAACI,SAAQ,CAACkB,UAAD,CAAT,CAAxB;YACD;UACF;QACF;IAlFH;EAoFD;;EAED,IAAI,CAAC9B,IAAL,EAAW;IACT,OAAO,IAAP;EACD;;EAED,oBACE,KAAC,gBAAD;IACE,KAAK,EAAE;MACLE,cAAc,EAAdA,cADK;MAELM,UAAU,EAAVA;IAFK,CADT;IAAA,uBAME,KAAC,IAAD;MACE,GAAG,EAAEhC,kBAAkB,CAACU,YAAD,EAAeoB,WAAf,CADzB;MAEE,EAAE,EAAEV,aAAa,CAACe,OAFpB;MAGE,IAAI,EAAC,MAHP;MAIE,0CAAiBd,SAAS,CAACc,OAA3B,wDAAiB,oBAAmBpB,EAJtC;MAKE,kBAAe,EALjB;MAME,QAAQ,EAAC,IANX;MAOE,SAAS,EAAEV,SAAS,CAACQ,SAAD,EAAYqC,aAAZ;IAPtB,GAQMjC,UARN;EANF,EADF;AAmBD,CAvM+B,CAA3B"}
1
+ {"version":3,"file":"MenuList.js","names":["useCallback","forwardRef","useEffect","useRef","useState","useLayoutEffect","useMenuContext","MenuListProvider","assignMultipleRefs","useOnClickOutside","useScope","queryScope","getCircularIndex","wrapEvent","useEnhancedEffect","window","MenuList","props","forwardedRef","as","Comp","innerAs","onKeyDown","preferredId","id","defaultActiveItemValue","otherProps","interactedOutside","itemSearchStr","itemSearchClearTimeout","menuListIdRef","buttonRef","onChange","openWithArrowKeyRef","open","isContextMenu","navigationItem","setNavigationItem","mounted","setMounted","menuListRef","scope","onNavigate","el","focus","current","allItems","queryAllNodes","index","length","i","dataset","value","handleClickOutside","e","button","target","HTMLElement","contains","preventDefault","handleKeyDown","key","currentIndex","findIndex","nextIndex","ctrlKey","altKey","slice","clearTimeout","setTimeout","searchStr","idx","dom","domText","innerText","toLowerCase","startsWith"],"sources":["../../../src/Menu/MenuList.tsx"],"sourcesContent":["import type { HTMLAttributes, ElementType, KeyboardEvent } from 'react';\nimport {\n useCallback,\n forwardRef,\n useEffect,\n useRef,\n useState,\n useLayoutEffect,\n} from 'react';\n\nimport { useMenuContext, MenuListProvider } from './context';\nimport { assignMultipleRefs } from '../utils/assign-ref';\nimport { useOnClickOutside } from '../hooks/useOnClickOutside';\nimport { useScope } from '../hooks';\nimport { queryScope } from './scope';\nimport { getCircularIndex, wrapEvent } from '../utils';\n\nconst useEnhancedEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nexport interface MenuListProps extends HTMLAttributes<HTMLUListElement> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n defaultActiveItemValue?: string;\n}\n\nexport const MenuList = forwardRef<HTMLUListElement, MenuListProps>(\n function MenuList(props, forwardedRef) {\n const {\n as: Comp = 'ul',\n innerAs,\n onKeyDown,\n id: preferredId,\n defaultActiveItemValue,\n ...otherProps\n } = props;\n\n const interactedOutside = useRef(false);\n const itemSearchStr = useRef('');\n const itemSearchClearTimeout = useRef<ReturnType<typeof setTimeout>>();\n\n const {\n menuListIdRef,\n buttonRef,\n onChange,\n openWithArrowKeyRef,\n open,\n isContextMenu,\n } = useMenuContext();\n\n const [navigationItem, setNavigationItem] = useState<\n HTMLElement | undefined\n >();\n\n const [mounted, setMounted] = useState(false);\n\n const menuListRef = useRef<HTMLUListElement>();\n\n const scope = useScope<HTMLLIElement, HTMLUListElement>(menuListRef);\n\n const onNavigate = (el: HTMLElement) => {\n el.focus();\n setNavigationItem(el);\n };\n\n menuListIdRef.current = preferredId || menuListIdRef.current;\n\n useEnhancedEffect(() => {\n if (!mounted) {\n const allItems = scope.current.queryAllNodes(queryScope);\n let index = getCircularIndex(\n openWithArrowKeyRef.current === 'ArrowUp' ? -1 : 0,\n allItems.length\n );\n\n if (defaultActiveItemValue) {\n for (let i = 0; i < allItems.length; i++) {\n if (allItems[i].dataset.value === defaultActiveItemValue) {\n index = i;\n break;\n }\n }\n }\n\n if (index !== null) {\n onNavigate && onNavigate(allItems[index]);\n }\n }\n\n openWithArrowKeyRef.current = null;\n setMounted(true);\n }, [\n mounted,\n navigationItem,\n onNavigate,\n openWithArrowKeyRef,\n scope,\n defaultActiveItemValue,\n ]);\n\n const handleClickOutside = useCallback(\n (e: PointerEvent) => {\n if (!interactedOutside.current) {\n // First interaction should be ignored, because\n // this is what triggered the context menu to open\n interactedOutside.current = true;\n return;\n }\n\n if (isContextMenu.current) {\n if (e.button === 0) {\n onChange(e as any, false);\n }\n } else {\n if (\n e.target instanceof HTMLElement &&\n e.target !== buttonRef.current &&\n !buttonRef.current?.contains(e.target)\n ) {\n onChange(e as any, false);\n }\n }\n e.preventDefault();\n },\n [buttonRef, isContextMenu, onChange]\n );\n\n useOnClickOutside(menuListRef, handleClickOutside, open);\n\n function handleKeyDown(e: KeyboardEvent<HTMLUListElement>) {\n switch (e.key) {\n case 'Escape':\n case 'Tab': {\n onChange(e, false);\n e.preventDefault(); // prevents focusing on next element, because we will be handling it\n itemSearchStr.current = '';\n buttonRef.current?.focus();\n break;\n }\n case 'Home':\n case 'End':\n case 'ArrowDown':\n case 'ArrowUp':\n e.preventDefault();\n itemSearchStr.current = '';\n const allItems = scope ? scope.current.queryAllNodes(queryScope) : [];\n const currentIndex = allItems.findIndex((e) => e === navigationItem);\n if (allItems.length === 0) {\n return;\n }\n let nextIndex: number = currentIndex;\n switch (e.key) {\n case 'ArrowUp':\n nextIndex += -1;\n break;\n case 'ArrowDown':\n nextIndex += 1;\n break;\n case 'Home':\n nextIndex = 0;\n break;\n case 'End':\n nextIndex = -1;\n break;\n }\n // We already checked if allItems.length = 0 above\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n nextIndex = getCircularIndex(nextIndex, allItems.length)!;\n onNavigate && onNavigate(allItems[nextIndex]);\n break;\n default: {\n if (e.key.length === 1 && !e.ctrlKey && !e.altKey) {\n // A-Z\n e.preventDefault();\n\n if (\n itemSearchStr.current.length === 0 ||\n itemSearchStr.current.slice(-1) !== e.key\n ) {\n itemSearchStr.current = itemSearchStr.current + e.key;\n }\n clearTimeout(itemSearchClearTimeout.current as any);\n itemSearchClearTimeout.current = setTimeout(() => {\n itemSearchStr.current = '';\n }, 500);\n\n const allItems = scope\n ? scope.current.queryAllNodes(queryScope)\n : [];\n const currentIndex = allItems.findIndex(\n (e) => e === navigationItem\n );\n const searchStr = itemSearchStr.current;\n let nextIndex = -1;\n for (\n let i = searchStr.length === 1 ? 1 : 0;\n i < allItems.length;\n i++\n ) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const idx = getCircularIndex(currentIndex + i, allItems.length)!;\n const dom = allItems[idx];\n const domText = dom.innerText.toLowerCase();\n if (domText.length > 0 && domText.startsWith(searchStr)) {\n nextIndex = idx;\n break;\n }\n }\n if (nextIndex >= 0 && nextIndex < allItems.length) {\n onNavigate && onNavigate(allItems[nextIndex]);\n }\n }\n }\n }\n }\n\n if (!open) {\n interactedOutside.current = false;\n return null;\n }\n\n return (\n <MenuListProvider\n value={{\n navigationItem,\n onNavigate,\n }}\n >\n <Comp\n ref={assignMultipleRefs(forwardedRef, menuListRef)}\n as={innerAs}\n id={menuListIdRef.current}\n role=\"menu\"\n aria-labelledby={buttonRef.current?.id}\n data-menu-list=\"\"\n tabIndex=\"-1\"\n onKeyDown={wrapEvent(onKeyDown, handleKeyDown)}\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,CAAC9B,IAAL,EAAW;IACTP,iBAAiB,CAACkB,OAAlB,GAA4B,KAA5B;IACA,OAAO,IAAP;EACD;;EAED,oBACE,KAAC,gBAAD;IACE,KAAK,EAAE;MACLT,cAAc,EAAdA,cADK;MAELM,UAAU,EAAVA;IAFK,CADT;IAAA,uBAME,KAAC,IAAD;MACE,GAAG,EAAElC,kBAAkB,CAACU,YAAD,EAAesB,WAAf,CADzB;MAEE,EAAE,EAAEnB,OAFN;MAGE,EAAE,EAAES,aAAa,CAACe,OAHpB;MAIE,IAAI,EAAC,MAJP;MAKE,0CAAiBd,SAAS,CAACc,OAA3B,wDAAiB,oBAAmBrB,EALtC;MAME,kBAAe,EANjB;MAOE,QAAQ,EAAC,IAPX;MAQE,SAAS,EAAEX,SAAS,CAACS,SAAD,EAAYsC,aAAZ;IARtB,GASMlC,UATN;EANF,EADF;AAoBD,CAvN+B,CAA3B"}
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["as"];
3
+ var _excluded = ["as", "innerAs"];
4
4
  import { forwardRef } from 'react';
5
5
  import { Popper } from '../Popper';
6
6
  import { useMenuContext } from './context';
@@ -8,6 +8,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
8
8
  export var MenuPopover = /*#__PURE__*/forwardRef(function MenuPopover(props, forwardedRef) {
9
9
  var _props$as = props.as,
10
10
  as = _props$as === void 0 ? 'div' : _props$as,
11
+ innerAs = props.innerAs,
11
12
  otherProps = _objectWithoutProperties(props, _excluded);
12
13
 
13
14
  var _useMenuContext = useMenuContext(),
@@ -22,6 +23,7 @@ export var MenuPopover = /*#__PURE__*/forwardRef(function MenuPopover(props, for
22
23
 
23
24
  return /*#__PURE__*/_jsx(Popper, _extends({
24
25
  as: as,
26
+ innerAs: innerAs,
25
27
  ref: forwardedRef,
26
28
  anchorEl: buttonRef,
27
29
  offsetFn: offsetFn,
@@ -1 +1 @@
1
- {"version":3,"file":"MenuPopover.js","names":["forwardRef","Popper","useMenuContext","MenuPopover","props","forwardedRef","as","otherProps","buttonRef","open","offsetFn","isContextMenu","current","undefined"],"sources":["../../../src/Menu/MenuPopover.tsx"],"sourcesContent":["import type { ElementType, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport type { PopperProps } from '../Popper';\nimport { Popper } from '../Popper';\nimport { useMenuContext } from './context';\n\nexport interface MenuPopoverProps extends Omit<PopperProps, 'anchorEl'> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const MenuPopover = forwardRef<HTMLDivElement, MenuPopoverProps>(\n function MenuPopover(props, forwardedRef) {\n const { as = 'div', ...otherProps } = props;\n const { buttonRef, open, offsetFn, isContextMenu } = useMenuContext();\n\n if (!open) {\n return null;\n }\n\n return (\n <Popper\n as={as}\n ref={forwardedRef}\n anchorEl={buttonRef}\n offsetFn={offsetFn}\n placement={isContextMenu.current ? 'bottom-start' : undefined}\n {...otherProps}\n />\n );\n }\n);\n"],"mappings":";;;AACA,SAASA,UAAT,QAA2B,OAA3B;AAGA,SAASC,MAAT,QAAuB,WAAvB;AACA,SAASC,cAAT,QAA+B,WAA/B;;AAQA,OAAO,IAAMC,WAAW,gBAAGH,UAAU,CACnC,SAASG,WAAT,CAAqBC,KAArB,EAA4BC,YAA5B,EAA0C;EACxC,gBAAsCD,KAAtC,CAAQE,EAAR;EAAA,IAAQA,EAAR,0BAAa,KAAb;EAAA,IAAuBC,UAAvB,4BAAsCH,KAAtC;;EACA,sBAAqDF,cAAc,EAAnE;EAAA,IAAQM,SAAR,mBAAQA,SAAR;EAAA,IAAmBC,IAAnB,mBAAmBA,IAAnB;EAAA,IAAyBC,QAAzB,mBAAyBA,QAAzB;EAAA,IAAmCC,aAAnC,mBAAmCA,aAAnC;;EAEA,IAAI,CAACF,IAAL,EAAW;IACT,OAAO,IAAP;EACD;;EAED,oBACE,KAAC,MAAD;IACE,EAAE,EAAEH,EADN;IAEE,GAAG,EAAED,YAFP;IAGE,QAAQ,EAAEG,SAHZ;IAIE,QAAQ,EAAEE,QAJZ;IAKE,SAAS,EAAEC,aAAa,CAACC,OAAd,GAAwB,cAAxB,GAAyCC;EALtD,GAMMN,UANN,EADF;AAUD,CAnBkC,CAA9B"}
1
+ {"version":3,"file":"MenuPopover.js","names":["forwardRef","Popper","useMenuContext","MenuPopover","props","forwardedRef","as","innerAs","otherProps","buttonRef","open","offsetFn","isContextMenu","current","undefined"],"sources":["../../../src/Menu/MenuPopover.tsx"],"sourcesContent":["import type { ElementType, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport type { PopperProps } from '../Popper';\nimport { Popper } from '../Popper';\nimport { useMenuContext } from './context';\n\nexport interface MenuPopoverProps extends Omit<PopperProps, 'anchorEl'> {\n as?: ElementType<any>;\n innerAs?: ElementType<any>;\n children?: ReactNode;\n}\n\nexport const MenuPopover = forwardRef<HTMLDivElement, MenuPopoverProps>(\n function MenuPopover(props, forwardedRef) {\n const { as = 'div', innerAs, ...otherProps } = props;\n const { buttonRef, open, offsetFn, isContextMenu } = useMenuContext();\n\n if (!open) {\n return null;\n }\n\n return (\n <Popper\n as={as}\n innerAs={innerAs}\n ref={forwardedRef}\n anchorEl={buttonRef}\n offsetFn={offsetFn}\n placement={isContextMenu.current ? 'bottom-start' : undefined}\n {...otherProps}\n />\n );\n }\n);\n"],"mappings":";;;AACA,SAASA,UAAT,QAA2B,OAA3B;AAGA,SAASC,MAAT,QAAuB,WAAvB;AACA,SAASC,cAAT,QAA+B,WAA/B;;AAQA,OAAO,IAAMC,WAAW,gBAAGH,UAAU,CACnC,SAASG,WAAT,CAAqBC,KAArB,EAA4BC,YAA5B,EAA0C;EACxC,gBAA+CD,KAA/C,CAAQE,EAAR;EAAA,IAAQA,EAAR,0BAAa,KAAb;EAAA,IAAoBC,OAApB,GAA+CH,KAA/C,CAAoBG,OAApB;EAAA,IAAgCC,UAAhC,4BAA+CJ,KAA/C;;EACA,sBAAqDF,cAAc,EAAnE;EAAA,IAAQO,SAAR,mBAAQA,SAAR;EAAA,IAAmBC,IAAnB,mBAAmBA,IAAnB;EAAA,IAAyBC,QAAzB,mBAAyBA,QAAzB;EAAA,IAAmCC,aAAnC,mBAAmCA,aAAnC;;EAEA,IAAI,CAACF,IAAL,EAAW;IACT,OAAO,IAAP;EACD;;EAED,oBACE,KAAC,MAAD;IACE,EAAE,EAAEJ,EADN;IAEE,OAAO,EAAEC,OAFX;IAGE,GAAG,EAAEF,YAHP;IAIE,QAAQ,EAAEI,SAJZ;IAKE,QAAQ,EAAEE,QALZ;IAME,SAAS,EAAEC,aAAa,CAACC,OAAd,GAAwB,cAAxB,GAAyCC;EANtD,GAOMN,UAPN,EADF;AAWD,CApBkC,CAA9B"}
@@ -1,5 +1,5 @@
1
1
  import type { OffsetsFunction } from '@popperjs/core/lib/modifiers/offset';
2
- import type { KeyboardEvent, MouseEvent, MutableRefObject, PointerEvent } from 'react';
2
+ import type { Dispatch, KeyboardEvent, MouseEvent, MutableRefObject, PointerEvent, SetStateAction } from 'react';
3
3
  export declare type ItemObject = {
4
4
  text: string;
5
5
  value: any;
@@ -9,10 +9,10 @@ export interface MenuContextProps {
9
9
  buttonRef: MutableRefObject<HTMLElement | null>;
10
10
  menuListIdRef: MutableRefObject<undefined | string>;
11
11
  openWithArrowKeyRef: MutableRefObject<string | null>;
12
- onChange?: (e: KeyboardEvent<HTMLElement> | MouseEvent<HTMLElement> | PointerEvent<HTMLElement>, isOpen: boolean) => void;
12
+ onChange: (e: KeyboardEvent<HTMLElement> | MouseEvent<HTMLElement> | PointerEvent<HTMLElement>, isOpen: boolean) => void;
13
13
  open: boolean;
14
- offset: MutableRefObject<[number, number]>;
15
- offsetFn: OffsetsFunction;
14
+ offsetFn: OffsetsFunction | undefined;
15
+ setOffsetFn: Dispatch<SetStateAction<OffsetsFunction | undefined>>;
16
16
  isContextMenu: MutableRefObject<boolean>;
17
17
  }
18
18
  export declare const MenuProvider: import("react").Provider<MenuContextProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":["createContext","useContext","menuContext","MenuProvider","Provider","useMenuContext","menuListContext","MenuListProvider","useMenuListContext"],"sources":["../../../src/Menu/context.ts"],"sourcesContent":["import type { OffsetsFunction } from '@popperjs/core/lib/modifiers/offset';\nimport type {\n KeyboardEvent,\n MouseEvent,\n MutableRefObject,\n PointerEvent,\n} from 'react';\nimport { createContext, useContext } from 'react';\n\nexport type ItemObject = { text: string; value: any; id: string | undefined };\n\n// MenuRoot\nexport interface MenuContextProps {\n buttonRef: MutableRefObject<HTMLElement | null>;\n menuListIdRef: MutableRefObject<undefined | string>;\n openWithArrowKeyRef: MutableRefObject<string | null>;\n onChange?: (\n e:\n | KeyboardEvent<HTMLElement>\n | MouseEvent<HTMLElement>\n | PointerEvent<HTMLElement>,\n isOpen: boolean\n ) => void;\n open: boolean;\n offset: MutableRefObject<[number, number]>;\n offsetFn: OffsetsFunction;\n isContextMenu: MutableRefObject<boolean>;\n}\n\nconst menuContext = createContext<MenuContextProps>(null as any);\nexport const { Provider: MenuProvider } = menuContext;\nexport const useMenuContext = () => useContext(menuContext);\n\n// MenuList\nexport interface MenuListContextProps {\n navigationItem: HTMLElement | undefined;\n onNavigate: undefined | ((idx: HTMLElement) => void);\n}\n\nconst menuListContext = createContext<MenuListContextProps>(null as any);\nexport const MenuListProvider = menuListContext.Provider;\nexport const useMenuListContext = () => useContext(menuListContext);\n"],"mappings":"AAOA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AAsBA,IAAMC,WAAW,gBAAGF,aAAa,CAAmB,IAAnB,CAAjC;AACO,IAAkBG,YAAlB,GAAmCD,WAAnC,CAAQE,QAAR;;AACP,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB;EAAA,OAAMJ,UAAU,CAACC,WAAD,CAAhB;AAAA,CAAvB,C,CAEP;;AAMA,IAAMI,eAAe,gBAAGN,aAAa,CAAuB,IAAvB,CAArC;AACA,OAAO,IAAMO,gBAAgB,GAAGD,eAAe,CAACF,QAAzC;AACP,OAAO,IAAMI,kBAAkB,GAAG,SAArBA,kBAAqB;EAAA,OAAMP,UAAU,CAACK,eAAD,CAAhB;AAAA,CAA3B"}
1
+ {"version":3,"file":"context.js","names":["createContext","useContext","menuContext","MenuProvider","Provider","useMenuContext","menuListContext","MenuListProvider","useMenuListContext"],"sources":["../../../src/Menu/context.ts"],"sourcesContent":["import type { OffsetsFunction } from '@popperjs/core/lib/modifiers/offset';\nimport type {\n Dispatch,\n KeyboardEvent,\n MouseEvent,\n MutableRefObject,\n PointerEvent,\n SetStateAction,\n} from 'react';\nimport { createContext, useContext } from 'react';\n\nexport type ItemObject = { text: string; value: any; id: string | undefined };\n\n// MenuRoot\nexport interface MenuContextProps {\n buttonRef: MutableRefObject<HTMLElement | null>;\n menuListIdRef: MutableRefObject<undefined | string>;\n openWithArrowKeyRef: MutableRefObject<string | null>;\n onChange: (\n e:\n | KeyboardEvent<HTMLElement>\n | MouseEvent<HTMLElement>\n | PointerEvent<HTMLElement>,\n isOpen: boolean\n ) => void;\n open: boolean;\n offsetFn: OffsetsFunction | undefined;\n setOffsetFn: Dispatch<SetStateAction<OffsetsFunction | undefined>>;\n isContextMenu: MutableRefObject<boolean>;\n}\n\nconst menuContext = createContext<MenuContextProps>(null as any);\nexport const { Provider: MenuProvider } = menuContext;\nexport const useMenuContext = () => useContext(menuContext);\n\n// MenuList\nexport interface MenuListContextProps {\n navigationItem: HTMLElement | undefined;\n onNavigate: undefined | ((idx: HTMLElement) => void);\n}\n\nconst menuListContext = createContext<MenuListContextProps>(null as any);\nexport const MenuListProvider = menuListContext.Provider;\nexport const useMenuListContext = () => useContext(menuListContext);\n"],"mappings":"AASA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AAsBA,IAAMC,WAAW,gBAAGF,aAAa,CAAmB,IAAnB,CAAjC;AACO,IAAkBG,YAAlB,GAAmCD,WAAnC,CAAQE,QAAR;;AACP,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB;EAAA,OAAMJ,UAAU,CAACC,WAAD,CAAhB;AAAA,CAAvB,C,CAEP;;AAMA,IAAMI,eAAe,gBAAGN,aAAa,CAAuB,IAAvB,CAArC;AACA,OAAO,IAAMO,gBAAgB,GAAGD,eAAe,CAACF,QAAzC;AACP,OAAO,IAAMI,kBAAkB,GAAG,SAArBA,kBAAqB;EAAA,OAAMP,UAAU,CAACK,eAAD,CAAhB;AAAA,CAA3B"}