@cratis/components 4.55.0 → 4.55.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/compat-manifest.json +13 -13
  2. package/dist/esm/Chat/ChatConversation.d.ts.map +1 -1
  3. package/dist/esm/Chat/ChatConversation.js +38 -10
  4. package/dist/esm/Chat/ChatConversation.js.map +1 -1
  5. package/dist/esm/Chat/ChatMessageBody.js +1 -1
  6. package/dist/esm/Chat/ChatMessageBody.js.map +1 -1
  7. package/dist/esm/Chat/ChatTopicList.js +1 -1
  8. package/dist/esm/Chat/ChatTopicList.js.map +1 -1
  9. package/dist/esm/Chat/Kit/Avatar/PersonAvatarCircle.d.ts.map +1 -1
  10. package/dist/esm/Chat/Kit/Avatar/PersonAvatarCircle.js +1 -1
  11. package/dist/esm/Chat/Kit/Avatar/PersonAvatarCircle.js.map +1 -1
  12. package/dist/esm/Chat/Kit/ChatComposer.js +1 -1
  13. package/dist/esm/Chat/Kit/ChatComposer.js.map +1 -1
  14. package/dist/esm/Chat/Kit/ChatMessageBubble.d.ts.map +1 -1
  15. package/dist/esm/Chat/Kit/ChatMessageBubble.js +18 -11
  16. package/dist/esm/Chat/Kit/ChatMessageBubble.js.map +1 -1
  17. package/dist/esm/Chat/Kit/Emoji/EmojiPicker.js +1 -1
  18. package/dist/esm/Chat/Kit/Emoji/EmojiPicker.js.map +1 -1
  19. package/dist/esm/Chat/Kit/FailedReply.js +1 -1
  20. package/dist/esm/Chat/Kit/FailedReply.js.map +1 -1
  21. package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.js +1 -1
  22. package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.js.map +1 -1
  23. package/dist/esm/Chat/Kit/MessageReactions.js +1 -1
  24. package/dist/esm/Chat/Kit/MessageReactions.js.map +1 -1
  25. package/dist/esm/Chat/Kit/ReactionPicker.js +1 -1
  26. package/dist/esm/Chat/Kit/ReactionPicker.js.map +1 -1
  27. package/dist/esm/Chat/Kit/TypingIndicator.js +1 -1
  28. package/dist/esm/Chat/Kit/TypingIndicator.js.map +1 -1
  29. package/dist/esm/DataTables/DataTableRow.d.ts.map +1 -1
  30. package/dist/esm/DataTables/DataTableRow.js +23 -12
  31. package/dist/esm/DataTables/DataTableRow.js.map +1 -1
  32. package/dist/esm/SchemaEditor/Tree/PropertyTypeGlyph.js +1 -1
  33. package/dist/esm/SchemaEditor/Tree/PropertyTypeGlyph.js.map +1 -1
  34. package/package.json +1 -1
