react-aria-menubutton
Advanced tools
Comparing version 6.0.0 to 6.0.1
# Changelog | ||
## 6.0.1 | ||
- Chore: Use loose mode for Babel compilation. | ||
## 6.0.0 | ||
@@ -4,0 +8,0 @@ |
'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -30,4 +28,2 @@ | ||
function AriaMenuButtonButton() { | ||
var _ref; | ||
var _temp, _this, _ret; | ||
@@ -41,3 +37,3 @@ | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = AriaMenuButtonButton.__proto__ || Object.getPrototypeOf(AriaMenuButtonButton)).call.apply(_ref, [this].concat(args))), _this), _this.handleKeyDown = function (event) { | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.handleKeyDown = function (event) { | ||
if (_this.props.disabled) return; | ||
@@ -74,44 +70,39 @@ | ||
_createClass(AriaMenuButtonButton, [{ | ||
key: 'componentWillMount', | ||
value: function componentWillMount() { | ||
this.context.ambManager.button = this; | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
this.context.ambManager.destroy(); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var props = this.props; | ||
AriaMenuButtonButton.prototype.componentWillMount = function componentWillMount() { | ||
this.context.ambManager.button = this; | ||
}; | ||
var buttonProps = { | ||
// "The menu button itself has a role of button." | ||
role: 'button', | ||
tabIndex: props.disabled ? '' : '0', | ||
// "The menu button has an aria-haspopup property, set to true." | ||
'aria-haspopup': true, | ||
'aria-expanded': this.context.ambManager.isOpen, | ||
'aria-disabled': props.disabled, | ||
onKeyDown: this.handleKeyDown, | ||
onClick: this.handleClick, | ||
onBlur: this.context.ambManager.handleBlur | ||
}; | ||
AriaMenuButtonButton.prototype.componentWillUnmount = function componentWillUnmount() { | ||
this.context.ambManager.destroy(); | ||
}; | ||
var reserved = {}; | ||
specialAssign(reserved, checkedProps); | ||
// The disabled property should be passed down to the Button element | ||
// if the tag has support for disabled attribute. So it needs to be removed | ||
// from the reserved property object | ||
if (disabledSupportedTags().indexOf(props.tag) >= 0) { | ||
delete reserved.disabled; | ||
} | ||
specialAssign(buttonProps, props, reserved); | ||
AriaMenuButtonButton.prototype.render = function render() { | ||
var props = this.props; | ||
return React.createElement(props.tag, buttonProps, props.children); | ||
var buttonProps = { | ||
// "The menu button itself has a role of button." | ||
role: 'button', | ||
tabIndex: props.disabled ? '' : '0', | ||
// "The menu button has an aria-haspopup property, set to true." | ||
'aria-haspopup': true, | ||
'aria-expanded': this.context.ambManager.isOpen, | ||
'aria-disabled': props.disabled, | ||
onKeyDown: this.handleKeyDown, | ||
onClick: this.handleClick, | ||
onBlur: this.context.ambManager.handleBlur | ||
}; | ||
var reserved = {}; | ||
specialAssign(reserved, checkedProps); | ||
// The disabled property should be passed down to the Button element | ||
// if the tag has support for disabled attribute. So it needs to be removed | ||
// from the reserved property object | ||
if (disabledSupportedTags().indexOf(props.tag) >= 0) { | ||
delete reserved.disabled; | ||
} | ||
}]); | ||
specialAssign(buttonProps, props, reserved); | ||
return React.createElement(props.tag, buttonProps, props.children); | ||
}; | ||
return AriaMenuButtonButton; | ||
@@ -118,0 +109,0 @@ }(React.Component); |
'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _class, _temp2; | ||
@@ -28,4 +26,2 @@ | ||
function _class() { | ||
var _ref; | ||
var _temp, _this, _ret; | ||
@@ -39,3 +35,3 @@ | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = _class.__proto__ || Object.getPrototypeOf(_class)).call.apply(_ref, [this].concat(args))), _this), _this.addTapListener = function () { | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.addTapListener = function () { | ||
var el = ReactDOM.findDOMNode(_this); | ||
@@ -53,59 +49,53 @@ if (!el) return; | ||
_createClass(_class, [{ | ||
key: 'componentWillMount', | ||
value: function componentWillMount() { | ||
this.context.ambManager.menu = this; | ||
_class.prototype.componentWillMount = function componentWillMount() { | ||
this.context.ambManager.menu = this; | ||
}; | ||
_class.prototype.componentDidUpdate = function componentDidUpdate() { | ||
var ambManager = this.context.ambManager; | ||
if (ambManager.isOpen && !this.tapListener) { | ||
this.addTapListener(); | ||
} else if (!ambManager.isOpen && this.tapListener) { | ||
this.tapListener.remove(); | ||
delete this.tapListener; | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
var ambManager = this.context.ambManager; | ||
if (ambManager.isOpen && !this.tapListener) { | ||
this.addTapListener(); | ||
} else if (!ambManager.isOpen && this.tapListener) { | ||
this.tapListener.remove(); | ||
delete this.tapListener; | ||
} | ||
if (!ambManager.isOpen) { | ||
// Clear the ambManager's items, so they | ||
// can be reloaded next time this menu opens | ||
ambManager.clearItems(); | ||
} | ||
if (!ambManager.isOpen) { | ||
// Clear the ambManager's items, so they | ||
// can be reloaded next time this menu opens | ||
ambManager.clearItems(); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
if (this.tapListener) this.tapListener.remove(); | ||
this.context.ambManager.destroy(); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var props = this.props; | ||
var ambManager = this.context.ambManager; | ||
}; | ||
var childrenToRender = function () { | ||
if (typeof props.children === 'function') { | ||
return props.children({ isOpen: ambManager.isOpen }); | ||
} | ||
if (ambManager.isOpen) return props.children; | ||
return false; | ||
}(); | ||
_class.prototype.componentWillUnmount = function componentWillUnmount() { | ||
if (this.tapListener) this.tapListener.remove(); | ||
this.context.ambManager.destroy(); | ||
}; | ||
if (!childrenToRender) return false; | ||
_class.prototype.render = function render() { | ||
var props = this.props; | ||
var ambManager = this.context.ambManager; | ||
var menuProps = { | ||
onKeyDown: ambManager.handleMenuKey, | ||
role: 'menu', | ||
onBlur: ambManager.handleBlur, | ||
tabIndex: -1 | ||
}; | ||
var childrenToRender = function () { | ||
if (typeof props.children === 'function') { | ||
return props.children({ isOpen: ambManager.isOpen }); | ||
} | ||
if (ambManager.isOpen) return props.children; | ||
return false; | ||
}(); | ||
specialAssign(menuProps, props, checkedProps); | ||
if (!childrenToRender) return false; | ||
return React.createElement(props.tag, menuProps, childrenToRender); | ||
} | ||
}]); | ||
var menuProps = { | ||
onKeyDown: ambManager.handleMenuKey, | ||
role: 'menu', | ||
onBlur: ambManager.handleBlur, | ||
tabIndex: -1 | ||
}; | ||
specialAssign(menuProps, props, checkedProps); | ||
return React.createElement(props.tag, menuProps, childrenToRender); | ||
}; | ||
return _class; | ||
@@ -112,0 +102,0 @@ }(React.Component), _class.propTypes = checkedProps, _class.defaultProps = { tag: 'div' }, _class.contextTypes = { |
'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -26,4 +24,2 @@ | ||
function AriaMenuButtonMenuItem() { | ||
var _ref; | ||
var _temp, _this, _ret; | ||
@@ -37,3 +33,3 @@ | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = AriaMenuButtonMenuItem.__proto__ || Object.getPrototypeOf(AriaMenuButtonMenuItem)).call.apply(_ref, [this].concat(args))), _this), _this.handleKeyDown = function (event) { | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.handleKeyDown = function (event) { | ||
if (event.key !== 'Enter' && event.key !== ' ') return; | ||
@@ -52,27 +48,23 @@ if (_this.props.tag === 'a' && _this.props.href) return; | ||
_createClass(AriaMenuButtonMenuItem, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.context.ambManager.addItem({ | ||
node: this.node, | ||
text: this.props.text | ||
}); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var menuItemProps = { | ||
onClick: this.selectItem, | ||
onKeyDown: this.handleKeyDown, | ||
role: 'menuitem', | ||
tabIndex: '-1', | ||
ref: this.registerNode | ||
}; | ||
AriaMenuButtonMenuItem.prototype.componentDidMount = function componentDidMount() { | ||
this.context.ambManager.addItem({ | ||
node: this.node, | ||
text: this.props.text | ||
}); | ||
}; | ||
specialAssign(menuItemProps, this.props, checkedProps); | ||
AriaMenuButtonMenuItem.prototype.render = function render() { | ||
var menuItemProps = { | ||
onClick: this.selectItem, | ||
onKeyDown: this.handleKeyDown, | ||
role: 'menuitem', | ||
tabIndex: '-1', | ||
ref: this.registerNode | ||
}; | ||
return React.createElement(this.props.tag, menuItemProps, this.props.children); | ||
} | ||
}]); | ||
specialAssign(menuItemProps, this.props, checkedProps); | ||
return React.createElement(this.props.tag, menuItemProps, this.props.children); | ||
}; | ||
return AriaMenuButtonMenuItem; | ||
@@ -79,0 +71,0 @@ }(React.Component); |
'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -30,31 +28,26 @@ | ||
return _possibleConstructorReturn(this, (AriaMenuButtonWrapper.__proto__ || Object.getPrototypeOf(AriaMenuButtonWrapper)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); | ||
} | ||
_createClass(AriaMenuButtonWrapper, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return { | ||
ambManager: this.manager | ||
}; | ||
} | ||
}, { | ||
key: 'componentWillMount', | ||
value: function componentWillMount() { | ||
this.manager = createManager({ | ||
onMenuToggle: this.props.onMenuToggle, | ||
onSelection: this.props.onSelection, | ||
closeOnSelection: this.props.closeOnSelection, | ||
id: this.props.id | ||
}); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var wrapperProps = {}; | ||
specialAssign(wrapperProps, this.props, checkedProps); | ||
return React.createElement(this.props.tag, wrapperProps, this.props.children); | ||
} | ||
}]); | ||
AriaMenuButtonWrapper.prototype.getChildContext = function getChildContext() { | ||
return { | ||
ambManager: this.manager | ||
}; | ||
}; | ||
AriaMenuButtonWrapper.prototype.componentWillMount = function componentWillMount() { | ||
this.manager = createManager({ | ||
onMenuToggle: this.props.onMenuToggle, | ||
onSelection: this.props.onSelection, | ||
closeOnSelection: this.props.closeOnSelection, | ||
id: this.props.id | ||
}); | ||
}; | ||
AriaMenuButtonWrapper.prototype.render = function render() { | ||
var wrapperProps = {}; | ||
specialAssign(wrapperProps, this.props, checkedProps); | ||
return React.createElement(this.props.tag, wrapperProps, this.props.children); | ||
}; | ||
return AriaMenuButtonWrapper; | ||
@@ -61,0 +54,0 @@ }(React.Component); |
{ | ||
"name": "react-aria-menubutton", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "A fully accessible and flexible React-powered menu button", | ||
@@ -8,9 +8,13 @@ "main": "dist/index.js", | ||
"lint": "eslint .", | ||
"demo-bundle": "webpack --config ./webpack-demo.config.js", | ||
"demo-watch": "webpack --config ./webpack-demo.config.js --watch", | ||
"demo-bundle": | ||
"webpack --mode production --config ./webpack-demo.config.js", | ||
"demo-watch": | ||
"webpack --mode development --config ./webpack-demo.config.js --watch", | ||
"start": "npm run demo-watch & http-server demo", | ||
"jest": "jest", | ||
"test": "npm run lint && npm run jest", | ||
"umd-unminified": "webpack --config ./webpack-umd.config.js", | ||
"umd-minified": "MINIFY=true webpack --config ./webpack-umd.config.js", | ||
"umd-unminified": | ||
"webpack --mode development --config ./webpack-umd.config.js", | ||
"umd-minified": | ||
"webpack --mode production --config ./webpack-umd.config.js", | ||
"umd": "npm run umd-unminified && npm run umd-minified", | ||
@@ -72,3 +76,4 @@ "format": "prettier --single-quote --write src/**/*.js demo/js/*.js", | ||
"react-test-renderer": "^16.2.0", | ||
"webpack": "^3.10.0" | ||
"webpack": "^4.15.1", | ||
"webpack-cli": "^3.0.8" | ||
}, | ||
@@ -78,3 +83,3 @@ "babel": { | ||
"react", | ||
"env" | ||
["env", {"loose": true}] | ||
], | ||
@@ -86,5 +91,3 @@ "plugins": [ | ||
"jest": { | ||
"setupFiles": [ | ||
"./src/__tests__/helpers/jest-setup.js" | ||
], | ||
"setupFiles": ["./src/__tests__/helpers/jest-setup.js"], | ||
"testRegex": "/__tests__/.*\\.test.js$", | ||
@@ -91,0 +94,0 @@ "clearMocks": true |
@@ -1,16 +0,14 @@ | ||
const path = require('path'); | ||
const path = require("path"); | ||
module.exports = { | ||
entry: { | ||
demo: './demo/js/index.js', | ||
demo: "./demo/js/index.js" | ||
}, | ||
output: { | ||
path: path.join(__dirname, 'demo'), | ||
filename: 'demo-bundle.js', | ||
path: path.join(__dirname, "demo"), | ||
filename: "demo-bundle.js" | ||
}, | ||
module: { | ||
loaders: [ | ||
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }, | ||
], | ||
}, | ||
rules: [{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }] | ||
} | ||
}; |
@@ -1,22 +0,16 @@ | ||
const webpack = require('webpack'); | ||
const path = require('path'); | ||
const path = require("path"); | ||
const plugins = []; | ||
if (process.env.MINIFY) { | ||
plugins.push(new webpack.optimize.UglifyJsPlugin()); | ||
} | ||
const filename = process.env.MINIFY | ||
? "ReactAriaMenuButton.min.js" | ||
: "ReactAriaMenuButton.js"; | ||
const filename = (process.env.MINIFY) | ||
? 'ReactAriaMenuButton.min.js' | ||
: 'ReactAriaMenuButton.js'; | ||
module.exports = { | ||
entry: { | ||
AriaMenuButton: './src/index.js', | ||
AriaMenuButton: "./src/index.js" | ||
}, | ||
output: { | ||
library: 'ReactAriaMenuButton', | ||
libraryTarget: 'umd', | ||
path: path.join(__dirname, 'umd'), | ||
filename: filename, | ||
library: "ReactAriaMenuButton", | ||
libraryTarget: "umd", | ||
path: path.join(__dirname, "umd"), | ||
filename: filename | ||
}, | ||
@@ -26,21 +20,19 @@ externals: [ | ||
react: { | ||
root: 'React', | ||
commonjs2: 'react', | ||
commonjs: 'react', | ||
amd: 'react', | ||
}, | ||
root: "React", | ||
commonjs2: "react", | ||
commonjs: "react", | ||
amd: "react" | ||
} | ||
}, | ||
{ | ||
'react-dom': { | ||
root: 'ReactDOM', | ||
commonjs2: 'react-dom', | ||
commonjs: 'react-dom', | ||
amd: 'react-dom', | ||
}, | ||
}, | ||
"react-dom": { | ||
root: "ReactDOM", | ||
commonjs2: "react-dom", | ||
commonjs: "react-dom", | ||
amd: "react-dom" | ||
} | ||
} | ||
], | ||
module: { | ||
loaders: [ | ||
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }, | ||
], | ||
rules: [{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }] | ||
}, | ||
@@ -50,5 +42,4 @@ node: { | ||
process: false, | ||
setImmediate: false, | ||
}, | ||
plugins: plugins, | ||
setImmediate: false | ||
} | ||
}; |
Sorry, the diff of this file is too big to display
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
10
123990
19
1518
2