Removed GopherJS, basic frontend completed, need backend changes for

torrent storage
This commit is contained in:
2017-11-30 18:12:11 -05:00
parent 67fdef16b1
commit e98ad2cc88
69321 changed files with 5498914 additions and 337 deletions

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;

View File

@@ -0,0 +1,155 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
// @inheritedComponent Popover
import React 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';
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 {
constructor(...args) {
var _temp;
return _temp = super(...args), this.getContentAnchorEl = () => {
if (!this.menuList || !this.menuList.selectedItem) {
// $FlowFixMe
return findDOMNode(this.menuList).firstChild;
}
return findDOMNode(this.menuList.selectedItem);
}, this.menuList = undefined, this.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();
}
}, this.handleEnter = element => {
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);
}
}, this.handleListKeyDown = (event, key) => {
if (key === 'tab') {
event.preventDefault();
if (this.props.onRequestClose) {
this.props.onRequestClose(event);
}
}
}, _temp;
}
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();
}
}
render() {
const _props = this.props,
{
children,
classes,
MenuListProps,
onEnter,
PaperProps = {},
PopoverClasses,
theme
} = _props,
other = _objectWithoutProperties(_props, ['children', 'classes', 'MenuListProps', 'onEnter', 'PaperProps', 'PopoverClasses', 'theme']);
return React.createElement(
Popover,
_extends({
getContentAnchorEl: this.getContentAnchorEl,
classes: PopoverClasses,
onEnter: this.handleEnter,
anchorOrigin: theme.direction === 'rtl' ? rtlOrigin : ltrOrigin,
transformOrigin: theme.direction === 'rtl' ? rtlOrigin : ltrOrigin,
PaperProps: _extends({}, PaperProps, {
classes: _extends({}, PaperProps.classes, {
root: classes.paper
})
})
}, other),
React.createElement(
MenuList,
_extends({
'data-mui-test': 'Menu',
role: 'menu',
onKeyDown: this.handleListKeyDown
}, MenuListProps, {
ref: node => {
this.menuList = node;
}
}),
children
)
);
}
}
Menu.defaultProps = {
open: false,
transitionDuration: 'auto'
};
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,55 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
// @inheritedComponent ListItem
import React from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import ListItem from '../List/ListItem';
export const styles = theme => ({
root: _extends({}, 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
}
});
function MenuItem(props) {
const { classes, className: classNameProp, component, selected, role } = props,
other = _objectWithoutProperties(props, ['classes', 'className', 'component', 'selected', 'role']);
const className = classNames(classes.root, {
[classes.selected]: selected
}, classNameProp);
return React.createElement(ListItem, _extends({
button: true,
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,159 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
// @inheritedComponent List
import React 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';
class MenuList extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.state = {
currentTabIndex: undefined
}, this.list = undefined, this.selectedItem = undefined, this.blurTimer = undefined, this.handleBlur = event => {
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);
}
}, this.handleKeyDown = event => {
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);
}
}, this.handleItemFocus = event => {
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;
}
}
}
}, _temp;
}
componentDidMount() {
this.resetTabIndex();
}
componentWillUnmount() {
clearTimeout(this.blurTimer);
}
setTabIndex(index) {
this.setState({ currentTabIndex: index });
}
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 _props = this.props,
{ children, className, onBlur, onKeyDown } = _props,
other = _objectWithoutProperties(_props, ['children', 'className', 'onBlur', 'onKeyDown']);
return React.createElement(
List,
_extends({
'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
});
})
);
}
}
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';

View File

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