dou-ui 0.1.0-alpha.15 → 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.
@@ -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 actions under a message show. */\nexport type ChatMessageActionsVisible = 'always' | 'hover'\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 actions show: `'always'`, or `'hover'` while the pointer is\n * over the message or focus is inside. Devices without hover always show\n * them. Buttons from the `actions` slot follow along. Defaults to\n * `'hover'` for the person's messages and `'always'` for the rest.\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\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\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 /** 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":";;AAqNA,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"}
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"}
@@ -1,5 +1,6 @@
1
1
  import { useNamespace } from "../../utils/namespace.js";
2
2
  import { useLocale } from "../config-provider/use-config.js";
3
+ import { devWarn } from "../../utils/status-check.js";
3
4
  import { isComposing } from "../../utils/keyboard.js";
4
5
  import { DouButton } from "../button/index.js";
5
6
  import { DouChatArtifact } from "../chat-artifact/index.js";
@@ -9,6 +10,7 @@ import { DouChatQuestion } from "../chat-question/index.js";
9
10
  import { planRunning } from "../chat-plan/chat-plan.js";
10
11
  import { DouChatPlan } from "../chat-plan/index.js";
11
12
  import { DouChatReasoning } from "../chat-reasoning/index.js";
13
+ import { DouPopover } from "../popover/index.js";
12
14
  import { DouChatSources } from "../chat-sources/index.js";
13
15
  import { stepsLive } from "../chat-steps/chat-steps.js";
14
16
  import { DouChatSteps } from "../chat-steps/index.js";
@@ -18,14 +20,22 @@ import { DouCopyButton } from "../copy-button/index.js";
18
20
  import { DouMarkdown } from "../markdown/index.js";
19
21
  import { DouStreamText } from "../stream-text/index.js";
20
22
  import { messageText } from "./chat-message.js";
21
- import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, mergeProps, nextTick, normalizeClass, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useSlots, useTemplateRef, vModelText, withCtx, withDirectives } from "vue";
22
- import { ChevronLeftIcon, ChevronRightIcon, EditIcon } from "@dou-ui/icons";
23
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, mergeProps, nextTick, normalizeClass, onBeforeUnmount, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useSlots, useTemplateRef, vModelText, watch, withCtx, withDirectives } from "vue";
24
+ import { ChevronLeftIcon, ChevronRightIcon, EditIcon, SmilePlusIcon } from "@dou-ui/icons";
23
25
  // src/components/chat-message/chat-message.vue?vue&type=script&setup=true&lang.ts
24
26
  var _hoisted_1 = ["aria-busy", "aria-current"];
25
27
  var _hoisted_2 = ["aria-label"];
26
28
  var _hoisted_3 = ["aria-label"];
27
29
  var _hoisted_4 = ["aria-label"];
30
+ var _hoisted_5 = ["aria-label"];
31
+ var _hoisted_6 = [
32
+ "aria-pressed",
33
+ "aria-label",
34
+ "onClick"
35
+ ];
36
+ var _hoisted_7 = ["aria-label"];
28
37
  var PREFIX = "markdown-";
38
+ var INTERACTIVE = "button, a[href], input, textarea, select, summary, [role=\"button\"]";
29
39
  var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
30
40
  name: "DouChatMessage",
31
41
  __name: "chat-message",
@@ -52,14 +62,20 @@ var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
52
62
  },
53
63
  versions: { default: 1 },
54
64
  version: { default: void 0 },
55
- highlighted: { type: Boolean }
65
+ highlighted: { type: Boolean },
66
+ reactions: {},
67
+ reactable: {
68
+ type: Boolean,
69
+ default: true
70
+ }
56
71
  },
57
72
  emits: [
58
73
  "update:version",
59
74
  "edit",
60
75
  "confirm",
61
76
  "artifact",
62
- "question"
77
+ "question",
78
+ "react"
63
79
  ],
64
80
  setup(__props, { emit: __emit }) {
65
81
  const props = __props;
@@ -77,7 +93,23 @@ var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
77
93
  inner: name.slice(9)
78
94
  }));
