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,24 @@
import { PropTypes, StandardProps } from '..';
import { PaperProps, PaperClassKey } from '../Paper/Paper';
export interface AppBarProps extends StandardProps<
PaperProps,
AppBarClassKey
> {
color?: PropTypes.Color;
position?: 'static' | 'fixed' | 'absolute';
}
export type AppBarClassKey =
| PaperClassKey
| 'positionFixed'
| 'positionAbsolute'
| 'positionStatic'
| 'colorDefault'
| 'colorPrimary'
| 'colorAccent'
;
declare const AppBar: React.ComponentType<AppBarProps>;
export default AppBar;

View File

@@ -0,0 +1,74 @@
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 Paper
import React from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import { capitalizeFirstLetter } from '../utils/helpers';
import Paper from '../Paper';
export const styles = theme => ({
root: {
display: 'flex',
flexDirection: 'column',
width: '100%',
boxSizing: 'border-box', // Prevent padding issue with the Modal and fixed positioned AppBar.
zIndex: theme.zIndex.appBar,
flexShrink: 0
},
positionFixed: {
position: 'fixed',
top: 0,
left: 'auto',
right: 0
},
positionAbsolute: {
position: 'absolute',
top: 0,
left: 'auto',
right: 0
},
positionStatic: {
position: 'static',
flexShrink: 0
},
colorDefault: {
backgroundColor: theme.palette.background.appBar,
color: theme.palette.getContrastText(theme.palette.background.appBar)
},
colorPrimary: {
backgroundColor: theme.palette.primary[500],
color: theme.palette.getContrastText(theme.palette.primary[500])
},
colorAccent: {
backgroundColor: theme.palette.secondary.A200,
color: theme.palette.getContrastText(theme.palette.secondary.A200)
}
});
function AppBar(props) {
const { children, classes, className: classNameProp, color, position } = props,
other = _objectWithoutProperties(props, ['children', 'classes', 'className', 'color', 'position']);
const className = classNames(classes.root, classes[`position${capitalizeFirstLetter(position)}`], {
[classes[`color${capitalizeFirstLetter(color)}`]]: color !== 'inherit',
'mui-fixed': position === 'fixed' // Useful for the Dialog
}, classNameProp);
return React.createElement(
Paper,
_extends({ square: true, component: 'header', elevation: 4, className: className }, other),
children
);
}
AppBar.defaultProps = {
color: 'primary',
position: 'fixed'
};
export default withStyles(styles, { name: 'MuiAppBar' })(AppBar);

View File

@@ -0,0 +1,2 @@
export { default } from './AppBar';
export * from './AppBar';

View File

@@ -0,0 +1 @@
export { default } from './AppBar';

View File

@@ -0,0 +1,25 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface AvatarProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
AvatarClassKey
> {
alt?: string;
childrenClassName?: string;
component?: React.ReactType;
imgProps?: Object;
sizes?: string;
src?: string;
srcSet?: string;
}
export type AvatarClassKey =
| 'root'
| 'colorDefault'
| 'img'
;
declare const Avatar: React.ComponentType<AvatarProps>;
export default Avatar;

View File

@@ -0,0 +1,85 @@
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';
import { emphasize } from '../styles/colorManipulator';
export const styles = theme => ({
root: {
position: 'relative',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
width: 40,
height: 40,
fontFamily: theme.typography.fontFamily,
fontSize: theme.typography.pxToRem(20),
borderRadius: '50%',
overflow: 'hidden',
userSelect: 'none'
},
colorDefault: {
color: theme.palette.background.default,
backgroundColor: emphasize(theme.palette.background.default, 0.26)
},
img: {
maxWidth: '100%',
width: '100%',
height: 'auto'
}
});
function Avatar(props) {
const {
alt,
classes,
className: classNameProp,
children: childrenProp,
childrenClassName: childrenClassNameProp,
component: ComponentProp,
imgProps,
sizes,
src,
srcSet
} = props,
other = _objectWithoutProperties(props, ['alt', 'classes', 'className', 'children', 'childrenClassName', 'component', 'imgProps', 'sizes', 'src', 'srcSet']);
const className = classNames(classes.root, {
[classes.colorDefault]: childrenProp && !src && !srcSet
}, classNameProp);
let children = null;
if (childrenProp) {
if (childrenClassNameProp && typeof childrenProp !== 'string' && React.isValidElement(childrenProp)) {
const childrenClassName = classNames(childrenClassNameProp, childrenProp.props.className);
children = React.cloneElement(childrenProp, { className: childrenClassName });
} else {
children = childrenProp;
}
} else if (src || srcSet) {
children = React.createElement('img', _extends({
alt: alt,
src: src,
srcSet: srcSet,
sizes: sizes,
className: classes.img
}, imgProps));
}
return React.createElement(
ComponentProp,
_extends({ className: className }, other),
children
);
}
Avatar.defaultProps = {
component: 'div'
};
export default withStyles(styles, { name: 'MuiAvatar' })(Avatar);

View File

@@ -0,0 +1,2 @@
export { default } from './Avatar';
export * from './Avatar';

View File

@@ -0,0 +1 @@
export { default } from './Avatar';

View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import { StandardProps, PropTypes } from '..';
export interface BadgeProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
BadgeClassKey
> {
badgeContent: React.ReactNode;
children: React.ReactNode;
color?: PropTypes.Color;
}
export type BadgeClassKey =
| 'root'
| 'badge'
| 'colorPrimary'
| 'colorAccent'
;
declare const Badge: React.ComponentType<BadgeProps>;
export default Badge;

View File

@@ -0,0 +1,74 @@
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 { capitalizeFirstLetter } from '../utils/helpers';
const RADIUS = 12;
export const styles = theme => ({
root: {
position: 'relative',
display: 'inline-flex'
},
badge: {
display: 'flex',
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'center',
alignContent: 'center',
alignItems: 'center',
position: 'absolute',
top: -RADIUS,
right: -RADIUS,
fontFamily: theme.typography.fontFamily,
fontWeight: theme.typography.fontWeight,
fontSize: theme.typography.pxToRem(RADIUS),
width: RADIUS * 2,
height: RADIUS * 2,
borderRadius: '50%',
backgroundColor: theme.palette.color,
color: theme.palette.textColor,
zIndex: 1 // Render the badge on top of potential ripples.
},
colorPrimary: {
backgroundColor: theme.palette.primary[500],
color: theme.palette.getContrastText(theme.palette.primary[500])
},
colorAccent: {
backgroundColor: theme.palette.secondary.A200,
color: theme.palette.getContrastText(theme.palette.secondary.A200)
}
});
function Badge(props) {
const { badgeContent, classes, className: classNameProp, color, children } = props,
other = _objectWithoutProperties(props, ['badgeContent', 'classes', 'className', 'color', 'children']);
const className = classNames(classes.root, classNameProp);
const badgeClassName = classNames(classes.badge, {
[classes[`color${capitalizeFirstLetter(color)}`]]: color !== 'default'
});
return React.createElement(
'div',
_extends({ className: className }, other),
children,
React.createElement(
'span',
{ className: badgeClassName },
badgeContent
)
);
}
Badge.defaultProps = {
color: 'default'
};
export default withStyles(styles, { name: 'MuiBadge' })(Badge);

View File

@@ -0,0 +1,2 @@
export { default } from './Badge';
export * from './Badge';

View File

@@ -0,0 +1 @@
export { default } from './Badge';

View File

@@ -0,0 +1,21 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface BottomNavigationProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
BottomNavigationClassKey,
'onChange'
> {
children: React.ReactNode;
onChange?: (event: React.ChangeEvent<{}>, value: any) => void;
showLabels?: boolean;
value?: any;
}
export type BottomNavigationClassKey =
| 'root'
;
declare const BottomNavigation: React.ComponentType<BottomNavigationProps>;
export default BottomNavigation;

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; }
// weak
import React from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = theme => ({
root: {
display: 'flex',
justifyContent: 'center',
height: 56,
backgroundColor: theme.palette.background.paper
}
});
function BottomNavigation(props) {
const {
children: childrenProp,
classes,
className: classNameProp,
onChange,
showLabels,
value
} = props,
other = _objectWithoutProperties(props, ['children', 'classes', 'className', 'onChange', 'showLabels', 'value']);
const className = classNames(classes.root, classNameProp);
const children = React.Children.map(childrenProp, (child, childIndex) => {
const childValue = child.props.value || childIndex;
return React.cloneElement(child, {
selected: childValue === value,
showLabel: child.props.showLabel !== undefined ? child.props.showLabel : showLabels,
value: childValue,
onChange
});
});
return React.createElement(
'div',
_extends({ className: className }, other),
children
);
}
BottomNavigation.defaultProps = {
showLabels: false
};
export default withStyles(styles, { name: 'MuiBottomNavigation' })(BottomNavigation);

View File

@@ -0,0 +1,32 @@
import * as React from 'react';
import { StandardProps } from '..';
import { ButtonBaseProps, ButtonBaseClassKey } from '../ButtonBase';
export interface BottomNavigationButtonProps extends StandardProps<
ButtonBaseProps,
BottomNavigationButtonClassKey,
'onChange'
> {
icon?: string | React.ReactElement<any>;
label?: React.ReactNode;
onChange?: (event: React.ChangeEvent<{}>, value: any) => void;
onClick?: React.ReactEventHandler<any>;
selected?: boolean;
showLabel?: boolean;
value?: any;
}
export type BottomNavigationButtonClassKey =
| ButtonBaseClassKey
| 'selected'
| 'selectedIconOnly'
| 'wrapper'
| 'label'
| 'selectedLabel'
| 'hiddenLabel'
| 'icon'
;
declare const BottomNavigationButton: React.ComponentType<BottomNavigationButtonProps>;
export default BottomNavigationButton;

View File

@@ -0,0 +1,136 @@
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 Icon from '../Icon';
export const styles = theme => ({
root: {
transition: theme.transitions.create(['color', 'padding-top'], {
duration: theme.transitions.duration.short
}),
paddingTop: 8,
paddingBottom: 10,
paddingLeft: 12,
paddingRight: 12,
minWidth: 80,
maxWidth: 168,
color: theme.palette.text.secondary,
flex: '1'
},
selected: {
paddingTop: 6,
color: theme.palette.primary[500]
},
selectedIconOnly: {
paddingTop: theme.spacing.unit * 2
},
wrapper: {
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
flexDirection: 'column'
},
label: {
fontFamily: theme.typography.fontFamily,
fontSize: theme.typography.pxToRem(theme.typography.fontSize - 2),
opacity: 1,
transition: 'font-size 0.2s, opacity 0.2s',
transitionDelay: '0.1s'
},
selectedLabel: {
fontSize: theme.typography.pxToRem(theme.typography.fontSize)
},
hiddenLabel: {
opacity: 0,
transitionDelay: '0s'
},
icon: {
display: 'block',
margin: 'auto'
}
});
class BottomNavigationButton extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.handleChange = event => {
const { onChange, value, onClick } = this.props;
if (onChange) {
onChange(event, value);
}
if (onClick) {
onClick(event);
}
}, _temp;
}
render() {
const _props = this.props,
{
label,
icon: iconProp,
selected,
classes,
className: classNameProp,
showLabel: showLabelProp,
onChange,
value
} = _props,
other = _objectWithoutProperties(_props, ['label', 'icon', 'selected', 'classes', 'className', 'showLabel', 'onChange', 'value']);
const className = classNames(classes.root, {
[classes.selected]: selected,
[classes.selectedIconOnly]: !showLabelProp && !selected
}, classNameProp);
let icon = null;
if (iconProp) {
if (React.isValidElement(iconProp) && typeof iconProp !== 'string') {
icon = React.cloneElement(iconProp, {
className: classNames(classes.icon, iconProp.props.className)
});
} else {
icon = React.createElement(
Icon,
null,
iconProp
);
}
}
const labelClassName = classNames(classes.label, {
[classes.selectedLabel]: selected,
[classes.hiddenLabel]: !showLabelProp && !selected
});
return React.createElement(
ButtonBase,
_extends({ className: className, focusRipple: true }, other, { onClick: this.handleChange }),
React.createElement(
'span',
{ className: classes.wrapper },
icon,
React.createElement(
'span',
{ className: labelClassName },
label
)
)
);
}
}
export default withStyles(styles, { name: 'MuiBottomNavigationButton' })(BottomNavigationButton);

