@opentiny/tiny-robot 0.3.0-alpha.12 → 0.3.0-alpha.14

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,20 +1,20 @@
1
- import { defineComponent as H, ref as p, computed as P, watch as K, watchEffect as ne, onMounted as Y, onBeforeUnmount as Z, createElementBlock as v, openBlock as g, normalizeClass as X, createElementVNode as u, withDirectives as oe, Fragment as z, renderList as M, createVNode as E, unref as w, toDisplayString as T, vShow as le, nextTick as ie, renderSlot as $, createCommentVNode as N, createBlock as L, normalizeStyle as ae, resolveComponent as ce, withCtx as O } from "vue";
2
- import { e as J, X as F, U as re, V as ue, W as ge } from "../tiny-robot-svgs.js";
1
+ import { defineComponent as U, ref as p, computed as P, watch as K, watchEffect as ne, onMounted as Y, onBeforeUnmount as Z, createElementBlock as v, openBlock as g, normalizeClass as j, createElementVNode as u, withDirectives as oe, Fragment as z, renderList as M, createVNode as E, unref as w, toDisplayString as T, vShow as le, nextTick as ie, renderSlot as x, createCommentVNode as N, createBlock as L, normalizeStyle as ae, resolveComponent as ce, withCtx as O } from "vue";
2
+ import { y as Q, d as G, x as re, g as ue, a as ge } from "../tiny-robot-svgs.js";
3
3
  function de(l, c = "") {
4
4
  const s = document.createElement("div");
5
5
  c && (s.className = c), s.style.visibility = "hidden", s.style.position = "absolute", s.style.whiteSpace = "nowrap", s.textContent = l, document.body.appendChild(s);
6
6
  const o = s.offsetWidth;
7
7
  return document.body.removeChild(s), o;
8
8
  }
9
- const j = /* @__PURE__ */ new Map();
10
- function Q(l, c = "") {
9
+ const F = /* @__PURE__ */ new Map();
10
+ function X(l, c = "") {
11
11
  const s = `${l}::${c}`;
12
- if (j.has(s))
13
- return j.get(s);
12
+ if (F.has(s))
13
+ return F.get(s);
14
14
  const o = de(l, c);
15
- return j.set(s, o), o;
15
+ return F.set(s, o), o;
16
16
  }
17
- const ve = { class: "tr-common-suggestions_content" }, me = { class: "tr-common-suggestions_expanded-wrapper" }, pe = { class: "tr-common-suggestions_expanded-area" }, he = ["onClick"], fe = { class: "tr-common-suggestions_item_icon" }, ye = { class: "tr-common-suggestions_item_text" }, _e = { class: "tr-common-suggestions_container" }, ke = ["onClick"], Ce = { class: "tr-common-suggestions_item_icon" }, $e = { class: "tr-common-suggestions_item_text" }, xe = /* @__PURE__ */ H({
17
+ const ve = { class: "tr-common-suggestions_content" }, me = { class: "tr-common-suggestions_expanded-wrapper" }, pe = { class: "tr-common-suggestions_expanded-area" }, he = ["onClick"], fe = { class: "tr-common-suggestions_item_icon" }, ye = { class: "tr-common-suggestions_item_text" }, _e = { class: "tr-common-suggestions_container" }, ke = ["onClick"], Ce = { class: "tr-common-suggestions_item_icon" }, xe = { class: "tr-common-suggestions_item_text" }, $e = /* @__PURE__ */ U({
18
18
  __name: "SuggestionCapsule",
19
19
  props: {
20
20
  suggestions: {
@@ -46,13 +46,13 @@ const ve = { class: "tr-common-suggestions_content" }, me = { class: "tr-common-
46
46
  let k = 0;
47
47
  const B = Math.min(3, s.suggestions.length);
48
48
  for (let C = 0; C < B; C++) {
49
- const I = Q(s.suggestions[C].text, "tr-common-suggestions_item") + _;
49
+ const I = X(s.suggestions[C].text, "tr-common-suggestions_item") + _;
50
50
  k += I;
51
51
  }
52
52
  const q = k / B;
53
53
  h.value = Math.max(1, Math.floor(d / q));
54
54
  for (let C = 0; C < s.suggestions.length; C++) {
55
- const I = s.suggestions[C], V = Q(I.text, "tr-common-suggestions_item") + _;
55
+ const I = s.suggestions[C], V = X(I.text, "tr-common-suggestions_item") + _;
56
56
  r + V <= d ? (r += V, m.value.push(I)) : a.value.push(I);
57
57
  }
58
58
  f.value = a.value.length > 0, o("show-expand-button", f.value);
@@ -73,7 +73,7 @@ const ve = { class: "tr-common-suggestions_content" }, me = { class: "tr-common-
73
73
  }), Z(() => {
74
74
  S.value && S.value.disconnect();
75
75
  }), (i, d) => (g(), v("div", {
76
- class: X(["tr-common-suggestions", { expanded: t.value }]),
76
+ class: j(["tr-common-suggestions", { expanded: t.value }]),
77
77
  ref_key: "capsuleRef",
78
78
  ref: n
79
79
  }, [
@@ -90,7 +90,7 @@ const ve = { class: "tr-common-suggestions_content" }, me = { class: "tr-common-
90
90
  onClick: (q) => y(k)
91
91
  }, [
92
92
  u("div", fe, [
93
- E(w(J))
93
+ E(w(Q))
94
94
  ]),
95
95
  u("div", ye, T(k.text), 1)
96
96
  ], 8, he))), 128))
@@ -106,9 +106,9 @@ const ve = { class: "tr-common-suggestions_content" }, me = { class: "tr-common-
106
106
  onClick: (k) => y(r)
107
107
  }, [
108
108
  u("div", Ce, [
109
- E(w(J))
109
+ E(w(Q))
110
110
  ]),
111
- u("div", $e, T(r.text), 1)
111
+ u("div", xe, T(r.text), 1)
112
112
  ], 8, ke))), 128))
