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,47 @@
import * as React from 'react';
import { StandardProps } from '..';
import { ButtonBaseProps } from '../ButtonBase';
import { ButtonBaseClassKey } from '../ButtonBase/ButtonBase';
export interface TabProps extends StandardProps<
ButtonBaseProps,
TabClassKey,
'onChange'
> {
disabled?: boolean;
fullWidth?: boolean;
icon?: string | React.ReactElement<any>;
value?: any;
label?: React.ReactNode;
onChange?: (
event: React.ChangeEvent<{ checked: boolean }>,
value: any
) => void;
onClick?: React.EventHandler<any>;
selected?: boolean;
style?: object;
textColor?: string | 'accent' | 'primary' | 'inherit';
}
export type TabClassKey =
| ButtonBaseClassKey
| 'rootLabelIcon'
| 'rootAccent'
| 'rootAccentSelected'
| 'rootAccentDisabled'
| 'rootPrimary'
| 'rootPrimarySelected'
| 'rootPrimaryDisabled'
| 'rootInherit'
| 'rootInheritSelected'
| 'rootInheritDisabled'
| 'fullWidth'
| 'wrapper'
| 'labelContainer'
| 'label'
| 'labelWrapped'
;
declare const Tab: React.ComponentType<TabProps>;
export default Tab;

225
torrent-project/node_modules/material-ui/es/Tabs/Tab.js generated vendored Normal file
View File

@@ -0,0 +1,225 @@
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 ButtonBase
import React from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import ButtonBase from '../ButtonBase';
import { capitalizeFirstLetter } from '../utils/helpers';
import Icon from '../Icon';
export const styles = theme => ({
root: _extends({}, theme.typography.button, {
maxWidth: 264,
position: 'relative',
minWidth: 72,
padding: 0,
height: 48,
flex: 'none',
overflow: 'hidden',
[theme.breakpoints.up('md')]: {
minWidth: 160
}
}),
rootLabelIcon: {
height: 72
},
rootAccent: {
color: theme.palette.text.secondary
},
rootAccentSelected: {
color: theme.palette.secondary.A200
},
rootAccentDisabled: {
color: theme.palette.text.disabled
},
rootPrimary: {
color: theme.palette.text.secondary
},
rootPrimarySelected: {
color: theme.palette.primary[500]
},
rootPrimaryDisabled: {
color: theme.palette.text.disabled
},
rootInherit: {
color: 'inherit',
opacity: 0.7
},
rootInheritSelected: {
opacity: 1
},
rootInheritDisabled: {
opacity: 0.4
},
fullWidth: {
flexGrow: 1
},
wrapper: {
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
flexDirection: 'column'
},
labelContainer: {
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 12,
paddingRight: 12,
[theme.breakpoints.up('md')]: {
paddingLeft: theme.spacing.unit * 3,
paddingRight: theme.spacing.unit * 3
}
},
label: {
fontSize: theme.typography.pxToRem(theme.typography.fontSize),
whiteSpace: 'normal',
[theme.breakpoints.up('md')]: {
fontSize: theme.typography.pxToRem(theme.typography.fontSize - 1)
}
},
labelWrapped: {
[theme.breakpoints.down('md')]: {
fontSize: theme.typography.pxToRem(theme.typography.fontSize - 2)
}
}
});
class Tab extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.state = {
wrappedText: false
}, this.handleChange = event => {
const { onChange, value, onClick } = this.props;
if (onChange) {
onChange(event, value);
}
if (onClick) {
onClick(event);
}
}, this.label = undefined, this.checkTextWrap = () => {
if (this.label) {
const wrappedText = this.label.getClientRects().length > 1;
if (this.state.wrappedText !== wrappedText) {
this.setState({ wrappedText });
}
}
}, _temp;
}
componentDidMount() {
this.checkTextWrap();
}
componentDidUpdate(prevProps, prevState) {
if (this.state.wrappedText === prevState.wrappedText) {
/**
* At certain text and tab lengths, a larger font size may wrap to two lines while the smaller
* font size still only requires one line. This check will prevent an infinite render loop
* fron occurring in that scenario.
*/
this.checkTextWrap();
}
}
render() {
const _props = this.props,
{
classes,
className: classNameProp,
disabled,
fullWidth,
icon: iconProp,
indicator,
label: labelProp,
onChange,
selected,
style: styleProp,
textColor,
value
} = _props,
other = _objectWithoutProperties(_props, ['classes', 'className', 'disabled', 'fullWidth', 'icon', 'indicator', 'label', 'onChange', 'selected', 'style', 'textColor', 'value']);
let icon;
if (iconProp !== undefined) {
icon = React.isValidElement(iconProp) ? iconProp : React.createElement(
Icon,
null,
iconProp
);
}
let label;
if (labelProp !== undefined) {
label = React.createElement(
'div',
{ className: classes.labelContainer },
React.createElement(
'span',
{
className: classNames(classes.label, {
[classes.labelWrapped]: this.state.wrappedText
}),
ref: node => {
this.label = node;
}
},
labelProp
)
);
}
const className = classNames(classes.root, {
[classes[`root${capitalizeFirstLetter(textColor)}`]]: true,
[classes[`root${capitalizeFirstLetter(textColor)}Disabled`]]: disabled,
[classes[`root${capitalizeFirstLetter(textColor)}Selected`]]: selected,
[classes.rootLabelIcon]: icon && label,
[classes.fullWidth]: fullWidth
}, classNameProp);
let style = {};
if (textColor !== 'accent' && textColor !== 'inherit') {
style.color = textColor;
}
style = Object.keys(style).length > 0 ? _extends({}, style, styleProp) : styleProp;
return React.createElement(
ButtonBase,
_extends({
focusRipple: true,
className: className,
style: style,
role: 'tab',
'aria-selected': selected,
disabled: disabled
}, other, {
onClick: this.handleChange
}),
React.createElement(
'span',
{ className: classes.wrapper },
icon,
label
),
indicator
);
}
}
Tab.defaultProps = {
disabled: false
};
export default withStyles(styles, { name: 'MuiTab' })(Tab);

View File

@@ -0,0 +1,20 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface TabIndicatorProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
TabIndicatorClassKey
> {
color: 'accent' | 'primary' | string;
style: { left: number; width: number };
}
export type TabIndicatorClassKey =
| 'root'
| 'colorAccent'
| 'colorPrimary'
;
declare const TabIndicator: React.ComponentType<TabIndicatorProps>;
export default TabIndicator;

View File

@@ -0,0 +1,44 @@
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; };
// weak
import React from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import { capitalizeFirstLetter } from '../utils/helpers';
export const styles = theme => ({
root: {
position: 'absolute',
height: 2,
bottom: 0,
width: '100%',
transition: theme.transitions.create(),
willChange: 'left, width'
},
colorAccent: {
backgroundColor: theme.palette.secondary.A200
},
colorPrimary: {
backgroundColor: theme.palette.primary[500]
}
});
/**
* @ignore - internal component.
*/
function TabIndicator(props) {
const { classes, className: classNameProp, color, style: styleProp } = props;
const colorPredefined = ['primary', 'accent'].indexOf(color) !== -1;
const className = classNames(classes.root, {
[classes[`color${capitalizeFirstLetter(color)}`]]: colorPredefined
}, classNameProp);
const style = colorPredefined ? styleProp : _extends({}, styleProp, {
backgroundColor: color
});
return React.createElement('div', { className: className, style: style });
}
export default withStyles(styles, { name: 'MuiTabIndicator' })(TabIndicator);

View File

@@ -0,0 +1,19 @@
import { StandardProps } from '..';
import { ButtonBaseProps, ButtonBaseClassKey } from '../ButtonBase/ButtonBase';
export interface TabScrollButtonProps extends StandardProps<
ButtonBaseProps,
TabScrollButtonClassKey
> {
direction?: 'left' | 'right';
visible?: boolean;
}
export type TabScrollButtonClassKey =
| ButtonBaseClassKey
| 'root'
;
declare const TabScrollButton: React.ComponentType<TabScrollButtonProps>;
export default TabScrollButton;

View File

