@opentiny/tiny-robot 0.2.0-alpha.1 → 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 (56) hide show
  1. package/dist/action-group/index.type.d.ts +1 -0
  2. package/dist/bubble/index.d.ts +2 -2
  3. package/dist/bubble/index.type.d.ts +16 -18
  4. package/dist/feedback/index.vue.d.ts +2 -2
  5. package/dist/icon-button/index.type.d.ts +2 -3
  6. package/dist/icon-button/index.vue.d.ts +3 -3
  7. package/dist/node_modules/.pnpm/@vueuse_core@13.1.0_vue@3.5.13/node_modules/@vueuse/core/index.js +262 -142
  8. package/dist/node_modules/.pnpm/@vueuse_shared@13.1.0_vue@3.5.13/node_modules/@vueuse/shared/index.js +96 -39
  9. package/dist/packages/components/src/action-group/ActionGroup.vue.js +2 -2
  10. package/dist/packages/components/src/action-group/ActionGroup.vue2.js +96 -72
  11. package/dist/packages/components/src/bubble/Bubble.vue.js +7 -0
  12. package/dist/packages/components/src/bubble/Bubble.vue2.js +76 -0
  13. package/dist/packages/components/src/bubble/BubbleList.vue.js +7 -0
  14. package/dist/packages/components/src/bubble/BubbleList.vue2.js +50 -0
  15. package/dist/packages/components/src/bubble/index.js +2 -2
  16. package/dist/packages/components/src/container/index.vue.js +2 -2
  17. package/dist/packages/components/src/container/index.vue2.js +36 -36
  18. package/dist/packages/components/src/feedback/index.vue.js +2 -2
  19. package/dist/packages/components/src/feedback/index.vue2.js +72 -71
  20. package/dist/packages/components/src/icon-button/index.vue.js +2 -2
  21. package/dist/packages/components/src/icon-button/index.vue2.js +9 -27
  22. package/dist/packages/components/src/sender/components/TemplateEditor.vue.js +2 -2
  23. package/dist/packages/components/src/sender/components/TemplateEditor.vue2.js +137 -83
  24. package/dist/sender/index.vue.d.ts +2 -2
  25. package/dist/style.css +1 -1
  26. package/package.json +3 -3
  27. package/src/action-group/ActionGroup.vue +38 -23
  28. package/src/action-group/index.type.ts +1 -0
  29. package/src/bubble/{bubble.vue → Bubble.vue} +13 -97
  30. package/src/bubble/BubbleList.vue +55 -0
  31. package/src/bubble/index.ts +2 -2
  32. package/src/bubble/index.type.ts +7 -21
  33. package/src/container/index.vue +10 -35
  34. package/src/feedback/index.vue +14 -14
  35. package/src/icon-button/index.type.ts +2 -3
  36. package/src/icon-button/index.vue +16 -10
  37. package/src/sender/components/TemplateEditor.vue +301 -110
  38. package/dist/bubble/components/actions/copy.vue.d.ts +0 -10
  39. package/dist/bubble/components/actions/index.d.ts +0 -2
  40. package/dist/bubble/components/actions/refresh.vue.d.ts +0 -2
  41. package/dist/bubble/useScroll.d.ts +0 -4
  42. package/dist/packages/components/src/bubble/bubble-list.vue.js +0 -7
  43. package/dist/packages/components/src/bubble/bubble-list.vue2.js +0 -37
  44. package/dist/packages/components/src/bubble/bubble.vue.js +0 -7
  45. package/dist/packages/components/src/bubble/bubble.vue2.js +0 -118
  46. package/dist/packages/components/src/bubble/components/actions/copy.vue.js +0 -7
  47. package/dist/packages/components/src/bubble/components/actions/copy.vue2.js +0 -35
  48. package/dist/packages/components/src/bubble/components/actions/refresh.vue.js +0 -7
  49. package/dist/packages/components/src/bubble/components/actions/refresh.vue2.js +0 -16
  50. package/dist/packages/components/src/bubble/useScroll.js +0 -13
  51. package/src/bubble/bubble-list.vue +0 -42
  52. package/src/bubble/components/actions/copy.vue +0 -54
  53. package/src/bubble/components/actions/index.ts +0 -2
  54. package/src/bubble/components/actions/refresh.vue +0 -31
  55. package/src/bubble/useScroll.ts +0 -14
  56. /package/dist/bubble/{bubble-list.vue.d.ts → BubbleList.vue.d.ts} +0 -0
