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,27 @@
import * as React from 'react';
import { StandardProps, PropTypes } from '..';
export interface FormControlProps extends StandardProps<
React.HtmlHTMLAttributes<HTMLDivElement>,
FormControlClassKey
> {
disabled?: boolean;
error?: boolean;
fullWidth?: boolean;
margin?: PropTypes.Margin;
onBlur?: React.EventHandler<any>;
onFocus?: React.EventHandler<any>;
required?: boolean;
component?: React.ReactType;
}
export type FormControlClassKey =
| 'root'
| 'marginNormal'
| 'marginDense'
| 'fullWidth'
;
declare const FormControl: React.ComponentType<FormControlProps>;
export default FormControl;

View File

@@ -0,0 +1,166 @@
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 PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import { isDirty, isAdornedStart } from '../Input/Input';
import { isMuiElement } from '../utils/reactHelpers';
export const styles = theme => ({
root: {
display: 'inline-flex',
flexDirection: 'column',
position: 'relative',
// Reset fieldset default style
minWidth: 0,
padding: 0,
margin: 0,
border: 0
},
marginNormal: {
marginTop: theme.spacing.unit * 2,
marginBottom: theme.spacing.unit
},
marginDense: {
marginTop: theme.spacing.unit,
marginBottom: theme.spacing.unit / 2
},
fullWidth: {
width: '100%'
}
});
/**
* Provides context such as dirty/focused/error/required for form inputs.
* Relying on the context provides high flexibilty and ensures that the state always stay
* consitent across the children of the `FormControl`.
* This context is used by the following components:
* - FormLabel
* - FormHelperText
* - Input
* - InputLabel
*/
class FormControl extends React.Component {
constructor(props, context) {
super(props, context);
// We need to iterate through the children and find the Input in order
// to fully support server side rendering.
this.state = {
adornedStart: false,
dirty: false,
focused: false
};
this.handleFocus = event => {
if (this.props.onFocus) {
this.props.onFocus(event);
}
if (!this.state.focused) {
this.setState({ focused: true });
}
};
this.handleBlur = event => {
if (this.props.onBlur) {
this.props.onBlur(event);
}
if (this.state.focused) {
this.setState({ focused: false });
}
};
this.handleDirty = () => {
if (!this.state.dirty) {
this.setState({ dirty: true });
}
};
this.handleClean = () => {
if (this.state.dirty) {
this.setState({ dirty: false });
}
};
const { children } = this.props;
if (children) {
React.Children.forEach(children, child => {
if (isMuiElement(child, ['Input', 'Select']) && isDirty(child.props, true)) {
this.state.dirty = true;
}
if (isMuiElement(child, ['Input']) && isAdornedStart(child.props)) {
this.state.adornedStart = true;
}
});
}
}
getChildContext() {
const { disabled, error, required, margin } = this.props;
const { adornedStart, dirty, focused } = this.state;
return {
muiFormControl: {
adornedStart,
dirty,
disabled,
error,
focused,
margin,
required,
onDirty: this.handleDirty,
onClean: this.handleClean,
onFocus: this.handleFocus,
onBlur: this.handleBlur
}
};
}
render() {
const _props = this.props,
{
children,
classes,
className,
component: ComponentProp,
disabled,
error,
fullWidth,
margin
} = _props,
other = _objectWithoutProperties(_props, ['children', 'classes', 'className', 'component', 'disabled', 'error', 'fullWidth', 'margin']);
return React.createElement(
ComponentProp,
_extends({
className: classNames(classes.root, {
[classes.marginNormal]: margin === 'normal',
[classes.marginDense]: margin === 'dense',
[classes.fullWidth]: fullWidth
}, className)
}, other, {
onFocus: this.handleFocus,
onBlur: this.handleBlur
}),
children
);
}
}
FormControl.defaultProps = {
component: 'div',
disabled: false,
error: false,
fullWidth: false,
margin: 'none',
required: false
};
FormControl.childContextTypes = {
muiFormControl: PropTypes.object.isRequired
};
export default withStyles(styles, { name: 'MuiFormControl' })(FormControl);

View File

@@ -0,0 +1,27 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface FormControlLabelProps extends StandardProps<
React.LabelHTMLAttributes<HTMLLabelElement>,
FormControlLabelClassKey,
'onChange'
> {
checked?: boolean | string;
control: React.ReactElement<any>;
disabled?: boolean;
inputRef?: React.Ref<any>;
label: React.ReactNode;
name?: string;
onChange?: (event: React.ChangeEvent<{}>, checked: boolean) => void;
value?: string;
}
export type FormControlLabelClassKey =
| 'root'
| 'disabled'
| 'label'
;
declare const FormControlLabel: React.ComponentType<FormControlLabelProps>;
export default FormControlLabel;

