import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; type $RestProps = SvelteHTMLElements["li"]; type $Props = { /** * Specify who sent the message: `"me"` aligns it to the end with the * accent color, `"them"` to the start with the avatar. * @default "them" */ from?: "me" | "them"; /** * Specify who sent the message, such as "Sam", or "You" for your own. * Screen readers announce it before the message, since alignment alone * doesn't say who is speaking. * @default "" */ author?: string; /** * Set to `true` to also show `author` above the first message of a * group, as in a group chat. * @default false */ showAuthor?: boolean; /** * Set to `true` when the previous message has the same author, to group * them: the avatar is left out and the gap is smaller. * @default false */ continued?: boolean; /** * Set to `true` while the message is still arriving, such as a reply * streamed word by word. Screen readers wait and announce it once, in * full, instead of every chunk. * @default false */ streaming?: boolean; /** * Set to `true` to show a typing indicator in place of the content. * @default false */ typing?: boolean; /** * Specify the text screen readers announce for the typing indicator * @default "Typing" */ typingText?: string; /** * Set the delivery status of your own message, shown with the meta line. * Show it on the last message of a group. `"failed"` adds a Retry button * that dispatches `retry`. */ status?: undefined | "sending" | "sent" | "delivered" | "read" | "failed"; /** * Specify the text for each delivery status. * @default (status) => ({ sending: "Sending", sent: "Sent", delivered: "Delivered", read: "Read", failed: "Not sent", })[status] */ statusText?: (status: "sending" | "sent" | "delivered" | "read" | "failed") => string; /** * Specify the text of the Retry button for a failed message * @default "Retry" */ retryText?: string; /** Beside the message, such as a reply button. */ actions?: (this: void) => void; /** Under the message, outside its bubble, such as an image, a file, a link card or a code block. */ attachments?: (this: void) => void; /** Shown beside messages from others, such as a UserAvatar of size "sm". */ avatar?: (this: void) => void; /** Under the message, such as the time. Show it on the last message of a group. */ meta?: (this: void) => void; /** The message content. */ children?: (this: void) => void; [key: `data-${string}`]: unknown; }; export type ChatMessageProps = Omit<$RestProps, keyof $Props> & $Props; export default class ChatMessage extends SvelteComponentTyped< ChatMessageProps, { retry: CustomEvent }, { /** The message content. */ default: Record; /** Beside the message, such as a reply button. */ actions: Record; /** Under the message, outside its bubble, such as an image, a file, a link card or a code block. */ attachments: Record; /** Shown beside messages from others, such as a UserAvatar of size "sm". */ avatar: Record; /** Under the message, such as the time. Show it on the last message of a group. */ meta: Record; } > {}