113
113
  ])
114
114
  ])
@@ -117,7 +117,7 @@ const ve = { class: "tr-common-suggestions_content" }, me = { class: "tr-common-
117
117
  }), be = { class: "tr-suggestion-categories" }, we = ["onClick"], Se = {
118
118
  key: 0,
119
119
  class: "category-icon"
120
- }, Ie = /* @__PURE__ */ H({
120
+ }, Ie = /* @__PURE__ */ U({
121
121
  __name: "CategoryNav",
122
122
  props: {
123
123
  categories: {
@@ -137,10 +137,10 @@ const ve = { class: "tr-common-suggestions_content" }, me = { class: "tr-common-
137
137
  return (n, f) => (g(), v("div", be, [
138
138
  (g(!0), v(z, null, M(l.categories, (t) => (g(), v("div", {
139
139
  key: t.id,
140
- class: X(["tr-suggestion-categories-item", { active: l.activeCategory === t.id }]),
140
+ class: j(["tr-suggestion-categories-item", { active: l.activeCategory === t.id }]),
141
141
  onClick: (m) => o(t.id)
142
142
  }, [
143
- $(n.$slots, "category-label", { category: t }, () => [
143
+ x(n.$slots, "category-label", { category: t }, () => [
144
144
  t.icon ? (g(), v("div", Se, T(t.icon), 1)) : N("", !0),
145
145
  u("span", null, T(t.label), 1)
146
146
  ])
@@ -198,7 +198,7 @@ const Te = { class: "tr-suggestion-panel" }, Be = { class: "tr-suggestion-header
198
198
  }, qe = {
199
199
  key: 2,
200
200
  class: "tr-suggestion-empty"
201
- }, Le = /* @__PURE__ */ H({
201
+ }, Le = /* @__PURE__ */ U({
202
202
  __name: "SuggestionPanel",
203
203
  props: {
204
204
  items: {
@@ -250,8 +250,8 @@ const Te = { class: "tr-suggestion-panel" }, Be = { class: "tr-suggestion-header
250
250
  u("div", Be, [
251
251
  u("div", De, [
252
252
  u("div", Oe, [
253
- $(i.$slots, "title-icon", {}, () => [
254
- E(w(F), { style: { color: "#1476ff", "font-size": "24px" } })
253
+ x(i.$slots, "title-icon", {}, () => [
254
+ E(w(G), { style: { color: "#1476ff", "font-size": "24px" } })
255
255
  ])
256
256
  ]),
257
257
  u("div", Re, T(l.title), 1)
@@ -276,17 +276,17 @@ const Te = { class: "tr-suggestion-panel" }, Be = { class: "tr-suggestion-header
276
276
  style: ae({ "max-height": h.value.length > l.maxVisibleItems ? `${l.maxVisibleItems * 56}px` : "auto" })
277
277
  }, [
278
278
  l.loading ? (g(), v("div", We, [
279
- $(i.$slots, "loading-indicator", {}, () => [
279
+ x(i.$slots, "loading-indicator", {}, () => [
280
280
  d[0] || (d[0] = u("div", { class: "tr-suggestion-loading-spinner" }, null, -1))
281
281
  ])
282
282
  ])) : h.value.length > 0 ? (g(), v("ul", Ae, [
283
283
  (g(!0), v(z, null, M(h.value, (r, _) => (g(), v("li", {
284
284
  key: r.id,
285
- class: X(["tr-suggestion-list-item", { "tr-suggestion-item-active": _ === w(m) }]),
285
+ class: j(["tr-suggestion-list-item", { "tr-suggestion-item-active": _ === w(m) }]),
286
286
  onClick: (k) => R(r),
287
287
  onMouseenter: (k) => y(_)
288
288
  }, [
289
- $(i.$slots, "item", {
289
+ x(i.$slots, "item", {
290
290
  item: r,
291
291
  active: _ === w(m)
292
292
  }, () => [
@@ -297,7 +297,7 @@ const Te = { class: "tr-suggestion-panel" }, Be = { class: "tr-suggestion-header
297
297
  ])
298
298
  ], 42, Ke))), 128))
299
299
  ])) : (g(), v("div", qe, [
300
- $(i.$slots, "empty", {}, () => [
300
+ x(i.$slots, "empty", {}, () => [
301
301
  d[1] || (d[1] = u("p", null, "无匹配结果", -1))
302
302
  ])
303
303
  ]))
@@ -317,7 +317,7 @@ const Te = { class: "tr-suggestion-panel" }, Be = { class: "tr-suggestion-header
317
317
  } : null;
318
318
  }
319
319
  };
320
- }, Ue = { class: "tr-suggestion__header" }, U = /* @__PURE__ */ H({
320
+ }, He = { class: "tr-suggestion__header" }, H = /* @__PURE__ */ U({
321
321
  __name: "index",
322
322
  props: {
323
323
  triggerKeys: { default: () => ["/"] },
@@ -344,7 +344,7 @@ const Te = { class: "tr-suggestion-panel" }, Be = { class: "tr-suggestion-header
344
344
  }, b = p(""), y = p(-1), i = p(null), d = p(null), r = P(() => o.open !== void 0 ? o.open : f.value), _ = P(() => {
345
345
  if (o.categories.length === 0 || !b.value)
346
346
  return t.value;
347
- const e = o.categories.find((x) => x.id === b.value);
347
+ const e = o.categories.find(($) => $.id === b.value);
348
348
  return e ? e.items : [];
349
349
  });
350
350
  K(r, (e) => {
@@ -370,9 +370,9 @@ const Te = { class: "tr-suggestion-panel" }, Be = { class: "tr-suggestion-header
370
370
  text: e.text || "",
371
371
  position: e.position || 0
372
372
  }), k(), f.value = !0, n("update:open", !0));
373
- }, I = (e, x) => {
374
- const A = B(e, x);
375
- return A ? (m.value = A, C(A), !0) : r.value && x === "" ? (C(!1), !0) : !1;
373
+ }, I = (e, $) => {
374
+ const A = B(e, $);
375
+ return A ? (m.value = A, C(A), !0) : r.value && $ === "" ? (C(!1), !0) : !1;
376
376
  }, V = (e) => {
377
377
  if (r.value && d.value) {
378
378
  d.value.handleKeyDown(e);
@@ -382,44 +382,44 @@ const Te = { class: "tr-suggestion-panel" }, Be = { class: "tr-suggestion-header
382
382
  o.open === void 0 && (f.value = !1), n("update:open", !1), n("close");
383
383
  }, ee = (e) => {
384
384
  b.value = e.id, y.value = 0, n("category-select", e);
385
- }, te = (e, x) => {
386
- n("select", e.text, x), e.template && n("fill-template", e.template), W();
387
- }, G = (e) => {
385
+ }, te = (e, $) => {
386
+ n("select", e.text, $), e.template && n("fill-template", e.template), W();
387
+ }, J = (e) => {
388
388
  o.closeOnOutsideClick && r.value && i.value && !i.value.contains(e.target) && W();
389
389
  }, se = () => {
390
390
  r.value ? W() : (k(), f.value = !0, n("update:open", !0));
391
391
  };
392
392
  return Y(() => {
393
- o.closeOnOutsideClick && document.addEventListener("click", G);
393
+ o.closeOnOutsideClick && document.addEventListener("click", J);
394
394
  }), Z(() => {
395
- o.closeOnOutsideClick && document.removeEventListener("click", G);
395
+ o.closeOnOutsideClick && document.removeEventListener("click", J);
396
396
  }), c({
397
397
  trigger: C,
398
398
  keyDown: V,
399
399
  input: I,
400
400
  toggleExpand: S
401
- }), (e, x) => {
401
+ }), (e, $) => {
402
402
  const A = ce("IconEdit");
403
403
  return g(), v("div", {
404
404
  ref_key: "rootRef",
405
405
  ref: i,
406
- class: X(["tr-suggestion", e.className, { "tr-suggestion--dark": e.theme === "dark" }])
406
+ class: j(["tr-suggestion", e.className, { "tr-suggestion--dark": e.theme === "dark" }])
407
407
  }, [
408
- u("div", Ue, [
408
+ u("div", He, [
409
409
  u("div", {
410
410
  class: "tr-suggestion__trigger",
411
411
  onClick: se
412
412
  }, [
413
- E(w(F), { style: { color: "#1476ff" } })
413
+ E(w(G), { style: { color: "#1476ff" } })
414
414
  ]),
415
- E(xe, {
415
+ E($e, {
416
416
  suggestions: e.items,
417
417
  isExpanded: a.value,
418
418
  onSuggestionClick: q,
419
419
  onShowExpandButton: R
420
420
  }, {
421
421
  "suggestion-icon": O((D) => [
422
- $(e.$slots, "capsule-icon", {
422
+ x(e.$slots, "capsule-icon", {
423
423
  suggestion: D.suggestion
424
424
  }, () => [
425
425
  E(A)
@@ -435,7 +435,7 @@ const Te = { class: "tr-suggestion-panel" }, Be = { class: "tr-suggestion-header
435
435
  a.value ? (g(), L(w(ge), { key: 1 })) : (g(), L(w(ue), { key: 0 }))
436
436
  ])) : N("", !0)
437
437
  ]),
438
- $(e.$slots, "trigger", {
438
+ x(e.$slots, "trigger", {
439
439
  onTrigger: C,
440
440
  onKeyDown: V,
441
441
  onInput: I
@@ -456,29 +456,29 @@ const Te = { class: "tr-suggestion-panel" }, Be = { class: "tr-suggestion-header
456
456
  onCategorySelect: ee
457
457
  }, {
458
458
  "title-icon": O(() => [
459
- $(e.$slots, "title-icon", {}, () => [
460
- E(w(F), { style: { "font-size": "24px", color: "#1476ff" } })
459
+ x(e.$slots, "title-icon", {}, () => [
460
+ E(w(G), { style: { "font-size": "24px", color: "#1476ff" } })
461
461
  ])
462
462
  ]),
463
463
  "category-label": O((D) => [
464
- $(e.$slots, "category-label", {
464
+ x(e.$slots, "category-label", {
465
465
  category: D.category
466
466
  })
467
467
  ]),
468
468
  item: O((D) => [
469
- $(e.$slots, "item", {
469
+ x(e.$slots, "item", {
470
470
  item: D.item,
471
471
  active: D.active
472
472
  })
473
473
  ]),
474
474
  "loading-indicator": O(() => [
475
- $(e.$slots, "loading-indicator", {}, () => [
476
- x[0] || (x[0] = u("div", { class: "tr-suggestion__loading-spinner" }, null, -1))
475
+ x(e.$slots, "loading-indicator", {}, () => [
476
+ $[0] || ($[0] = u("div", { class: "tr-suggestion__loading-spinner" }, null, -1))
477
477
  ])
478
478
  ]),
479
479
  empty: O(() => [
480
- $(e.$slots, "empty", {}, () => [
481
- x[1] || (x[1] = u("p", null, "无匹配结果", -1))
480
+ x(e.$slots, "empty", {}, () => [
481
+ $[1] || ($[1] = u("p", null, "无匹配结果", -1))
482
482
  ])
483
483
  ]),
484
484
  _: 3
@@ -487,11 +487,11 @@ const Te = { class: "tr-suggestion-panel" }, Be = { class: "tr-suggestion-header
487
487
  };
488
488
  }
489
489
  });
490
- U.name = "TrSuggestion";
491
- const He = function(l) {
492
- l.component(U.name, U);
490
+ H.name = "TrSuggestion";
491
+ const Ue = function(l) {
492
+ l.component(H.name, H);
493
493
  };
494
- U.install = He;
494
+ H.install = Ue;
495
495
  export {
496
- U as default
496
+ H as default
497
497
  };
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as K, useSlots as Q, computed as a, createElementBlock as m, openBlock as r, normalizeClass as w, renderSlot as H, createBlock as S, resolveDynamicComponent as b, createCommentVNode as M, toDisplayString as ne, mergeModels as N, useModel as le, ref as d, watch as R, nextTick as $, createElementVNode as D, Fragment as z, renderList as G, isVNode as j, createVNode as q, Transition as se, withCtx as re, unref as ae } from "vue";
2
- import { V as ie } from "../tiny-robot-svgs.js";
3
- import { e as ce, f as J, w as ue, o as fe, g as de } from "../index3.js";
2
+ import { g as ie } from "../tiny-robot-svgs.js";
3
+ import { e as ce, b as J, f as ue, o as fe, g as de } from "../index3.js";
4
4
  import { u as me } from "../useSlotRefs.js";
5
5
  import { _ as U } from "../_plugin-vue_export-helper.js";
6
6
  const pe = { key: 0 }, ge = /* @__PURE__ */ K({
@@ -46,10 +46,10 @@ const pe = { key: 0 }, ge = /* @__PURE__ */ K({
46
46
  }),
47
47
  emits: /* @__PURE__ */ N(["click-outside"], ["update:showAll"]),
48
48
  setup(i, { expose: v, emit: _ }) {
49
- const p = i, I = Q(), x = _, { vnodes: o } = me(I.default, !0), u = le(i, "showAll"), c = d(null), f = d(null), A = d(null), { width: W } = ce(f), V = d(0), B = a(() => p.overflowMode === "expand" && W.value < V.value), g = d(-1), X = a(() => B.value && u.value ? o.value.slice(0, g.value) : o.value), C = a(() => B.value && u.value ? o.value.slice(g.value).map((e, t) => ({
49
+ const p = i, I = Q(), x = _, { vnodes: o } = me(I.default, !0), u = le(i, "showAll"), c = d(null), f = d(null), A = d(null), { width: W } = ce(f), C = d(0), B = a(() => p.overflowMode === "expand" && W.value < C.value), g = d(-1), X = a(() => B.value && u.value ? o.value.slice(0, g.value) : o.value), T = a(() => B.value && u.value ? o.value.slice(g.value).map((e, t) => ({
50
50
  vnode: e,
51
51
  index: t + g.value
52
- })) : []), T = d([]), E = d([]), P = a(() => T.value.map((e) => J(e)).filter((e) => e instanceof Element)), Y = a(() => E.value.map((e) => J(e)).filter((e) => e instanceof Element)), L = () => {
52
+ })) : []), E = d([]), P = d([]), V = a(() => E.value.map((e) => J(e)).filter((e) => e instanceof Element)), Y = a(() => P.value.map((e) => J(e)).filter((e) => e instanceof Element)), L = () => {
53
53
  const e = f.value, t = A.value;
54
54
  return Array.from((e == null ? void 0 : e.children) || []).concat(Array.from((t == null ? void 0 : t.children) || []));
55
55
  }, O = () => {
@@ -74,7 +74,7 @@ const pe = { key: 0 }, ge = /* @__PURE__ */ K({
74
74
  if (!f.value)
75
75
  return;
76
76
  const e = L(), t = parseFloat(getComputedStyle(f.value).rowGap) || 0;
77
- V.value = e.reduce((n, l, s) => n + l.offsetWidth + (s > 0 ? t : 0), 0);
77
+ C.value = e.reduce((n, l, s) => n + l.offsetWidth + (s > 0 ? t : 0), 0);
78
78
  });
79
79
  },
80
80
  { immediate: !0 }
@@ -102,7 +102,7 @@ const pe = { key: 0 }, ge = /* @__PURE__ */ K({
102
102
  return R(
103
103
  () => p.autoScrollOn,
104
104
  (e) => {
105
- y && (y(), y = null), e && (y = de(P, e, (t) => {
105
+ y && (y(), y = null), e && (y = de(V, e, (t) => {
106
106
  t.currentTarget && ee(t.currentTarget);
107
107
  }));
108
108
  },
@@ -110,7 +110,7 @@ const pe = { key: 0 }, ge = /* @__PURE__ */ K({
110
110
  immediate: !0
111
111
  }
112
112
  ), v({
113
- children: a(() => P.value.concat(Y.value))
113
+ children: a(() => V.value.concat(Y.value))
114
114
  }), (e, t) => (r(), m("div", {
115
115
  class: "tr-suggestion-pills__wrapper",
116
116
  ref_key: "containerWrapperRef",
@@ -125,23 +125,23 @@ const pe = { key: 0 }, ge = /* @__PURE__ */ K({
125
125
  key: j(n) ? n.key : l,
126
126
  ref_for: !0,
127
127
  ref_key: "staticMaybeItemRefs",
128
- ref: T
128
+ ref: E
129
129
  }))), 128))
130
130
  ], 2),
131
131
  D("div", he, [
132
132
  q(se, { name: "tr-suggestion-pills__more" }, {
133
133
  default: re(() => [
134
- C.value.length ? (r(), m("div", {
134
+ T.value.length ? (r(), m("div", {
135
135
  key: 0,
136
136
  class: "tr-suggestion-pills__more",
137
137
  ref_key: "floatingItemsRef",
138
138
  ref: A
139
139
  }, [
140
- (r(!0), m(z, null, G(C.value, ({ vnode: n, index: l }) => (r(), S(b(n), {
140
+ (r(!0), m(z, null, G(T.value, ({ vnode: n, index: l }) => (r(), S(b(n), {
141
141
  key: j(n) ? n.key : l,
142
142
  ref_for: !0,
143
143
  ref_key: "floatingMaybeItemRefs",
144
- ref: E
144
+ ref: P
145
145
  }))), 128))
146
146
  ], 512)) : M("", !0)
147
147
  ]),