@opentiny/tiny-robot 0.2.0-alpha.0 → 0.2.0-alpha.1
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/ActionGroup.vue.d.ts +26 -0
- package/dist/action-group/ActionGroupItem.vue.d.ts +18 -0
- package/dist/action-group/index.d.ts +12 -0
- package/dist/action-group/index.type.d.ts +16 -0
- package/dist/feedback/components/SourceList.vue.d.ts +11 -0
- package/dist/feedback/components/index.d.ts +1 -0
- package/dist/feedback/index.d.ts +7 -0
- package/dist/feedback/index.type.d.ts +25 -0
- package/dist/feedback/index.vue.d.ts +13 -0
- package/dist/history/components/index.d.ts +2 -0
- package/dist/history/components/item-tag.vue.d.ts +5 -0
- package/dist/history/components/search-empty.vue.d.ts +7 -0
- package/dist/history/composables/index.d.ts +1 -0
- package/dist/history/composables/useEditItemTitle.d.ts +12 -0
- package/dist/history/index.d.ts +6 -0
- package/dist/history/index.type.d.ts +43 -0
- package/dist/history/index.vue.d.ts +2 -0
- package/dist/icon-button/index.d.ts +7 -0
- package/dist/icon-button/index.type.d.ts +7 -0
- package/dist/icon-button/index.vue.d.ts +6 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +57 -27
- package/dist/node_modules/.pnpm/@opentiny_utils@3.22.0/node_modules/@opentiny/utils/dist/index.es.js +1335 -884
- package/dist/node_modules/.pnpm/@opentiny_vue-common@3.22.0/node_modules/@opentiny/vue-common/lib/index.js +660 -144
- package/dist/node_modules/.pnpm/@opentiny_vue-hooks@3.22.0/node_modules/@opentiny/vue-hooks/dist/src/vue-popper.js +85 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-locale@3.22.0/node_modules/@opentiny/vue-locale/lib/index.js +1783 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.22.0/node_modules/@opentiny/vue-renderless/tooltip/index.js +77 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.22.0/node_modules/@opentiny/vue-renderless/tooltip/vue.js +90 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-tooltip@3.22.0/node_modules/@opentiny/vue-tooltip/lib/index.js +176 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-tooltip@3.22.0/node_modules/@opentiny/vue-tooltip/lib/pc.js +248 -0
- package/dist/node_modules/.pnpm/@vueuse_core@13.1.0_vue@3.5.13/node_modules/@vueuse/core/index.js +190 -0
- package/dist/node_modules/.pnpm/@vueuse_shared@13.1.0_vue@3.5.13/node_modules/@vueuse/shared/index.js +53 -0
- package/dist/packages/components/src/action-group/ActionGroup.vue.js +7 -0
- package/dist/packages/components/src/action-group/ActionGroup.vue2.js +97 -0
- package/dist/packages/components/src/action-group/ActionGroupItem.vue.js +14 -0
- package/dist/packages/components/src/action-group/ActionGroupItem.vue2.js +4 -0
- package/dist/packages/components/src/action-group/index.js +17 -0
- package/dist/packages/components/src/bubble/bubble.vue.js +2 -2
- package/dist/packages/components/src/bubble/bubble.vue2.js +46 -46
- package/dist/packages/components/src/container/index.vue.js +1 -1
- package/dist/packages/components/src/container/index.vue2.js +17 -17
- package/dist/packages/components/src/feedback/components/SourceList.vue.js +7 -0
- package/dist/packages/components/src/feedback/components/SourceList.vue2.js +52 -0
- package/dist/packages/components/src/feedback/index.js +9 -0
- package/dist/packages/components/src/feedback/index.vue.js +7 -0
- package/dist/packages/components/src/feedback/index.vue2.js +142 -0
- package/dist/packages/components/src/history/components/item-tag.vue.js +7 -0
- package/dist/packages/components/src/history/components/item-tag.vue2.js +21 -0
- package/dist/packages/components/src/history/components/search-empty.vue.js +7 -0
- package/dist/packages/components/src/history/components/search-empty.vue2.js +20 -0
- package/dist/packages/components/src/history/composables/useEditItemTitle.js +43 -0
- package/dist/packages/components/src/history/index.js +11 -0
- package/dist/packages/components/src/history/index.vue.js +7 -0
- package/dist/packages/components/src/history/index.vue2.js +130 -0
- package/dist/packages/components/src/icon-button/index.js +9 -0
- package/dist/packages/components/src/icon-button/index.vue.js +7 -0
- package/dist/packages/components/src/icon-button/index.vue2.js +40 -0
- package/dist/packages/components/src/prompts/prompt.vue.js +2 -2
- package/dist/packages/components/src/prompts/prompt.vue2.js +17 -15
- package/dist/packages/components/src/question/components/HotQuestions.vue.js +23 -23
- package/dist/packages/components/src/question/index.vue.js +18 -18
- package/dist/packages/components/src/sender/components/TemplateEditor.vue.js +7 -0
- package/dist/packages/components/src/sender/components/TemplateEditor.vue2.js +121 -0
- package/dist/packages/components/src/sender/index.vue.js +149 -128
- package/dist/packages/components/src/suggestion/components/CategoryNav.vue.js +38 -0
- package/dist/packages/components/src/suggestion/components/CategoryNav.vue2.js +4 -0
- package/dist/packages/components/src/suggestion/components/SuggestionCapsule.vue.js +107 -0
- package/dist/packages/components/src/suggestion/components/SuggestionCapsule.vue2.js +4 -0
- package/dist/packages/components/src/suggestion/components/SuggestionPanel.vue.js +123 -0
- package/dist/packages/components/src/suggestion/components/SuggestionPanel.vue2.js +4 -0
- package/dist/packages/components/src/suggestion/composables/useKeyboardNavigation.js +45 -0
- package/dist/packages/components/src/suggestion/composables/useTriggerDetection.js +17 -0
- package/dist/packages/components/src/suggestion/index.js +9 -0
- package/dist/packages/components/src/suggestion/index.vue.js +179 -0
- package/dist/packages/components/src/suggestion/index.vue2.js +4 -0
- package/dist/packages/components/src/suggestion/utils/dom.js +18 -0
- package/dist/packages/svgs/dist/tiny-robot-svgs.js +306 -90
- package/dist/question/components/HotQuestions.vue.d.ts +2 -2
- package/dist/sender/components/TemplateEditor.vue.d.ts +18 -0
- package/dist/sender/index.type.d.ts +47 -0
- package/dist/sender/index.vue.d.ts +68 -3
- package/dist/style.css +1 -1
- package/dist/suggestion/components/CategoryNav.vue.d.ts +45 -0
- package/dist/suggestion/components/SuggestionCapsule.vue.d.ts +32 -0
- package/dist/suggestion/components/SuggestionPanel.vue.d.ts +84 -0
- package/dist/suggestion/composables/useKeyboardNavigation.d.ts +18 -0
- package/dist/suggestion/composables/useSuggestionFilter.d.ts +10 -0
- package/dist/suggestion/composables/useTriggerDetection.d.ts +11 -0
- package/dist/suggestion/index.d.ts +7 -0
- package/dist/suggestion/index.type.d.ts +94 -0
- package/dist/suggestion/index.vue.d.ts +343 -0
- package/dist/suggestion/utils/dom.d.ts +20 -0
- package/package.json +4 -3
- package/src/action-group/ActionGroup.vue +232 -0
- package/src/action-group/ActionGroupItem.vue +9 -0
- package/src/action-group/index.ts +25 -0
- package/src/action-group/index.type.ts +20 -0
- package/src/bubble/bubble.vue +4 -14
- package/src/container/index.vue +1 -2
- package/src/feedback/components/SourceList.vue +112 -0
- package/src/feedback/components/index.ts +1 -0
- package/src/feedback/index.ts +12 -0
- package/src/feedback/index.type.ts +27 -0
- package/src/feedback/index.vue +166 -0
- package/src/history/components/index.ts +2 -0
- package/src/history/components/item-tag.vue +49 -0
- package/src/history/components/search-empty.vue +38 -0
- package/src/history/composables/index.ts +1 -0
- package/src/history/composables/useEditItemTitle.ts +75 -0
- package/src/history/index.ts +12 -0
- package/src/history/index.type.ts +50 -0
- package/src/history/index.vue +292 -0
- package/src/icon-button/index.ts +12 -0
- package/src/icon-button/index.type.ts +8 -0
- package/src/icon-button/index.vue +52 -0
- package/src/index.ts +33 -1
- package/src/prompts/prompt.vue +7 -21
- package/src/question/components/HotQuestions.vue +1 -1
- package/src/question/index.less +9 -10
- package/src/sender/components/TemplateEditor.vue +274 -0
- package/src/sender/index.less +17 -7
- package/src/sender/index.type.ts +51 -0
- package/src/sender/index.vue +56 -8
- package/src/sender/vars.less +3 -3
- package/src/suggestion/components/CategoryNav.vue +38 -0
- package/src/suggestion/components/SuggestionCapsule.vue +183 -0
- package/src/suggestion/components/SuggestionPanel.vue +147 -0
- package/src/suggestion/composables/useKeyboardNavigation.ts +101 -0
- package/src/suggestion/composables/useSuggestionFilter.ts +34 -0
- package/src/suggestion/composables/useTriggerDetection.ts +46 -0
- package/src/suggestion/index.less +497 -0
- package/src/suggestion/index.ts +12 -0
- package/src/suggestion/index.type.ts +101 -0
- package/src/suggestion/index.vue +338 -0
- package/src/suggestion/utils/dom.ts +66 -0
- package/src/suggestion/vars.less +141 -0
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import { useInputHandler as
|
|
4
|
-
import { useKeyboardHandler as
|
|
5
|
-
import { useSpeechHandler as
|
|
6
|
-
import
|
|
1
|
+
import { defineComponent as ee, ref as w, computed as a, watch as te, createElementBlock as n, openBlock as o, normalizeClass as K, createElementVNode as p, createVNode as f, createCommentVNode as u, Transition as B, withCtx as L, renderSlot as _, createBlock as W, unref as i, isRef as se, normalizeStyle as oe, toDisplayString as C, Fragment as le, renderList as ne } from "vue";
|
|
2
|
+
import ae from "../../../../node_modules/.pnpm/@opentiny_vue-input@3.21.0/node_modules/@opentiny/vue-input/lib/index.js";
|
|
3
|
+
import { useInputHandler as ie } from "./composables/useInputHandler.js";
|
|
4
|
+
import { useKeyboardHandler as re } from "./composables/useKeyboardHandler.js";
|
|
5
|
+
import { useSpeechHandler as ue } from "./composables/useSpeechHandler.js";
|
|
6
|
+
import H from "./components/ActionButtons.vue.js";
|
|
7
|
+
import de from "./components/TemplateEditor.vue.js";
|
|
7
8
|
/* empty css */
|
|
8
|
-
const
|
|
9
|
+
const pe = ["data-theme"], ce = { class: "tiny-sender__container" }, me = { class: "tiny-sender__input-wrapper" }, fe = {
|
|
9
10
|
key: 0,
|
|
10
11
|
class: "tiny-sender__header-slot"
|
|
11
|
-
},
|
|
12
|
+
}, he = {
|
|
12
13
|
key: 0,
|
|
13
14
|
class: "tiny-sender__prefix-slot"
|
|
14
|
-
},
|
|
15
|
+
}, ye = { class: "tiny-sender__content-area" }, ve = {
|
|
15
16
|
key: 1,
|
|
16
17
|
class: "tiny-sender__actions-slot"
|
|
17
|
-
},
|
|
18
|
+
}, ge = { class: "tiny-sender__buttons-container" }, be = {
|
|
18
19
|
key: 0,
|
|
19
20
|
class: "tiny-sender__footer-slot"
|
|
20
|
-
},
|
|
21
|
+
}, we = {
|
|
21
22
|
key: 0,
|
|
22
23
|
class: "tiny-sender__word-limit"
|
|
23
|
-
},
|
|
24
|
+
}, _e = {
|
|
24
25
|
key: 1,
|
|
25
26
|
class: "tiny-sender__toolbar"
|
|
26
|
-
},
|
|
27
|
+
}, Ce = { class: "tiny-sender__buttons-container" }, Se = {
|
|
27
28
|
key: 0,
|
|
28
29
|
class: "tiny-sender__suggestions"
|
|
29
|
-
},
|
|
30
|
+
}, ke = ["onClick"], $e = {
|
|
30
31
|
key: 0,
|
|
31
32
|
class: "tiny-sender__error"
|
|
32
|
-
},
|
|
33
|
+
}, ze = /* @__PURE__ */ ee({
|
|
33
34
|
__name: "index",
|
|
34
35
|
props: {
|
|
35
36
|
autofocus: { type: Boolean, default: !1 },
|
|
@@ -48,187 +49,207 @@ const oe = ["data-theme"], ne = { class: "tiny-sender__container" }, le = { clas
|
|
|
48
49
|
placeholder: { default: "请输入内容..." },
|
|
49
50
|
showWordLimit: { type: Boolean, default: !1 },
|
|
50
51
|
suggestions: {},
|
|
51
|
-
theme: { default: "light" }
|
|
52
|
+
theme: { default: "light" },
|
|
53
|
+
template: { default: "" },
|
|
54
|
+
hasContent: { type: Boolean, default: void 0 }
|
|
52
55
|
},
|
|
53
|
-
emits: ["update:modelValue", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel"],
|
|
54
|
-
setup(
|
|
55
|
-
const t =
|
|
56
|
-
|
|
57
|
-
},
|
|
56
|
+
emits: ["update:modelValue", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel", "reset-template"],
|
|
57
|
+
setup(N, { expose: O, emit: q }) {
|
|
58
|
+
const t = N, l = q, c = w(null), h = w(null), I = a(() => !!t.template), { inputValue: s, isComposing: y, clearInput: D } = ie(t, l), S = () => {
|
|
59
|
+
D(), t.template && l("reset-template");
|
|
60
|
+
}, v = w(!1), T = a(() => !t.suggestions || !s.value ? [] : t.suggestions.filter((e) => e.toLowerCase().includes(s.value.toLowerCase()))), U = (e) => {
|
|
61
|
+
s.value = e, v.value = !1, l("suggestion-select", e);
|
|
62
|
+
}, F = (e) => {
|
|
63
|
+
s.value = e, l("update:modelValue", e);
|
|
64
|
+
}, V = () => {
|
|
65
|
+
h.value && h.value.activateFirstField();
|
|
66
|
+
}, M = a(() => ({
|
|
58
67
|
...typeof t.speech == "object" ? t.speech : {},
|
|
59
|
-
onStart: () =>
|
|
60
|
-
onEnd: (e) =>
|
|
61
|
-
onInterim: (e) =>
|
|
68
|
+
onStart: () => l("speech-start"),
|
|
69
|
+
onEnd: (e) => l("speech-end", e),
|
|
70
|
+
onInterim: (e) => l("speech-interim", e),
|
|
62
71
|
onFinal: (e) => {
|
|
63
|
-
s.value = e,
|
|
72
|
+
s.value = e, l("speech-end", e);
|
|
64
73
|
},
|
|
65
74
|
onError: (e) => {
|
|
66
|
-
|
|
75
|
+
Y(e.message), l("speech-error", e);
|
|
67
76
|
}
|
|
68
|
-
})), { speechState: g, start:
|
|
69
|
-
g.isRecording ?
|
|
70
|
-
}, { handleKeyPress:
|
|
77
|
+
})), { speechState: g, start: E, stop: R } = ue(M.value), k = () => {
|
|
78
|
+
g.isRecording ? R() : E();
|
|
79
|
+
}, { handleKeyPress: P, triggerSubmit: $ } = re(
|
|
71
80
|
t,
|
|
72
|
-
|
|
81
|
+
l,
|
|
73
82
|
s,
|
|
74
|
-
f,
|
|
75
|
-
g,
|
|
76
83
|
y,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
},
|
|
84
|
+
g,
|
|
85
|
+
v,
|
|
86
|
+
k
|
|
87
|
+
), A = (e) => {
|
|
88
|
+
l("focus", e);
|
|
89
|
+
}, G = (e) => {
|
|
90
|
+
l("blur", e);
|
|
91
|
+
}, J = a(() => t.mode === "multiple" ? { minRows: 2, maxRows: 5 } : { maxRows: 1 }), Q = a(
|
|
83
92
|
() => ({
|
|
84
93
|
display: "flex",
|
|
85
94
|
justifyContent: t.showWordLimit && t.maxLength !== 1 / 0 ? "space-between" : "flex-end",
|
|
86
95
|
alignItems: "center"
|
|
87
96
|
})
|
|
88
|
-
),
|
|
89
|
-
"is-disabled":
|
|
90
|
-
"is-loading":
|
|
91
|
-
"has-error": !!
|
|
92
|
-
})),
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
|
|
97
|
+
), b = a(() => t.disabled), j = a(() => t.loading), z = a(() => t.hasContent !== void 0 ? t.hasContent : !!s.value), X = a(() => ({
|
|
98
|
+
"is-disabled": b.value,
|
|
99
|
+
"is-loading": j.value,
|
|
100
|
+
"has-error": !!m.value
|
|
101
|
+
})), m = w(""), Y = (e) => {
|
|
102
|
+
m.value = e, setTimeout(() => m.value = "", 5e3);
|
|
103
|
+
}, Z = () => {
|
|
104
|
+
y.value = !1, setTimeout(() => y.value = !1, 50);
|
|
96
105
|
};
|
|
97
|
-
return
|
|
98
|
-
|
|
99
|
-
}),
|
|
106
|
+
return te(s, () => {
|
|
107
|
+
v.value = !!t.suggestions && !!s.value;
|
|
108
|
+
}), O({
|
|
100
109
|
focus: () => {
|
|
101
|
-
if (
|
|
102
|
-
|
|
110
|
+
if (I.value && h.value)
|
|
111
|
+
V();
|
|
112
|
+
else if (c.value)
|
|
113
|
+
c.value.focus();
|
|
103
114
|
else {
|
|
104
115
|
const e = document.querySelector(".tiny-input__inner");
|
|
105
116
|
e == null || e.focus();
|
|
106
117
|
}
|
|
107
118
|
},
|
|
108
119
|
blur: () => {
|
|
109
|
-
if (
|
|
110
|
-
|
|
120
|
+
if (c.value)
|
|
121
|
+
c.value.blur();
|
|
111
122
|
else {
|
|
112
123
|
const e = document.querySelector(".tiny-input__inner");
|
|
113
124
|
e == null || e.blur();
|
|
114
125
|
}
|
|
115
126
|
},
|
|
116
|
-
clear:
|
|
117
|
-
submit:
|
|
118
|
-
startSpeech:
|
|
119
|
-
stopSpeech:
|
|
120
|
-
|
|
121
|
-
|
|
127
|
+
clear: S,
|
|
128
|
+
submit: $,
|
|
129
|
+
startSpeech: E,
|
|
130
|
+
stopSpeech: R,
|
|
131
|
+
activateTemplateFirstField: V
|
|
132
|
+
}), (e, r) => (o(), n("div", {
|
|
133
|
+
class: K(["tiny-sender", [X.value, `theme-${e.theme}`, `mode-${e.mode}`]]),
|
|
122
134
|
"data-theme": e.theme
|
|
123
135
|
}, [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
p("div", ce, [
|
|
137
|
+
p("div", me, [
|
|
138
|
+
f(B, { name: "tiny-sender-slide-down" }, {
|
|
127
139
|
default: L(() => [
|
|
128
|
-
e.$slots.header ? (
|
|
129
|
-
|
|
130
|
-
])) :
|
|
140
|
+
e.$slots.header ? (o(), n("div", fe, [
|
|
141
|
+
_(e.$slots, "header")
|
|
142
|
+
])) : u("", !0)
|
|
131
143
|
]),
|
|
132
144
|
_: 3
|
|
133
145
|
}),
|
|
134
|
-
|
|
135
|
-
class:
|
|
146
|
+
p("div", {
|
|
147
|
+
class: K(["tiny-sender__input-row", { "has-prefix": e.$slots.prefix, "has-header": e.$slots.header }])
|
|
136
148
|
}, [
|
|
137
|
-
e.$slots.prefix ? (
|
|
138
|
-
|
|
139
|
-
])) :
|
|
140
|
-
|
|
141
|
-
|
|
149
|
+
e.$slots.prefix ? (o(), n("div", he, [
|
|
150
|
+
_(e.$slots, "prefix")
|
|
151
|
+
])) : u("", !0),
|
|
152
|
+
p("div", ye, [
|
|
153
|
+
I.value ? (o(), W(de, {
|
|
154
|
+
key: 0,
|
|
155
|
+
ref_key: "templateEditorRef",
|
|
156
|
+
ref: h,
|
|
157
|
+
template: e.template,
|
|
158
|
+
value: i(s),
|
|
159
|
+
"onUpdate:value": F,
|
|
160
|
+
onInput: F
|
|
161
|
+
}, null, 8, ["template", "value"])) : (o(), W(i(ae), {
|
|
162
|
+
key: 1,
|
|
142
163
|
ref_key: "inputRef",
|
|
143
|
-
ref:
|
|
144
|
-
autosize:
|
|
145
|
-
type:
|
|
146
|
-
readonly:
|
|
147
|
-
resize:
|
|
148
|
-
modelValue:
|
|
149
|
-
"onUpdate:modelValue":
|
|
150
|
-
disabled:
|
|
164
|
+
ref: c,
|
|
165
|
+
autosize: J.value,
|
|
166
|
+
type: "textarea",
|
|
167
|
+
readonly: j.value,
|
|
168
|
+
resize: "none",
|
|
169
|
+
modelValue: i(s),
|
|
170
|
+
"onUpdate:modelValue": r[0] || (r[0] = (d) => se(s) ? s.value = d : null),
|
|
171
|
+
disabled: b.value,
|
|
151
172
|
placeholder: e.placeholder,
|
|
152
173
|
maxlength: e.maxLength,
|
|
153
174
|
autofocus: e.autofocus,
|
|
154
|
-
onKeydown:
|
|
155
|
-
onCompositionstart:
|
|
156
|
-
onCompositionend:
|
|
157
|
-
onFocus:
|
|
158
|
-
onBlur:
|
|
159
|
-
}, null, 8, ["autosize", "
|
|
175
|
+
onKeydown: i(P),
|
|
176
|
+
onCompositionstart: r[1] || (r[1] = (d) => y.value = !0),
|
|
177
|
+
onCompositionend: Z,
|
|
178
|
+
onFocus: A,
|
|
179
|
+
onBlur: G
|
|
180
|
+
}, null, 8, ["autosize", "readonly", "modelValue", "disabled", "placeholder", "maxlength", "autofocus", "onKeydown"]))
|
|
160
181
|
]),
|
|
161
|
-
e.mode === "single" ? (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
182
|
+
e.mode === "single" ? (o(), n("div", ve, [
|
|
183
|
+
p("div", ge, [
|
|
184
|
+
_(e.$slots, "actions"),
|
|
185
|
+
f(H, {
|
|
165
186
|
class: "inline-buttons",
|
|
166
187
|
"allow-speech": e.allowSpeech,
|
|
167
188
|
"allow-files": e.allowFiles,
|
|
168
189
|
loading: e.loading,
|
|
169
|
-
disabled:
|
|
190
|
+
disabled: b.value,
|
|
170
191
|
"show-clear": e.clearable,
|
|
171
|
-
"has-content":
|
|
172
|
-
"speech-status":
|
|
192
|
+
"has-content": z.value,
|
|
193
|
+
"speech-status": i(g),
|
|
173
194
|
"submit-type": e.submitType,
|
|
174
|
-
onClear:
|
|
175
|
-
onToggleSpeech:
|
|
176
|
-
onSubmit:
|
|
177
|
-
onCancel:
|
|
178
|
-
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "
|
|
195
|
+
onClear: S,
|
|
196
|
+
onToggleSpeech: k,
|
|
197
|
+
onSubmit: i($),
|
|
198
|
+
onCancel: r[2] || (r[2] = (d) => e.$emit("cancel"))
|
|
199
|
+
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "onSubmit"])
|
|
179
200
|
])
|
|
180
|
-
])) :
|
|
201
|
+
])) : u("", !0)
|
|
181
202
|
], 2),
|
|
182
|
-
|
|
203
|
+
f(B, { name: "tiny-sender-slide-up" }, {
|
|
183
204
|
default: L(() => [
|
|
184
|
-
e.$slots.footer ? (
|
|
185
|
-
|
|
186
|
-
])) : e.mode !== "single" || e.showWordLimit && e.maxLength !== 1 / 0 ? (
|
|
205
|
+
e.$slots.footer ? (o(), n("div", be, [
|
|
206
|
+
_(e.$slots, "footer")
|
|
207
|
+
])) : e.mode !== "single" || e.showWordLimit && e.maxLength !== 1 / 0 ? (o(), n("div", {
|
|
187
208
|
key: 1,
|
|
188
|
-
style:
|
|
209
|
+
style: oe(Q.value),
|
|
189
210
|
class: "tiny-sender__footer-slot tiny-sender__bottom-row"
|
|
190
211
|
}, [
|
|
191
|
-
e.showWordLimit && e.maxLength !== 1 / 0 ? (
|
|
192
|
-
e.mode === "multiple" ? (
|
|
193
|
-
|
|
194
|
-
|
|
212
|
+
e.showWordLimit && e.maxLength !== 1 / 0 ? (o(), n("div", we, C(i(s).length) + "/" + C(e.maxLength), 1)) : u("", !0),
|
|
213
|
+
e.mode === "multiple" ? (o(), n("div", _e, [
|
|
214
|
+
p("div", Ce, [
|
|
215
|
+
f(H, {
|
|
195
216
|
"allow-speech": e.allowSpeech,
|
|
196
217
|
"allow-files": e.allowFiles,
|
|
197
218
|
loading: e.loading,
|
|
198
|
-
disabled:
|
|
219
|
+
disabled: b.value,
|
|
199
220
|
"show-clear": e.clearable,
|
|
200
|
-
"has-content":
|
|
201
|
-
"speech-status":
|
|
221
|
+
"has-content": z.value,
|
|
222
|
+
"speech-status": i(g),
|
|
202
223
|
"submit-type": e.submitType,
|
|
203
|
-
onClear:
|
|
204
|
-
onToggleSpeech:
|
|
205
|
-
onSubmit:
|
|
206
|
-
onCancel:
|
|
207
|
-
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "
|
|
224
|
+
onClear: S,
|
|
225
|
+
onToggleSpeech: k,
|
|
226
|
+
onSubmit: i($),
|
|
227
|
+
onCancel: r[3] || (r[3] = (d) => e.$emit("cancel"))
|
|
228
|
+
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "onSubmit"])
|
|
208
229
|
])
|
|
209
|
-
])) :
|
|
210
|
-
], 4)) :
|
|
230
|
+
])) : u("", !0)
|
|
231
|
+
], 4)) : u("", !0)
|
|
211
232
|
]),
|
|
212
233
|
_: 3
|
|
213
234
|
})
|
|
214
235
|
])
|
|
215
236
|
]),
|
|
216
|
-
|
|
237
|
+
f(B, { name: "tiny-sender-slide-up" }, {
|
|
217
238
|
default: L(() => [
|
|
218
|
-
|
|
219
|
-
(
|
|
220
|
-
key:
|
|
239
|
+
v.value && T.value.length ? (o(), n("div", Se, [
|
|
240
|
+
(o(!0), n(le, null, ne(T.value, (d, x) => (o(), n("div", {
|
|
241
|
+
key: x,
|
|
221
242
|
class: "suggestion-item",
|
|
222
|
-
onClick: (
|
|
223
|
-
},
|
|
224
|
-
])) :
|
|
243
|
+
onClick: (Be) => U(d)
|
|
244
|
+
}, C(d), 9, ke))), 128))
|
|
245
|
+
])) : u("", !0)
|
|
225
246
|
]),
|
|
226
247
|
_: 1
|
|
227
248
|
}),
|
|
228
|
-
|
|
229
|
-
], 10,
|
|
249
|
+
m.value ? (o(), n("div", $e, C(m.value), 1)) : u("", !0)
|
|
250
|
+
], 10, pe));
|
|
230
251
|
}
|
|
231
252
|
});
|
|
232
253
|
export {
|
|
233
|
-
|
|
254
|
+
ze as default
|
|
234
255
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineComponent as l, createElementBlock as t, openBlock as o, Fragment as d, renderList as m, normalizeClass as u, renderSlot as g, createCommentVNode as p, createElementVNode as C, toDisplayString as s } from "vue";
|
|
2
|
+
const _ = { class: "tr-suggestion-categories" }, v = ["onClick"], y = {
|
|
3
|
+
key: 0,
|
|
4
|
+
class: "category-icon"
|
|
5
|
+
}, S = /* @__PURE__ */ l({
|
|
6
|
+
__name: "CategoryNav",
|
|
7
|
+
props: {
|
|
8
|
+
categories: {
|
|
9
|
+
type: Array,
|
|
10
|
+
required: !0
|
|
11
|
+
},
|
|
12
|
+
activeCategory: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: ""
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
emits: ["category-select"],
|
|
18
|
+
setup(n, { emit: r }) {
|
|
19
|
+
const a = r, c = (i) => {
|
|
20
|
+
a("category-select", i);
|
|
21
|
+
};
|
|
22
|
+
return (i, k) => (o(), t("div", _, [
|
|
23
|
+
(o(!0), t(d, null, m(n.categories, (e) => (o(), t("div", {
|
|
24
|
+
key: e.id,
|
|
25
|
+
class: u(["tr-suggestion-categories-item", { active: n.activeCategory === e.id }]),
|
|
26
|
+
onClick: (f) => c(e.id)
|
|
27
|
+
}, [
|
|
28
|
+
g(i.$slots, "category-label", { category: e }, () => [
|
|
29
|
+
e.icon ? (o(), t("div", y, s(e.icon), 1)) : p("", !0),
|
|
30
|
+
C("span", null, s(e.label), 1)
|
|
31
|
+
])
|
|
32
|
+
], 10, v))), 128))
|
|
33
|
+
]));
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
export {
|
|
37
|
+
S as default
|
|
38
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { defineComponent as L, ref as a, computed as N, watch as O, watchEffect as T, onMounted as V, onBeforeUnmount as q, createElementBlock as c, openBlock as l, normalizeClass as A, createElementVNode as s, withDirectives as F, Fragment as k, renderList as y, createVNode as W, unref as $, toDisplayString as B, vShow as H, nextTick as P } from "vue";
|
|
2
|
+
import { IconEdit as R } from "../../../../svgs/dist/tiny-robot-svgs.js";
|
|
3
|
+
import { getCachedTextWidth as z } from "../utils/dom.js";
|
|
4
|
+
const U = { class: "tr-common-suggestions_content" }, Y = { class: "tr-common-suggestions_expanded-wrapper" }, j = { class: "tr-common-suggestions_expanded-area" }, G = ["onClick"], J = { class: "tr-common-suggestions_item_icon" }, K = { class: "tr-common-suggestions_item_text" }, Q = { class: "tr-common-suggestions_container" }, X = ["onClick"], Z = { class: "tr-common-suggestions_item_icon" }, ee = { class: "tr-common-suggestions_item_text" }, oe = /* @__PURE__ */ L({
|
|
5
|
+
__name: "SuggestionCapsule",
|
|
6
|
+
props: {
|
|
7
|
+
suggestions: {
|
|
8
|
+
type: Array,
|
|
9
|
+
required: !0
|
|
10
|
+
},
|
|
11
|
+
isExpanded: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: !1
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
emits: ["suggestion-click", "show-expand-button"],
|
|
17
|
+
setup(M, { emit: I }) {
|
|
18
|
+
const n = M, _ = I, u = a(null), p = a(!1), f = a(!1), x = a([]), r = a([]), w = a(0), v = a(null), D = N(() => {
|
|
19
|
+
if (w.value <= 0 || r.value.length === 0) return [];
|
|
20
|
+
const e = [], d = [...r.value];
|
|
21
|
+
for (; d.length > 0; )
|
|
22
|
+
e.push(d.splice(0, w.value));
|
|
23
|
+
return e.reverse();
|
|
24
|
+
}), C = async () => {
|
|
25
|
+
if (await P(), !u.value || n.suggestions.length === 0) {
|
|
26
|
+
p.value = !1, _("show-expand-button", !1);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const d = u.value.clientWidth;
|
|
30
|
+
x.value = [], r.value = [];
|
|
31
|
+
let t = 0;
|
|
32
|
+
const g = 8;
|
|
33
|
+
let o = 0;
|
|
34
|
+
const h = Math.min(3, n.suggestions.length);
|
|
35
|
+
for (let i = 0; i < h; i++) {
|
|
36
|
+
const m = z(n.suggestions[i].text, "tr-common-suggestions_item") + g;
|
|
37
|
+
o += m;
|
|
38
|
+
}
|
|
39
|
+
const b = o / h;
|
|
40
|
+
w.value = Math.max(1, Math.floor(d / b));
|
|
41
|
+
for (let i = 0; i < n.suggestions.length; i++) {
|
|
42
|
+
const m = n.suggestions[i], E = z(m.text, "tr-common-suggestions_item") + g;
|
|
43
|
+
t + E <= d ? (t += E, x.value.push(m)) : r.value.push(m);
|
|
44
|
+
}
|
|
45
|
+
p.value = r.value.length > 0, _("show-expand-button", p.value);
|
|
46
|
+
}, S = (e) => {
|
|
47
|
+
_("suggestion-click", e);
|
|
48
|
+
};
|
|
49
|
+
return O(
|
|
50
|
+
() => n.isExpanded,
|
|
51
|
+
(e) => {
|
|
52
|
+
f.value = e;
|
|
53
|
+
}
|
|
54
|
+
), T(() => {
|
|
55
|
+
u.value && n.suggestions.length && C();
|
|
56
|
+
}), V(() => {
|
|
57
|
+
u.value && (v.value = new ResizeObserver(() => {
|
|
58
|
+
C();
|
|
59
|
+
}), v.value.observe(u.value));
|
|
60
|
+
}), q(() => {
|
|
61
|
+
v.value && v.value.disconnect();
|
|
62
|
+
}), (e, d) => (l(), c("div", {
|
|
63
|
+
class: A(["tr-common-suggestions", { expanded: f.value }]),
|
|
64
|
+
ref_key: "capsuleRef",
|
|
65
|
+
ref: u
|
|
66
|
+
}, [
|
|
67
|
+
s("div", U, [
|
|
68
|
+
s("div", Y, [
|
|
69
|
+
F(s("div", j, [
|
|
70
|
+
(l(!0), c(k, null, y(D.value, (t, g) => (l(), c("div", {
|
|
71
|
+
key: `row-${g}`,
|
|
72
|
+
class: "tr-common-suggestions_row"
|
|
73
|
+
}, [
|
|
74
|
+
(l(!0), c(k, null, y(t, (o, h) => (l(), c("div", {
|
|
75
|
+
key: `hidden-${o.id}-${h}`,
|
|
76
|
+
class: "tr-common-suggestions_item",
|
|
77
|
+
onClick: (b) => S(o)
|
|
78
|
+
}, [
|
|
79
|
+
s("div", J, [
|
|
80
|
+
W($(R))
|
|
81
|
+
]),
|
|
82
|
+
s("div", K, B(o.text), 1)
|
|
83
|
+
], 8, G))), 128))
|
|
84
|
+
]))), 128))
|
|
85
|
+
], 512), [
|
|
86
|
+
[H, f.value && r.value.length > 0]
|
|
87
|
+
])
|
|
88
|
+
]),
|
|
89
|
+
s("div", Q, [
|
|
90
|
+
(l(!0), c(k, null, y(x.value, (t, g) => (l(), c("div", {
|
|
91
|
+
key: `visible-${t.id}-${g}`,
|
|
92
|
+
class: "tr-common-suggestions_item",
|
|
93
|
+
onClick: (o) => S(t)
|
|
94
|
+
}, [
|
|
95
|
+
s("div", Z, [
|
|
96
|
+
W($(R))
|
|
97
|
+
]),
|
|
98
|
+
s("div", ee, B(t.text), 1)
|
|
99
|
+
], 8, X))), 128))
|
|
100
|
+
])
|
|
101
|
+
])
|
|
102
|
+
], 2));
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
export {
|
|
106
|
+
oe as default
|
|
107
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { defineComponent as N, ref as y, computed as B, createElementBlock as a, openBlock as i, createElementVNode as t, createBlock as z, createCommentVNode as f, renderSlot as d, createVNode as p, unref as g, toDisplayString as v, normalizeStyle as A, Fragment as D, renderList as E, normalizeClass as H } from "vue";
|
|
2
|
+
import K from "./CategoryNav.vue.js";
|
|
3
|
+
import { useKeyboardNavigation as M } from "../composables/useKeyboardNavigation.js";
|
|
4
|
+
import { IconHotQuestion as Q, IconClose as q } from "../../../../svgs/dist/tiny-robot-svgs.js";
|
|
5
|
+
const w = { class: "tr-suggestion-panel" }, F = { class: "tr-suggestion-header" }, L = { class: "tr-suggestion-header-left" }, P = { class: "tr-suggestion-header-icon" }, T = { class: "tr-suggestion-header-title" }, j = { class: "close-icon" }, G = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "tr-suggestion-loading"
|
|
8
|
+
}, J = { key: 1 }, O = ["onClick", "onMouseenter"], R = { class: "item-content" }, U = { class: "item-label" }, W = {
|
|
9
|
+
key: 0,
|
|
10
|
+
class: "item-description"
|
|
11
|
+
}, X = {
|
|
12
|
+
key: 2,
|
|
13
|
+
class: "tr-suggestion-empty"
|
|
14
|
+
}, se = /* @__PURE__ */ N({
|
|
15
|
+
__name: "SuggestionPanel",
|
|
16
|
+
props: {
|
|
17
|
+
items: {
|
|
18
|
+
type: Array,
|
|
19
|
+
required: !0
|
|
20
|
+
},
|
|
21
|
+
categories: {
|
|
22
|
+
type: Array,
|
|
23
|
+
default: () => []
|
|
24
|
+
},
|
|
25
|
+
loading: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: !1
|
|
28
|
+
},
|
|
29
|
+
title: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: "指令"
|
|
32
|
+
},
|
|
33
|
+
maxVisibleItems: {
|
|
34
|
+
type: Number,
|
|
35
|
+
default: 5
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
emits: ["close", "select", "category-select", "item-hover"],
|
|
39
|
+
setup(n, { expose: _, emit: k }) {
|
|
40
|
+
const l = n, c = k, C = y(l.items), { handleKeyDown: S, activeIndex: h } = M(C, {
|
|
41
|
+
initialIndex: 0,
|
|
42
|
+
onClose: () => c("close"),
|
|
43
|
+
onSelect: (e) => c("select", e)
|
|
44
|
+
}), r = y(l.categories.length > 0 ? l.categories[0].id : ""), u = B(() => {
|
|
45
|
+
if (l.categories.length === 0 || !r.value)
|
|
46
|
+
return l.items;
|
|
47
|
+
const e = l.categories.find((s) => s.id === r.value);
|
|
48
|
+
return e ? e.items : [];
|
|
49
|
+
}), I = (e) => {
|
|
50
|
+
r.value = e;
|
|
51
|
+
const s = l.categories.find((o) => o.id === e);
|
|
52
|
+
s && c("category-select", s);
|
|
53
|
+
}, $ = (e) => {
|
|
54
|
+
c("select", e);
|
|
55
|
+
}, b = () => {
|
|
56
|
+
c("close");
|
|
57
|
+
}, V = (e) => {
|
|
58
|
+
c("item-hover", e);
|
|
59
|
+
};
|
|
60
|
+
return _({
|
|
61
|
+
handleKeyDown: S
|
|
62
|
+
}), (e, s) => (i(), a("div", w, [
|
|
63
|
+
t("div", F, [
|
|
64
|
+
t("div", L, [
|
|
65
|
+
t("div", P, [
|
|
66
|
+
d(e.$slots, "title-icon", {}, () => [
|
|
67
|
+
p(g(Q))
|
|
68
|
+
])
|
|
69
|
+
]),
|
|
70
|
+
t("div", T, v(n.title), 1)
|
|
71
|
+
]),
|
|
72
|
+
t("span", {
|
|
73
|
+
class: "tr-suggestion-close-btn",
|
|
74
|
+
onClick: b
|
|
75
|
+
}, [
|
|
76
|
+
t("span", j, [
|
|
77
|
+
p(g(q))
|
|
78
|
+
])
|
|
79
|
+
])
|
|
80
|
+
]),
|
|
81
|
+
n.categories.length > 0 ? (i(), z(K, {
|
|
82
|
+
key: 0,
|
|
83
|
+
categories: n.categories,
|
|
84
|
+
"active-category": r.value,
|
|
85
|
+
onCategorySelect: I
|
|
86
|
+
}, null, 8, ["categories", "active-category"])) : f("", !0),
|
|
87
|
+
t("div", {
|
|
88
|
+
class: "tr-suggestion-content",
|
|
89
|
+
style: A({ "max-height": u.value.length > n.maxVisibleItems ? `${n.maxVisibleItems * 56}px` : "auto" })
|
|
90
|
+
}, [
|
|
91
|
+
n.loading ? (i(), a("div", G, [
|
|
92
|
+
d(e.$slots, "loading-indicator", {}, () => [
|
|
93
|
+
s[0] || (s[0] = t("div", { class: "tr-suggestion-loading-spinner" }, null, -1))
|
|
94
|
+
])
|
|
95
|
+
])) : u.value.length > 0 ? (i(), a("ul", J, [
|
|
96
|
+
(i(!0), a(D, null, E(u.value, (o, m) => (i(), a("li", {
|
|
97
|
+
key: o.id,
|
|
98
|
+
class: H(["tr-suggestion-list-item", { "tr-suggestion-item-active": m === g(h) }]),
|
|
99
|
+
onClick: (x) => $(o),
|
|
100
|
+
onMouseenter: (x) => V(m)
|
|
101
|
+
}, [
|
|
102
|
+
d(e.$slots, "item", {
|
|
103
|
+
item: o,
|
|
104
|
+
active: m === g(h)
|
|
105
|
+
}, () => [
|
|
106
|
+
t("div", R, [
|
|
107
|
+
t("div", U, v(o.text), 1),
|
|
108
|
+
o.description ? (i(), a("div", W, v(o.description), 1)) : f("", !0)
|
|
109
|
+
])
|
|
110
|
+
])
|
|
111
|
+
], 42, O))), 128))
|
|
112
|
+
])) : (i(), a("div", X, [
|
|
113
|
+
d(e.$slots, "empty", {}, () => [
|
|
114
|
+
s[1] || (s[1] = t("p", null, "无匹配结果", -1))
|
|
115
|
+
])
|
|
116
|
+
]))
|
|
117
|
+
], 4)
|
|
118
|
+
]));
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
export {
|
|
122
|
+
se as default
|
|
123
|
+
};
|