refactor: use type directly from drawer in use-adjusted-to

This commit is contained in:
07akioni 2021-03-17 18:14:54 +08:00
parent 5f1b1838cb
commit 7068e5b35f

View File

@ -1,21 +1,18 @@
import { useMemo } from 'vooks'
import { ComponentPublicInstance, ComputedRef, inject } from 'vue'
import type { ModalBodyInjection } from '../../modal/src/BodyWrapper'
import type { DrawerBodyInjection } from '../../drawer/src/DrawerBodyWrapper'
interface UseAdjustedToProps {
to?: string | HTMLElement
[key: string]: unknown
}
interface DrawerInjection {
bodyRef: HTMLElement
}
export function useAdjustedTo (
props: UseAdjustedToProps
): ComputedRef<HTMLElement | string> {
const modal = inject<ModalBodyInjection | null>('NModalBody', null)
const drawer = inject<DrawerInjection | null>('NDrawerBody', null)
const drawer = inject<DrawerBodyInjection | null>('NDrawerBody', null)
return useMemo(() => {
const { to } = props
if (to !== undefined) return to