79
95
  const isUser = computed(() => props.sender === "user");
80
- const actionsShow = computed(() => props.actionsVisible ?? (isUser.value ? "hover" : "always"));
96
+ const actionsShow = computed(() => props.actionsVisible ?? "hover");
97
+ const touched = ref(false);
98
+ const rootRef = useTemplateRef("root");
99
+ function onPointerUp(event) {
100
+ if (event.pointerType === "mouse") return;
101
+ if (event.target?.closest(INTERACTIVE)) return;
102
+ if (getSelection()?.isCollapsed === false) return;
103
+ touched.value = !touched.value;
104
+ }
105
+ function onOutsidePointerDown(event) {
106
+ if (!rootRef.value?.contains(event.target)) touched.value = false;
107
+ }
108
+ watch(touched, (on) => {
109
+ if (on) document.addEventListener("pointerdown", onOutsidePointerDown, true);
110
+ else document.removeEventListener("pointerdown", onOutsidePointerDown, true);
111
+ });
112
+ onBeforeUnmount(() => document.removeEventListener("pointerdown", onOutsidePointerDown, true));
81
113
  const files = computed(() => isUser.value ? parts.value.filter((p) => p.type === "files") : []);
82
114
  const body = computed(() => isUser.value ? parts.value.filter((p) => p.type !== "files") : parts.value);
83
115
  const text = computed(() => messageText(parts.value));
@@ -107,7 +139,41 @@ var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
107
139
  innerVersion.value = next;
108
140
  emit("update:version", next);
109
141
  }
110
- const showActions = computed(() => !busy.value && (props.versions > 1 || props.copyable && !!text.value || props.editable && isUser.value || !!slots.actions));
142
+ const reactions = computed(() => (props.reactions ?? []).filter((r) => r.count > 0));
143
+ const canReact = computed(() => props.reactable && !!slots["reaction-picker"]);
144
+ const pickerOpen = ref(false);
145
+ if (process.env.NODE_ENV !== "production") watch(() => props.reactions, (list) => {
146
+ const seen = /* @__PURE__ */ new Set();
147
+ for (const { emoji } of list ?? []) {
148
+ if (seen.has(emoji)) devWarn(`[dou-ui] DouChatMessage: \`reactions\` lists "${emoji}" more than once; give each emoji one entry with its count.`);
149
+ seen.add(emoji);
150
+ }
151
+ }, { immediate: true });
152
+ function react(emoji) {
153
+ emit("react", emoji, props.reactions?.find((r) => r.emoji === emoji));
154
+ }
155
+ function pick(emoji) {
156
+ pickerOpen.value = false;
157
+ react(emoji);
158
+ nextTick(() => {
159
+ const root = rootRef.value;
160
+ if (!root || root.contains(document.activeElement)) return;
161
+ root.querySelector(`.${ns.e("add-reaction")}`)?.focus();
162
+ });
163
+ }
164
+ /** Read out and shown on hover: the emoji and count, then `label` when given. */
165
+ function reactionLabel(reaction) {
166
+ const base = t("chat.reaction", {
167
+ emoji: reaction.emoji,
168
+ count: reaction.count
169
+ });
170
+ return reaction.label ? t("chat.reactionWith", {
171
+ reaction: base,
172
+ label: reaction.label
173
+ }) : base;
174
+ }
175
+ const addInActions = computed(() => canReact.value && !reactions.value.length);
176
+ const showActions = computed(() => !busy.value && (props.versions > 1 || props.copyable && !!text.value || props.editable && isUser.value || addInActions.value || !!slots.actions));
111
177
  const editing = ref(false);
112
178
  const draft = ref("");
113
179
  const editorRef = useTemplateRef("editor");
@@ -174,10 +240,14 @@ var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
174
240
  unref(ns).m(`actions-${actionsShow.value}`),
175
241
  unref(ns).is("loading", __props.loading),
176
242
  unref(ns).is("editing", editing.value),
