@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
@@ -0,0 +1,22 @@
1
+ import { defineComponent as i, useCssVars as u, computed as n, createElementBlock as p, openBlock as c, createBlock as l, resolveDynamicComponent as m } from "vue";
2
+ const f = { class: "tr-icon-button" }, x = /* @__PURE__ */ i({
3
+ __name: "index",
4
+ props: {
5
+ icon: {},
6
+ size: { default: "24px" },
7
+ svgSize: { default: "16px" }
8
+ },
9
+ setup(s) {
10
+ u((e) => ({
11
+ "2d9cffb8": r.value,
12
+ "0c8b8982": a.value
13
+ }));
14
+ const t = s, o = (e) => isNaN(Number(e)) ? e : `${e}px`, r = n(() => o(t.size)), a = n(() => o(t.svgSize));
15
+ return (e, _) => (c(), p("button", f, [
16
+ (c(), l(m(t.icon)))
17
+ ]));
18
+ }
19
+ });
20
+ export {
21
+ x as default
22
+ };
@@ -1,7 +1,7 @@
1
1
  import o from "./prompt.vue2.js";
2
2
  /* empty css */
3
3
  import t from "../../../../_virtual/_plugin-vue_export-helper.js";
4
- const f = /* @__PURE__ */ t(o, [["__scopeId", "data-v-3ef50849"]]);
4
+ const a = /* @__PURE__ */ t(o, [["__scopeId", "data-v-e04bfae3"]]);
5
5
  export {
6
- f as default
6
+ a as default
7
7
  };