View File

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

View File

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

View File

@@ -0,0 +1,39 @@
import * as React from 'react';
import { StandardProps, PropTypes } from '..';
import { ButtonBaseProps, ButtonBaseClassKey } from '../ButtonBase';
export interface ButtonProps extends StandardProps<
ButtonBaseProps,
ButtonClassKey
> {
color?: PropTypes.Color | 'contrast';
component?: React.ReactType;
dense?: boolean;
disabled?: boolean;
disableFocusRipple?: boolean;
disableRipple?: boolean;
fab?: boolean;
href?: string;
raised?: boolean;
type?: string;
}
export type ButtonClassKey =
| ButtonBaseClassKey
| 'dense'
| 'label'
| 'flatPrimary'
| 'flatAccent'
| 'flatContrast'
| 'colorInherit'
| 'raised'
| 'keyboardFocused'
| 'raisedPrimary'
| 'raisedAccent'
| 'raisedContrast'
| 'fab'
;
declare const Button: React.ComponentType<ButtonProps>;
export default Button

View File

@@ -0,0 +1,211 @@
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 { fade } from '../styles/colorManipulator';
import ButtonBase from '../ButtonBase';
export const styles = theme => ({
root: _extends({}, theme.typography.button, {
lineHeight: '1.4em', // Improve readability for multiline button.
boxSizing: 'border-box',
minWidth: 88,
minHeight: 36,
padding: `${theme.spacing.unit}px ${theme.spacing.unit * 2}px`,
borderRadius: 2,
color: theme.palette.text.primary,
transition: theme.transitions.create(['background-color', 'box-shadow'], {
duration: theme.transitions.duration.short
}),
'&:hover': {
textDecoration: 'none',
// Reset on mouse devices
backgroundColor: fade(theme.palette.text.primary, 0.12),
'@media (hover: none)': {
backgroundColor: 'transparent'
},
'&$disabled': {
backgroundColor: 'transparent'
}
}
}),
dense: {
padding: `${theme.spacing.unit - 1}px ${theme.spacing.unit}px`,
minWidth: 64,
minHeight: 32,
fontSize: theme.typography.pxToRem(theme.typography.fontSize - 1)
},
label: {
width: '100%',
display: 'inherit',
alignItems: 'inherit',
justifyContent: 'inherit'
},
flatPrimary: {
color: theme.palette.primary[500],
'&:hover': {
backgroundColor: fade(theme.palette.primary[500], 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent'
}
}
},
flatAccent: {
color: theme.palette.secondary.A200,
'&:hover': {
backgroundColor: fade(theme.palette.secondary.A200, 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent'
}
}
},
flatContrast: {
color: theme.palette.getContrastText(theme.palette.primary[500]),
'&:hover': {
backgroundColor: fade(theme.palette.getContrastText(theme.palette.primary[500]), 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent'
}
}
},
colorInherit: {
color: 'inherit'
},
raised: {
color: theme.palette.getContrastText(theme.palette.grey[300]),
backgroundColor: theme.palette.grey[300],
boxShadow: theme.shadows[2],
'&$keyboardFocused': {
boxShadow: theme.shadows[6]
},
'&:active': {
boxShadow: theme.shadows[8]
},
'&$disabled': {
boxShadow: theme.shadows[0],
backgroundColor: theme.palette.text.divider
},
'&:hover': {
backgroundColor: theme.palette.grey.A100,
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: theme.palette.grey[300]
},
'&$disabled': {
backgroundColor: theme.palette.text.divider,
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: theme.palette.grey[300]
}
}
}
},
keyboardFocused: {},
raisedPrimary: {
color: theme.palette.getContrastText(theme.palette.primary[500]),
backgroundColor: theme.palette.primary[500],
'&:hover': {
backgroundColor: theme.palette.primary[700],
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: theme.palette.primary[500]
}
}
},
raisedAccent: {
color: theme.palette.getContrastText(theme.palette.secondary.A200),
backgroundColor: theme.palette.secondary.A200,
'&:hover': {
backgroundColor: theme.palette.secondary.A400,
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: theme.palette.secondary.A200
}
}
},
raisedContrast: {
color: theme.palette.getContrastText(theme.palette.primary[500])
},
disabled: {
color: theme.palette.action.disabled
},
fab: {
borderRadius: '50%',
padding: 0,
minWidth: 0,
width: 56,
height: 56,
boxShadow: theme.shadows[6],
'&:active': {
boxShadow: theme.shadows[12]
}
}
});
function Button(props) {
const {
children,
classes,
className: classNameProp,
color,
dense,
disabled,
disableFocusRipple,
fab,
raised
} = props,
other = _objectWithoutProperties(props, ['children', 'classes', 'className', 'color', 'dense', 'disabled', 'disableFocusRipple', 'fab', 'raised']);
const flat = !raised && !fab;
const className = classNames({
[classes.root]: true,
[classes.raised]: raised || fab,
[classes.fab]: fab,
[classes.colorInherit]: color === 'inherit',
[classes.flatPrimary]: flat && color === 'primary',
[classes.flatAccent]: flat && color === 'accent',
[classes.flatContrast]: flat && color === 'contrast',
[classes.raisedPrimary]: !flat && color === 'primary',
[classes.raisedAccent]: !flat && color === 'accent',
[classes.raisedContrast]: !flat && color === 'contrast',
[classes.dense]: dense,
[classes.disabled]: disabled
}, classNameProp);
return React.createElement(
ButtonBase,
_extends({
className: className,
disabled: disabled,
focusRipple: !disableFocusRipple,
keyboardFocusedClassName: classes.keyboardFocused
}, other),
React.createElement(
'span',
{ className: classes.label },
children
)
);
}
Button.defaultProps = {
color: 'default',
dense: false,
disabled: false,
fab: false,
disableFocusRipple: false,
raised: false,
disableRipple: false,
type: 'button'
};
export default withStyles(styles, { name: 'MuiButton' })(Button);

View File

@@ -0,0 +1,2 @@
export { default } from './Button';
export * from './Button';

View File

@@ -0,0 +1 @@
export { default } from './Button';

View File

@@ -0,0 +1,24 @@
import * as React from 'react';
import { StandardProps, Replace } from '..';
export interface ButtonBaseProps extends StandardProps<
Replace<React.AnchorHTMLAttributes<HTMLAnchorElement>, React.ButtonHTMLAttributes<HTMLButtonElement>>,
ButtonBaseClassKey
> {
centerRipple?: boolean;
component?: React.ReactType;
disableRipple?: boolean;
focusRipple?: boolean;
keyboardFocusedClassName?: string;
onKeyboardFocus?: React.FocusEventHandler<any>;
rootRef?: React.Ref<any>;
}
export type ButtonBaseClassKey =
| 'root'
| 'disabled'
;
declare const ButtonBase: React.ComponentType<ButtonBaseProps>;
export default ButtonBase;

View File

@@ -0,0 +1,239 @@
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 { findDOMNode } from 'react-dom';
import classNames from 'classnames';
import keycode from 'keycode';
import withStyles from '../styles/withStyles';
import { listenForFocusKeys, detectKeyboardFocus, focusKeyPressed } from '../utils/keyboardFocus';
import TouchRipple from './TouchRipple';
import createRippleHandler from './createRippleHandler';
export const styles = theme => ({
root: {
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
position: 'relative',
// Remove grey highlight
WebkitTapHighlightColor: theme.palette.common.transparent,
backgroundColor: 'transparent', // Reset default value
outline: 'none',
border: 0,
borderRadius: 0,
cursor: 'pointer',
userSelect: 'none',
appearance: 'none',
textDecoration: 'none',
// So we take precedent over the style of a native <a /> element.
color: 'inherit',
'&::-moz-focus-inner': {
borderStyle: 'none' // Remove Firefox dotted outline.
}
},
disabled: {
pointerEvents: 'none', // Disable link interactions
cursor: 'default'
}
});
class ButtonBase extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.state = {
keyboardFocused: false
}, this.onKeyboardFocusHandler = event => {
this.keyDown = false;
this.setState({ keyboardFocused: true });
if (this.props.onKeyboardFocus) {
this.props.onKeyboardFocus(event);
}
}, this.ripple = null, this.keyDown = false, this.button = null, this.keyboardFocusTimeout = null, this.keyboardFocusCheckTime = 30, this.keyboardFocusMaxCheckTimes = 5, this.handleKeyDown = event => {
const { component, focusRipple, onKeyDown, onClick } = this.props;
const key = keycode(event);
// Check if key is already down to avoid repeats being counted as multiple activations
if (focusRipple && !this.keyDown && this.state.keyboardFocused && key === 'space') {
this.keyDown = true;
event.persist();
this.ripple.stop(event, () => {
this.ripple.start(event);
});
}
if (onKeyDown) {
onKeyDown(event);
}
// Keyboard accessibility for non interactive elements
if (event.target === this.button && onClick && component && component !== 'a' && component !== 'button' && (key === 'space' || key === 'enter')) {
event.preventDefault();
onClick(event);
}
}, this.handleKeyUp = event => {
if (this.props.focusRipple && keycode(event) === 'space' && this.state.keyboardFocused) {
this.keyDown = false;
event.persist();
this.ripple.stop(event, () => this.ripple.pulsate(event));
}
if (this.props.onKeyUp) {
this.props.onKeyUp(event);
}
}, this.handleMouseDown = createRippleHandler(this, 'MouseDown', 'start', () => {
clearTimeout(this.keyboardFocusTimeout);
focusKeyPressed(false);
if (this.state.keyboardFocused) {
this.setState({ keyboardFocused: false });
}
}), this.handleMouseUp = createRippleHandler(this, 'MouseUp', 'stop'), this.handleMouseLeave = createRippleHandler(this, 'MouseLeave', 'stop', event => {
if (this.state.keyboardFocused) {
event.preventDefault();
}
}), this.handleTouchStart = createRippleHandler(this, 'TouchStart', 'start'), this.handleTouchEnd = createRippleHandler(this, 'TouchEnd', 'stop'), this.handleTouchMove = createRippleHandler(this, 'TouchEnd', 'stop'), this.handleBlur = createRippleHandler(this, 'Blur', 'stop', () => {
clearTimeout(this.keyboardFocusTimeout);
focusKeyPressed(false);
this.setState({ keyboardFocused: false });
}), this.handleFocus = event => {
if (this.props.disabled) {
return;
}
// Fix for https://github.com/facebook/react/issues/7769
if (!this.button) {
this.button = event.currentTarget;
}
event.persist();
const keyboardFocusCallback = this.onKeyboardFocusHandler.bind(this, event);
detectKeyboardFocus(this, this.button, keyboardFocusCallback);
if (this.props.onFocus) {
this.props.onFocus(event);
}
}, _temp;
}
componentDidMount() {
this.button = findDOMNode(this);
listenForFocusKeys();
}
componentWillUpdate(nextProps, nextState) {
if (this.props.focusRipple && nextState.keyboardFocused && !this.state.keyboardFocused && !this.props.disableRipple) {
this.ripple.pulsate();
}
}
componentWillUnmount() {
this.button = null;
clearTimeout(this.keyboardFocusTimeout);
} // Used to help track keyboard activation keyDown
renderRipple() {
if (!this.props.disableRipple && !this.props.disabled) {
return React.createElement(TouchRipple, {
innerRef: node => {
this.ripple = node;
},
center: this.props.centerRipple
});
}
return null;
}
render() {
const _props = this.props,
{
centerRipple,
children,
classes,
className: classNameProp,
component,
disabled,
disableRipple,
focusRipple,
keyboardFocusedClassName,
onBlur,
onFocus,
onKeyboardFocus,
onKeyDown,
onKeyUp,
onMouseDown,
onMouseLeave,
onMouseUp,
onTouchEnd,
onTouchMove,
onTouchStart,
rootRef,
tabIndex,
type
} = _props,
other = _objectWithoutProperties(_props, ['centerRipple', 'children', 'classes', 'className', 'component', 'disabled', 'disableRipple', 'focusRipple', 'keyboardFocusedClassName', 'onBlur', 'onFocus', 'onKeyboardFocus', 'onKeyDown', 'onKeyUp', 'onMouseDown', 'onMouseLeave', 'onMouseUp', 'onTouchEnd', 'onTouchMove', 'onTouchStart', 'rootRef', 'tabIndex', 'type']);
const className = classNames(classes.root, {
[classes.disabled]: disabled,
[keyboardFocusedClassName || '']: this.state.keyboardFocused
}, classNameProp);
const buttonProps = {};
let ComponentProp = component;
if (!ComponentProp) {
if (other.href) {
ComponentProp = 'a';
} else {
ComponentProp = 'button';
}
}
if (ComponentProp === 'button') {
buttonProps.type = type || 'button';
}
if (ComponentProp !== 'a') {
buttonProps.role = buttonProps.role || 'button';
buttonProps.disabled = disabled;
}
return React.createElement(
ComponentProp,
_extends({
onBlur: this.handleBlur,
onFocus: this.handleFocus,
onKeyDown: this.handleKeyDown,
onKeyUp: this.handleKeyUp,
onMouseDown: this.handleMouseDown,
onMouseLeave: this.handleMouseLeave,
onMouseUp: this.handleMouseUp,
onTouchEnd: this.handleTouchEnd,
onTouchMove: this.handleTouchMove,
onTouchStart: this.handleTouchStart,
tabIndex: disabled ? -1 : tabIndex,
className: className
}, buttonProps, other, {
ref: rootRef
}),
children,
this.renderRipple()
);
}
}
ButtonBase.defaultProps = {
centerRipple: false,
focusRipple: false,
disableRipple: false,
tabIndex: 0,
type: 'button'
};
export default withStyles(styles, { name: 'MuiButtonBase' })(ButtonBase);