177
- unref(ns).is("highlighted", __props.highlighted)
243
+ unref(ns).is("highlighted", __props.highlighted),
244
+ unref(ns).is("reacting", pickerOpen.value),
245
+ unref(ns).is("touched", touched.value)
178
246
  ]),
247
+ ref: "root",
179
248
  "aria-busy": busy.value || void 0,
180
- "aria-current": __props.highlighted || void 0
249
+ "aria-current": __props.highlighted || void 0,
250
+ onPointerup: onPointerUp
181
251
  }, [
182
252
  files.value.length && !editing.value ? (openBlock(), createElementBlock("div", {
183
253
  key: 0,
@@ -353,15 +423,71 @@ var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
353
423
  class: normalizeClass(unref(ns).e("loading")),
354
424
  role: "status",
355
425
  "aria-label": unref(t)("chat.loading")
356
- }, [..._cache[3] || (_cache[3] = [
426
+ }, [..._cache[5] || (_cache[5] = [
357
427
  createElementVNode("i", null, null, -1),
358
428
  createElementVNode("i", null, null, -1),
359
429
  createElementVNode("i", null, null, -1)
360
430
  ])], 10, _hoisted_3)) : createCommentVNode("", true)], 2)) : createCommentVNode("", true),
361
- showActions.value && !editing.value ? (openBlock(), createElementBlock("div", {
431
+ reactions.value.length && !editing.value ? (openBlock(), createElementBlock("div", {
362
432
  key: 3,
363
- class: normalizeClass(unref(ns).e("actions"))
364
- }, [
433
+ class: normalizeClass(unref(ns).e("reactions")),
434
+ role: "group",
435
+ "aria-label": unref(t)("chat.reactions")
436
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(reactions.value, (reaction) => {
437
+ return openBlock(), createBlock(unref(DouTooltip), {
438
+ key: reaction.emoji,
439
+ content: reactionLabel(reaction)
440
+ }, {
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,
453
+ type: "button",
454
+ class: normalizeClass([unref(ns).e("reaction"), unref(ns).is("reacted", !!reaction.reacted)]),
455
+ "aria-pressed": !!reaction.reacted,
456
+ "aria-label": reactionLabel(reaction),
457
+ onClick: ($event) => react(reaction.emoji)
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))]),
459
+ _: 2
460
+ }, 1032, ["content"]);
461
+ }), 128)), canReact.value ? (openBlock(), createBlock(unref(DouTooltip), {
462
+ key: 0,
463
+ content: unref(t)("chat.addReaction")
464
+ }, {
465
+ default: withCtx(() => [createVNode(unref(DouPopover), {
466
+ open: pickerOpen.value,
467
+ "onUpdate:open": _cache[1] || (_cache[1] = ($event) => pickerOpen.value = $event),
468
+ placement: "top-start"
469
+ }, {
470
+ content: withCtx(({ close }) => [renderSlot(_ctx.$slots, "reaction-picker", {
471
+ react: pick,
472
+ close
473
+ })]),
474
+ default: withCtx(() => [createVNode(unref(DouButton), {
475
+ variant: "ghost",
476
+ size: "xs",
477
+ class: normalizeClass(unref(ns).e("add-reaction")),
478
+ "aria-label": unref(t)("chat.addReaction")
479
+ }, {
480
+ default: withCtx(() => [createVNode(unref(SmilePlusIcon))]),
481
+ _: 1
482
+ }, 8, ["class", "aria-label"])]),
483
+ _: 3
484
+ }, 8, ["open"])]),
485
+ _: 3
486
+ }, 8, ["content"])) : createCommentVNode("", true)], 10, _hoisted_4)) : createCommentVNode("", true),
487
+ showActions.value && !editing.value ? (openBlock(), createElementBlock("div", {
488
+ key: 4,
489
+ class: normalizeClass(unref(ns).e("toolbar"))
490
+ }, [createElementVNode("div", { class: normalizeClass(unref(ns).e("actions")) }, [
365
491
  __props.versions > 1 ? (openBlock(), createElementBlock("div", {
366
492
  key: 0,
367
493
  class: normalizeClass(unref(ns).e("versions")),
@@ -373,7 +499,7 @@ var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
373
499
  size: "sm",
374
500
  disabled: version.value <= 1,
375
501
  "aria-label": unref(t)("chat.previousVersion"),
376
- onClick: _cache[1] || (_cache[1] = ($event) => step(-1))
502
+ onClick: _cache[2] || (_cache[2] = ($event) => step(-1))
377
503
  }, {
378
504
  default: withCtx(() => [createVNode(unref(ChevronLeftIcon))]),
379
505
  _: 1
@@ -384,12 +510,12 @@ var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
384
510
  size: "sm",
385
511
  disabled: version.value >= __props.versions,
386
512
  "aria-label": unref(t)("chat.nextVersion"),
387
- onClick: _cache[2] || (_cache[2] = ($event) => step(1))
513
+ onClick: _cache[3] || (_cache[3] = ($event) => step(1))
388
514
  }, {
389
515
  default: withCtx(() => [createVNode(unref(ChevronRightIcon))]),
390
516
  _: 1
391
517
  }, 8, ["disabled", "aria-label"])
392
- ], 10, _hoisted_4)) : createCommentVNode("", true),
518
+ ], 10, _hoisted_7)) : createCommentVNode("", true),
393
519
  __props.copyable && text.value ? (openBlock(), createBlock(unref(DouCopyButton), {
394
520
  key: 1,
395
521
  size: "sm",
@@ -410,9 +536,35 @@ var chat_message_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
410
536
  }, 8, ["aria-label"])]),
