2017-12-13 23:23:38 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
import RcCollapse from 'rc-collapse';
|
|
|
|
import classNames from 'classnames';
|
2020-05-26 20:55:39 +08:00
|
|
|
import { ConfigContext } from '../config-provider';
|
2017-12-13 23:23:38 +08:00
|
|
|
|
|
|
|
export interface CollapsePanelProps {
|
2019-07-13 10:31:56 +08:00
|
|
|
key: string | number;
|
2017-12-13 23:23:38 +08:00
|
|
|
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;
|
2019-02-13 19:32:49 +08:00
|
|
|
extra?: React.ReactNode;
|
2017-12-13 23:23:38 +08:00
|
|
|
}
|
|
|
|
|
2020-05-26 20:55:39 +08:00
|
|
|
const CollapsePanel: React.FC<CollapsePanelProps> = props => {
|
|
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
|
|
const { prefixCls: customizePrefixCls, className = '', showArrow = true } = props;
|
|
|
|
const prefixCls = getPrefixCls('collapse', customizePrefixCls);
|
|
|
|
const collapsePanelClassName = classNames(
|
|
|
|
{
|
|
|
|
[`${prefixCls}-no-arrow`]: !showArrow,
|
|
|
|
},
|
|
|
|
className,
|
|
|
|
);
|
|
|
|
return <RcCollapse.Panel {...props} prefixCls={prefixCls} className={collapsePanelClassName} />;
|
|
|
|
};
|
2018-12-05 19:12:18 +08:00
|
|
|
|
2020-05-26 20:55:39 +08:00
|
|
|
export default CollapsePanel;
|