File tree Expand file tree Collapse file tree 1 file changed +26
-33
lines changed Expand file tree Collapse file tree 1 file changed +26
-33
lines changed Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
- import { useTemplateRef , Component as VueComponent , watch } from ' vue'
2
+ import { Component as VueComponent } from ' vue'
3
3
4
- const props = defineProps <{
4
+ defineProps <{
5
5
eoa? : string
6
6
modalClose? : () => void
7
7
isVisible: boolean
8
8
modalContent: VueComponent
9
9
attrs: { [key : string ]: any }
10
10
}>()
11
-
12
- const dialog = useTemplateRef (' dialog' )
13
-
14
- watch (props , () => {
15
- if (props .isVisible ) {
16
- dialog .value ?.showModal ()
17
- } else {
18
- dialog .value ?.close ()
19
- }
20
- })
21
11
</script >
22
12
23
13
<style >
@@ -43,25 +33,28 @@ html:has(dialog[open]) {
43
33
</style >
44
34
45
35
<template >
46
- <dialog
47
- ref =" dialog"
48
- class =" fixed inset-0 flex items-center justify-center overflow-y-auto backdrop:bg-black/60"
49
- :class =" { hidden: !isVisible }"
50
- >
51
- <Transition >
52
- <div class =" relative m-auto w-full py-4" >
53
- <component
54
- :eoa =" eoa"
55
- :modalClose =" modalClose"
56
- v-show =" isVisible"
57
- :is =" modalContent"
58
- v-bind =" attrs"
59
- >
60
- <template #after :description >
61
- <slot name =" after:description" />
62
- </template >
63
- </component >
64
- </div >
65
- </Transition >
66
- </dialog >
36
+ <Teleport to =" body" >
37
+ <dialog
38
+ class =" fixed inset-0 flex items-center justify-center overflow-y-auto"
39
+ v-show =" isVisible"
40
+ :open =" isVisible"
41
+ >
42
+ <div class =" fixed inset-0 bg-black/60" ></div >
43
+ <Transition >
44
+ <div class =" relative m-auto w-full py-4" >
45
+ <component
46
+ :eoa =" eoa"
47
+ :modalClose =" modalClose"
48
+ v-show =" isVisible"
49
+ :is =" modalContent"
50
+ v-bind =" attrs"
51
+ >
52
+ <template #after :description >
53
+ <slot name =" after:description" />
54
+ </template >
55
+ </component >
56
+ </div >
57
+ </Transition >
58
+ </dialog >
59
+ </Teleport >
67
60
</template >
You can’t perform that action at this time.
0 commit comments