@cratis/components 4.39.5 → 4.40.0
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.
- package/compat-manifest.json +11 -11
- package/dist/esm/Chat/Kit/ChatComposer.d.ts.map +1 -1
- package/dist/esm/Chat/Kit/ChatComposer.js +14 -7
- package/dist/esm/Chat/Kit/ChatComposer.js.map +1 -1
- package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.d.ts +3 -1
- package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.d.ts.map +1 -1
- package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.js +2 -1
- package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.js.map +1 -1
- package/dist/esm/Chat/Kit/Mentions/mentionOptionId.d.ts +9 -0
- package/dist/esm/Chat/Kit/Mentions/mentionOptionId.d.ts.map +1 -0
- package/dist/esm/Chat/Kit/Mentions/mentionOptionId.js +4 -0
- package/dist/esm/Chat/Kit/Mentions/mentionOptionId.js.map +1 -0
- package/dist/esm/styles.Canvas.css +1 -0
- package/dist/esm/styles.Chat.css +1 -0
- package/dist/esm/styles.css +1 -0
- package/dist/esm/theme.css +1 -0
- package/package.json +1 -1
package/compat-manifest.json
CHANGED
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
{
|
|
69
69
|
"name": "@cratis/components",
|
|
70
70
|
"role": "core",
|
|
71
|
-
"version": "4.
|
|
71
|
+
"version": "4.40.0",
|
|
72
72
|
"releaseMajorRange": ">=4 <5",
|
|
73
73
|
"independentRelease": false,
|
|
74
74
|
"private": false,
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
{
|
|
93
93
|
"name": "@cratis/eslint-plugin-components",
|
|
94
94
|
"role": "eslint",
|
|
95
|
-
"version": "4.
|
|
95
|
+
"version": "4.40.0",
|
|
96
96
|
"releaseMajorRange": ">=4 <5",
|
|
97
97
|
"independentRelease": false,
|
|
98
98
|
"private": false,
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
{
|
|
106
106
|
"name": "@cratis/components.migrator",
|
|
107
107
|
"role": "migrator",
|
|
108
|
-
"version": "4.
|
|
108
|
+
"version": "4.40.0",
|
|
109
109
|
"releaseMajorRange": ">=4 <5",
|
|
110
110
|
"independentRelease": false,
|
|
111
111
|
"private": false,
|
|
@@ -116,13 +116,13 @@
|
|
|
116
116
|
{
|
|
117
117
|
"name": "@cratis/components.conformance",
|
|
118
118
|
"role": "conformance",
|
|
119
|
-
"version": "4.
|
|
119
|
+
"version": "4.40.0",
|
|
120
120
|
"releaseMajorRange": ">=4 <5",
|
|
121
121
|
"independentRelease": false,
|
|
122
122
|
"private": false,
|
|
123
123
|
"packageAccess": "public",
|
|
124
124
|
"peerDependencies": {
|
|
125
|
-
"@cratis/components": "4.
|
|
125
|
+
"@cratis/components": "4.40.0",
|
|
126
126
|
"react": "^19.0.0",
|
|
127
127
|
"react-dom": "^19.0.0"
|
|
128
128
|
},
|
|
@@ -132,13 +132,13 @@
|
|
|
132
132
|
{
|
|
133
133
|
"name": "@cratis/components.mui",
|
|
134
134
|
"role": "renderer-adapter",
|
|
135
|
-
"version": "4.
|
|
135
|
+
"version": "4.40.0",
|
|
136
136
|
"releaseMajorRange": ">=4 <5",
|
|
137
137
|
"independentRelease": false,
|
|
138
138
|
"private": false,
|
|
139
139
|
"packageAccess": "public",
|
|
140
140
|
"peerDependencies": {
|
|
141
|
-
"@cratis/components": "4.
|
|
141
|
+
"@cratis/components": "4.40.0",
|
|
142
142
|
"@emotion/react": ">=11.5 <12",
|
|
143
143
|
"@emotion/styled": ">=11.11 <12",
|
|
144
144
|
"@mui/material": ">=9 <10",
|
|
@@ -188,13 +188,13 @@
|
|
|
188
188
|
{
|
|
189
189
|
"name": "@cratis/components.primereact",
|
|
190
190
|
"role": "renderer-adapter",
|
|
191
|
-
"version": "4.
|
|
191
|
+
"version": "4.40.0",
|
|
192
192
|
"releaseMajorRange": ">=4 <5",
|
|
193
193
|
"independentRelease": false,
|
|
194
194
|
"private": false,
|
|
195
195
|
"packageAccess": "public",
|
|
196
196
|
"peerDependencies": {
|
|
197
|
-
"@cratis/components": "4.
|
|
197
|
+
"@cratis/components": "4.40.0",
|
|
198
198
|
"@primereact/core": ">=11 <12",
|
|
199
199
|
"@primereact/ui": ">=11 <12",
|
|
200
200
|
"@primeuix/themes": ">=3 <4",
|
|
@@ -256,13 +256,13 @@
|
|
|
256
256
|
{
|
|
257
257
|
"name": "@cratis/components.primereact10",
|
|
258
258
|
"role": "renderer-adapter",
|
|
259
|
-
"version": "4.
|
|
259
|
+
"version": "4.40.0",
|
|
260
260
|
"releaseMajorRange": ">=4 <5",
|
|
261
261
|
"independentRelease": false,
|
|
262
262
|
"private": false,
|
|
263
263
|
"packageAccess": "public",
|
|
264
264
|
"peerDependencies": {
|
|
265
|
-
"@cratis/components": "4.
|
|
265
|
+
"@cratis/components": "4.40.0",
|
|
266
266
|
"primereact": ">=10.9.9 <11",
|
|
267
267
|
"react": "^19.0.0",
|
|
268
268
|
"react-dom": "^19.0.0"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComposer.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/ChatComposer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatComposer.d.ts","sourceRoot":"","sources":["../../../../Chat/Kit/ChatComposer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAU,CAAC;AAMrD,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,qBAAY,CAAC;AACvE,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,qBAAkB,CAAC;AAE7E;eACe;AACf,MAAM,WAAW,kBAAkB;IAC/B,8FAA8F;IAC9F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,cAAc,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,uFAAuF;IACvF,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAEvC;;;;;;;;OAQG;IACH,wBAAwB,CAAC,EAAE,CACvB,KAAK,EAAE,MAAM,KACZ,gBAAgB,EAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAEtD;;;;OAIG;IACH,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,KAAK,IAAI,CAAC;IAE7D,0CAA0C;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,wFAAwF;IACxF,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,MAAM,CAAC;IAE1D,+FAA+F;IAC/F,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAC/B,2EAA2E;IAC3E,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,8FAgSxB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useState, useRef, useEffect, useImperativeHandle } from 'react';
|
|
2
|
+
import { forwardRef, useState, useId, useRef, useEffect, useImperativeHandle } from 'react';
|
|
3
3
|
import { AnchoredOverlay } from './AnchoredOverlay.js';
|
|
4
4
|
import { activeMentionQuery } from './Mentions/activeMentionQuery.js';
|
|
5
5
|
import { applyMention } from './Mentions/applyMention.js';
|
|
6
|
+
import { mentionOptionId } from './Mentions/mentionOptionId.js';
|
|
6
7
|
import { extractMentions } from './Mentions/extractMentions.js';
|
|
7
8
|
import { matchCandidates } from './Mentions/matchCandidates.js';
|
|
8
9
|
import { MentionSuggestions } from './Mentions/MentionSuggestions.js';
|
|
@@ -11,6 +12,8 @@ import { ReactionPicker } from './ReactionPicker.js';
|
|
|
11
12
|
const ChatComposer = forwardRef(({ mentionCandidates, resolveMentionCandidates, onSend, autoFocus = false, disabled = false, buildAvatarUrl, labels, }, handleRef) => {
|
|
12
13
|
const [draft, setDraft] = useState({ text: '', caret: 0 });
|
|
13
14
|
const [highlightedIndex, setHighlightedIndex] = useState(0);
|
|
15
|
+
const [dismissed, setDismissed] = useState(null);
|
|
16
|
+
const listId = useId();
|
|
14
17
|
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
|
|
15
18
|
const [resolvedCandidates, setResolvedCandidates] = useState([]);
|
|
16
19
|
const inputRef = useRef(null);
|
|
@@ -22,6 +25,12 @@ const ChatComposer = forwardRef(({ mentionCandidates, resolveMentionCandidates,
|
|
|
22
25
|
? activeMentionQuery(draft.text, draft.caret)
|
|
23
26
|
: null;
|
|
24
27
|
const queryText = query?.text;
|
|
28
|
+
const isDismissed = dismissed !== null && query?.start === dismissed.start && query.text === dismissed.text;
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (dismissed !== null && !isDismissed) {
|
|
31
|
+
setDismissed(null);
|
|
32
|
+
}
|
|
33
|
+
}, [dismissed, isDismissed]);
|
|
25
34
|
useEffect(() => {
|
|
26
35
|
if (!resolveMentionCandidates || queryText === undefined) {
|
|
27
36
|
setResolvedCandidates((previous) => previous.length === 0 ? previous : []);
|
|
@@ -60,7 +69,7 @@ const ChatComposer = forwardRef(({ mentionCandidates, resolveMentionCandidates,
|
|
|
60
69
|
const queryIsCompleteMention = query !== null &&
|
|
61
70
|
/\s$/.test(query.text) &&
|
|
62
71
|
candidatePool.some((candidate) => candidate.name.toLowerCase() === query.text.trim().toLowerCase());
|
|
63
|
-
const suggestions = query && !queryIsCompleteMention
|
|
72
|
+
const suggestions = query && !queryIsCompleteMention && !isDismissed
|
|
64
73
|
? matchCandidates(candidatePool, query.text)
|
|
65
74
|
: [];
|
|
66
75
|
const isSuggesting = !disabled && suggestions.length > 0;
|
|
@@ -139,10 +148,8 @@ const ChatComposer = forwardRef(({ mentionCandidates, resolveMentionCandidates,
|
|
|
139
148
|
}
|
|
140
149
|
if (event.key === 'Escape') {
|
|
141
150
|
event.preventDefault();
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
caret: previous.text.length,
|
|
145
|
-
}));
|
|
151
|
+
event.stopPropagation();
|
|
152
|
+
setDismissed(query);
|
|
146
153
|
return;
|
|
147
154
|
}
|
|
148
155
|
}
|
|
@@ -151,7 +158,7 @@ const ChatComposer = forwardRef(({ mentionCandidates, resolveMentionCandidates,
|
|
|
151
158
|
send();
|
|
152
159
|
}
|
|
153
160
|
};
|
|
154
|
-
return (jsxs("div", { className: 'chat-composer', children: [isSuggesting && (jsx(MentionSuggestions, { candidates: suggestions, highlightedIndex: highlighted, 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, 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', 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 }) })] }));
|
|
155
162
|
});
|
|
156
163
|
ChatComposer.displayName = 'ChatComposer';
|
|
157
164
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComposer.js","sources":["../../../../Chat/Kit/ChatComposer.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 type React from 'react';\nimport { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport { AnchoredOverlay } from './AnchoredOverlay';\nimport type { BuildAvatarUrlParams } from './Avatar';\nimport { activeMentionQuery } from './Mentions/activeMentionQuery';\nimport { applyMention } from './Mentions/applyMention';\nimport { extractMentions } from './Mentions/extractMentions';\nimport { matchCandidates } from './Mentions/matchCandidates';\nimport { MentionSuggestions, type MentionCandidate } from './Mentions';\nimport { ReactionPicker, type ReactionPickerLabels } from './ReactionPicker';\n\n/** Overrides for the composer's own labels. Any field left unset falls back to a literal English\n * default. */\nexport interface ChatComposerLabels {\n /** Placeholder text for the draft input. Defaults to `'Write a message… (Enter to send)'`. */\n placeholder?: string;\n /** Tooltip/accessible label for the emoji-insert toggle. Defaults to `'Insert emoji'`. */\n insertEmoji?: string;\n /** Tooltip for the send button. Defaults to `'Send'`. */\n send?: string;\n /** Accessible label for the send button. Defaults to `'Send message'`. */\n sendMessage?: string;\n /** Labels forwarded to the emoji-insert {@link ReactionPicker}. */\n reactionPicker?: ReactionPickerLabels;\n}\n\n/**\n * Props for the compose row of a conversation — the text area, the `@` mention list it opens, and\n * the send button. It owns the draft so the surrounding panel stays a renderer of messages.\n */\nexport interface ChatComposerProps {\n /** Everyone who can be mentioned from this conversation. Omit 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 `@` — for hosts whose candidates come from a lookup rather than a list they already\n * hold. May answer synchronously or with a promise; a stale answer (one that arrives after\n * the query has moved on) is dropped. Combines with {@link mentionCandidates} when both are\n * given.\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 /**\n * Invoked with the trimmed message text when the user sends, together with who that text\n * actually mentions — reduced from every candidate the draft saw, so a mention that was\n * picked but edited away again does not count.\n */\n onSend: (text: string, mentions: MentionCandidate[]) => void;\n\n /** Whether to take focus when mounted. */\n autoFocus?: boolean;\n\n /** Disables drafting, emoji insertion, and sending. Defaults to false. */\n disabled?: boolean;\n\n /** Builds the avatar image URL for mention candidates. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Overrides for the composer's labels. Unset fields fall back to literal English defaults. */\n labels?: ChatComposerLabels;\n}\n\n/**\n * Imperative actions a caller can drive on the composer without owning its draft state — used by a\n * quick reply, which sets the starting text for whatever the person types next rather than sending\n * anything itself.\n */\nexport interface ChatComposerHandle {\n /** Replaces the current draft and takes focus, caret placed at the end. */\n prefill: (text: string) => void;\n}\n\n/**\n * The compose row of a conversation — the text area, the `@` mention list it opens, and the send\n * button. It owns the draft so the surrounding panel stays a renderer of messages.\n */\nexport const ChatComposer = forwardRef<ChatComposerHandle, ChatComposerProps>(\n (\n {\n mentionCandidates,\n resolveMentionCandidates,\n onSend,\n autoFocus = false,\n disabled = false,\n buildAvatarUrl,\n labels,\n },\n handleRef,\n ) => {\n const [draft, setDraft] = useState({ text: '', caret: 0 });\n const [highlightedIndex, setHighlightedIndex] = useState(0);\n const [showEmojiPicker, setShowEmojiPicker] = useState(false);\n const [resolvedCandidates, setResolvedCandidates] = useState<MentionCandidate[]>(\n [],\n );\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const didAutoFocus = useRef(false);\n const emojiButtonRef = useRef<HTMLButtonElement>(null);\n // Every candidate this draft has seen — resolved or picked — so the mentions reported on\n // send can be found again even when the resolver's latest answer no longer includes them.\n const seenCandidatesRef = useRef(new Map<string, MentionCandidate>());\n\n const mentionsEnabled = !!mentionCandidates || !!resolveMentionCandidates;\n const query = mentionsEnabled\n ? activeMentionQuery(draft.text, draft.caret)\n : null;\n const queryText = query?.text;\n\n useEffect(() => {\n if (!resolveMentionCandidates || queryText === undefined) {\n setResolvedCandidates((previous) =>\n previous.length === 0 ? previous : [],\n );\n return;\n }\n let cancelled = false;\n Promise.resolve(resolveMentionCandidates(queryText))\n .then((candidates) => {\n if (cancelled) return;\n setResolvedCandidates(candidates);\n candidates.forEach((candidate) =>\n seenCandidatesRef.current.set(candidate.id, candidate),\n );\n })\n .catch(() => {\n if (!cancelled) {\n setResolvedCandidates([]);\n }\n });\n return () => {\n cancelled = true;\n };\n }, [resolveMentionCandidates, queryText]);\n\n const uniqueById = (candidates: MentionCandidate[]): MentionCandidate[] => {\n const byId = new Map<string, MentionCandidate>();\n candidates.forEach((candidate) => {\n if (!byId.has(candidate.id)) {\n byId.set(candidate.id, candidate);\n }\n });\n return [...byId.values()];\n };\n\n const candidatePool = uniqueById([\n ...(mentionCandidates ?? []),\n ...resolvedCandidates,\n ]);\n // A query that ends in whitespace and spells a candidate's full name is a mention already\n // made — the trailing space applyMention writes is its closing. Without this, Enter right\n // after picking would re-pick the same name instead of sending the message.\n const queryIsCompleteMention =\n query !== null &&\n /\\s$/.test(query.text) &&\n candidatePool.some(\n (candidate) =>\n candidate.name.toLowerCase() === query.text.trim().toLowerCase(),\n );\n const suggestions =\n query && !queryIsCompleteMention\n ? matchCandidates(candidatePool, query.text)\n : [];\n const isSuggesting = !disabled && suggestions.length > 0;\n const highlighted = Math.min(highlightedIndex, suggestions.length - 1);\n\n useEffect(() => {\n if (autoFocus && !disabled && !didAutoFocus.current && inputRef.current) {\n inputRef.current.focus();\n didAutoFocus.current = true;\n }\n }, [autoFocus, disabled]);\n\n useEffect(() => {\n if (disabled) {\n setShowEmojiPicker(false);\n }\n }, [disabled]);\n\n useImperativeHandle(\n handleRef,\n () => ({\n prefill: (text: string) => {\n setDraft({ text, caret: text.length });\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n inputRef.current?.setSelectionRange(text.length, text.length);\n });\n },\n }),\n [],\n );\n\n const readDraft = (element: HTMLTextAreaElement) => {\n const text = element.value;\n // Only editing the text restarts the selection. Resetting on every key event would undo the\n // arrow-key navigation on the very next keyup.\n if (text !== draft.text) {\n setHighlightedIndex(0);\n }\n setDraft({ text, caret: element.selectionStart ?? text.length });\n };\n\n const send = () => {\n const trimmed = draft.text.trim();\n if (!trimmed || disabled) return;\n const known = uniqueById([\n ...(mentionCandidates ?? []),\n ...seenCandidatesRef.current.values(),\n ]);\n onSend(trimmed, extractMentions(trimmed, known));\n seenCandidatesRef.current.clear();\n setDraft({ text: '', caret: 0 });\n };\n\n const choose = (candidate: MentionCandidate) => {\n if (!query) return;\n seenCandidatesRef.current.set(candidate.id, candidate);\n const applied = applyMention(draft.text, draft.caret, query, candidate.name);\n setDraft(applied);\n setHighlightedIndex(0);\n // The caret has to be restored after React has written the new value back into the element.\n requestAnimationFrame(() =>\n inputRef.current?.setSelectionRange(applied.caret, applied.caret),\n );\n inputRef.current?.focus();\n };\n\n const insertEmoji = (emoji: string) => {\n const text = `${draft.text.slice(0, draft.caret)}${emoji}${draft.text.slice(draft.caret)}`;\n const caret = draft.caret + emoji.length;\n setDraft({ text, caret });\n setShowEmojiPicker(false);\n // Same restore-after-write pattern as choose() above — React has to write the new value in\n // before the caret can be placed past the emoji it inserted.\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n inputRef.current?.setSelectionRange(caret, caret);\n });\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (isSuggesting) {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n const step = event.key === 'ArrowDown' ? 1 : suggestions.length - 1;\n setHighlightedIndex((highlighted + step) % suggestions.length);\n return;\n }\n\n if (event.key === 'Enter' || event.key === 'Tab') {\n event.preventDefault();\n choose(suggestions[highlighted]);\n return;\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n // Closing the list without changing the text: move the caret past the mention so the\n // query no longer resolves.\n setDraft((previous) => ({\n ...previous,\n caret: previous.text.length,\n }));\n return;\n }\n }\n\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n send();\n }\n };\n\n return (\n <div className='chat-composer'>\n {isSuggesting && (\n <MentionSuggestions\n candidates={suggestions}\n highlightedIndex={highlighted}\n onSelect={choose}\n onHighlight={setHighlightedIndex}\n buildAvatarUrl={buildAvatarUrl}\n />\n )}\n <textarea\n ref={inputRef}\n className='chat-composer__input'\n value={draft.text}\n onChange={(event) => readDraft(event.target)}\n onKeyUp={(event) => readDraft(event.currentTarget)}\n onClick={(event) => readDraft(event.currentTarget)}\n onKeyDown={handleKeyDown}\n placeholder={\n labels?.placeholder ?? 'Write a message… (Enter to send)'\n }\n rows={2}\n disabled={disabled}\n />\n <button\n ref={emojiButtonRef}\n type='button'\n className='chat-composer__emoji-toggle'\n disabled={disabled}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => setShowEmojiPicker((previous) => !previous)}\n title={labels?.insertEmoji ?? 'Insert emoji'}\n aria-label={labels?.insertEmoji ?? 'Insert emoji'}\n aria-expanded={showEmojiPicker}\n >\n ☺\n </button>\n <button\n type='button'\n className='chat-composer__send'\n onClick={send}\n disabled={disabled || !draft.text.trim()}\n title={labels?.send ?? 'Send'}\n aria-label={labels?.sendMessage ?? 'Send message'}\n >\n <svg\n width='16'\n height='16'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2.5'\n aria-hidden='true'\n >\n <line x1='22' y1='2' x2='11' y2='13' />\n <polygon points='22 2 15 22 11 13 2 9 22 2' />\n </svg>\n </button>\n {/* Portaled to <body>, same reason as the reaction picker on a message bubble: the chat\n panel scrolls/clips, so a picker positioned inside it would be cut off at the edge. */}\n <AnchoredOverlay\n anchorRef={emojiButtonRef}\n open={showEmojiPicker && !disabled}\n side='above'\n align='right'\n gap={6}\n >\n <ReactionPicker\n anchorRef={emojiButtonRef}\n onPick={insertEmoji}\n onDismiss={() => setShowEmojiPicker(false)}\n labels={labels?.reactionPicker}\n />\n </AnchoredOverlay>\n </div>\n );\n },\n);\nChatComposer.displayName = 'ChatComposer';\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AAoFO,MAAM,YAAY,GAAG,UAAU,CAClC,CACI,EACI,iBAAiB,EACjB,wBAAwB,EACxB,MAAM,EACN,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,cAAc,EACd,MAAM,GACT,EACD,SAAS,KACT;AACA,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC1D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAC3D,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC7D,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CACxD,EAAE,CACL;AACD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAsB,IAAI,CAAC;AAClD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;AAClC,IAAA,MAAM,cAAc,GAAG,MAAM,CAAoB,I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AA,QAAA,EAEjDD,cACI,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,MAAA,EAAA,EAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,EACvCA,GAAA,CAAA,SAAA,EAAA,EAAS,MAAM,EAAC,2BAA2B,EAAA,CAAG,CAAA,EAAA,CAC5C,GACD,EAGTA,GAAA,CAAC,eAAe,EAAA,EACZ,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,eAAe,IAAI,CAAC,QAAQ,EAClC,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,OAAO,EACb,GAAG,EAAE,CAAC,EAAA,QAAA,EAENA,GAAA,CAAC,cAAc,EAAA,EACX,SAAS,EAAE,cAAc,EACzB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,kBAAkB,CAAC,KAAK,CAAC,EAC1C,MAAM,EAAE,MAAM,EAAE,cAAc,GAChC,EAAA,CACY,CAAA,EAAA,CAChB;AAEd,CAAC;AAEL,YAAY,CAAC,WAAW,GAAG,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"ChatComposer.js","sources":["../../../../Chat/Kit/ChatComposer.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 type React from 'react';\nimport { forwardRef, useEffect, useId, useImperativeHandle, useRef, useState } from 'react';\nimport { AnchoredOverlay } from './AnchoredOverlay';\nimport type { BuildAvatarUrlParams } from './Avatar';\nimport { activeMentionQuery } from './Mentions/activeMentionQuery';\nimport { applyMention } from './Mentions/applyMention';\nimport { mentionOptionId } from './Mentions/mentionOptionId';\nimport { extractMentions } from './Mentions/extractMentions';\nimport { matchCandidates } from './Mentions/matchCandidates';\nimport { MentionSuggestions, type MentionCandidate } from './Mentions';\nimport { ReactionPicker, type ReactionPickerLabels } from './ReactionPicker';\n\n/** Overrides for the composer's own labels. Any field left unset falls back to a literal English\n * default. */\nexport interface ChatComposerLabels {\n /** Placeholder text for the draft input. Defaults to `'Write a message… (Enter to send)'`. */\n placeholder?: string;\n /** Tooltip/accessible label for the emoji-insert toggle. Defaults to `'Insert emoji'`. */\n insertEmoji?: string;\n /** Tooltip for the send button. Defaults to `'Send'`. */\n send?: string;\n /** Accessible label for the send button. Defaults to `'Send message'`. */\n sendMessage?: string;\n /** Labels forwarded to the emoji-insert {@link ReactionPicker}. */\n reactionPicker?: ReactionPickerLabels;\n}\n\n/**\n * Props for the compose row of a conversation — the text area, the `@` mention list it opens, and\n * the send button. It owns the draft so the surrounding panel stays a renderer of messages.\n */\nexport interface ChatComposerProps {\n /** Everyone who can be mentioned from this conversation. Omit 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 `@` — for hosts whose candidates come from a lookup rather than a list they already\n * hold. May answer synchronously or with a promise; a stale answer (one that arrives after\n * the query has moved on) is dropped. Combines with {@link mentionCandidates} when both are\n * given.\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 /**\n * Invoked with the trimmed message text when the user sends, together with who that text\n * actually mentions — reduced from every candidate the draft saw, so a mention that was\n * picked but edited away again does not count.\n */\n onSend: (text: string, mentions: MentionCandidate[]) => void;\n\n /** Whether to take focus when mounted. */\n autoFocus?: boolean;\n\n /** Disables drafting, emoji insertion, and sending. Defaults to false. */\n disabled?: boolean;\n\n /** Builds the avatar image URL for mention candidates. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Overrides for the composer's labels. Unset fields fall back to literal English defaults. */\n labels?: ChatComposerLabels;\n}\n\n/**\n * Imperative actions a caller can drive on the composer without owning its draft state — used by a\n * quick reply, which sets the starting text for whatever the person types next rather than sending\n * anything itself.\n */\nexport interface ChatComposerHandle {\n /** Replaces the current draft and takes focus, caret placed at the end. */\n prefill: (text: string) => void;\n}\n\n/**\n * The compose row of a conversation — the text area, the `@` mention list it opens, and the send\n * button. It owns the draft so the surrounding panel stays a renderer of messages.\n */\nexport const ChatComposer = forwardRef<ChatComposerHandle, ChatComposerProps>(\n (\n {\n mentionCandidates,\n resolveMentionCandidates,\n onSend,\n autoFocus = false,\n disabled = false,\n buildAvatarUrl,\n labels,\n },\n handleRef,\n ) => {\n const [draft, setDraft] = useState({ text: '', caret: 0 });\n const [highlightedIndex, setHighlightedIndex] = useState(0);\n // The query the user dismissed with Escape; it stays closed until the query itself changes.\n const [dismissed, setDismissed] = useState<{ start: number; text: string } | null>(null);\n const listId = useId();\n const [showEmojiPicker, setShowEmojiPicker] = useState(false);\n const [resolvedCandidates, setResolvedCandidates] = useState<MentionCandidate[]>(\n [],\n );\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const didAutoFocus = useRef(false);\n const emojiButtonRef = useRef<HTMLButtonElement>(null);\n // Every candidate this draft has seen — resolved or picked — so the mentions reported on\n // send can be found again even when the resolver's latest answer no longer includes them.\n const seenCandidatesRef = useRef(new Map<string, MentionCandidate>());\n\n const mentionsEnabled = !!mentionCandidates || !!resolveMentionCandidates;\n const query = mentionsEnabled\n ? activeMentionQuery(draft.text, draft.caret)\n : null;\n const queryText = query?.text;\n const isDismissed =\n dismissed !== null && query?.start === dismissed.start && query.text === dismissed.text;\n\n useEffect(() => {\n if (dismissed !== null && !isDismissed) {\n setDismissed(null);\n }\n }, [dismissed, isDismissed]);\n\n useEffect(() => {\n if (!resolveMentionCandidates || queryText === undefined) {\n setResolvedCandidates((previous) =>\n previous.length === 0 ? previous : [],\n );\n return;\n }\n let cancelled = false;\n Promise.resolve(resolveMentionCandidates(queryText))\n .then((candidates) => {\n if (cancelled) return;\n setResolvedCandidates(candidates);\n candidates.forEach((candidate) =>\n seenCandidatesRef.current.set(candidate.id, candidate),\n );\n })\n .catch(() => {\n if (!cancelled) {\n setResolvedCandidates([]);\n }\n });\n return () => {\n cancelled = true;\n };\n }, [resolveMentionCandidates, queryText]);\n\n const uniqueById = (candidates: MentionCandidate[]): MentionCandidate[] => {\n const byId = new Map<string, MentionCandidate>();\n candidates.forEach((candidate) => {\n if (!byId.has(candidate.id)) {\n byId.set(candidate.id, candidate);\n }\n });\n return [...byId.values()];\n };\n\n const candidatePool = uniqueById([\n ...(mentionCandidates ?? []),\n ...resolvedCandidates,\n ]);\n // A query that ends in whitespace and spells a candidate's full name is a mention already\n // made — the trailing space applyMention writes is its closing. Without this, Enter right\n // after picking would re-pick the same name instead of sending the message.\n const queryIsCompleteMention =\n query !== null &&\n /\\s$/.test(query.text) &&\n candidatePool.some(\n (candidate) =>\n candidate.name.toLowerCase() === query.text.trim().toLowerCase(),\n );\n const suggestions =\n query && !queryIsCompleteMention && !isDismissed\n ? matchCandidates(candidatePool, query.text)\n : [];\n const isSuggesting = !disabled && suggestions.length > 0;\n const highlighted = Math.min(highlightedIndex, suggestions.length - 1);\n\n useEffect(() => {\n if (autoFocus && !disabled && !didAutoFocus.current && inputRef.current) {\n inputRef.current.focus();\n didAutoFocus.current = true;\n }\n }, [autoFocus, disabled]);\n\n useEffect(() => {\n if (disabled) {\n setShowEmojiPicker(false);\n }\n }, [disabled]);\n\n useImperativeHandle(\n handleRef,\n () => ({\n prefill: (text: string) => {\n setDraft({ text, caret: text.length });\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n inputRef.current?.setSelectionRange(text.length, text.length);\n });\n },\n }),\n [],\n );\n\n const readDraft = (element: HTMLTextAreaElement) => {\n const text = element.value;\n // Only editing the text restarts the selection. Resetting on every key event would undo the\n // arrow-key navigation on the very next keyup.\n if (text !== draft.text) {\n setHighlightedIndex(0);\n }\n setDraft({ text, caret: element.selectionStart ?? text.length });\n };\n\n const send = () => {\n const trimmed = draft.text.trim();\n if (!trimmed || disabled) return;\n const known = uniqueById([\n ...(mentionCandidates ?? []),\n ...seenCandidatesRef.current.values(),\n ]);\n onSend(trimmed, extractMentions(trimmed, known));\n seenCandidatesRef.current.clear();\n setDraft({ text: '', caret: 0 });\n };\n\n const choose = (candidate: MentionCandidate) => {\n if (!query) return;\n seenCandidatesRef.current.set(candidate.id, candidate);\n const applied = applyMention(draft.text, draft.caret, query, candidate.name);\n setDraft(applied);\n setHighlightedIndex(0);\n // The caret has to be restored after React has written the new value back into the element.\n requestAnimationFrame(() =>\n inputRef.current?.setSelectionRange(applied.caret, applied.caret),\n );\n inputRef.current?.focus();\n };\n\n const insertEmoji = (emoji: string) => {\n const text = `${draft.text.slice(0, draft.caret)}${emoji}${draft.text.slice(draft.caret)}`;\n const caret = draft.caret + emoji.length;\n setDraft({ text, caret });\n setShowEmojiPicker(false);\n // Same restore-after-write pattern as choose() above — React has to write the new value in\n // before the caret can be placed past the emoji it inserted.\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n inputRef.current?.setSelectionRange(caret, caret);\n });\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (isSuggesting) {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n const step = event.key === 'ArrowDown' ? 1 : suggestions.length - 1;\n setHighlightedIndex((highlighted + step) % suggestions.length);\n return;\n }\n\n if (event.key === 'Enter' || event.key === 'Tab') {\n event.preventDefault();\n choose(suggestions[highlighted]);\n return;\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n // The Escape belongs to the list while it is open, not to a dialog around the composer.\n event.stopPropagation();\n // Closing the list leaves the draft and caret alone.\n setDismissed(query);\n return;\n }\n }\n\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n send();\n }\n };\n\n return (\n <div className='chat-composer'>\n {isSuggesting && (\n <MentionSuggestions\n candidates={suggestions}\n highlightedIndex={highlighted}\n id={listId}\n onSelect={choose}\n onHighlight={setHighlightedIndex}\n buildAvatarUrl={buildAvatarUrl}\n />\n )}\n <textarea\n ref={inputRef}\n className='chat-composer__input'\n value={draft.text}\n onChange={(event) => readDraft(event.target)}\n onKeyUp={(event) => readDraft(event.currentTarget)}\n onClick={(event) => readDraft(event.currentTarget)}\n onKeyDown={handleKeyDown}\n placeholder={\n labels?.placeholder ?? 'Write a message… (Enter to send)'\n }\n rows={2}\n aria-autocomplete={isSuggesting ? 'list' : undefined}\n aria-controls={isSuggesting ? listId : undefined}\n aria-activedescendant={isSuggesting ? mentionOptionId(listId, highlighted) : undefined}\n disabled={disabled}\n />\n <button\n ref={emojiButtonRef}\n type='button'\n className='chat-composer__emoji-toggle'\n disabled={disabled}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => setShowEmojiPicker((previous) => !previous)}\n title={labels?.insertEmoji ?? 'Insert emoji'}\n aria-label={labels?.insertEmoji ?? 'Insert emoji'}\n aria-expanded={showEmojiPicker}\n >\n ☺\n </button>\n <button\n type='button'\n className='chat-composer__send'\n onClick={send}\n disabled={disabled || !draft.text.trim()}\n title={labels?.send ?? 'Send'}\n aria-label={labels?.sendMessage ?? 'Send message'}\n >\n <svg\n width='16'\n height='16'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2.5'\n aria-hidden='true'\n >\n <line x1='22' y1='2' x2='11' y2='13' />\n <polygon points='22 2 15 22 11 13 2 9 22 2' />\n </svg>\n </button>\n {/* Portaled to <body>, same reason as the reaction picker on a message bubble: the chat\n panel scrolls/clips, so a picker positioned inside it would be cut off at the edge. */}\n <AnchoredOverlay\n anchorRef={emojiButtonRef}\n open={showEmojiPicker && !disabled}\n side='above'\n align='right'\n gap={6}\n >\n <ReactionPicker\n anchorRef={emojiButtonRef}\n onPick={insertEmoji}\n onDismiss={() => setShowEmojiPicker(false)}\n labels={labels?.reactionPicker}\n />\n </AnchoredOverlay>\n </div>\n );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AAI,MAAM,gBACjB,MAAM,EAAE,WAAW,IAAI,cAAc,EAAA,QAAA,EAEjDD,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,iBACL,MAAM,EAAA,QAAA,EAAA,CAElBC,cAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,EACvCA,GAAA,CAAA,SAAA,EAAA,EAAS,MAAM,EAAC,2BAA2B,EAAA,CAAG,IAC5C,EAAA,CACD,EAGTA,IAAC,eAAe,EAAA,EACZ,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,eAAe,IAAI,CAAC,QAAQ,EAClC,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,OAAO,EACb,GAAG,EAAE,CAAC,EAAA,QAAA,EAENA,IAAC,cAAc,EAAA,EACX,SAAS,EAAE,cAAc,EACzB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,kBAAkB,CAAC,KAAK,CAAC,EAC1C,MAAM,EAAE,MAAM,EAAE,cAAc,GAChC,EAAA,CACY,CAAA,EAAA,CAChB;AAEd,CAAC;AAEL,YAAY,CAAC,WAAW,GAAG,cAAc;;"}
|
|
@@ -13,6 +13,8 @@ export interface MentionSuggestionsProps {
|
|
|
13
13
|
onSelect: (candidate: MentionCandidate) => void;
|
|
14
14
|
/** Invoked when the pointer moves onto a candidate, so hover and keyboard stay in step. */
|
|
15
15
|
onHighlight: (index: number) => void;
|
|
16
|
+
/** Id of the list element. When given, each option gets a position-based id the input can reference with `aria-activedescendant`. */
|
|
17
|
+
id?: string;
|
|
16
18
|
/** Accessible name for the suggestion list. Defaults to `'Mention suggestions'`. */
|
|
17
19
|
'aria-label'?: string;
|
|
18
20
|
/** Builds the avatar image URL. Omit to always show initials — see {@link PersonAvatarCircleProps}. */
|
|
@@ -22,5 +24,5 @@ export interface MentionSuggestionsProps {
|
|
|
22
24
|
* The list that opens while an `@` mention is being typed, showing people and agents together with
|
|
23
25
|
* their avatars.
|
|
24
26
|
*/
|
|
25
|
-
export declare const MentionSuggestions: ({ candidates, highlightedIndex, onSelect, onHighlight, buildAvatarUrl, 'aria-label': ariaLabel, }: MentionSuggestionsProps) => import("react").JSX.Element;
|
|
27
|
+
export declare const MentionSuggestions: ({ candidates, highlightedIndex, onSelect, onHighlight, buildAvatarUrl, id, 'aria-label': ariaLabel, }: MentionSuggestionsProps) => import("react").JSX.Element;
|
|
26
28
|
//# sourceMappingURL=MentionSuggestions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentionSuggestions.d.ts","sourceRoot":"","sources":["../../../../../Chat/Kit/Mentions/MentionSuggestions.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,oBAAW,CAAC;AAE1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"MentionSuggestions.d.ts","sourceRoot":"","sources":["../../../../../Chat/Kit/Mentions/MentionSuggestions.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,oBAAW,CAAC;AAE1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAoB,CAAC;AAG3D;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACpC,wEAAwE;IACxE,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAE/B,iEAAiE;IACjE,gBAAgB,EAAE,MAAM,CAAC;IAEzB,kDAAkD;IAClD,QAAQ,EAAE,CAAC,SAAS,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAEhD,2FAA2F;IAC3F,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAErC,qIAAqI;IACrI,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,oFAAoF;IACpF,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,uGAAuG;IACvG,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,MAAM,CAAC;CAC7D;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,0GAQ5B,uBAAuB,gCA+BzB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { PersonAvatarCircle } from '../Avatar/PersonAvatarCircle.js';
|
|
3
3
|
import { ChatAuthorKind } from '../ChatAuthorKind.js';
|
|
4
|
+
import { mentionOptionId } from './mentionOptionId.js';
|
|
4
5
|
|
|
5
|
-
const MentionSuggestions = ({ candidates, highlightedIndex, onSelect, onHighlight, buildAvatarUrl, 'aria-label': ariaLabel = 'Mention suggestions', }) => (jsx("div", { className: 'mention-suggestions', role: 'listbox', "aria-label": ariaLabel, children: candidates.map((candidate, index) => (jsxs("button", { type: 'button', role: 'option', "aria-selected": index === highlightedIndex, className: `mention-suggestions__item${index === highlightedIndex ? ' mention-suggestions__item--highlighted' : ''}`, onMouseDown: (event) => event.preventDefault(), onMouseEnter: () => onHighlight(index), onClick: () => onSelect(candidate), children: [jsx(PersonAvatarCircle, { userId: candidate.id, name: candidate.name, hasAvatar: candidate.hasAvatar, size: 20, ownerType: candidate.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users', version: candidate.avatarVersion, buildAvatarUrl: buildAvatarUrl }), jsx("span", { className: 'mention-suggestions__name', children: candidate.name })] }, candidate.id))) }));
|
|
6
|
+
const MentionSuggestions = ({ candidates, highlightedIndex, onSelect, onHighlight, buildAvatarUrl, id, 'aria-label': ariaLabel = 'Mention suggestions', }) => (jsx("div", { id: id, className: 'mention-suggestions', role: 'listbox', "aria-label": ariaLabel, children: candidates.map((candidate, index) => (jsxs("button", { id: id === undefined ? undefined : mentionOptionId(id, index), type: 'button', tabIndex: -1, role: 'option', "aria-selected": index === highlightedIndex, className: `mention-suggestions__item${index === highlightedIndex ? ' mention-suggestions__item--highlighted' : ''}`, onMouseDown: (event) => event.preventDefault(), onMouseEnter: () => onHighlight(index), onClick: () => onSelect(candidate), children: [jsx(PersonAvatarCircle, { userId: candidate.id, name: candidate.name, hasAvatar: candidate.hasAvatar, size: 20, ownerType: candidate.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users', version: candidate.avatarVersion, buildAvatarUrl: buildAvatarUrl }), jsx("span", { className: 'mention-suggestions__name', children: candidate.name })] }, candidate.id))) }));
|
|
6
7
|
|
|
7
8
|
export { MentionSuggestions };
|
|
8
9
|
//# sourceMappingURL=MentionSuggestions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentionSuggestions.js","sources":["../../../../../Chat/Kit/Mentions/MentionSuggestions.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 { PersonAvatarCircle, type BuildAvatarUrlParams } from '../Avatar';\nimport { ChatAuthorKind } from '../ChatAuthorKind';\nimport type { MentionCandidate } from './MentionCandidate';\n\n/**\n * Props for the list that opens while an `@` mention is being typed, showing people and agents\n * together with their avatars.\n */\nexport interface MentionSuggestionsProps {\n /** The candidates to offer, already filtered by what has been typed. */\n candidates: MentionCandidate[];\n\n /** The index of the highlighted candidate, which Enter picks. */\n highlightedIndex: number;\n\n /** Invoked with the candidate the user picked. */\n onSelect: (candidate: MentionCandidate) => void;\n\n /** Invoked when the pointer moves onto a candidate, so hover and keyboard stay in step. */\n onHighlight: (index: number) => void;\n\n /** Accessible name for the suggestion list. Defaults to `'Mention suggestions'`. */\n 'aria-label'?: string;\n\n /** Builds the avatar image URL. Omit to always show initials — see {@link PersonAvatarCircleProps}. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n}\n\n/**\n * The list that opens while an `@` mention is being typed, showing people and agents together with\n * their avatars.\n */\nexport const MentionSuggestions = ({\n candidates,\n highlightedIndex,\n onSelect,\n onHighlight,\n buildAvatarUrl,\n 'aria-label': ariaLabel = 'Mention suggestions',\n}: MentionSuggestionsProps) => (\n <div className='mention-suggestions' role='listbox' aria-label={ariaLabel}>\n {candidates.map((candidate, index) => (\n <button\n key={candidate.id}\n type='button'\n role='option'\n aria-selected={index === highlightedIndex}\n className={`mention-suggestions__item${index === highlightedIndex ? ' mention-suggestions__item--highlighted' : ''}`}\n // The input must keep focus, so the pointer press never reaches it as a blur.\n onMouseDown={(event) => event.preventDefault()}\n onMouseEnter={() => onHighlight(index)}\n onClick={() => onSelect(candidate)}\n >\n <PersonAvatarCircle\n userId={candidate.id}\n name={candidate.name}\n hasAvatar={candidate.hasAvatar}\n size={20}\n ownerType={\n candidate.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users'\n }\n version={candidate.avatarVersion}\n buildAvatarUrl={buildAvatarUrl}\n />\n <span className='mention-suggestions__name'>{candidate.name}</span>\n </button>\n ))}\n </div>\n);\n"],"names":["_jsx","_jsxs"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MentionSuggestions.js","sources":["../../../../../Chat/Kit/Mentions/MentionSuggestions.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 { PersonAvatarCircle, type BuildAvatarUrlParams } from '../Avatar';\nimport { ChatAuthorKind } from '../ChatAuthorKind';\nimport type { MentionCandidate } from './MentionCandidate';\nimport { mentionOptionId } from './mentionOptionId';\n\n/**\n * Props for the list that opens while an `@` mention is being typed, showing people and agents\n * together with their avatars.\n */\nexport interface MentionSuggestionsProps {\n /** The candidates to offer, already filtered by what has been typed. */\n candidates: MentionCandidate[];\n\n /** The index of the highlighted candidate, which Enter picks. */\n highlightedIndex: number;\n\n /** Invoked with the candidate the user picked. */\n onSelect: (candidate: MentionCandidate) => void;\n\n /** Invoked when the pointer moves onto a candidate, so hover and keyboard stay in step. */\n onHighlight: (index: number) => void;\n\n /** Id of the list element. When given, each option gets a position-based id the input can reference with `aria-activedescendant`. */\n id?: string;\n\n /** Accessible name for the suggestion list. Defaults to `'Mention suggestions'`. */\n 'aria-label'?: string;\n\n /** Builds the avatar image URL. Omit to always show initials — see {@link PersonAvatarCircleProps}. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n}\n\n/**\n * The list that opens while an `@` mention is being typed, showing people and agents together with\n * their avatars.\n */\nexport const MentionSuggestions = ({\n candidates,\n highlightedIndex,\n onSelect,\n onHighlight,\n buildAvatarUrl,\n id,\n 'aria-label': ariaLabel = 'Mention suggestions',\n}: MentionSuggestionsProps) => (\n <div id={id} className='mention-suggestions' role='listbox' aria-label={ariaLabel}>\n {candidates.map((candidate, index) => (\n <button\n key={candidate.id}\n id={id === undefined ? undefined : mentionOptionId(id, index)}\n type='button'\n tabIndex={-1}\n role='option'\n aria-selected={index === highlightedIndex}\n className={`mention-suggestions__item${index === highlightedIndex ? ' mention-suggestions__item--highlighted' : ''}`}\n // The input must keep focus, so the pointer press never reaches it as a blur.\n onMouseDown={(event) => event.preventDefault()}\n onMouseEnter={() => onHighlight(index)}\n onClick={() => onSelect(candidate)}\n >\n <PersonAvatarCircle\n userId={candidate.id}\n name={candidate.name}\n hasAvatar={candidate.hasAvatar}\n size={20}\n ownerType={\n candidate.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users'\n }\n version={candidate.avatarVersion}\n buildAvatarUrl={buildAvatarUrl}\n />\n <span className='mention-suggestions__name'>{candidate.name}</span>\n </button>\n ))}\n </div>\n);\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;MAuCa,kBAAkB,GAAG,CAAC,EAC/B,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,EAAE,EACF,YAAY,EAAE,SAAS,GAAG,qBAAqB,GACzB,MACtBA,aAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAC,qBAAqB,EAAC,IAAI,EAAC,SAAS,EAAA,YAAA,EAAa,SAAS,EAAA,QAAA,EAC5E,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,MAC7BC,iBAEI,EAAE,EAAE,EAAE,KAAK,SAAS,GAAG,SAAS,GAAG,eAAe,CAAC,EAAE,EAAE,KAAK,CAAC,EAC7D,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,EAAE,EACZ,IAAI,EAAC,QAAQ,EAAA,eAAA,EACE,KAAK,KAAK,gBAAgB,EACzC,SAAS,EAAE,CAAA,yBAAA,EAA4B,KAAK,KAAK,gBAAgB,GAAG,yCAAyC,GAAG,EAAE,EAAE,EAEpH,WAAW,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,cAAc,EAAE,EAC9C,YAAY,EAAE,MAAM,WAAW,CAAC,KAAK,CAAC,EACtC,OAAO,EAAE,MAAM,QAAQ,CAAC,SAAS,CAAC,aAElCD,GAAA,CAAC,kBAAkB,EAAA,EACf,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,IAAI,EAAE,SAAS,CAAC,IAAI,EACpB,SAAS,EAAE,SAAS,CAAC,SAAS,EAC9B,IAAI,EAAE,EAAE,EACR,SAAS,EACL,SAAS,CAAC,IAAI,KAAK,cAAc,CAAC,KAAK,GAAG,QAAQ,GAAG,OAAO,EAEhE,OAAO,EAAE,SAAS,CAAC,aAAa,EAChC,cAAc,EAAE,cAAc,EAAA,CAChC,EACFA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,2BAA2B,EAAA,QAAA,EAAE,SAAS,CAAC,IAAI,EAAA,CAAQ,CAAA,EAAA,EAvB9D,SAAS,CAAC,EAAE,CAwBZ,CACZ,CAAC,EAAA,CACA;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the DOM id of a suggestion option from its list's id and its position, never from the
|
|
3
|
+
* candidate's own id, which comes from the host and can repeat across composers.
|
|
4
|
+
* @param listId The id of the suggestion list.
|
|
5
|
+
* @param index The option's position in the list.
|
|
6
|
+
* @returns The id the textarea's `aria-activedescendant` refers to.
|
|
7
|
+
*/
|
|
8
|
+
export declare const mentionOptionId: (listId: string, index: number) => string;
|
|
9
|
+
//# sourceMappingURL=mentionOptionId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mentionOptionId.d.ts","sourceRoot":"","sources":["../../../../../Chat/Kit/Mentions/mentionOptionId.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,WAAY,MAAM,SAAS,MAAM,KAAG,MAAqC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mentionOptionId.js","sources":["../../../../../Chat/Kit/Mentions/mentionOptionId.ts"],"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\n/**\n * Builds the DOM id of a suggestion option from its list's id and its position, never from the\n * candidate's own id, which comes from the host and can repeat across composers.\n * @param listId The id of the suggestion list.\n * @param index The option's position in the list.\n * @returns The id the textarea's `aria-activedescendant` refers to.\n */\nexport const mentionOptionId = (listId: string, index: number): string => `${listId}-option-${index}`;\n"],"names":[],"mappings":"AAUO,MAAM,eAAe,GAAG,CAAC,MAAc,EAAE,KAAa,KAAa,CAAA,EAAG,MAAM,CAAA,QAAA,EAAW,KAAK;;"}
|
package/dist/esm/styles.Chat.css
CHANGED
package/dist/esm/styles.css
CHANGED
package/dist/esm/theme.css
CHANGED
|
@@ -188,6 +188,7 @@
|
|
|
188
188
|
.cratis-theme:not(.cratis-light) {
|
|
189
189
|
--cratis-primary-color: Highlight;
|
|
190
190
|
--cratis-primary-color-text: HighlightText;
|
|
191
|
+
--cratis-primary-600: Highlight;
|
|
191
192
|
--cratis-primary-600-text: HighlightText;
|
|
192
193
|
--cratis-action-background: Highlight;
|
|
193
194
|
--cratis-action-text: HighlightText;
|
package/package.json
CHANGED