7
7
v-model =" toast.options.value"
8
8
:title =" toast.content.title"
9
9
:body =" toast.content.body"
10
- :component =" toast.content.vnode "
10
+ :component =" toast.content.body "
11
11
:variant =" toast.options.variant"
12
12
@destroyed =" handleDestroy"
13
13
>
14
14
</b-toast >
15
15
</div >
16
16
</template >
17
17
18
- <script lang="ts">
19
- import {
20
- computed ,
21
- defineComponent ,
22
- getCurrentInstance ,
23
- nextTick ,
24
- onMounted ,
25
- PropType ,
26
- reactive ,
27
- Ref ,
28
- ref ,
29
- toRefs ,
30
- ToRefs ,
31
- watch ,
32
- } from ' vue'
33
- import {ToastInstance } from ' ./plugin'
34
- import type {ContainerPosition } from ' ../../types'
18
+ <script setup lang="ts">
19
+ // import type {BToasterProps} from '@/types/components'
20
+ import {computed } from ' vue'
21
+ import type {ContainerPosition } from ' @/types'
22
+ import type {ToastInstance } from ' @/components/BToast/plugin'
23
+
24
+ interface BToasterProps {
25
+ position? : ContainerPosition
26
+ instance: ToastInstance
27
+ // appendToast?: boolean
28
+ }
29
+
30
+ const props = withDefaults (defineProps <BToasterProps >(), {
31
+ position: ' top-right' ,
32
+ })
35
33
36
34
const toastPositions = {
37
35
' top-left' : ' top-0 start-0' ,
@@ -45,26 +43,10 @@ const toastPositions = {
45
43
' bottom-right' : ' bottom-0 end-0' ,
46
44
}
47
45
48
- export default defineComponent ({
49
- name: ' BToaster' ,
50
- props: {
51
- position: {type: String as PropType <ContainerPosition >, default: ' top-right' },
52
- instance: {type: Object as PropType <ToastInstance >},
53
- // appendToast: {type: Boolean, default: false},
54
- },
46
+ const positionClass = computed (() => toastPositions [props .position ])
55
47
56
- setup(props , {emit }) {
57
- const positionClass = computed (() => toastPositions [props .position ])
58
-
59
- const handleDestroy = (id : string ) => {
60
- // we made want to disable reactivity for deletes. Future Note
61
- props .instance ?.remove (id )
62
- }
63
- return {
64
- positionClass ,
65
- handleDestroy ,
66
- }
67
- },
68
- computed: {},
69
- })
48
+ const handleDestroy = (id : string ) => {
49
+ // we made want to disable reactivity for deletes. Future Note
50
+ props .instance ?.remove (id )
51
+ }
70
52
</script >
0 commit comments