@opentiny/tiny-robot 0.3.1-alpha.3 → 0.3.1-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index2.js CHANGED
@@ -1,301 +1,199 @@
1
- import { ref as _, onMounted as ne, onBeforeUnmount as oe, defineComponent as P, createElementBlock as a, openBlock as r, createElementVNode as w, createVNode as $, unref as n, toDisplayString as B, mergeModels as W, useModel as j, computed as I, normalizeStyle as ie, Fragment as S, renderList as V, createBlock as H, resolveDynamicComponent as Y, nextTick as se, normalizeClass as U, withDirectives as q, createCommentVNode as G, renderSlot as A, withKeys as F, withModifiers as J, isRef as le, vModelText as re, vShow as ae } from "vue";
2
- import { IconEmptySearch as ue, IconEditPen as ce, IconDelete as de, IconCheck as me, IconClose as fe, IconMenu2 as pe } from "@opentiny/tiny-robot-svgs";
3
- import { _ as z } from "./_plugin-vue_export-helper.js";
4
- import { o as Z, a as ve, d as ge, c as ye } from "./index3.js";
5
- import { t as O } from "./utils.js";
6
- const D = _(!1);
7
- let T = 0, b;
8
- function _e() {
9
- const s = window.matchMedia("(hover: none) and (pointer: coarse)"), m = () => {
10
- D.value = s.matches;
11
- };
12
- m(), s.addEventListener("change", m);
13
- const t = (c) => {
14
- D.value = c.pointerType !== "mouse";
15
- };
16
- return window.addEventListener("pointerdown", t, !0), () => {
17
- s.removeEventListener("change", m), window.removeEventListener("pointerdown", t, !0);
18
- };
1
+ import { inject as E, defineComponent as h, computed as p, createBlock as m, createElementBlock as d, openBlock as i, unref as o, withCtx as x, createElementVNode as f, normalizeClass as b, renderSlot as $, resolveDynamicComponent as T, normalizeStyle as B, createVNode as _, createCommentVNode as k, toDisplayString as I, Transition as P } from "vue";
2
+ import { _ as g } from "./_plugin-vue_export-helper.js";
3
+ import { IconSend as A, IconStop as N, IconClear as F } from "@opentiny/tiny-robot-svgs";
4
+ import { TinyTooltip as D } from "@opentiny/vue";
5
+ const L = Symbol("chat-input-context");
6
+ function w() {
7
+ const s = E(L);
8
+ if (!s)
9
+ throw new Error("useChatInputContext must be used within ChatInput component");
10
+ return s;
19
11
  }
20
- function he() {
21
- b == null || b(), b = void 0;
12
+ function S(s) {
13
+ if (s)
14
+ return typeof s == "string" ? () => s : s;
22
15
  }
23
- function Ce() {
24
- return typeof window > "u" ? {
25
- isTouchDevice: D
26
- } : (ne(() => {
27
- T++, T === 1 && (b = _e());
28
- }), oe(() => {
29
- T = Math.max(0, T - 1), T === 0 && he();
30
- }), {
31
- isTouchDevice: D
32
- });
33
- }
34
- const ke = { class: "tr-history__empty" }, Le = { class: "tr-history__empty-icon" }, Ee = { class: "tr-history__empty-text" }, we = /* @__PURE__ */ P({
35
- __name: "Empty",
16
+ const R = ["disabled"], V = ["disabled"], W = /* @__PURE__ */ h({
17
+ __name: "index",
36
18
  props: {
37
- text: { default: "暂无内容" }
19
+ icon: {},
20
+ disabled: { type: Boolean, default: !1 },
21
+ active: { type: Boolean, default: !1 },
22
+ tooltip: {},
23
+ tooltipPlacement: { default: "top" },
24
+ size: { default: 32 }
38
25
  },
39
26
  setup(s) {
40
- const m = s;
41
- return (t, c) => (r(), a("div", ke, [
42
- w("span", Le, [
43
- $(n(ue))
27
+ const t = s, a = p(() => S(t.tooltip)), l = p(() => ({ fontSize: typeof t.size == "number" ? `${t.size}px` : t.size }));
28
+ return (r, c) => t.tooltip ? (i(), m(o(D), {
29
+ key: 0,
30
+ "render-content": a.value,
31
+ placement: t.tooltipPlacement,
32
+ effect: "light",
33
+ "visible-arrow": !1,
34
+ "popper-class": "tr-action-button-tooltip-popper"
35
+ }, {
36
+ default: x(() => [
37
+ f("button", {
38
+ class: b(["tr-action-button", { active: t.active }]),
39
+ disabled: t.disabled,
40
+ onFocusCapture: c[0] || (c[0] = (u) => u.stopPropagation())
41
+ }, [
42
+ $(r.$slots, "icon", {}, () => [
43
+ (i(), m(T(t.icon), {
44
+ style: B(l.value)
45
+ }, null, 8, ["style"]))
46
+ ], !0)
47
+ ], 42, R)
44
48
  ]),
45
- w("span", Ee, B(m.text), 1)
46
- ]));
47
- }
48
- }), Re = /* @__PURE__ */ z(we, [["__scopeId", "data-v-d0340c39"]]), Ie = ["onClick"], Q = 4, xe = /* @__PURE__ */ P({
49
- __name: "MenuList",
50
- props: /* @__PURE__ */ W({
51
- items: {},
52
- menuListGap: { default: 8 }
53
- }, {
54
- trigger: { default: null },
55
- triggerModifiers: {},
56
- data: { default: null },
57
- dataModifiers: {}
58
- }),
59
- emits: /* @__PURE__ */ W(["item-click"], ["update:trigger", "update:data"]),
60
- setup(s, { emit: m }) {
61
- const t = j(s, "trigger"), c = j(s, "data"), h = s, C = m, E = _(null);
62
- Z(
63
- E,
64
- () => {
65
- t.value = null, c.value = null;
66
- },
67
- {
68
- ignore: [t]
69
- }
70
- );
71
- const { top: p, bottom: x, left: y } = ve(t), { width: M, height: k } = ge(E, void 0, { box: "border-box" }), { height: R } = ye(), o = I(() => {
72
- const L = {
73
- left: `min(${O(y.value)}, calc(100% - ${O(M.value + Q)}))`
74
- }, g = x.value + h.menuListGap;
75
- return g + k.value + Q > R.value ? L.bottom = `calc(100% - ${O(p.value - h.menuListGap)})` : L.top = O(g), L;
76
- }), v = (L) => {
77
- C("item-click", L), t.value = null, c.value = null;
78
- };
79
- return (L, g) => (r(), a("ul", {
80
- class: "tr-history__menu-list",
81
- ref_key: "menuRef",
82
- ref: E,
83
- style: ie(o.value)
49
+ _: 3
50
+ }, 8, ["render-content", "placement"])) : (i(), d("button", {
51
+ key: 1,
52
+ class: b(["tr-action-button", { active: t.active }]),
53
+ disabled: t.disabled
84
54
  }, [
85
- (r(!0), a(S, null, V(h.items, (u) => (r(), a("li", {
86
- class: "tr-history__menu-list__item",
87
- key: u.id,
88
- onClick: (K) => v(u)
89
- }, [
90
- (r(), H(Y(u.icon))),
91
- w("span", null, B(u.text), 1)
92
- ], 8, Ie))), 128))
93
- ], 4));
55
+ $(r.$slots, "icon", {}, () => [
56
+ (i(), m(T(t.icon), {
57
+ style: B(l.value)
58
+ }, null, 8, ["style"]))
59
+ ], !0)
60
+ ], 10, V));
94
61
  }
95
- }), Me = /* @__PURE__ */ z(xe, [["__scopeId", "data-v-89fdb41c"]]), Te = ({
96
- renameControlOnClickOutside: s,
97
- onItemTitleChange: m
98
- }) => {
99
- const t = _(void 0), c = _(null), h = I(() => {
100
- var o;
101
- return (o = c.value) == null ? void 0 : o.at(0);
102
- }), C = _(null), E = I(() => {
103
- var o;
104
- return (o = C.value) == null ? void 0 : o.at(0);
105
- }), p = _(null), x = I(() => {
106
- var o;
107
- return (o = p.value) == null ? void 0 : o.at(0);
108
- }), y = _(""), M = (o) => {
109
- t.value = o, y.value = o.title, se(() => {
110
- const v = h.value;
111
- v && (v.focus(), v.select());
112
- });
113
- }, k = () => {
114
- t.value = void 0, y.value = "";
115
- }, R = () => {
116
- t.value && m(y.value, t.value), t.value = void 0, y.value = "";
117
- };
118
- return (s === "confirm" || s === "cancel") && Z(
119
- h,
120
- () => {
121
- s === "confirm" ? R() : k();
122
- },
123
- { ignore: [E, x] }
124
- ), {
125
- editingItem: t,
126
- editorRefList: c,
127
- editorConfirmRefList: C,
128
- editorCancelRefList: p,
129
- editorValue: y,
130
- handleEdit: M,
131
- handleEditCancel: k,
132
- handleEditConfirm: R
133
- };
134
- }, X = Symbol("NO_GROUP"), $e = {
62
+ }), O = /* @__PURE__ */ g(W, [["__scopeId", "data-v-13f08153"]]), j = {
135
63
  key: 0,
136
- class: "tr-history__group-title"
137
- }, be = { class: "tr-history__group-items" }, Ge = ["onClick"], Oe = ["title"], Se = ["onClick"], Be = /* @__PURE__ */ P({
64
+ class: "tr-chat-input-submit-button__cancel-text"
65
+ }, H = /* @__PURE__ */ h({
138
66
  __name: "index",
139
- props: {
140
- data: {},
141
- selected: {},
142
- showRenameControls: { type: Boolean, default: !1 },
143
- renameControlOnClickOutside: { default: "confirm" },
144
- menuItems: { default: () => [
145
- { id: "rename", text: "重命名", icon: ce },
146
- { id: "delete", text: "删除", icon: de }
147
- ] },
148
- menuListGap: { default: 8 }
149
- },
150
- emits: ["item-click", "item-title-change", "item-action"],
151
- setup(s, { emit: m }) {
152
- const t = s, c = m, h = (i) => {
153
- var f;
154
- const e = typeof ((f = i[0]) == null ? void 0 : f.group);
155
- return e === "string" || e === "symbol";
156
- }, C = I(() => {
157
- const i = t.data;
158
- return h(i) ? i : [{ group: X, items: i }];
159
- }), E = I(() => C.value.length === 0 || C.value.every((i) => i.items.length === 0)), {
160
- editingItem: p,
161
- editorRefList: x,
162
- editorConfirmRefList: y,
163
- editorCancelRefList: M,
164
- editorValue: k,
165
- handleEdit: R,
166
- handleEditCancel: o,
167
- handleEditConfirm: v
168
- } = Te({
169
- renameControlOnClickOutside: t.renameControlOnClickOutside,
170
- onItemTitleChange: (i, e) => {
171
- c("item-title-change", i, e);
172
- }
173
- }), { isTouchDevice: L } = Ce(), g = _(null), u = _(null), K = (i, e) => {
174
- if (i.currentTarget instanceof HTMLButtonElement) {
175
- if (u.value === e) {
176
- g.value = null, u.value = null;
177
- return;
178
- }
179
- g.value = i.currentTarget, u.value = e;
180
- } else
181
- g.value = null, u.value = null;
182
- }, ee = (i) => {
183
- const e = u.value;
184
- e && (i.id === "rename" && R(e), c("item-action", i, e));
67
+ setup(s) {
68
+ const { canSubmit: t, loading: a, defaultActions: l, submit: r, cancel: c, stopText: u } = w(), v = p(() => {
69
+ var e, n;
70
+ return (n = (e = l.value) == null ? void 0 : e.submit) != null && n.disabled ? !0 : !t.value && !a.value;
71
+ }), y = p(() => {
72
+ var e, n;
73
+ return S((n = (e = l.value) == null ? void 0 : e.submit) == null ? void 0 : n.tooltip);
74
+ }), z = p(() => {
75
+ var e, n;
76
+ return ((n = (e = l.value) == null ? void 0 : e.submit) == null ? void 0 : n.tooltipPlacement) ?? "top";
77
+ }), C = () => {
78
+ a.value ? c() : r();
185
79
  };
186
- return (i, e) => (r(), a("div", {
187
- class: U(["tr-history", { "touch-device": n(L) }])
188
- }, [
189
- E.value ? (r(), H(Re, { key: 1 })) : (r(), a(S, { key: 0 }, [
190
- (r(!0), a(S, null, V(C.value, (f) => (r(), a("div", {
191
- class: "tr-history__group",
192
- key: f.group
80
+ return (e, n) => y.value && !o(a) ? (i(), m(o(D), {
81
+ key: 0,
82
+ "render-content": y.value,
83
+ placement: z.value,
84
+ effect: "light",
85
+ "visible-arrow": !1,
86
+ "popper-class": "tr-submit-button-tooltip-popper"
87
+ }, {
88
+ default: x(() => [
89
+ f("div", {
90
+ class: b([
91
+ "tr-chat-input-submit-button",
92
+ {
93
+ "is-disabled": v.value,
94
+ "is-loading": o(a)
95
+ }
96
+ ]),
97
+ onClick: C
193
98
  }, [
194
- f.group !== n(X) ? (r(), a("div", $e, B(f.group), 1)) : G("", !0),
195
- w("div", be, [
196
- (r(!0), a(S, null, V(f.items, (l, te) => (r(), a("div", {
197
- class: U(["tr-history__item", {
198
- selected: l.id && l.id === t.selected,
199
- editing: n(p) === l,
200
- active: u.value === l
201
- }]),
202
- key: l.id || te,
203
- onClick: (d) => c("item-click", l)
204
- }, [
205
- A(i.$slots, "item-prefix", { item: l }, void 0, !0),
206
- l.icon ? (r(), H(Y(l.icon), { key: 0 })) : G("", !0),
207
- n(p) === l ? q((r(), a("input", {
208
- key: 1,
209
- class: "tr-history__item-editor",
210
- type: "text",
211
- onClick: e[0] || (e[0] = J(() => {
212
- }, ["stop"])),
213
- ref_for: !0,
214
- ref_key: "editorRefList",
215
- ref: x,
216
- "onUpdate:modelValue": e[1] || (e[1] = (d) => le(k) ? k.value = d : null),
217
- onKeydown: [
218
- e[2] || (e[2] = F(
219
- //@ts-ignore
220
- (...d) => n(v) && n(v)(...d),
221
- ["enter"]
222
- )),
223
- e[3] || (e[3] = F(
224
- //@ts-ignore
225
- (...d) => n(o) && n(o)(...d),
226
- ["escape"]
227
- ))
228
- ]
229
- }, null, 544)), [
230
- [re, n(k)]
231
- ]) : A(i.$slots, "item-title", {
232
- key: 2,
233
- item: l
234
- }, () => [
235
- w("span", {
236
- class: "text",
237
- title: l.title
238
- }, B(l.title), 9, Oe)
239
- ], !0),
240
- w("span", {
241
- class: "tr-history__item-actions",
242
- onClick: e[6] || (e[6] = J(() => {
243
- }, ["stop"]))
244
- }, [
245
- t.showRenameControls && n(p) === l ? (r(), a("button", {
246
- key: 0,
247
- class: "editor-confirm",
248
- ref_for: !0,
249
- ref_key: "editorConfirmRefList",
250
- ref: y,
251
- onClick: e[4] || (e[4] = //@ts-ignore
252
- (...d) => n(v) && n(v)(...d))
253
- }, [
254
- $(n(me))
255
- ], 512)) : G("", !0),
256
- t.showRenameControls && n(p) === l ? (r(), a("button", {
257
- key: 1,
258
- class: "editor-cancel",
259
- ref_for: !0,
260
- ref_key: "editorCancelRefList",
261
- ref: M,
262
- onClick: e[5] || (e[5] = //@ts-ignore
263
- (...d) => n(o) && n(o)(...d))
264
- }, [
265
- $(n(fe))
266
- ], 512)) : G("", !0),
267
- w("button", {
268
- class: U(["menu", { hidden: n(p) === l }]),
269
- onClick: (d) => K(d, l)
270
- }, [
271
- $(n(pe))
272
- ], 10, Se)
273
- ])
274
- ], 10, Ge))), 128))
275
- ])
276
- ]))), 128)),
277
- q($(Me, {
278
- trigger: g.value,
279
- "onUpdate:trigger": e[7] || (e[7] = (f) => g.value = f),
280
- data: u.value,
281
- "onUpdate:data": e[8] || (e[8] = (f) => u.value = f),
282
- items: t.menuItems,
283
- "menu-list-gap": t.menuListGap,
284
- onItemClick: ee
285
- }, null, 8, ["trigger", "data", "items", "menu-list-gap"]), [
286
- [ae, g.value]
287
- ])
288
- ], 64))
99
+ _(o(A), { class: "tr-chat-input-submit-button__icon" })
100
+ ], 2)
101
+ ]),
102
+ _: 1
103
+ }, 8, ["render-content", "placement"])) : (i(), d("div", {
104
+ key: 1,
105
+ class: b([
106
+ "tr-chat-input-submit-button",
107
+ {
108
+ "is-disabled": v.value,
109
+ "is-loading": o(a)
110
+ }
111
+ ]),
112
+ onClick: C
113
+ }, [
114
+ o(a) ? (i(), d("div", {
115
+ key: 1,
116
+ class: b(["tr-chat-input-submit-button__cancel", { "icon-only": !o(u) }])
117
+ }, [
118
+ _(o(N), { class: "tr-chat-input-submit-button__cancel-icon" }),
119
+ o(u) ? (i(), d("span", j, I(o(u)), 1)) : k("", !0)
120
+ ], 2)) : (i(), m(o(A), {
121
+ key: 0,
122
+ class: "tr-chat-input-submit-button__icon"
123
+ }))
289
124
  ], 2));
290
125
  }
291
- }), N = /* @__PURE__ */ z(Be, [["__scopeId", "data-v-97a7e8a2"]]), De = function(s) {
292
- s.component(N.name, N);
293
- };
294
- Object.assign(N, {
295
- name: "TrHistory",
296
- install: De
297
- });
126
+ }), K = /* @__PURE__ */ g(H, [["__scopeId", "data-v-f1b6fef8"]]), U = /* @__PURE__ */ h({
127
+ __name: "index",
128
+ setup(s) {
129
+ const { hasContent: t, clearable: a, clear: l, loading: r, defaultActions: c } = w(), u = p(() => {
130
+ var e, n;
131
+ return ((n = (e = c.value) == null ? void 0 : e.clear) == null ? void 0 : n.disabled) !== void 0 ? c.value.clear.disabled : !1;
132
+ }), v = p(() => {
133
+ var e, n;
134
+ return S((n = (e = c.value) == null ? void 0 : e.clear) == null ? void 0 : n.tooltip);
135
+ }), y = p(() => {
136
+ var e, n;
137
+ return ((n = (e = c.value) == null ? void 0 : e.clear) == null ? void 0 : n.tooltipPlacement) ?? "top";
138
+ }), z = p(() => a.value && t.value && !r.value && !u.value), C = () => {
139
+ u.value || l();
140
+ };
141
+ return (e, n) => z.value ? (i(), m(O, {
142
+ key: 0,
143
+ icon: o(F),
144
+ disabled: u.value,
145
+ tooltip: v.value,
146
+ "tooltip-placement": y.value,
147
+ onClick: C
148
+ }, null, 8, ["icon", "disabled", "tooltip", "tooltip-placement"])) : k("", !0);
149
+ }
150
+ }), X = {
151
+ key: 0,
152
+ class: "tr-chat-input-word-counter"
153
+ }, Y = /* @__PURE__ */ h({
154
+ __name: "index",
155
+ setup(s) {
156
+ const { characterCount: t, maxLength: a, isOverLimit: l, showWordLimit: r } = w(), c = p(() => r.value && a.value !== void 0);
157
+ return (u, v) => c.value ? (i(), d("span", X, [
158
+ f("span", {
159
+ class: b({ "is-over-limit": o(l) })
160
+ }, I(o(t)), 3),
161
+ f("span", null, "/" + I(o(a)), 1)
162
+ ])) : k("", !0);
163
+ }
164
+ }), nt = /* @__PURE__ */ g(Y, [["__scopeId", "data-v-e7c0fd64"]]), q = { class: "tr-default-action-buttons" }, G = {
165
+ key: 0,
166
+ class: "tr-action-buttons-group"
167
+ }, J = { class: "tr-submit-wrapper" }, M = /* @__PURE__ */ h({
168
+ __name: "index",
169
+ setup(s) {
170
+ const { hasContent: t, loading: a } = w();
171
+ return (l, r) => (i(), d("div", q, [
172
+ _(P, { name: "tr-slide-right" }, {
173
+ default: x(() => [
174
+ o(t) || o(a) ? (i(), d("div", G, [
175
+ _(P, { name: "tr-slide-right" }, {
176
+ default: x(() => [
177
+ _(U)
178
+ ]),
179
+ _: 1
180
+ }),
181
+ f("div", J, [
182
+ _(K)
183
+ ])
184
+ ])) : k("", !0)
185
+ ]),
186
+ _: 1
187
+ })
188
+ ]));
189
+ }
190
+ }), ot = /* @__PURE__ */ g(M, [["__scopeId", "data-v-e40bfaf6"]]);
298
191
  export {
299
- N as H,
300
- Ce as u
192
+ O as A,
193
+ L as C,
194
+ ot as D,
195
+ K as S,
196
+ nt as W,
197
+ U as _,
198
+ w as u
301
199
  };