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

@@ -1,23 +1,15 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface ListProps extends StandardProps<
React.HTMLAttributes<HTMLUListElement>,
ListClassKey
> {
component?: React.ReactType;
export interface ListProps
extends StandardProps<React.HTMLAttributes<HTMLUListElement>, ListClassKey> {
component?: React.ReactType<ListProps>;
dense?: boolean;
disablePadding?: boolean;
rootRef?: React.Ref<any>;
subheader?: React.ReactElement<any>;
}
export type ListClassKey =
| 'root'
| 'padding'
| 'dense'
| 'subheader'
;
export type ListClassKey = 'root' | 'padding' | 'dense' | 'subheader';
declare const List: React.ComponentType<ListProps>;

View File

@@ -55,14 +55,9 @@ var _withStyles2 = _interopRequireDefault(_withStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_ElementType = require('react').babelPluginFlowReactPropTypes_proptype_ElementType || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
return {
root: {
flex: '1 1 auto',
listStyle: 'none',
margin: 0,
padding: 0,
@@ -82,51 +77,6 @@ var styles = exports.styles = function styles(theme) {
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* The content of the component.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: typeof babelPluginFlowReactPropTypes_proptype_ElementType === 'function' ? babelPluginFlowReactPropTypes_proptype_ElementType : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_ElementType),
/**
* If `true`, compact vertical padding designed for keyboard and mouse input will be used for
* the list and list items. The property is available to descendant components as the
* `dense` context.
*/
dense: require('prop-types').bool,
/**
* If `true`, vertical padding will be removed from the list.
*/
disablePadding: require('prop-types').bool,
/**
* Use that property to pass a ref callback to the root component.
*/
rootRef: require('prop-types').func,
/**
* The content of the component, normally `ListItem`.
*/
subheader: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)
};
var List = function (_React$Component) {
(0, _inherits3.default)(List, _React$Component);
@@ -148,21 +98,20 @@ var List = function (_React$Component) {
var _classNames;
var _props = this.props,
children = _props.children,
classes = _props.classes,
classNameProp = _props.className,
ComponentProp = _props.component,
disablePadding = _props.disablePadding,
children = _props.children,
Component = _props.component,
dense = _props.dense,
disablePadding = _props.disablePadding,
subheader = _props.subheader,
rootRef = _props.rootRef,
other = (0, _objectWithoutProperties3.default)(_props, ['classes', 'className', 'component', 'disablePadding', 'children', 'dense', 'subheader', 'rootRef']);
other = (0, _objectWithoutProperties3.default)(_props, ['children', 'classes', 'className', 'component', 'dense', 'disablePadding', 'subheader']);
var className = (0, _classnames2.default)(classes.root, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.dense, dense && !disablePadding), (0, _defineProperty3.default)(_classNames, classes.padding, !disablePadding), (0, _defineProperty3.default)(_classNames, classes.subheader, subheader), _classNames), classNameProp);
return _react2.default.createElement(
ComponentProp,
(0, _extends3.default)({ className: className }, other, { ref: rootRef }),
Component,
(0, _extends3.default)({ className: className }, other),
subheader,
children
);
@@ -171,13 +120,46 @@ var List = function (_React$Component) {
return List;
}(_react2.default.Component);
List.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component.
*/
children: _propTypes2.default.node,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]),
/**
* If `true`, compact vertical padding designed for keyboard and mouse input will be used for
* the list and list items. The property is available to descendant components as the
* `dense` context.
*/
dense: _propTypes2.default.bool,
/**
* If `true`, vertical padding will be removed from the list.
*/
disablePadding: _propTypes2.default.bool,
/**
* The content of the subheader, normally `ListSubheader`.
*/
subheader: _propTypes2.default.node
} : {};
List.defaultProps = {
component: 'ul',
dense: false,
disablePadding: false
};
List.childContextTypes = {
dense: _propTypes2.default.bool
};

View File

