2020-07-15 07:27:35 +00:00
|
|
|
import { inject } from 'vue';
|
|
|
|
import { getOptionProps, getComponent, getSlot } from '../_util/props-util';
|
2019-01-12 03:33:27 +00:00
|
|
|
import VcCollapse, { panelProps } from '../vc-collapse';
|
2019-03-15 03:20:37 +00:00
|
|
|
import { ConfigConsumerProps } from '../config-provider';
|
2018-02-01 10:18:05 +00:00
|
|
|
|
|
|
|
export default {
|
2018-04-08 13:17:20 +00:00
|
|
|
name: 'ACollapsePanel',
|
2020-07-16 08:24:44 +00:00
|
|
|
inheritAttrs: false,
|
2018-02-01 10:18:05 +00:00
|
|
|
props: {
|
2019-02-21 06:31:35 +00:00
|
|
|
...panelProps(),
|
2018-02-01 10:18:05 +00:00
|
|
|
},
|
2020-07-15 07:27:35 +00:00
|
|
|
setup() {
|
|
|
|
return {
|
|
|
|
configProvider: inject('configProvider', ConfigConsumerProps),
|
|
|
|
};
|
2019-03-15 03:20:37 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
render() {
|
2020-01-18 13:34:23 +00:00
|
|
|
const { prefixCls: customizePrefixCls, showArrow = true } = this;
|
2019-09-11 14:35:25 +00:00
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
2019-03-15 03:20:37 +00:00
|
|
|
const prefixCls = getPrefixCls('collapse', customizePrefixCls);
|
2020-07-16 08:24:44 +00:00
|
|
|
const { class: className, ...restAttrs } = this.$attrs;
|
2018-02-01 10:18:05 +00:00
|
|
|
const collapsePanelClassName = {
|
2020-07-16 08:24:44 +00:00
|
|
|
[className]: className,
|
2018-02-01 10:18:05 +00:00
|
|
|
[`${prefixCls}-no-arrow`]: !showArrow,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2020-07-15 07:27:35 +00:00
|
|
|
|
2018-02-01 10:18:05 +00:00
|
|
|
const rcCollapePanelProps = {
|
2020-07-15 07:27:35 +00:00
|
|
|
...getOptionProps(this),
|
|
|
|
header: getComponent(this, 'header'),
|
|
|
|
prefixCls,
|
|
|
|
extra: getComponent(this, 'extra'),
|
2018-02-01 10:18:05 +00:00
|
|
|
class: collapsePanelClassName,
|
2020-07-16 08:24:44 +00:00
|
|
|
...restAttrs,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2020-07-15 07:27:35 +00:00
|
|
|
return <VcCollapse.Panel {...rcCollapePanelProps}>{getSlot(this)}</VcCollapse.Panel>;
|
2018-02-01 10:18:05 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|