@opentiny/tiny-robot 0.2.0 → 0.2.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.
@@ -53,9 +53,8 @@ const N = { class: "tr-prompt__icon" }, T = { class: "tr-prompt__content" }, V =
53
53
  class: m(["tr-prompts__list-container", { wrap: s.wrap, vertical: s.vertical }])
54
54
  }, [
55
55
  (e(!0), c(y, null, w(s.items, (i, g) => (e(), d(r, x({
56
- key: i.id || g,
57
- ref_for: !0
58
- }, i, {
56
+ key: i.id || g
57
+ }, { ref_for: !0 }, i, {
59
58
  style: s.itemStyle,
60
59
  class: s.itemClass,
61
60
  onClick: (C) => k(C, i)
@@ -1,9 +1,9 @@
1
- import { ref as O, watch as Y, reactive as Le, computed as P, nextTick as W, defineComponent as ve, createElementBlock as M, openBlock as k, createCommentVNode as $, createBlock as Z, unref as T, withCtx as G, createVNode as U, normalizeClass as le, resolveDynamicComponent as Ue, createElementVNode as K, mergeModels as Ne, useModel as Ze, onMounted as Ge, useSlots as Je, Transition as ge, renderSlot as ne, isRef as Te, createTextVNode as xe, toDisplayString as se, normalizeStyle as Qe, Fragment as Re, renderList as ke, withModifiers as Ye } from "vue";
1
+ import { ref as O, watch as Y, reactive as Le, computed as P, nextTick as W, defineComponent as ve, createElementBlock as M, openBlock as k, createCommentVNode as $, createBlock as Z, unref as T, withCtx as G, createVNode as U, normalizeClass as le, resolveDynamicComponent as Ue, createElementVNode as X, mergeModels as Ne, useModel as Ze, onMounted as Ge, useSlots as Je, Transition as ge, renderSlot as ne, isRef as Te, createTextVNode as xe, toDisplayString as se, normalizeStyle as Qe, Fragment as Re, renderList as ke, withModifiers as Ye } from "vue";
2
2
  import { I as et } from "../index5.js";
3
3
  import { B as ue } from "../index3.js";
4
4
  import { T as me } from "../index4.js";
5
5
  import { i as tt } from "../close.js";
6
- import { I as nt, L as st, u as lt, w as ot, P as at, _ as it } from "../tiny-robot-svgs.js";
6
+ import { I as nt, L as st, v as lt, w as ot, P as at, _ as it } from "../tiny-robot-svgs.js";
7
7
  function rt(e, b) {
8
8
  const f = O(e.modelValue || e.defaultValue || ""), o = O(null);
9
9
  Y(
@@ -488,19 +488,19 @@ const ht = { class: "action-buttons" }, vt = {
488
488
  onClick: C[0] || (C[0] = (w) => y.loading ? F() : _())
489
489
  }, {
490
490
  default: G(() => [
491
- K("div", yt, [
491
+ X("div", yt, [
492
492
  y.loading ? (k(), Z(T(me), {
493
493
  key: 1,
494
494
  content: "停止生成",
495
495
  placement: "top"
496
496
  }, {
497
497
  default: G(() => [
498
- K("div", bt, [
498
+ X("div", bt, [
499
499
  U(T(at), {
500
500
  class: "action-buttons__icon action-buttons__icon--stop",
501
501
  alt: "加载中"
502
502
  }),
503
- C[1] || (C[1] = K("span", { class: "action-buttons__cancel-text" }, "停止回答", -1))
503
+ C[1] || (C[1] = X("span", { class: "action-buttons__cancel-text" }, "停止回答", -1))
504
504
  ])
505
505
  ]),
506
506
  _: 1
@@ -575,8 +575,8 @@ function Ct(e, b) {
575
575
  document.body.removeChild(s);
576
576
  const V = n ? 1.5 : 2, q = N / I, B = Math.max(V, Math.ceil(q));
577
577
  t.style.setProperty("min-width", `${B}em`, "important");
578
- const X = 20;
579
- B > X ? (t.style.setProperty("max-width", `${X}em`, "important"), t.style.setProperty("white-space", "normal", "important"), t.style.setProperty("word-break", "break-word", "important")) : t.style.removeProperty("max-width");
578
+ const H = 20;
579
+ B > H ? (t.style.setProperty("max-width", `${H}em`, "important"), t.style.setProperty("white-space", "normal", "important"), t.style.setProperty("word-break", "break-word", "important")) : t.style.removeProperty("max-width");
580
580
  }, a = (t) => {
581
581
  const n = (t === void 0 ? p() : t).trim().length > 0;
582
582
  f.value !== n && (f.value = n, o.onContentStatusChange(n));
@@ -648,10 +648,10 @@ function Ct(e, b) {
648
648
  }), s += I.content.length, d++) : N = !1;
649
649
  else {
650
650
  let V = "";
651
- const q = t.find((B, X) => X > d && B.type === "text");
651
+ const q = t.find((B, H) => H > d && B.type === "text");
652
652
  if (q) {
653
- const B = i.substring(s), X = B.indexOf(q.content);
654
- X !== -1 ? (V = B.substring(0, X), s += V.length) : N = !1;
653
+ const B = i.substring(s), H = B.indexOf(q.content);
654
+ H !== -1 ? (V = B.substring(0, H), s += V.length) : N = !1;
655
655
  } else
656
656
  V = i.substring(s), s = i.length;
657
657
  if (N) {
@@ -840,8 +840,8 @@ const wt = /* @__PURE__ */ ve({
840
840
  onSubmit: (g) => r("submit", g)
841
841
  }), F = (g, h) => {
842
842
  let x = g;
843
- return Object.entries(h).forEach(([H, t]) => {
844
- const i = `[${H}]`;
843
+ return Object.entries(h).forEach(([K, t]) => {
844
+ const i = `[${K}]`;
845
845
  x = x.replace(new RegExp(i.replace(/[[\]]/g, "\\$&"), "g"), t);
846
846
  }), x;
847
847
  }, y = (g) => {
@@ -860,11 +860,11 @@ const wt = /* @__PURE__ */ ve({
860
860
  }, w = () => {
861
861
  E.value = !1, a.handleInput();
862
862
  }, m = (g) => {
863
- var H;
863
+ var K;
864
864
  if (!p.value) return;
865
865
  const h = g.target;
866
866
  let x = null;
867
- if (h.classList.contains("template-field") ? x = h : (H = h.parentElement) != null && H.classList.contains("template-field") && (x = h.parentElement), x && (!x.textContent || x.textContent.trim() === "")) {
867
+ if (h.classList.contains("template-field") ? x = h : (K = h.parentElement) != null && K.classList.contains("template-field") && (x = h.parentElement), x && (!x.textContent || x.textContent.trim() === "")) {
868
868
  const t = window.getSelection(), i = document.createRange();
869
869
  t && (i.selectNodeContents(x), i.collapse(!0), t.removeAllRanges(), t.addRange(i), x.focus(), g.preventDefault(), g.stopPropagation());
870
870
  }
@@ -872,7 +872,7 @@ const wt = /* @__PURE__ */ ve({
872
872
  g.preventDefault();
873
873
  const h = g.clipboardData;
874
874
  if (!h) return;
875
- const x = h.getData("text/html"), H = h.getData("text/plain");
875
+ const x = h.getData("text/html"), K = h.getData("text/plain");
876
876
  if (x) {
877
877
  const t = document.createElement("div");
878
878
  t.innerHTML = x;
@@ -885,8 +885,8 @@ const wt = /* @__PURE__ */ ve({
885
885
  N.backgroundColor.toLowerCase().includes("0.05") || N.backgroundColor.toLowerCase().includes("0.08")), B = N.borderRadius === "4px" || N.padding === "3px 8px" || N.margin === "0px 2px" || N.whiteSpace === "nowrap";
886
886
  if (I || V || q || B) {
887
887
  if (n = !0, d.className = "template-field", !d.getAttribute("data-placeholder")) {
888
- const X = a.extractPlaceholderFromElement(d);
889
- X && d.setAttribute("data-placeholder", X);
888
+ const H = a.extractPlaceholderFromElement(d);
889
+ H && d.setAttribute("data-placeholder", H);
890
890
  }
891
891
  d.removeAttribute("style");
892
892
  }
@@ -895,16 +895,16 @@ const wt = /* @__PURE__ */ ve({
895
895
  return;
896
896
  }
897
897
  }
898
- H && z(H);
898
+ K && z(K);
899
899
  }, A = (g) => {
900
900
  const h = window.getSelection();
901
901
  if (h && h.rangeCount > 0) {
902
902
  const x = h.getRangeAt(0);
903
903
  x.deleteContents();
904
- const H = document.createDocumentFragment();
904
+ const K = document.createDocumentFragment();
905
905
  for (; g.firstChild; )
906
- H.appendChild(g.firstChild);
907
- x.insertNode(H), x.collapse(!1), h.removeAllRanges(), h.addRange(x), j();
906
+ K.appendChild(g.firstChild);
907
+ x.insertNode(K), x.collapse(!1), h.removeAllRanges(), h.addRange(x), j();
908
908
  }
909
909
  }, z = (g) => {
910
910
  const h = window.getSelection();
@@ -1013,7 +1013,7 @@ const wt = /* @__PURE__ */ ve({
1013
1013
  }, Vt = { class: "tiny-sender__buttons-container" }, Bt = {
1014
1014
  key: 1,
1015
1015
  class: "tiny-sender__footer-slot"
1016
- }, Wt = ["onMouseenter", "onMousedown"], $t = { class: "suggestion-item__icon" }, Pt = { class: "suggestion-item__text" }, Kt = {
1016
+ }, Wt = ["onMouseenter", "onMousedown"], $t = { class: "suggestion-item__text" }, Pt = {
1017
1017
  key: 0,
1018
1018
  class: "tiny-sender__error"
1019
1019
  }, ce = /* @__PURE__ */ ve({
@@ -1054,7 +1054,7 @@ const wt = /* @__PURE__ */ ve({
1054
1054
  updateSuggestionsState: g,
1055
1055
  selectSuggestion: h,
1056
1056
  acceptCurrentSuggestion: x,
1057
- closeSuggestionsPopup: H,
1057
+ closeSuggestionsPopup: K,
1058
1058
  navigateSuggestions: t,
1059
1059
  handleSuggestionItemHover: i,
1060
1060
  highlightSuggestionText: n
@@ -1105,11 +1105,11 @@ const wt = /* @__PURE__ */ ve({
1105
1105
  q();
1106
1106
  }, 50);
1107
1107
  });
1108
- }, X = () => {
1108
+ }, H = () => {
1109
1109
  var c;
1110
1110
  F(), E.value ? B() : (c = p.value) == null || c.focus(), W(() => {
1111
1111
  a.value === "" && (s.value = o.mode || "single");
1112
- }), H();
1112
+ }), K();
1113
1113
  }, Ae = (c) => {
1114
1114
  S("update:modelValue", c);
1115
1115
  }, ye = () => {
@@ -1149,7 +1149,7 @@ const wt = /* @__PURE__ */ ve({
1149
1149
  y,
1150
1150
  z,
1151
1151
  x,
1152
- H,
1152
+ K,
1153
1153
  t,
1154
1154
  de,
1155
1155
  s,
@@ -1157,7 +1157,7 @@ const wt = /* @__PURE__ */ ve({
1157
1157
  ), Be = (c) => {
1158
1158
  S("focus", c), a.value && A.value.length > 0 && !o.template && (y.value = !0, m.value = !0, C.value === -1 && (C.value = 0), j(z.value || A.value[0]));
1159
1159
  }, We = (c) => {
1160
- S("blur", c);
1160
+ S("blur", c), K();
1161
1161
  }, $e = P(() => s.value === "multiple" ? "textarea" : "text"), Pe = P(
1162
1162
  () => ({
1163
1163
  display: "flex",
@@ -1193,7 +1193,7 @@ const wt = /* @__PURE__ */ ve({
1193
1193
  c == null || c.blur();
1194
1194
  }
1195
1195
  },
1196
- clear: X,
1196
+ clear: H,
1197
1197
  submit: fe,
1198
1198
  startSpeech: be,
1199
1199
  stopSpeech: Ce,
@@ -1205,8 +1205,8 @@ const wt = /* @__PURE__ */ ve({
1205
1205
  class: le(["tiny-sender", [Xe.value, `theme-${c.theme}`, `mode-${s.value}`]]),
1206
1206
  "data-theme": c.theme
1207
1207
  }, [
1208
- K("div", Et, [
1209
- K("div", {
1208
+ X("div", Et, [
1209
+ X("div", {
1210
1210
  class: "tiny-sender__input-wrapper",
1211
1211
  ref_key: "inputWrapperRef",
1212
1212
  ref: l
@@ -1219,13 +1219,13 @@ const wt = /* @__PURE__ */ ve({
1219
1219
  ]),
1220
1220
  _: 3
1221
1221
  }),
1222
- K("div", {
1222
+ X("div", {
1223
1223
  class: le(["tiny-sender__input-row", { "has-prefix": c.$slots.prefix, "has-header": c.$slots.header }])
1224
1224
  }, [
1225
1225
  c.$slots.prefix ? (k(), M("div", Nt, [
1226
1226
  ne(c.$slots, "prefix")
1227
1227
  ])) : $("", !0),
1228
- K("div", Tt, [
1228
+ X("div", Tt, [
1229
1229
  c.$slots.decorativeContent ? (k(), M("div", xt, [
1230
1230
  ne(c.$slots, "decorativeContent")
1231
1231
  ])) : $("", !0),
@@ -1257,14 +1257,14 @@ const wt = /* @__PURE__ */ ve({
1257
1257
  onBlur: We
1258
1258
  }, null, 8, ["autosize", "type", "readonly", "modelValue", "disabled", "placeholder", "autofocus", "onKeydown"]),
1259
1259
  T(w) && !T(_) ? (k(), M("div", kt, [
1260
- K("span", Dt, se(T(a)), 1),
1260
+ X("span", Dt, se(T(a)), 1),
1261
1261
  xe(se(T(w)) + " ", 1),
1262
1262
  T(m) ? (k(), M("div", Ft, "TAB")) : $("", !0)
1263
1263
  ])) : $("", !0)
1264
1264
  ]))
1265
1265
  ]),
1266
1266
  s.value === "single" ? (k(), M("div", Lt, [
1267
- K("div", {
1267
+ X("div", {
1268
1268
  class: "tiny-sender__buttons-container",
1269
1269
  ref_key: "buttonsContainerRef",
1270
1270
  ref: v
@@ -1280,7 +1280,7 @@ const wt = /* @__PURE__ */ ve({
1280
1280
  "speech-status": T(ae),
1281
1281
  "submit-type": c.submitType,
1282
1282
  "is-over-limit": pe.value,
1283
- onClear: X,
1283
+ onClear: H,
1284
1284
  onToggleSpeech: de,
1285
1285
  onSubmit: T(fe),
1286
1286
  onCancel: R[3] || (R[3] = (D) => c.$emit("cancel"))
@@ -1295,20 +1295,20 @@ const wt = /* @__PURE__ */ ve({
1295
1295
  style: Qe(Pe.value),
1296
1296
  class: "tiny-sender__footer-slot tiny-sender__bottom-row"
1297
1297
  }, [
1298
- K("div", Ot, [
1298
+ X("div", Ot, [
1299
1299
  ne(c.$slots, "footer-left")
1300
1300
  ]),
1301
- K("div", At, [
1301
+ X("div", At, [
1302
1302
  ne(c.$slots, "footer-right"),
1303
1303
  c.showWordLimit && c.maxLength !== 1 / 0 ? (k(), M("div", {
1304
1304
  key: 0,
1305
1305
  class: le(["tiny-sender__word-limit", { "is-over-limit": pe.value }])
1306
1306
  }, [
1307
- K("span", It, se(T(a).length), 1),
1307
+ X("span", It, se(T(a).length), 1),
1308
1308
  xe("/" + se(c.maxLength), 1)
1309
1309
  ], 2)) : $("", !0),
1310
1310
  s.value === "multiple" ? (k(), M("div", Mt, [
1311
- K("div", Vt, [
1311
+ X("div", Vt, [
1312
1312
  U(Fe, {
1313
1313
  "allow-speech": c.allowSpeech,
1314
1314
  "allow-files": c.allowFiles,
@@ -1319,7 +1319,7 @@ const wt = /* @__PURE__ */ ve({
1319
1319
  "speech-status": T(ae),
1320
1320
  "submit-type": c.submitType,
1321
1321
  "is-over-limit": pe.value,
1322
- onClear: X,
1322
+ onClear: H,
1323
1323
  onToggleSpeech: de,
1324
1324
  onSubmit: T(fe),
1325
1325
  onCancel: R[4] || (R[4] = (D) => c.$emit("cancel"))
@@ -1349,10 +1349,8 @@ const wt = /* @__PURE__ */ ve({
1349
1349
  onMouseenter: (te) => T(i)(ee),
1350
1350
  onMousedown: Ye((te) => T(h)(D), ["prevent"])
1351
1351
  }, [
1352
- K("span", $t, [
1353
- U(T(it))
1354
- ]),
1355
- K("span", Pt, [
1352
+ U(T(it), { class: "suggestion-item__icon" }),
1353
+ X("span", $t, [
1356
1354
  (k(!0), M(Re, null, ke(T(n)(D, T(a)), (te, Ee) => (k(), M("span", {
1357
1355
  key: Ee,
1358
1356
  class: le({ "suggestion-item__text--match": te.isMatch, "suggestion-item__text--normal": !te.isMatch })
@@ -1363,15 +1361,15 @@ const wt = /* @__PURE__ */ ve({
1363
1361
  ]),
1364
1362
  _: 1
1365
1363
  }),
1366
- oe.value ? (k(), M("div", Kt, se(oe.value), 1)) : $("", !0)
1364
+ oe.value ? (k(), M("div", Pt, se(oe.value), 1)) : $("", !0)
1367
1365
  ], 10, St));
1368
1366
  }
1369
1367
  });
1370
1368
  ce.name = "TrSender";
1371
- const Ht = function(e) {
1369
+ const Kt = function(e) {
1372
1370
  e.component(ce.name, ce);
1373
1371
  };
1374
- ce.install = Ht;
1372
+ ce.install = Kt;
1375
1373
  export {
1376
1374
  ce as default
1377
1375
  };