View File

@@ -0,0 +1,79 @@
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 Transition from 'react-transition-group/Transition';
/**
* @ignore - internal component.
*/
class Ripple extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.state = {
rippleVisible: false,
rippleLeaving: false
}, this.getRippleStyles = props => {
const { rippleSize, rippleX, rippleY } = props;
return {
width: rippleSize,
height: rippleSize,
top: -(rippleSize / 2) + rippleY,
left: -(rippleSize / 2) + rippleX
};
}, this.handleEnter = () => {
this.setState({
rippleVisible: true
});
}, this.handleExit = () => {
this.setState({
rippleLeaving: true
});
}, _temp;
}
render() {
const _props = this.props,
{
classes,
className: classNameProp,
pulsate,
rippleX,
rippleY,
rippleSize
} = _props,
other = _objectWithoutProperties(_props, ['classes', 'className', 'pulsate', 'rippleX', 'rippleY', 'rippleSize']);
const { rippleVisible, rippleLeaving } = this.state;
const className = classNames(classes.wrapper, {
[classes.wrapperLeaving]: rippleLeaving,
[classes.wrapperPulsating]: pulsate
}, classNameProp);
const rippleClassName = classNames(classes.ripple, {
[classes.rippleVisible]: rippleVisible,
[classes.rippleFast]: pulsate
});
return React.createElement(
Transition,
_extends({ onEnter: this.handleEnter, onExit: this.handleExit }, other),
React.createElement(
'span',
{ className: className },
React.createElement('span', { className: rippleClassName, style: this.getRippleStyles(this.props) })
)
);
}
}
Ripple.defaultProps = {
pulsate: false
};
export default Ripple;

View File

@@ -0,0 +1,260 @@
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 ReactDOM from 'react-dom';
import TransitionGroup from 'react-transition-group/TransitionGroup';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import Ripple from './Ripple';
const DURATION = 550;
export const DELAY_RIPPLE = 80;
export const styles = theme => ({
root: {
display: 'block',
position: 'absolute',
overflow: 'hidden',
borderRadius: 'inherit',
width: '100%',
height: '100%',
left: 0,
top: 0,
pointerEvents: 'none',
zIndex: 0
},
wrapper: {
opacity: 1
},
wrapperLeaving: {
opacity: 0,
animation: `mui-ripple-exit ${DURATION}ms ${theme.transitions.easing.easeInOut}`
},
wrapperPulsating: {
position: 'absolute',
left: 0,
top: 0,
display: 'block',
width: '100%',
height: '100%',
animation: `mui-ripple-pulsate 1500ms ${theme.transitions.easing.easeInOut} 200ms infinite`,
rippleVisible: {
opacity: 0.2
}
},
'@keyframes mui-ripple-enter': {
'0%': {
transform: 'scale(0)'
},
'100%': {
transform: 'scale(1)'
}
},
'@keyframes mui-ripple-exit': {
'0%': {
opacity: 1
},
'100%': {
opacity: 0
}
},
'@keyframes mui-ripple-pulsate': {
'0%': {
transform: 'scale(1)'
},
'50%': {
transform: 'scale(0.9)'
},
'100%': {
transform: 'scale(1)'
}
},
ripple: {
width: 50,
height: 50,
left: 0,
top: 0,
opacity: 0,
position: 'absolute',
borderRadius: '50%',
background: 'currentColor'
},
rippleVisible: {
opacity: 0.3,
transform: 'scale(1)',
animation: `mui-ripple-enter ${DURATION}ms ${theme.transitions.easing.easeInOut}`
},
rippleFast: {
animationDuration: '200ms'
}
});
/**
* @ignore - internal component.
*/
class TouchRipple extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.state = {
nextKey: 0,
ripples: []
}, this.ignoringMouseDown = false, this.startTimer = null, this.startTimerCommit = null, this.pulsate = () => {
this.start({}, { pulsate: true });
}, this.start = (event = {}, options = {}, cb) => {
const {
pulsate = false,
center = this.props.center || options.pulsate,
fakeElement = false // For test purposes
} = options;
if (event.type === 'mousedown' && this.ignoringMouseDown) {
this.ignoringMouseDown = false;
return;
}
if (event.type === 'touchstart') {
this.ignoringMouseDown = true;
}
const element = fakeElement ? null : ReactDOM.findDOMNode(this);
const rect = element ? // $FlowFixMe
element.getBoundingClientRect() : {
width: 0,
height: 0,
left: 0,
top: 0
};
// Get the size of the ripple
let rippleX;
let rippleY;
let rippleSize;
if (center || event.clientX === 0 && event.clientY === 0 || !event.clientX && !event.touches) {
rippleX = Math.round(rect.width / 2);
rippleY = Math.round(rect.height / 2);
} else {
const clientX = event.clientX ? event.clientX : event.touches[0].clientX;
const clientY = event.clientY ? event.clientY : event.touches[0].clientY;
rippleX = Math.round(clientX - rect.left);
rippleY = Math.round(clientY - rect.top);
}
if (center) {
rippleSize = Math.sqrt((2 * Math.pow(rect.width, 2) + Math.pow(rect.height, 2)) / 3);
// For some reason the animation is broken on Mobile Chrome if the size if even.
if (rippleSize % 2 === 0) {
rippleSize += 1;
}
} else {
const sizeX = Math.max(
// $FlowFixMe
Math.abs((element ? element.clientWidth : 0) - rippleX), rippleX) * 2 + 2;
const sizeY = Math.max(
// $FlowFixMe
Math.abs((element ? element.clientHeight : 0) - rippleY), rippleY) * 2 + 2;
rippleSize = Math.sqrt(Math.pow(sizeX, 2) + Math.pow(sizeY, 2));
}
// Touche devices
if (event.touches) {
// Prepare the ripple effect.
this.startTimerCommit = () => {
this.startCommit({ pulsate, rippleX, rippleY, rippleSize, cb });
};
// Deplay the execution of the ripple effect.
this.startTimer = setTimeout(() => {
this.startTimerCommit();
this.startTimerCommit = null;
}, DELAY_RIPPLE); // We have to make a tradeoff with this value.
} else {
this.startCommit({ pulsate, rippleX, rippleY, rippleSize, cb });
}
}, this.startCommit = params => {
const { pulsate, rippleX, rippleY, rippleSize, cb } = params;
let ripples = this.state.ripples;
// Add a ripple to the ripples array
ripples = [...ripples, React.createElement(Ripple, {
key: this.state.nextKey,
classes: this.props.classes,
timeout: {
exit: DURATION,
enter: DURATION
},
pulsate: pulsate,
rippleX: rippleX,
rippleY: rippleY,
rippleSize: rippleSize
})];
this.setState({
nextKey: this.state.nextKey + 1,
ripples
}, cb);
}, this.stop = (event, cb) => {
clearTimeout(this.startTimer);
const { ripples } = this.state;
// The touch interaction occures to quickly.
// We still want to show ripple effect.
if (event.type === 'touchend' && this.startTimerCommit) {
event.persist();
this.startTimerCommit();
this.startTimerCommit = null;
this.startTimer = setTimeout(() => {
this.stop(event, cb);
}, 0);
return;
}
this.startTimerCommit = null;
if (ripples && ripples.length) {
this.setState({
ripples: ripples.slice(1)
}, cb);
}
}, _temp;
}
componentWillUnmount() {
clearTimeout(this.startTimer);
}
// Used to filter out mouse emulated events on mobile.
// We use a timer in order to only show the ripples for touch "click" like events.
// We don't want to display the ripple for touch scroll events.
// This is the hook called once the previous timeout is ready.
render() {
const _props = this.props,
{ center, classes, className } = _props,
other = _objectWithoutProperties(_props, ['center', 'classes', 'className']);
return React.createElement(
TransitionGroup,
_extends({
component: 'span',
enter: true,
exit: true,
className: classNames(classes.root, className)
}, other),
this.state.ripples
);
}
}
TouchRipple.defaultProps = {
center: false
};
export default withStyles(styles, { flip: false, name: 'MuiTouchRipple' })(TouchRipple);

