File tree 2 files changed +18
-4
lines changed
2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import theme from '#build/ui/toast'
7
7
import { extendDevtoolsMeta } from ' ../composables/extendDevtoolsMeta'
8
8
import { tv } from ' ../utils/tv'
9
9
import type { AvatarProps , ButtonProps } from ' ../types'
10
+ import type { StringOrVNode } from ' ../types/utils'
10
11
11
12
const appConfigToast = _appConfig as AppConfig & { ui: { toast: Partial <typeof theme > } }
12
13
@@ -20,8 +21,8 @@ export interface ToastProps extends Pick<ToastRootProps, 'defaultOpen' | 'open'
20
21
* @defaultValue 'li'
21
22
*/
22
23
as? : any
23
- title? : string
24
- description? : string
24
+ title? : StringOrVNode
25
+ description? : StringOrVNode
25
26
icon? : string
26
27
avatar? : AvatarProps
27
28
color? : ToastVariants [' color' ]
@@ -124,12 +125,20 @@ defineExpose({
124
125
<div :class =" ui.wrapper({ class: props.ui?.wrapper })" >
125
126
<ToastTitle v-if =" title || !!slots.title" :class =" ui.title({ class: props.ui?.title })" >
126
127
<slot name =" title" >
127
- {{ title }}
128
+ <component :is =" title()" v-if =" typeof title === 'function'" />
129
+ <component :is =" title" v-else-if =" typeof title === 'object'" />
130
+ <template v-else >
131
+ {{ title }}
132
+ </template >
128
133
</slot >
129
134
</ToastTitle >
130
135
<ToastDescription v-if =" description || !!slots.description" :class =" ui.description({ class: props.ui?.description })" >
131
136
<slot name =" description" >
132
- {{ description }}
137
+ <component :is =" description()" v-if =" typeof description === 'function'" />
138
+ <component :is =" description" v-else-if =" typeof description === 'object'" />
139
+ <template v-else >
140
+ {{ description }}
141
+ </template >
133
142
</slot >
134
143
</ToastDescription >
135
144
Original file line number Diff line number Diff line change @@ -33,3 +33,8 @@ export type SelectItemKey<T> = T extends Record<string, any> ? keyof T : string
33
33
export type SelectModelValueEmits < T , V , M extends boolean = false , DV = T > = {
34
34
'update:modelValue' : [ payload : SelectModelValue < T , V , M , DV > ]
35
35
}
36
+
37
+ export type StringOrVNode =
38
+ | string
39
+ | VNode
40
+ | ( ( ) => VNode )
You can’t perform that action at this time.
0 commit comments