diff --git a/src/_base/index.js b/src/_base/index.js index 7ddf0a49e..9e44d49be 100644 --- a/src/_base/index.js +++ b/src/_base/index.js @@ -1,2 +1,4 @@ export { default as WindowResizeObserver } from './window-resize-observer' export { default as ResizeObserver } from './resize-observer' +export { default as Teleport } from './teleport' +export { default as LazyTeleport } from './lazy-teleport' diff --git a/src/_base/teleport/index.js b/src/_base/teleport/index.js new file mode 100644 index 000000000..db1fa16e6 --- /dev/null +++ b/src/_base/teleport/index.js @@ -0,0 +1 @@ +export { default } from './src/Teleport.vue' diff --git a/src/_base/teleport/src/Teleport.vue b/src/_base/teleport/src/Teleport.vue new file mode 100644 index 000000000..ce119c461 --- /dev/null +++ b/src/_base/teleport/src/Teleport.vue @@ -0,0 +1,34 @@ + + + diff --git a/src/_deprecated/NimbusServiceLayout/src/SiderMenu.vue b/src/_deprecated/NimbusServiceLayout/src/SiderMenu.vue index 1cf785050..58c3230f6 100644 --- a/src/_deprecated/NimbusServiceLayout/src/SiderMenu.vue +++ b/src/_deprecated/NimbusServiceLayout/src/SiderMenu.vue @@ -35,8 +35,6 @@ export default { children: item.childItems ? this.createItems(item.childItems) : undefined, group: item.group, onClick: !(item.group && item.childItems) ? () => { - console.log('item click') - console.log(this.$router, item.path) if (this.$router && item.path) { Promise.resolve( this.$router.push(item.path) diff --git a/src/_utils/deprecated/installPropsUnsafeTransition.js b/src/_utils/deprecated/installPropsUnsafeTransition.js deleted file mode 100644 index 72c255d55..000000000 --- a/src/_utils/deprecated/installPropsUnsafeTransition.js +++ /dev/null @@ -1,15 +0,0 @@ -export default function (Vue) { - if (!Vue.options.components.PropsUnsafeTransition) { - const PropsUnsafeTransition = { ...(Vue.options.components.Transition) } - PropsUnsafeTransition.name = 'PropsUnsafeTransition' - PropsUnsafeTransition.props = { - name: { - validator: () => true - }, - appear: { - validator: () => true - } - } - Vue.component(PropsUnsafeTransition.name, PropsUnsafeTransition) - } -} diff --git a/src/_utils/deprecated/vNodeUtils.js b/src/_utils/deprecated/vNodeUtils.js deleted file mode 100644 index f2b74d4f0..000000000 --- a/src/_utils/deprecated/vNodeUtils.js +++ /dev/null @@ -1,33 +0,0 @@ -function getComponentNameOf (vNode) { - /** - * Functional component - */ - if (vNode.fnOptions && vNode.fnOptions.name) { - return vNode.fnOptions.name - } - if ( - vNode.componentOptions && - vNode.componentOptions.Ctor && - vNode.componentOptions.Ctor.extendOptions && - vNode.componentOptions.Ctor.extendOptions.name - ) { - return vNode.componentOptions.Ctor.extendOptions.name - } - return null -} - -function getDefaultSlotOf (componentInstance) { - return getSlotOf(componentInstance, 'default') -} - -function getSlotOf (componentInstance, slotName) { - if (componentInstance.$slots[slotName]) return componentInstance.$slots[slotName] || [] - if (componentInstance.$slots[slotName]) return componentInstance.$slots[slotName]() || [] - return [] -} - -export { - getSlotOf, - getDefaultSlotOf, - getComponentNameOf -} diff --git a/src/_utils/naive/index.js b/src/_utils/naive/index.js index cc0d89afb..a5c1c64a4 100644 --- a/src/_utils/naive/index.js +++ b/src/_utils/naive/index.js @@ -1 +1,2 @@ -export { warn } from './warn' +export { warn, warnOnce } from './warn' +export { debug } from './debug' diff --git a/src/back-top/src/BackTop.vue b/src/back-top/src/BackTop.vue index 1b1dcd16a..2667fdf5b 100644 --- a/src/back-top/src/BackTop.vue +++ b/src/back-top/src/BackTop.vue @@ -88,7 +88,7 @@ export default { }, to: { type: [String, Object], - default: 'body' + default: undefined }, visibilityHeight: { type: Number, diff --git a/src/dialog/src/DialogProvider.js b/src/dialog/src/DialogProvider.js index 0a8e07926..a6b4fa96c 100644 --- a/src/dialog/src/DialogProvider.js +++ b/src/dialog/src/DialogProvider.js @@ -7,7 +7,7 @@ export default { props: { to: { type: [String, Object], - default: 'body' + default: undefined } }, provide () { diff --git a/src/drawer/src/Drawer.vue b/src/drawer/src/Drawer.vue index c55438172..c802236f6 100644 --- a/src/drawer/src/Drawer.vue +++ b/src/drawer/src/Drawer.vue @@ -109,7 +109,7 @@ export default { }, to: { type: [String, Object], - default: 'body' + default: undefined }, displayDirective: { validator (value) { diff --git a/src/loading-bar/src/LoadingBarProvider.js b/src/loading-bar/src/LoadingBarProvider.js index b8f993285..540c910a9 100644 --- a/src/loading-bar/src/LoadingBarProvider.js +++ b/src/loading-bar/src/LoadingBarProvider.js @@ -1,5 +1,6 @@ -import { Fragment, Teleport, h } from 'vue' +import { Fragment, h, ref } from 'vue' import { useIsMounted } from '../../_utils/composition' +import { Teleport } from '../../_base' import NLoadingBar from './LoadingBar.vue' export default { @@ -17,49 +18,50 @@ export default { props: { to: { type: [String, Object], - default: 'body' + default: undefined } }, setup () { return { - isMounted: useIsMounted() + isMounted: useIsMounted(), + loadingBarRef: ref(null) } }, methods: { start () { if (this.isMounted) { - this.$refs.loadingBar.start() + this.loadingBarRef.start() } else { this.$nextTick(() => { - this.$refs.loadingBar.start() + this.loadingBarRef.start() }) } }, error () { if (this.isMounted) { - this.$refs.loadingBar.error() + this.loadingBarRef.error() } else { this.$nextTick(() => { - this.$refs.loadingBar.error() + this.loadingBarRef.error() }) } }, finish () { if (this.isMounted) { - this.$refs.loadingBar.finish() + this.loadingBarRef.finish() } else { this.$nextTick(() => { - this.$refs.loadingBar.finish() + this.loadingBarRef.finish() }) } }, update (options) { const { percent } = options if (this.isMounted) { - this.$refs.loadingBar.update(percent) + this.loadingBarRef.update(percent) } else { this.$nextTick(() => { - this.$refs.loadingBar.update(percent) + this.loadingBarRef.update(percent) }) } } @@ -68,11 +70,11 @@ export default { return h(Fragment, null, [ h(Teleport, { to: this.to - }, [ - h(NLoadingBar, { - ref: 'loadingBar' + }, { + default: () => h(NLoadingBar, { + ref: 'loadingBarRef' }) - ]), + }), this.$slots.default() ]) } diff --git a/src/message/src/MessageProvider.js b/src/message/src/MessageProvider.js index 11180c3b1..d4879b299 100644 --- a/src/message/src/MessageProvider.js +++ b/src/message/src/MessageProvider.js @@ -1,5 +1,6 @@ -import { Fragment, Teleport, ref, h, reactive } from 'vue' +import { Fragment, ref, h, reactive } from 'vue' import { createId, omit } from '../../_utils/vue' +import { Teleport } from '../../_base' import MessageEnvironment from './MessageEnvironment.js' export default { @@ -7,7 +8,7 @@ export default { props: { to: { type: [String, Object], - default: 'body' + default: undefined } }, provide () { diff --git a/src/modal/src/Modal.js b/src/modal/src/Modal.js index ac91dd700..c86651250 100644 --- a/src/modal/src/Modal.js +++ b/src/modal/src/Modal.js @@ -39,7 +39,7 @@ export default { }, to: { type: [String, Object], - default: 'body' + default: undefined }, displayDirective: { validator (value) { diff --git a/src/notification/src/NotificationProvider.js b/src/notification/src/NotificationProvider.js index 2d98e4927..b8d786d98 100644 --- a/src/notification/src/NotificationProvider.js +++ b/src/notification/src/NotificationProvider.js @@ -1,5 +1,6 @@ -import { Fragment, h, Teleport, reactive, ref } from 'vue' +import { Fragment, h, reactive, ref } from 'vue' import { createId, omit } from '../../_utils/vue' +import { Teleport } from '../../_base' import NotificationContainer from './NotificationContainer.vue' import NotificationEnvironment from './NotificationEnvironment' @@ -19,7 +20,7 @@ export default { props: { to: { type: [String, Object], - default: 'body' + default: undefined }, scrollable: { type: Boolean, @@ -70,8 +71,8 @@ export default { return h(Fragment, null, [ h(Teleport, { to: this.to - }, [ - this.notificationList.length ? h(NotificationContainer, { + }, { + default: () => this.notificationList.length ? h(NotificationContainer, { scrollable: this.scrollable }, { default: () => { @@ -84,7 +85,7 @@ export default { ) } }) : null - ]), + }), this.$slots.default() ]) }