@reach/menu-button
Advanced tools
Comparing version 0.10.0 to 0.10.1
@@ -119,3 +119,2 @@ /** | ||
export declare const MenuLink: import("@reach/utils").ComponentWithAs<"a", Pick<MenuItemImplProps, "children" | "index" | "valueText"> & { | ||
to?: string | undefined; | ||
onSelect?(): void; | ||
@@ -129,3 +128,2 @@ } & { | ||
export declare type MenuLinkProps = Omit<MenuItemImplProps, "isLink" | "onSelect"> & { | ||
to?: string; | ||
onSelect?(): void; | ||
@@ -132,0 +130,0 @@ }; |
@@ -54,2 +54,3 @@ 'use strict'; | ||
var OPEN_MENU_AT_FIRST_ITEM = "OPEN_MENU_AT_FIRST_ITEM"; | ||
var OPEN_MENU_CLEARED = "OPEN_MENU_CLEARED"; | ||
var SEARCH_FOR_ITEM = "SEARCH_FOR_ITEM"; | ||
@@ -236,3 +237,3 @@ var SELECT_ITEM_AT_INDEX = "SELECT_ITEM_AT_INDEX"; | ||
dispatch({ | ||
type: OPEN_MENU_AT_FIRST_ITEM | ||
type: OPEN_MENU_CLEARED | ||
}); | ||
@@ -895,2 +896,8 @@ } | ||
case OPEN_MENU_CLEARED: | ||
return _extends({}, state, { | ||
isExpanded: true, | ||
selectionIndex: -1 | ||
}); | ||
case SELECT_ITEM_AT_INDEX: | ||
@@ -897,0 +904,0 @@ if (action.payload.index >= 0) { |
@@ -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"]),p=n.useContext(d),E=p.buttonRef,v=p.buttonClickedRef,x=p.menuId,_=p.state,m=_.buttonId,y=_.isExpanded,M=p.dispatch,w=u.useForkedRef(E,r);return n.useEffect((function(){var e=null!=l?l:x?u.makeId("menu-button",x):"menu-button";m!==e&&M({type:"SET_BUTTON_ID",payload:e})}),[m,M,l,x]),t.createElement(a,Object.assign({"aria-expanded":!!y||void 0,"aria-haspopup":!0,"aria-controls":x},f,{ref:w,"data-reach-menu-button":"",id:m||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){y||(v.current=!0),I(e.nativeEvent)||M(y?{type:"CLOSE_MENU",payload:{buttonRef:E}}:{type:"OPEN_MENU_AT_FIRST_ITEM"})})),type:"button"}))})),p=u.forwardRefWithAs((function(e,r){var o=e.as,i=e.index,l=e.isLink,f=void 0!==l&&l,p=e.onClick,E=e.onDragStart,v=e.onMouseDown,x=e.onMouseEnter,_=e.onMouseLeave,m=e.onMouseMove,w=e.onMouseUp,T=e.onSelect,h=e.valueText,C=s(e,["as","index","isLink","onClick","onDragStart","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseUp","onSelect","valueText"]),b=n.useContext(d),R=b.buttonRef,D=b.dispatch,k=b.selectCallbacks,L=b.state.selectionIndex,S=n.useRef(null),O=n.useState(h||""),N=O[0],A=O[1],g=n.useCallback((function(e){e&&(S.current=e,(!h||e.textContent&&N!==e.textContent)&&A(e.textContent))}),[N,h]),U=u.useForkedRef(r,g),P=n.useRef(!1),j=a.useDescendant({context:c,element:S.current,key:N,isLink:f},i),F=j===L;function K(){M(R.current),T&&T(),D({type:"CLICK_MENU_ITEM"})}return k.current[j]=T,n.useEffect((function(){var e=u.getOwnerDocument(S.current)||document,n=function(){return P.current=!1};return e.addEventListener("mouseup",n),function(){return e.removeEventListener("mouseup",n)}}),[]),t.createElement(o,Object.assign({role:"menuitem",id:y(j),tabIndex:-1},C,{ref:U,"data-reach-menu-item":"","data-selected":F?"":void 0,"data-valuetext":N,onClick:u.wrapEvent(p,(function(e){f&&!I(e.nativeEvent)&&K()})),onDragStart:u.wrapEvent(E,(function(e){f&&e.preventDefault()})),onMouseDown:u.wrapEvent(v,(function(e){I(e.nativeEvent)||(f?P.current=!0:e.preventDefault())})),onMouseEnter:u.wrapEvent(x,(function(e){F||null==j||D({type:"SELECT_ITEM_AT_INDEX",payload:{index:j}})})),onMouseLeave:u.wrapEvent(_,(function(e){D({type:"CLEAR_SELECTION_INDEX"})})),onMouseMove:u.wrapEvent(m,(function(e){F||null==j||D({type:"SELECT_ITEM_AT_INDEX",payload:{index:j}})})),onMouseUp:u.wrapEvent(w,(function(e){I(e.nativeEvent)||(f?P.current?P.current=!1:S.current&&S.current.click():K())}))}))})),E=u.forwardRefWithAs((function(e,n){var r=e.as,o=void 0===r?"div":r,a=s(e,["as"]);return t.createElement(p,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,p=s(e,["as","children","id","onKeyDown"]),E=n.useContext(d),v=E.menuId,x=E.dispatch,_=E.buttonRef,m=E.menuRef,I=E.selectCallbacks,w=E.state,T=w.isExpanded,h=w.buttonId,C=w.selectionIndex,b=w.typeaheadQuery,R=n.useContext(c).descendants,D=u.useForkedRef(m,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}(R,b);b&&null!=e&&x({type:"SELECT_ITEM_AT_INDEX",payload:{index:e}});var n=window.setTimeout((function(){return b&&x({type:"SEARCH_FOR_ITEM",payload:""})}),1e3);return function(){return window.clearTimeout(n)}}),[x,R,b]);var k=u.usePrevious(R.length),L=u.usePrevious(R[C]),S=u.usePrevious(C);n.useEffect((function(){C>R.length-1?x({type:"SELECT_ITEM_AT_INDEX",payload:{index:R.length-1}}):k!==R.length&&C>-1&&L&&S===C&&R[C]!==L&&x({type:"SELECT_ITEM_AT_INDEX",payload:{index:R.findIndex((function(e){return e.key===L.key}))}})}),[x,R,k,L,S,C]);var O=u.wrapEvent((function(e){var n=e.key;if(T)switch(n){case"Enter":case" ":var t=R.find((function(e){return e.index===C}));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=b+n.toLowerCase();x({type:"SEARCH_FOR_ITEM",payload:r})}}}),a.useDescendantKeyDown(c,{currentIndex:C,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":y(C)||void 0,"aria-labelledby":h||void 0,role:"menu",tabIndex:-1},p,{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(p,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(m,{portal:o},t.createElement(v,Object.assign({},a,{ref:n,"data-reach-menu-list":""})))})),m=n.forwardRef((function(e,r){var a=e.children,c=e.portal,l=void 0===c||c,f=e.position,p=s(e,["children","portal","position"]),E=n.useContext(d),v=E.buttonRef,x=E.buttonClickedRef,_=E.dispatch,m=E.menuRef,y=E.popoverRef,I=E.state.isExpanded,M=u.useForkedRef(y,r);n.useEffect((function(){function e(e){var n;x.current?x.current=!1:I&&y.current&&((null===(n=y.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,m,y]);var w=i({ref:M,"data-reach-menu":"","data-reach-menu-popover":"",hidden:!I,children:a},p);return l?t.createElement(o,Object.assign({},w,{targetRef:v,position:f})):t.createElement("div",Object.assign({},w))}));function y(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"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),p=n.useRef(null),E=a.useDescendants(),v=E[0],x=E[1],_=n.useReducer(w,l),m=_[0],y=_[1],I=r.useId(o),T=o||u.makeId("menu",I),h=n.useRef(!1),C=n.useRef([]),b={buttonRef:s,dispatch:y,menuId:T,menuRef:f,popoverRef:p,buttonClickedRef:h,selectCallbacks:C,state:m};return n.useEffect((function(){m.isExpanded?(window.__REACH_DISABLE_TOOLTIPS=!0,window.requestAnimationFrame((function(){M(f.current)}))):window.__REACH_DISABLE_TOOLTIPS=!1}),[m.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:m.isExpanded,isOpen:m.isExpanded}):i))},exports.MenuButton=f,exports.MenuItem=E,exports.MenuItems=v,exports.MenuLink=x,exports.MenuList=_,exports.MenuPopover=m,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,m=_.buttonId,y=_.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";m!==e&&M({type:"SET_BUTTON_ID",payload:e})}),[m,M,l,x]),t.createElement(a,Object.assign({"aria-expanded":!!y||void 0,"aria-haspopup":!0,"aria-controls":x},f,{ref:w,"data-reach-menu-button":"",id:m||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){y||(v.current=!0),I(e.nativeEvent)||M(y?{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,m=e.onMouseMove,w=e.onMouseUp,C=e.onSelect,T=e.valueText,h=s(e,["as","index","isLink","onClick","onDragStart","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseUp","onSelect","valueText"]),b=n.useContext(d),R=b.buttonRef,D=b.dispatch,L=b.selectCallbacks,k=b.state.selectionIndex,O=n.useRef(null),S=n.useState(T||""),N=S[0],A=S[1],g=n.useCallback((function(e){e&&(O.current=e,(!T||e.textContent&&N!==e.textContent)&&A(e.textContent))}),[N,T]),U=u.useForkedRef(r,g),P=n.useRef(!1),j=a.useDescendant({context:c,element:O.current,key:N,isLink:f},i),F=j===k;function K(){M(R.current),C&&C(),D({type:"CLICK_MENU_ITEM"})}return L.current[j]=C,n.useEffect((function(){var e=u.getOwnerDocument(O.current)||document,n=function(){return P.current=!1};return e.addEventListener("mouseup",n),function(){return e.removeEventListener("mouseup",n)}}),[]),t.createElement(o,Object.assign({role:"menuitem",id:y(j),tabIndex:-1},h,{ref:U,"data-reach-menu-item":"","data-selected":F?"":void 0,"data-valuetext":N,onClick:u.wrapEvent(E,(function(e){f&&!I(e.nativeEvent)&&K()})),onDragStart:u.wrapEvent(p,(function(e){f&&e.preventDefault()})),onMouseDown:u.wrapEvent(v,(function(e){I(e.nativeEvent)||(f?P.current=!0:e.preventDefault())})),onMouseEnter:u.wrapEvent(x,(function(e){F||null==j||D({type:"SELECT_ITEM_AT_INDEX",payload:{index:j}})})),onMouseLeave:u.wrapEvent(_,(function(e){D({type:"CLEAR_SELECTION_INDEX"})})),onMouseMove:u.wrapEvent(m,(function(e){F||null==j||D({type:"SELECT_ITEM_AT_INDEX",payload:{index:j}})})),onMouseUp:u.wrapEvent(w,(function(e){I(e.nativeEvent)||(f?P.current?P.current=!1:O.current&&O.current.click():K())}))}))})),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,m=p.menuRef,I=p.selectCallbacks,w=p.state,C=w.isExpanded,T=w.buttonId,h=w.selectionIndex,b=w.typeaheadQuery,R=n.useContext(c).descendants,D=u.useForkedRef(m,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}(R,b);b&&null!=e&&x({type:"SELECT_ITEM_AT_INDEX",payload:{index:e}});var n=window.setTimeout((function(){return b&&x({type:"SEARCH_FOR_ITEM",payload:""})}),1e3);return function(){return window.clearTimeout(n)}}),[x,R,b]);var L=u.usePrevious(R.length),k=u.usePrevious(R[h]),O=u.usePrevious(h);n.useEffect((function(){h>R.length-1?x({type:"SELECT_ITEM_AT_INDEX",payload:{index:R.length-1}}):L!==R.length&&h>-1&&k&&O===h&&R[h]!==k&&x({type:"SELECT_ITEM_AT_INDEX",payload:{index:R.findIndex((function(e){return e.key===k.key}))}})}),[x,R,L,k,O,h]);var S=u.wrapEvent((function(e){var n=e.key;if(C)switch(n){case"Enter":case" ":var t=R.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=b+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":y(h)||void 0,"aria-labelledby":T||void 0,role:"menu",tabIndex:-1},E,{ref:D,"data-reach-menu-items":"",id:v,onKeyDown:u.wrapEvent(f,S)}),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(m,{portal:o},t.createElement(v,Object.assign({},a,{ref:n,"data-reach-menu-list":""})))})),m=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,m=p.menuRef,y=p.popoverRef,I=p.state.isExpanded,M=u.useForkedRef(y,r);n.useEffect((function(){function e(e){var n;x.current?x.current=!1:I&&y.current&&((null===(n=y.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,m,y]);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 y(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.useDescendants(),v=p[0],x=p[1],_=n.useReducer(w,l),m=_[0],y=_[1],I=r.useId(o),C=o||u.makeId("menu",I),T=n.useRef(!1),h=n.useRef([]),b={buttonRef:s,dispatch:y,menuId:C,menuRef:f,popoverRef:E,buttonClickedRef:T,selectCallbacks:h,state:m};return n.useEffect((function(){m.isExpanded?(window.__REACH_DISABLE_TOOLTIPS=!0,window.requestAnimationFrame((function(){M(f.current)}))):window.__REACH_DISABLE_TOOLTIPS=!1}),[m.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:m.isExpanded,isOpen:m.isExpanded}):i))},exports.MenuButton=f,exports.MenuItem=p,exports.MenuItems=v,exports.MenuLink=x,exports.MenuList=_,exports.MenuPopover=m,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 |
@@ -47,2 +47,3 @@ import React, { useRef, useReducer, useEffect, useContext, forwardRef, useMemo, useState, useCallback } from 'react'; | ||
var OPEN_MENU_AT_FIRST_ITEM = "OPEN_MENU_AT_FIRST_ITEM"; | ||
var OPEN_MENU_CLEARED = "OPEN_MENU_CLEARED"; | ||
var SEARCH_FOR_ITEM = "SEARCH_FOR_ITEM"; | ||
@@ -229,3 +230,3 @@ var SELECT_ITEM_AT_INDEX = "SELECT_ITEM_AT_INDEX"; | ||
dispatch({ | ||
type: OPEN_MENU_AT_FIRST_ITEM | ||
type: OPEN_MENU_CLEARED | ||
}); | ||
@@ -888,2 +889,8 @@ } | ||
case OPEN_MENU_CLEARED: | ||
return _extends({}, state, { | ||
isExpanded: true, | ||
selectionIndex: -1 | ||
}); | ||
case SELECT_ITEM_AT_INDEX: | ||
@@ -890,0 +897,0 @@ if (action.payload.index >= 0) { |
{ | ||
"name": "@reach/menu-button", | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"description": "Accessible React button dropdown menu.", | ||
@@ -16,9 +16,8 @@ "author": "React Training <hello@reacttraining.com>", | ||
"dependencies": { | ||
"@reach/auto-id": "^0.10.0", | ||
"@reach/descendants": "^0.10.0", | ||
"@reach/popover": "^0.10.0", | ||
"@reach/utils": "^0.10.0", | ||
"@reach/auto-id": "^0.10.1", | ||
"@reach/descendants": "^0.10.1", | ||
"@reach/popover": "^0.10.1", | ||
"@reach/utils": "^0.10.1", | ||
"prop-types": "^15.7.2", | ||
"tslib": "^1.10.0", | ||
"warning": "^4.0.3" | ||
"tslib": "^1.11.1" | ||
}, | ||
@@ -37,3 +36,3 @@ "peerDependencies": { | ||
], | ||
"gitHead": "e95268bdcebc7f0b5311beff4b6a8e29636decfe" | ||
"gitHead": "c279bc0fb9ae84aa77306c5f1a9909d088bc665c" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
225854
8
1936
- Removedwarning@^4.0.3
Updated@reach/auto-id@^0.10.1
Updated@reach/descendants@^0.10.1
Updated@reach/popover@^0.10.1
Updated@reach/utils@^0.10.1
Updatedtslib@^1.11.1