@@ -1,8 +1,8 @@
1
- import { defineComponent as s, computed as c, createElementBlock as p, openBlock as t, normalizeClass as a, createElementVNode as o, createBlock as i, resolveDynamicComponent as l, createCommentVNode as b, toDisplayString as d } from "vue";
2
- const g = { class: "tr-prompt__icon" }, v = { class: "tr-prompt__content" }, C = { class: "tr-prompt__content-label" }, f = {
1
+ import { defineComponent as i, createElementBlock as s, openBlock as t, normalizeClass as r, createElementVNode as o, createBlock as a, resolveDynamicComponent as c, createCommentVNode as d, toDisplayString as n, Fragment as l, createTextVNode as _ } from "vue";
2
+ const m = { class: "tr-prompt__icon" }, b = { class: "tr-prompt__content" }, g = { class: "tr-prompt__content-label" }, y = {
3
3
  key: 0,
4
4
  class: "tr-prompt__content-description"
5
- }, k = /* @__PURE__ */ s({
5
+ }, u = /* @__PURE__ */ i({
6
6
  __name: "prompt",
7
7
  props: {
8
8
  label: {},
@@ -12,26 +12,28 @@ const g = { class: "tr-prompt__icon" }, v = { class: "tr-prompt__content" }, C =
12
12
  disabled: { type: Boolean },
13
13
  badge: {}
14
14
  },
15
- setup(_) {
16
- const e = _, r = (n) => n ? s(() => () => n) : null, m = c(() => r(e.icon)), u = c(() => r(e.badge));
17
- return (n, h) => (t(), p("div", {
18
- class: a(["tr-prompt", { disabled: e.disabled }])
15
+ setup(p) {
16
+ const e = p;
17
+ return (f, h) => (t(), s("div", {
18
+ class: r(["tr-prompt", { disabled: e.disabled }])
19
19
  }, [
20
- o("div", g, [
21
- (t(), i(l(m.value)))
20
+ o("div", m, [
21
+ (t(), a(c(e.icon)))
22
22
  ]),
23
- o("div", v, [
24
- o("h6", C, d(e.label), 1),
25
- e.description ? (t(), p("p", f, d(e.description), 1)) : b("", !0)
23
+ o("div", b, [
24
+ o("h6", g, n(e.label), 1),
25
+ e.description ? (t(), s("p", y, n(e.description), 1)) : d("", !0)
26
26
  ]),
27
27
  o("div", {
28
- class: a(["tr-prompt__badge", { label: typeof e.badge == "string" }])
28
+ class: r(["tr-prompt__badge", { label: typeof e.badge == "string" }])
29
29
  }, [
30
- (t(), i(l(u.value)))
30
+ typeof e.badge == "string" ? (t(), s(l, { key: 0 }, [
31
+ _(n(e.badge), 1)
32
+ ], 64)) : (t(), a(c(e.badge), { key: 1 }))
31
33
  ], 2)
32
34
  ], 2));
33
35
  }
34
36
  });
35
37
  export {
36
- k as default
38
+ u as default
37
39
  };
@@ -1,8 +1,8 @@
1
- import { defineComponent as S, ref as k, computed as _, watch as x, createElementBlock as i, createCommentVNode as h, openBlock as l, createElementVNode as s, withModifiers as M, normalizeStyle as N, createVNode as v, unref as r, Fragment as C, renderList as q, normalizeClass as Q, renderSlot as u, toDisplayString as f, createTextVNode as V } from "vue";
2
- import T from "../../../../../node_modules/.pnpm/@opentiny_vue-icon@3.22.0/node_modules/@opentiny/vue-icon/lib/close.js";
3
- import z from "../../../../../node_modules/.pnpm/@opentiny_vue-button@3.21.0/node_modules/@opentiny/vue-button/lib/index.js";
4
- import { IconHotQuestion as A, IconTypeAll as E } from "../../../../svgs/dist/tiny-robot-svgs.js";
5
- const H = { class: "tr-question-header" }, I = { style: { display: "flex", "align-items": "center", gap: "12px" } }, R = {
1
+ import { defineComponent as O, ref as k, computed as Q, watch as S, createElementBlock as i, createCommentVNode as h, openBlock as l, createElementVNode as s, withModifiers as _, normalizeStyle as M, createVNode as v, unref as r, Fragment as C, renderList as q, normalizeClass as N, renderSlot as u, toDisplayString as f, createTextVNode as V } from "vue";
2
+ import z from "../../../../../node_modules/.pnpm/@opentiny_vue-icon@3.22.0/node_modules/@opentiny/vue-icon/lib/close.js";
3
+ import I from "../../../../../node_modules/.pnpm/@opentiny_vue-button@3.21.0/node_modules/@opentiny/vue-button/lib/index.js";
4
+ import { IconHotQuestion as T, IconTypeAll as A } from "../../../../svgs/dist/tiny-robot-svgs.js";
5
+ const E = { class: "tr-question-header" }, H = { style: { display: "flex", "align-items": "center", gap: "12px", "font-size": "36px" } }, R = {
6
6
  key: 0,
7
7
  class: "tr-question-categories"
8
8
  }, W = ["onClick"], D = { class: "category-icon" }, F = { class: "tr-question-content" }, L = {
@@ -11,7 +11,7 @@ const H = { class: "tr-question-header" }, I = { style: { display: "flex", "alig
11
11
  }, P = { key: 1 }, j = ["onClick"], G = {
12
12
  key: 2,
13
13
  class: "tr-question-empty"
14
- }, Z = /* @__PURE__ */ S({
14
+ }, Z = /* @__PURE__ */ O({
15
15
  __name: "HotQuestions",
16
16
  props: {
17
17
  visible: {
@@ -37,13 +37,13 @@ const H = { class: "tr-question-header" }, I = { style: { display: "flex", "alig
37
37
  },
38
38
  emits: ["update:visible", "close", "select-category", "question-click"],
39
39
  setup(n, { emit: b }) {
40
- const w = T(), a = n, c = b, d = k(""), p = _(() => {
40
+ const B = z(), a = n, c = b, d = k(""), p = Q(() => {
41
41
  if (!d.value && a.categories.length > 0)
42
42
  return a.categories[0].questions || [];
43
43
  const e = a.categories.find((t) => t.id === d.value);
44
44
  return e ? e.questions : [];
45
45
  });
46
- x(
46
+ S(
47
47
  () => a.categories,
48
48
  (e) => {
49
49
  e.length > 0 && !d.value && (d.value = e[0].id);
@@ -52,33 +52,33 @@ const H = { class: "tr-question-header" }, I = { style: { display: "flex", "alig
52
52
  );
53
53
  const y = () => {
54
54
  c("update:visible", !1), c("close");
55
- }, B = (e) => {
55
+ }, $ = (e) => {
56
56
  d.value = e, c(
57
57
  "select-category",
58
58
  a.categories.find((t) => t.id === e)
59
59
  );
60
- }, $ = (e) => {
60
+ }, w = (e) => {
61
61
  c("question-click", e);
62
- }, O = (e) => {
62
+ }, x = (e) => {
63
63
  a.closeOnClickOutside && !e.composedPath().includes(g.value) && y();
64
64
  }, g = k(null);
65
65
  return (e, t) => n.visible ? (l(), i("div", {
66
66
  key: 0,
67
67
  class: "tr-question-modal-backdrop",
68
- onMousedown: O
68
+ onMousedown: x
69
69
  }, [
70
70
  s("div", {
71
71
  ref_key: "modalRef",
72
72
  ref: g,
73
73
  class: "tr-question-panel",
74
- style: N({ width: n.modalWidth }),
75
- onMousedown: t[0] || (t[0] = M(() => {
74
+ style: M({ width: n.modalWidth }),
75
+ onMousedown: t[0] || (t[0] = _(() => {
76
76
  }, ["stop"]))
77
77
  }, [
78
- s("div", H, [
79
- s("div", I, [
78
+ s("div", E, [
79
+ s("div", H, [
80
80
  s("div", null, [
81
- v(r(A))
81
+ v(r(T))
82
82
  ]),
83
83
  t[1] || (t[1] = s("div", { class: "tr-question-header-title" }, "热门问题", -1))
84
84
  ]),
@@ -86,8 +86,8 @@ const H = { class: "tr-question-header" }, I = { style: { display: "flex", "alig
86
86
  class: "tr-question-close-btn",
87
87
  onClick: y
88
88
  }, [
89
- v(r(z), {
90
- icon: r(w),
89
+ v(r(I), {
90
+ icon: r(B),
91
91
  type: "text"
92
92
  }, null, 8, ["icon"])
93
93
  ])
@@ -95,12 +95,12 @@ const H = { class: "tr-question-header" }, I = { style: { display: "flex", "alig
95
95
  n.categories.length > 0 ? (l(), i("div", R, [
96
96
  (l(!0), i(C, null, q(n.categories, (o) => (l(), i("div", {
97
97
  key: o.id,
98
- class: Q(["tr-question-categories-item", { active: d.value === o.id }]),
99
- onClick: (m) => B(o.id)
98
+ class: N(["tr-question-categories-item", { active: d.value === o.id }]),
99
+ onClick: (m) => $(o.id)
100
100
  }, [
101
101
  u(e.$slots, "category-label", { category: o }, () => [
102
102
  s("div", D, [
103
- v(r(E))
103
+ v(r(A))
104
104
  ]),
105
105
  s("span", null, f(o.label), 1)
106
106
  ])
@@ -115,7 +115,7 @@ const H = { class: "tr-question-header" }, I = { style: { display: "flex", "alig
115
115
  (l(!0), i(C, null, q(p.value, (o, m) => (l(), i("li", {
116
116
  key: o.id,
117
117
  class: "tr-question-list-item",
118
- onClick: (J) => $(o)
118
+ onClick: (J) => w(o)
119
119
  }, [
120
120
  u(e.$slots, "question-item", {
121
121
  question: o,
@@ -1,10 +1,10 @@
1
- import { defineComponent as N, computed as O, ref as E, watch as T, onMounted as D, createElementBlock as b, openBlock as i, normalizeClass as M, createElementVNode as l, createVNode as a, createCommentVNode as U, unref as n, withCtx as d, renderSlot as r, createTextVNode as W, toDisplayString as p, createBlock as q } from "vue";
1
+ import { defineComponent as D, computed as N, ref as w, watch as O, onMounted as T, createElementBlock as q, openBlock as i, normalizeClass as M, createElementVNode as l, createVNode as a, createCommentVNode as U, unref as n, withCtx as d, renderSlot as r, createTextVNode as W, toDisplayString as p, createBlock as B } from "vue";
2
2
  import { useQuestions as z } from "./composables/useQuestions.js";
3
3
  import F from "./components/CommonQuestions.vue.js";
4
4
  import H from "./components/HotQuestions.vue.js";
5
5
  import { IconHotQuestion as j, IconTypeAll as G, IconArrowUp as J, IconArrowDown as K } from "../../../svgs/dist/tiny-robot-svgs.js";
6
6
  /* empty css */
7
- const L = ["data-theme"], P = { class: "category-icon" }, te = /* @__PURE__ */ N({
7
+ const L = ["data-theme"], P = { class: "category-icon" }, te = /* @__PURE__ */ D({
8
8
  __name: "index",
9
9
  props: {
10
10
  categories: { default: () => [] },
@@ -16,11 +16,11 @@ const L = ["data-theme"], P = { class: "category-icon" }, te = /* @__PURE__ */ N
16
16
  loading: { type: Boolean, default: !1 }
17
17
  },
18
18
  emits: ["question-click", "select-category"],
19
- setup(B, { expose: $, emit: Q }) {
20
- const u = B, g = () => {
19
+ setup(b, { expose: Q, emit: $ }) {
20
+ const u = b, g = () => {
21
21
  s.value = !s.value;
22
- }, f = Q, v = O(() => u.categories), s = E(u.initialExpanded), { modalVisible: m, currentTheme: x, setActiveCategory: h, openModal: c, closeModal: k, setTheme: S, refreshData: A } = z(v);
23
- T(
22
+ }, f = $, v = N(() => u.categories), s = w(u.initialExpanded), { modalVisible: m, currentTheme: x, setActiveCategory: h, openModal: c, closeModal: k, setTheme: S, refreshData: A } = z(v);
23
+ O(
24
24
  () => u.theme,
25
25
  (e) => {
26
26
  S(e);
@@ -28,20 +28,20 @@ const L = ["data-theme"], P = { class: "category-icon" }, te = /* @__PURE__ */ N
28
28
  );
29
29
  const y = (e) => {
30
30
  k(), f("question-click", e);
31
- }, V = (e) => {
31
+ }, I = (e) => {
32
32
  e && (h(e.id), f("select-category", e));
33
- }, C = E(!1), I = (e) => {
33
+ }, C = w(!1), V = (e) => {
34
34
  C.value = e;
35
35
  };
36
- return D(() => {
36
+ return T(() => {
37
37
  document.documentElement.setAttribute("data-theme", x.value);
38
- }), $({
38
+ }), Q({
39
39
  openModal: c,
40
40
  closeModal: k,
41
41
  toggleFloating: g,
42
42
  setActiveCategory: h,
43
43
  refreshData: A
44
- }), (e, t) => (i(), b("div", {
44
+ }), (e, t) => (i(), q("div", {
45
45
  class: M(["tr-question-container", [`theme-${e.theme}`]]),
46
46
  "data-theme": e.theme
47
47
  }, [
@@ -61,7 +61,7 @@ const L = ["data-theme"], P = { class: "category-icon" }, te = /* @__PURE__ */ N
61
61
  "onUpdate:visible": t[1] || (t[1] = (o) => m.value = o),
62
62
  onClose: t[2] || (t[2] = (o) => m.value = !1),
63
63
  onQuestionClick: y,
64
- onSelectCategory: V
64
+ onSelectCategory: I
65
65
  }, {
66
66
  "category-label": d(({ category: o }) => [
67
67
  r(e.$slots, "category-label", { category: o }, () => [
@@ -71,12 +71,12 @@ const L = ["data-theme"], P = { class: "category-icon" }, te = /* @__PURE__ */ N
71
71
  l("span", null, p(o.label), 1)
72
72
  ])
73
73
  ]),
74
- "question-item": d(({ question: o, index: w }) => [
74
+ "question-item": d(({ question: o, index: E }) => [
75
75
  r(e.$slots, "question-item", {
76
76
  question: o,
77
- index: w
77
+ index: E
78
78
  }, () => [
79
- l("span", null, p(w + 1) + ".", 1),
79
+ l("span", null, p(E + 1) + ".", 1),
80
80
  W(" " + p(o.text), 1)
81
81
  ])
82
82
  ]),
@@ -95,15 +95,15 @@ const L = ["data-theme"], P = { class: "category-icon" }, te = /* @__PURE__ */ N
95
95
  a(F, {
96
96
  isExpanded: s.value,
97
97
  questions: e.commonQuestions,
98
- onShowExpandButton: I,
98
+ onShowExpandButton: V,
99
99
  onQuestionClick: y
100
100
  }, null, 8, ["isExpanded", "questions"]),
101
- C.value ? (i(), b("div", {
101
+ C.value ? (i(), q("div", {
102
102
  key: 0,
103
103
  class: "tr-question-wrap-trigger",
104
104
  onClick: g
105
105
  }, [
106
- s.value ? (i(), q(n(K), { key: 1 })) : (i(), q(n(J), { key: 0 }))
106
+ s.value ? (i(), B(n(K), { key: 1 })) : (i(), B(n(J), { key: 0 }))
107
107
  ])) : U("", !0)
108
108
  ], 10, L));
109
109
  }
@@ -0,0 +1,7 @@
1
+ import o from "./TemplateEditor.vue2.js";
2
+ /* empty css */
3
+ import t from "../../../../../_virtual/_plugin-vue_export-helper.js";
4
+ const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-09e9c7ed"]]);
5
+ export {
6
+ p as default
7
+ };
@@ -0,0 +1,175 @@
1
+ import { defineComponent as U, ref as c, watch as T, nextTick as D, onMounted as j, createElementBlock as r, openBlock as f, createElementVNode as W, Fragment as P, renderList as q, toDisplayString as S, normalizeClass as G, withModifiers as J } from "vue";
2
+ const Q = { class: "template-editor" }, X = { key: 0 }, Y = ["onClick"], Z = ["onInput"], ee = {
3
+ key: 1,
4
+ class: "template-placeholder"
5
+ }, le = /* @__PURE__ */ U({
6
+ __name: "TemplateEditor",
7
+ props: {
8
+ template: {},
9
+ value: {}
10
+ },
11
+ emits: ["update:value", "input", "content-status", "field-active"],
12
+ setup(B, { expose: L, emit: M }) {
13
+ const d = B, p = M, $ = c(null), m = c({}), u = c(-1), _ = c(!1), v = c(!1), g = c(!1), s = c([]), k = (e) => {
14
+ const t = [];
15
+ let n = 0, a = 0;
16
+ const l = /\[(.*?)\]/g;
17
+ let o;
18
+ for (; (o = l.exec(e)) !== null; )
19
+ o.index > n && t.push({
20
+ content: e.substring(n, o.index),
21
+ isField: !1
22
+ }), t.push({
23
+ content: o[1],
24
+ // 使用占位符作为默认内容
25
+ placeholder: o[1],
26
+ isField: !0,
27
+ fieldIndex: a++
28
+ }), n = o.index + o[0].length;
29
+ return n < e.length && t.push({
30
+ content: e.substring(n),
31
+ isField: !1
32
+ }), t;
33
+ }, z = () => {
34
+ s.value = k(d.template), d.value && I(d.value);
35
+ }, I = (e) => {
36
+ if (!e || g.value || F() === e) return;
37
+ const n = k(d.template), a = [];
38
+ n.forEach((i) => {
39
+ i.isField ? a.push(`__FIELD_${i.fieldIndex}__`) : a.push(i.content);
40
+ });
41
+ let l = e, o = 0;
42
+ for (let i = 0; i < s.value.length; i++) {
43
+ if (!s.value[i].isField) continue;
44
+ const b = a[o];
45
+ o++;
46
+ const x = a[o] || "";
47
+ if (b && l.startsWith(b))
48
+ if (l = l.substring(b.length), x && l.includes(x)) {
49
+ const w = l.indexOf(x), R = l.substring(0, w);
50
+ R && (s.value[i].content = R, u.value === i && m.value[i] && (v.value = !0)), l = l.substring(w);
51
+ } else !x && l && (s.value[i].content = l, l = "");
52
+ }
53
+ C(e);
54
+ }, F = () => s.value.map((e) => e.content).join(""), h = () => {
55
+ g.value = !0;
56
+ const e = F();
57
+ p("update:value", e), p("input", e), C(e), setTimeout(() => {
58
+ g.value = !1;
59
+ }, 0);
60
+ }, C = (e) => {
61
+ const n = (e || F()).trim().length > 0;
62
+ _.value !== n && (_.value = n, p("content-status", n));
63
+ }, A = (e, t) => {
64
+ e && (m.value[t] = e, e.textContent || (e.textContent = s.value[t].content), new MutationObserver(() => {
65
+ u.value === t && !v.value && (v.value = !0, setTimeout(() => {
66
+ s.value[t].content = e.textContent !== null ? e.textContent : "", v.value = !1;
67
+ }, 0));
68
+ }).observe(e, {
69
+ characterData: !0,
70
+ childList: !0,
71
+ subtree: !0
72
+ }));
73
+ }, H = (e, t) => {
74
+ v.value = !0;
75
+ const n = e.target, a = n.textContent !== null ? n.textContent : "";
76
+ s.value[t].content !== a && (s.value[t].content = a, h()), setTimeout(() => {
77
+ v.value = !1;
78
+ }, 10);
79
+ }, K = (e) => {
80
+ if (document.createRange) {
81
+ const t = document.createRange();
82
+ t.selectNodeContents(e), t.collapse(!1);
83
+ const n = window.getSelection();
84
+ n && (n.removeAllRanges(), n.addRange(t));
85
+ }
86
+ }, E = (e) => {
87
+ if (u.value !== e) {
88
+ if (u.value !== -1) {
89
+ const t = u.value, n = m.value[t];
90
+ n && (s.value[t].content = n.textContent !== null ? n.textContent : "", h());
91
+ }
92
+ u.value = e, p("field-active", !0, e), D(() => {
93
+ const t = m.value[e];
94
+ t && (t.focus(), !t.textContent && s.value[e].content && (t.textContent = s.value[e].content), K(t));
95
+ });
96
+ }
97
+ }, y = () => {
98
+ const e = u.value;
99
+ if (e >= 0) {
100
+ const t = m.value[e];
101
+ if (t) {
102
+ const n = t.textContent !== null ? t.textContent : "";
103
+ s.value[e].content = n;
104
+ }
105
+ p("field-active", !1, e);
106
+ }
107
+ h(), u.value = -1;
108
+ }, N = (e) => {
109
+ e.key === "Enter" && (e.preventDefault(), y());
110
+ };
111
+ T(
112
+ () => d.value,
113
+ (e) => {
114
+ e === "" ? V() : e && !g.value && I(e);
115
+ }
116
+ ), T(
117
+ () => d.template,
118
+ () => {
119
+ z(), D(() => {
120
+ C();
121
+ });
122
+ },
123
+ { immediate: !0 }
124
+ );
125
+ const V = () => {
126
+ s.value.forEach((e) => {
127
+ e.isField && (e.content = e.placeholder || "");
128
+ }), h();
129
+ }, O = () => {
130
+ V();
131
+ };
132
+ return j(() => {
133
+ C();
134
+ }), L({
135
+ activateFirstField: () => {
136
+ for (let e = 0; e < s.value.length; e++)
137
+ if (s.value[e].isField) {
138
+ E(e);
139
+ break;
140
+ }
141
+ },
142
+ resetFields: O
143
+ }), (e, t) => (f(), r("div", Q, [
144
+ W("div", {
145
+ class: "template-content",
146
+ ref_key: "editorRef",
147
+ ref: $
148
+ }, [
149
+ (f(!0), r(P, null, q(s.value, (n, a) => (f(), r(P, { key: a }, [
150
+ n.isField ? (f(), r("span", {
151
+ key: 1,
152
+ class: G(["template-field", { "template-field-active": u.value === a }]),
153
+ onClick: (l) => E(a)
154
+ }, [
155
+ u.value === a ? (f(), r("span", {
156
+ key: 0,
157
+ ref_for: !0,
158
+ ref: (l) => A(l, a),
159
+ class: "template-editable",
160
+ contenteditable: "true",
161
+ onInput: (l) => H(l, a),
162
+ onBlur: t[0] || (t[0] = (l) => y()),
163
+ onKeydown: t[1] || (t[1] = (l) => N(l)),
164
+ onClick: t[2] || (t[2] = J(() => {
165
+ }, ["stop"]))
166
+ }, null, 40, Z)) : (f(), r("span", ee, S(n.content), 1))
167
+ ], 10, Y)) : (f(), r("span", X, S(n.content), 1))
168
+ ], 64))), 128))
169
+ ], 512)
170
+ ]));
171
+ }
172
+ });
173
+ export {
174
+ le as default
175
+ };