-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtypes.ts
More file actions
325 lines (301 loc) · 9.42 KB
/
types.ts
File metadata and controls
325 lines (301 loc) · 9.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
import type IgcChatComponent from './chat.js';
/* jsonAPIPlainObject */
/**
* Represents a single chat message in the conversation.
*/
export interface IgcChatMessage {
/**
* A unique identifier for the message.
*/
id: string;
/**
* The textual content of the message.
*/
text: string;
/**
* The identifier or name of the sender of the message.
*/
sender: string;
/**
* The timestamp indicating when the message was sent.
*/
timestamp?: string;
/**
* Optional list of attachments associated with the message,
* such as images, files, or links.
*/
attachments?: IgcChatMessageAttachment[];
/**
* Optional list of reactions associated with the message.
*/
reactions?: string[];
}
/* jsonAPIPlainObject */
/**
* Represents an attachment associated with a chat message.
*/
export interface IgcChatMessageAttachment {
/**
* A unique identifier for the attachment.
*/
id: string;
/**
* The display name of the attachment (e.g. file name).
*/
name: string;
/**
* The URL from which the attachment can be downloaded or viewed.
* Typically used for attachments stored on a server or CDN.
*/
url?: string;
/* blazorSuppress */
/**
* The actual File object, if the attachment was provided locally (e.g. via upload).
*/
file?: File;
/* blazorAlternateName: attachmentType */
/**
* The MIME type or a custom type identifier for the attachment (e.g. "image/png", "pdf", "audio").
*/
type?: string;
/**
* Optional URL to a thumbnail preview of the attachment (e.g. for images or videos).
*/
thumbnail?: string;
}
/* jsonAPIPlainObject */
/**
* Configuration options for customizing the behavior and appearance of the chat component.
*/
export interface IgcChatOptions {
/**
* The ID of the current user. Used to differentiate between incoming and outgoing messages.
*/
currentUserId?: string;
/**
* If `true`, prevents the chat from automatically scrolling to the latest message.
*/
disableAutoScroll?: boolean;
/**
* If `true`, disables the ability to upload and send attachments.
* Defaults to `false`.
*/
disableInputAttachments?: boolean;
/**
* Indicates whether the other user is currently typing a message.
*/
isTyping?: boolean;
/**
* The accepted files that could be attached.
* Defines the file types as a list of comma-separated values (e.g. "image/*,.pdf") that the file input should accept.
*/
acceptedFiles?: string;
/**
* Optional header text to display at the top of the chat component.
*/
headerText?: string;
/**
* Optional placeholder text for the chat input area.
* Provides a hint to the user about what they can type (e.g. "Type a message...").
*/
inputPlaceholder?: string;
/**
* Suggested text snippets or quick replies that can be shown as user-selectable options.
*/
suggestions?: string[];
/**
* Controls the position of the chat suggestions within the component layout.
*
* - `"below-input"`: Renders suggestions below the chat input area.
* - `"below-messages"`: Renders suggestions below the chat messages area.
*
* Default is `"below-messages"`.
*/
suggestionsPosition?: ChatSuggestionsPosition;
/**
* Time in milliseconds to wait before dispatching a stop typing event.
* Default is `3000`.
*/
stopTypingDelay?: number;
/**
* A boolean flag that, when `true`, enables a **quick and dirty workaround** for styling
* components rendered within the Shadow DOM, from custom message renderers, by allowing them
* to inherit styles from the document's root. This can be useful for developers who prefer not to handle
* Shadow DOM encapsulation, but it is **not the recommended approach**.
*
* It is highly advised to use standard Web Component styling methods first, in this order:
*
* 1. **CSS Variables and Parts API**: Use the exposed `::part` API with custom CSS variables to style
* your content in your custom renderers.
*
* 2. **`link` elements**: For larger style sheets, link them directly within the Shadow DOM to maintain
* encapsulation.
*
* 3. **Inline `<style>` tags**: Use these for small, self-contained styles within a template.
*
* This property should be used as a **last resort** as it can lead to **style leakage**, where
* global styles unexpectedly bleed into the component, breaking encapsulation and causing
* unpredictable visual issues.
*
*/
adoptRootStyles?: boolean;
/**
* An object containing a collection of custom renderers for different parts of the chat UI.
*/
renderers?: ChatRenderers;
}
/* jsonAPIPlainObject */
/**
* Represents a draft message that is being composed by the user, including the text and any attachments.
*/
export interface IgcChatDraftMessage {
/**
* The textual content of the draft message.
*/
text: string;
/**
* An array of attachments associated with the draft message.
*/
attachments?: IgcChatMessageAttachment[];
}
/* jsonAPIPlainObject */
/**
* Represents a user's reaction to a specific chat message.
*/
export interface IgcChatMessageReaction {
/**
* The chat message that the reaction is associated with.
*/
message: IgcChatMessage;
/**
* The string representation of the reaction, such as an emoji or a string;
*/
reaction: string;
}
/* blazorSuppress */
/**
* A collection of optional rendering functions that allow for custom UI rendering.
* Each property is a function that takes a context object and returns a template result.
*/
export interface ChatRenderers {
/**
* Custom renderer for a single chat message attachment.
*/
attachment?: ChatTemplateRenderer<ChatAttachmentRenderContext>;
/**
* Custom renderer for the content of an attachment.
*/
attachmentContent?: ChatTemplateRenderer<ChatAttachmentRenderContext>;
/**
* Custom renderer for the header of an attachment.
*/
attachmentHeader?: ChatTemplateRenderer<ChatAttachmentRenderContext>;
/**
* Custom renderer for the file upload button in the input area.
*/
fileUploadButton?: ChatTemplateRenderer<ChatRenderContext>;
/**
* Custom renderer for the main chat input field.
*/
input?: ChatTemplateRenderer<ChatInputRenderContext>;
/**
* Custom renderer for the actions container within the input area.
*/
inputActions?: ChatTemplateRenderer<ChatRenderContext>;
/**
* Custom renderer for the actions at the end of the input area.
*/
inputActionsEnd?: ChatTemplateRenderer<ChatRenderContext>;
/**
* Custom renderer for the actions at the start of the input area.
*/
inputActionsStart?: ChatTemplateRenderer<ChatRenderContext>;
/**
* Custom renderer for the attachment previews within the input field.
*/
inputAttachments?: ChatTemplateRenderer<ChatInputRenderContext>;
/**
* Custom renderer for an entire chat message bubble.
*/
message?: ChatTemplateRenderer<ChatMessageRenderContext>;
/**
* Custom renderer for message-specific actions (e.g., reply or delete buttons).
*/
messageActions?: ChatTemplateRenderer<ChatMessageRenderContext>;
/**
* Custom renderer for the attachments associated with a message.
*/
messageAttachments?: ChatTemplateRenderer<ChatMessageRenderContext>;
/**
* Custom renderer for the main text and content of a message.
*/
messageContent?: ChatTemplateRenderer<ChatMessageRenderContext>;
/**
* Custom renderer for the header of a message, including sender and timestamp.
*/
messageHeader?: ChatTemplateRenderer<ChatMessageRenderContext>;
/**
* Custom renderer for the message send button.
*/
sendButton?: ChatTemplateRenderer<ChatRenderContext>;
/**
* Custom renderer for the prefix text shown before suggestions.
*/
suggestionPrefix?: ChatTemplateRenderer<ChatRenderContext>;
}
/**
* A generic type for a function that serves as a custom renderer.
* It takes a context object of type T and returns a template result.
*/
export type ChatTemplateRenderer<T> = (ctx: T) => unknown;
/**
* A string literal type defining the two possible positions for chat suggestions.
*/
export type ChatSuggestionsPosition = 'below-input' | 'below-messages';
/* jsonAPIPlainObject */
/**
* The base context object passed to custom renderer functions, containing the chat component instance.
*/
export interface ChatRenderContext {
/**
* The instance of the IgcChatComponent.
*/
instance: IgcChatComponent;
}
/* jsonAPIPlainObject */
/**
* The context object for renderers that deal with the chat input area.
* It extends the base context with input-specific properties.
*/
export interface ChatInputRenderContext extends ChatRenderContext {
/**
* The list of attachments currently in the input area.
*/
attachments: IgcChatMessageAttachment[];
/**
* The current value of the input field.
*/
value: string;
}
/* jsonAPIPlainObject */
/**
* The context object for renderers that deal with a specific chat message.
* It extends the base context with the message data.
*/
export interface ChatMessageRenderContext extends ChatRenderContext {
/**
* The specific chat message being rendered.
*/
message: IgcChatMessage;
}
/* jsonAPIPlainObject */
/**
* The context object for renderers that deal with a specific attachment within a message.
* It extends the message context with the attachment data.
*/
export interface ChatAttachmentRenderContext extends ChatMessageRenderContext {
/**
* The specific attachment being rendered.
*/
attachment: IgcChatMessageAttachment;
}