33 v-if =" context"
44 :key =" id"
55 v-model =" modal"
6+ v-bind =" context.attrs"
67 class =" dialog"
78 :title =" context.title"
89 :size =" context.size"
910 :centered =" context.centered"
1011 :dismissable =" context.dismissable"
1112 :no-close-on-backdrop =" context.noCloseOnBackdrop"
13+ @show =" onModalShow"
14+ @hide =" onModalHide"
1215 @close =" onCancel" >
1316 <template #header >
1417 <Heading
3235 :cancel-color =" context.cancel.color"
3336 :cancel-variant =" context.cancel.variant"
3437 :cancel-text =" context.cancel.text"
38+ :cancel-attrs =" context.cancel.attrs"
3539 :confirm-class =" context.confirm.className"
3640 :confirm-visible =" context.confirm.visible"
3741 :confirm-color =" context.confirm.color"
3842 :confirm-variant =" context.confirm.variant"
3943 :confirm-text =" context.confirm.text"
44+ :confirm-attrs =" context.confirm.attrs"
4045 @confirm =" onConfirm"
4146 @cancel =" onCancel" />
4247 </template >
@@ -50,40 +55,52 @@ import Heading from '../heading/Heading.vue'
5055import DialogFooter from ' ./DialogFooter.vue'
5156import type { DialogContext } from ' .'
5257import { vPMd } from ' ../markdown'
58+ import { until } from ' @vueuse/core'
5359
54- const id = ref <symbol >()
55- const modal = ref (false )
56- const context = ref <DialogContext >()
60+ const id = ref <symbol >()
61+ const modal = ref (false )
62+ const processing = ref (false )
63+ const context = ref <DialogContext >()
5764
58- function show (options : DialogContext ) {
65+ async function show (options : DialogContext ) {
5966 id .value = Symbol (' DialogId' )
6067 context .value = options
6168
62- nextTick (() => {
63- modal . value = true
64- })
65- }
69+ await nextTick ()
70+
71+ modal . value = true
72+ processing . value = true
6673
67- function hide () {
68- modal . value = false
74+ // Wait animation done
75+ await until ( processing ). toBe ( false )
6976}
7077
71- function onConfirm () {
72- hide ()
78+ async function hide () {
79+ modal .value = false
80+ processing .value = true
7381
7482 // Wait animation done
75- setTimeout (() => {
76- context .value .onConfirm ()
77- }, 150 )
83+ await until (processing ).toBe (false )
7884}
7985
80- function onCancel () {
81- hide ()
86+ async function onConfirm () {
87+ await hide ()
8288
83- // Wait animation done
84- setTimeout (() => {
85- context .value .onCancel ()
86- }, 150 )
89+ context .value .onConfirm ()
90+ }
91+
92+ async function onCancel () {
93+ await hide ()
94+
95+ context .value .onCancel ()
96+ }
97+
98+ function onModalHide () {
99+ processing .value = false
100+ }
101+
102+ function onModalShow () {
103+ processing .value = false
87104}
88105
89106defineExpose ({
0 commit comments