Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

25
goTorrentWebUI/node_modules/material-ui/Menu/Menu.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import * as React from 'react';
import { PopoverProps, PopoverClassKey } from '../Popover';
import { TransitionDuration, TransitionHandlers } from '../internal/transition';
import { MenuListProps } from './MenuList';
import { StandardProps } from '..';
export interface MenuProps extends StandardProps<
PopoverProps & Partial<TransitionHandlers>,
MenuClassKey
> {
anchorEl?: HTMLElement;
MenuListProps?: MenuListProps;
onRequestClose?: React.EventHandler<any>;
open?: boolean;
transitionDuration?: TransitionDuration;
}
export type MenuClassKey =
| PopoverClassKey
| 'root'
;
declare const Menu: React.ComponentType<MenuProps>;
export default Menu;

310
goTorrentWebUI/node_modules/material-ui/Menu/Menu.js generated vendored Normal file
View File

@@ -0,0 +1,310 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.styles = undefined;
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _reactDom = require('react-dom');
var _scrollbarSize = require('dom-helpers/util/scrollbarSize');
var _scrollbarSize2 = _interopRequireDefault(_scrollbarSize);
var _withStyles = require('../styles/withStyles');
var _withStyles2 = _interopRequireDefault(_withStyles);
var _Popover = require('../Popover');
var _Popover2 = _interopRequireDefault(_Popover);
var _MenuList = require('./MenuList');
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 = {
vertical: 'top',
horizontal: 'right'
};
var ltrOrigin = {
vertical: 'top',
horizontal: 'left'
};
var styles = exports.styles = {
paper: {
// specZ: The maximum height of a simple menu should be one or more rows less than the view
// height. This ensures a tappable area outside of the simple menu with which to dismiss
// the menu.
maxHeight: 'calc(100vh - 96px)',
// Add iOS momentum scrolling.
WebkitOverflowScrolling: 'touch'
}
};
var Menu = function (_React$Component) {
(0, _inherits3.default)(Menu, _React$Component);
function Menu() {
var _ref;
var _temp, _this, _ret;
(0, _classCallCheck3.default)(this, Menu);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
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.
_this.focus();
// 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 + ')';
}
if (_this.props.onEnter) {
_this.props.onEnter(element);
}
}, _this.handleListKeyDown = function (event, key) {
if (key === 'tab') {
event.preventDefault();
if (_this.props.onRequestClose) {
_this.props.onRequestClose(event);
}
}
}, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
}
(0, _createClass3.default)(Menu, [{
key: 'componentDidMount',
value: function componentDidMount() {
if (this.props.open) {
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() {
var _this2 = this;
var _props = this.props,
children = _props.children,
classes = _props.classes,
MenuListProps = _props.MenuListProps,
onEnter = _props.onEnter,
_props$PaperProps = _props.PaperProps,
PaperProps = _props$PaperProps === undefined ? {} : _props$PaperProps,
PopoverClasses = _props.PopoverClasses,
theme = _props.theme,
other = (0, _objectWithoutProperties3.default)(_props, ['children', 'classes', 'MenuListProps', 'onEnter', 'PaperProps', 'PopoverClasses', 'theme']);
return _react2.default.createElement(
_Popover2.default,
(0, _extends3.default)({
getContentAnchorEl: this.getContentAnchorEl,
classes: PopoverClasses,
onEnter: this.handleEnter,
anchorOrigin: theme.direction === 'rtl' ? rtlOrigin : ltrOrigin,
transformOrigin: theme.direction === 'rtl' ? rtlOrigin : ltrOrigin,
PaperProps: (0, _extends3.default)({}, PaperProps, {
classes: (0, _extends3.default)({}, PaperProps.classes, {
root: classes.paper
})
})
}, other),
_react2.default.createElement(
_MenuList2.default,
(0, _extends3.default)({
role: 'menu',
onKeyDown: this.handleListKeyDown
}, MenuListProps, {
ref: function ref(node) {
_this2.menuList = node;
}
}),
children
)
);
}
}]);
return Menu;
}(_react2.default.Component);
Menu.defaultProps = {
open: false,
transitionDuration: 'auto'
};
exports.default = (0, _withStyles2.default)(styles, { withTheme: true, name: 'MuiMenu' })(Menu);

View File

@@ -0,0 +1,231 @@
// @flow
// @inheritedComponent Popover
import React from 'react';
import type { Node } from 'react';
import { findDOMNode } from 'react-dom';
import getScrollbarSize from 'dom-helpers/util/scrollbarSize';
import withStyles from '../styles/withStyles';
import Popover from '../Popover';
import MenuList from './MenuList';
import type { TransitionCallback } from '../internal/transition';
type ProvidedProps = {
classes: Object,
theme: Object,
};
export type Props = {
/**
* The DOM element used to set the position of the menu.
*/
anchorEl?: ?HTMLElement, // match Popover
/**
* Menu contents, normally `MenuItem`s.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* Properties applied to the `MenuList` element.
*/
MenuListProps?: Object,
/**
* Callback fired before the Menu enters.
*/
onEnter?: TransitionCallback,
/**
* Callback fired when the Menu is entering.
*/
onEntering?: TransitionCallback,
/**
* Callback fired when the Menu has entered.
*/
onEntered?: TransitionCallback,
/**
* Callback fired before the Menu exits.
*/
onExit?: TransitionCallback,
/**
* Callback fired when the Menu is exiting.
*/
onExiting?: TransitionCallback,
/**
* Callback fired when the Menu has exited.
*/
onExited?: TransitionCallback,
/**
* Callback fired when the component requests to be closed.
*
* @param {object} event The event source of the callback
*/
onRequestClose?: Function,
/**
* If `true`, the menu is visible.
*/
open?: boolean,
/**
* @ignore
*/
PaperProps?: Object,
/**
* `classes` property applied to the `Popover` element.
*/
PopoverClasses?: Object,
/**
* @ignore
*/
theme?: Object,
/**
* The length of the transition in `ms`, or 'auto'
*/
transitionDuration?: number | { enter?: number, exit?: number } | 'auto',
};
const rtlOrigin = {
vertical: 'top',
horizontal: 'right',
};
const ltrOrigin = {
vertical: 'top',
horizontal: 'left',
};
export const styles = {
paper: {
// specZ: The maximum height of a simple menu should be one or more rows less than the view
// height. This ensures a tappable area outside of the simple menu with which to dismiss
// the menu.
maxHeight: 'calc(100vh - 96px)',
// Add iOS momentum scrolling.
WebkitOverflowScrolling: 'touch',
},
};
class Menu extends React.Component<ProvidedProps & Props> {
static defaultProps = {
open: false,
transitionDuration: 'auto',
};
componentDidMount() {
if (this.props.open) {
this.focus();
}
}
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();
}
}
getContentAnchorEl = () => {
if (!this.menuList || !this.menuList.selectedItem) {
// $FlowFixMe
return findDOMNode(this.menuList).firstChild;
}
return findDOMNode(this.menuList.selectedItem);
};
menuList = undefined;
focus = () => {
if (this.menuList && this.menuList.selectedItem) {
// $FlowFixMe
findDOMNode(this.menuList.selectedItem).focus();
return;
}
const menuList = findDOMNode(this.menuList);
if (menuList && menuList.firstChild) {
// $FlowFixMe
menuList.firstChild.focus();
}
};
handleEnter = (element: HTMLElement) => {
const { theme } = this.props;
const menuList = findDOMNode(this.menuList);
// Focus so the scroll computation of the Popover works as expected.
this.focus();
// 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) {
const size = `${getScrollbarSize()}px`;
// $FlowFixMe
menuList.style[theme.direction === 'rtl' ? 'paddingLeft' : 'paddingRight'] = size;
// $FlowFixMe
menuList.style.width = `calc(100% + ${size})`;
}
if (this.props.onEnter) {
this.props.onEnter(element);
}
};
handleListKeyDown = (event: SyntheticUIEvent<>, key: string) => {
if (key === 'tab') {
event.preventDefault();
if (this.props.onRequestClose) {
this.props.onRequestClose(event);
}
}
};
render() {
const {
children,
classes,
MenuListProps,
onEnter,
PaperProps = {},
PopoverClasses,
theme,
...other
} = this.props;
return (
<Popover
getContentAnchorEl={this.getContentAnchorEl}
classes={PopoverClasses}
onEnter={this.handleEnter}
anchorOrigin={theme.direction === 'rtl' ? rtlOrigin : ltrOrigin}
transformOrigin={theme.direction === 'rtl' ? rtlOrigin : ltrOrigin}
PaperProps={{
...PaperProps,
classes: {
...PaperProps.classes,
root: classes.paper,
},
}}
{...other}
>
<MenuList
data-mui-test="Menu"
role="menu"
onKeyDown={this.handleListKeyDown}
{...MenuListProps}
ref={node => {
this.menuList = node;
}}
>
{children}
</MenuList>
</Popover>
);
}
}
export default withStyles(styles, { withTheme: true, name: 'MuiMenu' })(Menu);

