11import React , { Component , PropTypes , Children , isValidElement } from 'react' ;
2- import propTypes from '../utils/propTypes' ;
32import Subheader from '../Subheader' ;
4- import deprecated from '../utils/deprecatedPropType' ;
5- import warning from 'warning' ;
63
74class List extends Component {
85 static propTypes = {
@@ -11,31 +8,10 @@ class List extends Component {
118 * be part of the list.
129 */
1310 children : PropTypes . node ,
14- /**
15- * If true, the subheader will be indented by 72px.
16- */
17- insetSubheader : deprecated ( PropTypes . bool ,
18- 'Refer to the `subheader` property. It will be removed with v0.16.0.' ) ,
1911 /**
2012 * Override the inline-styles of the root element.
2113 */
2214 style : PropTypes . object ,
23- /**
24- * The subheader string that will be displayed at the top of the list.
25- */
26- subheader : deprecated ( PropTypes . node ,
27- 'Instead, nest the `Subheader` component directly inside the `List`. It will be removed with v0.16.0.' ) ,
28- /**
29- * Override the inline-styles of the subheader element.
30- */
31- subheaderStyle : deprecated ( PropTypes . object ,
32- 'Refer to the `subheader` property. It will be removed with v0.16.0.' ) ,
33- /**
34- * @ignore
35- * ** Breaking change ** List no longer supports `zDepth`. Instead, wrap it in `Paper`
36- * or another component that provides zDepth.
37- */
38- zDepth : propTypes . zDepth ,
3915 } ;
4016
4117 static contextTypes = {
@@ -45,28 +21,17 @@ class List extends Component {
4521 render ( ) {
4622 const {
4723 children,
48- insetSubheader = false ,
4924 style,
50- subheader,
51- subheaderStyle,
52- zDepth,
5325 ...other ,
5426 } = this . props ;
5527
5628 const { prepareStyles} = this . context . muiTheme ;
5729
58- warning ( ( typeof zDepth === 'undefined' ) , 'List no longer supports `zDepth`. Instead, wrap it in `Paper` ' +
59- 'or another component that provides zDepth. It will be removed with v0.16.0.' ) ;
60-
6130 let hasSubheader = false ;
6231
63- if ( subheader ) {
32+ const firstChild = Children . toArray ( children ) [ 0 ] ;
33+ if ( isValidElement ( firstChild ) && firstChild . type === Subheader ) {
6434 hasSubheader = true ;
65- } else {
66- const firstChild = Children . toArray ( children ) [ 0 ] ;
67- if ( isValidElement ( firstChild ) && firstChild . type === Subheader ) {
68- hasSubheader = true ;
69- }
7035 }
7136
7237 const styles = {
@@ -79,11 +44,6 @@ class List extends Component {
7944
8045 return (
8146 < div { ...other } style = { prepareStyles ( Object . assign ( styles . root , style ) ) } >
82- { subheader && (
83- < Subheader inset = { insetSubheader } style = { subheaderStyle } >
84- { subheader }
85- </ Subheader >
86- ) }
8747 { children }
8848 </ div >
8949 ) ;
0 commit comments