@@ -1,118 +0,0 @@
1
- import { defineComponent as g, useCssVars as B, useSlots as A, computed as c, createElementBlock as s, openBlock as o, normalizeClass as h, createCommentVNode as d, createElementVNode as a, createBlock as _, resolveDynamicComponent as f, renderSlot as i, toDisplayString as M, unref as S, Fragment as x, renderList as D, withDirectives as L, vShow as V } from "vue";
2
- import $ from "../../../../node_modules/.pnpm/markdown-it@14.1.0/node_modules/markdown-it/lib/index.js";
3
- import E from "./components/actions/copy.vue.js";
4
- import H from "./components/actions/refresh.vue.js";
5
- const I = {
6
- key: 0,
7
- class: "tr-bubble__avatar"
8
- }, N = { class: "tr-bubble__content-wrapper" }, T = {
9
- key: 1,
10
- class: /* @__PURE__ */ h(["tr-bubble__content"])
11
- }, W = { class: "tr-bubbule__body" }, z = ["innerHTML"], F = { key: 1 }, R = {
12
- key: 2,
13
- class: "tr-bubbule__aborted"
14
- }, j = {
15
- key: 0,
16
- class: "tr-bubbule__footer"
17
- }, q = { class: "tr-bubbule__footer-left" }, G = { class: "tr-bubbule__footer-actions" }, Q = /* @__PURE__ */ g({
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(v, { emit: y }) {
34
- B((n) => ({
35
- "8efd816c": e.maxWidth
36
- }));
37
- const e = v, l = y, k = A(), p = c(() => e.type === "markdown" ? $(e.mdConfig || {}).render(e.content) : e.content), b = c(() => e.placement === "start"), u = /* @__PURE__ */ new Map([
38
- [
39
- "copy",
40
- {
41
- name: "copy",
42
- vnode: E,
43
- show: !0
44
- }
45
- ],
46
- [
47
- "refresh",
48
- {
49
- name: "refresh",
50
- vnode: H,
51
- show: !0
52
- }
53
- ]
54
- ]), m = c(() => (e.actions || []).map((t) => typeof t == "string" ? u.get(t) : u.has(t.name) ? {
55
- ...u.get(t.name),
56
- ...t
57
- } : t).filter((t) => !!t)), w = (n, ...t) => {
58
- if (n === "copy") {
59
- l("copy", t[0]);
60
- return;
61
- }
62
- if (n === "refresh") {
63
- l("refresh");
64
- return;
65
- }
66
- l("action", n, ...t);
67
- };
68
- return (n, t) => (o(), s("div", {
69
- class: h([
70
- "tr-bubble",
71
- {
72
- "placement-start": b.value,
73
- "placement-end": !b.value
74
- }
75
- ])
76
- }, [
77
- e.avatar ? (o(), s("div", I, [
78
- (o(), _(f(e.avatar)))
79
- ])) : d("", !0),
80
- a("div", N, [
81
- e.loading ? i(n.$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", T, [
88
- a("div", W, [
89
- i(n.$slots, "default", {}, () => [
90
- e.type === "markdown" ? (o(), s("span", {
91
- key: 0,
92
- innerHTML: p.value
93
- }, null, 8, z)) : (o(), s("span", F, M(p.value), 1)),
94
- e.aborted ? (o(), s("span", R, "(用户停止)")) : d("", !0)
95
- ], !0)
96
- ]),
97
- S(k).footer || m.value.length > 0 ? (o(), s("div", j, [
98
- a("div", q, [
99
- i(n.$slots, "footer", {}, void 0, !0)
100
- ]),
101
- a("div", G, [
102
- (o(!0), s(x, null, D(m.value, (r) => L((o(), _(f(r.vnode), {
103
- key: r == null ? void 0 : r.name,
104
- bubbleItem: e,
105
- onClick: (C) => w(r.name, C)
106
- }, null, 8, ["onClick"])), [
107
- [V, typeof r.show == "function" ? r.show(e) : r.show]
108
- ])), 128))
109
- ])
110
- ])) : d("", !0)
111
- ]))
112
- ])
113
- ], 2));
114
- }
115
- });
116
- export {
117
- Q 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,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
- }