View File

@@ -0,0 +1,21 @@
import * as React from 'react';
import { StandardProps } from '..';
import { ListItemProps, ListItemClassKey } from '../List';
export interface MenuItemProps extends StandardProps<
ListItemProps,
MenuItemClassKey
> {
component?: React.ReactType;
role?: string;
selected?: boolean;
}
export type MenuItemClassKey =
| ListItemClassKey
| 'selected'
;
declare const MenuItem: React.ComponentType<MenuItemProps>;
export default MenuItem;

View File

@@ -0,0 +1,132 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.styles = undefined;
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _ref;
// @inheritedComponent ListItem
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
var _withStyles = require('../styles/withStyles');
var _withStyles2 = _interopRequireDefault(_withStyles);
var _ListItem = require('../List/ListItem');
var _ListItem2 = _interopRequireDefault(_ListItem);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_ElementType = require('react').babelPluginFlowReactPropTypes_proptype_ElementType || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
return {
root: (0, _extends3.default)({}, theme.typography.subheading, {
height: 24,
boxSizing: 'content-box',
background: 'none',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
'&:focus': {
background: theme.palette.text.divider
},
'&:hover': {
backgroundColor: theme.palette.text.divider
}
}),
selected: {
backgroundColor: theme.palette.text.divider
}
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* Menu item contents.
*/
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,
/**
* @ignore
*/
className: require('prop-types').string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: typeof babelPluginFlowReactPropTypes_proptype_ElementType === 'function' ? babelPluginFlowReactPropTypes_proptype_ElementType : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_ElementType),
/**
* @ignore
*/
role: require('prop-types').string,
/**
* Use to apply selected styling.
*/
selected: require('prop-types').bool
};
function MenuItem(props) {
var classes = props.classes,
classNameProp = props.className,
component = props.component,
selected = props.selected,
role = props.role,
other = (0, _objectWithoutProperties3.default)(props, ['classes', 'className', 'component', 'selected', 'role']);
var className = (0, _classnames2.default)(classes.root, (0, _defineProperty3.default)({}, classes.selected, selected), classNameProp);
return _react2.default.createElement(_ListItem2.default, (0, _extends3.default)({
button: true,
role: role,
tabIndex: -1,
className: className,
component: component
}, other));
}
MenuItem.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired,
role: require('prop-types').string.isRequired,
selected: require('prop-types').bool.isRequired,
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), (0, _defineProperty3.default)(_ref, 'component', typeof babelPluginFlowReactPropTypes_proptype_ElementType === 'function' ? babelPluginFlowReactPropTypes_proptype_ElementType : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_ElementType)), (0, _defineProperty3.default)(_ref, 'role', require('prop-types').string), (0, _defineProperty3.default)(_ref, 'selected', require('prop-types').bool), _ref) : {};
MenuItem.defaultProps = {
role: 'menuitem',
selected: false
};
exports.default = (0, _withStyles2.default)(styles, { name: 'MuiMenuItem' })(MenuItem);

