mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.4 KiB
59 lines
1.4 KiB
2 years ago
|
<script lang="ts" setup>
|
||
|
import { onKeyDown } from '@vueuse/core'
|
||
2 years ago
|
import type { TeleportProps } from '@vue/runtime-core'
|
||
2 years ago
|
import { useVModel, watch } from '#imports'
|
||
|
|
||
|
interface Props {
|
||
|
modelValue?: any
|
||
2 years ago
|
/** if true, overlay will use `position: absolute` instead of `position: fixed` */
|
||
|
inline?: boolean
|
||
|
/** target to teleport to */
|
||
|
target?: TeleportProps['to']
|
||
|
teleportDisabled?: TeleportProps['disabled']
|
||
|
transition?: boolean
|
||
2 years ago
|
}
|
||
|
|
||
|
interface Emits {
|
||
|
(event: 'update:modelValue', value: boolean): void
|
||
|
(event: 'close'): void
|
||
|
(event: 'open'): void
|
||
|
}
|
||
|
|
||
2 years ago
|
const { transition = true, teleportDisabled = false, inline = false, target, ...rest } = defineProps<Props>()
|
||
2 years ago
|
|
||
|
const emits = defineEmits<Emits>()
|
||
|
|
||
2 years ago
|
const vModel = useVModel(rest, 'modelValue', emits)
|
||
2 years ago
|
|
||
|
onKeyDown('Escape', () => {
|
||
|
vModel.value = false
|
||
|
})
|
||
|
|
||
|
watch(vModel, (nextVal) => {
|
||
|
if (nextVal) emits('open')
|
||
|
else emits('close')
|
||
|
})
|
||
|
</script>
|
||
|
|
||
2 years ago
|
<script lang="ts">
|
||
|
export default {
|
||
|
inheritAttrs: false,
|
||
|
}
|
||
|
</script>
|
||
|
|
||
2 years ago
|
<template>
|
||
2 years ago
|
<teleport :disabled="teleportDisabled || (inline && !target)" :to="target || 'body'">
|
||
2 years ago
|
<div
|
||
2 years ago
|
v-bind="$attrs"
|
||
|
:class="[
|
||
|
vModel ? 'opacity-100' : 'opacity-0 pointer-events-none',
|
||
|
inline ? 'absolute' : 'fixed',
|
||
|
transition ? 'transition-opacity duration-200 ease-in-out' : '',
|
||
|
]"
|
||
|
class="z-100 top-0 left-0 bottom-0 right-0 bg-gray-700/75"
|
||
2 years ago
|
>
|
||
|
<slot :is-open="vModel" />
|
||
|
</div>
|
||
|
</teleport>
|
||
|
</template>
|