dou-ui 0.1.0-alpha.16 → 0.1.0-alpha.17
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/dist/components/chat-message/chat-message.js.map +1 -1
- package/dist/components/chat-message/chat-message.vue_vue_type_script_setup_true_lang.js +23 -7
- package/dist/components/chat-message/chat-message.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/chat-message/chat-message2.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/components/chat-message/chat-message.d.ts +8 -0
- package/dist/types/components/chat-message/chat-message.vue.d.ts +1 -0
- package/dist/types/components/chat-message/index.d.ts +3 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-message.js","names":[],"sources":["../../../src/components/chat-message/chat-message.ts"],"sourcesContent":["import type { ChatArtifactKind, ChatArtifactStatus } from '../chat-artifact/chat-artifact'\nimport type { ChatAttachment } from '../chat-attachments/chat-attachments'\nimport type {\n ChatConfirmDecision,\n ChatConfirmStatus,\n ChatConfirmTone,\n} from '../chat-confirm/chat-confirm'\nimport type { ChatPlanItem } from '../chat-plan/chat-plan'\nimport type { ChatQuestionOption, ChatQuestionStatus } from '../chat-question/chat-question'\nimport type { ChatSource } from '../chat-sources/chat-sources'\nimport type { ChatStep } from '../chat-steps/chat-steps'\nimport type { ChatToolCallStatus } from '../chat-tool-call/chat-tool-call'\nimport type { MarkdownProps, MarkdownSlots } from '../markdown/markdown'\n\n/** Options for the Markdown of text and reasoning parts. */\nexport type ChatMessageMarkdown = Pick<\n MarkdownProps,\n 'smooth' | 'speed' | 'caret' | 'linkTarget' | 'sanitizeUrl'\n>\n\n/** Who wrote the message. */\nexport type ChatMessageSender = 'user' | 'assistant' | 'system'\n\n/** When the bar of actions over a message shows. */\nexport type ChatMessageActionsVisible = 'always' | 'hover'\n\n/** One kind of reaction on a message, e.g. 👍 from three people. */\nexport interface ChatMessageReaction {\n /** The emoji, or any key the app knows the reaction by; shown as is unless the `reaction` slot renders it. */\n emoji: string\n /** How many reacted this way. A reaction at 0 is not shown. */\n count: number\n /** The person reacted this way too; pressing it again takes theirs back. */\n reacted?: boolean\n /** More about it, e.g. who reacted; read out and shown on hover after the emoji and count. */\n label?: string\n}\n\nexport interface ChatTextPart {\n type: 'text'\n text: string\n /** More text is still coming. */\n streaming?: boolean\n}\nexport interface ChatReasoningPart {\n type: 'reasoning'\n text: string\n thinking?: boolean\n /** Seconds it took. */\n duration?: number\n}\nexport interface ChatToolPart {\n type: 'tool'\n name?: string\n title?: string\n status?: ChatToolCallStatus\n input?: unknown\n output?: unknown\n live?: boolean\n}\nexport interface ChatStepsPart {\n type: 'steps'\n items: ChatStep[]\n live?: boolean\n title?: string\n}\nexport interface ChatPlanPart {\n type: 'plan'\n items: ChatPlanItem[]\n title?: string\n collapsible?: boolean\n live?: boolean\n}\nexport interface ChatSourcesPart {\n type: 'sources'\n items: ChatSource[]\n}\nexport interface ChatFilesPart {\n type: 'files'\n files: ChatAttachment[]\n}\nexport interface ChatArtifactPart {\n type: 'artifact'\n /** Handed back with `artifact`, to tell artifacts apart. */\n id?: string | number\n title: string\n kind?: ChatArtifactKind\n /** Below the title. While running it shimmers; left out, the line reads \"Generating\". */\n description?: string\n status?: ChatArtifactStatus\n active?: boolean\n}\nexport interface ChatConfirmPart {\n type: 'confirm'\n /** Handed back with `confirm`, to tell requests apart. */\n id?: string | number\n title: string\n description?: string\n status?: ChatConfirmStatus\n allowAlways?: boolean\n tone?: ChatConfirmTone\n /** Shown as monospace detail, e.g. the command to run or a diff. */\n detail?: string\n}\nexport interface ChatQuestionPart {\n type: 'question'\n /** Handed back with `question`, to tell questions apart. */\n id?: string | number\n title: string\n description?: string\n options: ChatQuestionOption[]\n status?: ChatQuestionStatus\n /** The `value` of the option chosen. */\n answer?: string | number\n}\n/** Any other part; render it with the `part` slot. */\nexport interface ChatCustomPart {\n type: string\n [key: string]: unknown\n}\n\nexport type ChatMessagePart =\n | ChatTextPart\n | ChatReasoningPart\n | ChatToolPart\n | ChatStepsPart\n | ChatPlanPart\n | ChatSourcesPart\n | ChatFilesPart\n | ChatArtifactPart\n | ChatConfirmPart\n | ChatQuestionPart\n\nexport interface ChatMessageProps {\n sender?: ChatMessageSender\n /**\n * What the message is made of, in order: text, reasoning, tool calls,\n * steps, a plan, sources, files, artifacts, confirmations and questions may follow\n * one another in any order.\n */\n parts?: (ChatMessagePart | ChatCustomPart)[]\n /** Shorthand for a message of one text part. */\n content?: string\n /**\n * Render text and reasoning parts as Markdown, streaming included. `[1]`\n * in the text becomes a citation of the message's sources parts. An\n * object turns it on with options for the Markdown component, such as\n * `sanitizeUrl`. Set it for every message in the ConfigProvider's\n * `defaults`.\n */\n markdown?: boolean | ChatMessageMarkdown\n /** No part has arrived yet: show the waiting dots, like ChatBubble's. */\n loading?: boolean\n /**\n * When the bar of actions over the top right corner shows: `'always'`,\n * or `'hover'` while the pointer is over the message, focus is inside,\n * or after a tap on it on a touch screen. Buttons from the `actions`\n * slot follow along. Defaults to `'hover'`.\n */\n actionsVisible?: ChatMessageActionsVisible\n /** Show a copy button among the actions, copying the text parts. */\n copyable?: boolean\n /** Offer an edit button on the person's own messages; saving emits `edit`. */\n editable?: boolean\n /** How many versions of this message there are, e.g. after regenerating. Two or more show a switcher. */\n versions?: number\n /** Which version is shown, from 1. Bound with `v-model:version`. */\n version?: number\n /**\n * Mark this message with a ring in the primary color that hugs the\n * bubble, e.g. after a search jumped to it. It stays while set and fades\n * once turned off (at once with reduced motion): turn it off after a\n * moment. Pair it with ChatList's `scrollToMessage`.\n */\n highlighted?: boolean\n /**\n * The reactions under the message, each with how many reacted and\n * whether the person did; one entry per emoji. Pressing one emits `react`; the app adds or\n * takes back the person's reaction itself.\n */\n reactions?: ChatMessageReaction[]\n}\n\nexport interface ChatMessageEmits {\n 'update:version': [version: number]\n /** An edited message was saved, with its new text. */\n edit: [text: string]\n /** A confirmation part was answered. */\n confirm: [part: ChatConfirmPart, decision: ChatConfirmDecision]\n /** An artifact part was pressed. */\n artifact: [part: ChatArtifactPart]\n /** An option of a question part was pressed, with its `value` and the option itself. */\n question: [part: ChatQuestionPart, value: string | number, option: ChatQuestionOption]\n /**\n * A reaction was pressed, or picked in the `reaction-picker` slot: add\n * the person's reaction, or take it back if `reacted` was on. `reaction`\n * is the entry of `reactions` with that emoji, if there is one.\n */\n react: [emoji: string, reaction: ChatMessageReaction | undefined]\n}\n\nexport interface ChatMessageSlots {\n /**\n * Renders a text part by hand, in place of plain text or `markdown`.\n * `text` is what has been revealed so far; `part.text` is all of it.\n * `sources` are the message's sources, for citations.\n */\n text?: (props: {\n part: ChatTextPart\n text: string\n index: number\n sources: ChatSource[]\n }) => unknown\n /** Renders parts of a type the message does not know. */\n part?: (props: { part: ChatCustomPart; index: number }) => unknown\n /** Buttons after the built-in actions, e.g. regenerate or feedback. */\n actions?: () => unknown\n /**\n * Content that follows the last word of the last text part on the same\n * line, e.g. an \"edited\" mark. Unlike `actions` it always shows, whatever\n * `actionsVisible` is. Without a text part it takes a line after the parts,\n * once `loading` is off.\n */\n trailing?: () => unknown\n /**\n * The panel opened by the add-reaction button, e.g. a row of common\n * emoji. Without it there is no add button. `react(emoji)` emits `react`\n * and closes the panel; `close` closes it without reacting.\n */\n 'reaction-picker'?: (props: { react: (emoji: string) => void; close: () => void }) => unknown\n /** Renders the emoji of a reaction, e.g. a custom image for an app's own key. */\n reaction?: (props: { reaction: ChatMessageReaction }) => unknown\n /** Replaces all parts, for a message laid out by hand. */\n default?: () => unknown\n}\n\n/**\n * The Markdown component's slots, with a `markdown-` prefix, for text\n * rendered with `markdown`: `markdown-code`, `markdown-container-tip`, ...\n */\nexport type ChatMessageMarkdownSlots = {\n [K in Exclude<keyof MarkdownSlots, 'trailing'> as `markdown-${K & string}`]: MarkdownSlots[K]\n}\n\n/** The text of a message, for copying: its text parts, one paragraph each. */\nexport function messageText(parts: readonly { type: string; text?: unknown }[]): string {\n return parts\n .filter((part) => part.type === 'text' && typeof part.text === 'string')\n .map((part) => part.text as string)\n .join('\\n\\n')\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"chat-message.js","names":[],"sources":["../../../src/components/chat-message/chat-message.ts"],"sourcesContent":["import type { ChatArtifactKind, ChatArtifactStatus } from '../chat-artifact/chat-artifact'\nimport type { ChatAttachment } from '../chat-attachments/chat-attachments'\nimport type {\n ChatConfirmDecision,\n ChatConfirmStatus,\n ChatConfirmTone,\n} from '../chat-confirm/chat-confirm'\nimport type { ChatPlanItem } from '../chat-plan/chat-plan'\nimport type { ChatQuestionOption, ChatQuestionStatus } from '../chat-question/chat-question'\nimport type { ChatSource } from '../chat-sources/chat-sources'\nimport type { ChatStep } from '../chat-steps/chat-steps'\nimport type { ChatToolCallStatus } from '../chat-tool-call/chat-tool-call'\nimport type { MarkdownProps, MarkdownSlots } from '../markdown/markdown'\n\n/** Options for the Markdown of text and reasoning parts. */\nexport type ChatMessageMarkdown = Pick<\n MarkdownProps,\n 'smooth' | 'speed' | 'caret' | 'linkTarget' | 'sanitizeUrl'\n>\n\n/** Who wrote the message. */\nexport type ChatMessageSender = 'user' | 'assistant' | 'system'\n\n/** When the bar of actions over a message shows. */\nexport type ChatMessageActionsVisible = 'always' | 'hover'\n\n/** One kind of reaction on a message, e.g. 👍 from three people. */\nexport interface ChatMessageReaction {\n /** The emoji, or any key the app knows the reaction by; shown as is unless the `reaction` slot renders it. */\n emoji: string\n /** How many reacted this way. A reaction at 0 is not shown. */\n count: number\n /** The person reacted this way too; pressing it again takes theirs back. */\n reacted?: boolean\n /** More about it, e.g. who reacted; read out and shown on hover after the emoji and count. */\n label?: string\n}\n\nexport interface ChatTextPart {\n type: 'text'\n text: string\n /** More text is still coming. */\n streaming?: boolean\n}\nexport interface ChatReasoningPart {\n type: 'reasoning'\n text: string\n thinking?: boolean\n /** Seconds it took. */\n duration?: number\n}\nexport interface ChatToolPart {\n type: 'tool'\n name?: string\n title?: string\n status?: ChatToolCallStatus\n input?: unknown\n output?: unknown\n live?: boolean\n}\nexport interface ChatStepsPart {\n type: 'steps'\n items: ChatStep[]\n live?: boolean\n title?: string\n}\nexport interface ChatPlanPart {\n type: 'plan'\n items: ChatPlanItem[]\n title?: string\n collapsible?: boolean\n live?: boolean\n}\nexport interface ChatSourcesPart {\n type: 'sources'\n items: ChatSource[]\n}\nexport interface ChatFilesPart {\n type: 'files'\n files: ChatAttachment[]\n}\nexport interface ChatArtifactPart {\n type: 'artifact'\n /** Handed back with `artifact`, to tell artifacts apart. */\n id?: string | number\n title: string\n kind?: ChatArtifactKind\n /** Below the title. While running it shimmers; left out, the line reads \"Generating\". */\n description?: string\n status?: ChatArtifactStatus\n active?: boolean\n}\nexport interface ChatConfirmPart {\n type: 'confirm'\n /** Handed back with `confirm`, to tell requests apart. */\n id?: string | number\n title: string\n description?: string\n status?: ChatConfirmStatus\n allowAlways?: boolean\n tone?: ChatConfirmTone\n /** Shown as monospace detail, e.g. the command to run or a diff. */\n detail?: string\n}\nexport interface ChatQuestionPart {\n type: 'question'\n /** Handed back with `question`, to tell questions apart. */\n id?: string | number\n title: string\n description?: string\n options: ChatQuestionOption[]\n status?: ChatQuestionStatus\n /** The `value` of the option chosen. */\n answer?: string | number\n}\n/** Any other part; render it with the `part` slot. */\nexport interface ChatCustomPart {\n type: string\n [key: string]: unknown\n}\n\nexport type ChatMessagePart =\n | ChatTextPart\n | ChatReasoningPart\n | ChatToolPart\n | ChatStepsPart\n | ChatPlanPart\n | ChatSourcesPart\n | ChatFilesPart\n | ChatArtifactPart\n | ChatConfirmPart\n | ChatQuestionPart\n\nexport interface ChatMessageProps {\n sender?: ChatMessageSender\n /**\n * What the message is made of, in order: text, reasoning, tool calls,\n * steps, a plan, sources, files, artifacts, confirmations and questions may follow\n * one another in any order.\n */\n parts?: (ChatMessagePart | ChatCustomPart)[]\n /** Shorthand for a message of one text part. */\n content?: string\n /**\n * Render text and reasoning parts as Markdown, streaming included. `[1]`\n * in the text becomes a citation of the message's sources parts. An\n * object turns it on with options for the Markdown component, such as\n * `sanitizeUrl`. Set it for every message in the ConfigProvider's\n * `defaults`.\n */\n markdown?: boolean | ChatMessageMarkdown\n /** No part has arrived yet: show the waiting dots, like ChatBubble's. */\n loading?: boolean\n /**\n * When the bar of actions over the top right corner shows: `'always'`,\n * or `'hover'` while the pointer is over the message, focus is inside,\n * or after a tap on it on a touch screen. Buttons from the `actions`\n * slot follow along. Defaults to `'hover'`.\n */\n actionsVisible?: ChatMessageActionsVisible\n /** Show a copy button among the actions, copying the text parts. */\n copyable?: boolean\n /** Offer an edit button on the person's own messages; saving emits `edit`. */\n editable?: boolean\n /** How many versions of this message there are, e.g. after regenerating. Two or more show a switcher. */\n versions?: number\n /** Which version is shown, from 1. Bound with `v-model:version`. */\n version?: number\n /**\n * Mark this message with a ring in the primary color that hugs the\n * bubble, e.g. after a search jumped to it. It stays while set and fades\n * once turned off (at once with reduced motion): turn it off after a\n * moment. Pair it with ChatList's `scrollToMessage`.\n */\n highlighted?: boolean\n /**\n * The reactions under the message, each with how many reacted and\n * whether the person did; one entry per emoji. Pressing one emits `react`; the app adds or\n * takes back the person's reaction itself.\n */\n reactions?: ChatMessageReaction[]\n /**\n * Let the person press `reactions` and add new ones. Turn it off to only\n * show them, e.g. on their own messages or in an archived conversation:\n * the chips look the same and keep the hover text, but cannot be pressed,\n * and there is no add-reaction button even with a `reaction-picker` slot.\n * Defaults to `true`.\n */\n reactable?: boolean\n}\n\nexport interface ChatMessageEmits {\n 'update:version': [version: number]\n /** An edited message was saved, with its new text. */\n edit: [text: string]\n /** A confirmation part was answered. */\n confirm: [part: ChatConfirmPart, decision: ChatConfirmDecision]\n /** An artifact part was pressed. */\n artifact: [part: ChatArtifactPart]\n /** An option of a question part was pressed, with its `value` and the option itself. */\n question: [part: ChatQuestionPart, value: string | number, option: ChatQuestionOption]\n /**\n * A reaction was pressed, or picked in the `reaction-picker` slot: add\n * the person's reaction, or take it back if `reacted` was on. `reaction`\n * is the entry of `reactions` with that emoji, if there is one.\n */\n react: [emoji: string, reaction: ChatMessageReaction | undefined]\n}\n\nexport interface ChatMessageSlots {\n /**\n * Renders a text part by hand, in place of plain text or `markdown`.\n * `text` is what has been revealed so far; `part.text` is all of it.\n * `sources` are the message's sources, for citations.\n */\n text?: (props: {\n part: ChatTextPart\n text: string\n index: number\n sources: ChatSource[]\n }) => unknown\n /** Renders parts of a type the message does not know. */\n part?: (props: { part: ChatCustomPart; index: number }) => unknown\n /** Buttons after the built-in actions, e.g. regenerate or feedback. */\n actions?: () => unknown\n /**\n * Content that follows the last word of the last text part on the same\n * line, e.g. an \"edited\" mark. Unlike `actions` it always shows, whatever\n * `actionsVisible` is. Without a text part it takes a line after the parts,\n * once `loading` is off.\n */\n trailing?: () => unknown\n /**\n * The panel opened by the add-reaction button, e.g. a row of common\n * emoji. Without it there is no add button. `react(emoji)` emits `react`\n * and closes the panel; `close` closes it without reacting.\n */\n 'reaction-picker'?: (props: { react: (emoji: string) => void; close: () => void }) => unknown\n /** Renders the emoji of a reaction, e.g. a custom image for an app's own key. */\n reaction?: (props: { reaction: ChatMessageReaction }) => unknown\n /** Replaces all parts, for a message laid out by hand. */\n default?: () => unknown\n}\n\n/**\n * The Markdown component's slots, with a `markdown-` prefix, for text\n * rendered with `markdown`: `markdown-code`, `markdown-container-tip`, ...\n */\nexport type ChatMessageMarkdownSlots = {\n [K in Exclude<keyof MarkdownSlots, 'trailing'> as `markdown-${K & string}`]: MarkdownSlots[K]\n}\n\n/** The text of a message, for copying: its text parts, one paragraph each. */\nexport function messageText(parts: readonly { type: string; text?: unknown }[]): string {\n return parts\n .filter((part) => part.type === 'text' && typeof part.text === 'string')\n .map((part) => part.text as string)\n .join('\\n\\n')\n}\n"],"mappings":";;AA6PA,SAAgB,YAAY,OAA4D;CACtF,OAAO,MACJ,QAAQ,SAAS,KAAK,SAAS,UAAU,OAAO,KAAK,SAAS,QAAQ,CAAC,CACvE,KAAK,SAAS,KAAK,IAAc,CAAC,CAClC,KAAK,MAAM;AAChB"}
|
|
@@ -27,12 +27,13 @@ var _hoisted_1 = ["aria-busy", "aria-current"];
|
|
|
27
27
|
var _hoisted_2 = ["aria-label"];
|
|
28
28
|
var _hoisted_3 = ["aria-label"];
|
|
29
29
|
var _hoisted_4 = ["aria-label"];
|
|
30
|
-
var _hoisted_5 = [
|
|
30
|
+
var _hoisted_5 = ["aria-label"];
|
|
31
|
+
var _hoisted_6 = [
|
|
31
32
|
"aria-pressed",
|
|
32
33
|
"aria-label",
|
|
33
34
|
"onClick"
|
|
34
35
|
];
|
|
35
|
-
var
|
|
36
|
+
var _hoisted_7 = ["aria-label"];
|
|
36
37
|
var PREFIX = "markdown-";
|
|
37
38
|
var INTERACTIVE = "button, a[href], input, textarea, select, summary, [role=\"button\"]";
|
|
38
39
|
var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
@@ -62,7 +63,11 @@ var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
62
63
|
versions: { default: 1 },
|
|
63
64
|
version: { default: void 0 },
|
|
64
65
|
highlighted: { type: Boolean },
|
|
65
|
-
reactions: {}
|
|
66
|
+
reactions: {},
|
|
67
|
+
reactable: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: true
|
|
70
|
+
}
|
|
66
71
|
},
|
|
67
72
|
emits: [
|
|
68
73
|
"update:version",
|
|
@@ -135,7 +140,7 @@ var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
135
140
|
emit("update:version", next);
|
|
136
141
|
}
|
|
137
142
|
const reactions = computed(() => (props.reactions ?? []).filter((r) => r.count > 0));
|
|
138
|
-
const canReact = computed(() => !!slots["reaction-picker"]);
|
|
143
|
+
const canReact = computed(() => props.reactable && !!slots["reaction-picker"]);
|
|
139
144
|
const pickerOpen = ref(false);
|
|
140
145
|
if (process.env.NODE_ENV !== "production") watch(() => props.reactions, (list) => {
|
|
141
146
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -433,13 +438,24 @@ var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
433
438
|
key: reaction.emoji,
|
|
434
439
|
content: reactionLabel(reaction)
|
|
435
440
|
}, {
|
|
436
|
-
default: withCtx(() => [
|
|
441
|
+
default: withCtx(() => [!__props.reactable ? (openBlock(), createElementBlock("span", {
|
|
442
|
+
key: 0,
|
|
443
|
+
role: "img",
|
|
444
|
+
tabindex: "0",
|
|
445
|
+
class: normalizeClass([
|
|
446
|
+
unref(ns).e("reaction"),
|
|
447
|
+
unref(ns).is("reacted", !!reaction.reacted),
|
|
448
|
+
unref(ns).is("readonly", true)
|
|
449
|
+
]),
|
|
450
|
+
"aria-label": reactionLabel(reaction)
|
|
451
|
+
}, [createElementVNode("span", { class: normalizeClass(unref(ns).e("reaction-emoji")) }, [renderSlot(_ctx.$slots, "reaction", { reaction }, () => [createTextVNode(toDisplayString(reaction.emoji), 1)])], 2), createElementVNode("span", { class: normalizeClass(unref(ns).e("reaction-count")) }, toDisplayString(reaction.count), 3)], 10, _hoisted_5)) : (openBlock(), createElementBlock("button", {
|
|
452
|
+
key: 1,
|
|
437
453
|
type: "button",
|
|
438
454
|
class: normalizeClass([unref(ns).e("reaction"), unref(ns).is("reacted", !!reaction.reacted)]),
|
|
439
455
|
"aria-pressed": !!reaction.reacted,
|
|
440
456
|
"aria-label": reactionLabel(reaction),
|
|
441
457
|
onClick: ($event) => react(reaction.emoji)
|
|
442
|
-
}, [createElementVNode("span", { class: normalizeClass(unref(ns).e("reaction-emoji")) }, [renderSlot(_ctx.$slots, "reaction", { reaction }, () => [createTextVNode(toDisplayString(reaction.emoji), 1)])], 2), createElementVNode("span", { class: normalizeClass(unref(ns).e("reaction-count")) }, toDisplayString(reaction.count), 3)], 10,
|
|
458
|
+
}, [createElementVNode("span", { class: normalizeClass(unref(ns).e("reaction-emoji")) }, [renderSlot(_ctx.$slots, "reaction", { reaction }, () => [createTextVNode(toDisplayString(reaction.emoji), 1)])], 2), createElementVNode("span", { class: normalizeClass(unref(ns).e("reaction-count")) }, toDisplayString(reaction.count), 3)], 10, _hoisted_6))]),
|
|
443
459
|
_: 2
|
|
444
460
|
}, 1032, ["content"]);
|
|
445
461
|
}), 128)), canReact.value ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
@@ -499,7 +515,7 @@ var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
499
515
|
default: withCtx(() => [createVNode(unref(ChevronRightIcon))]),
|
|
500
516
|
_: 1
|
|
501
517
|
}, 8, ["disabled", "aria-label"])
|
|
502
|
-
], 10,
|
|
518
|
+
], 10, _hoisted_7)) : createCommentVNode("", true),
|
|
503
519
|
__props.copyable && text.value ? (openBlock(), createBlock(unref(DouCopyButton), {
|
|
504
520
|
key: 1,
|
|
505
521
|
size: "sm",
|
package/dist/components/chat-message/chat-message.vue_vue_type_script_setup_true_lang.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-message.vue_vue_type_script_setup_true_lang.js","names":["_useSlots","_openBlock","_createElementBlock","_normalizeClass","_unref","_Fragment","_renderList","_createBlock","_createCommentVNode","_withDirectives","_createElementVNode","_vModelText","_createVNode","_withCtx","_createTextVNode","_toDisplayString","_renderSlot","_mergeProps","_createSlots"],"sources":["../../../src/components/chat-message/chat-message.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ChevronLeftIcon, ChevronRightIcon, EditIcon, SmilePlusIcon } from '@dou-ui/icons'\nimport { computed, nextTick, onBeforeUnmount, ref, useTemplateRef, watch } from 'vue'\nimport { isComposing } from '../../utils/keyboard'\nimport { devWarn } from '../../utils/status-check'\nimport { useNamespace } from '../../utils/namespace'\nimport { DouButton } from '../button'\nimport { DouChatArtifact } from '../chat-artifact'\nimport { DouChatAttachments } from '../chat-attachments'\nimport { DouChatConfirm } from '../chat-confirm'\nimport { DouChatQuestion } from '../chat-question'\nimport { DouChatPlan } from '../chat-plan'\nimport { planRunning, type ChatPlanItem } from '../chat-plan/chat-plan'\nimport { DouChatReasoning } from '../chat-reasoning'\nimport { DouChatSources } from '../chat-sources'\nimport { DouChatSteps } from '../chat-steps'\nimport { stepsLive, type ChatStep } from '../chat-steps/chat-steps'\nimport { DouChatToolCall } from '../chat-tool-call'\nimport { useLocale } from '../config-provider/use-config'\nimport { DouCopyButton } from '../copy-button'\nimport { DouMarkdown } from '../markdown'\nimport { DouPopover } from '../popover'\nimport type { ChatSource } from '../chat-sources/chat-sources'\nimport { DouStreamText } from '../stream-text'\nimport { DouTooltip } from '../tooltip'\nimport { messageText } from './chat-message'\nimport type {\n ChatArtifactPart,\n ChatConfirmPart,\n ChatQuestionPart,\n ChatCustomPart,\n ChatMessageEmits,\n ChatMessagePart,\n ChatMessageMarkdownSlots,\n ChatMessageProps,\n ChatMessageReaction,\n ChatMessageSlots,\n} from './chat-message'\n\ndefineOptions({ name: 'DouChatMessage' })\n\nconst props = withDefaults(defineProps<ChatMessageProps>(), {\n sender: 'assistant',\n loading: false,\n copyable: true,\n editable: false,\n markdown: false,\n actionsVisible: undefined,\n versions: 1,\n version: undefined,\n})\nconst emit = defineEmits<ChatMessageEmits>()\nconst slots = defineSlots<ChatMessageSlots & ChatMessageMarkdownSlots>()\n\nconst ns = useNamespace('chat-message')\nconst { t } = useLocale()\n\ntype AnyPart = ChatMessagePart | ChatCustomPart\n\nconst parts = computed<AnyPart[]>(\n () => props.parts ?? (props.content === undefined ? [] : [{ type: 'text', text: props.content }]),\n)\nconst markdownOptions = computed(() =>\n typeof props.markdown === 'object' ? props.markdown : undefined,\n)\n// `markdown-code` here is the Markdown component's `code`\nconst PREFIX = 'markdown-'\nconst markdownSlots = () =>\n Object.keys(slots)\n // the message's own `trailing` goes to its last text, not to every Markdown in it\n .filter((name) => name.startsWith(PREFIX) && name !== `${PREFIX}trailing`)\n .map((name) => ({\n name: name as keyof ChatMessageMarkdownSlots,\n inner: name.slice(PREFIX.length),\n }))\nconst isUser = computed(() => props.sender === 'user')\nconst actionsShow = computed(() => props.actionsVisible ?? 'hover')\n\n// Without hover, a tap on the message shows its actions and a tap\n// anywhere else hides them. Taps on its own buttons and links, and\n// selecting text, leave them as they are.\nconst touched = ref(false)\nconst rootRef = useTemplateRef<HTMLElement>('root')\nconst INTERACTIVE = 'button, a[href], input, textarea, select, summary, [role=\"button\"]'\nfunction onPointerUp(event: PointerEvent) {\n if (event.pointerType === 'mouse') return\n const target = event.target as Element | null\n if (target?.closest(INTERACTIVE)) return\n if (getSelection()?.isCollapsed === false) return\n touched.value = !touched.value\n}\nfunction onOutsidePointerDown(event: PointerEvent) {\n if (!rootRef.value?.contains(event.target as Node)) touched.value = false\n}\nwatch(touched, (on) => {\n if (on) document.addEventListener('pointerdown', onOutsidePointerDown, true)\n else document.removeEventListener('pointerdown', onOutsidePointerDown, true)\n})\nonBeforeUnmount(() => document.removeEventListener('pointerdown', onOutsidePointerDown, true))\n// the person's attachments sit above their bubble, not inside it\nconst files = computed(() => (isUser.value ? parts.value.filter((p) => p.type === 'files') : []))\nconst body = computed(() =>\n isUser.value ? parts.value.filter((p) => p.type !== 'files') : parts.value,\n)\nconst text = computed(() => messageText(parts.value as { type: string; text?: unknown }[]))\n/** The last text part, which the `trailing` slot follows; -1 without one. */\nconst lastText = computed(() => {\n for (let i = body.value.length - 1; i >= 0; i--) if (body.value[i]!.type === 'text') return i\n return -1\n})\n// Every source of the message, numbered in order, for `[1]` in Markdown\n// text. The same array while the sources stay the same, so text that\n// streams in does not redraw the whole reply.\nlet lastSources: ChatSource[] = []\nconst sources = computed(() => {\n const next = parts.value.flatMap((part) =>\n part.type === 'sources' ? ((part as { items?: ChatSource[] }).items ?? []) : [],\n )\n if (next.length === lastSources.length && next.every((s, i) => s === lastSources[i]))\n return lastSources\n return (lastSources = next)\n})\n\nconst busy = computed(\n () =>\n props.loading ||\n parts.value.some((part) => {\n const p = part as Record<string, unknown>\n // an artifact can keep being made after the reply ends, so it doesn't hold the actions back\n const working = p.status === 'running' && p.type !== 'artifact' && p.live !== false\n // busy exactly when steps or a plan show themselves running\n const live = p.live as boolean | undefined\n const steps = p.type === 'steps' && stepsLive(p.items as ChatStep[] | undefined, live)\n const plan = p.type === 'plan' && planRunning(p.items as ChatPlanItem[] | undefined, live)\n return !!p.streaming || !!p.thinking || steps || plan || working\n }),\n)\n\nconst innerVersion = ref(props.versions)\nconst version = computed(() => Math.min(props.version ?? innerVersion.value, props.versions))\nfunction step(delta: number) {\n const next = Math.min(Math.max(version.value + delta, 1), props.versions)\n innerVersion.value = next\n emit('update:version', next)\n}\n\n// reactions\nconst reactions = computed(() => (props.reactions ?? []).filter((r) => r.count > 0))\nconst canReact = computed(() => !!slots['reaction-picker'])\nconst pickerOpen = ref(false)\nif (process.env.NODE_ENV !== 'production') {\n watch(\n () => props.reactions,\n (list) => {\n const seen = new Set<string>()\n for (const { emoji } of list ?? []) {\n if (seen.has(emoji))\n devWarn(\n `[dou-ui] DouChatMessage: \\`reactions\\` lists \"${emoji}\" more than once; give each emoji one entry with its count.`,\n )\n seen.add(emoji)\n }\n },\n { immediate: true },\n )\n}\nfunction react(emoji: string) {\n emit(\n 'react',\n emoji,\n props.reactions?.find((r) => r.emoji === emoji),\n )\n}\n// Picked in the panel: the add button may move from the actions to the end\n// of the reactions as the first one comes in, so focus follows it there\n// rather than falling back to the page.\nfunction pick(emoji: string) {\n pickerOpen.value = false\n react(emoji)\n void nextTick(() => {\n const root = rootRef.value\n if (!root || root.contains(document.activeElement)) return\n root.querySelector<HTMLElement>(`.${ns.e('add-reaction')}`)?.focus()\n })\n}\n/** Read out and shown on hover: the emoji and count, then `label` when given. */\nfunction reactionLabel(reaction: ChatMessageReaction) {\n const base = t('chat.reaction', { emoji: reaction.emoji, count: reaction.count })\n return reaction.label ? t('chat.reactionWith', { reaction: base, label: reaction.label }) : base\n}\n// The add button sits among the actions until the first reaction, then at\n// the end of the reactions, so a message without any takes no extra line.\nconst addInActions = computed(() => canReact.value && !reactions.value.length)\n\nconst showActions = computed(\n () =>\n !busy.value &&\n (props.versions > 1 ||\n (props.copyable && !!text.value) ||\n (props.editable && isUser.value) ||\n addInActions.value ||\n !!slots.actions),\n)\n\n// editing in place\nconst editing = ref(false)\nconst draft = ref('')\nconst editorRef = useTemplateRef<HTMLTextAreaElement>('editor')\nfunction startEdit() {\n draft.value = text.value\n editing.value = true\n void nextTick(() => {\n const el = editorRef.value\n el?.focus()\n el?.setSelectionRange(el.value.length, el.value.length)\n fitEditor()\n })\n}\nfunction cancelEdit() {\n editing.value = false\n}\nfunction saveEdit() {\n if (!draft.value.trim()) return\n editing.value = false\n emit('edit', draft.value)\n}\nfunction fitEditor() {\n const el = editorRef.value\n if (!el) return\n el.style.height = 'auto'\n el.style.height = `${el.scrollHeight}px`\n}\nfunction onEditorKeydown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n event.preventDefault()\n cancelEdit()\n } else if (event.key === 'Enter' && !event.shiftKey && !isComposing(event)) {\n event.preventDefault()\n saveEdit()\n }\n}\n\nconst asText = (part: AnyPart) => part as Extract<ChatMessagePart, { type: 'text' }>\nconst asReasoning = (part: AnyPart) => part as Extract<ChatMessagePart, { type: 'reasoning' }>\nconst asFiles = (part: AnyPart) => part as Extract<ChatMessagePart, { type: 'files' }>\nconst asConfirm = (part: AnyPart) => part as ChatConfirmPart\nconst asArtifact = (part: AnyPart) => part as ChatArtifactPart\nconst asQuestion = (part: AnyPart) => part as ChatQuestionPart\nconst known = new Set([\n 'text',\n 'reasoning',\n 'tool',\n 'steps',\n 'plan',\n 'sources',\n 'files',\n 'artifact',\n 'confirm',\n 'question',\n])\n// props for the part components, without the `type` discriminator\nconst rest = (part: AnyPart) => {\n const { type: _type, ...others } = part as Record<string, unknown>\n return others\n}\n</script>\n\n<template>\n <div\n :class=\"[\n ns.b(),\n ns.m(sender),\n ns.m(`actions-${actionsShow}`),\n ns.is('loading', loading),\n ns.is('editing', editing),\n ns.is('highlighted', highlighted),\n ns.is('reacting', pickerOpen),\n ns.is('touched', touched),\n ]\"\n ref=\"root\"\n :aria-busy=\"busy || undefined\"\n :aria-current=\"highlighted || undefined\"\n @pointerup=\"onPointerUp\"\n >\n <div v-if=\"files.length && !editing\" :class=\"ns.e('files')\">\n <template v-for=\"(part, index) in files\" :key=\"`f${index}`\">\n <DouChatAttachments :model-value=\"asFiles(part).files\" :removable=\"false\" />\n </template>\n </div>\n\n <div v-if=\"editing\" :class=\"ns.e('editor')\">\n <textarea\n ref=\"editor\"\n v-model=\"draft\"\n :class=\"ns.e('editor-native')\"\n rows=\"1\"\n :aria-label=\"t('chat.edit')\"\n @input=\"fitEditor\"\n @keydown=\"onEditorKeydown\"\n />\n <div :class=\"ns.e('editor-actions')\">\n <DouButton size=\"sm\" variant=\"ghost\" @click=\"cancelEdit\">{{ t('chat.cancel') }}</DouButton>\n <DouButton size=\"sm\" :disabled=\"!draft.trim()\" @click=\"saveEdit\">\n {{ t('chat.send') }}\n </DouButton>\n </div>\n </div>\n\n <div v-else-if=\"body.length || loading || slots.default\" :class=\"ns.e('content')\">\n <slot>\n <template v-for=\"(part, index) in body\" :key=\"index\">\n <DouMarkdown\n v-if=\"part.type === 'text' && markdown && !slots.text\"\n v-bind=\"markdownOptions\"\n :class=\"ns.e('text')\"\n :content=\"asText(part).text\"\n :streaming=\"!!asText(part).streaming\"\n :sources=\"sources.length ? sources : undefined\"\n >\n <template v-for=\"slot in markdownSlots()\" :key=\"slot.name\" #[slot.inner]=\"scope\">\n <slot :name=\"slot.name\" v-bind=\"scope\" />\n </template>\n <template v-if=\"slots.trailing && index === lastText\" #trailing>\n <slot name=\"trailing\" />\n </template>\n </DouMarkdown>\n <DouStreamText\n v-else-if=\"part.type === 'text'\"\n :class=\"ns.e('text')\"\n :content=\"asText(part).text\"\n :streaming=\"!!asText(part).streaming\"\n >\n <template v-if=\"slots.text\" #default=\"{ text: shown }\">\n <slot\n name=\"text\"\n :part=\"asText(part)\"\n :text=\"shown\"\n :index=\"index\"\n :sources=\"sources\"\n />\n </template>\n <template v-if=\"slots.trailing && index === lastText\" #trailing>\n <slot name=\"trailing\" />\n </template>\n </DouStreamText>\n <DouChatReasoning\n v-else-if=\"part.type === 'reasoning'\"\n :thinking=\"!!asReasoning(part).thinking\"\n :duration=\"asReasoning(part).duration\"\n >\n <DouMarkdown\n v-if=\"markdown\"\n v-bind=\"markdownOptions\"\n :content=\"asReasoning(part).text\"\n :streaming=\"!!asReasoning(part).thinking\"\n :caret=\"false\"\n >\n <template v-for=\"slot in markdownSlots()\" :key=\"slot.name\" #[slot.inner]=\"scope\">\n <slot :name=\"slot.name\" v-bind=\"scope\" />\n </template>\n </DouMarkdown>\n <DouStreamText\n v-else\n :content=\"asReasoning(part).text\"\n :streaming=\"!!asReasoning(part).thinking\"\n :caret=\"false\"\n />\n </DouChatReasoning>\n <DouChatToolCall v-else-if=\"part.type === 'tool'\" v-bind=\"rest(part)\" />\n <DouChatSteps v-else-if=\"part.type === 'steps'\" v-bind=\"rest(part)\" />\n <DouChatPlan v-else-if=\"part.type === 'plan'\" v-bind=\"rest(part)\" />\n <DouChatSources v-else-if=\"part.type === 'sources'\" v-bind=\"rest(part)\" />\n <DouChatAttachments\n v-else-if=\"part.type === 'files'\"\n :model-value=\"asFiles(part).files\"\n :removable=\"false\"\n />\n <DouChatArtifact\n v-else-if=\"part.type === 'artifact'\"\n v-bind=\"rest(part)\"\n @open=\"emit('artifact', asArtifact(part))\"\n />\n <DouChatConfirm\n v-else-if=\"part.type === 'confirm'\"\n :title=\"asConfirm(part).title\"\n :description=\"asConfirm(part).description\"\n :status=\"asConfirm(part).status\"\n :allow-always=\"asConfirm(part).allowAlways\"\n :tone=\"asConfirm(part).tone\"\n @decide=\"emit('confirm', asConfirm(part), $event)\"\n >\n <pre v-if=\"asConfirm(part).detail\" :class=\"ns.e('code')\">{{\n asConfirm(part).detail\n }}</pre>\n </DouChatConfirm>\n <DouChatQuestion\n v-else-if=\"part.type === 'question'\"\n :title=\"asQuestion(part).title\"\n :description=\"asQuestion(part).description\"\n :options=\"asQuestion(part).options\"\n :status=\"asQuestion(part).status\"\n :answer=\"asQuestion(part).answer\"\n @select=\"(value, option) => emit('question', asQuestion(part), value, option)\"\n />\n <slot\n v-else-if=\"!known.has(part.type)\"\n name=\"part\"\n :part=\"part as ChatCustomPart\"\n :index=\"index\"\n />\n </template>\n <div v-if=\"slots.trailing && lastText < 0 && !loading\" :class=\"ns.e('trailing')\">\n <slot name=\"trailing\" />\n </div>\n </slot>\n <span v-if=\"loading\" :class=\"ns.e('loading')\" role=\"status\" :aria-label=\"t('chat.loading')\">\n <i /><i /><i />\n </span>\n </div>\n\n <div\n v-if=\"reactions.length && !editing\"\n :class=\"ns.e('reactions')\"\n role=\"group\"\n :aria-label=\"t('chat.reactions')\"\n >\n <DouTooltip\n v-for=\"reaction in reactions\"\n :key=\"reaction.emoji\"\n :content=\"reactionLabel(reaction)\"\n >\n <button\n type=\"button\"\n :class=\"[ns.e('reaction'), ns.is('reacted', !!reaction.reacted)]\"\n :aria-pressed=\"!!reaction.reacted\"\n :aria-label=\"reactionLabel(reaction)\"\n @click=\"react(reaction.emoji)\"\n >\n <span :class=\"ns.e('reaction-emoji')\">\n <slot name=\"reaction\" :reaction=\"reaction\">{{ reaction.emoji }}</slot>\n </span>\n <span :class=\"ns.e('reaction-count')\">{{ reaction.count }}</span>\n </button>\n </DouTooltip>\n <DouTooltip v-if=\"canReact\" :content=\"t('chat.addReaction')\">\n <DouPopover v-model:open=\"pickerOpen\" placement=\"top-start\">\n <DouButton\n variant=\"ghost\"\n size=\"xs\"\n :class=\"ns.e('add-reaction')\"\n :aria-label=\"t('chat.addReaction')\"\n >\n <SmilePlusIcon />\n </DouButton>\n <template #content=\"{ close }\">\n <slot name=\"reaction-picker\" :react=\"pick\" :close=\"close\" />\n </template>\n </DouPopover>\n </DouTooltip>\n </div>\n\n <!-- last in reading order, drawn at the top right of the message -->\n <div v-if=\"showActions && !editing\" :class=\"ns.e('toolbar')\">\n <div :class=\"ns.e('actions')\">\n <div\n v-if=\"versions > 1\"\n :class=\"ns.e('versions')\"\n role=\"group\"\n :aria-label=\"t('chat.versions')\"\n >\n <DouButton\n variant=\"ghost\"\n size=\"sm\"\n :disabled=\"version <= 1\"\n :aria-label=\"t('chat.previousVersion')\"\n @click=\"step(-1)\"\n >\n <ChevronLeftIcon />\n </DouButton>\n <span :class=\"ns.e('version')\">{{ version }} / {{ versions }}</span>\n <DouButton\n variant=\"ghost\"\n size=\"sm\"\n :disabled=\"version >= versions\"\n :aria-label=\"t('chat.nextVersion')\"\n @click=\"step(1)\"\n >\n <ChevronRightIcon />\n </DouButton>\n </div>\n <DouCopyButton v-if=\"copyable && text\" size=\"sm\" :text=\"text\" />\n <DouTooltip v-if=\"editable && isUser\" :content=\"t('chat.edit')\">\n <DouButton variant=\"ghost\" size=\"sm\" :aria-label=\"t('chat.edit')\" @click=\"startEdit\">\n <EditIcon />\n </DouButton>\n </DouTooltip>\n <DouTooltip v-if=\"addInActions\" :content=\"t('chat.addReaction')\">\n <DouPopover v-model:open=\"pickerOpen\" placement=\"top-start\">\n <DouButton\n variant=\"ghost\"\n size=\"sm\"\n :class=\"ns.e('add-reaction')\"\n :aria-label=\"t('chat.addReaction')\"\n >\n <SmilePlusIcon />\n </DouButton>\n <template #content=\"{ close }\">\n <slot name=\"reaction-picker\" :react=\"pick\" :close=\"close\" />\n </template>\n </DouPopover>\n </DouTooltip>\n <slot name=\"actions\" />\n </div>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,IAAM,SAAS;AAiBf,IAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA1CpB,MAAM,QAAQ;EAUd,MAAM,OAAO;EACb,MAAM,QAAQA,SAAA;EAEd,MAAM,KAAK,aAAa,cAAc;EACtC,MAAM,EAAE,MAAM,UAAU;EAIxB,MAAM,QAAQ,eACN,MAAM,UAAU,MAAM,YAAY,KAAA,IAAY,CAA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AA,CAAA,CAAC,CAAA,WAAA;;MAC/C,SAAAS,cAEY,CAFZD,YAEYR,MAAA,SAAA,GAAA;OAFD,SAAQ;OAAQ,MAAK;OAAM,cAAYA,MAAA,CAAA,CAAC,CAAA,WAAA;OAAgB,SAAO;;OACxE,SAAAS,cAAY,CAAZD,YAAYR,MAAA,QAAA,CAAA,C;;;;;KAGE,aAAA,SAAlBH,UAAA,GAAAM,YAcaH,MAAA,UAAA,GAAA;;MAdoB,SAASA,MAAA,CAAA,CAAC,CAAA,kBAAA;;MACzC,SAAAS,cAYa,CAZbD,YAYaR,MAAA,UAAA,GAAA;OAZO,MAAM,WAAA;OAAA,iBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,WAAU,QAAA;OAAE,WAAU;;OASnC,SAAOS,SAC4C,EADxC,YAAK,CACzBG,WAA4D,KAAA,QAAA,mBAAA;QAA9B,OAAO;QAAc;;OATrD,SAAAH,cAOY,CAPZD,YAOYR,MAAA,SAAA,GAAA;QANV,SAAQ;QACR,MAAK;QACJ,OAAKD,eAAEC,MAAA,EAAA,CAAE,CAAC,EAAC,cAAA,CAAA;QACX,cAAYA,MAAA,CAAA,CAAC,CAAA,kBAAA;;QAEd,SAAAS,cAAiB,CAAjBD,YAAiBR,MAAA,aAAA,CAAA,C;;;;;;;KAOvBY,WAAuB,KAAA,QAAA,SAAA"}
|
|
1
|
+
{"version":3,"file":"chat-message.vue_vue_type_script_setup_true_lang.js","names":["_useSlots","_openBlock","_createElementBlock","_normalizeClass","_unref","_Fragment","_renderList","_createBlock","_createCommentVNode","_withDirectives","_createElementVNode","_vModelText","_createVNode","_withCtx","_createTextVNode","_toDisplayString","_renderSlot","_mergeProps","_createSlots"],"sources":["../../../src/components/chat-message/chat-message.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ChevronLeftIcon, ChevronRightIcon, EditIcon, SmilePlusIcon } from '@dou-ui/icons'\nimport { computed, nextTick, onBeforeUnmount, ref, useTemplateRef, watch } from 'vue'\nimport { isComposing } from '../../utils/keyboard'\nimport { devWarn } from '../../utils/status-check'\nimport { useNamespace } from '../../utils/namespace'\nimport { DouButton } from '../button'\nimport { DouChatArtifact } from '../chat-artifact'\nimport { DouChatAttachments } from '../chat-attachments'\nimport { DouChatConfirm } from '../chat-confirm'\nimport { DouChatQuestion } from '../chat-question'\nimport { DouChatPlan } from '../chat-plan'\nimport { planRunning, type ChatPlanItem } from '../chat-plan/chat-plan'\nimport { DouChatReasoning } from '../chat-reasoning'\nimport { DouChatSources } from '../chat-sources'\nimport { DouChatSteps } from '../chat-steps'\nimport { stepsLive, type ChatStep } from '../chat-steps/chat-steps'\nimport { DouChatToolCall } from '../chat-tool-call'\nimport { useLocale } from '../config-provider/use-config'\nimport { DouCopyButton } from '../copy-button'\nimport { DouMarkdown } from '../markdown'\nimport { DouPopover } from '../popover'\nimport type { ChatSource } from '../chat-sources/chat-sources'\nimport { DouStreamText } from '../stream-text'\nimport { DouTooltip } from '../tooltip'\nimport { messageText } from './chat-message'\nimport type {\n ChatArtifactPart,\n ChatConfirmPart,\n ChatQuestionPart,\n ChatCustomPart,\n ChatMessageEmits,\n ChatMessagePart,\n ChatMessageMarkdownSlots,\n ChatMessageProps,\n ChatMessageReaction,\n ChatMessageSlots,\n} from './chat-message'\n\ndefineOptions({ name: 'DouChatMessage' })\n\nconst props = withDefaults(defineProps<ChatMessageProps>(), {\n sender: 'assistant',\n loading: false,\n copyable: true,\n reactable: true,\n editable: false,\n markdown: false,\n actionsVisible: undefined,\n versions: 1,\n version: undefined,\n})\nconst emit = defineEmits<ChatMessageEmits>()\nconst slots = defineSlots<ChatMessageSlots & ChatMessageMarkdownSlots>()\n\nconst ns = useNamespace('chat-message')\nconst { t } = useLocale()\n\ntype AnyPart = ChatMessagePart | ChatCustomPart\n\nconst parts = computed<AnyPart[]>(\n () => props.parts ?? (props.content === undefined ? [] : [{ type: 'text', text: props.content }]),\n)\nconst markdownOptions = computed(() =>\n typeof props.markdown === 'object' ? props.markdown : undefined,\n)\n// `markdown-code` here is the Markdown component's `code`\nconst PREFIX = 'markdown-'\nconst markdownSlots = () =>\n Object.keys(slots)\n // the message's own `trailing` goes to its last text, not to every Markdown in it\n .filter((name) => name.startsWith(PREFIX) && name !== `${PREFIX}trailing`)\n .map((name) => ({\n name: name as keyof ChatMessageMarkdownSlots,\n inner: name.slice(PREFIX.length),\n }))\nconst isUser = computed(() => props.sender === 'user')\nconst actionsShow = computed(() => props.actionsVisible ?? 'hover')\n\n// Without hover, a tap on the message shows its actions and a tap\n// anywhere else hides them. Taps on its own buttons and links, and\n// selecting text, leave them as they are.\nconst touched = ref(false)\nconst rootRef = useTemplateRef<HTMLElement>('root')\nconst INTERACTIVE = 'button, a[href], input, textarea, select, summary, [role=\"button\"]'\nfunction onPointerUp(event: PointerEvent) {\n if (event.pointerType === 'mouse') return\n const target = event.target as Element | null\n if (target?.closest(INTERACTIVE)) return\n if (getSelection()?.isCollapsed === false) return\n touched.value = !touched.value\n}\nfunction onOutsidePointerDown(event: PointerEvent) {\n if (!rootRef.value?.contains(event.target as Node)) touched.value = false\n}\nwatch(touched, (on) => {\n if (on) document.addEventListener('pointerdown', onOutsidePointerDown, true)\n else document.removeEventListener('pointerdown', onOutsidePointerDown, true)\n})\nonBeforeUnmount(() => document.removeEventListener('pointerdown', onOutsidePointerDown, true))\n// the person's attachments sit above their bubble, not inside it\nconst files = computed(() => (isUser.value ? parts.value.filter((p) => p.type === 'files') : []))\nconst body = computed(() =>\n isUser.value ? parts.value.filter((p) => p.type !== 'files') : parts.value,\n)\nconst text = computed(() => messageText(parts.value as { type: string; text?: unknown }[]))\n/** The last text part, which the `trailing` slot follows; -1 without one. */\nconst lastText = computed(() => {\n for (let i = body.value.length - 1; i >= 0; i--) if (body.value[i]!.type === 'text') return i\n return -1\n})\n// Every source of the message, numbered in order, for `[1]` in Markdown\n// text. The same array while the sources stay the same, so text that\n// streams in does not redraw the whole reply.\nlet lastSources: ChatSource[] = []\nconst sources = computed(() => {\n const next = parts.value.flatMap((part) =>\n part.type === 'sources' ? ((part as { items?: ChatSource[] }).items ?? []) : [],\n )\n if (next.length === lastSources.length && next.every((s, i) => s === lastSources[i]))\n return lastSources\n return (lastSources = next)\n})\n\nconst busy = computed(\n () =>\n props.loading ||\n parts.value.some((part) => {\n const p = part as Record<string, unknown>\n // an artifact can keep being made after the reply ends, so it doesn't hold the actions back\n const working = p.status === 'running' && p.type !== 'artifact' && p.live !== false\n // busy exactly when steps or a plan show themselves running\n const live = p.live as boolean | undefined\n const steps = p.type === 'steps' && stepsLive(p.items as ChatStep[] | undefined, live)\n const plan = p.type === 'plan' && planRunning(p.items as ChatPlanItem[] | undefined, live)\n return !!p.streaming || !!p.thinking || steps || plan || working\n }),\n)\n\nconst innerVersion = ref(props.versions)\nconst version = computed(() => Math.min(props.version ?? innerVersion.value, props.versions))\nfunction step(delta: number) {\n const next = Math.min(Math.max(version.value + delta, 1), props.versions)\n innerVersion.value = next\n emit('update:version', next)\n}\n\n// reactions\nconst reactions = computed(() => (props.reactions ?? []).filter((r) => r.count > 0))\nconst canReact = computed(() => props.reactable && !!slots['reaction-picker'])\nconst pickerOpen = ref(false)\nif (process.env.NODE_ENV !== 'production') {\n watch(\n () => props.reactions,\n (list) => {\n const seen = new Set<string>()\n for (const { emoji } of list ?? []) {\n if (seen.has(emoji))\n devWarn(\n `[dou-ui] DouChatMessage: \\`reactions\\` lists \"${emoji}\" more than once; give each emoji one entry with its count.`,\n )\n seen.add(emoji)\n }\n },\n { immediate: true },\n )\n}\nfunction react(emoji: string) {\n emit(\n 'react',\n emoji,\n props.reactions?.find((r) => r.emoji === emoji),\n )\n}\n// Picked in the panel: the add button may move from the actions to the end\n// of the reactions as the first one comes in, so focus follows it there\n// rather than falling back to the page.\nfunction pick(emoji: string) {\n pickerOpen.value = false\n react(emoji)\n void nextTick(() => {\n const root = rootRef.value\n if (!root || root.contains(document.activeElement)) return\n root.querySelector<HTMLElement>(`.${ns.e('add-reaction')}`)?.focus()\n })\n}\n/** Read out and shown on hover: the emoji and count, then `label` when given. */\nfunction reactionLabel(reaction: ChatMessageReaction) {\n const base = t('chat.reaction', { emoji: reaction.emoji, count: reaction.count })\n return reaction.label ? t('chat.reactionWith', { reaction: base, label: reaction.label }) : base\n}\n// The add button sits among the actions until the first reaction, then at\n// the end of the reactions, so a message without any takes no extra line.\nconst addInActions = computed(() => canReact.value && !reactions.value.length)\n\nconst showActions = computed(\n () =>\n !busy.value &&\n (props.versions > 1 ||\n (props.copyable && !!text.value) ||\n (props.editable && isUser.value) ||\n addInActions.value ||\n !!slots.actions),\n)\n\n// editing in place\nconst editing = ref(false)\nconst draft = ref('')\nconst editorRef = useTemplateRef<HTMLTextAreaElement>('editor')\nfunction startEdit() {\n draft.value = text.value\n editing.value = true\n void nextTick(() => {\n const el = editorRef.value\n el?.focus()\n el?.setSelectionRange(el.value.length, el.value.length)\n fitEditor()\n })\n}\nfunction cancelEdit() {\n editing.value = false\n}\nfunction saveEdit() {\n if (!draft.value.trim()) return\n editing.value = false\n emit('edit', draft.value)\n}\nfunction fitEditor() {\n const el = editorRef.value\n if (!el) return\n el.style.height = 'auto'\n el.style.height = `${el.scrollHeight}px`\n}\nfunction onEditorKeydown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n event.preventDefault()\n cancelEdit()\n } else if (event.key === 'Enter' && !event.shiftKey && !isComposing(event)) {\n event.preventDefault()\n saveEdit()\n }\n}\n\nconst asText = (part: AnyPart) => part as Extract<ChatMessagePart, { type: 'text' }>\nconst asReasoning = (part: AnyPart) => part as Extract<ChatMessagePart, { type: 'reasoning' }>\nconst asFiles = (part: AnyPart) => part as Extract<ChatMessagePart, { type: 'files' }>\nconst asConfirm = (part: AnyPart) => part as ChatConfirmPart\nconst asArtifact = (part: AnyPart) => part as ChatArtifactPart\nconst asQuestion = (part: AnyPart) => part as ChatQuestionPart\nconst known = new Set([\n 'text',\n 'reasoning',\n 'tool',\n 'steps',\n 'plan',\n 'sources',\n 'files',\n 'artifact',\n 'confirm',\n 'question',\n])\n// props for the part components, without the `type` discriminator\nconst rest = (part: AnyPart) => {\n const { type: _type, ...others } = part as Record<string, unknown>\n return others\n}\n</script>\n\n<template>\n <div\n :class=\"[\n ns.b(),\n ns.m(sender),\n ns.m(`actions-${actionsShow}`),\n ns.is('loading', loading),\n ns.is('editing', editing),\n ns.is('highlighted', highlighted),\n ns.is('reacting', pickerOpen),\n ns.is('touched', touched),\n ]\"\n ref=\"root\"\n :aria-busy=\"busy || undefined\"\n :aria-current=\"highlighted || undefined\"\n @pointerup=\"onPointerUp\"\n >\n <div v-if=\"files.length && !editing\" :class=\"ns.e('files')\">\n <template v-for=\"(part, index) in files\" :key=\"`f${index}`\">\n <DouChatAttachments :model-value=\"asFiles(part).files\" :removable=\"false\" />\n </template>\n </div>\n\n <div v-if=\"editing\" :class=\"ns.e('editor')\">\n <textarea\n ref=\"editor\"\n v-model=\"draft\"\n :class=\"ns.e('editor-native')\"\n rows=\"1\"\n :aria-label=\"t('chat.edit')\"\n @input=\"fitEditor\"\n @keydown=\"onEditorKeydown\"\n />\n <div :class=\"ns.e('editor-actions')\">\n <DouButton size=\"sm\" variant=\"ghost\" @click=\"cancelEdit\">{{ t('chat.cancel') }}</DouButton>\n <DouButton size=\"sm\" :disabled=\"!draft.trim()\" @click=\"saveEdit\">\n {{ t('chat.send') }}\n </DouButton>\n </div>\n </div>\n\n <div v-else-if=\"body.length || loading || slots.default\" :class=\"ns.e('content')\">\n <slot>\n <template v-for=\"(part, index) in body\" :key=\"index\">\n <DouMarkdown\n v-if=\"part.type === 'text' && markdown && !slots.text\"\n v-bind=\"markdownOptions\"\n :class=\"ns.e('text')\"\n :content=\"asText(part).text\"\n :streaming=\"!!asText(part).streaming\"\n :sources=\"sources.length ? sources : undefined\"\n >\n <template v-for=\"slot in markdownSlots()\" :key=\"slot.name\" #[slot.inner]=\"scope\">\n <slot :name=\"slot.name\" v-bind=\"scope\" />\n </template>\n <template v-if=\"slots.trailing && index === lastText\" #trailing>\n <slot name=\"trailing\" />\n </template>\n </DouMarkdown>\n <DouStreamText\n v-else-if=\"part.type === 'text'\"\n :class=\"ns.e('text')\"\n :content=\"asText(part).text\"\n :streaming=\"!!asText(part).streaming\"\n >\n <template v-if=\"slots.text\" #default=\"{ text: shown }\">\n <slot\n name=\"text\"\n :part=\"asText(part)\"\n :text=\"shown\"\n :index=\"index\"\n :sources=\"sources\"\n />\n </template>\n <template v-if=\"slots.trailing && index === lastText\" #trailing>\n <slot name=\"trailing\" />\n </template>\n </DouStreamText>\n <DouChatReasoning\n v-else-if=\"part.type === 'reasoning'\"\n :thinking=\"!!asReasoning(part).thinking\"\n :duration=\"asReasoning(part).duration\"\n >\n <DouMarkdown\n v-if=\"markdown\"\n v-bind=\"markdownOptions\"\n :content=\"asReasoning(part).text\"\n :streaming=\"!!asReasoning(part).thinking\"\n :caret=\"false\"\n >\n <template v-for=\"slot in markdownSlots()\" :key=\"slot.name\" #[slot.inner]=\"scope\">\n <slot :name=\"slot.name\" v-bind=\"scope\" />\n </template>\n </DouMarkdown>\n <DouStreamText\n v-else\n :content=\"asReasoning(part).text\"\n :streaming=\"!!asReasoning(part).thinking\"\n :caret=\"false\"\n />\n </DouChatReasoning>\n <DouChatToolCall v-else-if=\"part.type === 'tool'\" v-bind=\"rest(part)\" />\n <DouChatSteps v-else-if=\"part.type === 'steps'\" v-bind=\"rest(part)\" />\n <DouChatPlan v-else-if=\"part.type === 'plan'\" v-bind=\"rest(part)\" />\n <DouChatSources v-else-if=\"part.type === 'sources'\" v-bind=\"rest(part)\" />\n <DouChatAttachments\n v-else-if=\"part.type === 'files'\"\n :model-value=\"asFiles(part).files\"\n :removable=\"false\"\n />\n <DouChatArtifact\n v-else-if=\"part.type === 'artifact'\"\n v-bind=\"rest(part)\"\n @open=\"emit('artifact', asArtifact(part))\"\n />\n <DouChatConfirm\n v-else-if=\"part.type === 'confirm'\"\n :title=\"asConfirm(part).title\"\n :description=\"asConfirm(part).description\"\n :status=\"asConfirm(part).status\"\n :allow-always=\"asConfirm(part).allowAlways\"\n :tone=\"asConfirm(part).tone\"\n @decide=\"emit('confirm', asConfirm(part), $event)\"\n >\n <pre v-if=\"asConfirm(part).detail\" :class=\"ns.e('code')\">{{\n asConfirm(part).detail\n }}</pre>\n </DouChatConfirm>\n <DouChatQuestion\n v-else-if=\"part.type === 'question'\"\n :title=\"asQuestion(part).title\"\n :description=\"asQuestion(part).description\"\n :options=\"asQuestion(part).options\"\n :status=\"asQuestion(part).status\"\n :answer=\"asQuestion(part).answer\"\n @select=\"(value, option) => emit('question', asQuestion(part), value, option)\"\n />\n <slot\n v-else-if=\"!known.has(part.type)\"\n name=\"part\"\n :part=\"part as ChatCustomPart\"\n :index=\"index\"\n />\n </template>\n <div v-if=\"slots.trailing && lastText < 0 && !loading\" :class=\"ns.e('trailing')\">\n <slot name=\"trailing\" />\n </div>\n </slot>\n <span v-if=\"loading\" :class=\"ns.e('loading')\" role=\"status\" :aria-label=\"t('chat.loading')\">\n <i /><i /><i />\n </span>\n </div>\n\n <div\n v-if=\"reactions.length && !editing\"\n :class=\"ns.e('reactions')\"\n role=\"group\"\n :aria-label=\"t('chat.reactions')\"\n >\n <DouTooltip\n v-for=\"reaction in reactions\"\n :key=\"reaction.emoji\"\n :content=\"reactionLabel(reaction)\"\n >\n <!-- read only: the same chip, read out as one image with its label -->\n <span\n v-if=\"!reactable\"\n role=\"img\"\n tabindex=\"0\"\n :class=\"[ns.e('reaction'), ns.is('reacted', !!reaction.reacted), ns.is('readonly', true)]\"\n :aria-label=\"reactionLabel(reaction)\"\n >\n <span :class=\"ns.e('reaction-emoji')\">\n <slot name=\"reaction\" :reaction=\"reaction\">{{ reaction.emoji }}</slot>\n </span>\n <span :class=\"ns.e('reaction-count')\">{{ reaction.count }}</span>\n </span>\n <button\n v-else\n type=\"button\"\n :class=\"[ns.e('reaction'), ns.is('reacted', !!reaction.reacted)]\"\n :aria-pressed=\"!!reaction.reacted\"\n :aria-label=\"reactionLabel(reaction)\"\n @click=\"react(reaction.emoji)\"\n >\n <span :class=\"ns.e('reaction-emoji')\">\n <slot name=\"reaction\" :reaction=\"reaction\">{{ reaction.emoji }}</slot>\n </span>\n <span :class=\"ns.e('reaction-count')\">{{ reaction.count }}</span>\n </button>\n </DouTooltip>\n <DouTooltip v-if=\"canReact\" :content=\"t('chat.addReaction')\">\n <DouPopover v-model:open=\"pickerOpen\" placement=\"top-start\">\n <DouButton\n variant=\"ghost\"\n size=\"xs\"\n :class=\"ns.e('add-reaction')\"\n :aria-label=\"t('chat.addReaction')\"\n >\n <SmilePlusIcon />\n </DouButton>\n <template #content=\"{ close }\">\n <slot name=\"reaction-picker\" :react=\"pick\" :close=\"close\" />\n </template>\n </DouPopover>\n </DouTooltip>\n </div>\n\n <!-- last in reading order, drawn at the top right of the message -->\n <div v-if=\"showActions && !editing\" :class=\"ns.e('toolbar')\">\n <div :class=\"ns.e('actions')\">\n <div\n v-if=\"versions > 1\"\n :class=\"ns.e('versions')\"\n role=\"group\"\n :aria-label=\"t('chat.versions')\"\n >\n <DouButton\n variant=\"ghost\"\n size=\"sm\"\n :disabled=\"version <= 1\"\n :aria-label=\"t('chat.previousVersion')\"\n @click=\"step(-1)\"\n >\n <ChevronLeftIcon />\n </DouButton>\n <span :class=\"ns.e('version')\">{{ version }} / {{ versions }}</span>\n <DouButton\n variant=\"ghost\"\n size=\"sm\"\n :disabled=\"version >= versions\"\n :aria-label=\"t('chat.nextVersion')\"\n @click=\"step(1)\"\n >\n <ChevronRightIcon />\n </DouButton>\n </div>\n <DouCopyButton v-if=\"copyable && text\" size=\"sm\" :text=\"text\" />\n <DouTooltip v-if=\"editable && isUser\" :content=\"t('chat.edit')\">\n <DouButton variant=\"ghost\" size=\"sm\" :aria-label=\"t('chat.edit')\" @click=\"startEdit\">\n <EditIcon />\n </DouButton>\n </DouTooltip>\n <DouTooltip v-if=\"addInActions\" :content=\"t('chat.addReaction')\">\n <DouPopover v-model:open=\"pickerOpen\" placement=\"top-start\">\n <DouButton\n variant=\"ghost\"\n size=\"sm\"\n :class=\"ns.e('add-reaction')\"\n :aria-label=\"t('chat.addReaction')\"\n >\n <SmilePlusIcon />\n </DouButton>\n <template #content=\"{ close }\">\n <slot name=\"reaction-picker\" :react=\"pick\" :close=\"close\" />\n </template>\n </DouPopover>\n </DouTooltip>\n <slot name=\"actions\" />\n </div>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,IAAM,SAAS;AAiBf,IAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA3CpB,MAAM,QAAQ;EAWd,MAAM,OAAO;EACb,MAAM,QAAQA,SAAA;EAEd,MAAM,KAAK,aAAa,cAAc;EACtC,MAAM,EAAE,MAAM,UAAU;EAIxB,MAAM,QAAQ,eACN,MAAM,UAAU,MAAM,YAAY,KAAA,IAAY,CAAC,IAAI,CAAC;GAAE,MAAM;GAAQ,MAAM,MAAM;EAAQ,CAAC,EACjG;EACA,MAAM,kBAAkB,eACtB,OAAO,MAAM,aAAa,WAAW,MAAM,WAAW,KAAA,CACxD;EAGA,MAAM,sBACJ,OAAO,KAAK,KAAK,CAAA,CAEd,QAAQ,SAAS,KAAK,WAAW,MAAM,KAAK,SAAS,GAAG,OAAO,SAAS,CAAA,CACxE,KAAK,UAAU;GACR;GACN,OAAO,KAAK,MAAM,CAAa;EACjC,EAAE;EACN,MAAM,SAAS,eAAe,MAAM,WAAW,MAAM;EACrD,MAAM,cAAc,eAAe,MAAM,kBAAkB,OAAO;EAKlE,MAAM,UAAU,IAAI,KAAK;EACzB,MAAM,UAAU,eAA4B,MAAM;EAElD,SAAS,YAAY,OAAqB;GACxC,IAAI,MAAM,gBAAgB,SAAS;GAEnC,IADe,MAAM,QACT,QAAQ,WAAW,GAAG;GAClC,IAAI,aAAa,CAAC,EAAE,gBAAgB,OAAO;GAC3C,QAAQ,QAAQ,CAAC,QAAQ;EAC3B;EACA,SAAS,qBA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CAAA,WAAA;;MAC/C,SAAAS,cAEY,CAFZD,YAEYR,MAAA,SAAA,GAAA;OAFD,SAAQ;OAAQ,MAAK;OAAM,cAAYA,MAAA,CAAA,CAAC,CAAA,WAAA;OAAgB,SAAO;;OACxE,SAAAS,cAAY,CAAZD,YAAYR,MAAA,QAAA,CAAA,C;;;;;KAGE,aAAA,SAAlBH,UAAA,GAAAM,YAcaH,MAAA,UAAA,GAAA;;MAdoB,SAASA,MAAA,CAAA,CAAC,CAAA,kBAAA;;MACzC,SAAAS,cAYa,CAZbD,YAYaR,MAAA,UAAA,GAAA;OAZO,MAAM,WAAA;OAAA,iBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,WAAU,QAAA;OAAE,WAAU;;OASnC,SAAOS,SAC4C,EADxC,YAAK,CACzBG,WAA4D,KAAA,QAAA,mBAAA;QAA9B,OAAO;QAAc;;OATrD,SAAAH,cAOY,CAPZD,YAOYR,MAAA,SAAA,GAAA;QANV,SAAQ;QACR,MAAK;QACJ,OAAKD,eAAEC,MAAA,EAAA,CAAE,CAAC,EAAC,cAAA,CAAA;QACX,cAAYA,MAAA,CAAA,CAAC,CAAA,kBAAA;;QAEd,SAAAS,cAAiB,CAAjBD,YAAiBR,MAAA,aAAA,CAAA,C;;;;;;;KAOvBY,WAAuB,KAAA,QAAA,SAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-message2.js","names":["_sfc_main"],"sources":["../../../src/components/chat-message/chat-message.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ChevronLeftIcon, ChevronRightIcon, EditIcon, SmilePlusIcon } from '@dou-ui/icons'\nimport { computed, nextTick, onBeforeUnmount, ref, useTemplateRef, watch } from 'vue'\nimport { isComposing } from '../../utils/keyboard'\nimport { devWarn } from '../../utils/status-check'\nimport { useNamespace } from '../../utils/namespace'\nimport { DouButton } from '../button'\nimport { DouChatArtifact } from '../chat-artifact'\nimport { DouChatAttachments } from '../chat-attachments'\nimport { DouChatConfirm } from '../chat-confirm'\nimport { DouChatQuestion } from '../chat-question'\nimport { DouChatPlan } from '../chat-plan'\nimport { planRunning, type ChatPlanItem } from '../chat-plan/chat-plan'\nimport { DouChatReasoning } from '../chat-reasoning'\nimport { DouChatSources } from '../chat-sources'\nimport { DouChatSteps } from '../chat-steps'\nimport { stepsLive, type ChatStep } from '../chat-steps/chat-steps'\nimport { DouChatToolCall } from '../chat-tool-call'\nimport { useLocale } from '../config-provider/use-config'\nimport { DouCopyButton } from '../copy-button'\nimport { DouMarkdown } from '../markdown'\nimport { DouPopover } from '../popover'\nimport type { ChatSource } from '../chat-sources/chat-sources'\nimport { DouStreamText } from '../stream-text'\nimport { DouTooltip } from '../tooltip'\nimport { messageText } from './chat-message'\nimport type {\n ChatArtifactPart,\n ChatConfirmPart,\n ChatQuestionPart,\n ChatCustomPart,\n ChatMessageEmits,\n ChatMessagePart,\n ChatMessageMarkdownSlots,\n ChatMessageProps,\n ChatMessageReaction,\n ChatMessageSlots,\n} from './chat-message'\n\ndefineOptions({ name: 'DouChatMessage' })\n\nconst props = withDefaults(defineProps<ChatMessageProps>(), {\n sender: 'assistant',\n loading: false,\n copyable: true,\n editable: false,\n markdown: false,\n actionsVisible: undefined,\n versions: 1,\n version: undefined,\n})\nconst emit = defineEmits<ChatMessageEmits>()\nconst slots = defineSlots<ChatMessageSlots & ChatMessageMarkdownSlots>()\n\nconst ns = useNamespace('chat-message')\nconst { t } = useLocale()\n\ntype AnyPart = ChatMessagePart | ChatCustomPart\n\nconst parts = computed<AnyPart[]>(\n () => props.parts ?? (props.content === undefined ? [] : [{ type: 'text', text: props.content }]),\n)\nconst markdownOptions = computed(() =>\n typeof props.markdown === 'object' ? props.markdown : undefined,\n)\n// `markdown-code` here is the Markdown component's `code`\nconst PREFIX = 'markdown-'\nconst markdownSlots = () =>\n Object.keys(slots)\n // the message's own `trailing` goes to its last text, not to every Markdown in it\n .filter((name) => name.startsWith(PREFIX) && name !== `${PREFIX}trailing`)\n .map((name) => ({\n name: name as keyof ChatMessageMarkdownSlots,\n inner: name.slice(PREFIX.length),\n }))\nconst isUser = computed(() => props.sender === 'user')\nconst actionsShow = computed(() => props.actionsVisible ?? 'hover')\n\n// Without hover, a tap on the message shows its actions and a tap\n// anywhere else hides them. Taps on its own buttons and links, and\n// selecting text, leave them as they are.\nconst touched = ref(false)\nconst rootRef = useTemplateRef<HTMLElement>('root')\nconst INTERACTIVE = 'button, a[href], input, textarea, select, summary, [role=\"button\"]'\nfunction onPointerUp(event: PointerEvent) {\n if (event.pointerType === 'mouse') return\n const target = event.target as Element | null\n if (target?.closest(INTERACTIVE)) return\n if (getSelection()?.isCollapsed === false) return\n touched.value = !touched.value\n}\nfunction onOutsidePointerDown(event: PointerEvent) {\n if (!rootRef.value?.contains(event.target as Node)) touched.value = false\n}\nwatch(touched, (on) => {\n if (on) document.addEventListener('pointerdown', onOutsidePointerDown, true)\n else document.removeEventListener('pointerdown', onOutsidePointerDown, true)\n})\nonBeforeUnmount(() => document.removeEventListener('pointerdown', onOutsidePointerDown, true))\n// the person's attachments sit above their bubble, not inside it\nconst files = computed(() => (isUser.value ? parts.value.filter((p) => p.type === 'files') : []))\nconst body = computed(() =>\n isUser.value ? parts.value.filter((p) => p.type !== 'files') : parts.value,\n)\nconst text = computed(() => messageText(parts.value as { type: string; text?: unknown }[]))\n/** The last text part, which the `trailing` slot follows; -1 without one. */\nconst lastText = computed(() => {\n for (let i = body.value.length - 1; i >= 0; i--) if (body.value[i]!.type === 'text') return i\n return -1\n})\n// Every source of the message, numbered in order, for `[1]` in Markdown\n// text. The same array while the sources stay the same, so text that\n// streams in does not redraw the whole reply.\nlet lastSources: ChatSource[] = []\nconst sources = computed(() => {\n const next = parts.value.flatMap((part) =>\n part.type === 'sources' ? ((part as { items?: ChatSource[] }).items ?? []) : [],\n )\n if (next.length === lastSources.length && next.every((s, i) => s === lastSources[i]))\n return lastSources\n return (lastSources = next)\n})\n\nconst busy = computed(\n () =>\n props.loading ||\n parts.value.some((part) => {\n const p = part as Record<string, unknown>\n // an artifact can keep being made after the reply ends, so it doesn't hold the actions back\n const working = p.status === 'running' && p.type !== 'artifact' && p.live !== false\n // busy exactly when steps or a plan show themselves running\n const live = p.live as boolean | undefined\n const steps = p.type === 'steps' && stepsLive(p.items as ChatStep[] | undefined, live)\n const plan = p.type === 'plan' && planRunning(p.items as ChatPlanItem[] | undefined, live)\n return !!p.streaming || !!p.thinking || steps || plan || working\n }),\n)\n\nconst innerVersion = ref(props.versions)\nconst version = computed(() => Math.min(props.version ?? innerVersion.value, props.versions))\nfunction step(delta: number) {\n const next = Math.min(Math.max(version.value + delta, 1), props.versions)\n innerVersion.value = next\n emit('update:version', next)\n}\n\n// reactions\nconst reactions = computed(() => (props.reactions ?? []).filter((r) => r.count > 0))\nconst canReact = computed(() => !!slots['reaction-picker'])\nconst pickerOpen = ref(false)\nif (process.env.NODE_ENV !== 'production') {\n watch(\n () => props.reactions,\n (list) => {\n const seen = new Set<string>()\n for (const { emoji } of list ?? []) {\n if (seen.has(emoji))\n devWarn(\n `[dou-ui] DouChatMessage: \\`reactions\\` lists \"${emoji}\" more than once; give each emoji one entry with its count.`,\n )\n seen.add(emoji)\n }\n },\n { immediate: true },\n )\n}\nfunction react(emoji: string) {\n emit(\n 'react',\n emoji,\n props.reactions?.find((r) => r.emoji === emoji),\n )\n}\n// Picked in the panel: the add button may move from the actions to the end\n// of the reactions as the first one comes in, so focus follows it there\n// rather than falling back to the page.\nfunction pick(emoji: string) {\n pickerOpen.value = false\n react(emoji)\n void nextTick(() => {\n const root = rootRef.value\n if (!root || root.contains(document.activeElement)) return\n root.querySelector<HTMLElement>(`.${ns.e('add-reaction')}`)?.focus()\n })\n}\n/** Read out and shown on hover: the emoji and count, then `label` when given. */\nfunction reactionLabel(reaction: ChatMessageReaction) {\n const base = t('chat.reaction', { emoji: reaction.emoji, count: reaction.count })\n return reaction.label ? t('chat.reactionWith', { reaction: base, label: reaction.label }) : base\n}\n// The add button sits among the actions until the first reaction, then at\n// the end of the reactions, so a message without any takes no extra line.\nconst addInActions = computed(() => canReact.value && !reactions.value.length)\n\nconst showActions = computed(\n () =>\n !busy.value &&\n (props.versions > 1 ||\n (props.copyable && !!text.value) ||\n (props.editable && isUser.value) ||\n addInActions.value ||\n !!slots.actions),\n)\n\n// editing in place\nconst editing = ref(false)\nconst draft = ref('')\nconst editorRef = useTemplateRef<HTMLTextAreaElement>('editor')\nfunction startEdit() {\n draft.value = text.value\n editing.value = true\n void nextTick(() => {\n const el = editorRef.value\n el?.focus()\n el?.setSelectionRange(el.value.length, el.value.length)\n fitEditor()\n })\n}\nfunction cancelEdit() {\n editing.value = false\n}\nfunction saveEdit() {\n if (!draft.value.trim()) return\n editing.value = false\n emit('edit', draft.value)\n}\nfunction fitEditor() {\n const el = editorRef.value\n if (!el) return\n el.style.height = 'auto'\n el.style.height = `${el.scrollHeight}px`\n}\nfunction onEditorKeydown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n event.preventDefault()\n cancelEdit()\n } else if (event.key === 'Enter' && !event.shiftKey && !isComposing(event)) {\n event.preventDefault()\n saveEdit()\n }\n}\n\nconst asText = (part: AnyPart) => part as Extract<ChatMessagePart, { type: 'text' }>\nconst asReasoning = (part: AnyPart) => part as Extract<ChatMessagePart, { type: 'reasoning' }>\nconst asFiles = (part: AnyPart) => part as Extract<ChatMessagePart, { type: 'files' }>\nconst asConfirm = (part: AnyPart) => part as ChatConfirmPart\nconst asArtifact = (part: AnyPart) => part as ChatArtifactPart\nconst asQuestion = (part: AnyPart) => part as ChatQuestionPart\nconst known = new Set([\n 'text',\n 'reasoning',\n 'tool',\n 'steps',\n 'plan',\n 'sources',\n 'files',\n 'artifact',\n 'confirm',\n 'question',\n])\n// props for the part components, without the `type` discriminator\nconst rest = (part: AnyPart) => {\n const { type: _type, ...others } = part as Record<string, unknown>\n return others\n}\n</script>\n\n<template>\n <div\n :class=\"[\n ns.b(),\n ns.m(sender),\n ns.m(`actions-${actionsShow}`),\n ns.is('loading', loading),\n ns.is('editing', editing),\n ns.is('highlighted', highlighted),\n ns.is('reacting', pickerOpen),\n ns.is('touched', touched),\n ]\"\n ref=\"root\"\n :aria-busy=\"busy || undefined\"\n :aria-current=\"highlighted || undefined\"\n @pointerup=\"onPointerUp\"\n >\n <div v-if=\"files.length && !editing\" :class=\"ns.e('files')\">\n <template v-for=\"(part, index) in files\" :key=\"`f${index}`\">\n <DouChatAttachments :model-value=\"asFiles(part).files\" :removable=\"false\" />\n </template>\n </div>\n\n <div v-if=\"editing\" :class=\"ns.e('editor')\">\n <textarea\n ref=\"editor\"\n v-model=\"draft\"\n :class=\"ns.e('editor-native')\"\n rows=\"1\"\n :aria-label=\"t('chat.edit')\"\n @input=\"fitEditor\"\n @keydown=\"onEditorKeydown\"\n />\n <div :class=\"ns.e('editor-actions')\">\n <DouButton size=\"sm\" variant=\"ghost\" @click=\"cancelEdit\">{{ t('chat.cancel') }}</DouButton>\n <DouButton size=\"sm\" :disabled=\"!draft.trim()\" @click=\"saveEdit\">\n {{ t('chat.send') }}\n </DouButton>\n </div>\n </div>\n\n <div v-else-if=\"body.length || loading || slots.default\" :class=\"ns.e('content')\">\n <slot>\n <template v-for=\"(part, index) in body\" :key=\"index\">\n <DouMarkdown\n v-if=\"part.type === 'text' && markdown && !slots.text\"\n v-bind=\"markdownOptions\"\n :class=\"ns.e('text')\"\n :content=\"asText(part).text\"\n :streaming=\"!!asText(part).streaming\"\n :sources=\"sources.length ? sources : undefined\"\n >\n <template v-for=\"slot in markdownSlots()\" :key=\"slot.name\" #[slot.inner]=\"scope\">\n <slot :name=\"slot.name\" v-bind=\"scope\" />\n </template>\n <template v-if=\"slots.trailing && index === lastText\" #trailing>\n <slot name=\"trailing\" />\n </template>\n </DouMarkdown>\n <DouStreamText\n v-else-if=\"part.type === 'text'\"\n :class=\"ns.e('text')\"\n :content=\"asText(part).text\"\n :streaming=\"!!asText(part).streaming\"\n >\n <template v-if=\"slots.text\" #default=\"{ text: shown }\">\n <slot\n name=\"text\"\n :part=\"asText(part)\"\n :text=\"shown\"\n :index=\"index\"\n :sources=\"sources\"\n />\n </template>\n <template v-if=\"slots.trailing && index === lastText\" #trailing>\n <slot name=\"trailing\" />\n </template>\n </DouStreamText>\n <DouChatReasoning\n v-else-if=\"part.type === 'reasoning'\"\n :thinking=\"!!asReasoning(part).thinking\"\n :duration=\"asReasoning(part).duration\"\n >\n <DouMarkdown\n v-if=\"markdown\"\n v-bind=\"markdownOptions\"\n :content=\"asReasoning(part).text\"\n :streaming=\"!!asReasoning(part).thinking\"\n :caret=\"false\"\n >\n <template v-for=\"slot in markdownSlots()\" :key=\"slot.name\" #[slot.inner]=\"scope\">\n <slot :name=\"slot.name\" v-bind=\"scope\" />\n </template>\n </DouMarkdown>\n <DouStreamText\n v-else\n :content=\"asReasoning(part).text\"\n :streaming=\"!!asReasoning(part).thinking\"\n :caret=\"false\"\n />\n </DouChatReasoning>\n <DouChatToolCall v-else-if=\"part.type === 'tool'\" v-bind=\"rest(part)\" />\n <DouChatSteps v-else-if=\"part.type === 'steps'\" v-bind=\"rest(part)\" />\n <DouChatPlan v-else-if=\"part.type === 'plan'\" v-bind=\"rest(part)\" />\n <DouChatSources v-else-if=\"part.type === 'sources'\" v-bind=\"rest(part)\" />\n <DouChatAttachments\n v-else-if=\"part.type === 'files'\"\n :model-value=\"asFiles(part).files\"\n :removable=\"false\"\n />\n <DouChatArtifact\n v-else-if=\"part.type === 'artifact'\"\n v-bind=\"rest(part)\"\n @open=\"emit('artifact', asArtifact(part))\"\n />\n <DouChatConfirm\n v-else-if=\"part.type === 'confirm'\"\n :title=\"asConfirm(part).title\"\n :description=\"asConfirm(part).description\"\n :status=\"asConfirm(part).status\"\n :allow-always=\"asConfirm(part).allowAlways\"\n :tone=\"asConfirm(part).tone\"\n @decide=\"emit('confirm', asConfirm(part), $event)\"\n >\n <pre v-if=\"asConfirm(part).detail\" :class=\"ns.e('code')\">{{\n asConfirm(part).detail\n }}</pre>\n </DouChatConfirm>\n <DouChatQuestion\n v-else-if=\"part.type === 'question'\"\n :title=\"asQuestion(part).title\"\n :description=\"asQuestion(part).description\"\n :options=\"asQuestion(part).options\"\n :status=\"asQuestion(part).status\"\n :answer=\"asQuestion(part).answer\"\n @select=\"(value, option) => emit('question', asQuestion(part), value, option)\"\n />\n <slot\n v-else-if=\"!known.has(part.type)\"\n name=\"part\"\n :part=\"part as ChatCustomPart\"\n :index=\"index\"\n />\n </template>\n <div v-if=\"slots.trailing && lastText < 0 && !loading\" :class=\"ns.e('trailing')\">\n <slot name=\"trailing\" />\n </div>\n </slot>\n <span v-if=\"loading\" :class=\"ns.e('loading')\" role=\"status\" :aria-label=\"t('chat.loading')\">\n <i /><i /><i />\n </span>\n </div>\n\n <div\n v-if=\"reactions.length && !editing\"\n :class=\"ns.e('reactions')\"\n role=\"group\"\n :aria-label=\"t('chat.reactions')\"\n >\n <DouTooltip\n v-for=\"reaction in reactions\"\n :key=\"reaction.emoji\"\n :content=\"reactionLabel(reaction)\"\n >\n <button\n type=\"button\"\n :class=\"[ns.e('reaction'), ns.is('reacted', !!reaction.reacted)]\"\n :aria-pressed=\"!!reaction.reacted\"\n :aria-label=\"reactionLabel(reaction)\"\n @click=\"react(reaction.emoji)\"\n >\n <span :class=\"ns.e('reaction-emoji')\">\n <slot name=\"reaction\" :reaction=\"reaction\">{{ reaction.emoji }}</slot>\n </span>\n <span :class=\"ns.e('reaction-count')\">{{ reaction.count }}</span>\n </button>\n </DouTooltip>\n <DouTooltip v-if=\"canReact\" :content=\"t('chat.addReaction')\">\n <DouPopover v-model:open=\"pickerOpen\" placement=\"top-start\">\n <DouButton\n variant=\"ghost\"\n size=\"xs\"\n :class=\"ns.e('add-reaction')\"\n :aria-label=\"t('chat.addReaction')\"\n >\n <SmilePlusIcon />\n </DouButton>\n <template #content=\"{ close }\">\n <slot name=\"reaction-picker\" :react=\"pick\" :close=\"close\" />\n </template>\n </DouPopover>\n </DouTooltip>\n </div>\n\n <!-- last in reading order, drawn at the top right of the message -->\n <div v-if=\"showActions && !editing\" :class=\"ns.e('toolbar')\">\n <div :class=\"ns.e('actions')\">\n <div\n v-if=\"versions > 1\"\n :class=\"ns.e('versions')\"\n role=\"group\"\n :aria-label=\"t('chat.versions')\"\n >\n <DouButton\n variant=\"ghost\"\n size=\"sm\"\n :disabled=\"version <= 1\"\n :aria-label=\"t('chat.previousVersion')\"\n @click=\"step(-1)\"\n >\n <ChevronLeftIcon />\n </DouButton>\n <span :class=\"ns.e('version')\">{{ version }} / {{ versions }}</span>\n <DouButton\n variant=\"ghost\"\n size=\"sm\"\n :disabled=\"version >= versions\"\n :aria-label=\"t('chat.nextVersion')\"\n @click=\"step(1)\"\n >\n <ChevronRightIcon />\n </DouButton>\n </div>\n <DouCopyButton v-if=\"copyable && text\" size=\"sm\" :text=\"text\" />\n <DouTooltip v-if=\"editable && isUser\" :content=\"t('chat.edit')\">\n <DouButton variant=\"ghost\" size=\"sm\" :aria-label=\"t('chat.edit')\" @click=\"startEdit\">\n <EditIcon />\n </DouButton>\n </DouTooltip>\n <DouTooltip v-if=\"addInActions\" :content=\"t('chat.addReaction')\">\n <DouPopover v-model:open=\"pickerOpen\" placement=\"top-start\">\n <DouButton\n variant=\"ghost\"\n size=\"sm\"\n :class=\"ns.e('add-reaction')\"\n :aria-label=\"t('chat.addReaction')\"\n >\n <SmilePlusIcon />\n </DouButton>\n <template #content=\"{ close }\">\n <slot name=\"reaction-picker\" :react=\"pick\" :close=\"close\" />\n </template>\n </DouPopover>\n </DouTooltip>\n <slot name=\"actions\" />\n </div>\n </div>\n </div>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"chat-message2.js","names":["_sfc_main"],"sources":["../../../src/components/chat-message/chat-message.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ChevronLeftIcon, ChevronRightIcon, EditIcon, SmilePlusIcon } from '@dou-ui/icons'\nimport { computed, nextTick, onBeforeUnmount, ref, useTemplateRef, watch } from 'vue'\nimport { isComposing } from '../../utils/keyboard'\nimport { devWarn } from '../../utils/status-check'\nimport { useNamespace } from '../../utils/namespace'\nimport { DouButton } from '../button'\nimport { DouChatArtifact } from '../chat-artifact'\nimport { DouChatAttachments } from '../chat-attachments'\nimport { DouChatConfirm } from '../chat-confirm'\nimport { DouChatQuestion } from '../chat-question'\nimport { DouChatPlan } from '../chat-plan'\nimport { planRunning, type ChatPlanItem } from '../chat-plan/chat-plan'\nimport { DouChatReasoning } from '../chat-reasoning'\nimport { DouChatSources } from '../chat-sources'\nimport { DouChatSteps } from '../chat-steps'\nimport { stepsLive, type ChatStep } from '../chat-steps/chat-steps'\nimport { DouChatToolCall } from '../chat-tool-call'\nimport { useLocale } from '../config-provider/use-config'\nimport { DouCopyButton } from '../copy-button'\nimport { DouMarkdown } from '../markdown'\nimport { DouPopover } from '../popover'\nimport type { ChatSource } from '../chat-sources/chat-sources'\nimport { DouStreamText } from '../stream-text'\nimport { DouTooltip } from '../tooltip'\nimport { messageText } from './chat-message'\nimport type {\n ChatArtifactPart,\n ChatConfirmPart,\n ChatQuestionPart,\n ChatCustomPart,\n ChatMessageEmits,\n ChatMessagePart,\n ChatMessageMarkdownSlots,\n ChatMessageProps,\n ChatMessageReaction,\n ChatMessageSlots,\n} from './chat-message'\n\ndefineOptions({ name: 'DouChatMessage' })\n\nconst props = withDefaults(defineProps<ChatMessageProps>(), {\n sender: 'assistant',\n loading: false,\n copyable: true,\n reactable: true,\n editable: false,\n markdown: false,\n actionsVisible: undefined,\n versions: 1,\n version: undefined,\n})\nconst emit = defineEmits<ChatMessageEmits>()\nconst slots = defineSlots<ChatMessageSlots & ChatMessageMarkdownSlots>()\n\nconst ns = useNamespace('chat-message')\nconst { t } = useLocale()\n\ntype AnyPart = ChatMessagePart | ChatCustomPart\n\nconst parts = computed<AnyPart[]>(\n () => props.parts ?? (props.content === undefined ? [] : [{ type: 'text', text: props.content }]),\n)\nconst markdownOptions = computed(() =>\n typeof props.markdown === 'object' ? props.markdown : undefined,\n)\n// `markdown-code` here is the Markdown component's `code`\nconst PREFIX = 'markdown-'\nconst markdownSlots = () =>\n Object.keys(slots)\n // the message's own `trailing` goes to its last text, not to every Markdown in it\n .filter((name) => name.startsWith(PREFIX) && name !== `${PREFIX}trailing`)\n .map((name) => ({\n name: name as keyof ChatMessageMarkdownSlots,\n inner: name.slice(PREFIX.length),\n }))\nconst isUser = computed(() => props.sender === 'user')\nconst actionsShow = computed(() => props.actionsVisible ?? 'hover')\n\n// Without hover, a tap on the message shows its actions and a tap\n// anywhere else hides them. Taps on its own buttons and links, and\n// selecting text, leave them as they are.\nconst touched = ref(false)\nconst rootRef = useTemplateRef<HTMLElement>('root')\nconst INTERACTIVE = 'button, a[href], input, textarea, select, summary, [role=\"button\"]'\nfunction onPointerUp(event: PointerEvent) {\n if (event.pointerType === 'mouse') return\n const target = event.target as Element | null\n if (target?.closest(INTERACTIVE)) return\n if (getSelection()?.isCollapsed === false) return\n touched.value = !touched.value\n}\nfunction onOutsidePointerDown(event: PointerEvent) {\n if (!rootRef.value?.contains(event.target as Node)) touched.value = false\n}\nwatch(touched, (on) => {\n if (on) document.addEventListener('pointerdown', onOutsidePointerDown, true)\n else document.removeEventListener('pointerdown', onOutsidePointerDown, true)\n})\nonBeforeUnmount(() => document.removeEventListener('pointerdown', onOutsidePointerDown, true))\n// the person's attachments sit above their bubble, not inside it\nconst files = computed(() => (isUser.value ? parts.value.filter((p) => p.type === 'files') : []))\nconst body = computed(() =>\n isUser.value ? parts.value.filter((p) => p.type !== 'files') : parts.value,\n)\nconst text = computed(() => messageText(parts.value as { type: string; text?: unknown }[]))\n/** The last text part, which the `trailing` slot follows; -1 without one. */\nconst lastText = computed(() => {\n for (let i = body.value.length - 1; i >= 0; i--) if (body.value[i]!.type === 'text') return i\n return -1\n})\n// Every source of the message, numbered in order, for `[1]` in Markdown\n// text. The same array while the sources stay the same, so text that\n// streams in does not redraw the whole reply.\nlet lastSources: ChatSource[] = []\nconst sources = computed(() => {\n const next = parts.value.flatMap((part) =>\n part.type === 'sources' ? ((part as { items?: ChatSource[] }).items ?? []) : [],\n )\n if (next.length === lastSources.length && next.every((s, i) => s === lastSources[i]))\n return lastSources\n return (lastSources = next)\n})\n\nconst busy = computed(\n () =>\n props.loading ||\n parts.value.some((part) => {\n const p = part as Record<string, unknown>\n // an artifact can keep being made after the reply ends, so it doesn't hold the actions back\n const working = p.status === 'running' && p.type !== 'artifact' && p.live !== false\n // busy exactly when steps or a plan show themselves running\n const live = p.live as boolean | undefined\n const steps = p.type === 'steps' && stepsLive(p.items as ChatStep[] | undefined, live)\n const plan = p.type === 'plan' && planRunning(p.items as ChatPlanItem[] | undefined, live)\n return !!p.streaming || !!p.thinking || steps || plan || working\n }),\n)\n\nconst innerVersion = ref(props.versions)\nconst version = computed(() => Math.min(props.version ?? innerVersion.value, props.versions))\nfunction step(delta: number) {\n const next = Math.min(Math.max(version.value + delta, 1), props.versions)\n innerVersion.value = next\n emit('update:version', next)\n}\n\n// reactions\nconst reactions = computed(() => (props.reactions ?? []).filter((r) => r.count > 0))\nconst canReact = computed(() => props.reactable && !!slots['reaction-picker'])\nconst pickerOpen = ref(false)\nif (process.env.NODE_ENV !== 'production') {\n watch(\n () => props.reactions,\n (list) => {\n const seen = new Set<string>()\n for (const { emoji } of list ?? []) {\n if (seen.has(emoji))\n devWarn(\n `[dou-ui] DouChatMessage: \\`reactions\\` lists \"${emoji}\" more than once; give each emoji one entry with its count.`,\n )\n seen.add(emoji)\n }\n },\n { immediate: true },\n )\n}\nfunction react(emoji: string) {\n emit(\n 'react',\n emoji,\n props.reactions?.find((r) => r.emoji === emoji),\n )\n}\n// Picked in the panel: the add button may move from the actions to the end\n// of the reactions as the first one comes in, so focus follows it there\n// rather than falling back to the page.\nfunction pick(emoji: string) {\n pickerOpen.value = false\n react(emoji)\n void nextTick(() => {\n const root = rootRef.value\n if (!root || root.contains(document.activeElement)) return\n root.querySelector<HTMLElement>(`.${ns.e('add-reaction')}`)?.focus()\n })\n}\n/** Read out and shown on hover: the emoji and count, then `label` when given. */\nfunction reactionLabel(reaction: ChatMessageReaction) {\n const base = t('chat.reaction', { emoji: reaction.emoji, count: reaction.count })\n return reaction.label ? t('chat.reactionWith', { reaction: base, label: reaction.label }) : base\n}\n// The add button sits among the actions until the first reaction, then at\n// the end of the reactions, so a message without any takes no extra line.\nconst addInActions = computed(() => canReact.value && !reactions.value.length)\n\nconst showActions = computed(\n () =>\n !busy.value &&\n (props.versions > 1 ||\n (props.copyable && !!text.value) ||\n (props.editable && isUser.value) ||\n addInActions.value ||\n !!slots.actions),\n)\n\n// editing in place\nconst editing = ref(false)\nconst draft = ref('')\nconst editorRef = useTemplateRef<HTMLTextAreaElement>('editor')\nfunction startEdit() {\n draft.value = text.value\n editing.value = true\n void nextTick(() => {\n const el = editorRef.value\n el?.focus()\n el?.setSelectionRange(el.value.length, el.value.length)\n fitEditor()\n })\n}\nfunction cancelEdit() {\n editing.value = false\n}\nfunction saveEdit() {\n if (!draft.value.trim()) return\n editing.value = false\n emit('edit', draft.value)\n}\nfunction fitEditor() {\n const el = editorRef.value\n if (!el) return\n el.style.height = 'auto'\n el.style.height = `${el.scrollHeight}px`\n}\nfunction onEditorKeydown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n event.preventDefault()\n cancelEdit()\n } else if (event.key === 'Enter' && !event.shiftKey && !isComposing(event)) {\n event.preventDefault()\n saveEdit()\n }\n}\n\nconst asText = (part: AnyPart) => part as Extract<ChatMessagePart, { type: 'text' }>\nconst asReasoning = (part: AnyPart) => part as Extract<ChatMessagePart, { type: 'reasoning' }>\nconst asFiles = (part: AnyPart) => part as Extract<ChatMessagePart, { type: 'files' }>\nconst asConfirm = (part: AnyPart) => part as ChatConfirmPart\nconst asArtifact = (part: AnyPart) => part as ChatArtifactPart\nconst asQuestion = (part: AnyPart) => part as ChatQuestionPart\nconst known = new Set([\n 'text',\n 'reasoning',\n 'tool',\n 'steps',\n 'plan',\n 'sources',\n 'files',\n 'artifact',\n 'confirm',\n 'question',\n])\n// props for the part components, without the `type` discriminator\nconst rest = (part: AnyPart) => {\n const { type: _type, ...others } = part as Record<string, unknown>\n return others\n}\n</script>\n\n<template>\n <div\n :class=\"[\n ns.b(),\n ns.m(sender),\n ns.m(`actions-${actionsShow}`),\n ns.is('loading', loading),\n ns.is('editing', editing),\n ns.is('highlighted', highlighted),\n ns.is('reacting', pickerOpen),\n ns.is('touched', touched),\n ]\"\n ref=\"root\"\n :aria-busy=\"busy || undefined\"\n :aria-current=\"highlighted || undefined\"\n @pointerup=\"onPointerUp\"\n >\n <div v-if=\"files.length && !editing\" :class=\"ns.e('files')\">\n <template v-for=\"(part, index) in files\" :key=\"`f${index}`\">\n <DouChatAttachments :model-value=\"asFiles(part).files\" :removable=\"false\" />\n </template>\n </div>\n\n <div v-if=\"editing\" :class=\"ns.e('editor')\">\n <textarea\n ref=\"editor\"\n v-model=\"draft\"\n :class=\"ns.e('editor-native')\"\n rows=\"1\"\n :aria-label=\"t('chat.edit')\"\n @input=\"fitEditor\"\n @keydown=\"onEditorKeydown\"\n />\n <div :class=\"ns.e('editor-actions')\">\n <DouButton size=\"sm\" variant=\"ghost\" @click=\"cancelEdit\">{{ t('chat.cancel') }}</DouButton>\n <DouButton size=\"sm\" :disabled=\"!draft.trim()\" @click=\"saveEdit\">\n {{ t('chat.send') }}\n </DouButton>\n </div>\n </div>\n\n <div v-else-if=\"body.length || loading || slots.default\" :class=\"ns.e('content')\">\n <slot>\n <template v-for=\"(part, index) in body\" :key=\"index\">\n <DouMarkdown\n v-if=\"part.type === 'text' && markdown && !slots.text\"\n v-bind=\"markdownOptions\"\n :class=\"ns.e('text')\"\n :content=\"asText(part).text\"\n :streaming=\"!!asText(part).streaming\"\n :sources=\"sources.length ? sources : undefined\"\n >\n <template v-for=\"slot in markdownSlots()\" :key=\"slot.name\" #[slot.inner]=\"scope\">\n <slot :name=\"slot.name\" v-bind=\"scope\" />\n </template>\n <template v-if=\"slots.trailing && index === lastText\" #trailing>\n <slot name=\"trailing\" />\n </template>\n </DouMarkdown>\n <DouStreamText\n v-else-if=\"part.type === 'text'\"\n :class=\"ns.e('text')\"\n :content=\"asText(part).text\"\n :streaming=\"!!asText(part).streaming\"\n >\n <template v-if=\"slots.text\" #default=\"{ text: shown }\">\n <slot\n name=\"text\"\n :part=\"asText(part)\"\n :text=\"shown\"\n :index=\"index\"\n :sources=\"sources\"\n />\n </template>\n <template v-if=\"slots.trailing && index === lastText\" #trailing>\n <slot name=\"trailing\" />\n </template>\n </DouStreamText>\n <DouChatReasoning\n v-else-if=\"part.type === 'reasoning'\"\n :thinking=\"!!asReasoning(part).thinking\"\n :duration=\"asReasoning(part).duration\"\n >\n <DouMarkdown\n v-if=\"markdown\"\n v-bind=\"markdownOptions\"\n :content=\"asReasoning(part).text\"\n :streaming=\"!!asReasoning(part).thinking\"\n :caret=\"false\"\n >\n <template v-for=\"slot in markdownSlots()\" :key=\"slot.name\" #[slot.inner]=\"scope\">\n <slot :name=\"slot.name\" v-bind=\"scope\" />\n </template>\n </DouMarkdown>\n <DouStreamText\n v-else\n :content=\"asReasoning(part).text\"\n :streaming=\"!!asReasoning(part).thinking\"\n :caret=\"false\"\n />\n </DouChatReasoning>\n <DouChatToolCall v-else-if=\"part.type === 'tool'\" v-bind=\"rest(part)\" />\n <DouChatSteps v-else-if=\"part.type === 'steps'\" v-bind=\"rest(part)\" />\n <DouChatPlan v-else-if=\"part.type === 'plan'\" v-bind=\"rest(part)\" />\n <DouChatSources v-else-if=\"part.type === 'sources'\" v-bind=\"rest(part)\" />\n <DouChatAttachments\n v-else-if=\"part.type === 'files'\"\n :model-value=\"asFiles(part).files\"\n :removable=\"false\"\n />\n <DouChatArtifact\n v-else-if=\"part.type === 'artifact'\"\n v-bind=\"rest(part)\"\n @open=\"emit('artifact', asArtifact(part))\"\n />\n <DouChatConfirm\n v-else-if=\"part.type === 'confirm'\"\n :title=\"asConfirm(part).title\"\n :description=\"asConfirm(part).description\"\n :status=\"asConfirm(part).status\"\n :allow-always=\"asConfirm(part).allowAlways\"\n :tone=\"asConfirm(part).tone\"\n @decide=\"emit('confirm', asConfirm(part), $event)\"\n >\n <pre v-if=\"asConfirm(part).detail\" :class=\"ns.e('code')\">{{\n asConfirm(part).detail\n }}</pre>\n </DouChatConfirm>\n <DouChatQuestion\n v-else-if=\"part.type === 'question'\"\n :title=\"asQuestion(part).title\"\n :description=\"asQuestion(part).description\"\n :options=\"asQuestion(part).options\"\n :status=\"asQuestion(part).status\"\n :answer=\"asQuestion(part).answer\"\n @select=\"(value, option) => emit('question', asQuestion(part), value, option)\"\n />\n <slot\n v-else-if=\"!known.has(part.type)\"\n name=\"part\"\n :part=\"part as ChatCustomPart\"\n :index=\"index\"\n />\n </template>\n <div v-if=\"slots.trailing && lastText < 0 && !loading\" :class=\"ns.e('trailing')\">\n <slot name=\"trailing\" />\n </div>\n </slot>\n <span v-if=\"loading\" :class=\"ns.e('loading')\" role=\"status\" :aria-label=\"t('chat.loading')\">\n <i /><i /><i />\n </span>\n </div>\n\n <div\n v-if=\"reactions.length && !editing\"\n :class=\"ns.e('reactions')\"\n role=\"group\"\n :aria-label=\"t('chat.reactions')\"\n >\n <DouTooltip\n v-for=\"reaction in reactions\"\n :key=\"reaction.emoji\"\n :content=\"reactionLabel(reaction)\"\n >\n <!-- read only: the same chip, read out as one image with its label -->\n <span\n v-if=\"!reactable\"\n role=\"img\"\n tabindex=\"0\"\n :class=\"[ns.e('reaction'), ns.is('reacted', !!reaction.reacted), ns.is('readonly', true)]\"\n :aria-label=\"reactionLabel(reaction)\"\n >\n <span :class=\"ns.e('reaction-emoji')\">\n <slot name=\"reaction\" :reaction=\"reaction\">{{ reaction.emoji }}</slot>\n </span>\n <span :class=\"ns.e('reaction-count')\">{{ reaction.count }}</span>\n </span>\n <button\n v-else\n type=\"button\"\n :class=\"[ns.e('reaction'), ns.is('reacted', !!reaction.reacted)]\"\n :aria-pressed=\"!!reaction.reacted\"\n :aria-label=\"reactionLabel(reaction)\"\n @click=\"react(reaction.emoji)\"\n >\n <span :class=\"ns.e('reaction-emoji')\">\n <slot name=\"reaction\" :reaction=\"reaction\">{{ reaction.emoji }}</slot>\n </span>\n <span :class=\"ns.e('reaction-count')\">{{ reaction.count }}</span>\n </button>\n </DouTooltip>\n <DouTooltip v-if=\"canReact\" :content=\"t('chat.addReaction')\">\n <DouPopover v-model:open=\"pickerOpen\" placement=\"top-start\">\n <DouButton\n variant=\"ghost\"\n size=\"xs\"\n :class=\"ns.e('add-reaction')\"\n :aria-label=\"t('chat.addReaction')\"\n >\n <SmilePlusIcon />\n </DouButton>\n <template #content=\"{ close }\">\n <slot name=\"reaction-picker\" :react=\"pick\" :close=\"close\" />\n </template>\n </DouPopover>\n </DouTooltip>\n </div>\n\n <!-- last in reading order, drawn at the top right of the message -->\n <div v-if=\"showActions && !editing\" :class=\"ns.e('toolbar')\">\n <div :class=\"ns.e('actions')\">\n <div\n v-if=\"versions > 1\"\n :class=\"ns.e('versions')\"\n role=\"group\"\n :aria-label=\"t('chat.versions')\"\n >\n <DouButton\n variant=\"ghost\"\n size=\"sm\"\n :disabled=\"version <= 1\"\n :aria-label=\"t('chat.previousVersion')\"\n @click=\"step(-1)\"\n >\n <ChevronLeftIcon />\n </DouButton>\n <span :class=\"ns.e('version')\">{{ version }} / {{ versions }}</span>\n <DouButton\n variant=\"ghost\"\n size=\"sm\"\n :disabled=\"version >= versions\"\n :aria-label=\"t('chat.nextVersion')\"\n @click=\"step(1)\"\n >\n <ChevronRightIcon />\n </DouButton>\n </div>\n <DouCopyButton v-if=\"copyable && text\" size=\"sm\" :text=\"text\" />\n <DouTooltip v-if=\"editable && isUser\" :content=\"t('chat.edit')\">\n <DouButton variant=\"ghost\" size=\"sm\" :aria-label=\"t('chat.edit')\" @click=\"startEdit\">\n <EditIcon />\n </DouButton>\n </DouTooltip>\n <DouTooltip v-if=\"addInActions\" :content=\"t('chat.addReaction')\">\n <DouPopover v-model:open=\"pickerOpen\" placement=\"top-start\">\n <DouButton\n variant=\"ghost\"\n size=\"sm\"\n :class=\"ns.e('add-reaction')\"\n :aria-label=\"t('chat.addReaction')\"\n >\n <SmilePlusIcon />\n </DouButton>\n <template #content=\"{ close }\">\n <slot name=\"reaction-picker\" :react=\"pick\" :close=\"close\" />\n </template>\n </DouPopover>\n </DouTooltip>\n <slot name=\"actions\" />\n </div>\n </div>\n </div>\n</template>\n"],"mappings":""}
|