View File

@@ -0,0 +1,23 @@
function createRippleHandler(instance, eventName, action, cb) {
return function handleEvent(event) {
if (cb) {
cb.call(instance, event);
}
if (event.defaultPrevented) {
return false;
}
if (instance.ripple) {
instance.ripple[action](event);
}
if (instance.props && typeof instance.props[`on${eventName}`] === 'function') {
instance.props[`on${eventName}`](event);
}
return true;
};
}
export default createRippleHandler;

View File

@@ -0,0 +1,2 @@
export { default } from './ButtonBase';
export * from './ButtonBase';

View File

@@ -0,0 +1 @@
export { default } from './ButtonBase';

View File

@@ -0,0 +1,18 @@
import * as React from 'react';
import { StandardProps } from '..';
import { PaperProps, PaperClassKey } from '../Paper';
export interface CardProps extends StandardProps<
PaperProps,
CardClassKey
> {
raised?: boolean;
}
export type CardClassKey =
| PaperClassKey
;
declare const Card: React.ComponentType<CardProps>;
export default Card;

View File

@@ -0,0 +1,21 @@
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 Paper
import React from 'react';
import Paper from '../Paper';
function Card(props) {
const { raised } = props,
other = _objectWithoutProperties(props, ['raised']);
return React.createElement(Paper, _extends({ elevation: raised ? 8 : 2 }, other));
}
Card.defaultProps = {
raised: false
};
export default Card;

View File

@@ -0,0 +1,18 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface CardActionsProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
CardActionClassKey
> {
disableActionSpacing?: boolean;
}
export type CardActionClassKey =
| 'root'
| 'actionSpacing'
;
declare const CardActions: React.ComponentType<CardActionsProps>;
export default CardActions;

View File

@@ -0,0 +1,38 @@
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';
import { cloneChildrenWithClassName } from '../utils/reactHelpers';
export const styles = {
root: {
height: 52,
display: 'flex',
alignItems: 'center',
padding: '2px 4px'
},
actionSpacing: {
margin: '0 4px'
}
};
function CardActions(props) {
const { disableActionSpacing, children, classes, className } = props,
other = _objectWithoutProperties(props, ['disableActionSpacing', 'children', 'classes', 'className']);
return React.createElement(
'div',
_extends({ className: classNames(classes.root, className) }, other),
disableActionSpacing ? children : cloneChildrenWithClassName(children, classes.actionSpacing)
);
}
CardActions.defaultProps = {
disableActionSpacing: false
};
export default withStyles(styles, { name: 'MuiCardActions' })(CardActions);

View File

@@ -0,0 +1,15 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface CardContentProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
CardContentClassKey
> {}
export type CardContentClassKey =
| 'root'
;
declare const CardContent: React.ComponentType<CardContentProps>;
export default CardContent;

View File

@@ -0,0 +1,25 @@
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 = theme => ({
root: {
padding: theme.spacing.unit * 2,
'&:last-child': {
paddingBottom: theme.spacing.unit * 3
}
}
});
function CardContent(props) {
const { classes, className } = props,
other = _objectWithoutProperties(props, ['classes', 'className']);
return React.createElement('div', _extends({ className: classNames(classes.root, className) }, other));
}
export default withStyles(styles, { name: 'MuiCardContent' })(CardContent);

View File

@@ -0,0 +1,25 @@
import * as React from 'react';
import { StandardProps } from '..';
import { CardContentProps, CardContentClassKey } from './CardContent';
export interface CardHeaderProps extends StandardProps<
CardContentProps,
CardHeaderClassKey,
'title'
> {
avatar?: React.ReactNode;
subheader?: React.ReactNode;
title?: React.ReactNode;
}
export type CardHeaderClassKey =
| CardContentClassKey
| 'avatar'
| 'content'
| 'title'
| 'subheader'
;
declare const CardHeader: React.ComponentType<CardHeaderProps>;
export default CardHeader;

View File

@@ -0,0 +1,70 @@
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 CardContent
import React from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import Typography from '../Typography';
import CardContent from './CardContent';
export const styles = theme => ({
root: {
display: 'flex',
alignItems: 'center'
},
avatar: {
flex: '0 0 auto',
marginRight: theme.spacing.unit * 2
},
content: {
flex: '1 1 auto'
},
title: {},
subheader: {}
});
function CardHeader(props) {
const { avatar, classes, className: classNameProp, subheader, title } = props,
other = _objectWithoutProperties(props, ['avatar', 'classes', 'className', 'subheader', 'title']);
const className = classNames(classes.root, classNameProp);
// Adjustments that depend on the presence of an avatar
const titleType = avatar ? 'body2' : 'headline';
const subheaderType = avatar ? 'body2' : 'body1';
return React.createElement(
CardContent,
_extends({ className: className }, other),
avatar && React.createElement(
'div',
{ className: classes.avatar },
avatar
),
React.createElement(
'div',
{ className: classes.content },
React.createElement(
Typography,
{ type: titleType, component: 'span', className: classes.title },
title
),
React.createElement(
Typography,
{
type: subheaderType,
component: 'span',
color: 'secondary',
className: classes.subheader
},
subheader
)
)
);
}
export default withStyles(styles, { name: 'MuiCardHeader' })(CardHeader);

View File

@@ -0,0 +1,19 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface CardMediaProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
CardMediaClassKey
> {
image?: string;
src?: string;
component?: React.ReactType;
}
export type CardMediaClassKey =
| 'root'
;
declare const CardMedia: React.ComponentType<CardMediaProps>;
export default CardMedia;

View File

@@ -0,0 +1,48 @@
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 warning from 'warning';
import withStyles from '../styles/withStyles';
export const styles = {
root: {
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center'
},
rootMedia: {
width: '100%'
}
};
const mediaComponents = ['video', 'audio', 'picture', 'iframe', 'img'];
function CardMedia(props) {
const { classes, className, image, style, src, component: ComponentProp } = props,
other = _objectWithoutProperties(props, ['classes', 'className', 'image', 'style', 'src', 'component']);
warning(Boolean(image || src), 'Material-UI: either `image` or `src` property must be specified.');
const isMediaComponent = mediaComponents.indexOf(ComponentProp) !== -1;
const composedStyle = !isMediaComponent && image ? _extends({ backgroundImage: `url(${image})` }, style) : style;
const composedClassName = classNames({
[classes.root]: !isMediaComponent,
[classes.rootMedia]: isMediaComponent
}, className);
return React.createElement(ComponentProp, _extends({
className: composedClassName,
style: composedStyle,
src: isMediaComponent ? image || src : undefined
}, other));
}
CardMedia.defaultProps = {
component: 'div'
};
export default withStyles(styles, { name: 'MuiCardMedia' })(CardMedia);

View File

@@ -0,0 +1,10 @@
export { default } from './Card';
export * from './Card';
export { default as CardActions } from './CardActions';
export * from './CardActions';
export { default as CardContent } from './CardContent';
export * from './CardContent';
export { default as CardHeader } from './CardHeader';
export * from './CardHeader';
export { default as CardMedia } from './CardMedia';
export * from './CardMedia';

View File

@@ -0,0 +1,5 @@
export { default } from './Card';
export { default as CardContent } from './CardContent';
export { default as CardActions } from './CardActions';
export { default as CardMedia } from './CardMedia';
export { default as CardHeader } from './CardHeader';

View File

@@ -0,0 +1,16 @@
import * as React from 'react';
import { StandardProps } from '..';
import { SwitchBaseProps, SwitchBaseClassKey } from '../internal/SwitchBase';
export interface CheckboxProps extends StandardProps<
SwitchBaseProps,
CheckboxClassKey
> {}
export type CheckboxClassKey =
| SwitchBaseClassKey
;
declare const Checkbox: React.ComponentType<CheckboxProps>;
export default Checkbox;

View File

@@ -0,0 +1,40 @@
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 withStyles from '../styles/withStyles';
import createSwitch from '../internal/SwitchBase';
import IndeterminateCheckBoxIcon from '../svg-icons/IndeterminateCheckBox';
export const styles = theme => ({
default: {
color: theme.palette.text.secondary
},
checked: {
color: theme.palette.primary[500]
},
disabled: {
color: theme.palette.action.disabled
}
});
const SwitchBase = createSwitch();
function Checkbox(props) {
const { checkedIcon, icon, indeterminate, indeterminateIcon } = props,
other = _objectWithoutProperties(props, ['checkedIcon', 'icon', 'indeterminate', 'indeterminateIcon']);
return React.createElement(SwitchBase, _extends({
checkedIcon: indeterminate ? indeterminateIcon : checkedIcon,
icon: indeterminate ? indeterminateIcon : icon
}, other));
}
Checkbox.defaultProps = {
indeterminate: false,
indeterminateIcon: React.createElement(IndeterminateCheckBoxIcon, null)
};
export default withStyles(styles, { name: 'MuiCheckbox' })(Checkbox);

View File

@@ -0,0 +1,2 @@
export { default } from './Checkbox';
export * from './Checkbox';

View File

@@ -0,0 +1 @@
export { default } from './Checkbox';

View File

@@ -0,0 +1,27 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface ChipProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
ChipClassKey
> {
avatar?: React.ReactElement<any>;
label?: React.ReactNode;
onKeyDown?: React.EventHandler<React.KeyboardEvent<any>>;
onRequestDelete?: React.EventHandler<any>;
deleteIcon?: React.ReactElement<any>;
}
export type ChipClassKey =
| 'root'
| 'clickable'
| 'deletable'
| 'avatar'
| 'avatarChildren'
| 'label'
| 'deleteIcon'
;
declare const Chip: React.ComponentType<ChipProps>;
export default Chip;

View File

