2020-01-18 21:34:23 +08:00
|
|
|
import { getOptionProps, getComponentFromProp, getListeners } from '../_util/props-util';
|
2019-01-12 11:33:27 +08:00
|
|
|
import VcCollapse, { panelProps } from '../vc-collapse';
|
2019-03-15 11:20:37 +08:00
|
|
|
import { ConfigConsumerProps } from '../config-provider';
|
2018-02-01 18:18:05 +08:00
|
|
|
|
|
|
|
export default {
|
2018-04-08 21:17:20 +08:00
|
|
|
name: 'ACollapsePanel',
|
2018-02-01 18:18:05 +08:00
|
|
|
props: {
|
2019-02-21 14:31:35 +08:00
|
|
|
...panelProps(),
|
2018-02-01 18:18:05 +08:00
|
|
|
},
|
2019-03-15 11:20:37 +08:00
|
|
|
inject: {
|
2019-09-11 22:35:25 +08:00
|
|
|
configProvider: { default: () => ConfigConsumerProps },
|
2019-03-15 11:20:37 +08:00
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
render() {
|
2020-01-18 21:34:23 +08:00
|
|
|
const { prefixCls: customizePrefixCls, showArrow = true } = this;
|
2019-09-11 22:35:25 +08:00
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
2019-03-15 11:20:37 +08:00
|
|
|
const prefixCls = getPrefixCls('collapse', customizePrefixCls);
|
|
|
|
|
2018-02-01 18:18:05 +08:00
|
|
|
const collapsePanelClassName = {
|
|
|
|
[`${prefixCls}-no-arrow`]: !showArrow,
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
2018-02-01 18:18:05 +08:00
|
|
|
const rcCollapePanelProps = {
|
|
|
|
props: {
|
|
|
|
...getOptionProps(this),
|
2019-03-15 11:20:37 +08:00
|
|
|
prefixCls,
|
2020-03-07 19:45:13 +08:00
|
|
|
extra: getComponentFromProp(this, 'extra'),
|
2018-02-01 18:18:05 +08:00
|
|
|
},
|
|
|
|
class: collapsePanelClassName,
|
2020-01-18 21:34:23 +08:00
|
|
|
on: getListeners(this),
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
|
|
|
const header = getComponentFromProp(this, 'header');
|
2018-02-02 17:19:42 +08:00
|
|
|
return (
|
2019-01-12 11:33:27 +08:00
|
|
|
<VcCollapse.Panel {...rcCollapePanelProps}>
|
2018-09-05 21:28:54 +08:00
|
|
|
{this.$slots.default}
|
2019-01-12 11:33:27 +08:00
|
|
|
{header ? <template slot="header">{header}</template> : null}
|
2018-09-05 21:28:54 +08:00
|
|
|
</VcCollapse.Panel>
|
2019-01-12 11:33:27 +08:00
|
|
|
);
|
2018-02-01 18:18:05 +08:00
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|