feat: update vc-dialog

pull/2376/head
tanjinzhou 2020-06-15 18:55:12 +08:00
parent 733c8fce8e
commit e2a7165508
6 changed files with 24 additions and 31 deletions

View File

@ -2,6 +2,7 @@ import PropTypes from './vue-types';
import switchScrollingEffect from './switchScrollingEffect'; import switchScrollingEffect from './switchScrollingEffect';
import setStyle from './setStyle'; import setStyle from './setStyle';
import Portal from './Portal'; import Portal from './Portal';
import createRefHooks from './createRefHooks';
let openCount = 0; let openCount = 0;
const windowIsUndefined = !( const windowIsUndefined = !(
@ -140,14 +141,7 @@ export default {
<Portal <Portal
getContainer={this.getDomContainer} getContainer={this.getDomContainer}
children={children(childProps)} children={children(childProps)}
{...{ {...createRefHooks(this.savePortal)}
directives: [
{
name: 'ant-ref',
value: this.savePortal,
},
],
}}
></Portal> ></Portal>
); );
} }

View File

@ -2,6 +2,7 @@ import PropTypes from '../_util/vue-types';
import Button from '../button'; import Button from '../button';
import BaseMixin from '../_util/BaseMixin'; import BaseMixin from '../_util/BaseMixin';
import buttonTypes from '../button/buttonTypes'; import buttonTypes from '../button/buttonTypes';
import { getSlot } from '../_util/props-util';
const ButtonType = buttonTypes().type; const ButtonType = buttonTypes().type;
const ActionButtonProps = { const ActionButtonProps = {
type: ButtonType, type: ButtonType,
@ -64,10 +65,10 @@ export default {
}, },
render() { render() {
const { type, $slots, loading, buttonProps } = this; const { type, loading, buttonProps } = this;
return ( return (
<Button type={type} onClick={this.onClick} loading={loading} {...buttonProps}> <Button type={type} onClick={this.onClick} loading={loading} {...buttonProps}>
{$slots.default} {getSlot(this)}
</Button> </Button>
); );
}, },

View File

@ -1,3 +1,4 @@
import { provide, Transition } from 'vue';
import { initDefaultProps } from '../_util/props-util'; import { initDefaultProps } from '../_util/props-util';
import KeyCode from '../_util/KeyCode'; import KeyCode from '../_util/KeyCode';
import contains from '../vc-util/Dom/contains'; import contains from '../vc-util/Dom/contains';
@ -66,12 +67,6 @@ export default {
}; };
}, },
provide() {
return {
dialogContext: this,
};
},
watch: { watch: {
visible(val) { visible(val) {
if (val) { if (val) {
@ -82,6 +77,9 @@ export default {
}); });
}, },
}, },
created() {
provide('dialogContext', this);
},
beforeMount() { beforeMount() {
this.inTransition = false; this.inTransition = false;
@ -295,12 +293,12 @@ export default {
</LazyRenderBox> </LazyRenderBox>
); );
const dialogTransitionProps = getTransitionProps(transitionName, { const dialogTransitionProps = getTransitionProps(transitionName, {
afterLeave: this.onAnimateLeave, onAfterLeave: this.onAnimateLeave,
}); });
return ( return (
<transition key="dialog" {...dialogTransitionProps}> <Transition key="dialog" {...dialogTransitionProps}>
{visible || !this.destroyPopup ? dialogElement : null} {visible || !this.destroyPopup ? dialogElement : null}
</transition> </Transition>
); );
}, },
getZIndexStyle() { getZIndexStyle() {
@ -334,9 +332,9 @@ export default {
if (maskTransition) { if (maskTransition) {
const maskTransitionProps = getTransitionProps(maskTransition); const maskTransitionProps = getTransitionProps(maskTransition);
maskElement = ( maskElement = (
<transition key="mask" {...maskTransitionProps}> <Transition key="mask" {...maskTransitionProps}>
{maskElement} {maskElement}
</transition> </Transition>
); );
} }
} }

View File

@ -1,7 +1,7 @@
import Dialog from './Dialog'; import Dialog from './Dialog';
import getDialogPropTypes from './IDialogPropTypes'; import getDialogPropTypes from './IDialogPropTypes';
import { getListeners } from '../_util/props-util';
import Portal from '../_util/PortalWrapper'; import Portal from '../_util/PortalWrapper';
import { getSlot } from '../_util/props-util';
const IDialogPropTypes = getDialogPropTypes(); const IDialogPropTypes = getDialogPropTypes();
const DialogWrap = { const DialogWrap = {
inheritAttrs: false, inheritAttrs: false,
@ -12,12 +12,11 @@ const DialogWrap = {
render() { render() {
const { visible, getContainer, forceRender } = this.$props; const { visible, getContainer, forceRender } = this.$props;
const dialogProps = { let dialogProps = {
props: this.$props, ...this.$props,
attrs: this.$attrs, ...this.$attrs,
ref: '_component', ref: '_component',
key: 'dialog', key: 'dialog',
on: getListeners(this),
}; };
// dom // dom
if (getContainer === false) { if (getContainer === false) {
@ -26,7 +25,7 @@ const DialogWrap = {
{...dialogProps} {...dialogProps}
getOpenCount={() => 2} // body getOpenCount={() => 2} // body
> >
{this.$slots.default} {getSlot(this)}
</Dialog> </Dialog>
); );
} }
@ -36,8 +35,8 @@ const DialogWrap = {
forceRender={forceRender} forceRender={forceRender}
getContainer={getContainer} getContainer={getContainer}
children={childProps => { children={childProps => {
dialogProps.props = { ...dialogProps.props, ...childProps }; dialogProps = { ...dialogProps, ...childProps };
return <Dialog {...dialogProps}>{this.$slots.default}</Dialog>; return <Dialog {...dialogProps}>{getSlot(this)}</Dialog>;
}} }}
/> />
); );

View File

@ -40,6 +40,7 @@ function IDialogPropTypes() {
// https://github.com/ant-design/ant-design/issues/19771 // https://github.com/ant-design/ant-design/issues/19771
// https://github.com/react-component/dialog/issues/95 // https://github.com/react-component/dialog/issues/95
focusTriggerAfterClose: PropTypes.bool, focusTriggerAfterClose: PropTypes.bool,
onClose: PropTypes.func,
}; };
} }

View File

@ -1,5 +1,5 @@
import PropTypes from '../_util/vue-types'; import PropTypes from '../_util/vue-types';
import { getListeners } from '../_util/props-util'; import { getSlot } from '../_util/props-util';
const ILazyRenderBoxPropTypes = { const ILazyRenderBoxPropTypes = {
visible: PropTypes.bool, visible: PropTypes.bool,
@ -10,6 +10,6 @@ const ILazyRenderBoxPropTypes = {
export default { export default {
props: ILazyRenderBoxPropTypes, props: ILazyRenderBoxPropTypes,
render() { render() {
return <div {...{ on: getListeners(this) }}>{this.$slots.default}</div>; return <div>{getSlot(this)}</div>;
}, },
}; };