@@ -0,0 +1,192 @@
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 keycode from 'keycode';
import withStyles from '../styles/withStyles';
import CancelIcon from '../svg-icons/Cancel';
import { emphasize, fade } from '../styles/colorManipulator';
import Avatar from '../Avatar/Avatar';
export const styles = theme => {
const height = 32;
const backgroundColor = emphasize(theme.palette.background.default, 0.12);
const deleteIconColor = fade(theme.palette.text.primary, 0.26);
return {
root: {
fontFamily: theme.typography.fontFamily,
fontSize: theme.typography.pxToRem(13),
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height,
color: theme.palette.getContrastText(backgroundColor),
backgroundColor,
borderRadius: height / 2,
whiteSpace: 'nowrap',
width: 'fit-content',
transition: theme.transitions.create(),
// label will inherit this from root, then `clickable` class overrides this for both
cursor: 'default',
outline: 'none', // No outline on focused element in Chrome (as triggered by tabIndex prop)
border: 'none', // Remove `button` border
padding: 0 // Remove `button` padding
},
clickable: {
// Remove grey highlight
WebkitTapHighlightColor: theme.palette.common.transparent,
cursor: 'pointer',
'&:hover, &:focus': {
backgroundColor: emphasize(backgroundColor, 0.08)
},
'&:active': {
boxShadow: theme.shadows[1],
backgroundColor: emphasize(backgroundColor, 0.12)
}
},
deletable: {
'&:focus': {
backgroundColor: emphasize(backgroundColor, 0.08)
}
},
avatar: {
marginRight: -4,
width: 32,
height: 32,
fontSize: theme.typography.pxToRem(16)
},
avatarChildren: {
width: 19,
height: 19
},
label: {
display: 'flex',
alignItems: 'center',
paddingLeft: 12,
paddingRight: 12,
userSelect: 'none',
whiteSpace: 'nowrap',
cursor: 'inherit'
},
deleteIcon: {
// Remove grey highlight
WebkitTapHighlightColor: theme.palette.common.transparent,
color: deleteIconColor,
cursor: 'pointer',
height: 'auto',
margin: '0 4px 0 -8px',
'&:hover': {
color: fade(deleteIconColor, 0.4)
}
}
};
};
/**
* Chips represent complex entities in small blocks, such as a contact.
*/
class Chip extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.chipRef = null, this.handleDeleteIconClick = event => {
// Stop the event from bubbling up to the `Chip`
event.stopPropagation();
const { onRequestDelete } = this.props;
if (onRequestDelete) {
onRequestDelete(event);
}
}, this.handleKeyDown = event => {
const { onClick, onRequestDelete, onKeyDown } = this.props;
const key = keycode(event);
if (onClick && (key === 'space' || key === 'enter')) {
event.preventDefault();
onClick(event);
} else if (onRequestDelete && key === 'backspace') {
event.preventDefault();
onRequestDelete(event);
} else if (key === 'esc') {
event.preventDefault();
if (this.chipRef) {
this.chipRef.blur();
}
}
if (onKeyDown) {
onKeyDown(event);
}
}, _temp;
}
render() {
const _props = this.props,
{
avatar: avatarProp,
classes,
className: classNameProp,
label,
onClick,
onKeyDown,
onRequestDelete,
deleteIcon: deleteIconProp,
tabIndex: tabIndexProp
} = _props,
other = _objectWithoutProperties(_props, ['avatar', 'classes', 'className', 'label', 'onClick', 'onKeyDown', 'onRequestDelete', 'deleteIcon', 'tabIndex']);
const className = classNames(classes.root, { [classes.clickable]: onClick }, { [classes.deletable]: onRequestDelete }, classNameProp);
let deleteIcon = null;
if (onRequestDelete && deleteIconProp && React.isValidElement(deleteIconProp)) {
deleteIcon = React.cloneElement(deleteIconProp, {
onClick: this.handleDeleteIconClick,
className: classNames(classes.deleteIcon, deleteIconProp.props.className)
});
} else if (onRequestDelete) {
deleteIcon = React.createElement(CancelIcon, { className: classes.deleteIcon, onClick: this.handleDeleteIconClick });
}
let avatar = null;
if (avatarProp && React.isValidElement(avatarProp)) {
// $FlowFixMe - this looks strictly correct, not sure why it errors.
avatar = React.cloneElement(avatarProp, {
className: classNames(classes.avatar, avatarProp.props.className),
childrenClassName: classNames(classes.avatarChildren, avatarProp.props.childrenClassName)
});
}
let tabIndex = tabIndexProp;
if (!tabIndex) {
tabIndex = onClick || onRequestDelete ? 0 : -1;
}
return React.createElement(
'div',
_extends({
role: 'button',
className: className,
tabIndex: tabIndex,
onClick: onClick,
onKeyDown: this.handleKeyDown
}, other, {
ref: node => {
this.chipRef = node;
}
}),
avatar,
React.createElement(
'span',
{ className: classes.label },
label
),
deleteIcon
);
}
}
export default withStyles(styles, { name: 'MuiChip' })(Chip);

View File

@@ -0,0 +1,2 @@
export { default } from './Chip';
export * from './Chip';

View File

@@ -0,0 +1 @@
export { default } from './Chip';

View File

@@ -0,0 +1,37 @@
import * as React from 'react';
import { StandardProps } from '..';
import { ModalProps, ModalClassKey } from '../internal/Modal';
import { TransitionDuration } from '../internal/transition';
export interface DialogProps extends StandardProps<
ModalProps,
DialogClassKey,
'onBackdropClick' | 'onEscapeKeyUp'
> {
fullScreen?: boolean;
ignoreBackdropClick?: boolean;
ignoreEscapeKeyUp?: boolean;
transitionDuration?: TransitionDuration;
maxWidth?: 'xs' | 'sm' | 'md';
fullWidth?: boolean;
onBackdropClick?: Function;
onEscapeKeyUp?: Function;
onRequestClose?: React.EventHandler<any>;
open?: boolean;
transition?: React.ReactType;
}
export type DialogClassKey =
| ModalClassKey
| 'root'
| 'paper'
| 'paperWidthXs'
| 'paperWidthSm'
| 'paperWidthMd'
| 'fullWidth'
| 'fullScreen'
;
declare const Dialog: React.ComponentType<DialogProps>;
export default Dialog;

View File

@@ -0,0 +1,138 @@
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';
import { capitalizeFirstLetter } from '../utils/helpers';
import Modal from '../internal/Modal';
import Fade from '../transitions/Fade';
import { duration } from '../styles/transitions';
import Paper from '../Paper';
export const styles = theme => ({
root: {
justifyContent: 'center',
alignItems: 'center'
},
paper: {
display: 'flex',
margin: theme.spacing.unit * 4,
flexDirection: 'column',
flex: '0 1 auto',
position: 'relative',
maxHeight: '90vh',
overflowY: 'auto', // Fix IE11 issue, to remove at some point.
'&:focus': {
outline: 'none'
}
},
paperWidthXs: {
maxWidth: theme.breakpoints.values.xs
},
paperWidthSm: {
maxWidth: theme.breakpoints.values.sm
},
paperWidthMd: {
maxWidth: theme.breakpoints.values.md
},
fullWidth: {
width: '100%'
},
fullScreen: {
margin: 0,
width: '100%',
maxWidth: '100%',
height: '100%',
maxHeight: '100%',
borderRadius: 0
}
});
/**
* Dialogs are overlaid modal paper based components with a backdrop.
*/
function Dialog(props) {
const {
children,
classes,
className,
fullScreen,
ignoreBackdropClick,
ignoreEscapeKeyUp,
transitionDuration,
maxWidth,
fullWidth,
open,
onBackdropClick,
onEscapeKeyUp,
onEnter,
onEntering,
onEntered,
onExit,
onExiting,
onExited,
onRequestClose,
transition: TransitionProp
} = props,
other = _objectWithoutProperties(props, ['children', 'classes', 'className', 'fullScreen', 'ignoreBackdropClick', 'ignoreEscapeKeyUp', 'transitionDuration', 'maxWidth', 'fullWidth', 'open', 'onBackdropClick', 'onEscapeKeyUp', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'onExited', 'onRequestClose', 'transition']);
return React.createElement(
Modal,
_extends({
className: classNames(classes.root, className),
BackdropTransitionDuration: transitionDuration,
ignoreBackdropClick: ignoreBackdropClick,
ignoreEscapeKeyUp: ignoreEscapeKeyUp,
onBackdropClick: onBackdropClick,
onEscapeKeyUp: onEscapeKeyUp,
onRequestClose: onRequestClose,
show: open
}, other),
React.createElement(
TransitionProp,
{
appear: true,
'in': open,
timeout: transitionDuration,
onEnter: onEnter,
onEntering: onEntering,
onEntered: onEntered,
onExit: onExit,
onExiting: onExiting,
onExited: onExited
},
React.createElement(
Paper,
{
'data-mui-test': 'Dialog',
elevation: 24,
className: classNames(classes.paper, classes[`paperWidth${capitalizeFirstLetter(maxWidth)}`], {
[classes.fullScreen]: fullScreen,
[classes.fullWidth]: fullWidth
})
},
children
)
)
);
}
Dialog.defaultProps = {
fullScreen: false,
ignoreBackdropClick: false,
ignoreEscapeKeyUp: false,
transitionDuration: {
enter: duration.enteringScreen,
exit: duration.leavingScreen
},
maxWidth: 'sm',
fullWidth: false,
open: false,
transition: Fade
};
export default withStyles(styles, { name: 'MuiDialog' })(Dialog);

View File