411
537
  _: 1
412
538
  }, 8, ["content"])) : createCommentVNode("", true),
539
+ addInActions.value ? (openBlock(), createBlock(unref(DouTooltip), {
540
+ key: 3,
541
+ content: unref(t)("chat.addReaction")
542
+ }, {
543
+ default: withCtx(() => [createVNode(unref(DouPopover), {
544
+ open: pickerOpen.value,
545
+ "onUpdate:open": _cache[4] || (_cache[4] = ($event) => pickerOpen.value = $event),
546
+ placement: "top-start"
547
+ }, {
548
+ content: withCtx(({ close }) => [renderSlot(_ctx.$slots, "reaction-picker", {
549
+ react: pick,
550
+ close
551
+ })]),
552
+ default: withCtx(() => [createVNode(unref(DouButton), {
553
+ variant: "ghost",
554
+ size: "sm",
555
+ class: normalizeClass(unref(ns).e("add-reaction")),
556
+ "aria-label": unref(t)("chat.addReaction")
557
+ }, {
558
+ default: withCtx(() => [createVNode(unref(SmilePlusIcon))]),
559
+ _: 1
560
+ }, 8, ["class", "aria-label"])]),
561
+ _: 3
562
+ }, 8, ["open"])]),
563
+ _: 3
564
+ }, 8, ["content"])) : createCommentVNode("", true),
413
565
  renderSlot(_ctx.$slots, "actions")
414
- ], 2)) : createCommentVNode("", true)
415
- ], 10, _hoisted_1);
566
+ ], 2)], 2)) : createCommentVNode("", true)
567
+ ], 42, _hoisted_1);
416
568
  };
417
569
  }
418
570
  });
