2016-09-21 11:54:53 +08:00
|
|
|
import React from 'react';
|
2016-11-06 15:06:34 +08:00
|
|
|
import RcCollapse from 'rc-collapse';
|
|
|
|
import classNames from 'classnames';
|
2017-02-20 15:34:16 +08:00
|
|
|
import animation from '../_util/openAnimation';
|
2015-07-11 10:17:58 +08:00
|
|
|
|
2016-06-24 15:20:48 +08:00
|
|
|
export interface CollapseProps {
|
2016-07-13 11:14:24 +08:00
|
|
|
activeKey?: Array<string> | string;
|
|
|
|
defaultActiveKey?: Array<string>;
|
2016-11-06 15:06:34 +08:00
|
|
|
/** 手风琴效果 */
|
2016-07-13 17:22:23 +08:00
|
|
|
accordion?: boolean;
|
|
|
|
onChange?: (key: string) => void;
|
2016-07-13 11:14:24 +08:00
|
|
|
style?: React.CSSProperties;
|
2016-11-06 15:06:34 +08:00
|
|
|
className?: string;
|
|
|
|
bordered?: boolean;
|
|
|
|
prefixCls?: string;
|
2016-06-24 15:20:48 +08:00
|
|
|
}
|
|
|
|
|
2016-07-07 20:25:03 +08:00
|
|
|
export interface CollapsePanelProps {
|
2016-07-13 11:14:24 +08:00
|
|
|
key: string;
|
|
|
|
header: React.ReactNode;
|
|
|
|
style?: React.CSSProperties;
|
2016-11-06 15:06:34 +08:00
|
|
|
className?: string;
|
2016-06-24 15:20:48 +08:00
|
|
|
}
|
|
|
|
|
2016-07-07 20:25:03 +08:00
|
|
|
export class CollapsePanel extends React.Component<CollapsePanelProps, {}> {
|
2016-06-24 15:20:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default class Collapse extends React.Component<CollapseProps, any> {
|
|
|
|
static Panel: typeof CollapsePanel = RcCollapse.Panel;
|
2016-03-29 14:01:10 +08:00
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
prefixCls: 'ant-collapse',
|
2016-11-06 15:06:34 +08:00
|
|
|
bordered: true,
|
2017-02-20 15:34:16 +08:00
|
|
|
openAnimation: { ...animation, appear() {} },
|
2016-07-13 11:14:24 +08:00
|
|
|
};
|
2016-03-29 14:01:10 +08:00
|
|
|
|
2015-07-11 10:17:58 +08:00
|
|
|
render() {
|
2016-11-06 15:06:34 +08:00
|
|
|
const { prefixCls, className = '', bordered } = this.props;
|
|
|
|
const collapseClassName = classNames({
|
|
|
|
[`${prefixCls}-borderless`]: !bordered,
|
2016-11-30 10:20:23 +08:00
|
|
|
}, className);
|
2016-11-06 15:06:34 +08:00
|
|
|
return <RcCollapse {...this.props} className={collapseClassName} />;
|
2015-07-11 10:17:58 +08:00
|
|
|
}
|
|
|
|
}
|