ant-design-vue/components/collapse/CollapsePanel.tsx

51 lines
1.6 KiB
Vue
Raw Normal View History

import { defineComponent, inject } from 'vue';
2020-07-15 07:27:35 +00:00
import { getOptionProps, getComponent, getSlot } from '../_util/props-util';
import VcCollapse from '../vc-collapse';
import { defaultConfigProvider } from '../config-provider';
import PropTypes from '../_util/vue-types';
2018-02-01 10:18:05 +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: {
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 {
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
},
});