Skip to content

Commit dfb73eb

Browse files
committed
feat(chat): return unknown instead of TemplateResult for templates
1 parent b2095e0 commit dfb73eb

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/components/chat/types.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type { TemplateResult } from 'lit';
22

3-
// export type IgcMessageAttachmentType = 'image' | 'file';
4-
53
/**
64
* Represents a single chat message in the conversation.
75
*/
@@ -76,11 +74,11 @@ export interface IgcMessageAttachment {
7674
* (e.g. rendering thumbnails, file icons, or download links).
7775
*
7876
* @param {IgcMessageAttachment[]} attachments - The list of attachments to render.
79-
* @returns {TemplateResult} A Lit `TemplateResult` representing the rendered attachments.
77+
* @returns {unknown} A custom rendered representation of the attachments.
8078
*/
8179
export type AttachmentTemplate = (
8280
attachments: IgcMessageAttachment[]
83-
) => TemplateResult;
81+
) => unknown;
8482

8583
/**
8684
* A function type used to render a single chat message.
@@ -89,9 +87,9 @@ export type AttachmentTemplate = (
8987
* including its text, sender info, timestamp, and any attachments.
9088
*
9189
* @param {IgcMessage} message - The chat message to render.
92-
* @returns {TemplateResult} A Lit `TemplateResult` representing the rendered message.
90+
* @returns {unknown} A custom rendered representation of the message.
9391
*/
94-
export type MessageTemplate = (message: IgcMessage) => TemplateResult;
92+
export type MessageTemplate = (message: IgcMessage) => unknown;
9593

9694
// export type MarkdownRenderer = (text: string) => TemplateResult;
9795

@@ -103,6 +101,16 @@ export type IgcChatOptions = {
103101
* The ID of the current user. Used to differentiate between incoming and outgoing messages.
104102
*/
105103
currentUserId?: string;
104+
/**
105+
* Whether to hide message timestamps.
106+
* Defaults to `false`.
107+
*/
108+
hideTimestamp?: boolean;
109+
/**
110+
* Whether to hide sender usernames in the message list.
111+
* Defaults to `false`.
112+
*/
113+
hideUserName?: boolean;
106114
/**
107115
* If `true`, prevents the chat from automatically scrolling to the latest message.
108116
*/
@@ -181,21 +189,21 @@ export type IgcChatTemplates = {
181189
/**
182190
* Template used to show an indicator when the other user is typing (e.g. “User is typing...”).
183191
*/
184-
composingIndicatorTemplate?: TemplateResult;
192+
composingIndicatorTemplate?: unknown;
185193

186194
/**
187195
* Template for customizing the text input element (usually a `<textarea>` or `<input>`).
188196
*
189197
* @param text - The current value of the text input.
190-
* @returns A Lit `TemplateResult` representing the rendered input.
198+
* @returns {unknown} A custom rendered representation of the text input.
191199
*/
192-
textInputTemplate?: (text: string) => TemplateResult;
200+
textInputTemplate?: (text: string) => unknown;
193201

194202
/**
195203
* Template for rendering additional controls in the message input area,
196204
* such as send buttons, emoji pickers, or voice recorders.
197205
*/
198-
textAreaActionsTemplate?: TemplateResult;
206+
textAreaActionsTemplate?: unknown;
199207

200208
/**
201209
* Template for rendering attachments that are currently queued for sending (in the input area).

0 commit comments

Comments
 (0)