@@ -3,12 +3,11 @@ import { html } from 'lit';
33import { GoogleGenAI , Modality } from '@google/genai' ;
44import {
55 IgcChatComponent ,
6- MarkdownMessageRenderer ,
6+ // MarkdownMessageRenderer,
77 defineComponents ,
88 registerIcon ,
99} from 'igniteui-webcomponents' ;
1010import type {
11- IgcChatTemplates ,
1211 IgcMessage ,
1312 IgcMessageAttachment ,
1413} from '../src/components/chat/types.js' ;
@@ -102,7 +101,7 @@ const userMessages: any[] = [];
102101
103102let isResponseSent : boolean ;
104103
105- const _messageAuthorTemplate = ( msg : any ) => {
104+ const _messageAuthorTemplate = ( msg : any , ctx : any ) => {
106105 return msg . sender !== 'user'
107106 ? html `
108107 < div >
@@ -118,7 +117,7 @@ const _messageAuthorTemplate = (msg: any) => {
118117 >
119118 </ div >
120119 `
121- : html `` ;
120+ : ctx . defaults . messageHeader . render ( ctx ) ;
122121} ;
123122const _messageActionsTemplate = ( msg : any ) => {
124123 return msg . sender !== 'user' && msg . text . trim ( )
@@ -169,19 +168,12 @@ const ai_chat_options = {
169168 'What is triskaidekaphobia?' ,
170169 'Show me very short sample typescript code' ,
171170 ] ,
172- templates : {
173- // messageActionsTemplate: messageActionsTemplate,
174- // typingIndicatorTemplate: _typingIndicatorTemplate,
175- // textInputTemplate: _textInputTemplate,
176- // textAreaActionsTemplate: _textAreaActionsTemplate,
177- // textAreaAttachmentsTemplate: _textAreaAttachmentsTemplate,
178- } ,
179171 // markdownRenderer: _customRenderer
180- messageRenderer : new MarkdownMessageRenderer ( {
181- // noHighlighter: true
182- // languages: ['typescript']
183- // theme: 'github-dark'
184- } ) ,
172+ // messageRenderer: new MarkdownMessageRenderer({
173+ // // noHighlighter: true
174+ // // languages: ['typescript']
175+ // // theme: 'github-dark'
176+ // }),
185177} ;
186178
187179const chat_options = {
@@ -195,18 +187,11 @@ const chat_options = {
195187 // // languages: ['typescript']
196188 // // theme: 'github-dark'
197189 // })
198- messageRenderer : new MarkdownMessageRenderer ( {
199- // noHighlighter: true
200- // languages: ['typescript']
201- // theme: 'github-dark'
202- } ) ,
203- templates : {
204- // attachmentContentTemplate: () => html`<p>content</p>`,
205- // attachmentHeaderTemplate: () => html`<p>header</p>`
206- // messageActionsTemplate: _messageActionsTemplate,
207- // textAreaAttachmentsTemplate: _textAreaAttachmentsTemplate,
208- // textAreaActionsTemplate: _textAreaActionsTemplate,
209- } as Partial < IgcChatTemplates > ,
190+ // messageRenderer: new MarkdownMessageRenderer({
191+ // // noHighlighter: true
192+ // // languages: ['typescript']
193+ // // theme: 'github-dark'
194+ // }),
210195} ;
211196
212197function handleCustomSendClick ( ) {
@@ -526,7 +511,8 @@ export const Chat_Templates: Story = {
526511 play : async ( ) => {
527512 const chat = document . querySelector ( 'igc-chat' ) ;
528513 if ( chat ) {
529- const actionsTemplate = ( ) => html `
514+ const _actionsTemplate = ( ctx ) => html `
515+ ${ ctx . defaults . fileUploadButton . render ( ctx ) }
530516 < igc-icon-button variant ="flat "> 🎤</ igc-icon-button >
531517 < div style ="margin-inline-start: auto; ">
532518 < igc-button @click =${ handleCustomSendClick } > Ask</ igc-button >
@@ -538,14 +524,31 @@ export const Chat_Templates: Story = {
538524 headerText : 'Chat' ,
539525 inputPlaceholder : 'Type your message here...' ,
540526 suggestions : [ 'Hello' , 'Hi' , 'Generate an image!' ] ,
541- templates : {
542- messageAuthorTemplate : _messageAuthorTemplate ,
543- messageActionsTemplate : _messageActionsTemplate ,
544- textAreaAttachmentsTemplate : _textAreaAttachmentsTemplate ,
545- textAreaActionsTemplate : actionsTemplate ,
546- suggestionPrefixTemplate : html `✨` ,
527+ renderers : {
528+ messageHeader : {
529+ render : ( ctx ) => _messageAuthorTemplate ( ctx . param , ctx ) ,
530+ } ,
531+ messageContent : {
532+ render : ( ctx ) => html `${ ctx . param . text . toUpperCase ( ) } ` ,
533+ } ,
534+ messageActions : {
535+ render : ( ctx ) => _messageActionsTemplate ( ctx . param ) ,
536+ } ,
537+ attachmentHeader : { render : ( ) => html `` } ,
538+ inputActions : { render : ( ctx ) => _actionsTemplate ( ctx ) } ,
539+ inputAttachments : {
540+ render : ( ctx ) =>
541+ html `< span > Attachments:</ span
542+ > ${ ctx . defaults . inputAttachments . render ( ctx ) } ` ,
543+ } ,
544+ typingIndicator : {
545+ render : ( ctx ) =>
546+ html `< span
547+ > Generating response
548+ ${ ctx . defaults . typingIndicator . render ( ctx ) } </ span
549+ > ` ,
550+ } ,
547551 } ,
548- messageRenderer : _customRenderer ,
549552 } ;
550553 chat . options = { ...options } ;
551554 }
0 commit comments