@opentiny/tiny-robot 0.2.0-alpha.0 → 0.2.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/action-group/ActionGroup.vue.d.ts +26 -0
  2. package/dist/action-group/ActionGroupItem.vue.d.ts +18 -0
  3. package/dist/action-group/index.d.ts +12 -0
  4. package/dist/action-group/index.type.d.ts +17 -0
  5. package/dist/bubble/index.d.ts +2 -2
  6. package/dist/bubble/index.type.d.ts +16 -18
  7. package/dist/feedback/components/SourceList.vue.d.ts +11 -0
  8. package/dist/feedback/components/index.d.ts +1 -0
  9. package/dist/feedback/index.d.ts +7 -0
  10. package/dist/feedback/index.type.d.ts +25 -0
  11. package/dist/feedback/index.vue.d.ts +13 -0
  12. package/dist/history/components/index.d.ts +2 -0
  13. package/dist/history/components/item-tag.vue.d.ts +5 -0
  14. package/dist/history/components/search-empty.vue.d.ts +7 -0
  15. package/dist/history/composables/index.d.ts +1 -0
  16. package/dist/history/composables/useEditItemTitle.d.ts +12 -0
  17. package/dist/history/index.d.ts +6 -0
  18. package/dist/history/index.type.d.ts +43 -0
  19. package/dist/history/index.vue.d.ts +2 -0
  20. package/dist/icon-button/index.d.ts +7 -0
  21. package/dist/icon-button/index.type.d.ts +6 -0
  22. package/dist/icon-button/index.vue.d.ts +6 -0
  23. package/dist/index.d.ts +10 -1
  24. package/dist/index.js +57 -27
  25. package/dist/node_modules/.pnpm/@opentiny_utils@3.22.0/node_modules/@opentiny/utils/dist/index.es.js +1335 -884
  26. package/dist/node_modules/.pnpm/@opentiny_vue-common@3.22.0/node_modules/@opentiny/vue-common/lib/index.js +660 -144
  27. package/dist/node_modules/.pnpm/@opentiny_vue-hooks@3.22.0/node_modules/@opentiny/vue-hooks/dist/src/vue-popper.js +85 -0
  28. package/dist/node_modules/.pnpm/@opentiny_vue-locale@3.22.0/node_modules/@opentiny/vue-locale/lib/index.js +1783 -0
  29. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.22.0/node_modules/@opentiny/vue-renderless/tooltip/index.js +77 -0
  30. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.22.0/node_modules/@opentiny/vue-renderless/tooltip/vue.js +90 -0
  31. package/dist/node_modules/.pnpm/@opentiny_vue-tooltip@3.22.0/node_modules/@opentiny/vue-tooltip/lib/index.js +176 -0
  32. package/dist/node_modules/.pnpm/@opentiny_vue-tooltip@3.22.0/node_modules/@opentiny/vue-tooltip/lib/pc.js +248 -0
  33. package/dist/node_modules/.pnpm/@vueuse_core@13.1.0_vue@3.5.13/node_modules/@vueuse/core/index.js +310 -0
  34. package/dist/node_modules/.pnpm/@vueuse_shared@13.1.0_vue@3.5.13/node_modules/@vueuse/shared/index.js +110 -0
  35. package/dist/packages/components/src/action-group/ActionGroup.vue.js +7 -0
  36. package/dist/packages/components/src/action-group/ActionGroup.vue2.js +121 -0
  37. package/dist/packages/components/src/action-group/ActionGroupItem.vue.js +14 -0
  38. package/dist/packages/components/src/action-group/ActionGroupItem.vue2.js +4 -0
  39. package/dist/packages/components/src/action-group/index.js +17 -0
  40. package/dist/packages/components/src/bubble/Bubble.vue.js +7 -0
  41. package/dist/packages/components/src/bubble/Bubble.vue2.js +76 -0
  42. package/dist/packages/components/src/bubble/BubbleList.vue.js +7 -0
  43. package/dist/packages/components/src/bubble/BubbleList.vue2.js +50 -0
  44. package/dist/packages/components/src/bubble/index.js +2 -2
  45. package/dist/packages/components/src/container/index.vue.js +2 -2
  46. package/dist/packages/components/src/container/index.vue2.js +36 -36
  47. package/dist/packages/components/src/feedback/components/SourceList.vue.js +7 -0
  48. package/dist/packages/components/src/feedback/components/SourceList.vue2.js +52 -0
  49. package/dist/packages/components/src/feedback/index.js +9 -0
  50. package/dist/packages/components/src/feedback/index.vue.js +7 -0
  51. package/dist/packages/components/src/feedback/index.vue2.js +143 -0
  52. package/dist/packages/components/src/history/components/item-tag.vue.js +7 -0
  53. package/dist/packages/components/src/history/components/item-tag.vue2.js +21 -0
  54. package/dist/packages/components/src/history/components/search-empty.vue.js +7 -0
  55. package/dist/packages/components/src/history/components/search-empty.vue2.js +20 -0
  56. package/dist/packages/components/src/history/composables/useEditItemTitle.js +43 -0
  57. package/dist/packages/components/src/history/index.js +11 -0
  58. package/dist/packages/components/src/history/index.vue.js +7 -0
  59. package/dist/packages/components/src/history/index.vue2.js +130 -0
  60. package/dist/packages/components/src/icon-button/index.js +9 -0
  61. package/dist/packages/components/src/icon-button/index.vue.js +7 -0
  62. package/dist/packages/components/src/icon-button/index.vue2.js +22 -0
  63. package/dist/packages/components/src/prompts/prompt.vue.js +2 -2
  64. package/dist/packages/components/src/prompts/prompt.vue2.js +17 -15
  65. package/dist/packages/components/src/question/components/HotQuestions.vue.js +23 -23
  66. package/dist/packages/components/src/question/index.vue.js +18 -18
  67. package/dist/packages/components/src/sender/components/TemplateEditor.vue.js +7 -0
  68. package/dist/packages/components/src/sender/components/TemplateEditor.vue2.js +175 -0
  69. package/dist/packages/components/src/sender/index.vue.js +149 -128
  70. package/dist/packages/components/src/suggestion/components/CategoryNav.vue.js +38 -0
  71. package/dist/packages/components/src/suggestion/components/CategoryNav.vue2.js +4 -0
  72. package/dist/packages/components/src/suggestion/components/SuggestionCapsule.vue.js +107 -0
  73. package/dist/packages/components/src/suggestion/components/SuggestionCapsule.vue2.js +4 -0
  74. package/dist/packages/components/src/suggestion/components/SuggestionPanel.vue.js +123 -0
  75. package/dist/packages/components/src/suggestion/components/SuggestionPanel.vue2.js +4 -0
  76. package/dist/packages/components/src/suggestion/composables/useKeyboardNavigation.js +45 -0
  77. package/dist/packages/components/src/suggestion/composables/useTriggerDetection.js +17 -0
  78. package/dist/packages/components/src/suggestion/index.js +9 -0
  79. package/dist/packages/components/src/suggestion/index.vue.js +179 -0
  80. package/dist/packages/components/src/suggestion/index.vue2.js +4 -0
  81. package/dist/packages/components/src/suggestion/utils/dom.js +18 -0
  82. package/dist/packages/svgs/dist/tiny-robot-svgs.js +306 -90
  83. package/dist/question/components/HotQuestions.vue.d.ts +2 -2
  84. package/dist/sender/components/TemplateEditor.vue.d.ts +18 -0
  85. package/dist/sender/index.type.d.ts +47 -0
  86. package/dist/sender/index.vue.d.ts +70 -5
  87. package/dist/style.css +1 -1
  88. package/dist/suggestion/components/CategoryNav.vue.d.ts +45 -0
  89. package/dist/suggestion/components/SuggestionCapsule.vue.d.ts +32 -0
  90. package/dist/suggestion/components/SuggestionPanel.vue.d.ts +84 -0
  91. package/dist/suggestion/composables/useKeyboardNavigation.d.ts +18 -0
  92. package/dist/suggestion/composables/useSuggestionFilter.d.ts +10 -0
  93. package/dist/suggestion/composables/useTriggerDetection.d.ts +11 -0
  94. package/dist/suggestion/index.d.ts +7 -0
  95. package/dist/suggestion/index.type.d.ts +94 -0
  96. package/dist/suggestion/index.vue.d.ts +343 -0
  97. package/dist/suggestion/utils/dom.d.ts +20 -0
  98. package/package.json +4 -3
  99. package/src/action-group/ActionGroup.vue +247 -0
  100. package/src/action-group/ActionGroupItem.vue +9 -0
  101. package/src/action-group/index.ts +25 -0
  102. package/src/action-group/index.type.ts +21 -0
  103. package/src/bubble/Bubble.vue +153 -0
  104. package/src/bubble/BubbleList.vue +55 -0
  105. package/src/bubble/index.ts +2 -2
  106. package/src/bubble/index.type.ts +7 -21
  107. package/src/container/index.vue +10 -36
  108. package/src/feedback/components/SourceList.vue +112 -0
  109. package/src/feedback/components/index.ts +1 -0
  110. package/src/feedback/index.ts +12 -0
  111. package/src/feedback/index.type.ts +27 -0
  112. package/src/feedback/index.vue +166 -0
  113. package/src/history/components/index.ts +2 -0
  114. package/src/history/components/item-tag.vue +49 -0
  115. package/src/history/components/search-empty.vue +38 -0
  116. package/src/history/composables/index.ts +1 -0
  117. package/src/history/composables/useEditItemTitle.ts +75 -0
  118. package/src/history/index.ts +12 -0
  119. package/src/history/index.type.ts +50 -0
  120. package/src/history/index.vue +292 -0
  121. package/src/icon-button/index.ts +12 -0
  122. package/src/icon-button/index.type.ts +7 -0
  123. package/src/icon-button/index.vue +58 -0
  124. package/src/index.ts +33 -1
  125. package/src/prompts/prompt.vue +7 -21
  126. package/src/question/components/HotQuestions.vue +1 -1
  127. package/src/question/index.less +9 -10
  128. package/src/sender/components/TemplateEditor.vue +465 -0
  129. package/src/sender/index.less +17 -7
  130. package/src/sender/index.type.ts +51 -0
  131. package/src/sender/index.vue +56 -8
  132. package/src/sender/vars.less +3 -3
  133. package/src/suggestion/components/CategoryNav.vue +38 -0
  134. package/src/suggestion/components/SuggestionCapsule.vue +183 -0
  135. package/src/suggestion/components/SuggestionPanel.vue +147 -0
  136. package/src/suggestion/composables/useKeyboardNavigation.ts +101 -0
  137. package/src/suggestion/composables/useSuggestionFilter.ts +34 -0
  138. package/src/suggestion/composables/useTriggerDetection.ts +46 -0
  139. package/src/suggestion/index.less +497 -0
  140. package/src/suggestion/index.ts +12 -0
  141. package/src/suggestion/index.type.ts +101 -0
  142. package/src/suggestion/index.vue +338 -0
  143. package/src/suggestion/utils/dom.ts +66 -0
  144. package/src/suggestion/vars.less +141 -0
  145. package/dist/bubble/components/actions/copy.vue.d.ts +0 -10
  146. package/dist/bubble/components/actions/index.d.ts +0 -2
  147. package/dist/bubble/components/actions/refresh.vue.d.ts +0 -2
  148. package/dist/bubble/useScroll.d.ts +0 -4
  149. package/dist/packages/components/src/bubble/bubble-list.vue.js +0 -7
  150. package/dist/packages/components/src/bubble/bubble-list.vue2.js +0 -37
  151. package/dist/packages/components/src/bubble/bubble.vue.js +0 -7
  152. package/dist/packages/components/src/bubble/bubble.vue2.js +0 -118
  153. package/dist/packages/components/src/bubble/components/actions/copy.vue.js +0 -7
  154. package/dist/packages/components/src/bubble/components/actions/copy.vue2.js +0 -35
  155. package/dist/packages/components/src/bubble/components/actions/refresh.vue.js +0 -7
  156. package/dist/packages/components/src/bubble/components/actions/refresh.vue2.js +0 -16
  157. package/dist/packages/components/src/bubble/useScroll.js +0 -13
  158. package/src/bubble/bubble-list.vue +0 -42
  159. package/src/bubble/bubble.vue +0 -247
  160. package/src/bubble/components/actions/copy.vue +0 -54
  161. package/src/bubble/components/actions/index.ts +0 -2
  162. package/src/bubble/components/actions/refresh.vue +0 -31
  163. package/src/bubble/useScroll.ts +0 -14
  164. /package/dist/bubble/{bubble-list.vue.d.ts → BubbleList.vue.d.ts} +0 -0
