revert: vc-xxx ts to js

pull/2936/head
tangjinzhou 2020-10-02 21:59:53 +08:00
parent b1c4013cee
commit aa07504e31
57 changed files with 1 additions and 123 deletions

View File

@ -1,98 +0,0 @@
import PropTypes from './vue-types';
export default {
props: {
autoMount: PropTypes.bool.def(true),
autoDestroy: PropTypes.bool.def(true),
visible: PropTypes.bool,
forceRender: PropTypes.bool.def(false),
parent: PropTypes.any,
getComponent: PropTypes.func.isRequired,
getContainer: PropTypes.func.isRequired,
children: PropTypes.func.isRequired,
},
mounted() {
if (this.autoMount) {
this.renderComponent();
}
},
updated() {
if (this.autoMount) {
this.renderComponent();
}
},
beforeUnmount() {
if (this.autoDestroy) {
this.removeContainer();
}
},
methods: {
removeContainer() {
if (this.container) {
this._component && this._component.$destroy();
this.container.parentNode.removeChild(this.container);
this.container = null;
this._component = null;
}
},
renderComponent(props = {}, ready) {
const { visible, forceRender, getContainer, parent } = this;
const self = this;
if (visible || parent._component || parent.$refs._component || forceRender) {
let el = this.componentEl;
if (!this.container) {
this.container = getContainer();
el = document.createElement('div');
this.componentEl = el;
this.container.appendChild(el);
}
// self.getComponent render render
const com = { component: self.getComponent(props) };
if (!this._component) {
this._component = new this.$root.constructor({
el,
parent: self,
data: {
_com: com,
},
mounted() {
this.$nextTick(() => {
if (ready) {
ready.call(self);
}
});
},
updated() {
this.$nextTick(() => {
if (ready) {
ready.call(self);
}
});
},
methods: {
setComponent(_com) {
this.$data._com = _com;
},
},
render() {
return this.$data._com.component;
},
});
} else {
this._component.setComponent(com);
}
}
},
},
render() {
return this.children({
renderComponent: this.renderComponent,
removeContainer: this.removeContainer,
});
},
};

View File

@ -1,24 +0,0 @@
export function antPortal(Vue) {
return Vue.directive('ant-portal', {
inserted(el, binding) {
const { value } = binding;
const parentNode = typeof value === 'function' ? value(el) : value;
if (parentNode !== el.parentNode) {
parentNode.appendChild(el);
}
},
componentUpdated(el, binding) {
const { value } = binding;
const parentNode = typeof value === 'function' ? value(el) : value;
if (parentNode !== el.parentNode) {
parentNode.appendChild(el);
}
},
});
}
export default {
install: Vue => {
antPortal(Vue);
},
};

View File

@ -3,7 +3,7 @@ import PropTypes from '../_util/vue-types';
import { alignElement, alignPoint } from 'dom-align';
import addEventListener from '../vc-util/Dom/addEventListener';
import { isWindow, buffer, isSamePoint, isSimilarValue, restoreFocus } from './util';
import { cloneElement } from '../_util/vnode.js';
import { cloneElement } from '../_util/vnode';
import clonedeep from 'lodash-es/cloneDeep';
import { getSlot, findDOMNode } from '../_util/props-util';