@opentiny/tiny-robot 0.2.0-alpha.0 → 0.2.0-alpha.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.
Files changed (164) hide show
  1. package/dist/action-group/ActionGroup.vue.d.ts +26 -0
  2. package/dist/action-group/ActionGroupItem.vue.d.ts +18 -0
  3. package/dist/action-group/index.d.ts +12 -0
  4. package/dist/action-group/index.type.d.ts +17 -0
  5. package/dist/bubble/index.d.ts +2 -2
  6. package/dist/bubble/index.type.d.ts +16 -18
  7. package/dist/feedback/components/SourceList.vue.d.ts +11 -0
  8. package/dist/feedback/components/index.d.ts +1 -0
  9. package/dist/feedback/index.d.ts +7 -0
  10. package/dist/feedback/index.type.d.ts +25 -0
  11. package/dist/feedback/index.vue.d.ts +13 -0
  12. package/dist/history/components/index.d.ts +2 -0
  13. package/dist/history/components/item-tag.vue.d.ts +5 -0
  14. package/dist/history/components/search-empty.vue.d.ts +7 -0
  15. package/dist/history/composables/index.d.ts +1 -0
  16. package/dist/history/composables/useEditItemTitle.d.ts +12 -0
  17. package/dist/history/index.d.ts +6 -0
  18. package/dist/history/index.type.d.ts +43 -0
  19. package/dist/history/index.vue.d.ts +2 -0
  20. package/dist/icon-button/index.d.ts +7 -0
  21. package/dist/icon-button/index.type.d.ts +6 -0
  22. package/dist/icon-button/index.vue.d.ts +6 -0
  23. package/dist/index.d.ts +10 -1
  24. package/dist/index.js +57 -27
  25. package/dist/node_modules/.pnpm/@opentiny_utils@3.22.0/node_modules/@opentiny/utils/dist/index.es.js +1335 -884
  26. package/dist/node_modules/.pnpm/@opentiny_vue-common@3.22.0/node_modules/@opentiny/vue-common/lib/index.js +660 -144
  27. package/dist/node_modules/.pnpm/@opentiny_vue-hooks@3.22.0/node_modules/@opentiny/vue-hooks/dist/src/vue-popper.js +85 -0
  28. package/dist/node_modules/.pnpm/@opentiny_vue-locale@3.22.0/node_modules/@opentiny/vue-locale/lib/index.js +1783 -0
  29. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.22.0/node_modules/@opentiny/vue-renderless/tooltip/index.js +77 -0
  30. package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.22.0/node_modules/@opentiny/vue-renderless/tooltip/vue.js +90 -0
  31. package/dist/node_modules/.pnpm/@opentiny_vue-tooltip@3.22.0/node_modules/@opentiny/vue-tooltip/lib/index.js +176 -0
  32. package/dist/node_modules/.pnpm/@opentiny_vue-tooltip@3.22.0/node_modules/@opentiny/vue-tooltip/lib/pc.js +248 -0
  33. package/dist/node_modules/.pnpm/@vueuse_core@13.1.0_vue@3.5.13/node_modules/@vueuse/core/index.js +310 -0
  34. package/dist/node_modules/.pnpm/@vueuse_shared@13.1.0_vue@3.5.13/node_modules/@vueuse/shared/index.js +110 -0
  35. package/dist/packages/components/src/action-group/ActionGroup.vue.js +7 -0
  36. package/dist/packages/components/src/action-group/ActionGroup.vue2.js +121 -0
  37. package/dist/packages/components/src/action-group/ActionGroupItem.vue.js +14 -0
  38. package/dist/packages/components/src/action-group/ActionGroupItem.vue2.js +4 -0
  39. package/dist/packages/components/src/action-group/index.js +17 -0
  40. package/dist/packages/components/src/bubble/Bubble.vue.js +7 -0
  41. package/dist/packages/components/src/bubble/Bubble.vue2.js +76 -0
  42. package/dist/packages/components/src/bubble/BubbleList.vue.js +7 -0
  43. package/dist/packages/components/src/bubble/BubbleList.vue2.js +50 -0
  44. package/dist/packages/components/src/bubble/index.js +2 -2
  45. package/dist/packages/components/src/container/index.vue.js +2 -2
  46. package/dist/packages/components/src/container/index.vue2.js +36 -36
  47. package/dist/packages/components/src/feedback/components/SourceList.vue.js +7 -0
  48. package/dist/packages/components/src/feedback/components/SourceList.vue2.js +52 -0
  49. package/dist/packages/components/src/feedback/index.js +9 -0
  50. package/dist/packages/components/src/feedback/index.vue.js +7 -0
  51. package/dist/packages/components/src/feedback/index.vue2.js +143 -0
  52. package/dist/packages/components/src/history/components/item-tag.vue.js +7 -0
  53. package/dist/packages/components/src/history/components/item-tag.vue2.js +21 -0
  54. package/dist/packages/components/src/history/components/search-empty.vue.js +7 -0
  55. package/dist/packages/components/src/history/components/search-empty.vue2.js +20 -0
  56. package/dist/packages/components/src/history/composables/useEditItemTitle.js +43 -0
  57. package/dist/packages/components/src/history/index.js +11 -0
  58. package/dist/packages/components/src/history/index.vue.js +7 -0
  59. package/dist/packages/components/src/history/index.vue2.js +130 -0
  60. package/dist/packages/components/src/icon-button/index.js +9 -0
  61. package/dist/packages/components/src/icon-button/index.vue.js +7 -0
  62. package/dist/packages/components/src/icon-button/index.vue2.js +22 -0
  63. package/dist/packages/components/src/prompts/prompt.vue.js +2 -2
  64. package/dist/packages/components/src/prompts/prompt.vue2.js +17 -15
  65. package/dist/packages/components/src/question/components/HotQuestions.vue.js +23 -23
  66. package/dist/packages/components/src/question/index.vue.js +18 -18
  67. package/dist/packages/components/src/sender/components/TemplateEditor.vue.js +7 -0
  68. package/dist/packages/components/src/sender/components/TemplateEditor.vue2.js +175 -0
  69. package/dist/packages/components/src/sender/index.vue.js +149 -128
  70. package/dist/packages/components/src/suggestion/components/CategoryNav.vue.js +38 -0
  71. package/dist/packages/components/src/suggestion/components/CategoryNav.vue2.js +4 -0
  72. package/dist/packages/components/src/suggestion/components/SuggestionCapsule.vue.js +107 -0
  73. package/dist/packages/components/src/suggestion/components/SuggestionCapsule.vue2.js +4 -0
  74. package/dist/packages/components/src/suggestion/components/SuggestionPanel.vue.js +123 -0
  75. package/dist/packages/components/src/suggestion/components/SuggestionPanel.vue2.js +4 -0
  76. package/dist/packages/components/src/suggestion/composables/useKeyboardNavigation.js +45 -0
  77. package/dist/packages/components/src/suggestion/composables/useTriggerDetection.js +17 -0
  78. package/dist/packages/components/src/suggestion/index.js +9 -0
  79. package/dist/packages/components/src/suggestion/index.vue.js +179 -0
  80. package/dist/packages/components/src/suggestion/index.vue2.js +4 -0
  81. package/dist/packages/components/src/suggestion/utils/dom.js +18 -0
  82. package/dist/packages/svgs/dist/tiny-robot-svgs.js +306 -90
  83. package/dist/question/components/HotQuestions.vue.d.ts +2 -2
  84. package/dist/sender/components/TemplateEditor.vue.d.ts +18 -0
  85. package/dist/sender/index.type.d.ts +47 -0
  86. package/dist/sender/index.vue.d.ts +70 -5
  87. package/dist/style.css +1 -1
  88. package/dist/suggestion/components/CategoryNav.vue.d.ts +45 -0
  89. package/dist/suggestion/components/SuggestionCapsule.vue.d.ts +32 -0
  90. package/dist/suggestion/components/SuggestionPanel.vue.d.ts +84 -0
  91. package/dist/suggestion/composables/useKeyboardNavigation.d.ts +18 -0
  92. package/dist/suggestion/composables/useSuggestionFilter.d.ts +10 -0
  93. package/dist/suggestion/composables/useTriggerDetection.d.ts +11 -0
  94. package/dist/suggestion/index.d.ts +7 -0
  95. package/dist/suggestion/index.type.d.ts +94 -0
  96. package/dist/suggestion/index.vue.d.ts +343 -0
  97. package/dist/suggestion/utils/dom.d.ts +20 -0
  98. package/package.json +4 -3
  99. package/src/action-group/ActionGroup.vue +247 -0
  100. package/src/action-group/ActionGroupItem.vue +9 -0
  101. package/src/action-group/index.ts +25 -0
  102. package/src/action-group/index.type.ts +21 -0
  103. package/src/bubble/Bubble.vue +153 -0
  104. package/src/bubble/BubbleList.vue +55 -0
  105. package/src/bubble/index.ts +2 -2
  106. package/src/bubble/index.type.ts +7 -21
  107. package/src/container/index.vue +10 -36
  108. package/src/feedback/components/SourceList.vue +112 -0
  109. package/src/feedback/components/index.ts +1 -0
  110. package/src/feedback/index.ts +12 -0
  111. package/src/feedback/index.type.ts +27 -0
  112. package/src/feedback/index.vue +166 -0
  113. package/src/history/components/index.ts +2 -0
  114. package/src/history/components/item-tag.vue +49 -0
  115. package/src/history/components/search-empty.vue +38 -0
  116. package/src/history/composables/index.ts +1 -0
  117. package/src/history/composables/useEditItemTitle.ts +75 -0
  118. package/src/history/index.ts +12 -0
  119. package/src/history/index.type.ts +50 -0
  120. package/src/history/index.vue +292 -0
  121. package/src/icon-button/index.ts +12 -0
  122. package/src/icon-button/index.type.ts +7 -0
  123. package/src/icon-button/index.vue +58 -0
  124. package/src/index.ts +33 -1
  125. package/src/prompts/prompt.vue +7 -21
  126. package/src/question/components/HotQuestions.vue +1 -1
  127. package/src/question/index.less +9 -10
  128. package/src/sender/components/TemplateEditor.vue +465 -0
  129. package/src/sender/index.less +17 -7
  130. package/src/sender/index.type.ts +51 -0
  131. package/src/sender/index.vue +56 -8
  132. package/src/sender/vars.less +3 -3
  133. package/src/suggestion/components/CategoryNav.vue +38 -0
  134. package/src/suggestion/components/SuggestionCapsule.vue +183 -0
  135. package/src/suggestion/components/SuggestionPanel.vue +147 -0
  136. package/src/suggestion/composables/useKeyboardNavigation.ts +101 -0
  137. package/src/suggestion/composables/useSuggestionFilter.ts +34 -0
  138. package/src/suggestion/composables/useTriggerDetection.ts +46 -0
  139. package/src/suggestion/index.less +497 -0
  140. package/src/suggestion/index.ts +12 -0
  141. package/src/suggestion/index.type.ts +101 -0
  142. package/src/suggestion/index.vue +338 -0
  143. package/src/suggestion/utils/dom.ts +66 -0
  144. package/src/suggestion/vars.less +141 -0
  145. package/dist/bubble/components/actions/copy.vue.d.ts +0 -10
  146. package/dist/bubble/components/actions/index.d.ts +0 -2
  147. package/dist/bubble/components/actions/refresh.vue.d.ts +0 -2
  148. package/dist/bubble/useScroll.d.ts +0 -4
  149. package/dist/packages/components/src/bubble/bubble-list.vue.js +0 -7
  150. package/dist/packages/components/src/bubble/bubble-list.vue2.js +0 -37
  151. package/dist/packages/components/src/bubble/bubble.vue.js +0 -7
  152. package/dist/packages/components/src/bubble/bubble.vue2.js +0 -118
  153. package/dist/packages/components/src/bubble/components/actions/copy.vue.js +0 -7
  154. package/dist/packages/components/src/bubble/components/actions/copy.vue2.js +0 -35
  155. package/dist/packages/components/src/bubble/components/actions/refresh.vue.js +0 -7
  156. package/dist/packages/components/src/bubble/components/actions/refresh.vue2.js +0 -16
  157. package/dist/packages/components/src/bubble/useScroll.js +0 -13
  158. package/src/bubble/bubble-list.vue +0 -42
  159. package/src/bubble/bubble.vue +0 -247
  160. package/src/bubble/components/actions/copy.vue +0 -54
  161. package/src/bubble/components/actions/index.ts +0 -2
  162. package/src/bubble/components/actions/refresh.vue +0 -31
  163. package/src/bubble/useScroll.ts +0 -14
  164. /package/dist/bubble/{bubble-list.vue.d.ts → BubbleList.vue.d.ts} +0 -0