View File

@@ -0,0 +1,94 @@
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; }
/* eslint-disable jsx-a11y/label-has-for */
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import Typography from '../Typography';
export const styles = theme => ({
root: {
display: 'inline-flex',
alignItems: 'center',
cursor: 'pointer',
// Remove grey highlight
WebkitTapHighlightColor: theme.palette.common.transparent,
marginLeft: -14,
marginRight: theme.spacing.unit * 2 // used for row presentation of radio/checkbox
},
disabled: {
color: theme.palette.text.disabled,
cursor: 'default'
},
label: {
userSelect: 'none'
}
});
/**
* Drop in replacement of the `Radio`, `Switch` and `Checkbox` component.
* Use this component if you want to display an extra label.
*/
function FormControlLabel(props, context) {
const {
checked,
classes,
className: classNameProp,
control,
disabled: disabledProp,
inputRef,
label,
name,
onChange,
value
} = props,
other = _objectWithoutProperties(props, ['checked', 'classes', 'className', 'control', 'disabled', 'inputRef', 'label', 'name', 'onChange', 'value']);
const { muiFormControl } = context;
let disabled = disabledProp;
if (typeof control.props.disabled !== 'undefined') {
if (typeof disabled === 'undefined') {
disabled = control.props.disabled;
}
}
if (muiFormControl) {
if (typeof disabled === 'undefined') {
disabled = muiFormControl.disabled;
}
}
const className = classNames(classes.root, {
[classes.disabled]: disabled
}, classNameProp);
return React.createElement(
'label',
_extends({ className: className }, other),
React.cloneElement(control, {
disabled,
checked: typeof control.props.checked === 'undefined' ? checked : control.props.checked,
name: control.props.name || name,
onChange: control.props.onChange || onChange,
value: control.props.value || value,
inputRef: control.props.inputRef || inputRef
}),
React.createElement(
Typography,
{ className: classes.label },
label
)
);
}
FormControlLabel.contextTypes = {
muiFormControl: PropTypes.object
};
export default withStyles(styles, { name: 'MuiFormControlLabel' })(FormControlLabel);

View File

@@ -0,0 +1,18 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface FormGroupProps extends StandardProps<
React.HtmlHTMLAttributes<HTMLDivElement>,
FormGroupClassKey
> {
row?: boolean;
}
export type FormGroupClassKey =
| 'root'
| 'row'
;
declare const FormGroup: React.ComponentType<FormGroupProps>;
export default FormGroup;

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; };
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 classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = {
root: {
display: 'flex',
flexDirection: 'column',
flexWrap: 'wrap'
},
row: {
flexDirection: 'row'
}
};
/**
* `FormGroup` wraps controls such as `Checkbox` and `Switch`.
* It provides compact row layout.
* For the `Radio`, you should be using the `RadioGroup` component instead of this one.
*/
function FormGroup(props) {
const { classes, className, children, row } = props,
other = _objectWithoutProperties(props, ['classes', 'className', 'children', 'row']);
const rootClassName = classNames(classes.root, {
[classes.row]: row
}, className);
return React.createElement(
'div',
_extends({ className: rootClassName }, other),
children
);
}
FormGroup.defaultProps = {
row: false
};
export default withStyles(styles, { name: 'MuiFormGroup' })(FormGroup);

View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface FormHelperTextProps extends StandardProps<
React.HTMLAttributes<HTMLParagraphElement>,
FormHelperTextClassKey
> {
disabled?: boolean;
error?: boolean;
margin?: 'dense';
}
export type FormHelperTextClassKey =
| 'root'
| 'dense'
| 'error'
| 'disabled'
;
declare const FormHelperText: React.ComponentType<FormHelperTextProps>;
export default FormHelperText;

View File