@@ -70,7 +70,7 @@
70
70
  {
71
71
  "name": "@cratis/components",
72
72
  "role": "core",
73
- "version": "4.55.0",
73
+ "version": "4.55.1",
74
74
  "releaseMajorRange": ">=4 <5",
75
75
  "independentRelease": false,
76
76
  "private": false,
@@ -94,7 +94,7 @@
94
94
  {
95
95
  "name": "@cratis/eslint-plugin-components",
96
96
  "role": "eslint",
97
- "version": "4.55.0",
97
+ "version": "4.55.1",
98
98
  "releaseMajorRange": ">=4 <5",
99
99
  "independentRelease": false,
100
100
  "private": false,
@@ -107,7 +107,7 @@
107
107
  {
108
108
  "name": "@cratis/components.migrator",
109
109
  "role": "migrator",
110
- "version": "4.55.0",
110
+ "version": "4.55.1",
111
111
  "releaseMajorRange": ">=4 <5",
112
112
  "independentRelease": false,
113
113
  "private": false,
@@ -118,13 +118,13 @@
118
118
  {
119
119
  "name": "@cratis/components.conformance",
120
120
  "role": "conformance",
121
- "version": "4.55.0",
121
+ "version": "4.55.1",
122
122
  "releaseMajorRange": ">=4 <5",
123
123
  "independentRelease": false,
124
124
  "private": false,
125
125
  "packageAccess": "public",
126
126
  "peerDependencies": {
127
- "@cratis/components": "4.55.0",
127
+ "@cratis/components": "4.55.1",
128
128
  "react": "^19.0.0",
129
129
  "react-dom": "^19.0.0"
130
130
  },
@@ -134,13 +134,13 @@
134
134
  {
135
135
  "name": "@cratis/components.mui",
136
136
  "role": "renderer-adapter",
137
- "version": "4.55.0",
137
+ "version": "4.55.1",
138
138
  "releaseMajorRange": ">=4 <5",
139
139
  "independentRelease": false,
140
140
  "private": false,
141
141
  "packageAccess": "public",
142
142
  "peerDependencies": {
143
- "@cratis/components": "4.55.0",
143
+ "@cratis/components": "4.55.1",
144
144
  "@emotion/react": ">=11.5 <12",
145
145
  "@emotion/styled": ">=11.11 <12",
146
146
  "@mui/material": ">=9 <10",
@@ -190,13 +190,13 @@
190
190
  {
191
191
  "name": "@cratis/components.primereact",
192
192
  "role": "renderer-adapter",
193
- "version": "4.55.0",
193
+ "version": "4.55.1",
194
194
  "releaseMajorRange": ">=4 <5",
195
195
  "independentRelease": false,
196
196
  "private": false,
197
197
  "packageAccess": "public",
198
198
  "peerDependencies": {
199
- "@cratis/components": "4.55.0",
199
+ "@cratis/components": "4.55.1",
200
200
  "@primereact/core": ">=11 <12",
201
201
  "@primereact/ui": ">=11 <12",
202
202
  "@primeuix/themes": ">=3 <4",
@@ -258,13 +258,13 @@
258
258
  {
259
259
  "name": "@cratis/components.primereact10",
260
260
  "role": "renderer-adapter",
261
- "version": "4.55.0",
261
+ "version": "4.55.1",
262
262
  "releaseMajorRange": ">=4 <5",
263
263
  "independentRelease": false,
264
264
  "private": false,
265
265
  "packageAccess": "public",
266
266
  "peerDependencies": {
267
- "@cratis/components": "4.55.0",
267
+ "@cratis/components": "4.55.1",
268
268
  "primereact": ">=10.9.9 <11",
269
269
  "react": "^19.0.0",
270
270
  "react-dom": "^19.0.0"
@@ -306,13 +306,13 @@
306
306
  {
307
307
  "name": "@cratis/components.designsystemet",
308
308
  "role": "renderer-adapter",
309
- "version": "4.55.0",
309
+ "version": "4.55.1",
310
310
  "releaseMajorRange": ">=4 <5",
311
311
  "independentRelease": false,
312
312
  "private": false,
313
313
  "packageAccess": "public",
314
314
  "peerDependencies": {
315
- "@cratis/components": "4.55.0",
315
+ "@cratis/components": "4.55.1",
316
316
  "@digdir/designsystemet-css": ">=1.24 <2",
317
317
  "@digdir/designsystemet-react": ">=1.24 <2",
318
318
  "react": "^19.0.0",
@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AExC;kEAC8D;IAC9D,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAEvC;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,CACvB,KAAK,EAAE,MAAM,KACZ,gBAAgB,EAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAEtD,0FAA0F;IAC1F,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAEnC;sCACkC;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,wFAAwF;IACxF,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,MAAM,CAAC;IAE1D,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,8FAA8F;IAC9F,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAEhC,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAmLD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,SAAS,WAAW,GAAG,WAAW,qOAiBxE,qBAAqB,CAAC,QAAQ,CAAC,gCA2EjC,CAAC"}
@@ -39,6 +39,30 @@ const typingLabel = (authors, labels) => {
39
39
  .replace('{second}', authors[1].name);
40
40
  return labels?.typingSeveral ?? 'Several people are typing';
41
41
  };
42
+ const conversationStatusLabel = (status, labels) => {
43
+ switch (status) {
44
+ case ChatStatus.Loading:
45
+ return jsx("span", { role: 'status', children: labels?.loading ?? 'Loading messages…' }, status);
46
+ case ChatStatus.Failed:
47
+ return jsx("span", { role: 'alert', children: labels?.failed ?? 'Could not load messages.' }, status);
48
+ case ChatStatus.Unauthorized:
49
+ return jsx("span", { role: 'alert', children: labels?.unauthorized ?? 'You are not authorized to view these messages.' }, status);
50
+ default:
51
+ return labels?.empty ?? 'No messages yet. Say hello!';
52
+ }
53
+ };
54
+ const renderConversationStatus = (messageCount, status, labels) => {
55
+ if (messageCount > 0 && status !== ChatStatus.Failed && status !== ChatStatus.Unauthorized)
56
+ return null;
57
+ return (jsx("p", { className: 'cratis-chat-conversation__empty', children: conversationStatusLabel(status, labels) }));
58
+ };
59
+ const renderMessageAuthor = (message, author, { renderAvatar, renderAuthorName, buildAvatarUrl }) => (jsxs("div", { className: 'cratis-chat-message__author', children: [renderAvatar ? (renderAvatar(message.authorId, author)) : (jsx(PersonAvatarCircle, { userId: chatIdentifierString(message.authorId), name: author.name, hasAvatar: author.hasAvatar ?? false, size: 22, ownerType: author.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users', version: author.avatarVersion, buildAvatarUrl: buildAvatarUrl })), jsx("span", { className: 'cratis-chat-message__author-name', children: renderAuthorName ? renderAuthorName(message.authorId, author) : author.name })] }));
60
+ const renderMessageActions = ({ message, author, availableActions, quickReply, labels, onQuickReply, }) => (jsxs("div", { className: 'cratis-chat-message__actions', children: [quickReply && (jsx("button", { type: 'button', className: 'cratis-chat-message__action', title: (labels?.quickReplyTo ?? 'Reply to {name}').replace('{name}', author.name), "aria-label": (labels?.quickReplyTo ?? 'Reply to {name}').replace('{name}', author.name), onClick: () => onQuickReply(author.name), children: jsx(ReplyIcon, {}) })), availableActions.map((action) => (jsx("button", { type: 'button', className: 'cratis-chat-message__action', title: action.label, "aria-label": action.label, onClick: () => action.onInvoke(message), children: typeof action.icon === 'string' ? jsx("i", { className: action.icon, "aria-hidden": 'true' }) : action.icon }, action.id)))] }));
61
+ const renderConversationMessage = (props) => {
62
+ const { message, author, info: { showAuthor, showTimestamp }, availableActions, quickReply, renderMessageExtra, labels } = props;
63
+ const showActionsRow = quickReply || availableActions.length > 0;
64
+ return (jsxs("div", { className: `cratis-chat-message${showAuthor ? '' : ' cratis-chat-message--continuation'}`, children: [showAuthor && renderMessageAuthor(message, author, props), jsxs("div", { className: 'cratis-chat-message__content', children: [jsxs("div", { className: `cratis-chat-message__panel${showActionsRow ? ' cratis-chat-message__panel--with-actions' : ''}`, children: [jsx(ChatMessageBody, { body: message.body, mentions: message.mentions }), showActionsRow && renderMessageActions(props)] }), renderMessageExtra?.(message), showTimestamp && (jsx("span", { className: 'cratis-chat-message__time', children: relativeTimestamp(timestampOf(message), new Date(), labels?.timestamps) }))] })] }, chatIdentifierString(message.id)));
65
+ };
42
66
  const ChatConversation = ({ messages, status = ChatStatus.Ready, onSendMessage, authorOf, renderAvatar, renderAuthorName, renderMessageExtra, actions, mentionCandidates, resolveMentionCandidates, typingAuthors = [], quickReply = true, buildAvatarUrl, autoFocus = false, labels, className, }) => {
43
67
  const composerRef = useRef(null);
44
68
  const messagesEndRef = useRef(null);
@@ -56,18 +80,22 @@ const ChatConversation = ({ messages, status = ChatStatus.Ready, onSendMessage,
56
80
  kind: candidate.kind,
57
81
  })));
58
82
  const quickReplyTo = (name) => composerRef.current?.prefill(`@${name} `);
59
- return (jsxs("div", { className: `cratis-chat-conversation${className ? ` ${className}` : ''}`, children: [jsxs("div", { className: 'cratis-chat-conversation__messages', "aria-busy": status === ChatStatus.Loading && messages.length > 0 || undefined, children: [(messages.length === 0 || status === ChatStatus.Failed || status === ChatStatus.Unauthorized) && (jsx("p", { className: 'cratis-chat-conversation__empty', children: status === ChatStatus.Loading ? (jsx("span", { role: 'status', children: labels?.loading ?? 'Loading messages…' }, status)) : status === ChatStatus.Failed ? (jsx("span", { role: 'alert', children: labels?.failed ?? 'Could not load messages.' }, status)) : status === ChatStatus.Unauthorized ? (jsx("span", { role: 'alert', children: labels?.unauthorized ?? 'You are not authorized to view these messages.' }, status)) : (labels?.empty ?? 'No messages yet. Say hello!') })), status !== ChatStatus.Unauthorized && messages.map((message, index) => {
83
+ return (jsxs("div", { className: `cratis-chat-conversation${className ? ` ${className}` : ''}`, "data-cratis-component": 'ChatConversation', children: [jsxs("div", { className: 'cratis-chat-conversation__messages', "aria-busy": status === ChatStatus.Loading && messages.length > 0 || undefined, children: [renderConversationStatus(messages.length, status, labels), status !== ChatStatus.Unauthorized && messages.map((message, index) => {
60
84
  const author = authorFor(message.authorId);
61
- const { showAuthor, showTimestamp } = renderInfo[index];
62
85
  const availableActions = (actions ?? []).filter((action) => action.isAvailable?.(message) ?? true);
63
- const showActionsRow = quickReply || availableActions.length > 0;
64
- return (jsxs("div", { className: `cratis-chat-message${showAuthor ? '' : ' cratis-chat-message--continuation'}`, children: [showAuthor && (jsxs("div", { className: 'cratis-chat-message__author', children: [renderAvatar ? (renderAvatar(message.authorId, author)) : (jsx(PersonAvatarCircle, { userId: chatIdentifierString(message.authorId), name: author.name, hasAvatar: author.hasAvatar ?? false, size: 22, ownerType: author.kind === ChatAuthorKind.Agent
65
- ? 'Agents'
66
- : 'Users', version: author.avatarVersion, buildAvatarUrl: buildAvatarUrl })), jsx("span", { className: 'cratis-chat-message__author-name', children: renderAuthorName
67
- ? renderAuthorName(message.authorId, author)
68
- : author.name })] })), jsxs("div", { className: 'cratis-chat-message__content', children: [jsxs("div", { className: `cratis-chat-message__panel${showActionsRow ? ' cratis-chat-message__panel--with-actions' : ''}`, children: [jsx(ChatMessageBody, { body: message.body, mentions: message.mentions }), showActionsRow && (jsxs("div", { className: 'cratis-chat-message__actions', children: [quickReply && (jsx("button", { type: 'button', className: 'cratis-chat-message__action', title: (labels?.quickReplyTo ??
69
- 'Reply to {name}').replace('{name}', author.name), "aria-label": (labels?.quickReplyTo ??
70
- 'Reply to {name}').replace('{name}', author.name), onClick: () => quickReplyTo(author.name), children: jsx(ReplyIcon, {}) })), availableActions.map((action) => (jsx("button", { type: 'button', className: 'cratis-chat-message__action', title: action.label, "aria-label": action.label, onClick: () => action.onInvoke(message), children: typeof action.icon === 'string' ? (jsx("i", { className: action.icon, "aria-hidden": 'true' })) : (action.icon) }, action.id)))] }))] }), renderMessageExtra?.(message), showTimestamp && (jsx("span", { className: 'cratis-chat-message__time', children: relativeTimestamp(timestampOf(message), new Date(), labels?.timestamps) }))] })] }, chatIdentifierString(message.id)));
86
+ return renderConversationMessage({
87
+ message,
88
+ author,
89
+ info: renderInfo[index],
90
+ availableActions,
91
+ quickReply,
92
+ onQuickReply: quickReplyTo,
93
+ renderAvatar,
94
+ renderAuthorName,
95
+ renderMessageExtra,
96
+ buildAvatarUrl,
97
+ labels,
98
+ });
71
99
  }), status !== ChatStatus.Unauthorized && (jsx(TypingIndicator, { authors: typingAuthors, label: typingLabel(typingAuthors, labels), buildAvatarUrl: buildAvatarUrl })), jsx("div", { ref: messagesEndRef })] }), jsx(ChatComposer, { ref: composerRef, mentionCandidates: mentionCandidates, resolveMentionCandidates: resolveMentionCandidates, onSend: send, disabled: status === ChatStatus.Unauthorized, autoFocus: autoFocus, buildAvatarUrl: buildAvatarUrl, labels: labels?.composer })] }));
72
100
  };
73
101
 
@@ -1 +1 @@
1
- {"version":3,"file":"ChatConversation.js","sources":["../../../Chat/ChatConversation.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useMemo, useRef, type ReactNode } from 'react';\nimport { PersonAvatarCircle, type BuildAvatarUrlParams } from './Kit/Avatar';\nimport { ChatAuthorKind } from './Kit/ChatAuthorKind';\nimport {\n ChatComposer,\n type ChatComposerHandle,\n type ChatComposerLabels,\n} from './Kit/ChatComposer';\nimport type { ChatTypingAuthor } from './Kit/ChatTypingAuthor';\nimport type { MentionCandidate } from './Kit/Mentions';\nimport { TypingIndicator } from './Kit/TypingIndicator';\nimport type { ChatAuthor } from './ChatAuthor';\nimport { chatIdentifierString, type ChatIdentifier } from './ChatIdentifier';\nimport type { ChatMention } from './ChatMention';\nimport type { ChatMessage } from './ChatMessage';\nimport { ChatStatus } from './ChatStatus';\nimport type { ChatMessageAction } from './ChatMessageAction';\nimport { ChatMessageBody } from './ChatMessageBody';\nimport { relativeTimestamp, type RelativeTimestampLabels } from './relativeTimestamp';\n\nconst ReplyIcon = () => (\n <svg\n width='14'\n height='14'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2.5'\n aria-hidden='true'\n >\n <polyline points='9 17 4 12 9 7' />\n <path d='M4 12h10a6 6 0 0 1 6 6v1' />\n </svg>\n);\n\n/** Overrides for every label the {@link ChatConversation} renders. Any field left unset falls\n * back to a literal English default — this library ships no i18n mechanism of its own, so a host\n * that localizes passes its own translated strings through here. */\nexport interface ChatConversationLabels {\n /** Shown while loading without messages. Defaults to `'Loading messages…'`. */\n loading?: string;\n\n /** Shown when loading messages fails, alongside any existing messages. Defaults to `'Could not load messages.'`. */\n failed?: string;\n\n /** Shown when access is denied; replaces any existing messages. Defaults to `'You are not authorized to view these messages.'`. */\n unauthorized?: string;\n\n /** Shown when there are no messages yet. Defaults to `'No messages yet. Say hello!'`. */\n empty?: string;\n\n /** One author typing. `{name}` is substituted. Defaults to `'{name} is typing'`. */\n typing?: string;\n\n /** Two authors typing. `{first}`/`{second}` are substituted. Defaults to `'{first} and {second} are typing'`. */\n typingTwo?: string;\n\n /** Three or more authors typing. Defaults to `'Several people are typing'`. */\n typingSeveral?: string;\n\n /** Tooltip/accessible label for the quick-reply button. `{name}` is substituted. Defaults to `'Reply to {name}'`. */\n quickReplyTo?: string;\n\n /** Overrides for the relative timestamps next to messages. */\n timestamps?: RelativeTimestampLabels;\n\n /** Labels forwarded to the composer. */\n composer?: ChatComposerLabels;\n}\n\n/**\n * Props for {@link ChatConversation}.\n * @typeParam TMessage The host's message type — anything extending {@link ChatMessage}.\n */\nexport interface ChatConversationProps<TMessage extends ChatMessage = ChatMessage> {\n /**\n * The messages of the conversation, rendered in the order given. Hand this the array a live\n * (observable) query delivers and the conversation re-renders as it changes.\n */\n messages: TMessage[];\n\n /** Query display state. Defaults to {@link ChatStatus.Ready}; existing messages remain visible on loading or failure, and unauthorized disables the composer. */\n status?: ChatStatus;\n\n /**\n * Invoked when a message is sent, with the trimmed body and who it mentions. Everything else\n * about persisting the message is the host's business.\n * @param body The message text, mentions written into it as plain `@Name`.\n * @param mentions Who the body mentions.\n */\n onSendMessage: (body: string, mentions: ChatMention[]) => void;\n\n /**\n * Resolves an author id into what it takes to render them — name, kind, whether an avatar\n * image exists. Messages deliberately carry only the id; this is where the rest comes from.\n * Omit to fall back to rendering the id itself as the name.\n * @param authorId The identifier of the author to resolve.\n * @returns The author.\n */\n authorOf?: (authorId: ChatIdentifier) => ChatAuthor;\n\n /**\n * Renders the avatar for an author, replacing the built-in initials circle entirely.\n * @param authorId The identifier of the author.\n * @param author The resolved author, as {@link authorOf} answered.\n * @returns What to render.\n */\n renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n\n /**\n * Renders the display name for an author, replacing the built-in name text entirely.\n * @param authorId The identifier of the author.\n * @param author The resolved author, as {@link authorOf} answered.\n * @returns What to render.\n */\n renderAuthorName?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n\n /**\n * Renders host content under a message's body, for example reactions or a failed-reply notice.\n * Nothing extra is rendered when it returns null or undefined.\n * @param message The message being rendered.\n * @returns What to render under the message body.\n */\n renderMessageExtra?: (message: TMessage) => ReactNode;\n\n /** The host's own actions, offered as buttons on every message each is available for. */\n actions?: ChatMessageAction<TMessage>[];\n\n /** Everyone who can be mentioned, when the host already holds the list. Omit (together with\n * {@link resolveMentionCandidates}) to turn mentions off. */\n mentionCandidates?: MentionCandidate[];\n\n /**\n * Resolves who can be mentioned as the person types, invoked with what has been typed after\n * the `@`. May answer synchronously or with a promise.\n * @param query What has been typed after the `@`.\n * @returns The candidates matching the query.\n */\n resolveMentionCandidates?: (\n query: string,\n ) => MentionCandidate[] | Promise<MentionCandidate[]>;\n\n /** Who the conversation is currently waiting on — someone typing, or an agent working. */\n typingAuthors?: ChatTypingAuthor[];\n\n /** Whether the quick-reply affordance (prefill the composer with `@Name`) is offered on\n * messages. Defaults to true. */\n quickReply?: boolean;\n\n /** Builds the avatar image URL for every author shown. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Whether the composer takes focus when mounted. */\n autoFocus?: boolean;\n\n /** Overrides for every label rendered. Unset fields fall back to literal English defaults. */\n labels?: ChatConversationLabels;\n\n /** Additional class name for the conversation's root element. */\n className?: string;\n}\n\n/** The message's timestamp as a `Date` — data that traveled through JSON may carry it as a string. */\nconst timestampOf = (message: ChatMessage): Date =>\n message.timestamp instanceof Date ? message.timestamp : new Date(message.timestamp);\n\nconst sameMinute = (left: Date, right: Date): boolean =>\n left.getFullYear() === right.getFullYear() &&\n left.getMonth() === right.getMonth() &&\n left.getDate() === right.getDate() &&\n left.getHours() === right.getHours() &&\n left.getMinutes() === right.getMinutes();\n\ninterface MessageRenderInfo {\n /** Whether to show the author row — false for a continuation by the same author. */\n showAuthor: boolean;\n\n /** Whether to show the timestamp — false when the next message continues the same minute. */\n showTimestamp: boolean;\n}\n\nconst computeRenderInfo = (messages: ChatMessage[]): MessageRenderInfo[] =>\n messages.map((message, index) => {\n const previous = index > 0 ? messages[index - 1] : undefined;\n const next = index < messages.length - 1 ? messages[index + 1] : undefined;\n\n const showAuthor =\n !previous ||\n chatIdentifierString(previous.authorId) !==\n chatIdentifierString(message.authorId);\n const showTimestamp =\n !next ||\n chatIdentifierString(next.authorId) !==\n chatIdentifierString(message.authorId) ||\n !sameMinute(timestampOf(message), timestampOf(next));\n\n return { showAuthor, showTimestamp };\n });\n\n/**\n * Composes the \"X is typing\" line from whoever the conversation is waiting on.\n * @param authors The authors currently typing or working.\n * @param labels Label overrides, as passed to {@link ChatConversation}.\n * @returns The label to show, empty when nobody is.\n */\nconst typingLabel = (\n authors: ChatTypingAuthor[],\n labels: ChatConversationLabels | undefined,\n): string => {\n if (authors.length === 0) return '';\n if (authors.length === 1)\n return (labels?.typing ?? '{name} is typing').replace('{name}', authors[0].name);\n if (authors.length === 2)\n return (labels?.typingTwo ?? '{first} and {second} are typing')\n .replace('{first}', authors[0].name)\n .replace('{second}', authors[1].name);\n return labels?.typingSeveral ?? 'Several people are typing';\n};\n\n/**\n * One conversation — its messages and the composer to add to them. Host-agnostic by design: it\n * renders whatever message array it is given (hand it a live query's data and it stays current),\n * resolves authors through the host's {@link ChatConversationProps.authorOf | authorOf} and\n * render callbacks, offers the host's own {@link ChatConversationProps.actions | actions} on\n * each message, and reports sends back through\n * {@link ChatConversationProps.onSendMessage | onSendMessage} without any opinion about the\n * backend behind it. Mentions and the emoji picker come along through the composer.\n */\nexport const ChatConversation = <TMessage extends ChatMessage = ChatMessage>({\n messages,\n status = ChatStatus.Ready,\n onSendMessage,\n authorOf,\n renderAvatar,\n renderAuthorName,\n renderMessageExtra,\n actions,\n mentionCandidates,\n resolveMentionCandidates,\n typingAuthors = [],\n quickReply = true,\n buildAvatarUrl,\n autoFocus = false,\n labels,\n className,\n}: ChatConversationProps<TMessage>) => {\n const composerRef = useRef<ChatComposerHandle>(null);\n const messagesEndRef = useRef<HTMLDivElement>(null);\n const renderInfo = useMemo(() => computeRenderInfo(messages), [messages]);\n\n useEffect(() => {\n messagesEndRef.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n }, [messages, typingAuthors.length]);\n\n const authorFor = (authorId: ChatIdentifier): ChatAuthor =>\n authorOf?.(authorId) ?? {\n name: chatIdentifierString(authorId),\n kind: ChatAuthorKind.User,\n };\n\n const send = (text: string, mentioned: MentionCandidate[]) =>\n onSendMessage(\n text,\n mentioned.map(\n (candidate) =>\n ({\n id: candidate.id,\n name: candidate.name,\n kind: candidate.kind,\n }) satisfies ChatMention,\n ),\n );\n\n const quickReplyTo = (name: string) => composerRef.current?.prefill(`@${name} `);\n\n return (\n <div className={`cratis-chat-conversation${className ? ` ${className}` : ''}`}>\n <div className='cratis-chat-conversation__messages' aria-busy={status === ChatStatus.Loading && messages.length > 0 || undefined}>\n {(messages.length === 0 || status === ChatStatus.Failed || status === ChatStatus.Unauthorized) && (\n <p className='cratis-chat-conversation__empty'>\n {status === ChatStatus.Loading ? (\n <span key={status} role='status'>{labels?.loading ?? 'Loading messages…'}</span>\n ) : status === ChatStatus.Failed ? (\n <span key={status} role='alert'>{labels?.failed ?? 'Could not load messages.'}</span>\n ) : status === ChatStatus.Unauthorized ? (\n <span key={status} role='alert'>{labels?.unauthorized ?? 'You are not authorized to view these messages.'}</span>\n ) : (\n labels?.empty ?? 'No messages yet. Say hello!'\n )}\n </p>\n )}\n {status !== ChatStatus.Unauthorized && messages.map((message, index) => {\n const author = authorFor(message.authorId);\n const { showAuthor, showTimestamp } = renderInfo[index];\n const availableActions = (actions ?? []).filter(\n (action) => action.isAvailable?.(message) ?? true,\n );\n const showActionsRow = quickReply || availableActions.length > 0;\n\n return (\n <div\n key={chatIdentifierString(message.id)}\n className={`cratis-chat-message${showAuthor ? '' : ' cratis-chat-message--continuation'}`}\n >\n {showAuthor && (\n <div className='cratis-chat-message__author'>\n {renderAvatar ? (\n renderAvatar(message.authorId, author)\n ) : (\n <PersonAvatarCircle\n userId={chatIdentifierString(\n message.authorId,\n )}\n name={author.name}\n hasAvatar={author.hasAvatar ?? false}\n size={22}\n ownerType={\n author.kind === ChatAuthorKind.Agent\n ? 'Agents'\n : 'Users'\n }\n version={author.avatarVersion}\n buildAvatarUrl={buildAvatarUrl}\n />\n )}\n <span className='cratis-chat-message__author-name'>\n {renderAuthorName\n ? renderAuthorName(message.authorId, author)\n : author.name}\n </span>\n </div>\n )}\n <div className='cratis-chat-message__content'>\n <div\n className={`cratis-chat-message__panel${showActionsRow ? ' cratis-chat-message__panel--with-actions' : ''}`}\n >\n <ChatMessageBody\n body={message.body}\n mentions={message.mentions}\n />\n {showActionsRow && (\n <div className='cratis-chat-message__actions'>\n {quickReply && (\n <button\n type='button'\n className='cratis-chat-message__action'\n title={(\n labels?.quickReplyTo ??\n 'Reply to {name}'\n ).replace('{name}', author.name)}\n aria-label={(\n labels?.quickReplyTo ??\n 'Reply to {name}'\n ).replace('{name}', author.name)}\n onClick={() =>\n quickReplyTo(author.name)\n }\n >\n <ReplyIcon />\n </button>\n )}\n {availableActions.map((action) => (\n <button\n key={action.id}\n type='button'\n className='cratis-chat-message__action'\n title={action.label}\n aria-label={action.label}\n onClick={() =>\n action.onInvoke(message)\n }\n >\n {typeof action.icon === 'string' ? (\n <i\n className={action.icon}\n aria-hidden='true'\n />\n ) : (\n action.icon\n )}\n </button>\n ))}\n </div>\n )}\n </div>\n {renderMessageExtra?.(message)}\n {showTimestamp && (\n <span className='cratis-chat-message__time'>\n {relativeTimestamp(\n timestampOf(message),\n new Date(),\n labels?.timestamps,\n )}\n </span>\n )}\n </div>\n </div>\n );\n })}\n {status !== ChatStatus.Unauthorized && (\n <TypingIndicator\n authors={typingAuthors}\n label={typingLabel(typingAuthors, labels)}\n buildAvatarUrl={buildAvatarUrl}\n />\n )}\n <div ref={messagesEndRef} />\n </div>\n\n <ChatComposer\n ref={composerRef}\n mentionCandidates={mentionCandidates}\n resolveMentionCandidates={resolveMentionCandidates}\n onSend={send}\n disabled={status === ChatStatus.Unauthorized}\n autoFocus={autoFocus}\n buildAvatarUrl={buildAvatarUrl}\n labels={labels?.composer}\n />\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;AAuBA,MAAM,SAAS,GAAG,OACdA,IAAA,CAAA,KAAA,EAAA,EACI,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EAAA,aAAA,EACL,MAAM,aAElBC,GAAA,CAAA,UAAA,EAAA,EAAU,MAAM,EAAC,eAAe,EAAA,CAAG,EACnCA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,0BAA0B,EAAA,CAAG,CAAA,EAAA,CACnC,CACT;AAkID,MAAM,WAAW,GAAG,CAAC,OAAoB,KACrC,OAAO,CAAC,SAAS,YAAY,IAAI,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;AAEvF,MAAM,UAAU,GAAG,CAAC,IAAU,EAAE,KAAW,KACvC,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE;AAC1C,IAAA,IAAI,CAA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MAAM,EAAE,QAAQ,EAAA,CAC1B,CAAA,EAAA,CACA;AAEd;;"}
1
+ {"version":3,"file":"ChatConversation.js","sources":["../../../Chat/ChatConversation.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useMemo, useRef, type ReactNode } from 'react';\nimport { PersonAvatarCircle, type BuildAvatarUrlParams } from './Kit/Avatar';\nimport { ChatAuthorKind } from './Kit/ChatAuthorKind';\nimport {\n ChatComposer,\n type ChatComposerHandle,\n type ChatComposerLabels,\n} from './Kit/ChatComposer';\nimport type { ChatTypingAuthor } from './Kit/ChatTypingAuthor';\nimport type { MentionCandidate } from './Kit/Mentions';\nimport { TypingIndicator } from './Kit/TypingIndicator';\nimport type { ChatAuthor } from './ChatAuthor';\nimport { chatIdentifierString, type ChatIdentifier } from './ChatIdentifier';\nimport type { ChatMention } from './ChatMention';\nimport type { ChatMessage } from './ChatMessage';\nimport { ChatStatus } from './ChatStatus';\nimport type { ChatMessageAction } from './ChatMessageAction';\nimport { ChatMessageBody } from './ChatMessageBody';\nimport { relativeTimestamp, type RelativeTimestampLabels } from './relativeTimestamp';\n\nconst ReplyIcon = () => (\n <svg\n width='14'\n height='14'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2.5'\n aria-hidden='true'\n >\n <polyline points='9 17 4 12 9 7' />\n <path d='M4 12h10a6 6 0 0 1 6 6v1' />\n </svg>\n);\n\n/** Overrides for every label the {@link ChatConversation} renders. Any field left unset falls\n * back to a literal English default — this library ships no i18n mechanism of its own, so a host\n * that localizes passes its own translated strings through here. */\nexport interface ChatConversationLabels {\n /** Shown while loading without messages. Defaults to `'Loading messages…'`. */\n loading?: string;\n\n /** Shown when loading messages fails, alongside any existing messages. Defaults to `'Could not load messages.'`. */\n failed?: string;\n\n /** Shown when access is denied; replaces any existing messages. Defaults to `'You are not authorized to view these messages.'`. */\n unauthorized?: string;\n\n /** Shown when there are no messages yet. Defaults to `'No messages yet. Say hello!'`. */\n empty?: string;\n\n /** One author typing. `{name}` is substituted. Defaults to `'{name} is typing'`. */\n typing?: string;\n\n /** Two authors typing. `{first}`/`{second}` are substituted. Defaults to `'{first} and {second} are typing'`. */\n typingTwo?: string;\n\n /** Three or more authors typing. Defaults to `'Several people are typing'`. */\n typingSeveral?: string;\n\n /** Tooltip/accessible label for the quick-reply button. `{name}` is substituted. Defaults to `'Reply to {name}'`. */\n quickReplyTo?: string;\n\n /** Overrides for the relative timestamps next to messages. */\n timestamps?: RelativeTimestampLabels;\n\n /** Labels forwarded to the composer. */\n composer?: ChatComposerLabels;\n}\n\n/**\n * Props for {@link ChatConversation}.\n * @typeParam TMessage The host's message type — anything extending {@link ChatMessage}.\n */\nexport interface ChatConversationProps<TMessage extends ChatMessage = ChatMessage> {\n /**\n * The messages of the conversation, rendered in the order given. Hand this the array a live\n * (observable) query delivers and the conversation re-renders as it changes.\n */\n messages: TMessage[];\n\n /** Query display state. Defaults to {@link ChatStatus.Ready}; existing messages remain visible on loading or failure, and unauthorized disables the composer. */\n status?: ChatStatus;\n\n /**\n * Invoked when a message is sent, with the trimmed body and who it mentions. Everything else\n * about persisting the message is the host's business.\n * @param body The message text, mentions written into it as plain `@Name`.\n * @param mentions Who the body mentions.\n */\n onSendMessage: (body: string, mentions: ChatMention[]) => void;\n\n /**\n * Resolves an author id into what it takes to render them — name, kind, whether an avatar\n * image exists. Messages deliberately carry only the id; this is where the rest comes from.\n * Omit to fall back to rendering the id itself as the name.\n * @param authorId The identifier of the author to resolve.\n * @returns The author.\n */\n authorOf?: (authorId: ChatIdentifier) => ChatAuthor;\n\n /**\n * Renders the avatar for an author, replacing the built-in initials circle entirely.\n * @param authorId The identifier of the author.\n * @param author The resolved author, as {@link authorOf} answered.\n * @returns What to render.\n */\n renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n\n /**\n * Renders the display name for an author, replacing the built-in name text entirely.\n * @param authorId The identifier of the author.\n * @param author The resolved author, as {@link authorOf} answered.\n * @returns What to render.\n */\n renderAuthorName?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n\n /**\n * Renders host content under a message's body, for example reactions or a failed-reply notice.\n * Nothing extra is rendered when it returns null or undefined.\n * @param message The message being rendered.\n * @returns What to render under the message body.\n */\n renderMessageExtra?: (message: TMessage) => ReactNode;\n\n /** The host's own actions, offered as buttons on every message each is available for. */\n actions?: ChatMessageAction<TMessage>[];\n\n /** Everyone who can be mentioned, when the host already holds the list. Omit (together with\n * {@link resolveMentionCandidates}) to turn mentions off. */\n mentionCandidates?: MentionCandidate[];\n\n /**\n * Resolves who can be mentioned as the person types, invoked with what has been typed after\n * the `@`. May answer synchronously or with a promise.\n * @param query What has been typed after the `@`.\n * @returns The candidates matching the query.\n */\n resolveMentionCandidates?: (\n query: string,\n ) => MentionCandidate[] | Promise<MentionCandidate[]>;\n\n /** Who the conversation is currently waiting on — someone typing, or an agent working. */\n typingAuthors?: ChatTypingAuthor[];\n\n /** Whether the quick-reply affordance (prefill the composer with `@Name`) is offered on\n * messages. Defaults to true. */\n quickReply?: boolean;\n\n /** Builds the avatar image URL for every author shown. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Whether the composer takes focus when mounted. */\n autoFocus?: boolean;\n\n /** Overrides for every label rendered. Unset fields fall back to literal English defaults. */\n labels?: ChatConversationLabels;\n\n /** Additional class name for the conversation's root element. */\n className?: string;\n}\n\n/** The message's timestamp as a `Date` — data that traveled through JSON may carry it as a string. */\nconst timestampOf = (message: ChatMessage): Date =>\n message.timestamp instanceof Date ? message.timestamp : new Date(message.timestamp);\n\nconst sameMinute = (left: Date, right: Date): boolean =>\n left.getFullYear() === right.getFullYear() &&\n left.getMonth() === right.getMonth() &&\n left.getDate() === right.getDate() &&\n left.getHours() === right.getHours() &&\n left.getMinutes() === right.getMinutes();\n\ninterface MessageRenderInfo {\n /** Whether to show the author row — false for a continuation by the same author. */\n showAuthor: boolean;\n\n /** Whether to show the timestamp — false when the next message continues the same minute. */\n showTimestamp: boolean;\n}\n\nconst computeRenderInfo = (messages: ChatMessage[]): MessageRenderInfo[] =>\n messages.map((message, index) => {\n const previous = index > 0 ? messages[index - 1] : undefined;\n const next = index < messages.length - 1 ? messages[index + 1] : undefined;\n\n const showAuthor =\n !previous ||\n chatIdentifierString(previous.authorId) !==\n chatIdentifierString(message.authorId);\n const showTimestamp =\n !next ||\n chatIdentifierString(next.authorId) !==\n chatIdentifierString(message.authorId) ||\n !sameMinute(timestampOf(message), timestampOf(next));\n\n return { showAuthor, showTimestamp };\n });\n\n/**\n * Composes the \"X is typing\" line from whoever the conversation is waiting on.\n * @param authors The authors currently typing or working.\n * @param labels Label overrides, as passed to {@link ChatConversation}.\n * @returns The label to show, empty when nobody is.\n */\nconst typingLabel = (\n authors: ChatTypingAuthor[],\n labels: ChatConversationLabels | undefined,\n): string => {\n if (authors.length === 0) return '';\n if (authors.length === 1)\n return (labels?.typing ?? '{name} is typing').replace('{name}', authors[0].name);\n if (authors.length === 2)\n return (labels?.typingTwo ?? '{first} and {second} are typing')\n .replace('{first}', authors[0].name)\n .replace('{second}', authors[1].name);\n return labels?.typingSeveral ?? 'Several people are typing';\n};\n\nconst conversationStatusLabel = (\n status: ChatStatus,\n labels: ChatConversationLabels | undefined,\n) => {\n switch (status) {\n case ChatStatus.Loading:\n return <span key={status} role='status'>{labels?.loading ?? 'Loading messages…'}</span>;\n case ChatStatus.Failed:\n return <span key={status} role='alert'>{labels?.failed ?? 'Could not load messages.'}</span>;\n case ChatStatus.Unauthorized:\n return <span key={status} role='alert'>{labels?.unauthorized ?? 'You are not authorized to view these messages.'}</span>;\n default:\n return labels?.empty ?? 'No messages yet. Say hello!';\n }\n};\n\nconst renderConversationStatus = (\n messageCount: number,\n status: ChatStatus,\n labels: ChatConversationLabels | undefined,\n) => {\n if (messageCount > 0 && status !== ChatStatus.Failed && status !== ChatStatus.Unauthorized) return null;\n return (\n <p className='cratis-chat-conversation__empty'>\n {conversationStatusLabel(status, labels)}\n </p>\n );\n};\n\ninterface ConversationMessageProps<TMessage extends ChatMessage> extends Pick<ChatConversationProps<TMessage>,\n 'renderAvatar' | 'renderAuthorName' | 'renderMessageExtra' | 'buildAvatarUrl' | 'labels'> {\n message: TMessage;\n author: ChatAuthor;\n info: MessageRenderInfo;\n availableActions: ChatMessageAction<TMessage>[];\n quickReply: boolean;\n onQuickReply: (name: string) => void;\n}\n\nconst renderMessageAuthor = (\n message: ChatMessage,\n author: ChatAuthor,\n { renderAvatar, renderAuthorName, buildAvatarUrl }: Pick<ChatConversationProps, 'renderAvatar' | 'renderAuthorName' | 'buildAvatarUrl'>,\n) => (\n <div className='cratis-chat-message__author'>\n {renderAvatar ? (\n renderAvatar(message.authorId, author)\n ) : (\n <PersonAvatarCircle\n userId={chatIdentifierString(message.authorId)}\n name={author.name}\n hasAvatar={author.hasAvatar ?? false}\n size={22}\n ownerType={author.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users'}\n version={author.avatarVersion}\n buildAvatarUrl={buildAvatarUrl}\n />\n )}\n <span className='cratis-chat-message__author-name'>\n {renderAuthorName ? renderAuthorName(message.authorId, author) : author.name}\n </span>\n </div>\n);\n\nconst renderMessageActions = <TMessage extends ChatMessage>({\n message, author, availableActions, quickReply, labels, onQuickReply,\n}: Pick<ConversationMessageProps<TMessage>, 'message' | 'author' | 'availableActions' | 'quickReply' | 'labels' | 'onQuickReply'>) => (\n <div className='cratis-chat-message__actions'>\n {quickReply && (\n <button\n type='button'\n className='cratis-chat-message__action'\n title={(labels?.quickReplyTo ?? 'Reply to {name}').replace('{name}', author.name)}\n aria-label={(labels?.quickReplyTo ?? 'Reply to {name}').replace('{name}', author.name)}\n onClick={() => onQuickReply(author.name)}\n >\n <ReplyIcon />\n </button>\n )}\n {availableActions.map((action) => (\n <button\n key={action.id}\n type='button'\n className='cratis-chat-message__action'\n title={action.label}\n aria-label={action.label}\n onClick={() => action.onInvoke(message)}\n >\n {typeof action.icon === 'string' ? <i className={action.icon} aria-hidden='true' /> : action.icon}\n </button>\n ))}\n </div>\n);\n\nconst renderConversationMessage = <TMessage extends ChatMessage>(props: ConversationMessageProps<TMessage>) => {\n const { message, author, info: { showAuthor, showTimestamp }, availableActions, quickReply, renderMessageExtra, labels } = props;\n const showActionsRow = quickReply || availableActions.length > 0;\n\n return (\n <div\n key={chatIdentifierString(message.id)}\n className={`cratis-chat-message${showAuthor ? '' : ' cratis-chat-message--continuation'}`}\n >\n {showAuthor && renderMessageAuthor(message, author, props)}\n <div className='cratis-chat-message__content'>\n <div className={`cratis-chat-message__panel${showActionsRow ? ' cratis-chat-message__panel--with-actions' : ''}`}>\n <ChatMessageBody body={message.body} mentions={message.mentions} />\n {showActionsRow && renderMessageActions(props)}\n </div>\n {renderMessageExtra?.(message)}\n {showTimestamp && (\n <span className='cratis-chat-message__time'>\n {relativeTimestamp(timestampOf(message), new Date(), labels?.timestamps)}\n </span>\n )}\n </div>\n </div>\n );\n};\n\n/**\n * One conversation — its messages and the composer to add to them. Host-agnostic by design: it\n * renders whatever message array it is given (hand it a live query's data and it stays current),\n * resolves authors through the host's {@link ChatConversationProps.authorOf | authorOf} and\n * render callbacks, offers the host's own {@link ChatConversationProps.actions | actions} on\n * each message, and reports sends back through\n * {@link ChatConversationProps.onSendMessage | onSendMessage} without any opinion about the\n * backend behind it. Mentions and the emoji picker come along through the composer.\n */\nexport const ChatConversation = <TMessage extends ChatMessage = ChatMessage>({\n messages,\n status = ChatStatus.Ready,\n onSendMessage,\n authorOf,\n renderAvatar,\n renderAuthorName,\n renderMessageExtra,\n actions,\n mentionCandidates,\n resolveMentionCandidates,\n typingAuthors = [],\n quickReply = true,\n buildAvatarUrl,\n autoFocus = false,\n labels,\n className,\n}: ChatConversationProps<TMessage>) => {\n const composerRef = useRef<ChatComposerHandle>(null);\n const messagesEndRef = useRef<HTMLDivElement>(null);\n const renderInfo = useMemo(() => computeRenderInfo(messages), [messages]);\n\n useEffect(() => {\n messagesEndRef.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n }, [messages, typingAuthors.length]);\n\n const authorFor = (authorId: ChatIdentifier): ChatAuthor =>\n authorOf?.(authorId) ?? {\n name: chatIdentifierString(authorId),\n kind: ChatAuthorKind.User,\n };\n\n const send = (text: string, mentioned: MentionCandidate[]) =>\n onSendMessage(\n text,\n mentioned.map(\n (candidate) =>\n ({\n id: candidate.id,\n name: candidate.name,\n kind: candidate.kind,\n }) satisfies ChatMention,\n ),\n );\n\n const quickReplyTo = (name: string) => composerRef.current?.prefill(`@${name} `);\n\n return (\n <div className={`cratis-chat-conversation${className ? ` ${className}` : ''}`} data-cratis-component='ChatConversation'>\n <div className='cratis-chat-conversation__messages' aria-busy={status === ChatStatus.Loading && messages.length > 0 || undefined}>\n {renderConversationStatus(messages.length, status, labels)}\n {status !== ChatStatus.Unauthorized && messages.map((message, index) => {\n const author = authorFor(message.authorId);\n const availableActions = (actions ?? []).filter(\n (action) => action.isAvailable?.(message) ?? true,\n );\n return renderConversationMessage({\n message,\n author,\n info: renderInfo[index],\n availableActions,\n quickReply,\n onQuickReply: quickReplyTo,\n renderAvatar,\n renderAuthorName,\n renderMessageExtra,\n buildAvatarUrl,\n labels,\n });\n })}\n {status !== ChatStatus.Unauthorized && (\n <TypingIndicator\n authors={typingAuthors}\n label={typingLabel(typingAuthors, labels)}\n buildAvatarUrl={buildAvatarUrl}\n />\n )}\n <div ref={messagesEndRef} />\n </div>\n\n <ChatComposer\n ref={composerRef}\n mentionCandidates={mentionCandidates}\n resolveMentionCandidates={resolveMentionCandidates}\n onSend={send}\n disabled={status === ChatStatus.Unauthorized}\n autoFocus={autoFocus}\n buildAvatarUrl={buildAvatarUrl}\n labels={labels?.composer}\n />\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;AAuBA,MAAM,SAAS,GAAG,OACdA,IAAA,CAAA,KAAA,EAAA,EACI,KAAK,EAAC,IAAI,E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K,UAAU,CAAC,YAAY,KAC/BC,GAAA,CAAC,eAAe,EAAA,EACZ,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,WAAW,CAAC,aAAa,EAAE,MAAM,CAAC,EACzC,cAAc,EAAE,cAAc,EAAA,CAChC,CACL,EACDA,aAAK,GAAG,EAAE,cAAc,EAAA,CAAI,CAAA,EAAA,CAC1B,EAENA,GAAA,CAAC,YAAY,EAAA,EACT,GAAG,EAAE,WAAW,EAChB,iBAAiB,EAAE,iBAAiB,EACpC,wBAAwB,EAAE,wBAAwB,EAClD,MAAM,EAAE,IAAI,EACZ,QAAQ,EAAE,MAAM,KAAK,UAAU,CAAC,YAAY,EAC5C,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAA,CAC1B,CAAA,EAAA,CACA;AAEd;;"}
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import './Kit/ChatAuthorKind.js';
4
4
  import { mentionSegments } from './Kit/Mentions/mentionSegments.js';
5
5
 
6
- const ChatMessageBody = ({ body, mentions }) => (jsx("p", { className: 'cratis-chat-message__body', children: mentionSegments(body, mentions ?? []).map((segment, index) => segment.mention ? (jsx("span", { className: 'cratis-chat-message__mention', "data-kind": segment.mention.kind, children: segment.text }, index)) : (jsx(React.Fragment, { children: segment.text }, index))) }));
6
+ const ChatMessageBody = ({ body, mentions }) => (jsx("p", { className: 'cratis-chat-message__body', "data-cratis-component": 'ChatMessageBody', children: mentionSegments(body, mentions ?? []).map((segment, index) => segment.mention ? (jsx("span", { className: 'cratis-chat-message__mention', "data-kind": segment.mention.kind, children: segment.text }, index)) : (jsx(React.Fragment, { children: segment.text }, index))) }));
7
7
 
8
8
  export { ChatMessageBody };
9
9
  //# sourceMappingURL=ChatMessageBody.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatMessageBody.js","sources":["../../../Chat/ChatMessageBody.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React from 'react';\nimport { mentionSegments } from './Kit/Mentions';\nimport type { ChatMention } from './ChatMention';\n\n/**\n * Props for {@link ChatMessageBody}.\n */\nexport interface ChatMessageBodyProps {\n /** The message text. Mentions appear in it as plain `@Name` text. */\n body: string;\n\n /** Who the body mentions — these render distinctly. Omit for a body with no mentions. */\n mentions?: ChatMention[];\n}\n\n/**\n * The text of one message. The body itself is plain text — including its `@Name` mentions — and\n * this component is what makes the mentions *look* like mentions: each known one renders as its\n * own element, marked with who it addresses, so a person and an agent mention can be styled\n * apart and the host's own CSS can hang further behavior off them.\n */\nexport const ChatMessageBody = ({ body, mentions }: ChatMessageBodyProps) => (\n <p className='cratis-chat-message__body'>\n {mentionSegments(body, mentions ?? []).map((segment, index) =>\n segment.mention ? (\n <span\n key={index}\n className='cratis-chat-message__mention'\n data-kind={segment.mention.kind}\n >\n {segment.text}\n </span>\n ) : (\n <React.Fragment key={index}>{segment.text}</React.Fragment>\n ),\n )}\n </p>\n);\n"],"names":["_jsx"],"mappings":";;;;;AAwBO,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAwB,MACpEA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,2BAA2B,EAAA,QAAA,EACnC,eAAe,CAAC,IAAI,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,KACtD,OAAO,CAAC,OAAO,IACXA,GAAA,CAAA,MAAA,EAAA,EAEI,SAAS,EAAC,8BAA8B,EAAA,WAAA,EAC7B,OAAO,CAAC,OAAO,CAAC,IAAI,EAAA,QAAA,EAE9B,OAAO,CAAC,IAAI,IAJR,KAAK,CAKP,KAEPA,IAAC,KAAK,CAAC,QAAQ,EAAA,EAAA,QAAA,EAAc,OAAO,CAAC,IAAI,IAApB,KAAK,CAAiC,CAC9D,CACJ,EAAA,CACD;;"}
1
+ {"version":3,"file":"ChatMessageBody.js","sources":["../../../Chat/ChatMessageBody.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React from 'react';\nimport { mentionSegments } from './Kit/Mentions';\nimport type { ChatMention } from './ChatMention';\n\n/**\n * Props for {@link ChatMessageBody}.\n */\nexport interface ChatMessageBodyProps {\n /** The message text. Mentions appear in it as plain `@Name` text. */\n body: string;\n\n /** Who the body mentions — these render distinctly. Omit for a body with no mentions. */\n mentions?: ChatMention[];\n}\n\n/**\n * The text of one message. The body itself is plain text — including its `@Name` mentions — and\n * this component is what makes the mentions *look* like mentions: each known one renders as its\n * own element, marked with who it addresses, so a person and an agent mention can be styled\n * apart and the host's own CSS can hang further behavior off them.\n */\nexport const ChatMessageBody = ({ body, mentions }: ChatMessageBodyProps) => (\n <p className='cratis-chat-message__body' data-cratis-component='ChatMessageBody'>\n {mentionSegments(body, mentions ?? []).map((segment, index) =>\n segment.mention ? (\n <span\n key={index}\n className='cratis-chat-message__mention'\n data-kind={segment.mention.kind}\n >\n {segment.text}\n </span>\n ) : (\n <React.Fragment key={index}>{segment.text}</React.Fragment>\n ),\n )}\n </p>\n);\n"],"names":["_jsx"],"mappings":";;;;;AAwBO,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAwB,MACpEA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,2BAA2B,EAAA,uBAAA,EAAuB,iBAAiB,EAAA,QAAA,EAC3E,eAAe,CAAC,IAAI,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,KACtD,OAAO,CAAC,OAAO,IACXA,cAEI,SAAS,EAAC,8BAA8B,EAAA,WAAA,EAC7B,OAAO,CAAC,OAAO,CAAC,IAAI,EAAA,QAAA,EAE9B,OAAO,CAAC,IAAI,IAJR,KAAK,CAKP,KAEPA,IAAC,KAAK,CAAC,QAAQ,EAAA,EAAA,QAAA,EAAc,OAAO,CAAC,IAAI,IAApB,KAAK,CAAiC,CAC9D,CACJ,EAAA,CACD;;"}
@@ -20,7 +20,7 @@ const ChatTopicList = ({ topics, status = ChatStatus.Ready, onOpen, onStart, aut
20
20
  kind: ChatAuthorKind.User,
21
21
  };
22
22
  const showMessage = topics.length === 0 || status === ChatStatus.Failed || status === ChatStatus.Unauthorized;
23
- return (jsxs("div", { className: `cratis-chat-topics${className ? ` ${className}` : ''}`, "aria-busy": status === ChatStatus.Loading && topics.length > 0 || undefined, children: [onStart && jsx(ChatTopicStartButton, { label: labels?.newTopic, disabled: status === ChatStatus.Unauthorized, onStart: onStart }), showMessage && jsx(ChatTopicEmptyMessage, { status: status, labels: labels }), jsx("ul", { ref: listRef, className: 'cratis-chat-topics__list', children: orderedTopics.map((topic) => (jsx(ChatTopicRow, { topic: topic, isPending: unnamed(topic), starter: topic.startedBy === undefined ? undefined : authorFor(topic.startedBy), labels: labels, availableActions: (topicActions ?? []).filter((action) => action.isAvailable?.(topic) ?? true), onOpen: onOpen, renderAvatar: renderAvatar, buildAvatarUrl: buildAvatarUrl, onActionFocus: onActionFocus, onActionBlur: onActionBlur }, chatIdentifierString(topic.id)))) })] }));
23
+ return (jsxs("div", { className: `cratis-chat-topics${className ? ` ${className}` : ''}`, "data-cratis-component": 'ChatTopicList', "aria-busy": status === ChatStatus.Loading && topics.length > 0 || undefined, children: [onStart && jsx(ChatTopicStartButton, { label: labels?.newTopic, disabled: status === ChatStatus.Unauthorized, onStart: onStart }), showMessage && jsx(ChatTopicEmptyMessage, { status: status, labels: labels }), jsx("ul", { ref: listRef, className: 'cratis-chat-topics__list', children: orderedTopics.map((topic) => (jsx(ChatTopicRow, { topic: topic, isPending: unnamed(topic), starter: topic.startedBy === undefined ? undefined : authorFor(topic.startedBy), labels: labels, availableActions: (topicActions ?? []).filter((action) => action.isAvailable?.(topic) ?? true), onOpen: onOpen, renderAvatar: renderAvatar, buildAvatarUrl: buildAvatarUrl, onActionFocus: onActionFocus, onActionBlur: onActionBlur }, chatIdentifierString(topic.id)))) })] }));
24
24
  };
25
25
 
26
26
  export { ChatTopicList };
@@ -1 +1 @@
1
- {"version":3,"file":"ChatTopicList.js","sources":["../../../Chat/ChatTopicList.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useRef, type ReactNode } from 'react';\nimport type { BuildAvatarUrlParams } from './Kit/Avatar';\nimport { ChatAuthorKind } from './Kit/ChatAuthorKind';\nimport type { ChatAuthor } from './ChatAuthor';\nimport { chatIdentifierString, type ChatIdentifier } from './ChatIdentifier';\nimport type { ChatTopic } from './ChatTopic';\nimport type { ChatTopicAction } from './ChatTopicAction';\nimport { ChatTopicEmptyMessage } from './ChatTopicEmptyMessage';\nimport { ChatTopicRow } from './ChatTopicRow';\nimport { ChatTopicStartButton } from './ChatTopicStartButton';\nimport { ChatStatus } from './ChatStatus';\nimport { isTopicUnnamed as defaultIsTopicUnnamed } from './isTopicUnnamed';\nimport type { RelativeTimestampLabels } from './relativeTimestamp';\nimport { useTopicActionFocusRecovery } from './useTopicActionFocusRecovery';\nimport { topicsByActivity } from './topicsByActivity';\n\n/** Overrides for every label the {@link ChatTopicList} renders. Any field left unset falls back\n * to a literal English default. */\nexport interface ChatTopicListLabels {\n /** The new-topic button. Defaults to `'New topic'`. */\n newTopic?: string;\n\n /** Placeholder name for a topic that has not been named yet. Defaults to `'New topic'`. */\n unnamedTopic?: string;\n\n /** The started-by line under a topic's name. `{name}` is substituted. Defaults to `'Started by {name}'`. */\n startedBy?: string;\n\n /** Shown while loading without topics. Defaults to `'Loading topics…'`. */\n loading?: string;\n\n /** Shown when loading topics fails, alongside any existing topics. Defaults to `'Could not load topics.'`. */\n failed?: string;\n\n /** Shown when access is denied; replaces any existing topics. Defaults to `'You are not authorized to view these topics.'`. */\n unauthorized?: string;\n\n /** Shown when there are no topics yet. Defaults to `'No topics yet. Start the first one!'`. */\n empty?: string;\n\n /** Overrides for the relative last-activity timestamps. */\n timestamps?: RelativeTimestampLabels;\n}\n\n/**\n * Props for {@link ChatTopicList}.\n * @typeParam TTopic The host's topic type — anything extending {@link ChatTopic}.\n */\nexport interface ChatTopicListProps<TTopic extends ChatTopic = ChatTopic> {\n /**\n * The topics, in any order — the list orders them by most recent activity itself. Hand this\n * the array a live (observable) query delivers and the list re-renders as it changes.\n */\n topics: TTopic[];\n\n /** Query display state. Defaults to {@link ChatStatus.Ready}; existing topics remain visible on loading or failure, and unauthorized disables starting a topic. */\n status?: ChatStatus;\n\n /**\n * Invoked when a topic is picked from the list.\n * @param topic The topic that was picked.\n */\n onOpen: (topic: TTopic) => void;\n\n /**\n * Invoked when a new topic is asked for. Creating the topic is the host's business — the\n * component only raises the intent. Omit to leave the new-topic affordance off.\n */\n onStart?: () => void;\n\n /**\n * Resolves an author id into what it takes to render whoever started a topic. Omit to fall\n * back to rendering the id itself as the name.\n * @param authorId The identifier of the author to resolve.\n * @returns The author.\n */\n authorOf?: (authorId: ChatIdentifier) => ChatAuthor;\n\n /**\n * Renders the avatar for whoever started a topic, replacing the built-in initials circle.\n * @param authorId The identifier of the author.\n * @param author The resolved author, as {@link authorOf} answered.\n * @returns What to render.\n */\n renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n\n /**\n * Decides whether a topic counts as unnamed and renders the pending placeholder. Defaults to\n * \"no name, or only whitespace\" — override when the host's backend stores a literal\n * placeholder for unnamed topics instead.\n * @param topic The topic to check.\n * @returns True when the topic has no usable name yet.\n */\n isTopicUnnamed?: (topic: TTopic) => boolean;\n\n /** Builds the avatar image URL for topic starters. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Overrides for every label rendered. Unset fields fall back to literal English defaults. */\n labels?: ChatTopicListLabels;\n\n /** The host's actions to offer on each topic where they are available. */\n topicActions?: ChatTopicAction<TTopic>[];\n\n /** Additional class name for the list's root element. */\n className?: string;\n}\n\n/**\n * The topics of a chat, most recently active first — pick one to open its conversation, or start\n * a new one. A topic that has not been named yet renders a placeholder in a pending style: with\n * host-side auto-naming, the name arrives through the data once the host has produced it, and\n * the placeholder simply stops being needed.\n */\nexport const ChatTopicList = <TTopic extends ChatTopic = ChatTopic>({\n topics,\n status = ChatStatus.Ready,\n onOpen,\n onStart,\n authorOf,\n renderAvatar,\n isTopicUnnamed,\n buildAvatarUrl,\n labels,\n topicActions,\n className,\n}: ChatTopicListProps<TTopic>) => {\n const unnamed = isTopicUnnamed ?? defaultIsTopicUnnamed;\n const listRef = useRef<HTMLUListElement>(null);\n const orderedTopics = status === ChatStatus.Unauthorized ? [] : topicsByActivity(topics);\n const { onActionFocus, onActionBlur } = useTopicActionFocusRecovery(\n listRef,\n orderedTopics.map((topic) => chatIdentifierString(topic.id)),\n );\n\n const authorFor = (authorId: ChatIdentifier): ChatAuthor =>\n authorOf?.(authorId) ?? {\n name: chatIdentifierString(authorId),\n kind: ChatAuthorKind.User,\n };\n\n const showMessage = topics.length === 0 || status === ChatStatus.Failed || status === ChatStatus.Unauthorized;\n\n return (\n <div className={`cratis-chat-topics${className ? ` ${className}` : ''}`} aria-busy={status === ChatStatus.Loading && topics.length > 0 || undefined}>\n {onStart && <ChatTopicStartButton label={labels?.newTopic} disabled={status === ChatStatus.Unauthorized} onStart={onStart} />}\n {showMessage && <ChatTopicEmptyMessage status={status} labels={labels} />}\n <ul ref={listRef} className='cratis-chat-topics__list'>\n {orderedTopics.map((topic) => (\n <ChatTopicRow<TTopic>\n key={chatIdentifierString(topic.id)}\n topic={topic}\n isPending={unnamed(topic)}\n starter={topic.startedBy === undefined ? undefined : authorFor(topic.startedBy)}\n labels={labels}\n availableActions={(topicActions ?? []).filter((action) => action.isAvailable?.(topic) ?? true)}\n onOpen={onOpen}\n renderAvatar={renderAvatar}\n buildAvatarUrl={buildAvatarUrl}\n onActionFocus={onActionFocus}\n onActionBlur={onActionBlur}\n />\n ))}\n </ul>\n </div>\n );\n};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AAIC,GAAA,CAAC,oBAAoB,IAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,KAAK,UAAU,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,GAAI,EAC5H,WAAW,IAAIA,GAAA,CAAC,qBAAqB,IAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAA,CAAI,EACzEA,GAAA,CAAA,IAAA,EAAA,EAAI,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,0BAA0B,YACjD,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,MACrBA,GAAA,CAAC,YAAY,EAAA,EAET,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,EACzB,OAAO,EAAE,KAAK,CAAC,SAAS,KAAK,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,EAC/E,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,CAAC,YAAY,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,EAC9F,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,IAVrB,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC,CAWrC,CACL,CAAC,EAAA,CACD,CAAA,EAAA,CACH;AAEd;;"}
1
+ {"version":3,"file":"ChatTopicList.js","sources":["../../../Chat/ChatTopicList.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useRef, type ReactNode } from 'react';\nimport type { BuildAvatarUrlParams } from './Kit/Avatar';\nimport { ChatAuthorKind } from './Kit/ChatAuthorKind';\nimport type { ChatAuthor } from './ChatAuthor';\nimport { chatIdentifierString, type ChatIdentifier } from './ChatIdentifier';\nimport type { ChatTopic } from './ChatTopic';\nimport type { ChatTopicAction } from './ChatTopicAction';\nimport { ChatTopicEmptyMessage } from './ChatTopicEmptyMessage';\nimport { ChatTopicRow } from './ChatTopicRow';\nimport { ChatTopicStartButton } from './ChatTopicStartButton';\nimport { ChatStatus } from './ChatStatus';\nimport { isTopicUnnamed as defaultIsTopicUnnamed } from './isTopicUnnamed';\nimport type { RelativeTimestampLabels } from './relativeTimestamp';\nimport { useTopicActionFocusRecovery } from './useTopicActionFocusRecovery';\nimport { topicsByActivity } from './topicsByActivity';\n\n/** Overrides for every label the {@link ChatTopicList} renders. Any field left unset falls back\n * to a literal English default. */\nexport interface ChatTopicListLabels {\n /** The new-topic button. Defaults to `'New topic'`. */\n newTopic?: string;\n\n /** Placeholder name for a topic that has not been named yet. Defaults to `'New topic'`. */\n unnamedTopic?: string;\n\n /** The started-by line under a topic's name. `{name}` is substituted. Defaults to `'Started by {name}'`. */\n startedBy?: string;\n\n /** Shown while loading without topics. Defaults to `'Loading topics…'`. */\n loading?: string;\n\n /** Shown when loading topics fails, alongside any existing topics. Defaults to `'Could not load topics.'`. */\n failed?: string;\n\n /** Shown when access is denied; replaces any existing topics. Defaults to `'You are not authorized to view these topics.'`. */\n unauthorized?: string;\n\n /** Shown when there are no topics yet. Defaults to `'No topics yet. Start the first one!'`. */\n empty?: string;\n\n /** Overrides for the relative last-activity timestamps. */\n timestamps?: RelativeTimestampLabels;\n}\n\n/**\n * Props for {@link ChatTopicList}.\n * @typeParam TTopic The host's topic type — anything extending {@link ChatTopic}.\n */\nexport interface ChatTopicListProps<TTopic extends ChatTopic = ChatTopic> {\n /**\n * The topics, in any order — the list orders them by most recent activity itself. Hand this\n * the array a live (observable) query delivers and the list re-renders as it changes.\n */\n topics: TTopic[];\n\n /** Query display state. Defaults to {@link ChatStatus.Ready}; existing topics remain visible on loading or failure, and unauthorized disables starting a topic. */\n status?: ChatStatus;\n\n /**\n * Invoked when a topic is picked from the list.\n * @param topic The topic that was picked.\n */\n onOpen: (topic: TTopic) => void;\n\n /**\n * Invoked when a new topic is asked for. Creating the topic is the host's business — the\n * component only raises the intent. Omit to leave the new-topic affordance off.\n */\n onStart?: () => void;\n\n /**\n * Resolves an author id into what it takes to render whoever started a topic. Omit to fall\n * back to rendering the id itself as the name.\n * @param authorId The identifier of the author to resolve.\n * @returns The author.\n */\n authorOf?: (authorId: ChatIdentifier) => ChatAuthor;\n\n /**\n * Renders the avatar for whoever started a topic, replacing the built-in initials circle.\n * @param authorId The identifier of the author.\n * @param author The resolved author, as {@link authorOf} answered.\n * @returns What to render.\n */\n renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n\n /**\n * Decides whether a topic counts as unnamed and renders the pending placeholder. Defaults to\n * \"no name, or only whitespace\" — override when the host's backend stores a literal\n * placeholder for unnamed topics instead.\n * @param topic The topic to check.\n * @returns True when the topic has no usable name yet.\n */\n isTopicUnnamed?: (topic: TTopic) => boolean;\n\n /** Builds the avatar image URL for topic starters. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Overrides for every label rendered. Unset fields fall back to literal English defaults. */\n labels?: ChatTopicListLabels;\n\n /** The host's actions to offer on each topic where they are available. */\n topicActions?: ChatTopicAction<TTopic>[];\n\n /** Additional class name for the list's root element. */\n className?: string;\n}\n\n/**\n * The topics of a chat, most recently active first — pick one to open its conversation, or start\n * a new one. A topic that has not been named yet renders a placeholder in a pending style: with\n * host-side auto-naming, the name arrives through the data once the host has produced it, and\n * the placeholder simply stops being needed.\n */\nexport const ChatTopicList = <TTopic extends ChatTopic = ChatTopic>({\n topics,\n status = ChatStatus.Ready,\n onOpen,\n onStart,\n authorOf,\n renderAvatar,\n isTopicUnnamed,\n buildAvatarUrl,\n labels,\n topicActions,\n className,\n}: ChatTopicListProps<TTopic>) => {\n const unnamed = isTopicUnnamed ?? defaultIsTopicUnnamed;\n const listRef = useRef<HTMLUListElement>(null);\n const orderedTopics = status === ChatStatus.Unauthorized ? [] : topicsByActivity(topics);\n const { onActionFocus, onActionBlur } = useTopicActionFocusRecovery(\n listRef,\n orderedTopics.map((topic) => chatIdentifierString(topic.id)),\n );\n\n const authorFor = (authorId: ChatIdentifier): ChatAuthor =>\n authorOf?.(authorId) ?? {\n name: chatIdentifierString(authorId),\n kind: ChatAuthorKind.User,\n };\n\n const showMessage = topics.length === 0 || status === ChatStatus.Failed || status === ChatStatus.Unauthorized;\n\n return (\n <div className={`cratis-chat-topics${className ? ` ${className}` : ''}`} data-cratis-component='ChatTopicList' aria-busy={status === ChatStatus.Loading && topics.length > 0 || undefined}>\n {onStart && <ChatTopicStartButton label={labels?.newTopic} disabled={status === ChatStatus.Unauthorized} onStart={onStart} />}\n {showMessage && <ChatTopicEmptyMessage status={status} labels={labels} />}\n <ul ref={listRef} className='cratis-chat-topics__list'>\n {orderedTopics.map((topic) => (\n <ChatTopicRow<TTopic>\n key={chatIdentifierString(topic.id)}\n topic={topic}\n isPending={unnamed(topic)}\n starter={topic.startedBy === undefined ? undefined : authorFor(topic.startedBy)}\n labels={labels}\n availableActions={(topicActions ?? []).filter((action) => action.isAvailable?.(topic) ?? true)}\n onOpen={onOpen}\n renderAvatar={renderAvatar}\n buildAvatarUrl={buildAvatarUrl}\n onActionFocus={onActionFocus}\n onActionBlur={onActionBlur}\n />\n ))}\n </ul>\n </div>\n );\n};\n"],"names":["isTopicUnnamed","defaultIsTopicUnnamed","_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AAqHO,MAAM,aAAa,GAAG,CAAuC,EAChE,MAAM,EACN,MAAM,GAAG,UAAU,CAAC,KAAK,EACzB,MAAM,EACN,OAAO,EACP,QAAQ,EACR,YAAY,kBACZA,gBAAc,EACd,cAAc,EACd,MAAM,EACN,YAAY,EACZ,SAAS,GACgB,KAAI;AAC7B,IAAA,MAAM,OAAO,GAAGA,gBAAc,IAAIC,cAAqB;AACvD,IAAA,MAAM,OAAO,GAAG,MAAM,CAAmB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,4EAA4E;IAC5E,UAAU,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAEhC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1B;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,MAAM,CAAC;IAE1D,wGAAwG;IACxG,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,kGAU5B,uBAAuB,gCAiDzB,CAAC"}
@@ -14,7 +14,7 @@ const PersonAvatarCircle = ({ userId, name, hasAvatar, size, ownerType = 'Users'
14
14
  });
15
15
  const [failedSrc, setFailedSrc] = useState(null);
16
16
  const showImage = hasAvatar && !!src && src !== failedSrc;
17
- return (jsx("span", { className: className ? `person-avatar-circle ${className}` : 'person-avatar-circle', style: {
17
+ return (jsx("span", { "data-cratis-component": 'PersonAvatarCircle', className: className ? `person-avatar-circle ${className}` : 'person-avatar-circle', style: {
18
18
  width: dimension,
19
19
  height: dimension,
20
20
  background: showImage ? undefined : getAvatarColor(userId.toString()),
@@ -1 +1 @@
1
- {"version":3,"file":"PersonAvatarCircle.js","sources":["../../../../../Chat/Kit/Avatar/PersonAvatarCircle.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport type { Guid } from '@cratis/fundamentals';\nimport { getInitials } from './getInitials';\nimport { getAvatarColor } from './getAvatarColor';\n\n/** The parameters {@link PersonAvatarCircleProps.buildAvatarUrl} resolves into an image URL. */\nexport interface BuildAvatarUrlParams {\n /** The identifier of the person, as a string. */\n userId: string;\n\n /** The kind of owner the avatar belongs to, matching the storage layout. */\n ownerType: 'Users' | 'Personas' | 'Agents';\n\n /** The avatar rendition requested. */\n avatarSize: 'Small' | 'Medium';\n\n /** A value that changes whenever the avatar image changes, for cache-busting. */\n version?: number | string;\n}\n\n/**\n * Props for rendering a person's avatar image when one has been uploaded and a URL can be built for\n * it, falling back to their initials on a color derived from their identifier so the same person\n * always shows the same fallback color.\n */\nexport interface PersonAvatarCircleProps {\n /** The identifier of the person, used to build the avatar image URL. */\n userId: Guid | string;\n\n /** The person's display name, used for initials and accessibility text. */\n name: string;\n\n /** Whether the person has an uploaded avatar image. */\n hasAvatar: boolean;\n\n /** The rendered size, in pixels. */\n size: number;\n\n /** The kind of owner the avatar belongs to, matching the storage layout. Defaults to 'Users'. */\n ownerType?: 'Users' | 'Personas' | 'Agents';\n\n /** The avatar rendition to request from the server. Defaults to 'Small'. */\n avatarSize?: 'Small' | 'Medium';\n\n /**\n * A value that changes whenever the avatar image changes (e.g. the upload timestamp). Passed on to\n * {@link buildAvatarUrl} so a re-uploaded avatar can bust the aggressive HTTP cache on the old URL.\n */\n version?: number | string;\n\n /**\n * Builds the avatar image URL from the resolved parameters. Omit to always show the initials\n * fallback - this library ships no avatar storage convention of its own, so a host with an avatar\n * endpoint passes this to opt into images; one without simply never renders a broken `<img>`.\n */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Additional class name applied to the circle, for context-specific styling (borders, cursor, ...). */\n className?: string;\n}\n\n/**\n * Renders a person's avatar image when one has been uploaded and a URL can be built for it, falling\n * back to their initials on a color derived from their identifier so the same person always shows the\n * same fallback color.\n */\nexport const PersonAvatarCircle = ({\n userId,\n name,\n hasAvatar,\n size,\n ownerType = 'Users',\n avatarSize = 'Small',\n version,\n buildAvatarUrl,\n className,\n}: PersonAvatarCircleProps) => {\n const initials = getInitials(name);\n const dimension = `${size}px`;\n const src = buildAvatarUrl?.({\n userId: userId.toString(),\n ownerType,\n avatarSize,\n version,\n });\n\n // The \"has avatar\" signal can outlive the stored image (e.g. a persona flag that stays set\n // after the blob is gone), which otherwise leaves a broken image and a stream of 404s.\n // Track the src that failed and fall back to initials for it — a new src (re-upload bumps the\n // version) is retried.\n const [failedSrc, setFailedSrc] = useState<string | null>(null);\n const showImage = hasAvatar && !!src && src !== failedSrc;\n\n return (\n <span\n className={\n className ? `person-avatar-circle ${className}` : 'person-avatar-circle'\n }\n style={{\n width: dimension,\n height: dimension,\n background: showImage ? undefined : getAvatarColor(userId.toString()),\n }}\n aria-label={name}\n title={name}\n >\n {showImage ? (\n <img\n className='person-avatar-circle-image'\n src={src}\n alt={name}\n draggable={false}\n onError={() => setFailedSrc(src)}\n />\n ) : (\n <span\n className='person-avatar-circle-initials'\n style={{ fontSize: `${Math.max(8, Math.round(size * 0.4))}px` }}\n >\n {initials}\n </span>\n )}\n </span>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;AAqEO,MAAM,kBAAkB,GAAG,CAAC,EAC/B,MAAM,EACN,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,SAAS,GAAG,OAAO,EACnB,UAAU,GAAG,OAAO,EACpB,OAAO,EACP,cAAc,EACd,SAAS,GACa,KAAI;AAC1B,IAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC;AAClC,IAAA,MAAM,SAAS,GAAG,CAAA,EAAG,IAAI,IAAI;AAC7B,IAAA,MAAM,GAAG,GAAG,cAAc,GAAG;AACzB,QAAA,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;QACzB,SAAS;QACT,UAAU;QACV,OAAO;AACV,KAAA,CAAC;IAMF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC;IAC/D,MAAM,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,SAAS;AAEzD,IAAA,QACIA,GAAA,CAAA,MAAA,EAAA,EACI,SAAS,EACL,SAAS,GAAG,CAAA,qBAAA,EAAwB,SAAS,EAAE,GAAG,sBAAsB,EAE5E,KAAK,EAAE;AACH,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,MAAM,EAAE,SAAS;AACjB,YAAA,UAAU,EAAE,SAAS,GAAG,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;AACxE,SAAA,EAAA,YAAA,EACW,IAAI,EAChB,KAAK,EAAE,IAAI,YAEV,SAAS,IACNA,GAAA,CAAA,KAAA,EAAA,EACI,SAAS,EAAC,4BAA4B,EACtC,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,KAAK,EAChB,OAAO,EAAE,MAAM,YAAY,CAAC,GAAG,CAAC,EAAA,CAClC,KAEFA,GAAA,CAAA,MAAA,EAAA,EACI,SAAS,EAAC,+BAA+B,EACzC,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAA,EAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAA,EAAA,CAAI,EAAE,EAAA,QAAA,EAE9D,QAAQ,GACN,CACV,EAAA,CACE;AAEf;;"}
1
+ {"version":3,"file":"PersonAvatarCircle.js","sources":["../../../../../Chat/Kit/Avatar/PersonAvatarCircle.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport type { Guid } from '@cratis/fundamentals';\nimport { getInitials } from './getInitials';\nimport { getAvatarColor } from './getAvatarColor';\n\n/** The parameters {@link PersonAvatarCircleProps.buildAvatarUrl} resolves into an image URL. */\nexport interface BuildAvatarUrlParams {\n /** The identifier of the person, as a string. */\n userId: string;\n\n /** The kind of owner the avatar belongs to, matching the storage layout. */\n ownerType: 'Users' | 'Personas' | 'Agents';\n\n /** The avatar rendition requested. */\n avatarSize: 'Small' | 'Medium';\n\n /** A value that changes whenever the avatar image changes, for cache-busting. */\n version?: number | string;\n}\n\n/**\n * Props for rendering a person's avatar image when one has been uploaded and a URL can be built for\n * it, falling back to their initials on a color derived from their identifier so the same person\n * always shows the same fallback color.\n */\nexport interface PersonAvatarCircleProps {\n /** The identifier of the person, used to build the avatar image URL. */\n userId: Guid | string;\n\n /** The person's display name, used for initials and accessibility text. */\n name: string;\n\n /** Whether the person has an uploaded avatar image. */\n hasAvatar: boolean;\n\n /** The rendered size, in pixels. */\n size: number;\n\n /** The kind of owner the avatar belongs to, matching the storage layout. Defaults to 'Users'. */\n ownerType?: 'Users' | 'Personas' | 'Agents';\n\n /** The avatar rendition to request from the server. Defaults to 'Small'. */\n avatarSize?: 'Small' | 'Medium';\n\n /**\n * A value that changes whenever the avatar image changes (e.g. the upload timestamp). Passed on to\n * {@link buildAvatarUrl} so a re-uploaded avatar can bust the aggressive HTTP cache on the old URL.\n */\n version?: number | string;\n\n /**\n * Builds the avatar image URL from the resolved parameters. Omit to always show the initials\n * fallback - this library ships no avatar storage convention of its own, so a host with an avatar\n * endpoint passes this to opt into images; one without simply never renders a broken `<img>`.\n */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Additional class name applied to the circle, for context-specific styling (borders, cursor, ...). */\n className?: string;\n}\n\n/**\n * Renders a person's avatar image when one has been uploaded and a URL can be built for it, falling\n * back to their initials on a color derived from their identifier so the same person always shows the\n * same fallback color.\n */\nexport const PersonAvatarCircle = ({\n userId,\n name,\n hasAvatar,\n size,\n ownerType = 'Users',\n avatarSize = 'Small',\n version,\n buildAvatarUrl,\n className,\n}: PersonAvatarCircleProps) => {\n const initials = getInitials(name);\n const dimension = `${size}px`;\n const src = buildAvatarUrl?.({\n userId: userId.toString(),\n ownerType,\n avatarSize,\n version,\n });\n\n // The \"has avatar\" signal can outlive the stored image (e.g. a persona flag that stays set\n // after the blob is gone), which otherwise leaves a broken image and a stream of 404s.\n // Track the src that failed and fall back to initials for it — a new src (re-upload bumps the\n // version) is retried.\n const [failedSrc, setFailedSrc] = useState<string | null>(null);\n const showImage = hasAvatar && !!src && src !== failedSrc;\n\n return (\n <span\n data-cratis-component='PersonAvatarCircle'\n className={\n className ? `person-avatar-circle ${className}` : 'person-avatar-circle'\n }\n style={{\n width: dimension,\n height: dimension,\n background: showImage ? undefined : getAvatarColor(userId.toString()),\n }}\n aria-label={name}\n title={name}\n >\n {showImage ? (\n <img\n className='person-avatar-circle-image'\n src={src}\n alt={name}\n draggable={false}\n onError={() => setFailedSrc(src)}\n />\n ) : (\n <span\n className='person-avatar-circle-initials'\n style={{ fontSize: `${Math.max(8, Math.round(size * 0.4))}px` }}\n >\n {initials}\n </span>\n )}\n </span>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;AAqEO,MAAM,kBAAkB,GAAG,CAAC,EAC/B,MAAM,EACN,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,SAAS,GAAG,OAAO,EACnB,UAAU,GAAG,OAAO,EACpB,OAAO,EACP,cAAc,EACd,SAAS,GACa,KAAI;AAC1B,IAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC;AAClC,IAAA,MAAM,SAAS,GAAG,CAAA,EAAG,IAAI,IAAI;AAC7B,IAAA,MAAM,GAAG,GAAG,cAAc,GAAG;AACzB,QAAA,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;QACzB,SAAS;QACT,UAAU;QACV,OAAO;AACV,KAAA,CAAC;IAMF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC;IAC/D,MAAM,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,SAAS;AAEzD,IAAA,QACIA,GAAA,CAAA,MAAA,EAAA,EAAA,uBAAA,EAC0B,oBAAoB,EAC1C,SAAS,EACL,SAAS,GAAG,CAAA,qBAAA,EAAwB,SAAS,EAAE,GAAG,sBAAsB,EAE5E,KAAK,EAAE;AACH,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,MAAM,EAAE,SAAS;AACjB,YAAA,UAAU,EAAE,SAAS,GAAG,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;AACxE,SAAA,EAAA,YAAA,EACW,IAAI,EAChB,KAAK,EAAE,IAAI,YAEV,SAAS,IACNA,GAAA,CAAA,KAAA,EAAA,EACI,SAAS,EAAC,4BAA4B,EACtC,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,KAAK,EAChB,OAAO,EAAE,MAAM,YAAY,CAAC,GAAG,CAAC,EAAA,CAClC,KAEFA,GAAA,CAAA,MAAA,EAAA,EACI,SAAS,EAAC,+BAA+B,EACzC,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAA,EAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAA,EAAA,CAAI,EAAE,EAAA,QAAA,EAE9D,QAAQ,GACN,CACV,EAAA,CACE;AAEf;;"}
@@ -158,7 +158,7 @@ const ChatComposer = forwardRef(({ mentionCandidates, resolveMentionCandidates,
158
158
  send();
159
159
  }
160
160
  };
161
- return (jsxs("div", { className: 'chat-composer', children: [isSuggesting && (jsx(MentionSuggestions, { candidates: suggestions, highlightedIndex: highlighted, id: listId, onSelect: choose, onHighlight: setHighlightedIndex, buildAvatarUrl: buildAvatarUrl })), jsx("textarea", { ref: inputRef, className: 'chat-composer__input', value: draft.text, onChange: (event) => readDraft(event.target), onKeyUp: (event) => readDraft(event.currentTarget), onClick: (event) => readDraft(event.currentTarget), onKeyDown: handleKeyDown, placeholder: labels?.placeholder ?? 'Write a message… (Enter to send)', rows: 2, "aria-autocomplete": isSuggesting ? 'list' : undefined, "aria-controls": isSuggesting ? listId : undefined, "aria-activedescendant": isSuggesting ? mentionOptionId(listId, highlighted) : undefined, disabled: disabled }), jsx("button", { ref: emojiButtonRef, type: 'button', className: 'chat-composer__emoji-toggle', disabled: disabled, onMouseDown: (event) => event.preventDefault(), onClick: () => setShowEmojiPicker((previous) => !previous), title: labels?.insertEmoji ?? 'Insert emoji', "aria-label": labels?.insertEmoji ?? 'Insert emoji', "aria-expanded": showEmojiPicker, children: "\u263A" }), jsx("button", { type: 'button', className: 'chat-composer__send', onClick: send, disabled: disabled || !draft.text.trim(), title: labels?.send ?? 'Send', "aria-label": labels?.sendMessage ?? 'Send message', children: jsxs("svg", { width: '16', height: '16', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2.5', "aria-hidden": 'true', children: [jsx("line", { x1: '22', y1: '2', x2: '11', y2: '13' }), jsx("polygon", { points: '22 2 15 22 11 13 2 9 22 2' })] }) }), jsx(AnchoredOverlay, { anchorRef: emojiButtonRef, open: showEmojiPicker && !disabled, side: 'above', align: 'right', gap: 6, children: jsx(ReactionPicker, { anchorRef: emojiButtonRef, onPick: insertEmoji, onDismiss: () => setShowEmojiPicker(false), labels: labels?.reactionPicker }) })] }));
161
+ return (jsxs("div", { className: 'chat-composer', "data-cratis-component": 'ChatComposer', children: [isSuggesting && (jsx(MentionSuggestions, { candidates: suggestions, highlightedIndex: highlighted, id: listId, onSelect: choose, onHighlight: setHighlightedIndex, buildAvatarUrl: buildAvatarUrl })), jsx("textarea", { ref: inputRef, className: 'chat-composer__input', value: draft.text, onChange: (event) => readDraft(event.target), onKeyUp: (event) => readDraft(event.currentTarget), onClick: (event) => readDraft(event.currentTarget), onKeyDown: handleKeyDown, placeholder: labels?.placeholder ?? 'Write a message… (Enter to send)', rows: 2, "aria-autocomplete": isSuggesting ? 'list' : undefined, "aria-controls": isSuggesting ? listId : undefined, "aria-activedescendant": isSuggesting ? mentionOptionId(listId, highlighted) : undefined, disabled: disabled }), jsx("button", { ref: emojiButtonRef, type: 'button', className: 'chat-composer__emoji-toggle', disabled: disabled, onMouseDown: (event) => event.preventDefault(), onClick: () => setShowEmojiPicker((previous) => !previous), title: labels?.insertEmoji ?? 'Insert emoji', "aria-label": labels?.insertEmoji ?? 'Insert emoji', "aria-expanded": showEmojiPicker, children: "\u263A" }), jsx("button", { type: 'button', className: 'chat-composer__send', onClick: send, disabled: disabled || !draft.text.trim(), title: labels?.send ?? 'Send', "aria-label": labels?.sendMessage ?? 'Send message', children: jsxs("svg", { width: '16', height: '16', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2.5', "aria-hidden": 'true', children: [jsx("line", { x1: '22', y1: '2', x2: '11', y2: '13' }), jsx("polygon", { points: '22 2 15 22 11 13 2 9 22 2' })] }) }), jsx(AnchoredOverlay, { anchorRef: emojiButtonRef, open: showEmojiPicker && !disabled, side: 'above', align: 'right', gap: 6, children: jsx(ReactionPicker, { anchorRef: emojiButtonRef, onPick: insertEmoji, onDismiss: () => setShowEmojiPicker(false), labels: labels?.reactionPicker }) })] }));
162
162
  });
163
163
  ChatComposer.displayName = 'ChatComposer';
164
164