2017-12-13 23:23:38 +08:00
|
|
|
import classNames from 'classnames';
|
2022-06-22 14:57:09 +08:00
|
|
|
import RcCollapse from 'rc-collapse';
|
|
|
|
import * as React from 'react';
|
2020-05-26 20:55:39 +08:00
|
|
|
import { ConfigContext } from '../config-provider';
|
2022-05-10 15:43:29 +08:00
|
|
|
import warning from '../_util/warning';
|
2020-11-30 15:20:42 +08:00
|
|
|
|
|
|
|
export type CollapsibleType = 'header' | 'disabled';
|
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;
|
2020-11-30 15:20:42 +08:00
|
|
|
/** @deprecated Use `collapsible="disabled"` instead */
|
2017-12-13 23:23:38 +08:00
|
|
|
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;
|
2020-12-01 09:40:35 +08:00
|
|
|
collapsible?: CollapsibleType;
|
2022-04-18 18:39:23 +08:00
|
|
|
children?: React.ReactNode;
|
2017-12-13 23:23:38 +08:00
|
|
|
}
|
|
|
|
|
2020-05-26 20:55:39 +08:00
|
|
|
const CollapsePanel: React.FC<CollapsePanelProps> = props => {
|
2022-05-10 15:43:29 +08:00
|
|
|
warning(
|
2020-11-30 15:20:42 +08:00
|
|
|
!('disabled' in props),
|
|
|
|
'Collapse.Panel',
|
|
|
|
'`disabled` is deprecated. Please use `collapsible="disabled"` instead.',
|
|
|
|
);
|
|
|
|
|
2020-05-26 20:55:39 +08:00
|
|
|
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;
|