Skip to content

Commit 4a296aa

Browse files
committed
chore(*): JSDoc for all types in types.ts
1 parent 4ddd539 commit 4a296aa

File tree

1 file changed

+158
-3
lines changed

1 file changed

+158
-3
lines changed

src/components/chat/types.ts

Lines changed: 158 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,213 @@ import type { TemplateResult } from 'lit';
22

33
// export type IgcMessageAttachmentType = 'image' | 'file';
44

5+
/**
6+
* Represents a single chat message in the conversation.
7+
*/
58
export interface IgcMessage {
9+
/**
10+
* A unique identifier for the message.
11+
*/
612
id: string;
13+
14+
/**
15+
* The textual content of the message.
16+
*/
717
text: string;
18+
19+
/**
20+
* The identifier or name of the sender of the message.
21+
*/
822
sender: string;
23+
24+
/**
25+
* The timestamp indicating when the message was sent.
26+
*/
927
timestamp: Date;
28+
29+
/**
30+
* Optional list of attachments associated with the message,
31+
* such as images, files, or links.
32+
*/
1033
attachments?: IgcMessageAttachment[];
1134
}
1235

36+
/**
37+
* Represents an attachment associated with a chat message.
38+
*/
1339
export interface IgcMessageAttachment {
40+
/**
41+
* A unique identifier for the attachment.
42+
*/
1443
id: string;
44+
45+
/**
46+
* The display name of the attachment (e.g. file name).
47+
*/
1548
name: string;
49+
50+
/**
51+
* The URL from which the attachment can be downloaded or viewed.
52+
* Typically used for attachments stored on a server or CDN.
53+
*/
1654
url?: string;
55+
56+
/**
57+
* The actual File object, if the attachment was provided locally (e.g. via upload).
58+
*/
1759
file?: File;
60+
61+
/**
62+
* The MIME type or a custom type identifier for the attachment (e.g. "image/png", "pdf", "audio").
63+
*/
1864
type?: string;
65+
66+
/**
67+
* Optional URL to a thumbnail preview of the attachment (e.g. for images or videos).
68+
*/
1969
thumbnail?: string;
2070
}
2171

72+
/**
73+
* A function type used to render a group of attachments in a chat message.
74+
*
75+
* This allows consumers to customize how message attachments are displayed
76+
* (e.g. rendering thumbnails, file icons, or download links).
77+
*
78+
* @param {IgcMessageAttachment[]} attachments - The list of attachments to render.
79+
* @returns {TemplateResult} A Lit `TemplateResult` representing the rendered attachments.
80+
*/
2281
export type AttachmentTemplate = (
2382
attachments: IgcMessageAttachment[]
2483
) => TemplateResult;
84+
85+
/**
86+
* A function type used to render a single chat message.
87+
*
88+
* This allows consumers to fully customize the display of a message,
89+
* including its text, sender info, timestamp, and any attachments.
90+
*
91+
* @param {IgcMessage} message - The chat message to render.
92+
* @returns {TemplateResult} A Lit `TemplateResult` representing the rendered message.
93+
*/
2594
export type MessageTemplate = (message: IgcMessage) => TemplateResult;
26-
export type MarkdownRenderer = (text: string) => TemplateResult;
2795

96+
// export type MarkdownRenderer = (text: string) => TemplateResult;
97+
98+
/**
99+
* Configuration options for customizing the behavior and appearance of the chat component.
100+
*/
28101
export type IgcChatOptions = {
102+
/**
103+
* The ID of the current user. Used to differentiate between incoming and outgoing messages.
104+
*/
29105
currentUserId?: string;
106+
/**
107+
* Whether to hide user avatars in the message list.
108+
* Defaults to `false`.
109+
*/
30110
hideAvatar?: boolean;
111+
/**
112+
* Whether to hide message timestamps.
113+
* Defaults to `false`.
114+
*/
31115
hideTimestamp?: boolean;
116+
/**
117+
* Whether to hide sender usernames in the message list.
118+
* Defaults to `false`.
119+
*/
32120
hideUserName?: boolean;
121+
/**
122+
* If `true`, prevents the chat from automatically scrolling to the latest message.
123+
*/
33124
disableAutoScroll?: boolean;
125+
/**
126+
* If `true`, disables the ability to upload and send attachments.
127+
* Defaults to `false`.
128+
*/
34129
disableAttachments?: boolean;
130+
/**
131+
* Indicates whether the other user is currently typing or composing a message.
132+
*/
35133
isComposing?: boolean;
36134
/**
37135
* The accepted files that could be attached.
38-
* Defines the file types as a list of comma-separated values that the file input should accept.
136+
* Defines the file types as a list of comma-separated values (e.g. "image/*,.pdf") that the file input should accept.
39137
*/
40138
acceptedFiles?: string;
139+
/**
140+
* Optional header text to display at the top of the chat component.
141+
*/
41142
headerText?: string;
143+
/**
144+
* Suggested text snippets or quick replies that can be shown as user-selectable options.
145+
*/
42146
suggestions?: string[];
147+
/**
148+
* A set of template override functions used to customize rendering of messages, attachments, etc.
149+
*/
43150
templates?: IgcChatTemplates;
44-
markdownRenderer?: MarkdownRenderer;
45151
};
46152

153+
/**
154+
* A collection of template functions used to customize different parts of the chat component.
155+
* Each template allows you to override the rendering of a specific part of the component.
156+
*/
47157
export type IgcChatTemplates = {
158+
/**
159+
* Template for rendering an attachment in a message.
160+
*/
48161
attachmentTemplate?: AttachmentTemplate;
162+
163+
/**
164+
* Template for rendering a custom header above the attachment in a message.
165+
*/
49166
attachmentHeaderTemplate?: AttachmentTemplate;
167+
168+
/**
169+
* Template for rendering custom action buttons or controls related to an attachment
170+
* (e.g. download, preview, delete).
171+
*/
50172
attachmentActionsTemplate?: AttachmentTemplate;
173+
174+
/**
175+
* Template for rendering the main content of an attachment, such as a thumbnail or file preview.
176+
*/
51177
attachmentContentTemplate?: AttachmentTemplate;
178+
179+
/**
180+
* Template for rendering a single chat message.
181+
* Use this to customize message layout, formatting, or metadata.
182+
*/
52183
messageTemplate?: MessageTemplate;
184+
185+
/**
186+
* Template for rendering message-specific actions such as edit, delete, reply, etc.
187+
*/
53188
messageActionsTemplate?: MessageTemplate;
189+
190+
/**
191+
* Template used to show an indicator when the other user is typing (e.g. “User is typing...”).
192+
*/
54193
composingIndicatorTemplate?: TemplateResult;
194+
195+
/**
196+
* Template for customizing the text input element (usually a `<textarea>` or `<input>`).
197+
*
198+
* @param text - The current value of the text input.
199+
* @returns A Lit `TemplateResult` representing the rendered input.
200+
*/
55201
textInputTemplate?: (text: string) => TemplateResult;
202+
203+
/**
204+
* Template for rendering additional controls in the message input area,
205+
* such as send buttons, emoji pickers, or voice recorders.
206+
*/
56207
textAreaActionsTemplate?: TemplateResult;
208+
209+
/**
210+
* Template for rendering attachments that are currently queued for sending (in the input area).
211+
*/
57212
textAreaAttachmentsTemplate?: AttachmentTemplate;
58213
};
59214

0 commit comments

Comments
 (0)