Skip to content

Commit e2a7165

Browse files
committed
feat: update vc-dialog
1 parent 733c8fc commit e2a7165

File tree

6 files changed

+24
-31
lines changed

6 files changed

+24
-31
lines changed

components/_util/PortalWrapper.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import PropTypes from './vue-types';
22
import switchScrollingEffect from './switchScrollingEffect';
33
import setStyle from './setStyle';
44
import Portal from './Portal';
5+
import createRefHooks from './createRefHooks';
56

67
let openCount = 0;
78
const windowIsUndefined = !(
@@ -140,14 +141,7 @@ export default {
140141
<Portal
141142
getContainer={this.getDomContainer}
142143
children={children(childProps)}
143-
{...{
144-
directives: [
145-
{
146-
name: 'ant-ref',
147-
value: this.savePortal,
148-
},
149-
],
150-
}}
144+
{...createRefHooks(this.savePortal)}
151145
></Portal>
152146
);
153147
}

components/modal/ActionButton.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import PropTypes from '../_util/vue-types';
22
import Button from '../button';
33
import BaseMixin from '../_util/BaseMixin';
44
import buttonTypes from '../button/buttonTypes';
5+
import { getSlot } from '../_util/props-util';
56
const ButtonType = buttonTypes().type;
67
const ActionButtonProps = {
78
type: ButtonType,
@@ -64,10 +65,10 @@ export default {
6465
},
6566

6667
render() {
67-
const { type, $slots, loading, buttonProps } = this;
68+
const { type, loading, buttonProps } = this;
6869
return (
6970
<Button type={type} onClick={this.onClick} loading={loading} {...buttonProps}>
70-
{$slots.default}
71+
{getSlot(this)}
7172
</Button>
7273
);
7374
},

components/vc-dialog/Dialog.jsx

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { provide, Transition } from 'vue';
12
import { initDefaultProps } from '../_util/props-util';
23
import KeyCode from '../_util/KeyCode';
34
import contains from '../vc-util/Dom/contains';
@@ -66,12 +67,6 @@ export default {
6667
};
6768
},
6869

69-
provide() {
70-
return {
71-
dialogContext: this,
72-
};
73-
},
74-
7570
watch: {
7671
visible(val) {
7772
if (val) {
@@ -82,6 +77,9 @@ export default {
8277
});
8378
},
8479
},
80+
created() {
81+
provide('dialogContext', this);
82+
},
8583

8684
beforeMount() {
8785
this.inTransition = false;
@@ -295,12 +293,12 @@ export default {
295293
</LazyRenderBox>
296294
);
297295
const dialogTransitionProps = getTransitionProps(transitionName, {
298-
afterLeave: this.onAnimateLeave,
296+
onAfterLeave: this.onAnimateLeave,
299297
});
300298
return (
301-
<transition key="dialog" {...dialogTransitionProps}>
299+
<Transition key="dialog" {...dialogTransitionProps}>
302300
{visible || !this.destroyPopup ? dialogElement : null}
303-
</transition>
301+
</Transition>
304302
);
305303
},
306304
getZIndexStyle() {
@@ -334,9 +332,9 @@ export default {
334332
if (maskTransition) {
335333
const maskTransitionProps = getTransitionProps(maskTransition);
336334
maskElement = (
337-
<transition key="mask" {...maskTransitionProps}>
335+
<Transition key="mask" {...maskTransitionProps}>
338336
{maskElement}
339-
</transition>
337+
</Transition>
340338
);
341339
}
342340
}

components/vc-dialog/DialogWrap.jsx

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Dialog from './Dialog';
22
import getDialogPropTypes from './IDialogPropTypes';
3-
import { getListeners } from '../_util/props-util';
43
import Portal from '../_util/PortalWrapper';
4+
import { getSlot } from '../_util/props-util';
55
const IDialogPropTypes = getDialogPropTypes();
66
const DialogWrap = {
77
inheritAttrs: false,
@@ -12,12 +12,11 @@ const DialogWrap = {
1212

1313
render() {
1414
const { visible, getContainer, forceRender } = this.$props;
15-
const dialogProps = {
16-
props: this.$props,
17-
attrs: this.$attrs,
15+
let dialogProps = {
16+
...this.$props,
17+
...this.$attrs,
1818
ref: '_component',
1919
key: 'dialog',
20-
on: getListeners(this),
2120
};
2221
// 渲染在当前 dom 里;
2322
if (getContainer === false) {
@@ -26,7 +25,7 @@ const DialogWrap = {
2625
{...dialogProps}
2726
getOpenCount={() => 2} // 不对 body 做任何操作。。
2827
>
29-
{this.$slots.default}
28+
{getSlot(this)}
3029
</Dialog>
3130
);
3231
}
@@ -36,8 +35,8 @@ const DialogWrap = {
3635
forceRender={forceRender}
3736
getContainer={getContainer}
3837
children={childProps => {
39-
dialogProps.props = { ...dialogProps.props, ...childProps };
40-
return <Dialog {...dialogProps}>{this.$slots.default}</Dialog>;
38+
dialogProps = { ...dialogProps, ...childProps };
39+
return <Dialog {...dialogProps}>{getSlot(this)}</Dialog>;
4140
}}
4241
/>
4342
);

components/vc-dialog/IDialogPropTypes.js

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function IDialogPropTypes() {
4040
// https://github.com/ant-design/ant-design/issues/19771
4141
// https://github.com/react-component/dialog/issues/95
4242
focusTriggerAfterClose: PropTypes.bool,
43+
onClose: PropTypes.func,
4344
};
4445
}
4546

components/vc-dialog/LazyRenderBox.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import PropTypes from '../_util/vue-types';
2-
import { getListeners } from '../_util/props-util';
2+
import { getSlot } from '../_util/props-util';
33

44
const ILazyRenderBoxPropTypes = {
55
visible: PropTypes.bool,
@@ -10,6 +10,6 @@ const ILazyRenderBoxPropTypes = {
1010
export default {
1111
props: ILazyRenderBoxPropTypes,
1212
render() {
13-
return <div {...{ on: getListeners(this) }}>{this.$slots.default}</div>;
13+
return <div>{getSlot(this)}</div>;
1414
},
1515
};

0 commit comments

Comments
 (0)