chore: use useConfigInject
parent
b8220bb4a3
commit
6596bd6255
|
@ -15,7 +15,7 @@ import classnames from '../_util/classNames';
|
||||||
import VcDrawer from '../vc-drawer';
|
import VcDrawer from '../vc-drawer';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined';
|
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined';
|
||||||
import { defaultConfigProvider } from '../config-provider';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
import { tuple, withInstall } from '../_util/type';
|
import { tuple, withInstall } from '../_util/type';
|
||||||
import omit from '../_util/omit';
|
import omit from '../_util/omit';
|
||||||
|
|
||||||
|
@ -80,8 +80,8 @@ const Drawer = defineComponent({
|
||||||
const preVisible = ref(props.visible);
|
const preVisible = ref(props.visible);
|
||||||
const destroyClose = ref(false);
|
const destroyClose = ref(false);
|
||||||
const vcDrawer = ref(null);
|
const vcDrawer = ref(null);
|
||||||
const configProvider = inject('configProvider', defaultConfigProvider);
|
|
||||||
const parentDrawerOpts = inject('parentDrawerOpts', null);
|
const parentDrawerOpts = inject('parentDrawerOpts', null);
|
||||||
|
const { prefixCls } = useConfigInject('drawer', props);
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
provide('parentDrawerOpts', {
|
provide('parentDrawerOpts', {
|
||||||
|
@ -285,20 +285,10 @@ const Drawer = defineComponent({
|
||||||
};
|
};
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const {
|
const { width, height, visible, placement, mask, className, ...rest } = props;
|
||||||
prefixCls: customizePrefixCls,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
visible,
|
|
||||||
placement,
|
|
||||||
mask,
|
|
||||||
className,
|
|
||||||
...rest
|
|
||||||
} = props;
|
|
||||||
const offsetStyle = mask ? getOffsetStyle() : {};
|
const offsetStyle = mask ? getOffsetStyle() : {};
|
||||||
const haveMask = mask ? '' : 'no-mask';
|
const haveMask = mask ? '' : 'no-mask';
|
||||||
const getPrefixCls = configProvider.getPrefixCls;
|
|
||||||
const prefixCls = getPrefixCls('drawer', customizePrefixCls);
|
|
||||||
const vcDrawerProps: any = {
|
const vcDrawerProps: any = {
|
||||||
...attrs,
|
...attrs,
|
||||||
...omit(rest, [
|
...omit(rest, [
|
||||||
|
@ -316,7 +306,7 @@ const Drawer = defineComponent({
|
||||||
onClose: close,
|
onClose: close,
|
||||||
afterVisibleChange,
|
afterVisibleChange,
|
||||||
handler: false,
|
handler: false,
|
||||||
prefixCls,
|
prefixCls: prefixCls.value,
|
||||||
open: visible,
|
open: visible,
|
||||||
showMask: mask,
|
showMask: mask,
|
||||||
placement,
|
placement,
|
||||||
|
@ -327,7 +317,7 @@ const Drawer = defineComponent({
|
||||||
style: getRcDrawerStyle(),
|
style: getRcDrawerStyle(),
|
||||||
ref: vcDrawer,
|
ref: vcDrawer,
|
||||||
};
|
};
|
||||||
return <VcDrawer {...vcDrawerProps}>{renderBody(prefixCls)}</VcDrawer>;
|
return <VcDrawer {...vcDrawerProps}>{renderBody(prefixCls.value)}</VcDrawer>;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue