2017-12-13 23:23:38 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
import RcCollapse from 'rc-collapse';
|
|
|
|
import classNames from 'classnames';
|
2018-12-05 19:12:18 +08:00
|
|
|
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
2017-12-13 23:23:38 +08:00
|
|
|
|
|
|
|
export interface CollapsePanelProps {
|
|
|
|
key: string;
|
|
|
|
header: React.ReactNode;
|
|
|
|
disabled?: boolean;
|
|
|
|
className?: string;
|
|
|
|
style?: React.CSSProperties;
|
|
|
|
showArrow?: boolean;
|
|
|
|
prefixCls?: string;
|
2018-01-31 10:44:33 +08:00
|
|
|
forceRender?: boolean;
|
2018-11-04 16:09:51 +08:00
|
|
|
id?: string;
|
2017-12-13 23:23:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default class CollapsePanel extends React.Component<CollapsePanelProps, {}> {
|
2018-12-05 19:12:18 +08:00
|
|
|
renderCollapsePanel = ({ getPrefixCls }: ConfigConsumerProps) => {
|
|
|
|
const { prefixCls: customizePrefixCls, className = '', showArrow = true } = this.props;
|
|
|
|
const prefixCls = getPrefixCls('collapse', customizePrefixCls);
|
2018-12-07 20:02:01 +08:00
|
|
|
const collapsePanelClassName = classNames(
|
|
|
|
{
|
|
|
|
[`${prefixCls}-no-arrow`]: !showArrow,
|
|
|
|
},
|
|
|
|
className,
|
|
|
|
);
|
2018-12-05 19:12:18 +08:00
|
|
|
return (
|
2018-12-07 20:02:01 +08:00
|
|
|
<RcCollapse.Panel {...this.props} prefixCls={prefixCls} className={collapsePanelClassName} />
|
2018-12-05 19:12:18 +08:00
|
|
|
);
|
2018-12-07 20:02:01 +08:00
|
|
|
};
|
2018-12-05 19:12:18 +08:00
|
|
|
|
|
|
|
render() {
|
2018-12-07 20:02:01 +08:00
|
|
|
return <ConfigConsumer>{this.renderCollapsePanel}</ConfigConsumer>;
|
2017-12-13 23:23:38 +08:00
|
|
|
}
|
|
|
|
}
|