@@ -0,0 +1,17 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface DialogActionsProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
DialogActionsClassKey
> {}
export type DialogActionsClassKey =
| 'root'
| 'action'
| 'button'
;
declare const DialogActions: React.ComponentType<DialogActionsProps>;
export default DialogActions;

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';
import '../Button'; // So we don't have any override priority issue.
export const styles = theme => ({
root: {
display: 'flex',
justifyContent: 'flex-end',
alignItems: 'center',
margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px`,
flex: '0 0 auto'
},
action: {
margin: `0 ${theme.spacing.unit / 2}px`
},
button: {
minWidth: 64
}
});
function DialogActions(props) {
const { children, classes, className } = props,
other = _objectWithoutProperties(props, ['children', 'classes', 'className']);
return React.createElement(
'div',
_extends({ 'data-mui-test': 'DialogActions', className: classNames(classes.root, className) }, other),
React.Children.map(children, button => React.isValidElement(button) && React.createElement(
'div',
{ className: classes.action },
React.cloneElement(button, {
className: classNames(classes.button, button.props.className)
})
))
);
}
export default withStyles(styles, { name: 'MuiDialogActions' })(DialogActions);

View File

@@ -0,0 +1,15 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface DialogContentProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
DialogContentClassKey
> {}
export type DialogContentClassKey =
| 'root'
;
declare const DialogContent: React.ComponentType<DialogContentProps>;
export default DialogContent;

View File

@@ -0,0 +1,35 @@
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 = theme => {
const spacing = theme.spacing.unit * 3;
return {
root: {
flex: '1 1 auto',
overflowY: 'auto',
padding: `0 ${spacing}px ${spacing}px ${spacing}px`,
'&:first-child': {
paddingTop: spacing
}
}
};
};
function DialogContent(props) {
const { classes, children, className } = props,
other = _objectWithoutProperties(props, ['classes', 'children', 'className']);
return React.createElement(
'div',
_extends({ className: classNames(classes.root, className) }, other),
children
);
}
export default withStyles(styles, { name: 'MuiDialogContent' })(DialogContent);

View File

@@ -0,0 +1,15 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface DialogContentTextProps extends StandardProps<
React.HTMLAttributes<HTMLParagraphElement>,
DialogContentTextClassKey
> {}
export type DialogContentTextClassKey =
| 'root'
;
declare const DialogContentText: React.ComponentType<DialogContentTextProps>;
export default DialogContentText;

View File

@@ -0,0 +1,28 @@
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 = theme => ({
root: _extends({}, theme.typography.subheading, {
color: theme.palette.text.secondary,
margin: 0
})
});
function DialogContentText(props) {
const { children, classes, className } = props,
other = _objectWithoutProperties(props, ['children', 'classes', 'className']);
return React.createElement(
'p',
_extends({ className: classNames(classes.root, className) }, other),
children
);
}
export default withStyles(styles, { name: 'MuiDialogContentText' })(DialogContentText);

View File

@@ -0,0 +1,17 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface DialogTitleProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
DialogTitleClassKey
> {
disableTypography?: boolean;
}
export type DialogTitleClassKey =
| 'root'
;
declare const DialogTitle: React.ComponentType<DialogTitleProps>;
export default DialogTitle;

View File

@@ -0,0 +1,39 @@
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';
import Typography from '../Typography';
export const styles = theme => ({
root: {
margin: 0,
padding: `${theme.spacing.unit * 3}px ${theme.spacing.unit * 3}px \
20px ${theme.spacing.unit * 3}px`,
flex: '0 0 auto'
}
});
function DialogTitle(props) {
const { children, classes, className, disableTypography } = props,
other = _objectWithoutProperties(props, ['children', 'classes', 'className', 'disableTypography']);
return React.createElement(
'div',
_extends({ 'data-mui-test': 'DialogTitle', className: classNames(classes.root, className) }, other),
disableTypography ? children : React.createElement(
Typography,
{ type: 'title' },
children
)
);
}
DialogTitle.defaultProps = {
disableTypography: false
};
export default withStyles(styles, { name: 'MuiDialogTitle' })(DialogTitle);

View File

@@ -0,0 +1,14 @@
export { default } from './Dialog';
export * from './Dialog';
export { default as DialogActions } from './DialogActions';
export * from './DialogActions';
export { default as DialogTitle } from './DialogTitle';
export * from './DialogTitle';
export { default as DialogContent } from './DialogContent';
export * from './DialogContent';
export { default as DialogContentText } from './DialogContentText';
export * from './DialogContentText';
export {
default as withMobileDialog,
} from './withMobileDialog';
export * from './withMobileDialog';

View File

@@ -0,0 +1,6 @@
export { default } from './Dialog';
export { default as DialogActions } from './DialogActions';
export { default as DialogTitle } from './DialogTitle';
export { default as DialogContent } from './DialogContent';
export { default as DialogContentText } from './DialogContentText';
export { default as withMobileDialog } from './withMobileDialog';

View File

@@ -0,0 +1,12 @@
import { Breakpoint } from '../styles/createBreakpoints';
import { WithWidthProps } from '../utils/withWidth';
export interface WithMobileDialogOptions {
breakpoint: Breakpoint;
}
export default function withMobileDialog<P = {}>(
options: WithMobileDialogOptions
): (
component: React.ComponentType<P & Partial<WithWidthProps>>
) => React.ComponentClass<P & Partial<WithWidthProps>>;

View File

@@ -0,0 +1,28 @@
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; };
import React from 'react';
import wrapDisplayName from 'recompose/wrapDisplayName';
import withWidth, { isWidthDown } from '../utils/withWidth';
/**
* Dialog will responsively be full screen *at or below* the given breakpoint
* (defaults to 'sm' for mobile devices).
* Notice that this Higher-order Component is incompatible with server side rendering.
*/
const withMobileDialog = (options = { breakpoint: 'sm' }) => Component => {
const { breakpoint } = options;
function WithMobileDialog(props) {
return React.createElement(Component, _extends({ fullScreen: isWidthDown(breakpoint, props.width) }, props));
}
if (process.env.NODE_ENV !== 'production') {
WithMobileDialog.displayName = wrapDisplayName(Component, 'withMobileDialog');
}
return withWidth()(WithMobileDialog);
};
export default withMobileDialog;

View File

@@ -0,0 +1,23 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface DividerProps extends StandardProps<
React.HTMLAttributes<HTMLHRElement>,
DividerClassKey
> {
absolute?: boolean;
inset?: boolean;
light?: boolean;
}
export type DividerClassKey =
| 'root'
| 'default'
| 'inset'
| 'light'
| 'absolute'
;
declare const Divider: React.ComponentType<DividerProps>;
export default Divider;

View File

@@ -0,0 +1,52 @@
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 = theme => ({
root: {
height: 1,
margin: 0, // Reset browser default style.
border: 'none',
flexShrink: 0
},
default: {
backgroundColor: theme.palette.text.divider
},
inset: {
marginLeft: 72
},
light: {
backgroundColor: theme.palette.text.lightDivider
},
absolute: {
position: 'absolute',
bottom: 0,
left: 0,
width: '100%'
}
});
function Divider(props) {
const { absolute, classes, className: classNameProp, inset, light } = props,
other = _objectWithoutProperties(props, ['absolute', 'classes', 'className', 'inset', 'light']);
const className = classNames(classes.root, {
[classes.absolute]: absolute,
[classes.inset]: inset,
[light ? classes.light : classes.default]: true
}, classNameProp);
return React.createElement('hr', _extends({ className: className }, other));
}
Divider.defaultProps = {
absolute: false,
inset: false,
light: false
};
export default withStyles(styles, { name: 'MuiDivider' })(Divider);

View File

@@ -0,0 +1,2 @@
export { default } from './Divider';
export * from './Divider';

View File

@@ -0,0 +1 @@
export { default } from './Divider';

View File

@@ -0,0 +1,34 @@
import * as React from 'react';
import { StandardProps } from '..';
import { ModalProps, ModalClassKey } from '../internal/Modal';
import { TransitionDuration } from '../internal/transition';
import { SlideProps } from '../transitions/Slide';
import { Theme } from '../styles/createMuiTheme';
export interface DrawerProps extends StandardProps<
ModalProps,
DrawerClassKey
> {
anchor?: 'left' | 'top' | 'right' | 'bottom';
elevation?: number;
transitionDuration?: TransitionDuration;
open?: boolean;
SlideProps?: SlideProps;
theme?: Theme;
type?: 'permanent' | 'persistent' | 'temporary';
}
export type DrawerClassKey =
| ModalClassKey
| 'paper'
| 'anchorLeft'
| 'anchorRight'
| 'anchorTop'
| 'anchorBottom'
| 'docked'
| 'modal'
;
declare const Drawer: React.ComponentType<DrawerProps>;
export default Drawer;

View File

@@ -0,0 +1,187 @@
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 Modal from '../internal/Modal';
import withStyles from '../styles/withStyles';
import Slide from '../transitions/Slide';
import Paper from '../Paper';
import { capitalizeFirstLetter } from '../utils/helpers';
import { duration } from '../styles/transitions';
function getSlideDirection(anchor) {
if (anchor === 'left') {
return 'right';
} else if (anchor === 'right') {
return 'left';
} else if (anchor === 'top') {
return 'down';
}
// (anchor === 'bottom')
return 'up';
}
export const styles = theme => ({
docked: {
flex: '0 0 auto'
},
paper: {
overflowY: 'auto',
display: 'flex',
flexDirection: 'column',
height: '100vh',
flex: '1 0 auto',
position: 'fixed',
top: 0,
zIndex: theme.zIndex.navDrawer,
willChange: 'transform',
'&:focus': {
outline: 'none'
},
WebkitOverflowScrolling: 'touch' // Add iOS momentum scrolling.
},
paperAnchorLeft: {
left: 0,
right: 'auto'
},
paperAnchorRight: {
left: 'auto',
right: 0
},
paperAnchorTop: {
top: 0,
left: 0,
bottom: 'auto',
right: 0,
height: 'auto',
maxHeight: '100vh'
},
paperAnchorBottom: {
top: 'auto',
left: 0,
bottom: 0,
right: 0,
height: 'auto',
maxHeight: '100vh'
},
paperAnchorDockedLeft: {
borderRight: `1px solid ${theme.palette.text.divider}`
},
paperAnchorDockedRight: {
borderLeft: `1px solid ${theme.palette.text.divider}`
},
modal: {} // Just here so people can override the style.
});
class Drawer extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.state = {
// Let's assume that the Drawer will always be rendered on user space.
// We use that state is order to skip the appear transition during the
// initial mount of the component.
firstMount: true
}, _temp;
}
componentWillReceiveProps() {
this.setState({
firstMount: false
});
}
render() {
const _props = this.props,
{
anchor: anchorProp,
children,
classes,
className,
elevation,
transitionDuration,
ModalProps,
onRequestClose,
open,
SlideProps,
theme,
type
} = _props,
other = _objectWithoutProperties(_props, ['anchor', 'children', 'classes', 'className', 'elevation', 'transitionDuration', 'ModalProps', 'onRequestClose', 'open', 'SlideProps', 'theme', 'type']);
const rtl = theme.direction === 'rtl';
let anchor = anchorProp;
if (rtl && ['left', 'right'].includes(anchor)) {
anchor = anchor === 'left' ? 'right' : 'left';
}
const drawer = React.createElement(
Paper,
{
elevation: type === 'temporary' ? elevation : 0,
square: true,
className: classNames(classes.paper, {
[classes[`paperAnchor${capitalizeFirstLetter(anchor)}`]]: type !== 'permanent',
[classes[`paperAnchorDocked${capitalizeFirstLetter(anchor)}`]]: type !== 'temporary'
})
},
children
);
if (type === 'permanent') {
return React.createElement(
'div',
_extends({ className: classNames(classes.docked, className) }, other),
drawer
);
}
const slidingDrawer = React.createElement(
Slide,
_extends({
'in': open,
direction: getSlideDirection(anchor),
timeout: transitionDuration,
appear: !this.state.firstMount
}, SlideProps),
drawer
);
if (type === 'persistent') {
return React.createElement(
'div',
_extends({ className: classNames(classes.docked, className) }, other),
slidingDrawer
);
}
// type === temporary
return React.createElement(
Modal,
_extends({
BackdropTransitionDuration: transitionDuration,
className: classNames(classes.modal, className),
show: open,
onRequestClose: onRequestClose
}, other, ModalProps),
slidingDrawer
);
}
}
Drawer.defaultProps = {
anchor: 'left',
elevation: 16,
transitionDuration: {
enter: duration.enteringScreen,
exit: duration.leavingScreen
},
open: false,
type: 'temporary' // Mobile first.
};
export default withStyles(styles, { flip: false, withTheme: true, name: 'MuiDrawer' })(Drawer);

View File

@@ -0,0 +1,2 @@
export { default } from './Drawer';
export * from './Drawer';

View File

@@ -0,0 +1 @@
export { default } from './Drawer';

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';

View File

@@ -0,0 +1,83 @@
import * as React from 'react';
import { StandardProps } from '..';
import { HiddenProps } from '../Hidden/Hidden';
import { Breakpoint } from '../styles/createBreakpoints';
export type GridItemsAlignment = 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
export type GridContentAlignment = 'stretch' | 'center' | 'flex-start' | 'flex-end' |'space-between' | 'space-around';
export type GridDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
export type GridSpacing = 0 | 8 | 16 | 24 | 40;
export type GridJustification =
| 'flex-start'
| 'center'
| 'flex-end'
| 'space-between'
| 'space-around';
export type GridWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
export type GridSize = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
export interface GridProps extends StandardProps<
React.HTMLAttributes<HTMLElement> & Partial<Record<Breakpoint, boolean | GridSize>>,
GridClassKey,
'hidden'
> {
component?: React.ReactType;
container?: boolean;
item?: boolean;
alignItems?: GridItemsAlignment;
alignContent?: GridContentAlignment;
direction?: GridDirection;
spacing?: GridSpacing;
hidden?: HiddenProps;
justify?: GridJustification;
wrap?: GridWrap;
}
export type GridClassKey =
| 'typeContainer'
| 'typeItem'
| 'direction-xs-column'
| 'direction-xs-column-reverse'
| 'direction-xs-row-reverse'
| 'wrap-xs-nowrap'
| 'align-items-xs-center'
| 'align-items-xs-flex-start'
| 'align-items-xs-flex-end'
| 'align-items-xs-baseline'
| 'align-content-xs-center'
| 'align-content-xs-flex-start'
| 'align-content-xs-flex-end'
| 'align-content-xs-space-between'
| 'align-content-xs-space-around'
| 'justify-xs-center'
| 'justify-xs-flex-end'
| 'justify-xs-space-between'
| 'justify-xs-space-around'
| 'spacing-xs-8'
| 'spacing-xs-16'
| 'spacing-xs-24'
| 'spacing-xs-40'
| 'grid-xs'
| 'grid-xs-1'
| 'grid-xs-2'
| 'grid-xs-3'
| 'grid-xs-4'
| 'grid-xs-5'
| 'grid-xs-6'
| 'grid-xs-7'
| 'grid-xs-8'
| 'grid-xs-9'
| 'grid-xs-10'
| 'grid-xs-11'
| 'grid-xs-12'
;
declare const Grid: React.ComponentType<GridProps>;
export default Grid;

View File

@@ -0,0 +1,254 @@
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; }
// A grid component using the following libs as inspiration.
//
// For the implementation:
// - http://v4-alpha.getbootstrap.com/layout/flexbox-grid/
// - https://github.com/kristoferjoseph/flexboxgrid/blob/master/src/css/flexboxgrid.css
// - https://github.com/roylee0704/react-flexbox-grid
// - https://material.angularjs.org/latest/layout/introduction
//
// Follow this flexbox Guide to better understand the underlying model:
// - https://css-tricks.com/snippets/css/a-guide-to-flexbox/
import React from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import { keys as breakpointKeys } from '../styles/createBreakpoints';
import requirePropFactory from '../utils/requirePropFactory';
import Hidden from '../Hidden';
const GUTTERS = [0, 8, 16, 24, 40];
const GRID_SIZES = [true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
function generateGrid(globalStyles, theme, breakpoint) {
// For the auto layouting
const styles = {
[`grid-${breakpoint}`]: {
flexBasis: 0,
flexGrow: 1,
maxWidth: '100%'
}
};
GRID_SIZES.forEach(size => {
if (typeof size === 'boolean') {
// Skip the first one as handle above.
return;
}
// Only keep 6 significant numbers.
const width = `${Math.round(size / 12 * Math.pow(10, 6)) / Math.pow(10, 4)}%`;
/* eslint-disable max-len */
// Close to the bootstrap implementation:
// https://github.com/twbs/bootstrap/blob/b0508a975d711d6b24c01f57dd5445c22699fac4/scss/mixins/_grid.scss#L69
/* eslint-enable max-len */
styles[`grid-${breakpoint}-${size}`] = {
flexBasis: width,
maxWidth: width
};
});
// No need for a media query for the first size.
if (breakpoint === 'xs') {
_extends(globalStyles, styles);
} else {
globalStyles[theme.breakpoints.up(breakpoint)] = styles;
}
}
function generateGutter(theme, breakpoint) {
const styles = {};
GUTTERS.forEach((spacing, index) => {
if (index === 0) {
// Skip the default style.
return;
}
styles[`spacing-${breakpoint}-${spacing}`] = {
margin: -spacing / 2,
width: `calc(100% + ${spacing}px)`,
'& > $typeItem': {
padding: spacing / 2
}
};
});
return styles;
}
// Default CSS values
// flex: '0 1 auto',
// flexDirection: 'row',
// alignItems: 'flex-start',
// flexWrap: 'nowrap',
// justifyContent: 'flex-start',
export const styles = theme => _extends({
typeContainer: {
boxSizing: 'border-box',
display: 'flex',
flexWrap: 'wrap',
width: '100%'
},
typeItem: {
boxSizing: 'border-box',
flex: '0 0 auto',
margin: '0' // For instance, it's useful when used with a `figure` element.
},
'direction-xs-column': {
flexDirection: 'column'
},
'direction-xs-column-reverse': {
flexDirection: 'column-reverse'
},
'direction-xs-row-reverse': {
flexDirection: 'row-reverse'
},
'wrap-xs-nowrap': {
flexWrap: 'nowrap'
},
'align-items-xs-center': {
alignItems: 'center'
},
'align-items-xs-flex-start': {
alignItems: 'flex-start'
},
'align-items-xs-flex-end': {
alignItems: 'flex-end'
},
'align-items-xs-baseline': {
alignItems: 'baseline'
},
'align-content-xs-center': {
alignContent: 'center'
},
'align-content-xs-flex-start': {
alignContent: 'flex-start'
},
'align-content-xs-flex-end': {
alignContent: 'flex-end'
},
'align-content-xs-space-between': {
alignContent: 'space-between'
},
'align-content-xs-space-around': {
alignContent: 'space-around'
},
'justify-xs-center': {
justifyContent: 'center'
},
'justify-xs-flex-end': {
justifyContent: 'flex-end'
},
'justify-xs-space-between': {
justifyContent: 'space-between'
},
'justify-xs-space-around': {
justifyContent: 'space-around'
}
}, generateGutter(theme, 'xs'), breakpointKeys.reduce((accumulator, key) => {
// Use side effect over immutability for better performance.
generateGrid(accumulator, theme, key);
return accumulator;
}, {}));
function Grid(props) {
const {
classes,
className: classNameProp,
component: ComponentProp,
container,
item,
alignContent,
alignItems,
direction,
spacing,
hidden,
justify,
wrap,
xs,
sm,
md,
lg,
xl
} = props,
other = _objectWithoutProperties(props, ['classes', 'className', 'component', 'container', 'item', 'alignContent', 'alignItems', 'direction', 'spacing', 'hidden', 'justify', 'wrap', 'xs', 'sm', 'md', 'lg', 'xl']);
const className = classNames({
[classes.typeContainer]: container,
[classes.typeItem]: item,
[classes[`spacing-xs-${String(spacing)}`]]: container && spacing !== 0,
[classes[`direction-xs-${String(direction)}`]]: direction !== Grid.defaultProps.direction,
[classes[`wrap-xs-${String(wrap)}`]]: wrap !== Grid.defaultProps.wrap,
[classes[`align-items-xs-${String(alignItems)}`]]: alignItems !== Grid.defaultProps.alignItems,
[classes[`align-content-xs-${String(alignContent)}`]]: alignContent !== Grid.defaultProps.alignContent,
[classes[`justify-xs-${String(justify)}`]]: justify !== Grid.defaultProps.justify,
[classes['grid-xs']]: xs === true,
[classes[`grid-xs-${String(xs)}`]]: xs && xs !== true,
[classes['grid-sm']]: sm === true,
[classes[`grid-sm-${String(sm)}`]]: sm && sm !== true,
[classes['grid-md']]: md === true,
[classes[`grid-md-${String(md)}`]]: md && md !== true,
[classes['grid-lg']]: lg === true,
[classes[`grid-lg-${String(lg)}`]]: lg && lg !== true,
[classes['grid-xl']]: xl === true,
[classes[`grid-xl-${String(xl)}`]]: xl && xl !== true
}, classNameProp);
const gridProps = _extends({ className }, other);
if (hidden) {
return React.createElement(
Hidden,
hidden,
React.createElement(ComponentProp, gridProps)
);
}
return React.createElement(ComponentProp, gridProps);
}
Grid.defaultProps = {
alignContent: 'stretch',
alignItems: 'stretch',
component: 'div',
container: false,
direction: 'row',
hidden: undefined,
item: false,
justify: 'flex-start',
spacing: 16,
wrap: 'wrap'
};
// Add a wrapper component to generate some helper messages in the development
// environment.
// eslint-disable-next-line import/no-mutable-exports
let GridWrapper = Grid;
if (process.env.NODE_ENV !== 'production') {
const requireProp = requirePropFactory('Grid');
GridWrapper = props => React.createElement(Grid, props);
// $FlowFixMe - cannot mix legacy propTypes with current HOC pattern - https://github.com/facebook/flow/issues/4644#issuecomment-332530909
GridWrapper.propTypes = {
alignContent: requireProp('container'),
alignItems: requireProp('container'),
direction: requireProp('container'),
justify: requireProp('container'),
lg: requireProp('item'),
md: requireProp('item'),
sm: requireProp('item'),
spacing: requireProp('container'),
wrap: requireProp('container'),
xs: requireProp('item')
};
}
export default withStyles(styles, { name: 'MuiGrid' })(GridWrapper);

View File

@@ -0,0 +1,2 @@
export { default } from './Grid';
export * from './Grid';

View File

@@ -0,0 +1 @@
export { default } from './Grid';

View File

@@ -0,0 +1,20 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface GridListProps extends StandardProps<
React.HTMLAttributes<HTMLUListElement>,
GridListClassKey
> {
cellHeight?: number | 'auto';
cols?: number;
component?: React.ReactType;
spacing?: number;
}
export type GridListClassKey =
| 'root'
;
declare const GridList: React.ComponentType<GridListProps>;
export default GridList;

View File

@@ -0,0 +1,64 @@
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';
export const styles = {
root: {
display: 'flex',
flexWrap: 'wrap',
overflowY: 'auto',
listStyle: 'none',
padding: 0,
WebkitOverflowScrolling: 'touch' // Add iOS momentum scrolling.
}
};
function GridList(props) {
const {
cols,
spacing,
cellHeight,
children,
classes,
className: classNameProp,
component: ComponentProp,
style
} = props,
other = _objectWithoutProperties(props, ['cols', 'spacing', 'cellHeight', 'children', 'classes', 'className', 'component', 'style']);
return React.createElement(
ComponentProp,
_extends({
className: classNames(classes.root, classNameProp),
style: _extends({ margin: -spacing / 2 }, style)
}, other),
React.Children.map(children, currentChild => {
const childCols = currentChild.props.cols || 1;
const childRows = currentChild.props.rows || 1;
return React.cloneElement(currentChild, {
style: _extends({
width: `${100 / cols * childCols}%`,
height: cellHeight === 'auto' ? 'auto' : cellHeight * childRows + spacing,
padding: spacing / 2
}, currentChild.props.style)
});
})
);
}
GridList.defaultProps = {
cols: 2,
spacing: 4,
cellHeight: 180,
component: 'ul'
};
export default withStyles(styles, { name: 'MuiGridList' })(GridList);

View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface GridListTileProps extends StandardProps<
React.HTMLAttributes<HTMLLIElement>,
GridListTileClassKey
> {
cols?: number;
component?: React.ReactType;
rows?: number;
}
export type GridListTileClassKey =
| 'root'
| 'tile'
| 'imgFullHeight'
| 'imgFullWidth'
;
declare const GridListTile: React.ComponentType<GridListTileProps>;
export default GridListTile;

View File

@@ -0,0 +1,134 @@
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 EventListener from 'react-event-listener';
import debounce from 'lodash/debounce';
import withStyles from '../styles/withStyles';
export const styles = {
root: {
boxSizing: 'border-box',
flexShrink: 0
},
tile: {
position: 'relative',
display: 'block', // In case it's not renderd with a div.
height: '100%',
overflow: 'hidden'
},
imgFullHeight: {
height: '100%',
transform: 'translateX(-50%)',
position: 'relative',
left: '50%'
},
imgFullWidth: {
width: '100%',
position: 'relative',
transform: 'translateY(-50%)',
top: '50%'
}
};
class GridListTile extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.imgElement = null, this.handleResize = debounce(() => {
this.fit();
}, 166), this.fit = () => {
const imgElement = this.imgElement;
if (!imgElement) {
return;
}
if (!imgElement.complete) {
return;
}
if (imgElement.width / imgElement.height > imgElement.parentNode.offsetWidth / imgElement.parentNode.offsetHeight) {
imgElement.classList.remove(this.props.classes.imgFullWidth);
imgElement.classList.add(this.props.classes.imgFullHeight);
} else {
imgElement.classList.remove(this.props.classes.imgFullHeight);
imgElement.classList.add(this.props.classes.imgFullWidth);
}
imgElement.removeEventListener('load', this.fit);
}, _temp;
}
componentDidMount() {
this.ensureImageCover();
}
componentDidUpdate() {
this.ensureImageCover();
}
componentWillUnmount() {
this.handleResize.cancel();
}
ensureImageCover() {
if (!this.imgElement) {
return;
}
if (this.imgElement.complete) {
this.fit();
} else {
this.imgElement.addEventListener('load', this.fit);
}
}
render() {
const _props = this.props,
{
children,
classes,
className,
cols,
// $FlowFixMe - no idea why it cannot find component on intersection
component: ComponentProp,
rows
} = _props,
other = _objectWithoutProperties(_props, ['children', 'classes', 'className', 'cols', 'component', 'rows']);
return React.createElement(
ComponentProp,
_extends({ className: classNames(classes.root, className) }, other),
React.createElement(EventListener, { target: 'window', onResize: this.handleResize }),
React.createElement(
'div',
{ className: classes.tile },
React.Children.map(children, child => {
if (child.type === 'img') {
return React.cloneElement(child, {
key: 'img',
ref: node => {
this.imgElement = node;
}
});
}
return child;
})
)
);
}
}
GridListTile.defaultProps = {
cols: 1,
rows: 1,
component: 'li'
};
export default withStyles(styles, { name: 'MuiGridListTile' })(GridListTile);

View File

@@ -0,0 +1,29 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface GridListTileBarProps extends StandardProps<{}, GridListTileBarClassKey>
{
actionIcon?: React.ReactNode;
actionPosition?: 'left' | 'right';
subtitle?: React.ReactNode;
title?: React.ReactNode;
titlePosition?: 'top' | 'bottom';
}
export type GridListTileBarClassKey =
| 'root'
| 'rootBottom'
| 'rootTop'
| 'rootWithSubtitle'
| 'titleWrap'
| 'titleWrapActionLeft'
| 'titleWrapActionRight'
| 'title'
| 'subtitle'
| 'actionIconPositionLeft'
| 'childImg'
;
declare const GridListTileBar: React.ComponentType<GridListTileBarProps>;
export default GridListTileBar;

View File

@@ -0,0 +1,125 @@
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';
export const styles = theme => ({
root: {
position: 'absolute',
left: 0,
right: 0,
height: 48,
background: 'rgba(0, 0, 0, 0.4)',
display: 'flex',
alignItems: 'center',
fontFamily: theme.typography.fontFamily
},
rootBottom: {
bottom: 0
},
rootTop: {
top: 0
},
rootWithSubtitle: {
height: 68
},
titleWrap: {
flexGrow: 1,
marginLeft: theme.mixins.gutters({}).paddingLeft,
marginRight: theme.mixins.gutters({}).paddingRight,
color: 'white',
overflow: 'hidden'
},
titleWrapActionLeft: {
marginLeft: 0
},
titleWrapActionRight: {
marginRight: 0
},
title: {
fontSize: theme.typography.pxToRem(16),
lineHeight: '24px',
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap'
},
subtitle: {
fontSize: theme.typography.pxToRem(12),
lineHeight: 1,
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap'
},
actionIconPositionLeft: {
order: -1
},
childImg: {
height: '100%',
transform: 'translateX(-50%)',
position: 'relative',
left: '50%'
}
});
function GridListTileBar(props) {
const {
actionIcon,
actionPosition,
classes,
className: classNameProp,
subtitle,
title,
titlePosition
} = props,
other = _objectWithoutProperties(props, ['actionIcon', 'actionPosition', 'classes', 'className', 'subtitle', 'title', 'titlePosition']);
const actionPos = actionIcon && actionPosition;
const className = classNames(classes.root, {
[classes.rootBottom]: titlePosition === 'bottom',
[classes.rootTop]: titlePosition === 'top',
[classes.rootWithSubtitle]: subtitle
}, classNameProp);
// Remove the margin between the title / subtitle wrapper, and the Action Icon
const titleWrapClassName = classNames(classes.titleWrap, {
[classes.titleWrapActionLeft]: actionPos === 'left',
[classes.titleWrapActionRight]: actionPos === 'right'
});
return React.createElement(
'div',
_extends({ className: className }, other),
React.createElement(
'div',
{ className: titleWrapClassName },
React.createElement(
'div',
{ className: classes.title },
title
),
subtitle ? React.createElement(
'div',
{ className: classes.subtitle },
subtitle
) : null
),
actionIcon ? React.createElement(
'div',
{ className: classNames({ [classes.actionIconPositionLeft]: actionPos === 'left' }) },
actionIcon
) : null
);
}
GridListTileBar.defaultProps = {
actionPosition: 'right',
titlePosition: 'bottom'
};
export default withStyles(styles, { name: 'MuiGridListTileBar' })(GridListTileBar);

View File

@@ -0,0 +1,8 @@
export { default } from './GridList';
export * from './GridList';
export { default as GridList } from './GridList';
export * from './GridList';
export { default as GridListTile } from './GridListTile';
export * from './GridListTile';
export { default as GridListTileBar } from './GridListTileBar';
export * from './GridListTileBar';

View File

@@ -0,0 +1,4 @@
export { default } from './GridList';
export { default as GridList } from './GridList';
export { default as GridListTile } from './GridListTile';
export { default as GridListTileBar } from './GridListTileBar';

View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import { StandardProps } from '..';
import { Breakpoint } from '../styles/createBreakpoints';
export interface HiddenProps extends StandardProps<{}, never> {
only?: Breakpoint | Array<Breakpoint>;
xsUp?: boolean;
smUp?: boolean;
mdUp?: boolean;
lgUp?: boolean;
xlUp?: boolean;
xsDown?: boolean;
smDown?: boolean;
mdDown?: boolean;
lgDown?: boolean;
xlDown?: boolean;
implementation?: 'js' | 'css';
}
declare const Hidden: React.ComponentType<HiddenProps>;
export default Hidden;

View File

@@ -0,0 +1,37 @@
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 HiddenJs from './HiddenJs';
import HiddenCss from './HiddenCss';
/**
* Responsively hides children based on the selected implementation.
*/
function Hidden(props) {
const { implementation } = props,
other = _objectWithoutProperties(props, ['implementation']);
if (implementation === 'js') {
return React.createElement(HiddenJs, other);
}
return React.createElement(HiddenCss, other);
}
Hidden.defaultProps = {
implementation: 'js',
xsUp: false,
smUp: false,
mdUp: false,
lgUp: false,
xlUp: false,
xsDown: false,
smDown: false,
mdDown: false,
lgDown: false,
xlDown: false
};
export default Hidden;

View File

@@ -0,0 +1,84 @@
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 flowtype/require-valid-file-annotation */
import React from 'react';
import warning from 'warning';
import { keys as breakpointKeys } from '../styles/createBreakpoints';
import { capitalizeFirstLetter } from '../utils/helpers';
import withStyles from '../styles/withStyles';
function generateStyles(theme) {
const hidden = {
display: 'none'
};
return breakpointKeys.reduce((styles, key) => {
styles[`only${capitalizeFirstLetter(key)}`] = {
[theme.breakpoints.only(key)]: hidden
};
styles[`${key}Up`] = {
[theme.breakpoints.up(key)]: hidden
};
styles[`${key}Down`] = {
[theme.breakpoints.down(key)]: hidden
};
return styles;
}, {});
}
const styles = theme => generateStyles(theme);
/**
* @ignore - internal component.
*/
function HiddenCss(props) {
const {
children,
classes,
only,
xsUp,
smUp,
mdUp,
lgUp,
xlUp,
xsDown,
smDown,
mdDown,
lgDown,
xlDown
} = props,
other = _objectWithoutProperties(props, ['children', 'classes', 'only', 'xsUp', 'smUp', 'mdUp', 'lgUp', 'xlUp', 'xsDown', 'smDown', 'mdDown', 'lgDown', 'xlDown']);
warning(Object.keys(other).length === 0 || Object.keys(other).length === 1 && other.hasOwnProperty('ref'), `Material-UI: unsupported properties received ${Object.keys(other).join(', ')} by \`<Hidden />\`.`);
const className = [];
for (let i = 0; i < breakpointKeys.length; i += 1) {
const breakpoint = breakpointKeys[i];
const breakpointUp = props[`${breakpoint}Up`];
const breakpointDown = props[`${breakpoint}Down`];
if (breakpointUp) {
className.push(classes[`${breakpoint}Up`]);
}
if (breakpointDown) {
className.push(classes[`${breakpoint}Down`]);
}
}
if (only) {
className.push(classes[`only${capitalizeFirstLetter(only)}`]);
}
return React.createElement(
'span',
{ className: className },
children
);
}
export default withStyles(styles, { name: 'MuiHiddenCss' })(HiddenCss);

View File

@@ -0,0 +1,20 @@
import * as React from 'react';
import { Breakpoint } from '../styles/createBreakpoints';
export interface HiddenJsProps {
only?: Breakpoint | Array<Breakpoint>;
xsUp?: boolean;
smUp?: boolean;
mdUp?: boolean;
lgUp?: boolean;
xlUp?: boolean;
xsDown?: boolean;
smDown?: boolean;
mdDown?: boolean;
lgDown?: boolean;
xlDown?: boolean;
}
declare const HiddenJs: React.ComponentType<HiddenJsProps>;
export default HiddenJs;

View File

@@ -0,0 +1,70 @@
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 warning from 'warning';
import { keys as breakpointKeys } from '../styles/createBreakpoints';
import withWidth, { isWidthDown, isWidthUp } from '../utils/withWidth';
/**
* @ignore - internal component.
*/
function HiddenJs(props) {
const {
children,
only,
xsUp,
smUp,
mdUp,
lgUp,
xlUp,
xsDown,
smDown,
mdDown,
lgDown,
xlDown,
width
} = props,
other = _objectWithoutProperties(props, ['children', 'only', 'xsUp', 'smUp', 'mdUp', 'lgUp', 'xlUp', 'xsDown', 'smDown', 'mdDown', 'lgDown', 'xlDown', 'width']);
warning(Object.keys(other).length === 0, `Material-UI: unsupported properties received ${JSON.stringify(other)} by \`<Hidden />\`.`);
let visible = true;
// `only` check is faster to get out sooner if used.
if (only) {
if (Array.isArray(only)) {
for (let i = 0; i < only.length; i += 1) {
const breakpoint = only[i];
if (width === breakpoint) {
visible = false;
break;
}
}
} else if (only && width === only) {
visible = false;
}
}
// Allow `only` to be combined with other props. If already hidden, no need to check others.
if (visible) {
// determine visibility based on the smallest size up
for (let i = 0; i < breakpointKeys.length; i += 1) {
const breakpoint = breakpointKeys[i];
const breakpointUp = props[`${breakpoint}Up`];
const breakpointDown = props[`${breakpoint}Down`];
if (breakpointUp && isWidthUp(breakpoint, width) || breakpointDown && isWidthDown(breakpoint, width)) {
visible = false;
break;
}
}
}
if (!visible) {
return null;
}
return children;
}
export default withWidth()(HiddenJs);

Some files were not shown because too many files have changed in this diff Show More