Completely updated React, fixed #11, (hopefully)
This commit is contained in:
52
goTorrentWebUI/node_modules/material-ui/es/Card/CardMedia.js
generated
vendored
52
goTorrentWebUI/node_modules/material-ui/es/Card/CardMedia.js
generated
vendored
@@ -1,11 +1,9 @@
|
||||
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 _extends from 'babel-runtime/helpers/extends';
|
||||
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import warning from 'warning';
|
||||
|
||||
import withStyles from '../styles/withStyles';
|
||||
|
||||
export const styles = {
|
||||
@@ -19,28 +17,60 @@ export const styles = {
|
||||
}
|
||||
};
|
||||
|
||||
const mediaComponents = ['video', 'audio', 'picture', 'iframe', 'img'];
|
||||
const MEDIA_COMPONENTS = ['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']);
|
||||
const { classes, className, component: Component, image, src, style } = props,
|
||||
other = _objectWithoutProperties(props, ['classes', 'className', 'component', 'image', 'src', 'style']);
|
||||
|
||||
warning(Boolean(image || src), 'Material-UI: either `image` or `src` property must be specified.');
|
||||
process.env.NODE_ENV !== "production" ? warning(Boolean(image || src), 'Material-UI: either `image` or `src` property must be specified.') : void 0;
|
||||
|
||||
const isMediaComponent = mediaComponents.indexOf(ComponentProp) !== -1;
|
||||
const isMediaComponent = MEDIA_COMPONENTS.indexOf(Component) !== -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({
|
||||
return React.createElement(Component, _extends({
|
||||
className: composedClassName,
|
||||
style: composedStyle,
|
||||
src: isMediaComponent ? image || src : undefined
|
||||
}, other));
|
||||
}
|
||||
|
||||
CardMedia.propTypes = process.env.NODE_ENV !== "production" ? {
|
||||
/**
|
||||
* Useful to extend the style applied to components.
|
||||
*/
|
||||
classes: PropTypes.object.isRequired,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* Component for rendering image.
|
||||
* Either a string to use a DOM element or a component.
|
||||
*/
|
||||
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
||||
/**
|
||||
* Image to be displayed as a background image.
|
||||
* Either `image` or `src` prop must be specified.
|
||||
* Note that caller must specify height otherwise the image will not be visible.
|
||||
*/
|
||||
image: PropTypes.string,
|
||||
/**
|
||||
* An alias for `image` property.
|
||||
* Available only with media components.
|
||||
* Media components: `video`, `audio`, `picture`, `iframe`, `img`.
|
||||
*/
|
||||
src: PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
style: PropTypes.object
|
||||
} : {};
|
||||
|
||||
CardMedia.defaultProps = {
|
||||
component: 'div'
|
||||
};
|
||||
|
Reference in New Issue
Block a user