Socket
Socket
Sign inDemoInstall

react-aria-menubutton

Package Overview
Dependencies
10
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.1 to 6.1.0

4

CHANGELOG.md
# Changelog
## 6.1.0
- Add `closeOnBlur` prop.
## 6.0.1

@@ -4,0 +8,0 @@

11

dist/Button.js

@@ -21,3 +21,3 @@ 'use strict';

var disabledSupportedTags = function disabledSupportedTags() {
return ["button", "fieldset", "input", "optgroup", "option", "select", "textarea"];
return ['button', 'fieldset', 'input', 'optgroup', 'option', 'select', 'textarea'];
};

@@ -79,2 +79,3 @@

var props = this.props;
var ambManager = this.context.ambManager;

@@ -87,7 +88,6 @@ var buttonProps = {

'aria-haspopup': true,
'aria-expanded': this.context.ambManager.isOpen,
'aria-expanded': ambManager.isOpen,
'aria-disabled': props.disabled,
onKeyDown: this.handleKeyDown,
onClick: this.handleClick,
onBlur: this.context.ambManager.handleBlur
onClick: this.handleClick
};

@@ -103,2 +103,5 @@

}
if (ambManager.options.closeOnBlur) {
buttonProps.onBlur = ambManager.handleBlur;
}
specialAssign(buttonProps, props, reserved);

@@ -105,0 +108,0 @@

@@ -20,2 +20,6 @@ 'use strict';

if (typeof this.options.closeOnBlur === 'undefined') {
this.options.closeOnBlur = true;
}
if (this.options.id) {

@@ -22,0 +26,0 @@ externalStateControl.registerManager(this.options.id, this);

@@ -53,2 +53,3 @@ 'use strict';

var ambManager = this.context.ambManager;
if (!ambManager.options.closeOnBlur) return;
if (ambManager.isOpen && !this.tapListener) {

@@ -90,6 +91,9 @@ this.addTapListener();

role: 'menu',
onBlur: ambManager.handleBlur,
tabIndex: -1
};
if (ambManager.options.closeOnBlur) {
menuProps.onBlur = ambManager.handleBlur;
}
specialAssign(menuProps, props, checkedProps);

@@ -96,0 +100,0 @@

@@ -19,2 +19,3 @@ 'use strict';

closeOnSelection: PropTypes.bool,
closeOnBlur: PropTypes.bool,
tag: PropTypes.string

@@ -43,2 +44,3 @@ };

closeOnSelection: this.props.closeOnSelection,
closeOnBlur: this.props.closeOnBlur,
id: this.props.id

@@ -45,0 +47,0 @@ });

