@opentiny/tiny-robot 0.2.0-alpha.1 → 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 (56) hide show
  1. package/dist/action-group/index.type.d.ts +1 -0
  2. package/dist/bubble/index.d.ts +2 -2
  3. package/dist/bubble/index.type.d.ts +16 -18
  4. package/dist/feedback/index.vue.d.ts +2 -2
  5. package/dist/icon-button/index.type.d.ts +2 -3
  6. package/dist/icon-button/index.vue.d.ts +3 -3
  7. package/dist/node_modules/.pnpm/@vueuse_core@13.1.0_vue@3.5.13/node_modules/@vueuse/core/index.js +262 -142
  8. package/dist/node_modules/.pnpm/@vueuse_shared@13.1.0_vue@3.5.13/node_modules/@vueuse/shared/index.js +96 -39
  9. package/dist/packages/components/src/action-group/ActionGroup.vue.js +2 -2
  10. package/dist/packages/components/src/action-group/ActionGroup.vue2.js +96 -72
  11. package/dist/packages/components/src/bubble/Bubble.vue.js +7 -0
  12. package/dist/packages/components/src/bubble/Bubble.vue2.js +76 -0
  13. package/dist/packages/components/src/bubble/BubbleList.vue.js +7 -0
  14. package/dist/packages/components/src/bubble/BubbleList.vue2.js +50 -0
  15. package/dist/packages/components/src/bubble/index.js +2 -2
  16. package/dist/packages/components/src/container/index.vue.js +2 -2
  17. package/dist/packages/components/src/container/index.vue2.js +36 -36
  18. package/dist/packages/components/src/feedback/index.vue.js +2 -2
  19. package/dist/packages/components/src/feedback/index.vue2.js +72 -71
  20. package/dist/packages/components/src/icon-button/index.vue.js +2 -2
  21. package/dist/packages/components/src/icon-button/index.vue2.js +9 -27
  22. package/dist/packages/components/src/sender/components/TemplateEditor.vue.js +2 -2
  23. package/dist/packages/components/src/sender/components/TemplateEditor.vue2.js +137 -83
  24. package/dist/sender/index.vue.d.ts +2 -2
  25. package/dist/style.css +1 -1
  26. package/package.json +3 -3
  27. package/src/action-group/ActionGroup.vue +38 -23
  28. package/src/action-group/index.type.ts +1 -0
  29. package/src/bubble/{bubble.vue → Bubble.vue} +13 -97
  30. package/src/bubble/BubbleList.vue +55 -0
  31. package/src/bubble/index.ts +2 -2
  32. package/src/bubble/index.type.ts +7 -21
  33. package/src/container/index.vue +10 -35
  34. package/src/feedback/index.vue +14 -14
  35. package/src/icon-button/index.type.ts +2 -3
  36. package/src/icon-button/index.vue +16 -10
  37. package/src/sender/components/TemplateEditor.vue +301 -110
  38. package/dist/bubble/components/actions/copy.vue.d.ts +0 -10
  39. package/dist/bubble/components/actions/index.d.ts +0 -2
  40. package/dist/bubble/components/actions/refresh.vue.d.ts +0 -2
  41. package/dist/bubble/useScroll.d.ts +0 -4
  42. package/dist/packages/components/src/bubble/bubble-list.vue.js +0 -7
  43. package/dist/packages/components/src/bubble/bubble-list.vue2.js +0 -37
  44. package/dist/packages/components/src/bubble/bubble.vue.js +0 -7
  45. package/dist/packages/components/src/bubble/bubble.vue2.js +0 -118
  46. package/dist/packages/components/src/bubble/components/actions/copy.vue.js +0 -7
  47. package/dist/packages/components/src/bubble/components/actions/copy.vue2.js +0 -35
  48. package/dist/packages/components/src/bubble/components/actions/refresh.vue.js +0 -7
  49. package/dist/packages/components/src/bubble/components/actions/refresh.vue2.js +0 -16
  50. package/dist/packages/components/src/bubble/useScroll.js +0 -13
  51. package/src/bubble/bubble-list.vue +0 -42
  52. package/src/bubble/components/actions/copy.vue +0 -54
  53. package/src/bubble/components/actions/index.ts +0 -2
  54. package/src/bubble/components/actions/refresh.vue +0 -31
  55. package/src/bubble/useScroll.ts +0 -14
  56. /package/dist/bubble/{bubble-list.vue.d.ts → BubbleList.vue.d.ts} +0 -0
