Socket
Socket
Sign inDemoInstall

@reach/menu-button

Package Overview
Dependencies
Maintainers
4
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reach/menu-button - npm Package Compare versions

Comparing version 0.10.4 to 0.10.5

8

dist/index.d.ts

@@ -45,3 +45,3 @@ /**

*/
export declare const MenuButton: import("@reach/utils").ComponentWithAs<"button", MenuButtonProps>;
export declare const MenuButton: import("@reach/utils").ForwardRefExoticComponentWithAs<"button", MenuButtonProps>;
/**

@@ -82,3 +82,3 @@ * @see Docs https://reacttraining.com/reach-ui/menu-button#menubutton-props

*/
export declare const MenuItem: import("@reach/utils").ComponentWithAs<"div", Pick<MenuItemImplProps, "children" | "onSelect" | "index" | "valueText">>;
export declare const MenuItem: import("@reach/utils").ForwardRefExoticComponentWithAs<"div", Pick<MenuItemImplProps, "children" | "onSelect" | "index" | "valueText">>;
/**

@@ -97,3 +97,3 @@ * @see Docs https://reacttraining.com/reach-ui/menu-button#menuitem-props

*/
export declare const MenuItems: import("@reach/utils").ComponentWithAs<"div", MenuItemsProps>;
export declare const MenuItems: import("@reach/utils").ForwardRefExoticComponentWithAs<"div", MenuItemsProps>;
/**

@@ -121,3 +121,3 @@ * @see Docs https://reacttraining.com/reach-ui/menu-button#menuitems-props

*/
export declare const MenuLink: import("@reach/utils").ComponentWithAs<"a", Pick<MenuItemImplProps, "children" | "index" | "valueText"> & {
export declare const MenuLink: import("@reach/utils").ForwardRefExoticComponentWithAs<"a", Pick<MenuItemImplProps, "children" | "index" | "valueText"> & {
onSelect?(): void;

@@ -124,0 +124,0 @@ } & {

@@ -788,9 +788,5 @@ 'use strict';

} else {
var relatedTarget = event.relatedTarget,
target = event.target; // We on want to close only if focus rests outside the menu
// We on want to close only if focus rests outside the menu
if (isExpanded && popoverRef.current) {
var _popoverRef$current;
if (!((_popoverRef$current = popoverRef.current) === null || _popoverRef$current === void 0 ? void 0 : _popoverRef$current.contains(relatedTarget || target))) {
if (!popoverRef.current.contains(event.target)) {
dispatch({

@@ -797,0 +793,0 @@ type: CLOSE_MENU,

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n);require("prop-types");var r=require("@reach/auto-id"),o=e(require("@reach/popover")),a=require("@reach/descendants"),u=require("@reach/utils");function i(){return(i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function s(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n.indexOf(t=a[r])>=0||(o[t]=e[t]);return o}var c=a.createDescendantContext("MenuDescendantContext"),d=u.createNamedContext("MenuContext",{}),l={buttonId:null,isExpanded:!1,typeaheadQuery:"",selectionIndex:-1},f=u.forwardRefWithAs((function(e,r){var o=e.as,a=void 0===o?"button":o,i=e.onKeyDown,c=e.onMouseDown,l=e.id,f=s(e,["as","onKeyDown","onMouseDown","id"]),E=n.useContext(d),p=E.buttonRef,v=E.buttonClickedRef,x=E.menuId,_=E.state,y=_.buttonId,m=_.isExpanded,M=E.dispatch,w=u.useForkedRef(p,r);return n.useEffect((function(){var e=null!=l?l:x?u.makeId("menu-button",x):"menu-button";y!==e&&M({type:"SET_BUTTON_ID",payload:e})}),[y,M,l,x]),t.createElement(a,Object.assign({"aria-expanded":!!m||void 0,"aria-haspopup":!0,"aria-controls":x},f,{ref:w,"data-reach-menu-button":"",id:y||void 0,onKeyDown:u.wrapEvent(i,(function(e){switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),M({type:"OPEN_MENU_AT_FIRST_ITEM"});break;case"Enter":case" ":M({type:"OPEN_MENU_AT_FIRST_ITEM"})}})),onMouseDown:u.wrapEvent(c,(function(e){m||(v.current=!0),I(e.nativeEvent)||M(m?{type:"CLOSE_MENU",payload:{buttonRef:p}}:{type:"OPEN_MENU_CLEARED"})})),type:"button"}))})),E=u.forwardRefWithAs((function(e,r){var o=e.as,i=e.index,l=e.isLink,f=void 0!==l&&l,E=e.onClick,p=e.onDragStart,v=e.onMouseDown,x=e.onMouseEnter,_=e.onMouseLeave,y=e.onMouseMove,w=e.onMouseUp,T=e.onSelect,C=e.valueText,h=s(e,["as","index","isLink","onClick","onDragStart","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseUp","onSelect","valueText"]),R=n.useContext(d),b=R.buttonRef,D=R.dispatch,L=R.readyToSelect,k=R.selectCallbacks,S=R.state,O=S.selectionIndex,N=S.isExpanded,A=n.useRef(null),g=n.useState(C||""),U=g[0],P=g[1],j=n.useCallback((function(e){e&&(A.current=e,(!C||e.textContent&&U!==e.textContent)&&P(e.textContent))}),[U,C]),F=u.useForkedRef(r,j),K=n.useRef(!1),X=a.useDescendant({element:A.current,key:U,isLink:f},c,i),q=X===O;function B(){M(b.current),T&&T(),D({type:"CLICK_MENU_ITEM"})}return k.current[X]=T,n.useEffect((function(){N||(L.current=!1)}),[N,L]),n.useEffect((function(){var e=u.getOwnerDocument(A.current)||document,n=function(){return K.current=!1};return e.addEventListener("mouseup",n),function(){return e.removeEventListener("mouseup",n)}}),[]),t.createElement(o,Object.assign({role:"menuitem",id:m(X),tabIndex:-1},h,{ref:F,"data-reach-menu-item":"","data-selected":q?"":void 0,"data-valuetext":U,onClick:u.wrapEvent(E,(function(e){f&&!I(e.nativeEvent)&&B()})),onDragStart:u.wrapEvent(p,(function(e){f&&e.preventDefault()})),onMouseDown:u.wrapEvent(v,(function(e){I(e.nativeEvent)||(f?K.current=!0:e.preventDefault())})),onMouseEnter:u.wrapEvent(x,(function(e){q||null==X||D({type:"SELECT_ITEM_AT_INDEX",payload:{index:X}})})),onMouseLeave:u.wrapEvent(_,(function(e){D({type:"CLEAR_SELECTION_INDEX"})})),onMouseMove:u.wrapEvent(y,(function(){L.current=!0,q||null==X||D({type:"SELECT_ITEM_AT_INDEX",payload:{index:X}})})),onMouseUp:u.wrapEvent(w,(function(e){L.current?I(e.nativeEvent)||(f?K.current?K.current=!1:A.current&&A.current.click():B()):L.current=!0}))}))})),p=u.forwardRefWithAs((function(e,n){var r=e.as,o=void 0===r?"div":r,a=s(e,["as"]);return t.createElement(E,Object.assign({},a,{ref:n,as:o}))})),v=u.forwardRefWithAs((function(e,r){var o=e.as,i=void 0===o?"div":o,l=e.children,f=e.onKeyDown,E=s(e,["as","children","id","onKeyDown"]),p=n.useContext(d),v=p.menuId,x=p.dispatch,_=p.buttonRef,y=p.menuRef,I=p.selectCallbacks,w=p.state,T=w.isExpanded,C=w.buttonId,h=w.selectionIndex,R=w.typeaheadQuery,b=a.useDescendants(c),D=u.useForkedRef(y,r);n.useEffect((function(){var e=function(e,n){if(void 0===n&&(n=""),!n)return null;var t=e.find((function(e){var t,r,o=e.element;return null==o||null===(t=o.dataset)||void 0===t||null===(r=t.valuetext)||void 0===r?void 0:r.toLowerCase().startsWith(n)}));return t?e.indexOf(t):null}(b,R);R&&null!=e&&x({type:"SELECT_ITEM_AT_INDEX",payload:{index:e}});var n=window.setTimeout((function(){return R&&x({type:"SEARCH_FOR_ITEM",payload:""})}),1e3);return function(){return window.clearTimeout(n)}}),[x,b,R]);var L=u.usePrevious(b.length),k=u.usePrevious(b[h]),S=u.usePrevious(h);n.useEffect((function(){h>b.length-1?x({type:"SELECT_ITEM_AT_INDEX",payload:{index:b.length-1}}):L!==b.length&&h>-1&&k&&S===h&&b[h]!==k&&x({type:"SELECT_ITEM_AT_INDEX",payload:{index:b.findIndex((function(e){return e.key===k.key}))}})}),[x,b,L,k,S,h]);var O=u.wrapEvent((function(e){var n=e.key;if(T)switch(n){case"Enter":case" ":var t=b.find((function(e){return e.index===h}));t&&(t.isLink&&t.element?t.element.click():(e.preventDefault(),M(_.current),I.current[t.index]&&I.current[t.index](),x({type:"CLICK_MENU_ITEM"})));break;case"Escape":M(_.current),x({type:"CLOSE_MENU",payload:{buttonRef:_}});break;case"Tab":e.preventDefault();break;default:if(u.isString(n)&&1===n.length){var r=R+n.toLowerCase();x({type:"SEARCH_FOR_ITEM",payload:r})}}}),a.useDescendantKeyDown(c,{currentIndex:h,orientation:"vertical",rotate:!1,callback:function(e){x({type:"SELECT_ITEM_AT_INDEX",payload:{index:e}})},key:"index"}));return t.createElement(i,Object.assign({"aria-activedescendant":m(h)||void 0,"aria-labelledby":C||void 0,role:"menu",tabIndex:-1},E,{ref:D,"data-reach-menu-items":"",id:v,onKeyDown:u.wrapEvent(f,O)}),l)})),x=u.forwardRefWithAs((function(e,n){var r=e.as,o=void 0===r?"a":r,a=e.component,i=e.onSelect,c=s(e,["as","component","onSelect"]);return a&&console.warn("[@reach/menu-button]: Please use the `as` prop instead of `component`."),t.createElement("div",{role:"none",tabIndex:-1},t.createElement(E,Object.assign({},c,{ref:n,"data-reach-menu-link":"",as:o,isLink:!0,onSelect:i||u.noop})))})),_=n.forwardRef((function(e,n){var r=e.portal,o=void 0===r||r,a=s(e,["portal"]);return t.createElement(y,{portal:o},t.createElement(v,Object.assign({},a,{ref:n,"data-reach-menu-list":""})))})),y=n.forwardRef((function(e,r){var a=e.children,c=e.portal,l=void 0===c||c,f=e.position,E=s(e,["children","portal","position"]),p=n.useContext(d),v=p.buttonRef,x=p.buttonClickedRef,_=p.dispatch,y=p.menuRef,m=p.popoverRef,I=p.state.isExpanded,M=u.useForkedRef(m,r);n.useEffect((function(){function e(e){var n;x.current?x.current=!1:I&&m.current&&((null===(n=m.current)||void 0===n?void 0:n.contains(e.relatedTarget||e.target))||_({type:"CLOSE_MENU",payload:{buttonRef:v}}))}return window.addEventListener("mousedown",e),function(){window.removeEventListener("mousedown",e)}}),[x,v,_,I,y,m]);var w=i({ref:M,"data-reach-menu":"","data-reach-menu-popover":"",hidden:!I,children:a},E);return l?t.createElement(o,Object.assign({},w,{targetRef:v,position:f})):t.createElement("div",Object.assign({},w))}));function m(e){var t=n.useContext(d);return null!=e&&e>-1?u.makeId("option-"+e,t.menuId):void 0}function I(e){return 3===e.which||2===e.button}function M(e){e&&e.focus()}function w(e,n){switch(void 0===n&&(n={}),n.type){case"CLICK_MENU_ITEM":case"CLOSE_MENU":return i({},e,{isExpanded:!1,selectionIndex:-1});case"OPEN_MENU_AT_FIRST_ITEM":return i({},e,{isExpanded:!0,selectionIndex:0});case"OPEN_MENU_CLEARED":return i({},e,{isExpanded:!0,selectionIndex:-1});case"SELECT_ITEM_AT_INDEX":return n.payload.index>=0?i({},e,{selectionIndex:null!=n.payload.max?Math.min(Math.max(n.payload.index,0),n.payload.max):Math.max(n.payload.index,0)}):e;case"CLEAR_SELECTION_INDEX":return i({},e,{selectionIndex:-1});case"SET_BUTTON_ID":return i({},e,{buttonId:n.payload});case"SEARCH_FOR_ITEM":return void 0!==n.payload?i({},e,{typeaheadQuery:n.payload}):e;default:return e}}exports.Menu=function(e){var o=e.id,i=e.children,s=n.useRef(null),f=n.useRef(null),E=n.useRef(null),p=a.useDescendantsInit(),v=p[0],x=p[1],_=n.useReducer(w,l),y=_[0],m=_[1],I=r.useId(o),T=o||u.makeId("menu",I),C=n.useRef(!1),h=n.useRef([]),R=n.useRef(!1),b={buttonRef:s,dispatch:m,menuId:T,menuRef:f,popoverRef:E,buttonClickedRef:C,readyToSelect:R,selectCallbacks:h,state:y};return n.useEffect((function(){y.isExpanded?(window.__REACH_DISABLE_TOOLTIPS=!0,window.requestAnimationFrame((function(){M(f.current)}))):window.__REACH_DISABLE_TOOLTIPS=!1}),[y.isExpanded]),n.useEffect((function(){return u.checkStyles("menu-button")}),[]),t.createElement(a.DescendantProvider,{context:c,items:v,set:x},t.createElement(d.Provider,{value:b},u.isFunction(i)?i({isExpanded:y.isExpanded,isOpen:y.isExpanded}):i))},exports.MenuButton=f,exports.MenuItem=p,exports.MenuItems=v,exports.MenuLink=x,exports.MenuList=_,exports.MenuPopover=y,exports.useMenuButtonContext=function(){var e=n.useContext(d).state.isExpanded;return n.useMemo((function(){return{isExpanded:e}}),[e])};
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n);require("prop-types");var r=require("@reach/auto-id"),o=e(require("@reach/popover")),a=require("@reach/descendants"),u=require("@reach/utils");function i(){return(i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function s(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n.indexOf(t=a[r])>=0||(o[t]=e[t]);return o}var c=a.createDescendantContext("MenuDescendantContext"),d=u.createNamedContext("MenuContext",{}),l={buttonId:null,isExpanded:!1,typeaheadQuery:"",selectionIndex:-1},f=u.forwardRefWithAs((function(e,r){var o=e.as,a=void 0===o?"button":o,i=e.onKeyDown,c=e.onMouseDown,l=e.id,f=s(e,["as","onKeyDown","onMouseDown","id"]),E=n.useContext(d),p=E.buttonRef,v=E.buttonClickedRef,x=E.menuId,_=E.state,y=_.buttonId,m=_.isExpanded,M=E.dispatch,w=u.useForkedRef(p,r);return n.useEffect((function(){var e=null!=l?l:x?u.makeId("menu-button",x):"menu-button";y!==e&&M({type:"SET_BUTTON_ID",payload:e})}),[y,M,l,x]),t.createElement(a,Object.assign({"aria-expanded":!!m||void 0,"aria-haspopup":!0,"aria-controls":x},f,{ref:w,"data-reach-menu-button":"",id:y||void 0,onKeyDown:u.wrapEvent(i,(function(e){switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),M({type:"OPEN_MENU_AT_FIRST_ITEM"});break;case"Enter":case" ":M({type:"OPEN_MENU_AT_FIRST_ITEM"})}})),onMouseDown:u.wrapEvent(c,(function(e){m||(v.current=!0),I(e.nativeEvent)||M(m?{type:"CLOSE_MENU",payload:{buttonRef:p}}:{type:"OPEN_MENU_CLEARED"})})),type:"button"}))})),E=u.forwardRefWithAs((function(e,r){var o=e.as,i=e.index,l=e.isLink,f=void 0!==l&&l,E=e.onClick,p=e.onDragStart,v=e.onMouseDown,x=e.onMouseEnter,_=e.onMouseLeave,y=e.onMouseMove,w=e.onMouseUp,T=e.onSelect,C=e.valueText,h=s(e,["as","index","isLink","onClick","onDragStart","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseUp","onSelect","valueText"]),R=n.useContext(d),b=R.buttonRef,D=R.dispatch,L=R.readyToSelect,k=R.selectCallbacks,S=R.state,O=S.selectionIndex,N=S.isExpanded,A=n.useRef(null),g=n.useState(C||""),U=g[0],P=g[1],j=n.useCallback((function(e){e&&(A.current=e,(!C||e.textContent&&U!==e.textContent)&&P(e.textContent))}),[U,C]),F=u.useForkedRef(r,j),K=n.useRef(!1),X=a.useDescendant({element:A.current,key:U,isLink:f},c,i),q=X===O;function B(){M(b.current),T&&T(),D({type:"CLICK_MENU_ITEM"})}return k.current[X]=T,n.useEffect((function(){N||(L.current=!1)}),[N,L]),n.useEffect((function(){var e=u.getOwnerDocument(A.current)||document,n=function(){return K.current=!1};return e.addEventListener("mouseup",n),function(){return e.removeEventListener("mouseup",n)}}),[]),t.createElement(o,Object.assign({role:"menuitem",id:m(X),tabIndex:-1},h,{ref:F,"data-reach-menu-item":"","data-selected":q?"":void 0,"data-valuetext":U,onClick:u.wrapEvent(E,(function(e){f&&!I(e.nativeEvent)&&B()})),onDragStart:u.wrapEvent(p,(function(e){f&&e.preventDefault()})),onMouseDown:u.wrapEvent(v,(function(e){I(e.nativeEvent)||(f?K.current=!0:e.preventDefault())})),onMouseEnter:u.wrapEvent(x,(function(e){q||null==X||D({type:"SELECT_ITEM_AT_INDEX",payload:{index:X}})})),onMouseLeave:u.wrapEvent(_,(function(e){D({type:"CLEAR_SELECTION_INDEX"})})),onMouseMove:u.wrapEvent(y,(function(){L.current=!0,q||null==X||D({type:"SELECT_ITEM_AT_INDEX",payload:{index:X}})})),onMouseUp:u.wrapEvent(w,(function(e){L.current?I(e.nativeEvent)||(f?K.current?K.current=!1:A.current&&A.current.click():B()):L.current=!0}))}))})),p=u.forwardRefWithAs((function(e,n){var r=e.as,o=void 0===r?"div":r,a=s(e,["as"]);return t.createElement(E,Object.assign({},a,{ref:n,as:o}))})),v=u.forwardRefWithAs((function(e,r){var o=e.as,i=void 0===o?"div":o,l=e.children,f=e.onKeyDown,E=s(e,["as","children","id","onKeyDown"]),p=n.useContext(d),v=p.menuId,x=p.dispatch,_=p.buttonRef,y=p.menuRef,I=p.selectCallbacks,w=p.state,T=w.isExpanded,C=w.buttonId,h=w.selectionIndex,R=w.typeaheadQuery,b=a.useDescendants(c),D=u.useForkedRef(y,r);n.useEffect((function(){var e=function(e,n){if(void 0===n&&(n=""),!n)return null;var t=e.find((function(e){var t,r,o=e.element;return null==o||null===(t=o.dataset)||void 0===t||null===(r=t.valuetext)||void 0===r?void 0:r.toLowerCase().startsWith(n)}));return t?e.indexOf(t):null}(b,R);R&&null!=e&&x({type:"SELECT_ITEM_AT_INDEX",payload:{index:e}});var n=window.setTimeout((function(){return R&&x({type:"SEARCH_FOR_ITEM",payload:""})}),1e3);return function(){return window.clearTimeout(n)}}),[x,b,R]);var L=u.usePrevious(b.length),k=u.usePrevious(b[h]),S=u.usePrevious(h);n.useEffect((function(){h>b.length-1?x({type:"SELECT_ITEM_AT_INDEX",payload:{index:b.length-1}}):L!==b.length&&h>-1&&k&&S===h&&b[h]!==k&&x({type:"SELECT_ITEM_AT_INDEX",payload:{index:b.findIndex((function(e){return e.key===k.key}))}})}),[x,b,L,k,S,h]);var O=u.wrapEvent((function(e){var n=e.key;if(T)switch(n){case"Enter":case" ":var t=b.find((function(e){return e.index===h}));t&&(t.isLink&&t.element?t.element.click():(e.preventDefault(),M(_.current),I.current[t.index]&&I.current[t.index](),x({type:"CLICK_MENU_ITEM"})));break;case"Escape":M(_.current),x({type:"CLOSE_MENU",payload:{buttonRef:_}});break;case"Tab":e.preventDefault();break;default:if(u.isString(n)&&1===n.length){var r=R+n.toLowerCase();x({type:"SEARCH_FOR_ITEM",payload:r})}}}),a.useDescendantKeyDown(c,{currentIndex:h,orientation:"vertical",rotate:!1,callback:function(e){x({type:"SELECT_ITEM_AT_INDEX",payload:{index:e}})},key:"index"}));return t.createElement(i,Object.assign({"aria-activedescendant":m(h)||void 0,"aria-labelledby":C||void 0,role:"menu",tabIndex:-1},E,{ref:D,"data-reach-menu-items":"",id:v,onKeyDown:u.wrapEvent(f,O)}),l)})),x=u.forwardRefWithAs((function(e,n){var r=e.as,o=void 0===r?"a":r,a=e.component,i=e.onSelect,c=s(e,["as","component","onSelect"]);return a&&console.warn("[@reach/menu-button]: Please use the `as` prop instead of `component`."),t.createElement("div",{role:"none",tabIndex:-1},t.createElement(E,Object.assign({},c,{ref:n,"data-reach-menu-link":"",as:o,isLink:!0,onSelect:i||u.noop})))})),_=n.forwardRef((function(e,n){var r=e.portal,o=void 0===r||r,a=s(e,["portal"]);return t.createElement(y,{portal:o},t.createElement(v,Object.assign({},a,{ref:n,"data-reach-menu-list":""})))})),y=n.forwardRef((function(e,r){var a=e.children,c=e.portal,l=void 0===c||c,f=e.position,E=s(e,["children","portal","position"]),p=n.useContext(d),v=p.buttonRef,x=p.buttonClickedRef,_=p.dispatch,y=p.menuRef,m=p.popoverRef,I=p.state.isExpanded,M=u.useForkedRef(m,r);n.useEffect((function(){function e(e){x.current?x.current=!1:I&&m.current&&(m.current.contains(e.target)||_({type:"CLOSE_MENU",payload:{buttonRef:v}}))}return window.addEventListener("mousedown",e),function(){window.removeEventListener("mousedown",e)}}),[x,v,_,I,y,m]);var w=i({ref:M,"data-reach-menu":"","data-reach-menu-popover":"",hidden:!I,children:a},E);return l?t.createElement(o,Object.assign({},w,{targetRef:v,position:f})):t.createElement("div",Object.assign({},w))}));function m(e){var t=n.useContext(d);return null!=e&&e>-1?u.makeId("option-"+e,t.menuId):void 0}function I(e){return 3===e.which||2===e.button}function M(e){e&&e.focus()}function w(e,n){switch(void 0===n&&(n={}),n.type){case"CLICK_MENU_ITEM":case"CLOSE_MENU":return i({},e,{isExpanded:!1,selectionIndex:-1});case"OPEN_MENU_AT_FIRST_ITEM":return i({},e,{isExpanded:!0,selectionIndex:0});case"OPEN_MENU_CLEARED":return i({},e,{isExpanded:!0,selectionIndex:-1});case"SELECT_ITEM_AT_INDEX":return n.payload.index>=0?i({},e,{selectionIndex:null!=n.payload.max?Math.min(Math.max(n.payload.index,0),n.payload.max):Math.max(n.payload.index,0)}):e;case"CLEAR_SELECTION_INDEX":return i({},e,{selectionIndex:-1});case"SET_BUTTON_ID":return i({},e,{buttonId:n.payload});case"SEARCH_FOR_ITEM":return void 0!==n.payload?i({},e,{typeaheadQuery:n.payload}):e;default:return e}}exports.Menu=function(e){var o=e.id,i=e.children,s=n.useRef(null),f=n.useRef(null),E=n.useRef(null),p=a.useDescendantsInit(),v=p[0],x=p[1],_=n.useReducer(w,l),y=_[0],m=_[1],I=r.useId(o),T=o||u.makeId("menu",I),C=n.useRef(!1),h=n.useRef([]),R=n.useRef(!1),b={buttonRef:s,dispatch:m,menuId:T,menuRef:f,popoverRef:E,buttonClickedRef:C,readyToSelect:R,selectCallbacks:h,state:y};return n.useEffect((function(){y.isExpanded?(window.__REACH_DISABLE_TOOLTIPS=!0,window.requestAnimationFrame((function(){M(f.current)}))):window.__REACH_DISABLE_TOOLTIPS=!1}),[y.isExpanded]),n.useEffect((function(){return u.checkStyles("menu-button")}),[]),t.createElement(a.DescendantProvider,{context:c,items:v,set:x},t.createElement(d.Provider,{value:b},u.isFunction(i)?i({isExpanded:y.isExpanded,isOpen:y.isExpanded}):i))},exports.MenuButton=f,exports.MenuItem=p,exports.MenuItems=v,exports.MenuLink=x,exports.MenuList=_,exports.MenuPopover=y,exports.useMenuButtonContext=function(){var e=n.useContext(d).state.isExpanded;return n.useMemo((function(){return{isExpanded:e}}),[e])};
//# sourceMappingURL=menu-button.cjs.production.min.js.map

@@ -781,9 +781,5 @@ import React, { useRef, useReducer, useEffect, useContext, forwardRef, useMemo, useState, useCallback } from 'react';

} else {
var relatedTarget = event.relatedTarget,
target = event.target; // We on want to close only if focus rests outside the menu
// We on want to close only if focus rests outside the menu
if (isExpanded && popoverRef.current) {
var _popoverRef$current;
if (!((_popoverRef$current = popoverRef.current) === null || _popoverRef$current === void 0 ? void 0 : _popoverRef$current.contains(relatedTarget || target))) {
if (!popoverRef.current.contains(event.target)) {
dispatch({

@@ -790,0 +786,0 @@ type: CLOSE_MENU,

{
"name": "@reach/menu-button",
"version": "0.10.4",
"version": "0.10.5",
"description": "Accessible React button dropdown menu.",

@@ -16,6 +16,6 @@ "author": "React Training <hello@reacttraining.com>",

"dependencies": {
"@reach/auto-id": "0.10.4",
"@reach/descendants": "0.10.4",
"@reach/popover": "0.10.4",
"@reach/utils": "0.10.4",
"@reach/auto-id": "0.10.5",
"@reach/descendants": "0.10.5",
"@reach/popover": "0.10.5",
"@reach/utils": "0.10.5",
"prop-types": "^15.7.2",

@@ -36,3 +36,3 @@ "tslib": "^2.0.0"

],
"gitHead": "a0c7b3672835b2a9f84732663bb0e78992541211"
"gitHead": "86a046f54d53b6420e392b3fa56dd991d9d4e458"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc