11<script lang="ts">
22import type { AppConfig } from ' @nuxt/schema'
3- import type { UIMessage } from ' ai'
3+ import type { UIDataTypes , UIMessage , UITools } from ' ai'
44import theme from ' #build/ui/chat-message'
55import type { AvatarProps , ButtonProps , IconProps } from ' ../types'
66import type { ComponentConfig } from ' ../types/tv'
77
88type ChatMessage = ComponentConfig <typeof theme , AppConfig , ' chatMessage' >
99
10- export interface ChatMessageProps extends UIMessage {
10+ export interface ChatMessageProps <METADATA = unknown , DATA_PARTS extends UIDataTypes = UIDataTypes , TOOLS extends UITools = UITools >
11+ extends UIMessage <METADATA , DATA_PARTS , TOOLS > {
1112 /**
1213 * The element or component this component should render as.
1314 * @defaultValue 'article'
@@ -31,7 +32,7 @@ export interface ChatMessageProps extends UIMessage {
3132 * The `label` will be used in a tooltip.
3233 * `{ size: 'xs', color: 'neutral', variant: 'ghost' }`{lang="ts-type"}
3334 */
34- actions? : (Omit <ButtonProps , ' onClick' > & { onClick? : (e : MouseEvent , message : UIMessage ) => void })[]
35+ actions? : (Omit <ButtonProps , ' onClick' > & { onClick? : (e : MouseEvent , message : UIMessage < METADATA , DATA_PARTS , TOOLS > ) => void })[]
3536 /**
3637 * Render the message in a compact style.
3738 * This is done automatically when used inside a `UChatPalette`{lang="ts-type"}.
@@ -47,14 +48,14 @@ export interface ChatMessageProps extends UIMessage {
4748 ui? : ChatMessage [' slots' ]
4849}
4950
50- export interface ChatMessageSlots {
51- leading(props : { avatar: ChatMessageProps [' avatar' ], ui: ChatMessage [' ui' ] }): any
52- content(props : ChatMessageProps ): any
53- actions(props : { actions: ChatMessageProps [' actions' ] }): any
51+ export interface ChatMessageSlots < METADATA = unknown , DATA_PARTS extends UIDataTypes = UIDataTypes , TOOLS extends UITools = UITools > {
52+ leading(props : { avatar: ChatMessageProps < METADATA , DATA_PARTS , TOOLS > [' avatar' ], ui: ChatMessage [' ui' ] }): any
53+ content(props : ChatMessageProps < METADATA , DATA_PARTS , TOOLS > ): any
54+ actions(props : { actions: ChatMessageProps < METADATA , DATA_PARTS , TOOLS > [' actions' ] }): any
5455}
5556 </script >
5657
57- <script setup lang="ts">
58+ <script setup lang="ts" generic = " METADATA = unknown , DATA_PARTS extends UIDataTypes = UIDataTypes , TOOLS extends UITools = UITools " >
5859import { computed } from ' vue'
5960import { Primitive } from ' reka-ui'
6061import { useAppConfig } from ' #imports'
@@ -65,10 +66,10 @@ import UTooltip from './Tooltip.vue'
6566import UAvatar from ' ./Avatar.vue'
6667import UIcon from ' ./Icon.vue'
6768
68- const props = withDefaults (defineProps <ChatMessageProps >(), {
69+ const props = withDefaults (defineProps <ChatMessageProps < METADATA , DATA_PARTS , TOOLS > >(), {
6970 as: ' article'
7071})
71- const slots = defineSlots <ChatMessageSlots >()
72+ const slots = defineSlots <ChatMessageSlots < METADATA , DATA_PARTS , TOOLS > >()
7273
7374const appConfig = useAppConfig () as ChatMessage [' AppConfig' ]
7475
@@ -105,7 +106,7 @@ const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.chatMessage
105106 <template v-else >
106107 <template v-for =" (part , index ) in parts " :key =" ` ${id }-${part .type }-${index } ` " >
107108 <template v-if =" part .type === ' text' " >
108- {{ part.text }}
109+ {{ ( part as any) .text }}
109110 </template >
110111 </template >
111112 </template >
0 commit comments