@@ -0,0 +1,45 @@
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; }
// weak
import React from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import ButtonBase from '../ButtonBase';
import KeyboardArrowLeft from '../svg-icons/KeyboardArrowLeft';
import KeyboardArrowRight from '../svg-icons/KeyboardArrowRight';
export const styles = theme => ({
root: {
color: 'inherit',
flex: `0 0 ${theme.spacing.unit * 7}px`
}
});
/**
* @ignore - internal component.
*/
function TabScrollButton(props) {
const { classes, className: classNameProp, direction, onClick, visible } = props,
other = _objectWithoutProperties(props, ['classes', 'className', 'direction', 'onClick', 'visible']);
const className = classNames(classes.root, classNameProp);
if (!visible) {
return React.createElement('div', { className: className });
}
return React.createElement(
ButtonBase,
_extends({ className: className, onClick: onClick, tabIndex: -1 }, other),
direction === 'left' ? React.createElement(KeyboardArrowLeft, null) : React.createElement(KeyboardArrowRight, null)
);
}
TabScrollButton.defaultProps = {
visible: true
};
export default withStyles(styles, { name: 'MuiTabScrollButton' })(TabScrollButton);

View File

@@ -0,0 +1,36 @@
import * as React from 'react';
import { StandardProps } from '..';
import { ButtonBaseProps, ButtonBaseClassKey } from '../ButtonBase/ButtonBase';
export interface TabsProps extends StandardProps<
ButtonBaseProps,
TabsClassKey,
'onChange'
> {
buttonClassName?: string;
centered?: boolean;
children?: React.ReactNode;
fullWidth?: boolean;
value: any;
indicatorClassName?: string;
indicatorColor?: 'accent' | 'primary' | string;
onChange: (event: React.ChangeEvent<{}>, value: any) => void;
scrollable?: boolean;
scrollButtons?: 'auto' | 'on' | 'off';
TabScrollButton?: React.ReactType,
textColor?: 'accent' | 'primary' | 'inherit' | string;
width?: string;
}
export type TabsClassKey =
| ButtonBaseClassKey
| 'flexContainer'
| 'scrollingContainer'
| 'fixed'
| 'scrollable'
| 'centered'
;
declare const Tabs: React.ComponentType<TabsProps>;
export default Tabs;

View File