@@ -1,14 +1,10 @@
// @flow
import React from 'react';
import type { ElementType, Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
flex: '1 1 auto',
listStyle: 'none',
margin: 0,
padding: 0,
@@ -27,56 +23,7 @@ export const styles = (theme: Object) => ({
},
});
type ProvidedProps = {
classes: Object,
component: ElementType,
};
export type Props = {
/**
* The content of the component.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component?: ElementType,
/**
* If `true`, compact vertical padding designed for keyboard and mouse input will be used for
* the list and list items. The property is available to descendant components as the
* `dense` context.
*/
dense?: boolean,
/**
* If `true`, vertical padding will be removed from the list.
*/
disablePadding?: boolean,
/**
* Use that property to pass a ref callback to the root component.
*/
rootRef?: Function,
/**
* The content of the component, normally `ListItem`.
*/
subheader?: Node,
};
class List extends React.Component<ProvidedProps & Props> {
static defaultProps = {
component: 'ul',
dense: false,
disablePadding: false,
};
class List extends React.Component {
getChildContext() {
return {
dense: this.props.dense,
@@ -85,14 +32,13 @@ class List extends React.Component<ProvidedProps & Props> {
render() {
const {
children,
classes,
className: classNameProp,
component: ComponentProp,
disablePadding,
children,
component: Component,
dense,
disablePadding,
subheader,
rootRef,
...other
} = this.props;
const className = classNames(
@@ -106,14 +52,54 @@ class List extends React.Component<ProvidedProps & Props> {
);
return (
<ComponentProp className={className} {...other} ref={rootRef}>
<Component className={className} {...other}>
{subheader}
{children}
</ComponentProp>
</Component>
);
}
}
List.propTypes = {
/**
* The content of the component.
*/
children: 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]),
/**
* If `true`, compact vertical padding designed for keyboard and mouse input will be used for
* the list and list items. The property is available to descendant components as the
* `dense` context.
*/
dense: PropTypes.bool,
/**
* If `true`, vertical padding will be removed from the list.
*/
disablePadding: PropTypes.bool,
/**
* The content of the subheader, normally `ListSubheader`.
*/
subheader: PropTypes.node,
};
List.defaultProps = {
component: 'ul',
dense: false,
disablePadding: false,
};
List.childContextTypes = {
dense: PropTypes.bool,
};

View File

@@ -1,13 +1,15 @@
import * as React from 'react';
import { StandardProps, Replace } from '..';
import { StandardProps } from '..';
import { ButtonBaseProps, ButtonBaseClassKey } from '../ButtonBase';
export interface ListItemProps extends StandardProps<
Replace<ButtonBaseProps, React.LiHTMLAttributes<HTMLLIElement>>,
ListItemClassKey
> {
export interface ListItemProps
extends StandardProps<
ButtonBaseProps & React.LiHTMLAttributes<HTMLElement>,
ListItemClassKey,
'component'
> {
button?: boolean;
component?: React.ReactType;
component?: React.ReactType<ListItemProps>;
dense?: boolean;
disabled?: boolean;
disableGutters?: boolean;
@@ -23,8 +25,7 @@ export type ListItemClassKey =
| 'divider'
| 'gutters'
| 'button'
| 'secondaryAction'
;
| 'secondaryAction';
declare const ListItem: React.ComponentType<ListItemProps>;

View File

@@ -61,10 +61,6 @@ var _reactHelpers = require('../utils/reactHelpers');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_ElementType = require('react').babelPluginFlowReactPropTypes_proptype_ElementType || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
return {
root: {
@@ -72,13 +68,16 @@ var styles = exports.styles = function styles(theme) {
justifyContent: 'flex-start',
alignItems: 'center',
position: 'relative',
textDecoration: 'none'
textDecoration: 'none',
width: '100%',
boxSizing: 'border-box',
textAlign: 'left'
},
container: {
position: 'relative'
},
keyboardFocused: {
background: theme.palette.text.divider
backgroundColor: theme.palette.action.hover
},
default: {
paddingTop: 12,
@@ -92,7 +91,8 @@ var styles = exports.styles = function styles(theme) {
opacity: 0.5
},
divider: {
borderBottom: '1px solid ' + theme.palette.text.lightDivider
borderBottom: '1px solid ' + theme.palette.divider,
backgroundClip: 'padding-box'
},
gutters: {
paddingLeft: theme.spacing.unit * 2,
@@ -104,13 +104,10 @@ var styles = exports.styles = function styles(theme) {
}),
'&:hover': {
textDecoration: 'none',
backgroundColor: theme.palette.text.divider,
backgroundColor: theme.palette.action.hover,
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent'
},
'&$disabled': {
backgroundColor: 'transparent'
}
}
},
@@ -122,54 +119,6 @@ var styles = exports.styles = function styles(theme) {
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* If `true`, the ListItem will be a button.
*/
button: require('prop-types').bool,
/**
* The content of the component.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: typeof babelPluginFlowReactPropTypes_proptype_ElementType === 'function' ? babelPluginFlowReactPropTypes_proptype_ElementType : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_ElementType),
/**
* If `true`, compact vertical padding designed for keyboard and mouse input will be used.
*/
dense: require('prop-types').bool,
/**
* @ignore
*/
disabled: require('prop-types').bool,
/**
* If `true`, the left and right padding is removed.
*/
disableGutters: require('prop-types').bool,
/**
* If `true`, a 1px light border is added to the bottom of the list item.
*/
divider: require('prop-types').bool
};
var ListItem = function (_React$Component) {
(0, _inherits3.default)(ListItem, _React$Component);
@@ -196,38 +145,42 @@ var ListItem = function (_React$Component) {
classes = _props.classes,
classNameProp = _props.className,
componentProp = _props.component,
ContainerComponent = _props.ContainerComponent,
ContainerProps = _props.ContainerProps,
dense = _props.dense,
disabled = _props.disabled,
divider = _props.divider,
disableGutters = _props.disableGutters,
other = (0, _objectWithoutProperties3.default)(_props, ['button', 'children', 'classes', 'className', 'component', 'dense', 'disabled', 'divider', 'disableGutters']);
divider = _props.divider,
other = (0, _objectWithoutProperties3.default)(_props, ['button', 'children', 'classes', 'className', 'component', 'ContainerComponent', 'ContainerProps', 'dense', 'disabled', 'disableGutters', 'divider']);
var isDense = dense || this.context.dense || false;
var children = _react2.default.Children.toArray(childrenProp);
var hasAvatar = children.some(function (value) {
return (0, _reactHelpers.isMuiElement)(value, ['ListItemAvatar']);
});
var hasSecondaryAction = children.length && (0, _reactHelpers.isMuiElement)(children[children.length - 1], ['ListItemSecondaryAction']);
var className = (0, _classnames2.default)(classes.root, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.gutters, !disableGutters), (0, _defineProperty3.default)(_classNames, classes.divider, divider), (0, _defineProperty3.default)(_classNames, classes.disabled, disabled), (0, _defineProperty3.default)(_classNames, classes.button, button), (0, _defineProperty3.default)(_classNames, classes.secondaryAction, hasSecondaryAction), (0, _defineProperty3.default)(_classNames, isDense || hasAvatar ? classes.dense : classes.default, true), _classNames), classNameProp);
var className = (0, _classnames2.default)(classes.root, isDense || hasAvatar ? classes.dense : classes.default, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.gutters, !disableGutters), (0, _defineProperty3.default)(_classNames, classes.divider, divider), (0, _defineProperty3.default)(_classNames, classes.disabled, disabled), (0, _defineProperty3.default)(_classNames, classes.button, button), (0, _defineProperty3.default)(_classNames, classes.secondaryAction, hasSecondaryAction), _classNames), classNameProp);
var listItemProps = (0, _extends3.default)({ className: className, disabled: disabled }, other);
var ComponentMain = componentProp;
var componentProps = (0, _extends3.default)({ className: className, disabled: disabled }, other);
var Component = componentProp || 'li';
if (button) {
ComponentMain = _ButtonBase2.default;
listItemProps.component = componentProp || 'li';
listItemProps.keyboardFocusedClassName = classes.keyboardFocused;
componentProps.component = componentProp || 'div';
componentProps.keyboardFocusedClassName = classes.keyboardFocused;
Component = _ButtonBase2.default;
}
if (hasSecondaryAction) {
Component = Component !== _ButtonBase2.default && !componentProp ? 'div' : Component;
return _react2.default.createElement(
'div',
{ className: classes.container },
ContainerComponent,
(0, _extends3.default)({ className: classes.container }, ContainerProps),
_react2.default.createElement(
ComponentMain,
listItemProps,
Component,
componentProps,
children
),
children.pop()
@@ -235,8 +188,8 @@ var ListItem = function (_React$Component) {
}
return _react2.default.createElement(
ComponentMain,
listItemProps,
Component,
componentProps,
children
);
}
@@ -244,16 +197,65 @@ var ListItem = function (_React$Component) {
return ListItem;
}(_react2.default.Component);
ListItem.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* If `true`, the list item will be a button (using `ButtonBase`).
*/
button: _propTypes2.default.bool,
/**
* The content of the component.
*/
children: _propTypes2.default.node,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
* By default, it's a `li` when `button` is `false` and a `div` when `button` is `true`.
*/
component: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]),
/**
* The container component. Useful when a `ListItemSecondaryAction` is rendered.
*/
ContainerComponent: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]),
/**
* Properties applied to the container element when the component
* is used to display a `ListItemSecondaryAction`.
*/
ContainerProps: _propTypes2.default.object,
/**
* If `true`, compact vertical padding designed for keyboard and mouse input will be used.
*/
dense: _propTypes2.default.bool,
/**
* @ignore
*/
disabled: _propTypes2.default.bool,
/**
* If `true`, the left and right padding is removed.
*/
disableGutters: _propTypes2.default.bool,
/**
* If `true`, a 1px light border is added to the bottom of the list item.
*/
divider: _propTypes2.default.bool
} : {};
ListItem.defaultProps = {
button: false,
component: 'li',
ContainerComponent: 'li',
dense: false,
disabled: false,
disableGutters: false,
divider: false
};
ListItem.contextTypes = {
dense: _propTypes2.default.bool
};

