Completely updated React, fixed #11, (hopefully)

This commit is contained in:
2018-03-04 19:11:49 -05:00
parent 6e0afd6e2a
commit 34e5f5139a
13674 changed files with 333464 additions and 473223 deletions

View File

@@ -37,6 +37,10 @@ var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _reactDom = require('react-dom');
var _scrollbarSize = require('dom-helpers/util/scrollbarSize');
@@ -57,105 +61,12 @@ var _MenuList2 = _interopRequireDefault(_MenuList);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
// @inheritedComponent Popover
var babelPluginFlowReactPropTypes_proptype_TransitionCallback = require('../internal/transition').babelPluginFlowReactPropTypes_proptype_TransitionCallback || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* The DOM element used to set the position of the menu.
*/
anchorEl: typeof HTMLElement === 'function' ? require('prop-types').instanceOf(HTMLElement) : require('prop-types').any,
// match Popover
/**
* Menu contents, normally `MenuItem`s.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* Properties applied to the `MenuList` element.
*/
MenuListProps: require('prop-types').object,
/**
* Callback fired before the Menu enters.
*/
onEnter: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* Callback fired when the Menu is entering.
*/
onEntering: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* Callback fired when the Menu has entered.
*/
onEntered: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* Callback fired before the Menu exits.
*/
onExit: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* Callback fired when the Menu is exiting.
*/
onExiting: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* Callback fired when the Menu has exited.
*/
onExited: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* Callback fired when the component requests to be closed.
*
* @param {object} event The event source of the callback
*/
onRequestClose: require('prop-types').func,
/**
* If `true`, the menu is visible.
*/
open: require('prop-types').bool,
/**
* @ignore
*/
PaperProps: require('prop-types').object,
/**
* `classes` property applied to the `Popover` element.
*/
PopoverClasses: require('prop-types').object,
/**
* @ignore
*/
theme: require('prop-types').object,
/**
* The length of the transition in `ms`, or 'auto'
*/
transitionDuration: require('prop-types').oneOfType([require('prop-types').number, require('prop-types').shape({
enter: require('prop-types').number,
exit: require('prop-types').number
}), require('prop-types').oneOf(['auto'])])
};
var rtlOrigin = {
var RTL_ORIGIN = {
vertical: 'top',
horizontal: 'right'
};
}; // @inheritedComponent Popover
var ltrOrigin = {
var LTR_ORIGIN = {
vertical: 'top',
horizontal: 'left'
};
@@ -187,27 +98,23 @@ var Menu = function (_React$Component) {
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = Menu.__proto__ || (0, _getPrototypeOf2.default)(Menu)).call.apply(_ref, [this].concat(args))), _this), _this.getContentAnchorEl = function () {
if (!_this.menuList || !_this.menuList.selectedItem) {
// $FlowFixMe
return (0, _reactDom.findDOMNode)(_this.menuList).firstChild;
}
return (0, _reactDom.findDOMNode)(_this.menuList.selectedItem);
}, _this.menuList = undefined, _this.focus = function () {
if (_this.menuList && _this.menuList.selectedItem) {
// $FlowFixMe
(0, _reactDom.findDOMNode)(_this.menuList.selectedItem).focus();
return;
}
var menuList = (0, _reactDom.findDOMNode)(_this.menuList);
if (menuList && menuList.firstChild) {
// $FlowFixMe
menuList.firstChild.focus();
}
}, _this.handleEnter = function (element) {
var theme = _this.props.theme;
var menuList = (0, _reactDom.findDOMNode)(_this.menuList);
// Focus so the scroll computation of the Popover works as expected.
@@ -215,12 +122,9 @@ var Menu = function (_React$Component) {
// Let's ignore that piece of logic if users are already overriding the width
// of the menu.
// $FlowFixMe
if (menuList && element.clientHeight < menuList.clientHeight && !menuList.style.width) {
var size = (0, _scrollbarSize2.default)() + 'px';
// $FlowFixMe
menuList.style[theme.direction === 'rtl' ? 'paddingLeft' : 'paddingRight'] = size;
// $FlowFixMe
menuList.style.width = 'calc(100% + ' + size + ')';
}
@@ -231,8 +135,8 @@ var Menu = function (_React$Component) {
if (key === 'tab') {
event.preventDefault();
if (_this.props.onRequestClose) {
_this.props.onRequestClose(event);
if (_this.props.onClose) {
_this.props.onClose(event);
}
}
}, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
@@ -245,15 +149,6 @@ var Menu = function (_React$Component) {
this.focus();
}
}
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps) {
if (!prevProps.open && this.props.open) {
// Needs to refocus as when a menu is rendered into another Modal,
// the first modal might change the focus to prevent any leak.
this.focus();
}
}
}, {
key: 'render',
value: function render() {
@@ -277,8 +172,8 @@ var Menu = function (_React$Component) {
getContentAnchorEl: this.getContentAnchorEl,
classes: PopoverClasses,
onEnter: this.handleEnter,
anchorOrigin: theme.direction === 'rtl' ? rtlOrigin : ltrOrigin,
transformOrigin: theme.direction === 'rtl' ? rtlOrigin : ltrOrigin,
anchorOrigin: theme.direction === 'rtl' ? RTL_ORIGIN : LTR_ORIGIN,
transformOrigin: theme.direction === 'rtl' ? RTL_ORIGIN : LTR_ORIGIN,
PaperProps: (0, _extends3.default)({}, PaperProps, {
classes: (0, _extends3.default)({}, PaperProps.classes, {
root: classes.paper
@@ -303,8 +198,77 @@ var Menu = function (_React$Component) {
return Menu;
}(_react2.default.Component);
Menu.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The DOM element used to set the position of the menu.
*/
anchorEl: _propTypes2.default.object,
/**
* Menu contents, normally `MenuItem`s.
*/
children: _propTypes2.default.node,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* Properties applied to the `MenuList` element.
*/
MenuListProps: _propTypes2.default.object,
/**
* Callback fired when the component requests to be closed.
*
* @param {object} event The event source of the callback
*/
onClose: _propTypes2.default.func,
/**
* Callback fired before the Menu enters.
*/
onEnter: _propTypes2.default.func,
/**
* Callback fired when the Menu has entered.
*/
onEntered: _propTypes2.default.func,
/**
* Callback fired when the Menu is entering.
*/
onEntering: _propTypes2.default.func,
/**
* Callback fired before the Menu exits.
*/
onExit: _propTypes2.default.func,
/**
* Callback fired when the Menu has exited.
*/
onExited: _propTypes2.default.func,
/**
* Callback fired when the Menu is exiting.
*/
onExiting: _propTypes2.default.func,
/**
* If `true`, the menu is visible.
*/
open: _propTypes2.default.bool.isRequired,
/**
* @ignore
*/
PaperProps: _propTypes2.default.object,
/**
* `classes` property applied to the `Popover` element.
*/
PopoverClasses: _propTypes2.default.object,
/**
* @ignore
*/
theme: _propTypes2.default.object.isRequired,
/**
* The length of the transition in `ms`, or 'auto'
*/
transitionDuration: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.shape({ enter: _propTypes2.default.number, exit: _propTypes2.default.number }), _propTypes2.default.oneOf(['auto'])])
} : {};
Menu.defaultProps = {
open: false,
transitionDuration: 'auto'
};
exports.default = (0, _withStyles2.default)(styles, { withTheme: true, name: 'MuiMenu' })(Menu);
exports.default = (0, _withStyles2.default)(styles, { name: 'MuiMenu', withTheme: true })(Menu);