-
Notifications
You must be signed in to change notification settings - Fork 134
/
Panel.jsx
90 lines (85 loc) · 2.05 KB
/
Panel.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import PanelContent from './PanelContent';
import Animate from 'rc-animate';
class CollapsePanel extends Component {
handleItemClick() {
this.props.onItemClick();
}
render() {
const {
className,
style,
prefixCls,
header,
headerClass,
children,
isActive,
showArrow,
destroyInactivePanel,
} = this.props;
const headerCls = classNames(`${prefixCls}-header`, {
[headerClass]: headerClass,
});
const itemCls = classNames({
[`${prefixCls}-item`]: true,
[`${prefixCls}-item-active`]: isActive,
}, className);
return (
<div className={itemCls} style={style}>
<div
className={headerCls}
onClick={this.handleItemClick.bind(this)}
role="tab"
aria-expanded={isActive}
>
{showArrow && <i className="arrow" />}
{header}
</div>
<Animate
showProp="isActive"
exclusive
component=""
animation={this.props.openAnimation}
>
<PanelContent
prefixCls={prefixCls}
isActive={isActive}
destroyInactivePanel={destroyInactivePanel}
>
{children}
</PanelContent>
</Animate>
</div>
);
}
}
CollapsePanel.propTypes = {
className: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object,
]),
children: PropTypes.any,
openAnimation: PropTypes.object,
prefixCls: PropTypes.string,
header: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.node,
]),
headerClass: PropTypes.string,
showArrow: PropTypes.bool,
isActive: PropTypes.bool,
onItemClick: PropTypes.func,
style: PropTypes.object,
destroyInactivePanel: PropTypes.bool,
};
CollapsePanel.defaultProps = {
showArrow: true,
isActive: false,
destroyInactivePanel: false,
onItemClick() {},
headerClass: '',
};
export default CollapsePanel;