{
"name": "react-aria-menubutton",
"version": "6.0.1",
"version": "6.1.0",
"description": "A fully accessible and flexible React-powered menu button",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -279,2 +279,4 @@ # react-aria-menubutton [![Build Status](https://travis-ci.org/davidtheclark/react-aria-menubutton.svg?branch=master)](https://travis-ci.org/davidtheclark/react-aria-menubutton)

**closeOnBlur** { Boolean }: By default, it *does* automatically close. If `false`, the menu will *not* automatically close when it blurs. Default: `true`.
**tag** { String }: The HTML tag for this element. Default: `'div'`.

@@ -281,0 +283,0 @@

@@ -9,2 +9,3 @@ const React = require('react');

const createMockManager = require('./helpers/createMockManager');
const createManager = require('../createManager');

@@ -39,2 +40,9 @@ const el = React.createElement;

test('no onBlur prop when closeOnBlur is false', function() {
const manager = createManager({ closeOnBlur: false });
const shallowOptions = { context: { ambManager: manager } };
const wrapper = shallow(el(Button, null, ''), shallowOptions);
expect(shallowToJson(wrapper).props).not.toHaveProperty('onBlur');
});
test('DOM with all possible props and element child', function() {

@@ -74,3 +82,3 @@ const button = el(

test('element have disabled attribute when disabled property is set to true', function() {
test('element has disabled attribute when disabled property is set to true', function() {
const wrapper = shallow(

@@ -77,0 +85,0 @@ el(Button, { disabled: true, tag: 'button' }, 'foo'),

@@ -43,2 +43,3 @@ /* globals Promise */

expect(manager.options.closeOnSelection).toBeTruthy();
expect(manager.options.closeOnBlur).toBeTruthy();
});

@@ -45,0 +46,0 @@

@@ -17,3 +17,7 @@ module.exports = function() {

addItem: jest.fn(),
options: {
closeOnBlur: true,
closeOnSelection: true
}
};
}

@@ -9,2 +9,3 @@ const React = require('react');

const createMockManager = require('./helpers/createMockManager');
const createManager = require('../createManager');

@@ -30,2 +31,11 @@ const el = React.createElement;

test('no onBlur prop when closeOnBlur is false', function() {
const ambManager = createManager({ closeOnBlur: false });
ambManager.isOpen = true;
const shallowOptions = { context: { ambManager: ambManager } };
const menuEl = el(Menu, null, el('div', null, 'foo'));
const wrapper = shallow(menuEl, shallowOptions);
expect(shallowToJson(wrapper).props).not.toHaveProperty('onBlur');
});
test('open Menu DOM with only required props and element child', function() {

@@ -32,0 +42,0 @@ ambManager.isOpen = true;

@@ -13,9 +13,9 @@ const React = require('react');

const disabledSupportedTags = () => [
"button",
"fieldset",
"input",
"optgroup",
"option",
"select",
"textarea"
'button',
'fieldset',
'input',
'optgroup',
'option',
'select',
'textarea'
];

@@ -75,2 +75,3 @@

const props = this.props;
const ambManager = this.context.ambManager;

@@ -83,7 +84,6 @@ const buttonProps = {

'aria-haspopup': true,
'aria-expanded': this.context.ambManager.isOpen,
'aria-expanded': ambManager.isOpen,
'aria-disabled': props.disabled,
onKeyDown: this.handleKeyDown,
onClick: this.handleClick,
onBlur: this.context.ambManager.handleBlur
onClick: this.handleClick
};

@@ -99,2 +99,5 @@

}
if (ambManager.options.closeOnBlur) {
buttonProps.onBlur = ambManager.handleBlur;
}
specialAssign(buttonProps, props, reserved);

@@ -101,0 +104,0 @@

@@ -18,2 +18,6 @@ const ReactDOM = require('react-dom');

if (typeof this.options.closeOnBlur === 'undefined') {
this.options.closeOnBlur = true;
}
if (this.options.id) {

@@ -102,4 +106,4 @@ externalStateControl.registerManager(this.options.id, this);

toggleMenu(closeOptions, openOptions) {
closeOptions = closeOptions || {}
openOptions = openOptions || {}
closeOptions = closeOptions || {};
openOptions = openOptions || {};
if (this.isOpen) {

@@ -106,0 +110,0 @@ this.closeMenu(closeOptions);

@@ -26,2 +26,3 @@ const React = require('react');

const ambManager = this.context.ambManager;
if (!ambManager.options.closeOnBlur) return;
if (ambManager.isOpen && !this.tapListener) {

@@ -82,6 +83,9 @@ this.addTapListener();

role: 'menu',
onBlur: ambManager.handleBlur,
tabIndex: -1
};
if (ambManager.options.closeOnBlur) {
menuProps.onBlur = ambManager.handleBlur;
}
specialAssign(menuProps, props, checkedProps);

@@ -88,0 +92,0 @@

@@ -11,2 +11,3 @@ const React = require('react');

closeOnSelection: PropTypes.bool,
closeOnBlur: PropTypes.bool,
tag: PropTypes.string

@@ -34,2 +35,3 @@ };

closeOnSelection: this.props.closeOnSelection,
closeOnBlur: this.props.closeOnBlur,
id: this.props.id

@@ -36,0 +38,0 @@ });

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports.ReactAriaMenuButton=t(require("react"),require("react-dom")):e.ReactAriaMenuButton=t(e.React,e.ReactDOM)}(window,function(e,t){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=16)}([function(e,t,n){"use strict";e.exports=function(e,t,n){for(var o in n=n||{},t)t.hasOwnProperty(o)&&(n[o]||(e[o]=t[o]))}},function(e,t,n){e.exports=n(14)()},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";var o={},r="a menu outside a mounted Wrapper with an id, or a menu that does not exist";e.exports={registerManager:function(e,t){o[e]=t},unregisterManager:function(e){delete o[e]},openMenu:function(e,t){var n=o[e];if(!n)throw new Error("Cannot open "+r);n.openMenu(t)},closeMenu:function(e,t){var n=o[e];if(!n)throw new Error("Cannot close "+r);n.closeMenu(t)}}},function(e,t,n){"use strict";function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var r=n(2),i=n(1),s=n(0),c={children:i.node.isRequired,tag:i.string,text:i.string,value:i.any},u=function(e){function t(){var n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,s=Array(i),c=0;c<i;c++)s[c]=arguments[c];return n=r=o(this,e.call.apply(e,[this].concat(s))),r.handleKeyDown=function(e){"Enter"!==e.key&&" "!==e.key||"a"===r.props.tag&&r.props.href||(e.preventDefault(),r.selectItem(e))},r.selectItem=function(e){var t=void 0!==r.props.value?r.props.value:r.props.children;r.context.ambManager.handleSelection(t,e)},r.registerNode=function(e){r.node=e},o(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.componentDidMount=function(){this.context.ambManager.addItem({node:this.node,text:this.props.text})},t.prototype.render=function(){var e={onClick:this.selectItem,onKeyDown:this.handleKeyDown,role:"menuitem",tabIndex:"-1",ref:this.registerNode};return s(e,this.props,c),r.createElement(this.props.tag,e,this.props.children)},t}(r.Component);u.propTypes=c,u.defaultProps={tag:"div"},u.contextTypes={ambManager:i.object.isRequired},e.exports=u},function(e,t){e.exports=function(e,t,n){var o=0,r=0,i=!1,s=!1,c=!1;function u(e){c||t(e)}function a(t){c=!0,i||(i=!0,e.addEventListener("touchmove",p,n),e.addEventListener("touchend",f,n),e.addEventListener("touchcancel",h,n),s=!1,o=t.touches[0].clientX,r=t.touches[0].clientY)}function p(e){s||Math.abs(e.touches[0].clientX-o)<=10&&Math.abs(e.touches[0].clientY-r)<=10||(s=!0)}function f(e){i=!1,l(),s||t(e)}function h(){i=!1,s=!1,o=0,r=0}function l(){e.removeEventListener("touchmove",p,n),e.removeEventListener("touchend",f,n),e.removeEventListener("touchcancel",h,n)}return e.addEventListener("click",u,n),e.addEventListener("touchstart",a,n),{remove:function(){e.removeEventListener("click",u,n),e.removeEventListener("touchstart",a,n),l()}}}},function(e,t,n){"use strict";var o,r;function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var s=n(2),c=n(3),u=n(1),a=n(6),p=n(0),f={children:u.oneOfType([u.func,u.node]).isRequired,tag:u.string};e.exports=(r=o=function(e){function t(){var n,o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var r=arguments.length,s=Array(r),u=0;u<r;u++)s[u]=arguments[u];return n=o=i(this,e.call.apply(e,[this].concat(s))),o.addTapListener=function(){var e=c.findDOMNode(o);if(e){var t=e.ownerDocument;t&&(o.tapListener=a(t.documentElement,o.handleTap))}},o.handleTap=function(e){c.findDOMNode(o).contains(e.target)||c.findDOMNode(o.context.ambManager.button).contains(e.target)||o.context.ambManager.closeMenu()},i(o,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.componentWillMount=function(){this.context.ambManager.menu=this},t.prototype.componentDidUpdate=function(){var e=this.context.ambManager;e.isOpen&&!this.tapListener?this.addTapListener():!e.isOpen&&this.tapListener&&(this.tapListener.remove(),delete this.tapListener),e.isOpen||e.clearItems()},t.prototype.componentWillUnmount=function(){this.tapListener&&this.tapListener.remove(),this.context.ambManager.destroy()},t.prototype.render=function(){var e=this.props,t=this.context.ambManager,n="function"==typeof e.children?e.children({isOpen:t.isOpen}):!!t.isOpen&&e.children;if(!n)return!1;var o={onKeyDown:t.handleMenuKey,role:"menu",onBlur:t.handleBlur,tabIndex:-1};return p(o,e,f),s.createElement(e.tag,o,n)},t}(s.Component),o.propTypes=f,o.defaultProps={tag:"div"},o.contextTypes={ambManager:u.object.isRequired},r)},function(e,t,n){"use strict";function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var r=n(2),i=n(1),s=n(0),c={children:i.node.isRequired,disabled:i.bool,tag:i.string},u=function(e){function t(){var n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,s=Array(i),c=0;c<i;c++)s[c]=arguments[c];return n=r=o(this,e.call.apply(e,[this].concat(s))),r.handleKeyDown=function(e){if(!r.props.disabled){var t=r.context.ambManager;switch(e.key){case"ArrowDown":e.preventDefault(),t.isOpen?t.focusItem(0):t.openMenu();break;case"Enter":case" ":e.preventDefault(),t.toggleMenu();break;case"Escape":t.handleMenuKey(e);break;default:t.handleButtonNonArrowKey(e)}}},r.handleClick=function(){r.props.disabled||r.context.ambManager.toggleMenu({},{focusMenu:!1})},o(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.componentWillMount=function(){this.context.ambManager.button=this},t.prototype.componentWillUnmount=function(){this.context.ambManager.destroy()},t.prototype.render=function(){var e=this.props,t={role:"button",tabIndex:e.disabled?"":"0","aria-haspopup":!0,"aria-expanded":this.context.ambManager.isOpen,"aria-disabled":e.disabled,onKeyDown:this.handleKeyDown,onClick:this.handleClick,onBlur:this.context.ambManager.handleBlur},n={};return s(n,c),["button","fieldset","input","optgroup","option","select","textarea"].indexOf(e.tag)>=0&&delete n.disabled,s(t,e,n),r.createElement(e.tag,t,e.children)},t}(r.Component);u.propTypes=c,u.contextTypes={ambManager:i.object.isRequired},u.defaultProps={tag:"span"},e.exports=u},function(e,t){function n(e){var t,n,o=(e=e||{}).keybindings||{};for(t in this._settings={keybindings:{next:o.next||{keyCode:40},prev:o.prev||{keyCode:38},first:o.first,last:o.last},wrap:e.wrap,stringSearch:e.stringSearch,stringSearchDelay:800},this._keybindingsLookup=[],this._settings.keybindings)(n=this._settings.keybindings[t])&&[].concat(n).forEach(function(e){e.metaKey=e.metaKey||!1,e.ctrlKey=e.ctrlKey||!1,e.altKey=e.altKey||!1,e.shiftKey=e.shiftKey||!1,this._keybindingsLookup.push({action:t,eventMatcher:e})}.bind(this));this._searchString="",this._members=[],e.members&&this.setMembers(e.members),this._boundHandleKeydownEvent=this._handleKeydownEvent.bind(this)}function o(e){e&&e.focus&&(e.focus(),"input"===e.tagName.toLowerCase()&&e.select())}n.prototype.activate=function(){return document.addEventListener("keydown",this._boundHandleKeydownEvent,!0),this},n.prototype.deactivate=function(){return document.removeEventListener("keydown",this._boundHandleKeydownEvent,!0),this._clearSearchStringRefreshTimer(),this},n.prototype._handleKeydownEvent=function(e){if(-1!==this._getActiveElementIndex()){var t=!1;this._keybindingsLookup.forEach(function(n){if(function(e,t){for(var n in e)if(void 0!==t[n]&&e[n]!==t[n])return!1;return!0}(n.eventMatcher,e))switch(t=!0,e.preventDefault(),n.action){case"next":this.moveFocusForward();break;case"prev":this.moveFocusBack();break;case"first":this.moveFocusToFirst();break;case"last":this.moveFocusToLast();break;default:return}}.bind(this)),t||this._handleUnboundKey(e)}},n.prototype.moveFocusForward=function(){var e,t=this._getActiveElementIndex();return e=t<this._members.length-1?t+1:this._settings.wrap?0:t,this.focusNodeAtIndex(e),e},n.prototype.moveFocusBack=function(){var e,t=this._getActiveElementIndex();return e=t>0?t-1:this._settings.wrap?this._members.length-1:t,this.focusNodeAtIndex(e),e},n.prototype.moveFocusToFirst=function(){this.focusNodeAtIndex(0)},n.prototype.moveFocusToLast=function(){this.focusNodeAtIndex(this._members.length-1)},n.prototype._handleUnboundKey=function(e){if(this._settings.stringSearch){if(""!==this._searchString&&(" "===e.key||32===e.keyCode))return e.preventDefault(),-1;if(!function(e){return e>=65&&e<=90}(e.keyCode))return-1;if(e.ctrlKey||e.metaKey||e.altKey)return-1;e.preventDefault(),this._addToSearchString(String.fromCharCode(e.keyCode)),this._runStringSearch()}},n.prototype._clearSearchString=function(){this._searchString=""},n.prototype._addToSearchString=function(e){this._searchString+=e.toLowerCase()},n.prototype._startSearchStringRefreshTimer=function(){var e=this;this._clearSearchStringRefreshTimer(),this._stringSearchTimer=setTimeout(function(){e._clearSearchString()},this._settings.stringSearchDelay)},n.prototype._clearSearchStringRefreshTimer=function(){clearTimeout(this._stringSearchTimer)},n.prototype._runStringSearch=function(){this._startSearchStringRefreshTimer(),this.moveFocusByString(this._searchString)},n.prototype.moveFocusByString=function(e){for(var t,n=0,r=this._members.length;n<r;n++)if((t=this._members[n]).text&&0===t.text.indexOf(e))return o(t.node)},n.prototype._findIndexOfNode=function(e){for(var t=0,n=this._members.length;t<n;t++)if(this._members[t].node===e)return t;return-1},n.prototype._getActiveElementIndex=function(){return this._findIndexOfNode(document.activeElement)},n.prototype.focusNodeAtIndex=function(e){var t=this._members[e];return t&&o(t.node),this},n.prototype.addMember=function(e,t){var n=e.node||e,o=e.text||n.getAttribute("data-focus-group-text")||n.textContent||"";this._checkNode(n);var r={node:n,text:o.replace(/[\W_]/g,"").toLowerCase()};return null!==t&&void 0!==t?this._members.splice(t,0,r):this._members.push(r),this},n.prototype.removeMember=function(e){var t="number"==typeof e?e:this._findIndexOfNode(e);if(-1!==t)return this._members.splice(t,1),this},n.prototype.clearMembers=function(){return this._members=[],this},n.prototype.setMembers=function(e){this.clearMembers();for(var t=0,n=e.length;t<n;t++)this.addMember(e[t]);return this},n.prototype.getMembers=function(){return this._members},n.prototype._checkNode=function(e){if(!e.nodeType||e.nodeType!==window.Node.ELEMENT_NODE)throw new Error("focus-group: only DOM nodes allowed");return e},e.exports=function(e){return new n(e)}},function(e,t,n){"use strict";var o=n(3),r=n(9),i=n(4),s={wrap:!0,stringSearch:!0},c={init:function(e){this.options=e||{},void 0===this.options.closeOnSelection&&(this.options.closeOnSelection=!0),this.options.id&&i.registerManager(this.options.id,this),this.handleBlur=function(){var e=this;e.blurTimer=setTimeout(function(){var t=o.findDOMNode(e.button);if(t){var n=t.ownerDocument.activeElement;if(!t||n!==t){var r=o.findDOMNode(e.menu);r!==n?r&&r.contains(n)||e.isOpen&&e.closeMenu({focusButton:!1}):e.focusItem(0)}}},0)}.bind(this),this.handleSelection=function(e,t){this.options.closeOnSelection&&this.closeMenu({focusButton:!0});this.options.onSelection&&this.options.onSelection(e,t)}.bind(this),this.handleMenuKey=function(e){this.isOpen&&"Escape"===e.key&&(e.preventDefault(),this.closeMenu({focusButton:!0}))}.bind(this),this.focusGroup=r(s),this.button=null,this.menu=null,this.isOpen=!1},focusItem:function(e){this.focusGroup.focusNodeAtIndex(e)},addItem:function(e){this.focusGroup.addMember(e)},clearItems:function(){this.focusGroup.clearMembers()},handleButtonNonArrowKey:function(e){this.focusGroup._handleUnboundKey(e)},destroy:function(){this.button=null,this.menu=null,this.focusGroup.deactivate(),clearTimeout(this.blurTimer),clearTimeout(this.moveFocusTimer)},update:function(){this.menu.setState({isOpen:this.isOpen}),this.button.setState({menuOpen:this.isOpen}),this.options.onMenuToggle&&this.options.onMenuToggle({isOpen:this.isOpen})},openMenu:function(e){if(!this.isOpen&&(void 0===(e=e||{}).focusMenu&&(e.focusMenu=!0),this.isOpen=!0,this.update(),this.focusGroup.activate(),e.focusMenu)){var t=this;this.moveFocusTimer=setTimeout(function(){t.focusItem(0)},0)}},closeMenu:function(e){this.isOpen&&(e=e||{},this.isOpen=!1,this.update(),e.focusButton&&o.findDOMNode(this.button).focus())},toggleMenu:function(e,t){e=e||{},t=t||{},this.isOpen?this.closeMenu(e):this.openMenu(t)}};e.exports=function(e){var t=Object.create(c);return t.init(e),t}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";var o=function(e){};e.exports=function(e,t,n,r,i,s,c,u){if(o(t),!e){var a;if(void 0===t)a=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var p=[n,r,i,s,c,u],f=0;(a=new Error(t.replace(/%s/g,function(){return p[f++]}))).name="Invariant Violation"}throw a.framesToPop=1,a}}},function(e,t,n){"use strict";function o(e){return function(){return e}}var r=function(){};r.thatReturns=o,r.thatReturnsFalse=o(!1),r.thatReturnsTrue=o(!0),r.thatReturnsNull=o(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";var o=n(13),r=n(12),i=n(11);e.exports=function(){function e(e,t,n,o,s,c){c!==i&&r(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=o,n.PropTypes=n,n}},function(e,t,n){"use strict";var o=n(2),r=n(1),i=n(10),s=n(0),c={children:r.node.isRequired,onMenuToggle:r.func,onSelection:r.func,closeOnSelection:r.bool,tag:r.string},u=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.getChildContext=function(){return{ambManager:this.manager}},t.prototype.componentWillMount=function(){this.manager=i({onMenuToggle:this.props.onMenuToggle,onSelection:this.props.onSelection,closeOnSelection:this.props.closeOnSelection,id:this.props.id})},t.prototype.render=function(){var e={};return s(e,this.props,c),o.createElement(this.props.tag,e,this.props.children)},t}(o.Component);u.propTypes=c,u.defaultProps={tag:"div"},u.childContextTypes={ambManager:r.object},e.exports=u},function(e,t,n){"use strict";var o=n(4);e.exports={Wrapper:n(15),Button:n(8),Menu:n(7),MenuItem:n(5),openMenu:o.openMenu,closeMenu:o.closeMenu}}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports.ReactAriaMenuButton=t(require("react"),require("react-dom")):e.ReactAriaMenuButton=t(e.React,e.ReactDOM)}(window,function(e,t){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=16)}([function(e,t,n){"use strict";e.exports=function(e,t,n){for(var o in n=n||{},t)t.hasOwnProperty(o)&&(n[o]||(e[o]=t[o]))}},function(e,t,n){e.exports=n(14)()},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";var o={},r="a menu outside a mounted Wrapper with an id, or a menu that does not exist";e.exports={registerManager:function(e,t){o[e]=t},unregisterManager:function(e){delete o[e]},openMenu:function(e,t){var n=o[e];if(!n)throw new Error("Cannot open "+r);n.openMenu(t)},closeMenu:function(e,t){var n=o[e];if(!n)throw new Error("Cannot close "+r);n.closeMenu(t)}}},function(e,t,n){"use strict";function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var r=n(2),i=n(1),s=n(0),u={children:i.node.isRequired,tag:i.string,text:i.string,value:i.any},c=function(e){function t(){var n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,s=Array(i),u=0;u<i;u++)s[u]=arguments[u];return n=r=o(this,e.call.apply(e,[this].concat(s))),r.handleKeyDown=function(e){"Enter"!==e.key&&" "!==e.key||"a"===r.props.tag&&r.props.href||(e.preventDefault(),r.selectItem(e))},r.selectItem=function(e){var t=void 0!==r.props.value?r.props.value:r.props.children;r.context.ambManager.handleSelection(t,e)},r.registerNode=function(e){r.node=e},o(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.componentDidMount=function(){this.context.ambManager.addItem({node:this.node,text:this.props.text})},t.prototype.render=function(){var e={onClick:this.selectItem,onKeyDown:this.handleKeyDown,role:"menuitem",tabIndex:"-1",ref:this.registerNode};return s(e,this.props,u),r.createElement(this.props.tag,e,this.props.children)},t}(r.Component);c.propTypes=u,c.defaultProps={tag:"div"},c.contextTypes={ambManager:i.object.isRequired},e.exports=c},function(e,t){e.exports=function(e,t,n){var o=0,r=0,i=!1,s=!1,u=!1;function c(e){u||t(e)}function a(t){u=!0,i||(i=!0,e.addEventListener("touchmove",p,n),e.addEventListener("touchend",f,n),e.addEventListener("touchcancel",l,n),s=!1,o=t.touches[0].clientX,r=t.touches[0].clientY)}function p(e){s||Math.abs(e.touches[0].clientX-o)<=10&&Math.abs(e.touches[0].clientY-r)<=10||(s=!0)}function f(e){i=!1,h(),s||t(e)}function l(){i=!1,s=!1,o=0,r=0}function h(){e.removeEventListener("touchmove",p,n),e.removeEventListener("touchend",f,n),e.removeEventListener("touchcancel",l,n)}return e.addEventListener("click",c,n),e.addEventListener("touchstart",a,n),{remove:function(){e.removeEventListener("click",c,n),e.removeEventListener("touchstart",a,n),h()}}}},function(e,t,n){"use strict";var o,r;function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var s=n(2),u=n(3),c=n(1),a=n(6),p=n(0),f={children:c.oneOfType([c.func,c.node]).isRequired,tag:c.string};e.exports=(r=o=function(e){function t(){var n,o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var r=arguments.length,s=Array(r),c=0;c<r;c++)s[c]=arguments[c];return n=o=i(this,e.call.apply(e,[this].concat(s))),o.addTapListener=function(){var e=u.findDOMNode(o);if(e){var t=e.ownerDocument;t&&(o.tapListener=a(t.documentElement,o.handleTap))}},o.handleTap=function(e){u.findDOMNode(o).contains(e.target)||u.findDOMNode(o.context.ambManager.button).contains(e.target)||o.context.ambManager.closeMenu()},i(o,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.componentWillMount=function(){this.context.ambManager.menu=this},t.prototype.componentDidUpdate=function(){var e=this.context.ambManager;e.options.closeOnBlur&&(e.isOpen&&!this.tapListener?this.addTapListener():!e.isOpen&&this.tapListener&&(this.tapListener.remove(),delete this.tapListener),e.isOpen||e.clearItems())},t.prototype.componentWillUnmount=function(){this.tapListener&&this.tapListener.remove(),this.context.ambManager.destroy()},t.prototype.render=function(){var e=this.props,t=this.context.ambManager,n="function"==typeof e.children?e.children({isOpen:t.isOpen}):!!t.isOpen&&e.children;if(!n)return!1;var o={onKeyDown:t.handleMenuKey,role:"menu",tabIndex:-1};return t.options.closeOnBlur&&(o.onBlur=t.handleBlur),p(o,e,f),s.createElement(e.tag,o,n)},t}(s.Component),o.propTypes=f,o.defaultProps={tag:"div"},o.contextTypes={ambManager:c.object.isRequired},r)},function(e,t,n){"use strict";function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var r=n(2),i=n(1),s=n(0),u={children:i.node.isRequired,disabled:i.bool,tag:i.string},c=function(e){function t(){var n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,s=Array(i),u=0;u<i;u++)s[u]=arguments[u];return n=r=o(this,e.call.apply(e,[this].concat(s))),r.handleKeyDown=function(e){if(!r.props.disabled){var t=r.context.ambManager;switch(e.key){case"ArrowDown":e.preventDefault(),t.isOpen?t.focusItem(0):t.openMenu();break;case"Enter":case" ":e.preventDefault(),t.toggleMenu();break;case"Escape":t.handleMenuKey(e);break;default:t.handleButtonNonArrowKey(e)}}},r.handleClick=function(){r.props.disabled||r.context.ambManager.toggleMenu({},{focusMenu:!1})},o(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.componentWillMount=function(){this.context.ambManager.button=this},t.prototype.componentWillUnmount=function(){this.context.ambManager.destroy()},t.prototype.render=function(){var e=this.props,t=this.context.ambManager,n={role:"button",tabIndex:e.disabled?"":"0","aria-haspopup":!0,"aria-expanded":t.isOpen,"aria-disabled":e.disabled,onKeyDown:this.handleKeyDown,onClick:this.handleClick},o={};return s(o,u),["button","fieldset","input","optgroup","option","select","textarea"].indexOf(e.tag)>=0&&delete o.disabled,t.options.closeOnBlur&&(n.onBlur=t.handleBlur),s(n,e,o),r.createElement(e.tag,n,e.children)},t}(r.Component);c.propTypes=u,c.contextTypes={ambManager:i.object.isRequired},c.defaultProps={tag:"span"},e.exports=c},function(e,t){function n(e){var t,n,o=(e=e||{}).keybindings||{};for(t in this._settings={keybindings:{next:o.next||{keyCode:40},prev:o.prev||{keyCode:38},first:o.first,last:o.last},wrap:e.wrap,stringSearch:e.stringSearch,stringSearchDelay:800},this._keybindingsLookup=[],this._settings.keybindings)(n=this._settings.keybindings[t])&&[].concat(n).forEach(function(e){e.metaKey=e.metaKey||!1,e.ctrlKey=e.ctrlKey||!1,e.altKey=e.altKey||!1,e.shiftKey=e.shiftKey||!1,this._keybindingsLookup.push({action:t,eventMatcher:e})}.bind(this));this._searchString="",this._members=[],e.members&&this.setMembers(e.members),this._boundHandleKeydownEvent=this._handleKeydownEvent.bind(this)}function o(e){e&&e.focus&&(e.focus(),"input"===e.tagName.toLowerCase()&&e.select())}n.prototype.activate=function(){return document.addEventListener("keydown",this._boundHandleKeydownEvent,!0),this},n.prototype.deactivate=function(){return document.removeEventListener("keydown",this._boundHandleKeydownEvent,!0),this._clearSearchStringRefreshTimer(),this},n.prototype._handleKeydownEvent=function(e){if(-1!==this._getActiveElementIndex()){var t=!1;this._keybindingsLookup.forEach(function(n){if(function(e,t){for(var n in e)if(void 0!==t[n]&&e[n]!==t[n])return!1;return!0}(n.eventMatcher,e))switch(t=!0,e.preventDefault(),n.action){case"next":this.moveFocusForward();break;case"prev":this.moveFocusBack();break;case"first":this.moveFocusToFirst();break;case"last":this.moveFocusToLast();break;default:return}}.bind(this)),t||this._handleUnboundKey(e)}},n.prototype.moveFocusForward=function(){var e,t=this._getActiveElementIndex();return e=t<this._members.length-1?t+1:this._settings.wrap?0:t,this.focusNodeAtIndex(e),e},n.prototype.moveFocusBack=function(){var e,t=this._getActiveElementIndex();return e=t>0?t-1:this._settings.wrap?this._members.length-1:t,this.focusNodeAtIndex(e),e},n.prototype.moveFocusToFirst=function(){this.focusNodeAtIndex(0)},n.prototype.moveFocusToLast=function(){this.focusNodeAtIndex(this._members.length-1)},n.prototype._handleUnboundKey=function(e){if(this._settings.stringSearch){if(""!==this._searchString&&(" "===e.key||32===e.keyCode))return e.preventDefault(),-1;if(!function(e){return e>=65&&e<=90}(e.keyCode))return-1;if(e.ctrlKey||e.metaKey||e.altKey)return-1;e.preventDefault(),this._addToSearchString(String.fromCharCode(e.keyCode)),this._runStringSearch()}},n.prototype._clearSearchString=function(){this._searchString=""},n.prototype._addToSearchString=function(e){this._searchString+=e.toLowerCase()},n.prototype._startSearchStringRefreshTimer=function(){var e=this;this._clearSearchStringRefreshTimer(),this._stringSearchTimer=setTimeout(function(){e._clearSearchString()},this._settings.stringSearchDelay)},n.prototype._clearSearchStringRefreshTimer=function(){clearTimeout(this._stringSearchTimer)},n.prototype._runStringSearch=function(){this._startSearchStringRefreshTimer(),this.moveFocusByString(this._searchString)},n.prototype.moveFocusByString=function(e){for(var t,n=0,r=this._members.length;n<r;n++)if((t=this._members[n]).text&&0===t.text.indexOf(e))return o(t.node)},n.prototype._findIndexOfNode=function(e){for(var t=0,n=this._members.length;t<n;t++)if(this._members[t].node===e)return t;return-1},n.prototype._getActiveElementIndex=function(){return this._findIndexOfNode(document.activeElement)},n.prototype.focusNodeAtIndex=function(e){var t=this._members[e];return t&&o(t.node),this},n.prototype.addMember=function(e,t){var n=e.node||e,o=e.text||n.getAttribute("data-focus-group-text")||n.textContent||"";this._checkNode(n);var r={node:n,text:o.replace(/[\W_]/g,"").toLowerCase()};return null!==t&&void 0!==t?this._members.splice(t,0,r):this._members.push(r),this},n.prototype.removeMember=function(e){var t="number"==typeof e?e:this._findIndexOfNode(e);if(-1!==t)return this._members.splice(t,1),this},n.prototype.clearMembers=function(){return this._members=[],this},n.prototype.setMembers=function(e){this.clearMembers();for(var t=0,n=e.length;t<n;t++)this.addMember(e[t]);return this},n.prototype.getMembers=function(){return this._members},n.prototype._checkNode=function(e){if(!e.nodeType||e.nodeType!==window.Node.ELEMENT_NODE)throw new Error("focus-group: only DOM nodes allowed");return e},e.exports=function(e){return new n(e)}},function(e,t,n){"use strict";var o=n(3),r=n(9),i=n(4),s={wrap:!0,stringSearch:!0},u={init:function(e){this.options=e||{},void 0===this.options.closeOnSelection&&(this.options.closeOnSelection=!0),void 0===this.options.closeOnBlur&&(this.options.closeOnBlur=!0),this.options.id&&i.registerManager(this.options.id,this),this.handleBlur=function(){var e=this;e.blurTimer=setTimeout(function(){var t=o.findDOMNode(e.button);if(t){var n=t.ownerDocument.activeElement;if(!t||n!==t){var r=o.findDOMNode(e.menu);r!==n?r&&r.contains(n)||e.isOpen&&e.closeMenu({focusButton:!1}):e.focusItem(0)}}},0)}.bind(this),this.handleSelection=function(e,t){this.options.closeOnSelection&&this.closeMenu({focusButton:!0});this.options.onSelection&&this.options.onSelection(e,t)}.bind(this),this.handleMenuKey=function(e){this.isOpen&&"Escape"===e.key&&(e.preventDefault(),this.closeMenu({focusButton:!0}))}.bind(this),this.focusGroup=r(s),this.button=null,this.menu=null,this.isOpen=!1},focusItem:function(e){this.focusGroup.focusNodeAtIndex(e)},addItem:function(e){this.focusGroup.addMember(e)},clearItems:function(){this.focusGroup.clearMembers()},handleButtonNonArrowKey:function(e){this.focusGroup._handleUnboundKey(e)},destroy:function(){this.button=null,this.menu=null,this.focusGroup.deactivate(),clearTimeout(this.blurTimer),clearTimeout(this.moveFocusTimer)},update:function(){this.menu.setState({isOpen:this.isOpen}),this.button.setState({menuOpen:this.isOpen}),this.options.onMenuToggle&&this.options.onMenuToggle({isOpen:this.isOpen})},openMenu:function(e){if(!this.isOpen&&(void 0===(e=e||{}).focusMenu&&(e.focusMenu=!0),this.isOpen=!0,this.update(),this.focusGroup.activate(),e.focusMenu)){var t=this;this.moveFocusTimer=setTimeout(function(){t.focusItem(0)},0)}},closeMenu:function(e){this.isOpen&&(e=e||{},this.isOpen=!1,this.update(),e.focusButton&&o.findDOMNode(this.button).focus())},toggleMenu:function(e,t){e=e||{},t=t||{},this.isOpen?this.closeMenu(e):this.openMenu(t)}};e.exports=function(e){var t=Object.create(u);return t.init(e),t}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";var o=function(e){};e.exports=function(e,t,n,r,i,s,u,c){if(o(t),!e){var a;if(void 0===t)a=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var p=[n,r,i,s,u,c],f=0;(a=new Error(t.replace(/%s/g,function(){return p[f++]}))).name="Invariant Violation"}throw a.framesToPop=1,a}}},function(e,t,n){"use strict";function o(e){return function(){return e}}var r=function(){};r.thatReturns=o,r.thatReturnsFalse=o(!1),r.thatReturnsTrue=o(!0),r.thatReturnsNull=o(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";var o=n(13),r=n(12),i=n(11);e.exports=function(){function e(e,t,n,o,s,u){u!==i&&r(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=o,n.PropTypes=n,n}},function(e,t,n){"use strict";var o=n(2),r=n(1),i=n(10),s=n(0),u={children:r.node.isRequired,onMenuToggle:r.func,onSelection:r.func,closeOnSelection:r.bool,closeOnBlur:r.bool,tag:r.string},c=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.getChildContext=function(){return{ambManager:this.manager}},t.prototype.componentWillMount=function(){this.manager=i({onMenuToggle:this.props.onMenuToggle,onSelection:this.props.onSelection,closeOnSelection:this.props.closeOnSelection,closeOnBlur:this.props.closeOnBlur,id:this.props.id})},t.prototype.render=function(){var e={};return s(e,this.props,u),o.createElement(this.props.tag,e,this.props.children)},t}(o.Component);c.propTypes=u,c.defaultProps={tag:"div"},c.childContextTypes={ambManager:r.object},e.exports=c},function(e,t,n){"use strict";var o=n(4);e.exports={Wrapper:n(15),Button:n(8),Menu:n(7),MenuItem:n(5),openMenu:o.openMenu,closeMenu:o.closeMenu}}])});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc