mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-06 05:59:46 +08:00
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { defineComponent, inject } from 'vue';
|
|
import { getOptionProps, getComponent, getSlot } from '../_util/props-util';
|
|
import VcCollapse from '../vc-collapse';
|
|
import { defaultConfigProvider } from '../config-provider';
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
export default defineComponent({
|
|
name: 'ACollapsePanel',
|
|
inheritAttrs: false,
|
|
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,
|
|
},
|
|
setup() {
|
|
return {
|
|
configProvider: inject('configProvider', defaultConfigProvider),
|
|
};
|
|
},
|
|
render() {
|
|
const { prefixCls: customizePrefixCls, showArrow = true } = this;
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
const prefixCls = getPrefixCls('collapse', customizePrefixCls);
|
|
const { class: className, ...restAttrs } = this.$attrs as any;
|
|
const collapsePanelClassName = {
|
|
[className]: className,
|
|
[`${prefixCls}-no-arrow`]: !showArrow,
|
|
};
|
|
|
|
const rcCollapePanelProps = {
|
|
...getOptionProps(this),
|
|
header: getComponent(this, 'header'),
|
|
prefixCls,
|
|
extra: getComponent(this, 'extra'),
|
|
class: collapsePanelClassName,
|
|
...restAttrs,
|
|
};
|
|
return <VcCollapse.Panel {...rcCollapePanelProps}>{getSlot(this)}</VcCollapse.Panel>;
|
|
},
|
|
});
|