Skip to content
17 changes: 9 additions & 8 deletions src/components/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { all } from './themes/themes.js';
import type {
ChatRenderContext,
ChatTemplateRenderer,
IgcChatDraftMessage,
IgcChatMessage,
IgcChatMessageAttachment,
IgcChatMessageReaction,
Expand Down Expand Up @@ -113,6 +114,8 @@ const Slots = setSlots(
'typing-indicator'
);

/* blazorIndirectRender */
/* blazorSupportsVisualChildren */
/**
* A chat UI component for displaying messages, attachments, and input interaction.
*
Expand Down Expand Up @@ -260,6 +263,8 @@ export default class IgcChatComponent extends EventEmitterMixin<
this._userInputContext.setValue(this._state, true);
}

/* blazorCollectionName: MessagesCollection */
/* blazorTreatAsCollection */
/**
* The list of chat messages currently displayed.
* Use this property to set or update the message history.
Expand All @@ -278,21 +283,15 @@ export default class IgcChatComponent extends EventEmitterMixin<
* Includes the draft text and any attachments.
*/
@property({ attribute: false })
public set draftMessage(value: {
text: string;
attachments?: IgcChatMessageAttachment[];
}) {
public set draftMessage(value: IgcChatDraftMessage) {
if (this._state && value) {
this._state.inputValue = value.text;
this._state.inputAttachments = value.attachments || [];
this.requestUpdate();
}
}

public get draftMessage(): {
text: string;
attachments?: IgcChatMessageAttachment[];
} {
public get draftMessage(): IgcChatDraftMessage {
return {
text: this._state.inputValue,
attachments: this._state.inputAttachments,
Expand All @@ -312,6 +311,7 @@ export default class IgcChatComponent extends EventEmitterMixin<
return this._state.options;
}

/* blazorSuppress */
/**
* The resource strings of the chat.
*/
Expand All @@ -322,6 +322,7 @@ export default class IgcChatComponent extends EventEmitterMixin<
this._i18nController.resourceStrings = value;
}

/* blazorSuppress */
public get resourceStrings(): IgcChatResourceStrings & IChatResourceStrings {
return this._i18nController.resourceStrings;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/chat/message-attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type DefaultAttachmentRenderers = {
* @csspart image-attachment - Part for the image element inside an image attachment.
*
* @fires igcAttachmentClick - Fired when an attachment header is toggled (clicked).
* @hidden @internal
*/
export default class IgcMessageAttachmentsComponent extends LitElement {
public static readonly tagName = 'igc-message-attachments';
Expand Down
30 changes: 28 additions & 2 deletions src/components/chat/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type IgcChatComponent from './chat.js';

/* jsonAPIPlainObject */
/**
* Represents a single chat message in the conversation.
*/
Expand Down Expand Up @@ -36,6 +37,7 @@ export interface IgcChatMessage {
reactions?: string[];
}

/* jsonAPIPlainObject */
/**
* Represents an attachment associated with a chat message.
*/
Expand All @@ -56,11 +58,13 @@ export interface IgcChatMessageAttachment {
*/
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").
*/
Expand All @@ -72,10 +76,11 @@ export interface IgcChatMessageAttachment {
thumbnail?: string;
}

/* jsonAPIPlainObject */
/**
* Configuration options for customizing the behavior and appearance of the chat component.
*/
export type IgcChatOptions = {
export interface IgcChatOptions {
/**
* The ID of the current user. Used to differentiate between incoming and outgoing messages.
*/
Expand Down Expand Up @@ -153,8 +158,24 @@ export type IgcChatOptions = {
* 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.
*/
Expand All @@ -169,6 +190,7 @@ export interface IgcChatMessageReaction {
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.
Expand Down Expand Up @@ -251,6 +273,7 @@ export type ChatTemplateRenderer<T> = (ctx: T) => unknown;
*/
export type ChatSuggestionsPosition = 'below-input' | 'below-messages';

/* jsonAPIPlainObject */
/**
* The base context object passed to custom renderer functions, containing the chat component instance.
*/
Expand All @@ -261,6 +284,7 @@ export interface ChatRenderContext {
instance: IgcChatComponent;
}

/* jsonAPIPlainObject */
/**
* The context object for renderers that deal with the chat input area.
* It extends the base context with input-specific properties.
Expand All @@ -276,6 +300,7 @@ export interface ChatInputRenderContext extends ChatRenderContext {
value: string;
}

/* jsonAPIPlainObject */
/**
* The context object for renderers that deal with a specific chat message.
* It extends the base context with the message data.
Expand All @@ -287,6 +312,7 @@ export interface ChatMessageRenderContext extends ChatRenderContext {
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.
Expand Down
Loading