@@ -0,0 +1,341 @@
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; }
import React from 'react';
import warning from 'warning';
import classNames from 'classnames';
import EventListener from 'react-event-listener';
import debounce from 'lodash/debounce';
import ScrollbarSize from 'react-scrollbar-size';
import { getNormalizedScrollLeft, detectScrollType } from 'normalize-scroll-left';
import scroll from 'scroll';
import withStyles from '../styles/withStyles';
import TabIndicator from './TabIndicator';
import TabScrollButton from './TabScrollButton';
export const styles = theme => ({
root: {
overflow: 'hidden',
minHeight: 48,
WebkitOverflowScrolling: 'touch' // Add iOS momentum scrolling.
},
flexContainer: {
display: 'flex'
},
scrollingContainer: {
position: 'relative',
display: 'inline-block',
flex: '1 1 auto',
whiteSpace: 'nowrap'
},
fixed: {
overflowX: 'hidden',
width: '100%'
},
scrollable: {
overflowX: 'scroll'
},
centered: {
justifyContent: 'center'
},
buttonAuto: {
[theme.breakpoints.down('sm')]: {
display: 'none'
}
}
});
class Tabs extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.state = {
indicatorStyle: {
left: 0,
width: 0
},
scrollerStyle: {
marginBottom: 0
},
showLeftScroll: false,
showRightScroll: false,
mounted: false
}, this.getConditionalElements = () => {
const {
classes,
buttonClassName,
scrollable,
scrollButtons,
TabScrollButton: TabScrollButtonProp,
theme
} = this.props;
const conditionalElements = {};
conditionalElements.scrollbarSizeListener = scrollable ? React.createElement(ScrollbarSize, {
onLoad: this.handleScrollbarSizeChange,
onChange: this.handleScrollbarSizeChange
}) : null;
const showScrollButtons = scrollable && (scrollButtons === 'auto' || scrollButtons === 'on');
conditionalElements.scrollButtonLeft = showScrollButtons ? React.createElement(TabScrollButtonProp, {
direction: theme.direction === 'rtl' ? 'right' : 'left',
onClick: this.handleLeftScrollClick,
visible: this.state.showLeftScroll,
className: classNames({
[classes.buttonAuto]: scrollButtons === 'auto'
}, buttonClassName)
}) : null;
conditionalElements.scrollButtonRight = showScrollButtons ? React.createElement(TabScrollButtonProp, {
direction: theme.direction === 'rtl' ? 'left' : 'right',
onClick: this.handleRightScrollClick,
visible: this.state.showRightScroll,
className: classNames({
[classes.buttonAuto]: scrollButtons === 'auto'
}, buttonClassName)
}) : null;
return conditionalElements;
}, this.getTabsMeta = (value, direction) => {
let tabsMeta;
if (this.tabs) {
const rect = this.tabs.getBoundingClientRect();
// create a new object with ClientRect class props + scrollLeft
tabsMeta = {
clientWidth: this.tabs ? this.tabs.clientWidth : 0,
scrollLeft: this.tabs ? this.tabs.scrollLeft : 0,
scrollLeftNormalized: this.tabs ? getNormalizedScrollLeft(this.tabs, direction) : 0,
scrollWidth: this.tabs ? this.tabs.scrollWidth : 0,
left: rect.left,
right: rect.right
};
}
let tabMeta;
if (this.tabs && value !== false) {
const children = this.tabs.children[0].children;
if (children.length > 0) {
const tab = children[this.valueToIndex[value]];
warning(Boolean(tab), `Material-UI: the value provided \`${value}\` is invalid`);
tabMeta = tab ? tab.getBoundingClientRect() : null;
}
}
return { tabsMeta, tabMeta };
}, this.tabs = undefined, this.valueToIndex = {}, this.handleResize = debounce(() => {
this.updateIndicatorState(this.props);
this.updateScrollButtonState();
}, 166), this.handleLeftScrollClick = () => {
if (this.tabs) {
this.moveTabsScroll(-this.tabs.clientWidth);
}
}, this.handleRightScrollClick = () => {
if (this.tabs) {
this.moveTabsScroll(this.tabs.clientWidth);
}
}, this.handleScrollbarSizeChange = ({ scrollbarHeight }) => {
this.setState({
scrollerStyle: {
marginBottom: -scrollbarHeight
}
});
}, this.handleTabsScroll = debounce(() => {
this.updateScrollButtonState();
}, 166), this.moveTabsScroll = delta => {
const { theme } = this.props;
if (this.tabs) {
const multiplier = theme.direction === 'rtl' ? -1 : 1;
const nextScrollLeft = this.tabs.scrollLeft + delta * multiplier;
// Fix for Edge
const invert = theme.direction === 'rtl' && detectScrollType() === 'reverse' ? -1 : 1;
scroll.left(this.tabs, invert * nextScrollLeft);
}
}, this.scrollSelectedIntoView = () => {
const { theme, value } = this.props;
const { tabsMeta, tabMeta } = this.getTabsMeta(value, theme.direction);
if (!tabMeta || !tabsMeta) {
return;
}
if (tabMeta.left < tabsMeta.left) {
// left side of button is out of view
const nextScrollLeft = tabsMeta.scrollLeft + (tabMeta.left - tabsMeta.left);
scroll.left(this.tabs, nextScrollLeft);
} else if (tabMeta.right > tabsMeta.right) {
// right side of button is out of view
const nextScrollLeft = tabsMeta.scrollLeft + (tabMeta.right - tabsMeta.right);
scroll.left(this.tabs, nextScrollLeft);
}
}, this.updateScrollButtonState = () => {
const { scrollable, scrollButtons, theme } = this.props;
if (this.tabs && scrollable && scrollButtons !== 'off') {
const { scrollWidth, clientWidth } = this.tabs;
const scrollLeft = getNormalizedScrollLeft(this.tabs, theme.direction);
const showLeftScroll = theme.direction === 'rtl' ? scrollWidth > clientWidth + scrollLeft : scrollLeft > 0;
const showRightScroll = theme.direction === 'rtl' ? scrollLeft > 0 : scrollWidth > clientWidth + scrollLeft;
if (showLeftScroll !== this.state.showLeftScroll || showRightScroll !== this.state.showRightScroll) {
this.setState({ showLeftScroll, showRightScroll });
}
}
}, _temp;
}
componentDidMount() {
// eslint-disable-next-line react/no-did-mount-set-state
this.setState({ mounted: true });
this.updateIndicatorState(this.props);
this.updateScrollButtonState();
}
componentDidUpdate(prevProps, prevState) {
this.updateScrollButtonState();
// The index might have changed at the same time.
// We need to check again the right indicator position.
this.updateIndicatorState(this.props);
if (this.state.indicatorStyle !== prevState.indicatorStyle) {
this.scrollSelectedIntoView();
}
}
componentWillUnmount() {
this.handleResize.cancel();
this.handleTabsScroll.cancel();
}
updateIndicatorState(props) {
const { theme, value } = props;
const { tabsMeta, tabMeta } = this.getTabsMeta(value, theme.direction);
let left = 0;
if (tabMeta && tabsMeta) {
const correction = theme.direction === 'rtl' ? tabsMeta.scrollLeftNormalized + tabsMeta.clientWidth - tabsMeta.scrollWidth : tabsMeta.scrollLeft;
left = tabMeta.left - tabsMeta.left + correction;
}
const indicatorStyle = {
left,
// May be wrong until the font is loaded.
width: tabMeta ? tabMeta.width : 0
};
if ((indicatorStyle.left !== this.state.indicatorStyle.left || indicatorStyle.width !== this.state.indicatorStyle.width) && !Number.isNaN(indicatorStyle.left) && !Number.isNaN(indicatorStyle.width)) {
this.setState({ indicatorStyle });
}
}
render() {
const _props = this.props,
{
buttonClassName,
centered,
classes,
children: childrenProp,
className: classNameProp,
fullWidth,
indicatorClassName,
indicatorColor,
onChange,
scrollable,
scrollButtons,
TabScrollButton: TabScrollButtonProp,
textColor,
theme,
value
} = _props,
other = _objectWithoutProperties(_props, ['buttonClassName', 'centered', 'classes', 'children', 'className', 'fullWidth', 'indicatorClassName', 'indicatorColor', 'onChange', 'scrollable', 'scrollButtons', 'TabScrollButton', 'textColor', 'theme', 'value']);
const className = classNames(classes.root, classNameProp);
const scrollerClassName = classNames(classes.scrollingContainer, {
[classes.fixed]: !scrollable,
[classes.scrollable]: scrollable
});
const tabItemContainerClassName = classNames(classes.flexContainer, {
[classes.centered]: centered && !scrollable
});
const indicator = React.createElement(TabIndicator, {
style: this.state.indicatorStyle,
className: indicatorClassName,
color: indicatorColor
});
this.valueToIndex = {};
let childIndex = 0;
const children = React.Children.map(childrenProp, child => {
if (!React.isValidElement(child)) {
return null;
}
const childValue = child.props.value || childIndex;
this.valueToIndex[childValue] = childIndex;
const selected = childValue === value;
childIndex += 1;
return React.cloneElement(child, {
fullWidth,
indicator: selected && !this.state.mounted && indicator,
selected,
onChange,
textColor,
value: childValue
});
});
const conditionalElements = this.getConditionalElements();
return React.createElement(
'div',
_extends({ className: className }, other),
React.createElement(EventListener, { target: 'window', onResize: this.handleResize }),
conditionalElements.scrollbarSizeListener,
React.createElement(
'div',
{ className: classes.flexContainer },
conditionalElements.scrollButtonLeft,
React.createElement(
'div',
{
className: scrollerClassName,
style: this.state.scrollerStyle,
ref: node => {
this.tabs = node;
},
role: 'tablist',
onScroll: this.handleTabsScroll
},
React.createElement(
'div',
{ className: tabItemContainerClassName },
children
),
this.state.mounted && indicator
),
conditionalElements.scrollButtonRight
)
);
}
}
Tabs.defaultProps = {
centered: false,
fullWidth: false,
indicatorColor: 'accent',
scrollable: false,
scrollButtons: 'auto',
TabScrollButton,
textColor: 'inherit'
};
export default withStyles(styles, { withTheme: true, name: 'MuiTabs' })(Tabs);

View File

@@ -0,0 +1,4 @@
export { default } from './Tabs';
export * from './Tabs';
export { default as Tab } from './Tab';
export * from './Tab';

View File

@@ -0,0 +1,2 @@
export { default } from './Tabs';
export { default as Tab } from './Tab';