@@ -1,15 +1,15 @@
1
- import { defineComponent as F, ref as M, createElementBlock as d, openBlock as o, createElementVNode as a, createCommentVNode as f, createVNode as _, unref as t, withCtx as l, Fragment as g, renderList as A, createBlock as c, createTextVNode as R, toDisplayString as k, resolveDynamicComponent as b } from "vue";
2
- import { IconArrowDown as h, IconArrowUp as C, IconDislike as T, IconLike as X, IconRefresh as z, IconCopy as O } from "../../../svgs/dist/tiny-robot-svgs.js";
3
- import x from "../../../../node_modules/.pnpm/@opentiny_vue-button@3.21.0/node_modules/@opentiny/vue-button/lib/index.js";
4
- import { ActionGroupItem as N } from "../action-group/index.js";
1
+ import { defineComponent as R, ref as T, createElementBlock as p, openBlock as o, createElementVNode as a, createCommentVNode as _, createBlock as l, unref as t, withCtx as c, Fragment as C, renderList as x, createVNode as f, createTextVNode as X, toDisplayString as k, resolveDynamicComponent as h } from "vue";
2
+ import { IconArrowDown as b, IconArrowUp as N, IconDislike as z, IconLike as O, IconRefresh as U, IconCopy as Z } from "../../../svgs/dist/tiny-robot-svgs.js";
3
+ import w from "../../../../node_modules/.pnpm/@opentiny_vue-button@3.21.0/node_modules/@opentiny/vue-button/lib/index.js";
4
+ import { ActionGroupItem as S } from "../action-group/index.js";
5
5
  import "../icon-button/index.js";