View File

@@ -0,0 +1,93 @@
// @flow
// @inheritedComponent ListItem
import React from 'react';
import type { ElementType, Node } from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import ListItem from '../List/ListItem';
export const styles = (theme: Object) => ({
root: {
...theme.typography.subheading,
height: 24,
boxSizing: 'content-box',
background: 'none',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
'&:focus': {
background: theme.palette.text.divider,
},
'&:hover': {
backgroundColor: theme.palette.text.divider,
},
},
selected: {
backgroundColor: theme.palette.text.divider,
},
});
type ProvidedProps = {
classes: Object,
role: string,
selected: boolean,
};
export type Props = {
/**
* Menu item contents.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component?: ElementType,
/**
* @ignore
*/
role?: string,
/**
* Use to apply selected styling.
*/
selected?: boolean,
};
function MenuItem(props: ProvidedProps & Props) {
const { classes, className: classNameProp, component, selected, role, ...other } = props;
const className = classNames(
classes.root,
{
[classes.selected]: selected,
},
classNameProp,
);
return (
<ListItem
button
role={role}
tabIndex={-1}
className={className}
component={component}
{...other}
/>
);
}
MenuItem.defaultProps = {
role: 'menuitem',
selected: false,
};
export default withStyles(styles, { name: 'MuiMenuItem' })(MenuItem);