@@ -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 } from '@dou-ui/icons'\nimport { computed, nextTick, ref, useTemplateRef } from 'vue'\nimport { isComposing } from '../../utils/keyboard'\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 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 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 ?? (isUser.value ? 'hover' : 'always'))\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\nconst showActions = computed(\n () =>\n !busy.value &&\n (props.versions > 1 ||\n (props.copyable && !!text.value) ||\n (props.editable && isUser.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 ]\"\n :aria-busy=\"busy || undefined\"\n :aria-current=\"highlighted || undefined\"\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 v-if=\"showActions && !editing\" :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 <slot name=\"actions\" />\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,IAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAzBf,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,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,mBAAmB,OAAO,QAAQ,UAAU,SAAS;EAE9F,MAAM,QAAQ,eAAgB,OAAO,QAAQ,MAAM,MAAM,QAAQ,MAAM,EAAE,SAAS,OAAO,IAAI,CAAC,CAAE;EAChG,MAAM,OAAO,eACX,OAAO,QAAQ,MAAM,MAAM,QAAQ,MAAM,EAAE,SAAS,OAAO,IAAI,MAAM,KACvE;EACA,MAAM,OAAO,eAAe,YAAY,MAAM,KAA2C,CAAC;;EAE1F,MAAM,WAAW,eAAe;GAC9B,KAAK,IAAI,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dQ,YAQYR,MAAA,SAAA,GAAA;OAPV,SAAQ;OACR,MAAK;OACJ,UAAU,QAAA,SAAO;OACjB,cAAYA,MAAA,CAAA,CAAC,CAAA,sBAAA;OACb,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,EAAA;;OAEZ,SAAAS,cAAmB,CAAnBD,YAAmBR,MAAA,eAAA,CAAA,C;;;MAErBM,mBAAoE,QAAA,EAA7D,OAAKP,eAAEC,MAAA,EAAA,CAAE,CAAC,EAAC,SAAA,CAAA,EAAgB,GAAAW,gBAAA,QAAA,KAAO,IAAG,QAAGA,gBAAG,QAAA,QAAQ,GAAA,CAAA;MAC1DH,YAQYR,MAAA,SAAA,GAAA;OAPV,SAAQ;OACR,MAAK;OACJ,UAAU,QAAA,SAAW,QAAA;OACrB,cAAYA,MAAA,CAAA,CAAC,CAAA,kBAAA;OACb,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,CAAA;;OAEZ,SAAAS,cAAoB,CAApBD,YAAoBR,MAAA,gBAAA,CAAA,C;;;;KAGH,QAAA,YAAY,KAAA,SAAjCH,UAAA,GAAAM,YAAgEH,MAAA,aAAA,GAAA;;MAAzB,MAAK;MAAM,MAAM,KAAA;;KACtC,QAAA,YAAY,OAAA,SAA9BH,UAAA,GAAAM,YAIaH,MAAA,UAAA,GAAA;;MAJ0B,SAASA,MAAA,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;;;;;KAGhBY,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;E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AS,cAAoB,CAApBD,YAAoBR,MAAA,gBAAA,CAAA,C;;;;KAGH,QAAA,YAAY,KAAA,SAAjCH,UAAA,GAAAM,YAAgEH,MAAA,aAAA,GAAA;;MAAzB,MAAK;MAAM,MAAM,KAAA;;KACtC,QAAA,YAAY,OAAA,SAA9BH,UAAA,GAAAM,YAIaH,MAAA,UAAA,GAAA;;MAJ0B,SAASA,MAAA,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 +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 } from '@dou-ui/icons'\nimport { computed, nextTick, ref, useTemplateRef } from 'vue'\nimport { isComposing } from '../../utils/keyboard'\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 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 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 ?? (isUser.value ? 'hover' : 'always'))\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\nconst showActions = computed(\n () =>\n !busy.value &&\n (props.versions > 1 ||\n (props.copyable && !!text.value) ||\n (props.editable && isUser.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 ]\"\n :aria-busy=\"busy || undefined\"\n :aria-current=\"highlighted || undefined\"\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 v-if=\"showActions && !editing\" :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 <slot name=\"actions\" />\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":""}
package/dist/locale/en.js CHANGED
@@ -457,7 +457,11 @@ var en = {
457
457
  cancel: "Cancel",
458
458
  versions: "Reply versions",
459
459
  previousVersion: "Previous version",
460
- nextVersion: "Next version"
460
+ nextVersion: "Next version",
461
+ reactions: "Reactions",
462
+ reaction: "{emoji} {count}",
463
+ reactionWith: "{reaction}: {label}",
464
+ addReaction: "Add reaction"
461
465
  },
462
466
  findReplace: {
463
467
  label: "Find and replace",