2020-10-14 09:57:38 +00:00
|
|
|
import { defineComponent, inject } from 'vue';
|
2020-07-15 07:27:35 +00:00
|
|
|
import { getOptionProps, getComponent, getSlot } from '../_util/props-util';
|
2020-10-14 09:57:38 +00:00
|
|
|
import VcCollapse from '../vc-collapse';
|
2020-09-30 02:47:18 +00:00
|
|
|
import { defaultConfigProvider } from '../config-provider';
|
2020-10-14 09:57:38 +00:00
|
|
|
import PropTypes from '../_util/vue-types';
|
2018-02-01 10:18:05 +00:00
|
|
|
|
2020-10-14 09:57:38 +00:00
|
|
|
export default defineComponent({
|
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: {
|
2020-10-14 09:57:38 +00:00
|
|
|
openAnimation: PropTypes.object,
|
|
|
|
prefixCls: PropTypes.string,
|
|
|
|
header: PropTypes.VNodeChild,
|
|
|
|
headerClass: PropTypes.string,
|
|
|
|
showArrow: PropTypes.looseBool,
|
|
|
|
isActive: PropTypes.looseBool,
|
|
|
|
destroyInactivePanel: PropTypes.looseBool,
|
|
|
|
disabled: PropTypes.looseBool,
|
|
|
|
accordion: PropTypes.looseBool,
|
|
|
|
forceRender: PropTypes.looseBool,
|
|
|
|
expandIcon: PropTypes.func,
|
|
|
|
extra: PropTypes.VNodeChild,
|
|
|
|
panelKey: PropTypes.VNodeChild,
|
2018-02-01 10:18:05 +00:00
|
|
|
},
|
2020-07-15 07:27:35 +00:00
|
|
|
setup() {
|
|
|
|
return {
|
2020-09-30 02:47:18 +00:00
|
|
|
configProvider: inject('configProvider', defaultConfigProvider),
|
2020-07-15 07:27:35 +00:00
|
|
|
};
|
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-11-14 05:56:39 +00:00
|
|
|
const { class: className, ...restAttrs } = this.$attrs;
|
2018-02-01 10:18:05 +00:00
|
|
|
const collapsePanelClassName = {
|
2020-11-14 05:56:39 +00:00
|
|
|
[className as string]: 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
|
|
|
},
|
2020-10-14 09:57:38 +00:00
|
|
|
});
|