-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(ChatMessages): expose registerMessageRef
#6275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v4
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,7 @@ export interface ChatMessagesProps<T extends UIMessage[] = UIMessage[]> { | |
| } | ||
|
|
||
| export type ChatMessagesSlots<T extends UIMessage[] = UIMessage[]> = { | ||
| default?(props?: {}): VNode[] | ||
| default?(props: { registerMessageRef: (id: string, element: ComponentPublicInstance | null) => void }): VNode[] | ||
| indicator?(props: { ui: ChatMessages['ui'] }): VNode[] | ||
| viewport?(props: { ui: ChatMessages['ui'], onClick: () => void }): VNode[] | ||
| } & { | ||
|
|
@@ -308,6 +308,10 @@ onMounted(() => { | |
| }, { childList: true, subtree: true }) | ||
| } | ||
| }) | ||
|
|
||
| defineExpose({ | ||
| registerMessageRef | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
|
|
@@ -318,7 +322,7 @@ onMounted(() => { | |
| :class="ui.root({ class: [props.ui?.root, props.class] })" | ||
| :style="{ '--last-message-height': `${lastMessageHeight}px` }" | ||
| > | ||
| <slot> | ||
| <slot :register-message-ref="registerMessageRef"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need to expose this in default slot? Isn't it enough to access it through a template ref? π€
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, Iβd prefer to avoid creating a template ref every time I need one when Iβm dealing with simpler cases. I see the template ref as necessary for more complex scenarios. |
||
| <template v-for="message in props.messages" :key="message.id"> | ||
| <UChatMessage | ||
| v-if="message.parts?.length" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.