Completely updated React, fixed #11, (hopefully)

This commit is contained in:
2018-03-04 19:11:49 -05:00
parent 6e0afd6e2a
commit 34e5f5139a
13674 changed files with 333464 additions and 473223 deletions

View File

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

View File

@@ -1,10 +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';
// @inheritedComponent Paper
import React from 'react';
import PropTypes from 'prop-types';
import Paper from '../Paper';
function Card(props) {
@@ -14,6 +13,17 @@ function Card(props) {
return React.createElement(Paper, _extends({ elevation: raised ? 8 : 2 }, other));
}
Card.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* @ignore
*/
className: PropTypes.string,
/**
* If `true`, the card will use raised styling.
*/
raised: PropTypes.bool
} : {};
Card.defaultProps = {
raised: false
};

View File

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

View File

@@ -1,9 +1,7 @@
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 withStyles from '../styles/withStyles';
import { cloneChildrenWithClassName } from '../utils/reactHelpers';
@@ -13,9 +11,10 @@ export const styles = {
height: 52,
display: 'flex',
alignItems: 'center',
padding: '2px 4px'
padding: '2px 4px',
boxSizing: 'border-box'
},
actionSpacing: {
action: {
margin: '0 4px'
}
};
@@ -27,10 +26,29 @@ function CardActions(props) {
return React.createElement(
'div',
_extends({ className: classNames(classes.root, className) }, other),
disableActionSpacing ? children : cloneChildrenWithClassName(children, classes.actionSpacing)
disableActionSpacing ? children : cloneChildrenWithClassName(children, classes.action)
);
}
CardActions.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* If `true`, the card actions do not have additional margin.
*/
disableActionSpacing: PropTypes.bool
} : {};
CardActions.defaultProps = {
disableActionSpacing: false
};

View File

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

View File

@@ -1,8 +1,7 @@
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 withStyles from '../styles/withStyles';
@@ -16,10 +15,30 @@ export const styles = theme => ({
});
function CardContent(props) {
const { classes, className } = props,
other = _objectWithoutProperties(props, ['classes', 'className']);
const { classes, className, component: Component } = props,
other = _objectWithoutProperties(props, ['classes', 'className', 'component']);
return React.createElement('div', _extends({ className: classNames(classes.root, className) }, other));
return React.createElement(Component, _extends({ className: classNames(classes.root, className) }, other));
}
CardContent.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
} : {};
CardContent.defaultProps = {
component: 'div'
};
export default withStyles(styles, { name: 'MuiCardContent' })(CardContent);

View File

@@ -1,24 +1,17 @@
import * as React from 'react';
import { StandardProps } from '..';
import { CardContentProps, CardContentClassKey } from './CardContent';
import { CardContentProps } from './CardContent';
export interface CardHeaderProps extends StandardProps<
CardContentProps,
CardHeaderClassKey,
'title'
> {
export interface CardHeaderProps
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, CardHeaderClassKey, 'title'> {
action?: React.ReactNode;
avatar?: React.ReactNode;
component?: React.ReactType<CardHeaderProps>;
subheader?: React.ReactNode;
title?: React.ReactNode;
}
export type CardHeaderClassKey =
| CardContentClassKey
| 'avatar'
| 'content'
| 'title'
| 'subheader'
;
export type CardHeaderClassKey = 'root' | 'avatar' | 'action' | 'content' | 'title' | 'subheader';
declare const CardHeader: React.ComponentType<CardHeaderProps>;

View File

@@ -1,25 +1,27 @@
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 _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 withStyles from '../styles/withStyles';
import Typography from '../Typography';
import CardContent from './CardContent';
export const styles = theme => ({
root: {
display: 'flex',
alignItems: 'center'
alignItems: 'center',
padding: theme.spacing.unit * 2
},
avatar: {
flex: '0 0 auto',
marginRight: theme.spacing.unit * 2
},
action: {
flex: '0 0 auto',
alignSelf: 'flex-start',
marginTop: theme.spacing.unit * -1,
marginRight: theme.spacing.unit * -2
},
content: {
flex: '1 1 auto'
},
@@ -28,18 +30,20 @@ export const styles = theme => ({
});
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';
const {
action,
avatar,
classes,
className: classNameProp,
component: Component,
subheader,
title
} = props,
other = _objectWithoutProperties(props, ['action', 'avatar', 'classes', 'className', 'component', 'subheader', 'title']);
return React.createElement(
CardContent,
_extends({ className: className }, other),
Component,
_extends({ className: classNames(classes.root, classNameProp) }, other),
avatar && React.createElement(
'div',
{ className: classes.avatar },
@@ -50,21 +54,66 @@ function CardHeader(props) {
{ className: classes.content },
React.createElement(
Typography,
{ type: titleType, component: 'span', className: classes.title },
{
variant: avatar ? 'body2' : 'headline',
component: 'span',
className: classes.title
},
title
),
React.createElement(
subheader && React.createElement(
Typography,
{
type: subheaderType,
variant: avatar ? 'body2' : 'body1',
component: 'span',
color: 'secondary',
color: 'textSecondary',
className: classes.subheader
},
subheader
)
),
action && React.createElement(
'div',
{ className: classes.action },
action
)
);
}
CardHeader.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The action to display in the card header.
*/
action: PropTypes.node,
/**
* The Avatar for the Card Header.
*/
avatar: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* The content of the component.
*/
subheader: PropTypes.node,
/**
* The content of the Card Title.
*/
title: PropTypes.node
} : {};
CardHeader.defaultProps = {
component: 'div'
};
export default withStyles(styles, { name: 'MuiCardHeader' })(CardHeader);

View File

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

View File

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