ant-design/components/collapse/index.tsx

46 lines
1.2 KiB
TypeScript
Raw Normal View History

2016-09-21 11:54:53 +08:00
import React from 'react';
import RcCollapse from 'rc-collapse';
import classNames from 'classnames';
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-07-13 17:22:23 +08:00
accordion?: boolean;
onChange?: (key: string) => void;
2016-07-13 11:14:24 +08:00
style?: React.CSSProperties;
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;
disabled?: boolean;
className?: string;
style?: React.CSSProperties;
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;
static defaultProps = {
prefixCls: 'ant-collapse',
bordered: true,
openAnimation: { ...animation, appear() {} },
2016-07-13 11:14:24 +08:00
};
2015-07-11 10:17:58 +08:00
render() {
const { prefixCls, className = '', bordered } = this.props;
const collapseClassName = classNames({
[`${prefixCls}-borderless`]: !bordered,
}, className);
return <RcCollapse {...this.props} className={collapseClassName} />;
2015-07-11 10:17:58 +08:00
}
}