@opentiny/tiny-robot 0.3.0-alpha.1 → 0.3.0-alpha.3
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/action-group/index.js +16 -16
- package/dist/bubble/index.js +788 -777
- package/dist/container/index.js +10 -10
- package/dist/feedback/index.js +43 -43
- package/dist/flow-layout-buttons/index.js +10 -10
- package/dist/history/index.js +39 -39
- package/dist/index.d.ts +23 -7
- package/dist/question/index.js +66 -66
- package/dist/sender/index.js +130 -130
- package/dist/style.css +1 -1
- package/dist/suggestion/index.js +58 -58
- package/dist/suggestion-pills/index.js +1 -1
- package/dist/suggestion-popover/index.js +25 -25
- package/dist/tiny-robot-svgs.js +172 -172
- package/package.json +3 -3
package/dist/question/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { ref as m, computed as H, watch as D, defineComponent as
|
|
2
|
-
import {
|
|
1
|
+
import { ref as m, computed as H, watch as D, defineComponent as j, onMounted as Z, onBeforeUnmount as ne, createElementBlock as d, openBlock as i, normalizeClass as P, createElementVNode as t, withDirectives as le, Fragment as R, renderList as A, createVNode as T, unref as q, toDisplayString as S, vShow as ie, nextTick as ae, createCommentVNode as U, withModifiers as ce, normalizeStyle as ue, renderSlot as B, createTextVNode as ee, createBlock as K, withCtx as N } from "vue";
|
|
2
|
+
import { L as X, P as te, k as se, l as de, n as re } from "../tiny-robot-svgs.js";
|
|
3
3
|
import { i as me } from "../close.js";
|
|
4
4
|
import { B as ve } from "../index3.js";
|
|
5
5
|
function he(v = m([])) {
|
|
6
|
-
const
|
|
7
|
-
if (!
|
|
6
|
+
const w = m(""), y = m(!1), a = m(!1), r = m("light"), k = H(() => {
|
|
7
|
+
if (!w.value && v.value.length > 0)
|
|
8
8
|
return v.value[0].questions;
|
|
9
|
-
const s = v.value.find((l) => l.id ===
|
|
9
|
+
const s = v.value.find((l) => l.id === w.value);
|
|
10
10
|
return s ? s.questions : [];
|
|
11
|
-
}),
|
|
12
|
-
|
|
11
|
+
}), x = (s) => {
|
|
12
|
+
w.value = s;
|
|
13
13
|
}, p = () => {
|
|
14
14
|
a.value = !0;
|
|
15
15
|
}, _ = () => {
|
|
@@ -27,12 +27,12 @@ function he(v = m([])) {
|
|
|
27
27
|
return D(a, (s) => {
|
|
28
28
|
b(s);
|
|
29
29
|
}), {
|
|
30
|
-
activeCategory:
|
|
30
|
+
activeCategory: w,
|
|
31
31
|
isFloatingExpanded: y,
|
|
32
32
|
modalVisible: a,
|
|
33
33
|
currentTheme: r,
|
|
34
34
|
activeQuestions: k,
|
|
35
|
-
setActiveCategory:
|
|
35
|
+
setActiveCategory: x,
|
|
36
36
|
openModal: p,
|
|
37
37
|
closeModal: _,
|
|
38
38
|
toggleFloating: c,
|
|
@@ -46,7 +46,7 @@ function he(v = m([])) {
|
|
|
46
46
|
toggleBodyScroll: b
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-questions_expanded-wrapper" }, ge = { class: "tr-common-questions_expanded-area" }, ye = ["onClick"], ke = { class: "tr-common-questions_item_icon" }, _e = { class: "tr-common-questions_item_text" }, Ce = { class: "tr-common-questions_container" }, qe = ["onClick"], $e = { class: "tr-common-questions_item_icon" },
|
|
49
|
+
const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-questions_expanded-wrapper" }, ge = { class: "tr-common-questions_expanded-area" }, ye = ["onClick"], ke = { class: "tr-common-questions_item_icon" }, _e = { class: "tr-common-questions_item_text" }, Ce = { class: "tr-common-questions_container" }, qe = ["onClick"], $e = { class: "tr-common-questions_item_icon" }, we = { class: "tr-common-questions_item_text" }, xe = /* @__PURE__ */ j({
|
|
50
50
|
__name: "CommonQuestions",
|
|
51
51
|
props: {
|
|
52
52
|
questions: {
|
|
@@ -59,8 +59,8 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
emits: ["question-click", "toggle-expand", "hover-change"],
|
|
62
|
-
setup(v, { emit:
|
|
63
|
-
const y = v, a =
|
|
62
|
+
setup(v, { emit: w }) {
|
|
63
|
+
const y = v, a = w, r = m(null), k = m(!1), x = m(!1), p = m(!1), _ = m([]), c = m([]), b = m(0), f = m(null), o = H(() => c.value.length > 0), u = H(() => {
|
|
64
64
|
if (b.value <= 0 || c.value.length === 0) return [];
|
|
65
65
|
const e = [], h = [...c.value];
|
|
66
66
|
for (; h.length > 0; )
|
|
@@ -70,31 +70,31 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
70
70
|
if (h.length === 0) return 0;
|
|
71
71
|
const E = e.clientWidth, W = 8, g = document.createElement("div");
|
|
72
72
|
g.className = "tr-common-questions_item", g.style.visibility = "hidden", g.style.position = "absolute", e.appendChild(g);
|
|
73
|
-
let
|
|
73
|
+
let L = 0;
|
|
74
74
|
const z = Math.min(3, h.length);
|
|
75
|
-
for (let
|
|
76
|
-
g.innerHTML = `<span class="icon-placeholder"></span>${h[
|
|
77
|
-
const
|
|
78
|
-
|
|
75
|
+
for (let O = 0; O < z; O++) {
|
|
76
|
+
g.innerHTML = `<span class="icon-placeholder"></span>${h[O].text}`;
|
|
77
|
+
const G = g.offsetWidth + W + 24;
|
|
78
|
+
L += G;
|
|
79
79
|
}
|
|
80
|
-
const M =
|
|
80
|
+
const M = L / z;
|
|
81
81
|
return e.removeChild(g), {
|
|
82
82
|
maxItemsCount: Math.max(1, Math.floor((E - $) / M))
|
|
83
83
|
};
|
|
84
84
|
}, l = (e, h, $, E = 40) => {
|
|
85
|
-
const g = [],
|
|
85
|
+
const g = [], L = [];
|
|
86
86
|
let z = 0;
|
|
87
87
|
if (h.length === 0)
|
|
88
|
-
return { visible: g, hidden:
|
|
88
|
+
return { visible: g, hidden: L };
|
|
89
89
|
const M = document.createElement("div");
|
|
90
90
|
M.className = "tr-common-questions_item", M.style.visibility = "hidden", M.style.position = "absolute", e.appendChild(M);
|
|
91
|
-
for (let
|
|
92
|
-
const I = h[
|
|
91
|
+
for (let O = 0; O < h.length; O++) {
|
|
92
|
+
const I = h[O];
|
|
93
93
|
M.innerHTML = `<span class="icon-placeholder"></span>${I.text}`;
|
|
94
|
-
const
|
|
95
|
-
z +
|
|
94
|
+
const J = M.offsetWidth + 8 + 24, oe = $ - E;
|
|
95
|
+
z + J <= oe ? (z += J, g.push(I)) : L.push(I);
|
|
96
96
|
}
|
|
97
|
-
return e.removeChild(M), { visible: g, hidden:
|
|
97
|
+
return e.removeChild(M), { visible: g, hidden: L };
|
|
98
98
|
};
|
|
99
99
|
D(
|
|
100
100
|
() => y.isExpanded,
|
|
@@ -106,15 +106,15 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
106
106
|
if (await ae(), r.value) {
|
|
107
107
|
const e = r.value, h = e.clientWidth, $ = 40;
|
|
108
108
|
if (_.value = [], c.value = [], y.questions.length === 0) {
|
|
109
|
-
|
|
109
|
+
x.value = !1;
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
const { maxItemsCount: E } = s(e, y.questions, $);
|
|
113
113
|
b.value = E;
|
|
114
114
|
const { visible: W, hidden: g } = l(e, y.questions, h, $);
|
|
115
|
-
_.value = W, c.value = g, c.value.length > 0 && _.value.push(c.value[0]),
|
|
115
|
+
_.value = W, c.value = g, c.value.length > 0 && _.value.push(c.value[0]), x.value = c.value.length > 0, y.isExpanded || (p.value = !1);
|
|
116
116
|
}
|
|
117
|
-
},
|
|
117
|
+
}, F = () => {
|
|
118
118
|
f.value && (clearTimeout(f.value), f.value = null), k.value = !0, a("hover-change", !0);
|
|
119
119
|
}, Y = () => {
|
|
120
120
|
f.value = setTimeout(() => {
|
|
@@ -133,31 +133,31 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
133
133
|
const C = () => {
|
|
134
134
|
Q();
|
|
135
135
|
};
|
|
136
|
-
return
|
|
136
|
+
return Z(() => {
|
|
137
137
|
Q(), window.addEventListener("resize", C);
|
|
138
138
|
}), ne(() => {
|
|
139
139
|
window.removeEventListener("resize", C), f.value && (window.clearTimeout(f.value), f.value = null);
|
|
140
140
|
}), (e, h) => (i(), d("div", {
|
|
141
|
-
class:
|
|
141
|
+
class: P(["tr-common-questions", { expanded: p.value }]),
|
|
142
142
|
ref_key: "commonQuestionsRef",
|
|
143
143
|
ref: r,
|
|
144
|
-
onMouseenter:
|
|
144
|
+
onMouseenter: F,
|
|
145
145
|
onMouseleave: Y
|
|
146
146
|
}, [
|
|
147
147
|
t("div", pe, [
|
|
148
148
|
t("div", fe, [
|
|
149
149
|
le(t("div", ge, [
|
|
150
|
-
(i(!0), d(
|
|
150
|
+
(i(!0), d(R, null, A(u.value, ($, E) => (i(), d("div", {
|
|
151
151
|
key: `row-${E}`,
|
|
152
152
|
class: "tr-common-questions_row"
|
|
153
153
|
}, [
|
|
154
|
-
(i(!0), d(
|
|
154
|
+
(i(!0), d(R, null, A($, (W, g) => (i(), d("div", {
|
|
155
155
|
key: `hidden-${W.id}-${g}`,
|
|
156
156
|
class: "tr-common-questions_item",
|
|
157
|
-
onClick: (
|
|
157
|
+
onClick: (L) => n(W)
|
|
158
158
|
}, [
|
|
159
159
|
t("div", ke, [
|
|
160
|
-
T(q(
|
|
160
|
+
T(q(X))
|
|
161
161
|
]),
|
|
162
162
|
t("div", _e, S(W.text), 1)
|
|
163
163
|
], 8, ye))), 128))
|
|
@@ -167,15 +167,15 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
167
167
|
])
|
|
168
168
|
]),
|
|
169
169
|
t("div", Ce, [
|
|
170
|
-
(i(!0), d(
|
|
170
|
+
(i(!0), d(R, null, A(_.value, ($, E) => (i(), d("div", {
|
|
171
171
|
key: `visible-${$.id}-${E}`,
|
|
172
|
-
class:
|
|
172
|
+
class: P(["tr-common-questions_item", { "last-item": !p.value && E === _.value.length - 1 && o.value }]),
|
|
173
173
|
onClick: (W) => n($)
|
|
174
174
|
}, [
|
|
175
175
|
t("div", $e, [
|
|
176
|
-
T(q(
|
|
176
|
+
T(q(X))
|
|
177
177
|
]),
|
|
178
|
-
t("div",
|
|
178
|
+
t("div", we, S($.text), 1)
|
|
179
179
|
], 10, qe))), 128))
|
|
180
180
|
])
|
|
181
181
|
])
|
|
@@ -187,10 +187,10 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
187
187
|
}, We = ["onClick"], Me = { class: "category-icon" }, Te = { class: "tr-question-content" }, Be = {
|
|
188
188
|
key: 0,
|
|
189
189
|
class: "tr-question-loading"
|
|
190
|
-
}, Se = { key: 1 },
|
|
190
|
+
}, Se = { key: 1 }, Le = ["onClick"], Oe = {
|
|
191
191
|
key: 2,
|
|
192
192
|
class: "tr-question-empty"
|
|
193
|
-
}, ze = /* @__PURE__ */
|
|
193
|
+
}, ze = /* @__PURE__ */ j({
|
|
194
194
|
__name: "HotQuestions",
|
|
195
195
|
props: {
|
|
196
196
|
visible: {
|
|
@@ -215,8 +215,8 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
215
215
|
}
|
|
216
216
|
},
|
|
217
217
|
emits: ["update:visible", "close", "select-category", "question-click"],
|
|
218
|
-
setup(v, { emit:
|
|
219
|
-
const y = me(), a = v, r =
|
|
218
|
+
setup(v, { emit: w }) {
|
|
219
|
+
const y = me(), a = v, r = w, k = m(""), x = H(() => {
|
|
220
220
|
if (!k.value && a.categories.length > 0)
|
|
221
221
|
return a.categories[0].questions || [];
|
|
222
222
|
const o = a.categories.find((u) => u.id === k.value);
|
|
@@ -272,9 +272,9 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
272
272
|
])
|
|
273
273
|
]),
|
|
274
274
|
v.categories.length > 0 ? (i(), d("div", Qe, [
|
|
275
|
-
(i(!0), d(
|
|
275
|
+
(i(!0), d(R, null, A(v.categories, (s) => (i(), d("div", {
|
|
276
276
|
key: s.id,
|
|
277
|
-
class:
|
|
277
|
+
class: P(["tr-question-categories-item", { active: k.value === s.id }]),
|
|
278
278
|
onClick: (l) => _(s.id)
|
|
279
279
|
}, [
|
|
280
280
|
B(o.$slots, "category-label", { category: s }, () => [
|
|
@@ -290,8 +290,8 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
290
290
|
B(o.$slots, "loading-indicator", {}, () => [
|
|
291
291
|
u[2] || (u[2] = t("div", { class: "tr-question-loading-spinner" }, null, -1))
|
|
292
292
|
])
|
|
293
|
-
])) :
|
|
294
|
-
(i(!0), d(
|
|
293
|
+
])) : x.value.length > 0 ? (i(), d("ul", Se, [
|
|
294
|
+
(i(!0), d(R, null, A(x.value, (s, l) => (i(), d("li", {
|
|
295
295
|
key: s.id,
|
|
296
296
|
class: "tr-question-list-item",
|
|
297
297
|
onClick: (Q) => c(s)
|
|
@@ -303,8 +303,8 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
303
303
|
t("span", null, S(l + 1) + ".", 1),
|
|
304
304
|
ee(" " + S(s.text), 1)
|
|
305
305
|
])
|
|
306
|
-
], 8,
|
|
307
|
-
])) : (i(), d("div",
|
|
306
|
+
], 8, Le))), 128))
|
|
307
|
+
])) : (i(), d("div", Oe, [
|
|
308
308
|
B(o.$slots, "empty-state", {}, () => [
|
|
309
309
|
u[3] || (u[3] = t("p", null, "暂无相关问题", -1))
|
|
310
310
|
])
|
|
@@ -313,7 +313,7 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
313
313
|
], 36)
|
|
314
314
|
], 32)) : U("", !0);
|
|
315
315
|
}
|
|
316
|
-
}),
|
|
316
|
+
}), Re = ["data-theme"], Ae = { class: "tr-question__header" }, He = { class: "category-icon" }, V = /* @__PURE__ */ j({
|
|
317
317
|
__name: "index",
|
|
318
318
|
props: {
|
|
319
319
|
categories: { default: () => [] },
|
|
@@ -325,10 +325,10 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
325
325
|
loading: { type: Boolean, default: !1 }
|
|
326
326
|
},
|
|
327
327
|
emits: ["question-click", "select-category"],
|
|
328
|
-
setup(v, { expose:
|
|
328
|
+
setup(v, { expose: w, emit: y }) {
|
|
329
329
|
const a = v, r = () => {
|
|
330
330
|
p.value = !p.value;
|
|
331
|
-
}, k = y,
|
|
331
|
+
}, k = y, x = H(() => a.categories), p = m(a.initialExpanded), _ = m(!1), { modalVisible: c, currentTheme: b, setActiveCategory: f, openModal: o, closeModal: u, setTheme: s, refreshData: l } = he(x);
|
|
332
332
|
D(
|
|
333
333
|
() => a.theme,
|
|
334
334
|
(n) => {
|
|
@@ -337,24 +337,24 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
337
337
|
);
|
|
338
338
|
const Q = (n) => {
|
|
339
339
|
u(), k("question-click", n);
|
|
340
|
-
},
|
|
340
|
+
}, F = (n) => {
|
|
341
341
|
_.value = n;
|
|
342
342
|
}, Y = (n) => {
|
|
343
343
|
n && (f(n.id), k("select-category", n));
|
|
344
344
|
};
|
|
345
|
-
return
|
|
345
|
+
return Z(() => {
|
|
346
346
|
document.documentElement.setAttribute("data-theme", b.value);
|
|
347
|
-
}),
|
|
347
|
+
}), w({
|
|
348
348
|
openModal: o,
|
|
349
349
|
closeModal: u,
|
|
350
350
|
toggleFloating: r,
|
|
351
351
|
setActiveCategory: f,
|
|
352
352
|
refreshData: l
|
|
353
353
|
}), (n, C) => (i(), d("div", {
|
|
354
|
-
class:
|
|
354
|
+
class: P(["tr-question-container", [`theme-${n.theme}`]]),
|
|
355
355
|
"data-theme": n.theme
|
|
356
356
|
}, [
|
|
357
|
-
t("div",
|
|
357
|
+
t("div", Ae, [
|
|
358
358
|
t("div", {
|
|
359
359
|
class: "tr-question__trigger",
|
|
360
360
|
onClick: C[0] || (C[0] = //@ts-ignore
|
|
@@ -362,23 +362,23 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
362
362
|
}, [
|
|
363
363
|
T(q(te), { style: { color: "#1476ff" } })
|
|
364
364
|
]),
|
|
365
|
-
T(
|
|
365
|
+
T(xe, {
|
|
366
366
|
questions: n.commonQuestions,
|
|
367
367
|
isExpanded: p.value,
|
|
368
368
|
onQuestionClick: Q,
|
|
369
|
-
onHoverChange:
|
|
369
|
+
onHoverChange: F
|
|
370
370
|
}, null, 8, ["questions", "isExpanded"]),
|
|
371
371
|
_.value ? (i(), d("div", {
|
|
372
372
|
key: 0,
|
|
373
373
|
class: "tr-question__expand-button",
|
|
374
374
|
onClick: r
|
|
375
375
|
}, [
|
|
376
|
-
p.value ? (i(),
|
|
376
|
+
p.value ? (i(), K(q(re), { key: 1 })) : (i(), K(q(de), { key: 0 }))
|
|
377
377
|
])) : U("", !0)
|
|
378
378
|
]),
|
|
379
379
|
T(ze, {
|
|
380
380
|
visible: q(c),
|
|
381
|
-
categories:
|
|
381
|
+
categories: x.value,
|
|
382
382
|
"modal-width": n.modalWidth,
|
|
383
383
|
loading: n.loading,
|
|
384
384
|
"close-on-click-outside": n.closeOnClickOutside,
|
|
@@ -416,14 +416,14 @@ const pe = { class: "tr-common-questions_content" }, fe = { class: "tr-common-qu
|
|
|
416
416
|
]),
|
|
417
417
|
_: 3
|
|
418
418
|
}, 8, ["visible", "categories", "modal-width", "loading", "close-on-click-outside"])
|
|
419
|
-
], 10,
|
|
419
|
+
], 10, Re));
|
|
420
420
|
}
|
|
421
421
|
});
|
|
422
|
-
|
|
422
|
+
V.name = "TrQuestion";
|
|
423
423
|
const De = function(v) {
|
|
424
|
-
v.component(
|
|
424
|
+
v.component(V.name, V);
|
|
425
425
|
};
|
|
426
|
-
|
|
426
|
+
V.install = De;
|
|
427
427
|
export {
|
|
428
|
-
|
|
428
|
+
V as default
|
|
429
429
|
};
|