@@ -1,118 +0,0 @@
1
- import { defineComponent as f, useCssVars as B, useSlots as M, computed as l, createElementBlock as s, openBlock as o, normalizeClass as y, createCommentVNode as c, createElementVNode as a, createBlock as v, resolveDynamicComponent as h, renderSlot as d, toDisplayString as S, unref as x, Fragment as D, renderList as L, withDirectives as V, vShow as $ } from "vue";
2
- import E from "../../../../node_modules/.pnpm/markdown-it@14.1.0/node_modules/markdown-it/lib/index.js";
3
- import H from "./components/actions/copy.vue.js";
4
- import I from "./components/actions/refresh.vue.js";
5
- const N = {
6
- key: 0,
7
- class: "tr-bubble__avatar"
8
- }, T = { class: "tr-bubble__content-wrapper" }, W = {
9
- key: 1,
10
- class: /* @__PURE__ */ y(["tr-bubble__content"])
11
- }, z = { class: "tr-bubbule__body" }, F = ["innerHTML"], R = { key: 1 }, j = {
12
- key: 2,
13
- class: "tr-bubbule__aborted"
14
- }, q = {
15
- key: 0,
16
- class: "tr-bubbule__footer"
17
- }, G = { class: "tr-bubbule__footer-left" }, J = { class: "tr-bubbule__footer-actions" }, U = /* @__PURE__ */ f({
18
- __name: "bubble",
19
- props: {
20
- content: { default: "" },
21
- id: {},
22
- placement: { default: "start" },
23
- avatar: {},
24
- role: {},
25
- type: { default: "text" },
26
- loading: { type: Boolean },
27
- aborted: { type: Boolean },
28
- mdConfig: {},
29
- actions: {},
30
- maxWidth: { default: "80%" }
31
- },
32
- emits: ["copy", "refresh", "action"],
33
- setup(k, { emit: C }) {
34
- B((r) => ({
35
- "088abd95": e.maxWidth
36
- }));
37
- const e = k, u = C, w = M(), p = l(() => e.type === "markdown" ? E(e.mdConfig || {}).render(e.content) : e.content), b = l(() => e.placement === "start"), m = l(() => e.avatar ? f(() => () => e.avatar) : null), i = /* @__PURE__ */ new Map([
38
- [
39
- "copy",
40
- {
41
- name: "copy",
42
- vnode: H,
43
- show: !0
44
- }
45
- ],
46
- [
47
- "refresh",
48
- {
49
- name: "refresh",
50
- vnode: I,
51
- show: !0
52
- }
53
- ]
54
- ]), _ = l(() => (e.actions || []).map((t) => typeof t == "string" ? i.get(t) : i.has(t.name) ? {
55
- ...i.get(t.name),
56
- ...t
57
- } : t).filter((t) => !!t)), g = (r, ...t) => {
58
- if (r === "copy") {
59
- u("copy", t[0]);
60
- return;
61
- }
62
- if (r === "refresh") {
63
- u("refresh");
64
- return;
65
- }
66
- u("action", r, ...t);
67
- };
68
- return (r, t) => (o(), s("div", {
69
- class: y([
70
- "tr-bubble",
71
- {
72
- "placement-start": b.value,
73
- "placement-end": !b.value
74
- }
75
- ])
76
- }, [
77
- m.value ? (o(), s("div", N, [
78
- (o(), v(h(m.value)))
79
- ])) : c("", !0),
80
- a("div", T, [
81
- e.loading ? d(r.$slots, "loading", { key: 0 }, () => [
82
- t[0] || (t[0] = a("div", { class: "tr-bubble__loading" }, [
83
- a("span"),
84
- a("span"),
85
- a("span")
86
- ], -1))
87
- ], !0) : (o(), s("div", W, [
88
- a("div", z, [
89
- d(r.$slots, "default", {}, () => [
90
- e.type === "markdown" ? (o(), s("span", {
91
- key: 0,
92
- innerHTML: p.value
93
- }, null, 8, F)) : (o(), s("span", R, S(p.value), 1)),
94
- e.aborted ? (o(), s("span", j, "(用户停止)")) : c("", !0)
95
- ], !0)
96
- ]),
97
- x(w).footer || _.value.length > 0 ? (o(), s("div", q, [
98
- a("div", G, [
99
- d(r.$slots, "footer", {}, void 0, !0)
100
- ]),
101
- a("div", J, [
102
- (o(!0), s(D, null, L(_.value, (n) => V((o(), v(h(n.vnode), {
103
- key: n == null ? void 0 : n.name,
104
- bubbleItem: e,
105
- onClick: (A) => g(n.name, A)
106
- }, null, 8, ["onClick"])), [
107
- [$, typeof n.show == "function" ? n.show(e) : n.show]
108
- ])), 128))
109
- ])
110
- ])) : c("", !0)
111
- ]))
112
- ])
113
- ], 2));
114
- }
115
- });
116
- export {
117
- U as default
118
- };
@@ -1,7 +0,0 @@
1
- import o from "./copy.vue2.js";
2
- /* empty css */
3
- import t from "../../../../../../_virtual/_plugin-vue_export-helper.js";
4
- const f = /* @__PURE__ */ t(o, [["__scopeId", "data-v-c674248f"]]);
5
- export {
6
- f as default
7
- };
@@ -1,35 +0,0 @@
1
- import { defineComponent as i, createElementBlock as l, openBlock as s, createVNode as m, unref as u } from "vue";
2
- import { IconCopy as b } from "../../../../../svgs/dist/tiny-robot-svgs.js";
3
- const d = /* @__PURE__ */ i({
4
- __name: "copy",
5
- props: {
6
- bubbleItem: {}
7
- },
8
- emits: ["click"],
9
- setup(e, { emit: c }) {
10
- const n = c;
11
- async function o(t) {
12
- try {
13
- return await navigator.clipboard.writeText(t), !0;
14
- } catch {
15
- return !1;
16
- }
17
- }
18
- const r = async () => {
19
- const t = e.bubbleItem.content ? await o(e.bubbleItem.content) : !1;
20
- n("click", t);
21
- };
22
- return (t, a) => (s(), l("button", {
23
- class: "icon-btn",
24
- onClick: r
25
- }, [
26
- m(u(b), {
27
- width: "16px",
28
- height: "16px"
29
- })
30
- ]));
31
- }
32
- });
33
- export {
34
- d as default
35
- };
@@ -1,7 +0,0 @@
1
- import o from "./refresh.vue2.js";
2
- /* empty css */
3
- import t from "../../../../../../_virtual/_plugin-vue_export-helper.js";
4
- const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-9f9f9745"]]);
5
- export {
6
- m as default
7
- };
@@ -1,16 +0,0 @@
1
- import { defineComponent as e, createElementBlock as t, openBlock as o, createVNode as n, unref as r } from "vue";
2
- import { IconRefresh as c } from "../../../../../svgs/dist/tiny-robot-svgs.js";
3
- const s = { class: "icon-btn" }, m = /* @__PURE__ */ e({
4
- __name: "refresh",
5
- setup(p) {
6
- return (_, a) => (o(), t("button", s, [
7
- n(r(c), {
8
- width: "16px",
9
- height: "16px"
10
- })
11
- ]));
12
- }
13
- });
14
- export {
15
- m as default
16
- };
@@ -1,13 +0,0 @@
1
- import { nextTick as l } from "vue";
2
- const s = (o) => ({ scrollToBottom: () => {
3
- l(() => {
4
- var t;
5
- (t = o.value) == null || t.scrollTo({
6
- top: o.value.scrollHeight,
7
- behavior: "smooth"
8
- });
9
- });
10
- } });
11
- export {
12
- s as useElementScroll
13
- };
@@ -1,42 +0,0 @@
1
- <script setup lang="ts">
2
- import { computed, ref, watch } from 'vue'
3
- import Bubble from './bubble.vue'
4
- import { BubbleListProps, BubbleProps } from './index.type'
5
- import { useElementScroll } from './useScroll'
6
-
7
- const props = withDefaults(defineProps<BubbleListProps>(), {})
8
-
9
- const scrollContainer = ref<HTMLDivElement>()
10
- const { scrollToBottom } = useElementScroll(scrollContainer)
11
-
12
- const lastBubble = computed(() => props.items.at(-1))
13
-
14
- watch([() => props.items.length, () => lastBubble.value?.content], () => {
15
- if (!props.autoScroll) {
16
- return
17
- }
18
-
19
- scrollToBottom()
20
- })
21
-
22
- const getItemProps = (item: BubbleProps): BubbleProps => {
23
- const defaultConfig = item.role ? props.roles?.[item.role] || {} : {}
24
- return { ...defaultConfig, ...item }
25
- }
26
- </script>
27
-
28
- <template>
29
- <div class="tr-bubble-list" ref="scrollContainer">
30
- <Bubble v-for="(item, index) in props.items" :key="item.id || index" v-bind="getItemProps(item)"></Bubble>
31
- </div>
32
- </template>
33
-
34
- <style lang="less" scoped>
35
- .tr-bubble-list {
36
- display: flex;
37
- flex-direction: column;
38
- gap: 16px;
39
- overflow-y: auto;
40
- padding: 16px;
41
- }
42
- </style>
@@ -1,247 +0,0 @@
1
- <script setup lang="ts">
2
- import markdownit from 'markdown-it'
3
- import { computed, defineComponent, useSlots } from 'vue'
4
- import { BubbleActionOptions, BubbleEvents, BubbleProps, BubbleSlots } from './index.type'
5
- import { CopyAction, RefreshAction } from './components/actions'
6
-
7
- const props = withDefaults(defineProps<BubbleProps>(), {
8
- content: '',
9
- placement: 'start',
10
- type: 'text',
11
- maxWidth: '80%',
12
- })
13
-
14
- const emit = defineEmits<BubbleEvents>()
15
-
16
- defineSlots<BubbleSlots>()
17
-
18
- const slots = useSlots()
19
-
20
- const bubbleContent = computed(() => {
21
- if (props.type === 'markdown') {
22
- return markdownit(props.mdConfig || {}).render(props.content)
23
- }
24
- return props.content
25
- })
26
-
27
- const placementStart = computed(() => props.placement === 'start')
28
-
29
- const AvatarComp = computed(() => {
30
- if (!props.avatar) {
31
- return null
32
- }
33
-
34
- return defineComponent(() => {
35
- return () => props.avatar
36
- })
37
- })
38
-
39
- const defaultActionsMap = new Map<string, BubbleActionOptions>([
40
- [
41
- 'copy',
42
- {
43
- name: 'copy',
44
- vnode: CopyAction,
45
- show: true,
46
- },
47
- ],
48
- [
49
- 'refresh',
50
- {
51
- name: 'refresh',
52
- vnode: RefreshAction,
53
- show: true,
54
- },
55
- ],
56
- ])
57
-
58
- const computedActions = computed(() => {
59
- const actions = (props.actions || []).map((action) => {
60
- if (typeof action === 'string') {
61
- return defaultActionsMap.get(action)
62
- }
63
-
64
- if (defaultActionsMap.has(action.name)) {
65
- return {
66
- ...defaultActionsMap.get(action.name),
67
- ...action,
68
- }
69
- }
70
-
71
- return action
72
- })
73
-
74
- return actions.filter((action): action is BubbleActionOptions => Boolean(action))
75
- })
76
-
77
- const handleActionClick = (name: string, ...args: unknown[]) => {
78
- if (name === 'copy') {
79
- emit('copy', args[0] as boolean)
80
- return
81
- }
82
-
83
- if (name === 'refresh') {
84
- emit('refresh')
85
- return
86
- }
87
-
88
- emit('action', name, ...args)
89
- }
90
- </script>
91
-
92
- <template>
93
- <div
94
- :class="[
95
- 'tr-bubble',
96
- {
97
- 'placement-start': placementStart,
98
- 'placement-end': !placementStart,
99
- },
100
- ]"
101
- >
102
- <div v-if="AvatarComp" class="tr-bubble__avatar">
103
- <component :is="AvatarComp"></component>
104
- </div>
105
- <div class="tr-bubble__content-wrapper">
106
- <slot v-if="props.loading" name="loading">
107
- <div class="tr-bubble__loading">
108
- <span></span>
109
- <span></span>
110
- <span></span>
111
- </div>
112
- </slot>
113
- <div v-else :class="['tr-bubble__content']">
114
- <div class="tr-bubbule__body">
115
- <slot>
116
- <span v-if="props.type === 'markdown'" v-html="bubbleContent"></span>
117
- <span v-else>{{ bubbleContent }}</span>
118
- <span v-if="props.aborted" class="tr-bubbule__aborted">(用户停止)</span>
119
- </slot>
120
- </div>
121
- <div v-if="slots.footer || computedActions.length > 0" class="tr-bubbule__footer">
122
- <div class="tr-bubbule__footer-left">
123
- <slot name="footer"></slot>
124
- </div>
125
- <div class="tr-bubbule__footer-actions">
126
- <template v-for="action in computedActions" :key="action?.name">
127
- <component
128
- :is="action.vnode"
129
- v-show="typeof action.show === 'function' ? action.show(props) : action.show"
130
- :bubbleItem="props"
131
- @click="handleActionClick(action.name, $event)"
132
- ></component>
133
- </template>
134
- </div>
135
- </div>
136
- </div>
137
- </div>
138
- </div>
139
- </template>
140
-
141
- <style lang="less" scoped>
142
- .tr-bubble {
143
- display: flex;
144
- gap: 16px;
145
- max-width: v-bind('props.maxWidth');
146
-
147
- &.placement-start {
148
- flex-direction: row;
149
- }
150
-
151
- &.placement-end {
152
- flex-direction: row-reverse;
153
- margin-left: auto;
154
- }
155
- }
156
-
157
- .tr-bubble__avatar {
158
- width: 40px;
159
- height: 40px;
160
- flex-shrink: 0;
161
- display: flex;
162
- align-items: center;
163
- justify-content: center;
164
- }
165
-
166
- .tr-bubble__loading {
167
- display: flex;
168
- align-items: center;
169
- justify-content: center;
170
- padding: 8px 0;
171
-
172
- span {
173
- height: 8px;
174
- width: 8px;
175
- margin: 0 2px;
176
- background-color: #bbb;
177
- border-radius: 50%;
178
- display: inline-block;
179
- animation: typing 1.4s infinite ease-in-out both;
180
-
181
- &:nth-child(1) {
182
- animation-delay: 0s;
183
- }
184
-
185
- &:nth-child(2) {
186
- animation-delay: 0.2s;
187
- }
188
-
189
- &:nth-child(3) {
190
- animation-delay: 0.4s;
191
- }
192
- }
193
-
194
- @keyframes typing {
195
- 0%,
196
- 80%,
197
- 100% {
198
- transform: scale(0);
199
- }
200
- 40% {
201
- transform: scale(1);
202
- }
203
- }
204
- }
205
-
206
- .tr-bubble__content {
207
- background-color: white;
208
- padding: 16px 24px;
209
- border-radius: 24px;
210
- box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.02);
211
-
212
- .tr-bubbule__body {
213
- color: rgb(25, 25, 25);
214
- font-size: 16px;
215
- line-height: 26px;
216
- }
217
-
218
- .tr-bubbule__aborted {
219
- color: rgb(128, 128, 128);
220
- font-size: 14px;
221
- }
222
-
223
- .tr-bubbule__footer {
224
- display: flex;
225
- gap: 12px;
226
-
227
- .tr-bubbule__footer-left {
228
- flex: 1;
229
- }
230
-
231
- .tr-bubbule__footer-actions {
232
- display: flex;
233
- flex-shrink: 0;
234
- gap: 4px;
235
- margin-top: 12px;
236
-
237
- & > * {
238
- display: flex;
239
- align-items: center;
240
- justify-content: center;
241
- width: 24px;
242
- height: 24px;
243
- }
244
- }
245
- }
246
- }
247
- </style>
@@ -1,54 +0,0 @@
1
- <script setup lang="ts">
2
- import { BubbleProps } from '../../index.type'
3
- import { IconCopy } from '@opentiny/tiny-robot-svgs'
4
-
5
- const { bubbleItem } = defineProps<{ bubbleItem: BubbleProps }>()
6
-
7
- const emit = defineEmits(['click'])
8
-
9
- async function copyToClipboard(text: string) {
10
- try {
11
- await navigator.clipboard.writeText(text)
12
- return true
13
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
- } catch (err: unknown) {
15
- return false
16
- }
17
- }
18
-
19
- const handleClick = async () => {
20
- const result = bubbleItem.content ? await copyToClipboard(bubbleItem.content) : false
21
-
22
- emit('click', result)
23
- }
24
- </script>
25
-
26
- <template>
27
- <button class="icon-btn" @click="handleClick">
28
- <IconCopy width="16px" height="16px" />
29
- </button>
30
- </template>
31
-
32
- <style lang="less" scoped>
33
- button.icon-btn {
34
- width: 28px;
35
- height: 28px;
36
- display: inline-flex;
37
- align-items: center;
38
- justify-content: center;
39
- border: none;
40
- border-radius: 8px;
41
- cursor: pointer;
42
- padding: 0;
43
- transition: background-color 0.3s;
44
- background-color: white;
45
-
46
- &:hover {
47
- background-color: rgba(0, 0, 0, 0.04);
48
- }
49
-
50
- &:active {
51
- background-color: rgba(0, 0, 0, 0.15);
52
- }
53
- }
54
- </style>
@@ -1,2 +0,0 @@
1
- export { default as CopyAction } from './copy.vue'
2
- export { default as RefreshAction } from './refresh.vue'
@@ -1,31 +0,0 @@
1
- <template>
2
- <button class="icon-btn"><IconRefresh width="16px" height="16px" /></button>
3
- </template>
4
-
5
- <script setup lang="ts">
6
- import { IconRefresh } from '@opentiny/tiny-robot-svgs'
7
- </script>
8
-
9
- <style lang="less" scoped>
10
- button.icon-btn {
11
- width: 28px;
12
- height: 28px;
13
- display: inline-flex;
14
- align-items: center;
15
- justify-content: center;
16
- border: none;
17
- border-radius: 8px;
18
- cursor: pointer;
19
- padding: 0;
20
- transition: background-color 0.3s;
21
- background-color: white;
22
-
23
- &:hover {
24
- background-color: rgba(0, 0, 0, 0.04);
25
- }
26
-
27
- &:active {
28
- background-color: rgba(0, 0, 0, 0.15);
29
- }
30
- }
31
- </style>
@@ -1,14 +0,0 @@
1
- import { nextTick, Ref } from 'vue'
2
-
3
- export const useElementScroll = (elemRef: Ref<HTMLElement | null | undefined>) => {
4
- const scrollToBottom = () => {
5
- nextTick(() => {
6
- elemRef.value?.scrollTo({
7
- top: elemRef.value.scrollHeight,
8
- behavior: 'smooth',
9
- })
10
- })
11
- }
12
-
13
- return { scrollToBottom }
14
- }