6
- import U from "./components/SourceList.vue.js";
7
- import w from "../action-group/ActionGroup.vue.js";
8
- import Z from "../icon-button/index.vue.js";
9
- const j = { class: "tr-feedback" }, q = { class: "tr-feedback__operations" }, H = {
6
+ import j from "./components/SourceList.vue.js";
7
+ import B from "../action-group/ActionGroup.vue.js";
8
+ import q from "../icon-button/index.vue.js";
9
+ const H = { class: "tr-feedback" }, J = { class: "tr-feedback__operations" }, K = { class: "tr-feedback__operations-left" }, P = { key: 1 }, Q = { class: "tr-feedback__operations-right" }, W = {
10
10
  key: 0,
11
- class: "tr-feedback__operations-left"
12
- }, J = { key: 1 }, K = { class: "tr-feedback__operations-right" }, P = { class: "tr-feedback__footer" }, Q = { key: 0 }, ie = /* @__PURE__ */ F({
11
+ class: "tr-feedback__footer"
12
+ }, Y = { key: 0 }, ae = /* @__PURE__ */ R({
13
13
  __name: "index",
14
14
  props: {
15
15
  operations: {},
@@ -20,60 +20,61 @@ const j = { class: "tr-feedback" }, q = { class: "tr-feedback__operations" }, H
20
20
  sourcesLinesLimit: { default: Number.MAX_SAFE_INTEGER }
21
21
  },
22
22
  emits: ["operation", "action"],
23
- setup(S, { emit: B }) {
24
- const e = S, D = {
25
- copy: O,
26
- refresh: z,
27
- like: X,
28
- dislike: T
29
- }, y = B, G = (m) => {
30
- var i, n, r;
31
- (r = (n = (i = e.operations) == null ? void 0 : i.find((u) => u.name === m)) == null ? void 0 : n.onClick) == null || r.call(n), y("operation", m);
32
- }, V = (m) => {
33
- var i, n, r;
34
- (r = (n = (i = e.actions) == null ? void 0 : i.find((u) => u.name === m)) == null ? void 0 : n.onClick) == null || r.call(n), y("action", m);
35
- }, p = M(!1), v = () => {
36
- p.value = !p.value;
23
+ setup(D, { emit: G }) {
24
+ const e = D, V = {
25
+ copy: Z,
26
+ refresh: U,
27
+ like: O,
28
+ dislike: z
29
+ }, y = G, F = (m) => {
30
+ var r, n, i;
31
+ (i = (n = (r = e.operations) == null ? void 0 : r.find((d) => d.name === m)) == null ? void 0 : n.onClick) == null || i.call(n), y("operation", m);
32
+ }, M = (m) => {
33
+ var r, n, i;
34
+ (i = (n = (r = e.actions) == null ? void 0 : r.find((d) => d.name === m)) == null ? void 0 : n.onClick) == null || i.call(n), y("action", m);
35
+ }, u = T(!1), v = () => {
36
+ u.value = !u.value;
37
37
  };
38
- return (m, i) => {
39
- var n, r, u, I, L, E;
40
- return o(), d("div", j, [
41
- a("div", q, [
42
- (n = e.operations) != null && n.length ? (o(), d("div", H, [
43
- _(t(w), {
38
+ return (m, r) => {
39
+ var n, i, d, g, I, L, E, A;
40
+ return o(), p("div", H, [
41
+ a("div", J, [
42
+ a("div", K, [
43
+ (n = e.operations) != null && n.length ? (o(), l(t(B), {
44
+ key: 0,
44
45
  "max-num": e.operationsLimit,
45
46
  "drop-down-show-label-only": !0,
46
- onItemClick: G,
47
+ onItemClick: F,
47
48
  class: "tr-feedback__operations-left-action-group"
48
49
  }, {
49
- moreBtn: l(() => [
50
- _(t(x), {
50
+ moreBtn: c(() => [
51
+ f(t(w), {
51
52
  round: "",
52
53
  size: "mini",
53
54
  "reset-time": 0,
54
55
  class: "tr-feedback__operations-more-btn"
55
56
  }, {
56
- default: l(() => [
57
- i[0] || (i[0] = a("span", null, "更多", -1)),
58
- _(t(h))
57
+ default: c(() => [
58
+ r[0] || (r[0] = a("span", null, "更多", -1)),
59
+ f(t(b))
59
60
  ]),
60
61
  _: 1
61
62
  })
62
63
  ]),
63
- default: l(() => [
64
- (o(!0), d(g, null, A(e.operations, (s) => (o(), c(t(N), {
64
+ default: c(() => [
65
+ (o(!0), p(C, null, x(e.operations, (s) => (o(), l(t(S), {
65
66
  key: s.name,
66
67
  name: s.name,
67
68
  label: s.label
68
69
  }, {
69
- default: l(() => [
70
- _(t(x), {
70
+ default: c(() => [
71
+ f(t(w), {
71
72
  round: "",
72
73
  "reset-time": 0,
73
74
  size: "mini"
74
75
  }, {
75
- default: l(() => [
76
- R(k(s.label), 1)
76
+ default: c(() => [
77
+ X(k(s.label), 1)
77
78
  ]),
78
79
  _: 2
79
80
  }, 1024)
@@ -82,33 +83,33 @@ const j = { class: "tr-feedback" }, q = { class: "tr-feedback__operations" }, H
82
83
  }, 1032, ["name", "label"]))), 128))
83
84
  ]),
84
85
  _: 1
85
- }, 8, ["max-num"])
86
- ])) : (r = e.sources) != null && r.length ? (o(), d("div", J, [
87
- a("span", {
88
- class: "tr-feedback__source",
89
- onClick: v
90
- }, [
91
- a("span", null, k((u = e.sources) == null ? void 0 : u.length) + "条来源", 1),
92
- (o(), c(b(p.value ? t(C) : t(h))))
93
- ])
94
- ])) : f("", !0),
95
- a("div", K, [
96
- _(t(w), {
86
+ }, 8, ["max-num"])) : (i = e.sources) != null && i.length ? (o(), p("div", P, [
87
+ a("span", {
88
+ class: "tr-feedback__source",
89
+ onClick: v
90
+ }, [
91
+ a("span", null, k((d = e.sources) == null ? void 0 : d.length) + "条来源", 1),
92
+ (o(), l(h(u.value ? t(N) : t(b))))
93
+ ])
94
+ ])) : _("", !0)
95
+ ]),
96
+ a("div", Q, [
97
+ f(t(B), {
97
98
  "max-num": e.actionsLimit,
98
- onItemClick: V
99
+ "show-tooltip": !0,
100
+ onItemClick: M
99
101
  }, {
100
- default: l(() => [
101
- (o(!0), d(g, null, A(e.actions, (s) => (o(), c(t(N), {
102
+ default: c(() => [
103
+ (o(!0), p(C, null, x(e.actions, (s) => (o(), l(t(S), {
102
104
  key: s.name,
103
105
  name: s.name,
104
106
  label: s.label
105
107
  }, {
106
- default: l(() => [
107
- typeof s.icon == "string" ? (o(), c(t(Z), {
108
+ default: c(() => [
109
+ typeof s.icon == "string" ? (o(), l(t(q), {
108
110
  key: 0,
109
- icon: D[s.icon],
110
- tooltip: s.label
111
- }, null, 8, ["icon", "tooltip"])) : (o(), c(b(s.icon), { key: 1 }))
111
+ icon: V[s.icon]
112
+ }, null, 8, ["icon"])) : (o(), l(h(s.icon), { key: 1 }))
112
113
  ]),
113
114
  _: 2
114
115
  }, 1032, ["name", "label"]))), 128))
@@ -117,26 +118,26 @@ const j = { class: "tr-feedback" }, q = { class: "tr-feedback__operations" }, H
117
118
  }, 8, ["max-num"])
118
119
  ])
119
120
  ]),
120
- a("div", P, [
121
- (I = e.operations) != null && I.length && ((L = e.sources) != null && L.length) ? (o(), d("div", Q, [
121
+ (g = e.operations) != null && g.length && ((I = e.sources) != null && I.length) || u.value && e.sources ? (o(), p("div", W, [
122
+ (L = e.operations) != null && L.length && ((E = e.sources) != null && E.length) ? (o(), p("div", Y, [
122
123
  a("span", {
123
124
  class: "tr-feedback__source",
124
125
  onClick: v
125
126
  }, [
126
- a("span", null, k((E = e.sources) == null ? void 0 : E.length) + "条来源", 1),
127
- (o(), c(b(p.value ? t(C) : t(h))))
127
+ a("span", null, k((A = e.sources) == null ? void 0 : A.length) + "条来源", 1),
128
+ (o(), l(h(u.value ? t(N) : t(b))))
128
129
  ])
129
- ])) : f("", !0),
130
- p.value && e.sources ? (o(), c(t(U), {
130
+ ])) : _("", !0),
131
+ u.value && e.sources ? (o(), l(t(j), {
131
132
  key: 1,
132
133
  sources: e.sources,
133
134
  "lines-limit": e.sourcesLinesLimit
134
- }, null, 8, ["sources", "lines-limit"])) : f("", !0)
135
- ])
135
+ }, null, 8, ["sources", "lines-limit"])) : _("", !0)
136
+ ])) : _("", !0)
136
137
  ]);
137
138
  };
138
139
  }
139
140
  });
140
141
  export {
141
- ie as default
142
+ ae as default
142
143
  };
@@ -1,7 +1,7 @@
1
1
  import o from "./index.vue2.js";
2
2
  /* empty css */
3
3
  import t from "../../../../_virtual/_plugin-vue_export-helper.js";
4
- const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-be35ecb5"]]);
4
+ const f = /* @__PURE__ */ t(o, [["__scopeId", "data-v-f6ea2c1a"]]);
5
5
  export {
6
- m as default
6
+ f as default
7
7
  };
@@ -1,37 +1,19 @@
1
- import { defineComponent as i, useCssVars as p, createBlock as n, createElementBlock as r, openBlock as e, unref as a, withCtx as l, createElementVNode as f, resolveDynamicComponent as c } from "vue";
2
- import u from "../../../../node_modules/.pnpm/@opentiny_vue-tooltip@3.22.0/node_modules/@opentiny/vue-tooltip/lib/index.js";
3
- const m = { class: "tr-icon-button" }, d = {
4
- key: 1,
5
- class: "tr-icon-button"
6
- }, x = /* @__PURE__ */ i({
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({
7
3
  __name: "index",
8
4
  props: {
9
5
  icon: {},
10
6
  size: { default: "24px" },
11
- svgSize: { default: "16px" },
12
- tooltip: {}
7
+ svgSize: { default: "16px" }
13
8
  },
14
9
  setup(s) {
15
- p((o) => ({
16
- "1bc6294b": t.size,
17
- "2e5bfafb": t.svgSize
10
+ u((e) => ({
11
+ "2d9cffb8": r.value,
12
+ "0c8b8982": a.value
18
13
  }));
19
- const t = s;
20
- return (o, _) => o.tooltip ? (e(), n(a(u), {
21
- key: 0,
22
- content: o.tooltip,
23
- effect: "dark",
24
- placement: "top",
25
- "open-delay": 500
26
- }, {
27
- default: l(() => [
28
- f("button", m, [
29
- (e(), n(c(t.icon)))
30
- ])
31
- ]),
32
- _: 1
33
- }, 8, ["content"])) : (e(), r("button", d, [
34
- (e(), n(c(t.icon)))
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)))
35
17
  ]));
36
18
  }
37
19
  });
@@ -1,7 +1,7 @@
1
1
  import o from "./TemplateEditor.vue2.js";
2
2
  /* empty css */
3
3
  import t from "../../../../../_virtual/_plugin-vue_export-helper.js";
4
- const a = /* @__PURE__ */ t(o, [["__scopeId", "data-v-0cf27800"]]);
4
+ const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-09e9c7ed"]]);
5
5
  export {
6
- a as default
6
+ p as default
7
7
  };
@@ -1,121 +1,175 @@
1
- import { defineComponent as E, ref as p, computed as I, watch as T, createElementBlock as o, openBlock as a, createElementVNode as b, Fragment as F, renderList as K, toDisplayString as k, normalizeClass as B, withDirectives as R, withModifiers as M, vModelText as N, nextTick as U } from "vue";
2
- const $ = { class: "template-editor" }, j = { key: 0 }, z = ["onClick"], L = ["onUpdate:modelValue", "onKeydown"], P = {
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
3
  key: 1,
4
4
  class: "template-placeholder"
5
- }, q = /* @__PURE__ */ E({
5
+ }, le = /* @__PURE__ */ U({
6
6
  __name: "TemplateEditor",
7
7
  props: {
8
8
  template: {},
9
9
  value: {}
10
10
  },
11
11
  emits: ["update:value", "input", "content-status", "field-active"],
12
- setup(_, { expose: y, emit: g }) {
13
- const u = _, v = g, w = p(null), c = p({}), r = p(-1), i = I(() => {
14
- if (u.value)
15
- return x();
16
- const e = [];
17
- let l = 0, t = 0;
18
- const s = /\[(.*?)\]/g;
19
- let n;
20
- for (; (n = s.exec(u.template)) !== null; )
21
- n.index > l && e.push({
22
- content: u.template.substring(l, n.index),
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),
23
21
  isField: !1
24
- }), e.push({
25
- content: "",
26
- placeholder: n[1],
22
+ }), t.push({
23
+ content: o[1],
24
+ // 使用占位符作为默认内容
25
+ placeholder: o[1],
27
26
  isField: !0,
28
- fieldIndex: t++
29
- }), l = n.index + n[0].length;
30
- return l < u.template.length && e.push({
31
- content: u.template.substring(l),
27
+ fieldIndex: a++
28
+ }), n = o.index + o[0].length;
29
+ return n < e.length && t.push({
30
+ content: e.substring(n),
32
31
  isField: !1
33
- }), e;
34
- }), x = () => i.value, V = () => i.value.map((e) => e.content).join(""), d = () => {
35
- const e = V();
36
- v("update:value", e), v("input", e);
37
- }, f = (e) => {
38
- r.value = e, U(() => {
39
- var l;
40
- c.value[e] && ((l = c.value[e]) == null || l.focus());
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);
41
40
  });
42
- }, m = () => {
43
- d(), r.value = -1;
44
- }, C = (e, l) => {
45
- if (e.key === "Tab") {
46
- e.preventDefault();
47
- const t = D(l, e.shiftKey);
48
- t !== -1 && (d(), f(t));
49
- } else e.key === "Enter" && (e.preventDefault(), m());
50
- }, D = (e, l = !1) => {
51
- if (l) {
52
- for (let t = e - 1; t >= 0; t--)
53
- if (i.value[t].isField)
54
- return t;
55
- for (let t = i.value.length - 1; t > e; t--)
56
- if (i.value[t].isField)
57
- return t;
58
- } else {
59
- for (let t = e + 1; t < i.value.length; t++)
60
- if (i.value[t].isField)
61
- return t;
62
- for (let t = 0; t < e; t++)
63
- if (i.value[t].isField)
64
- return t;
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 = "");
65
52
  }
66
- return -1;
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());
67
110
  };
68
111
  T(
69
- () => u.value,
112
+ () => d.value,
70
113
  (e) => {
71
- e === "" && h();
114
+ e === "" ? V() : e && !g.value && I(e);
72
115
  }
116
+ ), T(
117
+ () => d.template,
118
+ () => {
119
+ z(), D(() => {
120
+ C();
121
+ });
122
+ },
123
+ { immediate: !0 }
73
124
  );
74
- const h = () => {
75
- i.value.forEach((e) => {
76
- e.isField && (e.content = "");
77
- }), d();
125
+ const V = () => {
126
+ s.value.forEach((e) => {
127
+ e.isField && (e.content = e.placeholder || "");
128
+ }), h();
129
+ }, O = () => {
130
+ V();
78
131
  };
79
- return y({
132
+ return j(() => {
133
+ C();
134
+ }), L({
80
135
  activateFirstField: () => {
81
- for (let e = 0; e < i.value.length; e++)
82
- if (i.value[e].isField) {
83
- f(e);
136
+ for (let e = 0; e < s.value.length; e++)
137
+ if (s.value[e].isField) {
138
+ E(e);
84
139
  break;
85
140
  }
86
141
  },
87
- resetFields: h
88
- }), (e, l) => (a(), o("div", $, [
89
- b("div", {
142
+ resetFields: O
143
+ }), (e, t) => (f(), r("div", Q, [
144
+ W("div", {
90
145
  class: "template-content",
91
146
  ref_key: "editorRef",
92
- ref: w
147
+ ref: $
93
148
  }, [
94
- (a(!0), o(F, null, K(i.value, (t, s) => (a(), o(F, { key: s }, [
95
- t.isField ? (a(), o("span", {
149
+ (f(!0), r(P, null, q(s.value, (n, a) => (f(), r(P, { key: a }, [
150
+ n.isField ? (f(), r("span", {
96
151
  key: 1,
97
- class: B(["template-field", { "template-field-active": r.value === s }]),
98
- onClick: (n) => f(s)
152
+ class: G(["template-field", { "template-field-active": u.value === a }]),
153
+ onClick: (l) => E(a)
99
154
  }, [
100
- r.value === s ? R((a(), o("input", {
155
+ u.value === a ? (f(), r("span", {
101
156
  key: 0,
102
157
  ref_for: !0,
103
- ref: (n) => c.value[s] = n,
104
- "onUpdate:modelValue": (n) => t.content = n,
105
- class: "template-input",
106
- onBlur: l[0] || (l[0] = (n) => m()),
107
- onKeydown: (n) => C(n, s),
108
- onClick: l[1] || (l[1] = M(() => {
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(() => {
109
165
  }, ["stop"]))
110
- }, null, 40, L)), [
111
- [N, t.content]
112
- ]) : (a(), o("span", P, k(t.content || t.placeholder), 1))
113
- ], 10, z)) : (a(), o("span", j, k(t.content), 1))
166
+ }, null, 40, Z)) : (f(), r("span", ee, S(n.content), 1))
167
+ ], 10, Y)) : (f(), r("span", X, S(n.content), 1))
114
168
  ], 64))), 128))
115
169
  ], 512)
116
170
  ]));
117
171
  }
118
172
  });
119
173
  export {
120
- q as default
174
+ le as default
121
175
  };
@@ -508,9 +508,9 @@ declare const __VLS_component: import('vue').DefineComponent<SenderProps, {
508
508
  }>, {
509
509
  loading: boolean;
510
510
  template: string;
511
- mode: import('./index.type').InputMode;
512
511
  disabled: boolean;
513
512
  modelValue: string;
513
+ mode: import('./index.type').InputMode;
514
514
  autofocus: boolean;
515
515
  clearable: boolean;
516
516
  showWordLimit: boolean;
@@ -519,9 +519,9 @@ declare const __VLS_component: import('vue').DefineComponent<SenderProps, {
519
519
  allowSpeech: boolean;
520
520
  allowFiles: boolean;
521
521
  submitType: import('./index.type').SubmitTrigger;
522
+ placeholder: string;
522
523
  autoSize: import('./index.type').AutoSize;
523
524
  maxLength: number;
524
- placeholder: string;
525
525
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
526
526
  templateEditorRef: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('./index.type').TemplateEditorProps> & Readonly<{
527
527
  onInput?: ((value: string) => any) | undefined;