@@ -0,0 +1,80 @@
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 PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = theme => ({
root: {
color: theme.palette.input.helperText,
fontFamily: theme.typography.fontFamily,
fontSize: theme.typography.pxToRem(12),
textAlign: 'left',
marginTop: theme.spacing.unit,
lineHeight: '1em',
minHeight: '1em',
margin: 0
},
dense: {
marginTop: theme.spacing.unit / 2
},
error: {
color: theme.palette.error.A400
},
disabled: {
color: theme.palette.input.disabled
}
});
function FormHelperText(props, context) {
const {
children,
classes,
className: classNameProp,
disabled: disabledProp,
error: errorProp,
margin: marginProp
} = props,
other = _objectWithoutProperties(props, ['children', 'classes', 'className', 'disabled', 'error', 'margin']);
const { muiFormControl } = context;
let disabled = disabledProp;
let error = errorProp;
let margin = marginProp;
if (muiFormControl) {
if (typeof disabled === 'undefined') {
disabled = muiFormControl.disabled;
}
if (typeof error === 'undefined') {
error = muiFormControl.error;
}
if (typeof margin === 'undefined') {
margin = muiFormControl.margin;
}
}
const className = classNames(classes.root, {
[classes.disabled]: disabled,
[classes.error]: error,
[classes.dense]: margin === 'dense'
}, classNameProp);
return React.createElement(
'p',
_extends({ className: className }, other),
children
);
}
FormHelperText.contextTypes = {
muiFormControl: PropTypes.object
};
export default withStyles(styles, { name: 'MuiFormHelperText' })(FormHelperText);

View File

@@ -0,0 +1,23 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface FormLabelProps extends StandardProps<
React.LabelHTMLAttributes<HTMLLabelElement>,
FormLabelClassKey
> {
disabled?: boolean;
error?: boolean;
focused?: boolean;
required?: boolean;
}
export type FormLabelClassKey =
| 'root'
| 'focused'
| 'error'
| 'disabled'
;
declare const FormLabel: React.ComponentType<FormLabelProps>;
export default FormLabel;

View File

@@ -0,0 +1,98 @@
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 PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = theme => {
const focusColor = theme.palette.primary[theme.palette.type === 'light' ? 'A700' : 'A200'];
return {
root: {
fontFamily: theme.typography.fontFamily,
color: theme.palette.input.labelText,
fontSize: theme.typography.pxToRem(16),
lineHeight: 1,
padding: 0
},
focused: {
color: focusColor
},
error: {
color: theme.palette.error.A400
},
disabled: {
color: theme.palette.input.disabled
}
};
};
function FormLabel(props, context) {
const {
children,
classes,
className: classNameProp,
component: Component,
disabled: disabledProp,
error: errorProp,
focused: focusedProp,
required: requiredProp
} = props,
other = _objectWithoutProperties(props, ['children', 'classes', 'className', 'component', 'disabled', 'error', 'focused', 'required']);
const { muiFormControl } = context;
let required = requiredProp;
let focused = focusedProp;
let disabled = disabledProp;
let error = errorProp;
if (muiFormControl) {
if (typeof required === 'undefined') {
required = muiFormControl.required;
}
if (typeof focused === 'undefined') {
focused = muiFormControl.focused;
}
if (typeof disabled === 'undefined') {
disabled = muiFormControl.disabled;
}
if (typeof error === 'undefined') {
error = muiFormControl.error;
}
}
const className = classNames(classes.root, {
[classes.focused]: focused,
[classes.disabled]: disabled,
[classes.error]: error
}, classNameProp);
const asteriskClassName = classNames({
[classes.error]: error
});
return React.createElement(
Component,
_extends({ className: className }, other),
children,
required && React.createElement(
'span',
{ className: asteriskClassName, 'data-mui-test': 'FormLabelAsterisk' },
'\u2009*'
)
);
}
FormLabel.defaultProps = {
component: 'label'
};
FormLabel.contextTypes = {
muiFormControl: PropTypes.object
};
export default withStyles(styles, { name: 'MuiFormLabel' })(FormLabel);

View File

@@ -0,0 +1,10 @@
export { default as FormGroup } from './FormGroup';
export * from './FormGroup';
export { default as FormLabel } from './FormLabel';
export * from './FormLabel';
export { default as FormControl } from './FormControl';
export * from './FormControl';
export { default as FormHelperText } from './FormHelperText';
export * from './FormHelperText';
export { default as FormControlLabel } from './FormControlLabel';
export * from './FormControlLabel';

View File

@@ -0,0 +1,5 @@
export { default as FormGroup } from './FormGroup';
export { default as FormLabel } from './FormLabel';
export { default as FormControl } from './FormControl';
export { default as FormHelperText } from './FormHelperText';
export { default as FormControlLabel } from './FormControlLabel';