View File

@@ -0,0 +1,19 @@
import * as React from 'react';
import { StandardProps } from '..';
import { ListProps, ListClassKey } from '../List';
export interface MenuListProps extends StandardProps<
ListProps,
MenuListClassKey,
'onKeyDown'
> {
onKeyDown?: React.ReactEventHandler<React.KeyboardEvent<any>>;
}
export type MenuListClassKey =
| ListClassKey
;
declare const MenuList: React.ComponentType<MenuListProps>;
export default MenuList;

View File

@@ -0,0 +1,266 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _reactDom = require('react-dom');
var _keycode = require('keycode');
var _keycode2 = _interopRequireDefault(_keycode);
var _contains = require('dom-helpers/query/contains');
var _contains2 = _interopRequireDefault(_contains);
var _activeElement = require('dom-helpers/activeElement');
var _activeElement2 = _interopRequireDefault(_activeElement);
var _ownerDocument = require('dom-helpers/ownerDocument');
var _ownerDocument2 = _interopRequireDefault(_ownerDocument);
var _List = require('../List');
var _List2 = _interopRequireDefault(_List);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
// @inheritedComponent List
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* MenuList contents, normally `MenuItem`s.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
/**
* @ignore
*/
className: require('prop-types').string,
/**
* @ignore
*/
onBlur: require('prop-types').func,
/**
* @ignore
*/
onKeyDown: require('prop-types').func
};
var MenuList = function (_React$Component) {
(0, _inherits3.default)(MenuList, _React$Component);
function MenuList() {
var _ref;
var _temp, _this, _ret;
(0, _classCallCheck3.default)(this, MenuList);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = MenuList.__proto__ || (0, _getPrototypeOf2.default)(MenuList)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
currentTabIndex: undefined
}, _this.list = undefined, _this.selectedItem = undefined, _this.blurTimer = undefined, _this.handleBlur = function (event) {
_this.blurTimer = setTimeout(function () {
if (_this.list) {
var list = (0, _reactDom.findDOMNode)(_this.list);
var currentFocus = (0, _activeElement2.default)((0, _ownerDocument2.default)(list));
if (!(0, _contains2.default)(list, currentFocus)) {
_this.resetTabIndex();
}
}
}, 30);
if (_this.props.onBlur) {
_this.props.onBlur(event);
}
}, _this.handleKeyDown = function (event) {
var list = (0, _reactDom.findDOMNode)(_this.list);
var key = (0, _keycode2.default)(event);
var currentFocus = (0, _activeElement2.default)((0, _ownerDocument2.default)(list));
if ((key === 'up' || key === 'down') && (!currentFocus || currentFocus && !(0, _contains2.default)(list, currentFocus))) {
if (_this.selectedItem) {
// $FlowFixMe
(0, _reactDom.findDOMNode)(_this.selectedItem).focus();
} else {
// $FlowFixMe
list.firstChild.focus();
}
} else if (key === 'down') {
event.preventDefault();
if (currentFocus.nextElementSibling) {
currentFocus.nextElementSibling.focus();
}
} else if (key === 'up') {
event.preventDefault();
if (currentFocus.previousElementSibling) {
currentFocus.previousElementSibling.focus();
}
}
if (_this.props.onKeyDown) {
_this.props.onKeyDown(event, key);
}
}, _this.handleItemFocus = function (event) {
var list = (0, _reactDom.findDOMNode)(_this.list);
if (list) {
// $FlowFixMe
for (var i = 0; i < list.children.length; i += 1) {
// $FlowFixMe
if (list.children[i] === event.currentTarget) {
_this.setTabIndex(i);
break;
}
}
}
}, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
}
(0, _createClass3.default)(MenuList, [{
key: 'componentDidMount',
value: function componentDidMount() {
this.resetTabIndex();
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
clearTimeout(this.blurTimer);
}
}, {
key: 'setTabIndex',
value: function setTabIndex(index) {
this.setState({ currentTabIndex: index });
}
}, {
key: 'focus',
value: function focus() {
var currentTabIndex = this.state.currentTabIndex;
var list = (0, _reactDom.findDOMNode)(this.list);
if (!list || !list.children || !list.firstChild) {
return;
}
if (currentTabIndex && currentTabIndex >= 0) {
// $FlowFixMe
list.children[currentTabIndex].focus();
} else {
// $FlowFixMe
list.firstChild.focus();
}
}
}, {
key: 'resetTabIndex',
value: function resetTabIndex() {
var list = (0, _reactDom.findDOMNode)(this.list);
var currentFocus = (0, _activeElement2.default)((0, _ownerDocument2.default)(list));
// $FlowFixMe
var items = [].concat((0, _toConsumableArray3.default)(list.children));
var currentFocusIndex = items.indexOf(currentFocus);
if (currentFocusIndex !== -1) {
return this.setTabIndex(currentFocusIndex);
}
if (this.selectedItem) {
return this.setTabIndex(items.indexOf((0, _reactDom.findDOMNode)(this.selectedItem)));
}
return this.setTabIndex(0);
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
var _props = this.props,
children = _props.children,
className = _props.className,
onBlur = _props.onBlur,
onKeyDown = _props.onKeyDown,
other = (0, _objectWithoutProperties3.default)(_props, ['children', 'className', 'onBlur', 'onKeyDown']);
return _react2.default.createElement(
_List2.default,
(0, _extends3.default)({
role: 'menu',
rootRef: function rootRef(node) {
_this2.list = node;
},
className: className,
onKeyDown: this.handleKeyDown,
onBlur: this.handleBlur
}, other),
_react2.default.Children.map(children, function (child, index) {
if (!_react2.default.isValidElement(child)) {
return null;
}
return _react2.default.cloneElement(child, {
tabIndex: index === _this2.state.currentTabIndex ? 0 : -1,
ref: child.props.selected ? function (node) {
_this2.selectedItem = node;
} : undefined,
onFocus: _this2.handleItemFocus
});
})
);
}
}]);
return MenuList;
}(_react2.default.Component);
MenuList.propTypes = process.env.NODE_ENV !== "production" ? {
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
className: require('prop-types').string,
onBlur: require('prop-types').func,
onKeyDown: require('prop-types').func
} : {};
exports.default = MenuList;