View File

@@ -1,26 +1,26 @@
// @flow
import React from 'react';
import type { ElementType, Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import ButtonBase from '../ButtonBase';
import { isMuiElement } from '../utils/reactHelpers';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
display: 'flex',
justifyContent: 'flex-start',
alignItems: 'center',
position: 'relative',
textDecoration: 'none',
width: '100%',
boxSizing: 'border-box',
textAlign: 'left',
},
container: {
position: 'relative',
},
keyboardFocused: {
background: theme.palette.text.divider,
backgroundColor: theme.palette.action.hover,
},
default: {
paddingTop: 12,
@@ -34,7 +34,8 @@ export const styles = (theme: Object) => ({
opacity: 0.5,
},
divider: {
borderBottom: `1px solid ${theme.palette.text.lightDivider}`,
borderBottom: `1px solid ${theme.palette.divider}`,
backgroundClip: 'padding-box',
},
gutters: {
paddingLeft: theme.spacing.unit * 2,
@@ -46,14 +47,11 @@ export const styles = (theme: Object) => ({
}),
'&:hover': {
textDecoration: 'none',
backgroundColor: theme.palette.text.divider,
backgroundColor: theme.palette.action.hover,
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent',
},
'&$disabled': {
backgroundColor: 'transparent',
},
},
},
secondaryAction: {
@@ -63,61 +61,7 @@ export const styles = (theme: Object) => ({
},
});
type ProvidedProps = {
classes: Object,
component: ElementType,
};
export type Props = {
/**
* If `true`, the ListItem will be a button.
*/
button?: boolean,
/**
* The content of the component.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component?: ElementType,
/**
* If `true`, compact vertical padding designed for keyboard and mouse input will be used.
*/
dense?: boolean,
/**
* @ignore
*/
disabled?: boolean,
/**
* If `true`, the left and right padding is removed.
*/
disableGutters?: boolean,
/**
* If `true`, a 1px light border is added to the bottom of the list item.
*/
divider?: boolean,
};
class ListItem extends React.Component<ProvidedProps & Props> {
static defaultProps = {
button: false,
component: 'li',
dense: false,
disabled: false,
disableGutters: false,
divider: false,
};
class ListItem extends React.Component {
getChildContext() {
return {
dense: this.props.dense || this.context.dense || false,
@@ -131,54 +75,117 @@ class ListItem extends React.Component<ProvidedProps & Props> {
classes,
className: classNameProp,
component: componentProp,
ContainerComponent,
ContainerProps,
dense,
disabled,
divider,
disableGutters,
divider,
...other
} = this.props;
const isDense = dense || this.context.dense || false;
const children = React.Children.toArray(childrenProp);
const hasAvatar = children.some(value => isMuiElement(value, ['ListItemAvatar']));
const hasSecondaryAction =
children.length && isMuiElement(children[children.length - 1], ['ListItemSecondaryAction']);
const className = classNames(
classes.root,
isDense || hasAvatar ? classes.dense : classes.default,
{
[classes.gutters]: !disableGutters,
[classes.divider]: divider,
[classes.disabled]: disabled,
[classes.button]: button,
[classes.secondaryAction]: hasSecondaryAction,
[isDense || hasAvatar ? classes.dense : classes.default]: true,
},
classNameProp,
);
const listItemProps = { className, disabled, ...other };
let ComponentMain = componentProp;
const componentProps = { className, disabled, ...other };
let Component = componentProp || 'li';
if (button) {
ComponentMain = ButtonBase;
listItemProps.component = componentProp || 'li';
listItemProps.keyboardFocusedClassName = classes.keyboardFocused;
componentProps.component = componentProp || 'div';
componentProps.keyboardFocusedClassName = classes.keyboardFocused;
Component = ButtonBase;
}
if (hasSecondaryAction) {
Component = Component !== ButtonBase && !componentProp ? 'div' : Component;
return (
<div className={classes.container}>
<ComponentMain {...listItemProps}>{children}</ComponentMain>
<ContainerComponent className={classes.container} {...ContainerProps}>
<Component {...componentProps}>{children}</Component>
{children.pop()}
</div>
</ContainerComponent>
);
}
return <ComponentMain {...listItemProps}>{children}</ComponentMain>;
return <Component {...componentProps}>{children}</Component>;
}
}
ListItem.propTypes = {
/**
* If `true`, the list item will be a button (using `ButtonBase`).
*/
button: PropTypes.bool,
/**
* The content of the component.
*/
children: 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.
* By default, it's a `li` when `button` is `false` and a `div` when `button` is `true`.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* The container component. Useful when a `ListItemSecondaryAction` is rendered.
*/
ContainerComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* Properties applied to the container element when the component
* is used to display a `ListItemSecondaryAction`.
*/
ContainerProps: PropTypes.object,
/**
* If `true`, compact vertical padding designed for keyboard and mouse input will be used.
*/
dense: PropTypes.bool,
/**
* @ignore
*/
disabled: PropTypes.bool,
/**
* If `true`, the left and right padding is removed.
*/
disableGutters: PropTypes.bool,
/**
* If `true`, a 1px light border is added to the bottom of the list item.
*/
divider: PropTypes.bool,
};
ListItem.defaultProps = {
button: false,
ContainerComponent: 'li',
dense: false,
disabled: false,
disableGutters: false,
divider: false,
};
ListItem.contextTypes = {
dense: PropTypes.bool,
};

View File

@@ -2,10 +2,7 @@ import { StandardProps } from '..';
export interface ListItemAvatarProps extends StandardProps<{}, ListItemAvatarClassKey> {}
export type ListItemAvatarClassKey =
| 'root'
| 'icon'
;
export type ListItemAvatarClassKey = 'root' | 'icon';
declare const ListItemAvatar: React.ComponentType<ListItemAvatarProps>;

View File

@@ -39,8 +39,6 @@ var _withStyles2 = _interopRequireDefault(_withStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Element = require('react').babelPluginFlowReactPropTypes_proptype_Element || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
return {
root: {
@@ -57,45 +55,42 @@ var styles = exports.styles = function styles(theme) {
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* The content of the component, normally `Avatar`.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Element === 'function' ? babelPluginFlowReactPropTypes_proptype_Element.isRequired ? babelPluginFlowReactPropTypes_proptype_Element.isRequired : babelPluginFlowReactPropTypes_proptype_Element : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Element).isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string
};
/**
* It's a simple wrapper to apply the `dense` mode styles to `Avatar`.
*/
function ListItemAvatar(props, context) {
if (context.dense === undefined) {
process.env.NODE_ENV !== "production" ? (0, _warning2.default)(false, 'Material-UI: <ListItemAvatar> is a simple wrapper to apply the dense styles\n to <Avatar>. You do not need it unless you are controlling the <List> dense property.') : void 0;
return props.children;
}
var children = props.children,
classes = props.classes,
classNameProp = props.className,
other = (0, _objectWithoutProperties3.default)(props, ['children', 'classes', 'className']);
if (context.dense === undefined) {
process.env.NODE_ENV !== "production" ? (0, _warning2.default)(false, 'Material-UI: <ListItemAvatar> is a simple wrapper to apply the dense styles\n to <Avatar>. You do not need it unless you are controlling the <List> dense property.') : void 0;
return props.children;
}
return _react2.default.cloneElement(children, (0, _extends3.default)({
className: (0, _classnames2.default)((0, _defineProperty3.default)({}, classes.root, context.dense), classNameProp, children.props.className),
childrenClassName: (0, _classnames2.default)((0, _defineProperty3.default)({}, classes.icon, context.dense), children.props.childrenClassName)
}, other));
}
ListItemAvatar.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component, normally `Avatar`.
*/
children: _propTypes2.default.element.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string
} : {};
ListItemAvatar.contextTypes = {
dense: _propTypes2.default.bool
};

View File

@@ -1,13 +1,10 @@
// @flow
import React from 'react';
import type { Element } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import warning from 'warning';
import withStyles from '../styles/withStyles';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
width: 36,
height: 36,
@@ -21,29 +18,12 @@ export const styles = (theme: Object) => ({
},
});
type ProvidedProps = {
classes: Object,
};
export type Props = {
/**
* The content of the component, normally `Avatar`.
*/
children: Element<any>,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
};
/**
* It's a simple wrapper to apply the `dense` mode styles to `Avatar`.
*/
function ListItemAvatar(props: ProvidedProps & Props, context: { dense: boolean }) {
function ListItemAvatar(props, context) {
const { children, classes, className: classNameProp, ...other } = props;
if (context.dense === undefined) {
warning(
false,
@@ -53,8 +33,6 @@ function ListItemAvatar(props: ProvidedProps & Props, context: { dense: boolean
return props.children;
}
const { children, classes, className: classNameProp, ...other } = props;
return React.cloneElement(children, {
className: classNames(
{ [classes.root]: context.dense },
@@ -69,6 +47,21 @@ function ListItemAvatar(props: ProvidedProps & Props, context: { dense: boolean
});
}
ListItemAvatar.propTypes = {
/**
* The content of the component, normally `Avatar`.
*/
children: PropTypes.element.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
};
ListItemAvatar.contextTypes = {
dense: PropTypes.bool,
};

View File

@@ -2,9 +2,7 @@ import { StandardProps } from '..';
export interface ListItemIconProps extends StandardProps<{}, ListItemIconClassKey> {}
export type ListItemIconClassKey =
| 'root'
;
export type ListItemIconClassKey = 'root';
declare const ListItemIcon: React.ComponentType<ListItemIconProps>;

View File

@@ -17,6 +17,10 @@ var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
@@ -27,8 +31,6 @@ var _withStyles2 = _interopRequireDefault(_withStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Element = require('react').babelPluginFlowReactPropTypes_proptype_Element || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
return {
root: {
@@ -41,25 +43,6 @@ var styles = exports.styles = function styles(theme) {
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* The content of the component, normally `Icon`, `SvgIcon`,
* or a `material-ui-icons` SVG icon component.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Element === 'function' ? babelPluginFlowReactPropTypes_proptype_Element.isRequired ? babelPluginFlowReactPropTypes_proptype_Element.isRequired : babelPluginFlowReactPropTypes_proptype_Element : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Element).isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string
};
/**
* A simple wrapper to apply `List` styles to an `Icon` or `SvgIcon`.
*/
@@ -75,4 +58,20 @@ function ListItemIcon(props) {
}, other));
}
ListItemIcon.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component, normally `Icon`, `SvgIcon`,
* or a `material-ui-icons` SVG icon component.
*/
children: _propTypes2.default.element.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string
} : {};
exports.default = (0, _withStyles2.default)(styles, { name: 'MuiListItemIcon' })(ListItemIcon);

View File

@@ -1,11 +1,9 @@
// @flow
import React from 'react';
import type { Element } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
height: 24,
marginRight: theme.spacing.unit * 2,
@@ -15,30 +13,10 @@ export const styles = (theme: Object) => ({
},
});
type ProvidedProps = {
classes: Object,
};
export type Props = {
/**
* The content of the component, normally `Icon`, `SvgIcon`,
* or a `material-ui-icons` SVG icon component.
*/
children: Element<any>,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
};
/**
* A simple wrapper to apply `List` styles to an `Icon` or `SvgIcon`.
*/
function ListItemIcon(props: ProvidedProps & Props) {
function ListItemIcon(props) {
const { children, classes, className: classNameProp, ...other } = props;
return React.cloneElement(children, {
@@ -47,4 +25,20 @@ function ListItemIcon(props: ProvidedProps & Props) {
});
}
ListItemIcon.propTypes = {
/**
* The content of the component, normally `Icon`, `SvgIcon`,
* or a `material-ui-icons` SVG icon component.
*/
children: PropTypes.element.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
};
export default withStyles(styles, { name: 'MuiListItemIcon' })(ListItemIcon);

View File

@@ -1,10 +1,9 @@
import { StandardProps } from '..';
export interface ListItemSecondaryActionProps extends StandardProps<{}, ListItemSecondaryActionClassKey> {}
export interface ListItemSecondaryActionProps
extends StandardProps<{}, ListItemSecondaryActionClassKey> {}
export type ListItemSecondaryActionClassKey =
| 'root'
;
export type ListItemSecondaryActionClassKey = 'root';
declare const ListItemSecondaryAction: React.ComponentType<ListItemSecondaryActionProps>;

View File

@@ -5,16 +5,22 @@ Object.defineProperty(exports, "__esModule", {
});
exports.styles = undefined;
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _extends2 = require('babel-runtime/helpers/extends');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends3 = _interopRequireDefault(_extends2);
var _ref; // weak
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
@@ -25,8 +31,6 @@ var _withStyles2 = _interopRequireDefault(_withStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
return {
root: {
@@ -38,41 +42,35 @@ var styles = exports.styles = function styles(theme) {
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* The content of the component, normally an `IconButton` or selection control.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string
};
function ListItemSecondaryAction(props) {
var children = props.children,
classes = props.classes,
className = props.className;
className = props.className,
other = (0, _objectWithoutProperties3.default)(props, ['children', 'classes', 'className']);
return _react2.default.createElement(
'div',
{ className: (0, _classnames2.default)(classes.root, className) },
(0, _extends3.default)({ className: (0, _classnames2.default)(classes.root, className) }, other),
children
);
}
ListItemSecondaryAction.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired,
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), _ref) : {};
ListItemSecondaryAction.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component, normally an `IconButton` or selection control.
*/
children: _propTypes2.default.node,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string
} : {};
ListItemSecondaryAction.muiName = 'ListItemSecondaryAction';
exports.default = (0, _withStyles2.default)(styles, { name: 'MuiListItemSecondaryAction' })(ListItemSecondaryAction);

View File

@@ -1,11 +1,9 @@
// @flow weak
import React from 'react';
import type { Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
position: 'absolute',
right: 4,
@@ -14,31 +12,31 @@ export const styles = (theme: Object) => ({
},
});
type ProvidedProps = {
classes: Object,
};
function ListItemSecondaryAction(props) {
const { children, classes, className, ...other } = props;
export type Props = {
return (
<div className={classNames(classes.root, className)} {...other}>
{children}
</div>
);
}
ListItemSecondaryAction.propTypes = {
/**
* The content of the component, normally an `IconButton` or selection control.
*/
children?: Node,
children: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className?: string,
className: PropTypes.string,
};
function ListItemSecondaryAction(props: ProvidedProps & Props) {
const { children, classes, className } = props;
return <div className={classNames(classes.root, className)}>{children}</div>;
}
ListItemSecondaryAction.muiName = 'ListItemSecondaryAction';
export default withStyles(styles, { name: 'MuiListItemSecondaryAction' })(ListItemSecondaryAction);

View File

@@ -1,10 +1,8 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface ListItemTextProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
ListItemTextClassKey
> {
export interface ListItemTextProps
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, ListItemTextClassKey> {
disableTypography?: boolean;
inset?: boolean;
primary?: React.ReactNode;
@@ -15,9 +13,9 @@ export type ListItemTextClassKey =
| 'root'
| 'inset'
| 'dense'
| 'text'
| 'textDense'
;
| 'primary'
| 'secondary'
| 'textDense';
declare const ListItemText: React.ComponentType<ListItemTextProps>;

View File

@@ -17,8 +17,6 @@ var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProp
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _ref; // weak
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
@@ -41,12 +39,11 @@ var _Typography2 = _interopRequireDefault(_Typography);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
return {
root: {
flex: '1 1 auto',
minWidth: 0,
padding: '0 16px',
'&:first-child': {
paddingLeft: 0
@@ -60,50 +57,30 @@ var styles = exports.styles = function styles(theme) {
dense: {
fontSize: theme.typography.pxToRem(13)
},
text: {}, // Present to allow external customization
textDense: {
fontSize: 'inherit'
}
primary: {
'&$textDense': {
fontSize: 'inherit'
}
},
secondary: {
'&$textDense': {
fontSize: 'inherit'
}
},
textDense: {}
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string,
/**
* If `true`, the children won't be wrapped by a typography component.
* For instance, that can be useful to can render an h4 instead of a
*/
disableTypography: require('prop-types').bool,
/**
* If `true`, the children will be indented.
* This should be used if there is no left avatar or left icon.
*/
inset: require('prop-types').bool,
primary: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
secondary: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)
};
function ListItemText(props, context) {
var _classNames;
var classes = props.classes,
classNameProp = props.className,
disableTypography = props.disableTypography,
inset = props.inset,
primary = props.primary,
secondary = props.secondary,
inset = props.inset,
other = (0, _objectWithoutProperties3.default)(props, ['classes', 'className', 'disableTypography', 'primary', 'secondary', 'inset']);
other = (0, _objectWithoutProperties3.default)(props, ['classes', 'className', 'disableTypography', 'inset', 'primary', 'secondary']);
var dense = context.dense;
var className = (0, _classnames2.default)(classes.root, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.dense, dense), (0, _defineProperty3.default)(_classNames, classes.inset, inset), _classNames), classNameProp);
@@ -114,31 +91,51 @@ function ListItemText(props, context) {
primary && (disableTypography ? primary : _react2.default.createElement(
_Typography2.default,
{
type: 'subheading',
className: (0, _classnames2.default)(classes.text, (0, _defineProperty3.default)({}, classes.textDense, dense))
variant: 'subheading',
className: (0, _classnames2.default)(classes.primary, (0, _defineProperty3.default)({}, classes.textDense, dense))
},
primary
)),
secondary && (disableTypography ? secondary : _react2.default.createElement(
_Typography2.default,
{
color: 'secondary',
type: 'body1',
className: (0, _classnames2.default)(classes.text, (0, _defineProperty3.default)({}, classes.textDense, dense))
variant: 'body1',
className: (0, _classnames2.default)(classes.secondary, (0, _defineProperty3.default)({}, classes.textDense, dense)),
color: 'textSecondary'
},
secondary
))
);
}
ListItemText.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), (0, _defineProperty3.default)(_ref, 'disableTypography', require('prop-types').bool), (0, _defineProperty3.default)(_ref, 'inset', require('prop-types').bool), (0, _defineProperty3.default)(_ref, 'primary', typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)), (0, _defineProperty3.default)(_ref, 'secondary', typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)), _ref) : {};
ListItemText.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string,
/**
* If `true`, the children won't be wrapped by a typography component.
* For instance, that can be useful to can render an h4 instead of a
*/
disableTypography: _propTypes2.default.bool,
/**
* If `true`, the children will be indented.
* This should be used if there is no left avatar or left icon.
*/
inset: _propTypes2.default.bool,
primary: _propTypes2.default.node,
secondary: _propTypes2.default.node
} : {};
ListItemText.defaultProps = {
disableTypography: false,
inset: false,
primary: false,
secondary: false,
inset: false
secondary: false
};
ListItemText.contextTypes = {

View File

@@ -1,15 +1,13 @@
// @flow weak
import React from 'react';
import type { Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import Typography from '../Typography';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
flex: '1 1 auto',
minWidth: 0,
padding: '0 16px',
'&:first-child': {
paddingLeft: 0,
@@ -23,47 +21,27 @@ export const styles = (theme: Object) => ({
dense: {
fontSize: theme.typography.pxToRem(13),
},
text: {}, // Present to allow external customization
textDense: {
fontSize: 'inherit',
primary: {
'&$textDense': {
fontSize: 'inherit',
},
},
secondary: {
'&$textDense': {
fontSize: 'inherit',
},
},
textDense: {},
});
type ProvidedProps = {
classes: Object,
};
export type Props = {
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* If `true`, the children won't be wrapped by a typography component.
* For instance, that can be useful to can render an h4 instead of a
*/
disableTypography?: boolean,
/**
* If `true`, the children will be indented.
* This should be used if there is no left avatar or left icon.
*/
inset?: boolean,
primary?: Node,
secondary?: Node,
};
function ListItemText(props: ProvidedProps & Props, context) {
function ListItemText(props, context) {
const {
classes,
className: classNameProp,
disableTypography,
inset,
primary,
secondary,
inset,
...other
} = props;
const { dense } = context;
@@ -83,8 +61,8 @@ function ListItemText(props: ProvidedProps & Props, context) {
primary
) : (
<Typography
type="subheading"
className={classNames(classes.text, { [classes.textDense]: dense })}
variant="subheading"
className={classNames(classes.primary, { [classes.textDense]: dense })}
>
{primary}
</Typography>
@@ -94,9 +72,11 @@ function ListItemText(props: ProvidedProps & Props, context) {
secondary
) : (
<Typography
color="secondary"
type="body1"
className={classNames(classes.text, { [classes.textDense]: dense })}
variant="body1"
className={classNames(classes.secondary, {
[classes.textDense]: dense,
})}
color="textSecondary"
>
{secondary}
</Typography>
@@ -105,11 +85,34 @@ function ListItemText(props: ProvidedProps & Props, context) {
);
}
ListItemText.propTypes = {
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* If `true`, the children won't be wrapped by a typography component.
* For instance, that can be useful to can render an h4 instead of a
*/
disableTypography: PropTypes.bool,
/**
* If `true`, the children will be indented.
* This should be used if there is no left avatar or left icon.
*/
inset: PropTypes.bool,
primary: PropTypes.node,
secondary: PropTypes.node,
};
ListItemText.defaultProps = {
disableTypography: false,
inset: false,
primary: false,
secondary: false,
inset: false,
};
ListItemText.contextTypes = {

View File

@@ -1,22 +1,15 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface ListSubheaderProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
ListSubheaderClassKey
> {
export interface ListSubheaderProps
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, ListSubheaderClassKey> {
component?: React.ReactType<ListSubheaderProps>;
color?: 'default' | 'primary' | 'inherit';
inset?: boolean;
disableSticky?: boolean;
}
export type ListSubheaderClassKey =
| 'root'
| 'colorPrimary'
| 'colorInherit'
| 'inset'
| 'sticky'
;
export type ListSubheaderClassKey = 'root' | 'colorPrimary' | 'colorInherit' | 'inset' | 'sticky';
declare const ListSubheader: React.ComponentType<ListSubheaderProps>;

View File

@@ -17,12 +17,14 @@ var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProp
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _ref; // weak
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
@@ -35,13 +37,12 @@ var _helpers = require('../utils/helpers');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
return {
root: {
boxSizing: 'border-box',
lineHeight: '48px',
listStyle: 'none',
paddingLeft: theme.spacing.unit * 2,
paddingRight: theme.spacing.unit * 2,
color: theme.palette.text.secondary,
@@ -50,7 +51,7 @@ var styles = exports.styles = function styles(theme) {
fontSize: theme.typography.pxToRem(theme.typography.fontSize)
},
colorPrimary: {
color: theme.palette.primary[500]
color: theme.palette.primary.main
},
colorInherit: {
color: 'inherit'
@@ -67,65 +68,57 @@ var styles = exports.styles = function styles(theme) {
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* The content of the component.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string,
/**
* The color of the component. It's using the theme palette when that makes sense.
*/
color: require('prop-types').oneOf(['default', 'primary', 'inherit']),
/**
* If `true`, the List Subheader will not stick to the top during scroll.
*/
disableSticky: require('prop-types').bool,
/**
* If `true`, the List Subheader will be indented.
*/
inset: require('prop-types').bool
};
function ListSubheader(props) {
var _classNames;
var children = props.children,
classes = props.classes,
var classes = props.classes,
classNameProp = props.className,
color = props.color,
Component = props.component,
disableSticky = props.disableSticky,
inset = props.inset,
other = (0, _objectWithoutProperties3.default)(props, ['children', 'classes', 'className', 'color', 'disableSticky', 'inset']);
other = (0, _objectWithoutProperties3.default)(props, ['classes', 'className', 'color', 'component', 'disableSticky', 'inset']);
var className = (0, _classnames2.default)(classes.root, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes['color' + (0, _helpers.capitalizeFirstLetter)(color)], color !== 'default'), (0, _defineProperty3.default)(_classNames, classes.inset, inset), (0, _defineProperty3.default)(_classNames, classes.sticky, !disableSticky), _classNames), classNameProp);
var className = (0, _classnames2.default)(classes.root, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes['color' + (0, _helpers.capitalize)(color)], color !== 'default'), (0, _defineProperty3.default)(_classNames, classes.inset, inset), (0, _defineProperty3.default)(_classNames, classes.sticky, !disableSticky), _classNames), classNameProp);
return _react2.default.createElement(
'div',
(0, _extends3.default)({ className: className }, other),
children
);
return _react2.default.createElement(Component, (0, _extends3.default)({ className: className }, other));
}
ListSubheader.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired,
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), (0, _defineProperty3.default)(_ref, 'color', require('prop-types').oneOf(['default', 'primary', 'inherit'])), (0, _defineProperty3.default)(_ref, 'disableSticky', require('prop-types').bool), (0, _defineProperty3.default)(_ref, 'inset', require('prop-types').bool), _ref) : {};
ListSubheader.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component.
*/
children: _propTypes2.default.node,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string,
/**
* The color of the component. It supports those theme colors that make sense for this component.
*/
color: _propTypes2.default.oneOf(['default', 'primary', 'inherit']),
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]),
/**
* If `true`, the List Subheader will not stick to the top during scroll.
*/
disableSticky: _propTypes2.default.bool,
/**
* If `true`, the List Subheader will be indented.
*/
inset: _propTypes2.default.bool
} : {};
ListSubheader.defaultProps = {
color: 'default',
component: 'li',
disableSticky: false,
inset: false
};

View File

@@ -1,15 +1,14 @@
// @flow weak
import React from 'react';
import type { Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import { capitalizeFirstLetter } from '../utils/helpers';
import { capitalize } from '../utils/helpers';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
boxSizing: 'border-box',
lineHeight: '48px',
listStyle: 'none',
paddingLeft: theme.spacing.unit * 2,
paddingRight: theme.spacing.unit * 2,
color: theme.palette.text.secondary,
@@ -18,7 +17,7 @@ export const styles = (theme: Object) => ({
fontSize: theme.typography.pxToRem(theme.typography.fontSize),
},
colorPrimary: {
color: theme.palette.primary[500],
color: theme.palette.primary.main,
},
colorInherit: {
color: 'inherit',
@@ -34,43 +33,12 @@ export const styles = (theme: Object) => ({
},
});
type ProvidedProps = {
classes: Object,
};
export type Props = {
/**
* The content of the component.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* The color of the component. It's using the theme palette when that makes sense.
*/
color?: 'default' | 'primary' | 'inherit',
/**
* If `true`, the List Subheader will not stick to the top during scroll.
*/
disableSticky?: boolean,
/**
* If `true`, the List Subheader will be indented.
*/
inset?: boolean,
};
function ListSubheader(props: ProvidedProps & Props) {
function ListSubheader(props) {
const {
children,
classes,
className: classNameProp,
color,
component: Component,
disableSticky,
inset,
...other
@@ -78,22 +46,51 @@ function ListSubheader(props: ProvidedProps & Props) {
const className = classNames(
classes.root,
{
[classes[`color${capitalizeFirstLetter(color)}`]]: color !== 'default',
[classes[`color${capitalize(color)}`]]: color !== 'default',
[classes.inset]: inset,
[classes.sticky]: !disableSticky,
},
classNameProp,
);
return (
<div className={className} {...other}>
{children}
</div>
);
return <Component className={className} {...other} />;
}
ListSubheader.propTypes = {
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The color of the component. It supports those theme colors that make sense for this component.
*/
color: PropTypes.oneOf(['default', 'primary', 'inherit']),
/**
* 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]),
/**
* If `true`, the List Subheader will not stick to the top during scroll.
*/
disableSticky: PropTypes.bool,
/**
* If `true`, the List Subheader will be indented.
*/
inset: PropTypes.bool,
};
ListSubheader.defaultProps = {
color: 'default',
component: 'li',
disableSticky: false,
inset: false,
};

View File

@@ -1,5 +1,3 @@
// @flow
export { default } from './List';
export { default as ListItem } from './ListItem';
export { default as ListItemAvatar } from './ListItemAvatar';