@@ -1,35 +1,36 @@
1
- import { defineComponent as G, ref as $, computed as d, watch as J, createElementBlock as o, openBlock as n, normalizeClass as z, createElementVNode as c, createVNode as p, createCommentVNode as r, Transition as k, withCtx as L, renderSlot as b, unref as l, isRef as Q, normalizeStyle as X, toDisplayString as w, Fragment as Y, renderList as Z } from "vue";
2
- import x from "../../../../node_modules/.pnpm/@opentiny_vue-input@3.21.0/node_modules/@opentiny/vue-input/lib/index.js";
3
- import { useInputHandler as ee } from "./composables/useInputHandler.js";
4
- import { useKeyboardHandler as se } from "./composables/useKeyboardHandler.js";
5
- import { useSpeechHandler as te } from "./composables/useSpeechHandler.js";
6
- import j from "./components/ActionButtons.vue.js";
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 oe = ["data-theme"], ne = { class: "tiny-sender__container" }, le = { class: "tiny-sender__input-wrapper" }, ae = {
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
- }, ie = {
12
+ }, he = {
12
13
  key: 0,
13
14
  class: "tiny-sender__prefix-slot"
14
- }, re = { class: "tiny-sender__content-area" }, ue = {
15
+ }, ye = { class: "tiny-sender__content-area" }, ve = {
15
16
  key: 1,
16
17
  class: "tiny-sender__actions-slot"
17
- }, de = { class: "tiny-sender__buttons-container" }, ce = {
18
+ }, ge = { class: "tiny-sender__buttons-container" }, be = {
18
19
  key: 0,
19
20
  class: "tiny-sender__footer-slot"
20
- }, pe = {
21
+ }, we = {
21
22
  key: 0,
22
23
  class: "tiny-sender__word-limit"
23
- }, me = {
24
+ }, _e = {
24
25
  key: 1,
25
26
  class: "tiny-sender__toolbar"
26
- }, he = { class: "tiny-sender__buttons-container" }, fe = {
27
+ }, Ce = { class: "tiny-sender__buttons-container" }, Se = {
27
28
  key: 0,
28
29
  class: "tiny-sender__suggestions"
29
- }, ye = ["onClick"], ge = {
30
+ }, ke = ["onClick"], $e = {
30
31
  key: 0,
31
32
  class: "tiny-sender__error"
32
- }, Le = /* @__PURE__ */ G({
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(F, { expose: E, emit: K }) {
55
- const t = F, a = K, m = $(null), { inputValue: s, isComposing: f, clearInput: _ } = ee(t, a), y = $(!1), B = d(() => !t.suggestions || !s.value ? [] : t.suggestions.filter((e) => e.toLowerCase().includes(s.value.toLowerCase()))), R = (e) => {
56
- s.value = e, y.value = !1, a("suggestion-select", e);
57
- }, W = d(() => ({
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: () => a("speech-start"),
60
- onEnd: (e) => a("speech-end", e),
61
- onInterim: (e) => a("speech-interim", 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, a("speech-end", e);
72
+ s.value = e, l("speech-end", e);
64
73
  },
65
74
  onError: (e) => {
66
- P(e.message), a("speech-error", e);
75
+ Y(e.message), l("speech-error", e);
67
76
  }
68
- })), { speechState: g, start: V, stop: I } = te(W.value), S = () => {
69
- g.isRecording ? I() : V();
70
- }, { handleKeyPress: H, triggerSubmit: C } = se(
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
- a,
81
+ l,
73
82
  s,
74
- f,
75
- g,
76
83
  y,
77
- S
78
- ), N = (e) => {
79
- a("focus", e);
80
- }, O = (e) => {
81
- a("blur", e);
82
- }, q = d(() => t.mode === "multiple" ? "textarea" : "text"), D = d(
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
- ), v = d(() => t.disabled), T = d(() => t.loading), M = d(() => ({
89
- "is-disabled": v.value,
90
- "is-loading": T.value,
91
- "has-error": !!h.value
92
- })), h = $(""), P = (e) => {
93
- h.value = e, setTimeout(() => h.value = "", 5e3);
94
- }, U = () => {
95
- f.value = !1, setTimeout(() => f.value = !1, 50);
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 J(s, () => {
98
- y.value = !!t.suggestions && !!s.value;
99
- }), E({
106
+ return te(s, () => {
107
+ v.value = !!t.suggestions && !!s.value;
108
+ }), O({
100
109
  focus: () => {
101
- if (m.value)
102
- m.value.focus();
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 (m.value)
110
- m.value.blur();
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: C,
118
- startSpeech: V,
119
- stopSpeech: I
120
- }), (e, i) => (n(), o("div", {
121
- class: z(["tiny-sender", [M.value, `theme-${e.theme}`, `mode-${e.mode}`]]),
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
- c("div", ne, [
125
- c("div", le, [
126
- p(k, { name: "tiny-sender-slide-down" }, {
136
+ p("div", ce, [
137
+ p("div", me, [
138
+ f(B, { name: "tiny-sender-slide-down" }, {
127
139
  default: L(() => [
128
- e.$slots.header ? (n(), o("div", ae, [
129
- b(e.$slots, "header")
130
- ])) : r("", !0)
140
+ e.$slots.header ? (o(), n("div", fe, [
141
+ _(e.$slots, "header")
142
+ ])) : u("", !0)
131
143
  ]),
132
144
  _: 3
133
145
  }),
134
- c("div", {
135
- class: z(["tiny-sender__input-row", { "has-prefix": e.$slots.prefix, "has-header": e.$slots.header }])
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 ? (n(), o("div", ie, [
138
- b(e.$slots, "prefix")
139
- ])) : r("", !0),
140
- c("div", re, [
141
- p(l(x), {
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: m,
144
- autosize: e.autoSize,
145
- type: q.value,
146
- readonly: T.value,
147
- resize: e.mode === "multiple" ? "none" : void 0,
148
- modelValue: l(s),
149
- "onUpdate:modelValue": i[0] || (i[0] = (u) => Q(s) ? s.value = u : null),
150
- disabled: v.value,
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: l(H),
155
- onCompositionstart: i[1] || (i[1] = (u) => f.value = !0),
156
- onCompositionend: U,
157
- onFocus: N,
158
- onBlur: O
159
- }, null, 8, ["autosize", "type", "readonly", "resize", "modelValue", "disabled", "placeholder", "maxlength", "autofocus", "onKeydown"])
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" ? (n(), o("div", ue, [
162
- c("div", de, [
163
- b(e.$slots, "actions"),
164
- p(j, {
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: v.value,
190
+ disabled: b.value,
170
191
  "show-clear": e.clearable,
171
- "has-content": !!l(s),
172
- "speech-status": l(g),
192
+ "has-content": z.value,
193
+ "speech-status": i(g),
173
194
  "submit-type": e.submitType,
174
- onClear: l(_),
175
- onToggleSpeech: S,
176
- onSubmit: l(C),
177
- onCancel: i[2] || (i[2] = (u) => e.$emit("cancel"))
178
- }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "onClear", "onSubmit"])
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
- ])) : r("", !0)
201
+ ])) : u("", !0)
181
202
  ], 2),
182
- p(k, { name: "tiny-sender-slide-up" }, {
203
+ f(B, { name: "tiny-sender-slide-up" }, {
183
204
  default: L(() => [
184
- e.$slots.footer ? (n(), o("div", ce, [
185
- b(e.$slots, "footer")
186
- ])) : e.mode !== "single" || e.showWordLimit && e.maxLength !== 1 / 0 ? (n(), o("div", {
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: X(D.value),
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 ? (n(), o("div", pe, w(l(s).length) + "/" + w(e.maxLength), 1)) : r("", !0),
192
- e.mode === "multiple" ? (n(), o("div", me, [
193
- c("div", he, [
194
- p(j, {
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: v.value,
219
+ disabled: b.value,
199
220
  "show-clear": e.clearable,
200
- "has-content": !!l(s),
201
- "speech-status": l(g),
221
+ "has-content": z.value,
222
+ "speech-status": i(g),
202
223
  "submit-type": e.submitType,
203
- onClear: l(_),
204
- onToggleSpeech: S,
205
- onSubmit: l(C),
206
- onCancel: i[3] || (i[3] = (u) => e.$emit("cancel"))
207
- }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "onClear", "onSubmit"])
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
- ])) : r("", !0)
210
- ], 4)) : r("", !0)
230
+ ])) : u("", !0)
231
+ ], 4)) : u("", !0)
211
232
  ]),
212
233
  _: 3
213
234
  })
214
235
  ])
215
236
  ]),
216
- p(k, { name: "tiny-sender-slide-up" }, {
237
+ f(B, { name: "tiny-sender-slide-up" }, {
217
238
  default: L(() => [
218
- y.value && B.value.length ? (n(), o("div", fe, [
219
- (n(!0), o(Y, null, Z(B.value, (u, A) => (n(), o("div", {
220
- key: A,
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: (ve) => R(u)
223
- }, w(u), 9, ye))), 128))
224
- ])) : r("", !0)
243
+ onClick: (Be) => U(d)
244
+ }, C(d), 9, ke))), 128))
245
+ ])) : u("", !0)
225
246
  ]),
226
247
  _: 1
227
248
  }),
228
- h.value ? (n(), o("div", ge, w(h.value), 1)) : r("", !0)
229
- ], 10, oe));
249
+ m.value ? (o(), n("div", $e, C(m.value), 1)) : u("", !0)
250
+ ], 10, pe));
230
251
  }
231
252
  });
232
253
  export {
233
- Le as default
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,4 @@
1
+ import f from "./CategoryNav.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -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,4 @@
1
+ import f from "./SuggestionCapsule.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -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
+ };