View File

@@ -0,0 +1,189 @@
// @flow
// @inheritedComponent List
import React from 'react';
import type { Node } from 'react';
import { findDOMNode } from 'react-dom';
import keycode from 'keycode';
import contains from 'dom-helpers/query/contains';
import activeElement from 'dom-helpers/activeElement';
import ownerDocument from 'dom-helpers/ownerDocument';
import List from '../List';
export type Props = {
/**
* MenuList contents, normally `MenuItem`s.
*/
children?: Node,
/**
* @ignore
*/
className?: string,
/**
* @ignore
*/
onBlur?: Function,
/**
* @ignore
*/
onKeyDown?: (event: SyntheticUIEvent<>, key: string) => void,
};
type State = {
currentTabIndex: ?number,
};
class MenuList extends React.Component<Props, State> {
state = {
currentTabIndex: undefined,
};
componentDidMount() {
this.resetTabIndex();
}
componentWillUnmount() {
clearTimeout(this.blurTimer);
}
setTabIndex(index: number) {
this.setState({ currentTabIndex: index });
}
list = undefined;
selectedItem = undefined;
blurTimer = undefined;
handleBlur = (event: SyntheticUIEvent<>) => {
this.blurTimer = setTimeout(() => {
if (this.list) {
const list = findDOMNode(this.list);
const currentFocus = activeElement(ownerDocument(list));
if (!contains(list, currentFocus)) {
this.resetTabIndex();
}
}
}, 30);
if (this.props.onBlur) {
this.props.onBlur(event);
}
};
handleKeyDown = (event: SyntheticUIEvent<>) => {
const list = findDOMNode(this.list);
const key = keycode(event);
const currentFocus = activeElement(ownerDocument(list));
if (
(key === 'up' || key === 'down') &&
(!currentFocus || (currentFocus && !contains(list, currentFocus)))
) {
if (this.selectedItem) {
// $FlowFixMe
findDOMNode(this.selectedItem).focus();
} else {
// $FlowFixMe
list.firstChild.focus();
}
} else if (key === 'down') {
event.preventDefault();
if (currentFocus.nextElementSibling) {
currentFocus.nextElementSibling.focus();
}
} else if (key === 'up') {
event.preventDefault();
if (currentFocus.previousElementSibling) {
currentFocus.previousElementSibling.focus();
}
}
if (this.props.onKeyDown) {
this.props.onKeyDown(event, key);
}
};
handleItemFocus = (event: SyntheticUIEvent<>) => {
const list = findDOMNode(this.list);
if (list) {
// $FlowFixMe
for (let i = 0; i < list.children.length; i += 1) {
// $FlowFixMe
if (list.children[i] === event.currentTarget) {
this.setTabIndex(i);
break;
}
}
}
};
focus() {
const { currentTabIndex } = this.state;
const list = findDOMNode(this.list);
if (!list || !list.children || !list.firstChild) {
return;
}
if (currentTabIndex && currentTabIndex >= 0) {
// $FlowFixMe
list.children[currentTabIndex].focus();
} else {
// $FlowFixMe
list.firstChild.focus();
}
}
resetTabIndex() {
const list = findDOMNode(this.list);
const currentFocus = activeElement(ownerDocument(list));
// $FlowFixMe
const items = [...list.children];
const currentFocusIndex = items.indexOf(currentFocus);
if (currentFocusIndex !== -1) {
return this.setTabIndex(currentFocusIndex);
}
if (this.selectedItem) {
return this.setTabIndex(items.indexOf(findDOMNode(this.selectedItem)));
}
return this.setTabIndex(0);
}
render() {
const { children, className, onBlur, onKeyDown, ...other } = this.props;
return (
<List
data-mui-test="MenuList"
role="menu"
rootRef={node => {
this.list = node;
}}
className={className}
onKeyDown={this.handleKeyDown}
onBlur={this.handleBlur}
{...other}
>
{React.Children.map(children, (child, index) => {
if (!React.isValidElement(child)) {
return null;
}
return React.cloneElement(child, {
tabIndex: index === this.state.currentTabIndex ? 0 : -1,
ref: child.props.selected
? node => {
this.selectedItem = node;
}
: undefined,
onFocus: this.handleItemFocus,
});
})}
</List>
);
}
}
export default MenuList;

View File

@@ -0,0 +1,6 @@
export { default } from './Menu';
export * from './Menu';
export { default as MenuList } from './MenuList';
export * from './MenuList';
export { default as MenuItem } from './MenuItem';
export * from './MenuItem';

34
goTorrentWebUI/node_modules/material-ui/Menu/index.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _Menu = require('./Menu');
Object.defineProperty(exports, 'default', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Menu).default;
}
});
var _MenuList = require('./MenuList');
Object.defineProperty(exports, 'MenuList', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_MenuList).default;
}
});
var _MenuItem = require('./MenuItem');
Object.defineProperty(exports, 'MenuItem', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_MenuItem).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

View File

@@ -0,0 +1,5 @@
// @flow
export { default } from './Menu';
export { default as MenuList } from './MenuList';
export { default as MenuItem } from './MenuItem';