@mobilon-dev/chotto 0.3.101 → 0.3.103

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 (29) hide show
  1. package/dist/chotto.css +1 -1
  2. package/dist/components/2_chatinput_elements/FilePreview/FilePreview.vue.js +4 -3
  3. package/dist/components/2_chatinput_elements/FilePreview/FilePreview.vue2.js +72 -119
  4. package/dist/components/2_chatinput_elements/FileUploader/FileUploader.vue.js +2 -2
  5. package/dist/components/2_chatinput_elements/FileUploader/FileUploader.vue2.js +109 -88
  6. package/dist/components/3_compounds/ChatInput/ChatInput.vue.js +2 -2
  7. package/dist/components/3_compounds/ChatInput/ChatInput.vue2.js +334 -225
  8. package/dist/components/3_compounds/ChatInput/icons/ArrowIcon.vue.js +40 -0
  9. package/dist/hooks/uploadFile/generatePreview.js +19 -18
  10. package/dist/hooks/useMessageDraft.js +85 -65
  11. package/dist/index.js +159 -157
  12. package/dist/locale/en.js +4 -0
  13. package/dist/locale/ru.js +4 -0
  14. package/dist/themes/dark.css +1 -1
  15. package/dist/themes/default.css +1 -1
  16. package/dist/themes/glass.css +1 -1
  17. package/dist/themes/green.css +1 -1
  18. package/dist/themes/mobilon1.css +1 -1
  19. package/dist/types/components/2_chatinput_elements/FilePreview/stories/FilePreview.stories.d.ts +3 -3
  20. package/dist/types/components/2_chatinput_elements/FilePreview/styles/types.d.ts +135 -127
  21. package/dist/types/components/2_chatinput_elements/FileUploader/FileUploader.vue.d.ts +9 -0
  22. package/dist/types/components/3_compounds/ChatInput/ChatInput.vue.d.ts +14 -3
  23. package/dist/types/components/3_compounds/ChatInput/icons/ArrowIcon.vue.d.ts +2 -0
  24. package/dist/types/components/3_compounds/ChatInput/icons/index.d.ts +1 -0
  25. package/dist/types/components/3_compounds/ChatInput/styles/types.d.ts +74 -0
  26. package/dist/types/hooks/useMessageDraft.d.ts +10 -3
  27. package/dist/types/locale/en.d.ts +4 -0
  28. package/dist/types/locale/ru.d.ts +4 -0
  29. package/package.json +1 -1
@@ -1,28 +1,29 @@
1
- import { defineComponent as we, inject as Ce, watch as d, ref as E, computed as _, nextTick as S, unref as u, onMounted as Ae, onUnmounted as Ee, createElementBlock as k, openBlock as F, createElementVNode as h, createVNode as O, normalizeClass as j, createBlock as Fe, createCommentVNode as U, renderSlot as Y, toDisplayString as Me, withDirectives as Re, withKeys as He, vModelText as ke } from "vue";
2
- import { useImmediateDebouncedRef as Le } from "../../../hooks/useImmediateDebouncedRef.js";
3
- import { useMessageDraft as De, commitChatDraftToList as Pe } from "../../../hooks/useMessageDraft.js";
1
+ import { defineComponent as Be, inject as Ne, watch as p, ref as _, computed as x, provide as je, nextTick as b, unref as a, onMounted as Ke, onUnmounted as $e, createElementBlock as C, openBlock as S, createElementVNode as u, createVNode as z, normalizeClass as O, toDisplayString as U, createCommentVNode as V, Fragment as Ge, renderList as Oe, createBlock as Ue, renderSlot as le, withDirectives as Ve, withKeys as Ye, vModelText as Xe } from "vue";
2
+ import { useImmediateDebouncedRef as Je } from "../../../hooks/useImmediateDebouncedRef.js";
3
+ import { MAX_ATTACHED_FILES as ie, useMessageDraft as Qe, getDraftFiles as Ze, commitChatDraftToList as et } from "../../../hooks/useMessageDraft.js";
4
4
  import "../../../hooks/useSearchModel.js";
5
5
  import "../../../hooks/useTheme.js";
6
- import { useEmojiNative as We } from "../../../hooks/useEmojiNative.js";
6
+ import { useEmojiNative as tt } from "../../../hooks/useEmojiNative.js";
7
7
  /* empty css */
8
8
  /* empty css */
9
- import { t as I } from "../../../locale/useLocale.js";
9
+ import { t as h } from "../../../locale/useLocale.js";
10
10
  /* empty css */
11
11
  import "../../../node_modules/linkifyjs/dist/linkify.js";
12
12
  import "../../../node_modules/linkify-string/dist/linkify-string.js";
13
13
  import "../../../functions/parseMarkdown.js";
14
- import { textToAppleEmojiHtml as qe, textContainsEmoji as Be, previousGraphemeIndex as V, nextGraphemeIndex as $, snapIndexToGrapheme as J } from "../../../functions/renderAppleEmojis.js";
15
- import { hideEditPreview as je } from "../../../hooks/messages/useStartEdit.js";
16
- import ze from "./icons/SendIcon.vue.js";
17
- import Ke from "../../2_chatinput_elements/TextFormatToolbar/TextFormatToolbar.vue.js";
18
- import Ne from "../../2_chatinput_elements/FilePreview/FilePreview.vue.js";
19
- const Ge = { class: "chat-input__container" }, Oe = ["id"], Ue = ["id"], Ye = { class: "chat-input__inline-buttons" }, Ve = {
14
+ import { textToAppleEmojiHtml as nt, textContainsEmoji as lt, previousGraphemeIndex as oe, nextGraphemeIndex as se, snapIndexToGrapheme as ae } from "../../../functions/renderAppleEmojis.js";
15
+ import { hideEditPreview as it } from "../../../hooks/messages/useStartEdit.js";
16
+ import ot from "./icons/SendIcon.vue.js";
17
+ import re from "./icons/ArrowIcon.vue.js";
18
+ import st from "../../2_chatinput_elements/TextFormatToolbar/TextFormatToolbar.vue.js";
19
+ import at from "../../2_chatinput_elements/FilePreview/FilePreview.vue.js";
20
+ const rt = { class: "chat-input__container" }, ut = ["id"], ct = ["id"], dt = { class: "chat-input__file-counter" }, ft = { class: "chat-input__file-chips-wrap" }, pt = ["aria-label"], ht = ["aria-label"], mt = { class: "chat-input__inline-buttons" }, vt = {
20
21
  key: 0,
21
22
  class: "chat-input__input chat-input__disabled-placeholder"
22
- }, $e = {
23
+ }, gt = {
23
24
  key: 1,
24
25
  class: "chat-input__input-wrap"
25
- }, Je = ["innerHTML"], Qe = ["disabled", "placeholder"], Xe = ["disabled"], Ze = { class: "" }, et = { class: "chat-input__third-line" }, z = 40, _t = /* @__PURE__ */ we({
26
+ }, yt = ["innerHTML"], _t = ["disabled", "placeholder"], xt = ["disabled"], St = { class: "" }, It = { class: "chat-input__third-line" }, Y = 40, Kt = /* @__PURE__ */ Be({
26
27
  __name: "ChatInput",
27
28
  props: {
28
29
  state: {
@@ -48,333 +49,441 @@ const Ge = { class: "chat-input__container" }, Oe = ["id"], Ue = ["id"], Ye = {
48
49
  type: String,
49
50
  required: !1,
50
51
  default: null
52
+ },
53
+ maxAttachedFiles: {
54
+ type: Number,
55
+ required: !1,
56
+ default: ie
51
57
  }
52
58
  },
53
59
  emits: ["send", "typing"],
54
- setup(T, { emit: Q }) {
55
- const L = Q, b = Ce("chatAppId"), { resetMessage: X, getMessage: l, setMessageText: M, setForceSendMessage: Z, resetEdit: ee, resetMessageFile: te } = De(b), { isNative: ne, emojiSrc: ie } = We(b);
56
- let K = l().id;
57
- d(
58
- () => l().id,
60
+ setup(E, { emit: ue }) {
61
+ const H = ue, M = Ne("chatAppId"), { resetMessage: ce, getMessage: o, setMessageText: D, setForceSendMessage: de, resetEdit: fe, removeMessageFile: pe } = Qe(M), { isNative: he, emojiSrc: me } = tt(M);
62
+ let X = o().id;
63
+ p(
64
+ () => o().id,
59
65
  (e) => {
60
- K = e;
66
+ X = e;
61
67
  }
62
68
  );
63
- const n = E(), m = E(), v = E(null), w = E(!1), oe = Le("", 2e3), D = _(() => {
64
- var e;
65
- return (e = l().file) == null ? void 0 : e.preview;
66
- }), le = _(
67
- () => qe(l().text || "", v.value, ie.value)
68
- ), g = _(
69
- () => !ne.value && Be(l().text || "")
70
- ), c = () => {
71
- if (!m.value || !n.value) return;
72
- const e = n.value, t = m.value, o = Math.max(0, e.offsetWidth - e.clientWidth);
73
- t.style.right = o > 0 ? `${o}px` : "", t.scrollTop = e.scrollTop;
69
+ const l = _(), F = _(), R = _(), T = _(null), k = _(!1), ve = Je("", 2e3), B = _(!1), N = _(!1);
70
+ let m = null;
71
+ const v = x(() => Ze(o()));
72
+ function W() {
73
+ const e = R.value;
74
+ if (!e) {
75
+ B.value = !1, N.value = !1;
76
+ return;
77
+ }
78
+ const t = e.scrollWidth - e.clientWidth;
79
+ B.value = e.scrollLeft > 1, N.value = t - e.scrollLeft > 1;
80
+ }
81
+ function ge(e) {
82
+ const t = e.firstElementChild;
83
+ if (!t) return e.clientWidth;
84
+ const n = parseFloat(getComputedStyle(e).gap) || 8;
85
+ return t.offsetWidth + n;
86
+ }
87
+ function J(e) {
88
+ const t = R.value;
89
+ if (!t) return;
90
+ const n = ge(t);
91
+ t.scrollBy({ left: e === "right" ? n : -n, behavior: "smooth" });
92
+ }
93
+ function Q() {
94
+ m == null || m.disconnect();
95
+ const e = R.value;
96
+ e && (m = new ResizeObserver(() => W()), m.observe(e));
97
+ }
98
+ function ye(e) {
99
+ return e.preview ?? {
100
+ isImage: !1,
101
+ isVideo: !1,
102
+ isAudio: !1,
103
+ fileName: e.name,
104
+ fileSize: ""
105
+ };
106
+ }
107
+ const _e = x(
108
+ () => nt(o().text || "", T.value, me.value)
109
+ ), A = x(
110
+ () => !he.value && lt(o().text || "")
111
+ ), g = () => {
112
+ if (!F.value || !l.value) return;
113
+ const e = l.value, t = F.value, n = Math.max(0, e.offsetWidth - e.clientWidth);
114
+ t.style.right = n > 0 ? `${n}px` : "", t.scrollTop = e.scrollTop;
74
115
  };
75
- let y = 0;
76
- function P() {
77
- v.value = null;
116
+ let w = 0;
117
+ function j() {
118
+ T.value = null;
78
119
  }
79
- function se(e = "nearest") {
80
- const t = n.value;
81
- if (!t || !g.value) return;
82
- const o = t.value, i = J(o, t.selectionStart, e), r = J(o, t.selectionEnd, e);
83
- (i !== t.selectionStart || r !== t.selectionEnd) && t.setSelectionRange(i, r);
120
+ function xe(e = "nearest") {
121
+ const t = l.value;
122
+ if (!t || !A.value) return;
123
+ const n = t.value, i = ae(n, t.selectionStart, e), s = ae(n, t.selectionEnd, e);
124
+ (i !== t.selectionStart || s !== t.selectionEnd) && t.setSelectionRange(i, s);
84
125
  }
85
- function W() {
86
- se("nearest"), f();
126
+ function K() {
127
+ xe("nearest"), I();
87
128
  }
88
- function ae(e) {
89
- if (!g.value || e.key !== "ArrowLeft" && e.key !== "ArrowRight" || e.altKey || e.metaKey || e.ctrlKey) return;
90
- const t = n.value;
129
+ function Se(e) {
130
+ if (!A.value || e.key !== "ArrowLeft" && e.key !== "ArrowRight" || e.altKey || e.metaKey || e.ctrlKey) return;
131
+ const t = l.value;
91
132
  if (!t) return;
92
- const o = t.value, i = t.selectionStart !== t.selectionEnd;
133
+ const n = t.value, i = t.selectionStart !== t.selectionEnd;
93
134
  if (e.shiftKey) {
94
- requestAnimationFrame(() => W());
135
+ requestAnimationFrame(() => K());
95
136
  return;
96
137
  }
97
138
  if (i) {
98
139
  e.preventDefault();
99
- const x = e.key === "ArrowLeft" ? t.selectionStart : t.selectionEnd, A = e.key === "ArrowLeft" ? V(o, x) : $(o, x);
100
- t.setSelectionRange(A, A), f();
140
+ const f = e.key === "ArrowLeft" ? t.selectionStart : t.selectionEnd, y = e.key === "ArrowLeft" ? oe(n, f) : se(n, f);
141
+ t.setSelectionRange(y, y), I();
101
142
  return;
102
143
  }
103
144
  e.preventDefault();
104
- const r = t.selectionStart, p = e.key === "ArrowLeft" ? V(o, r) : $(o, r);
105
- t.setSelectionRange(p, p), f();
145
+ const s = t.selectionStart, d = e.key === "ArrowLeft" ? oe(n, s) : se(n, s);
146
+ t.setSelectionRange(d, d), I();
106
147
  }
107
- function f() {
108
- if (!g.value) {
109
- P();
148
+ function I() {
149
+ if (!A.value) {
150
+ j();
110
151
  return;
111
152
  }
112
- y && cancelAnimationFrame(y), y = requestAnimationFrame(() => {
113
- var p;
114
- y = 0;
115
- const e = n.value;
153
+ w && cancelAnimationFrame(w), w = requestAnimationFrame(() => {
154
+ var d;
155
+ w = 0;
156
+ const e = l.value;
116
157
  if (!e) {
117
- P();
158
+ j();
118
159
  return;
119
160
  }
120
- const t = e.selectionStart, o = e.selectionEnd;
121
- if (t === o) {
122
- v.value !== null && (v.value = null, S(c));
161
+ const t = e.selectionStart, n = e.selectionEnd;
162
+ if (t === n) {
163
+ T.value !== null && (T.value = null, b(g));
123
164
  return;
124
165
  }
125
- const i = v.value;
126
- if (i && i.start === t && i.end === o) return;
127
- const r = ((p = m.value) == null ? void 0 : p.scrollTop) ?? 0;
128
- v.value = { start: t, end: o }, S(() => {
129
- m.value && (m.value.scrollTop = r), c();
166
+ const i = T.value;
167
+ if (i && i.start === t && i.end === n) return;
168
+ const s = ((d = F.value) == null ? void 0 : d.scrollTop) ?? 0;
169
+ T.value = { start: t, end: n }, b(() => {
170
+ F.value && (F.value.scrollTop = s), g();
130
171
  });
131
172
  });
132
173
  }
133
- function re(e) {
134
- e.buttons && f();
174
+ function Ie(e) {
175
+ e.buttons && I();
135
176
  }
136
- function N() {
137
- document.activeElement === n.value && f();
177
+ function Z() {
178
+ document.activeElement === l.value && I();
138
179
  }
139
- const a = T, ue = _(() => !!(a.state == "disabled" || l().text == "" && !l().file || l().isRecording)), ce = _(() => {
180
+ const c = E, ee = x(() => {
181
+ const e = Number(c.maxAttachedFiles);
182
+ return Number.isFinite(e) && e > 0 ? Math.floor(e) : ie;
183
+ });
184
+ je("maxAttachedFiles", ee);
185
+ const be = x(
186
+ () => h("component.ChatInput.FilesSelectedCount").replace("{count}", String(v.value.length)).replace("{max}", String(ee.value))
187
+ ), Ce = x(() => !!(c.state == "disabled" || o().text == "" && !v.value.length || o().isRecording)), Fe = x(() => {
140
188
  var t;
141
- if (a.inputButtonColor)
142
- return a.inputButtonColor;
143
- if (!((t = a.selectedChannel) != null && t.channelId))
189
+ if (c.inputButtonColor)
190
+ return c.inputButtonColor;
191
+ if (!((t = c.selectedChannel) != null && t.channelId))
144
192
  return "#25D366";
145
- const e = a.selectedChannel.channelId.toLowerCase();
193
+ const e = c.selectedChannel.channelId.toLowerCase();
146
194
  return e.includes("whatsapp") || e.includes("waba") ? "#25D366" : e.includes("telegram") ? "#37AFE2" : e.includes("sms") ? "#6C757D" : e.includes("max") ? "#4B0082" : "#25D366";
147
- }), de = _(() => {
195
+ }), Te = x(() => {
148
196
  var t;
149
- if (!((t = a.selectedChannel) != null && t.channelId))
150
- return I("component.ChatInput.InputPlaceholder");
151
- const e = a.selectedChannel.channelId.toLowerCase();
152
- return e.includes("whatsapp") || e.includes("waba") ? I("component.ChatInput.WhatsappInputPlaceholder") : e.includes("telegram") ? I("component.ChatInput.TelegramInputPlaceholder") : e.includes("sms") ? I("component.ChatInput.SmsInputPlaceholder") : e.includes("max") ? I("component.ChatInput.MaxInputPlaceholder") : I("component.ChatInput.InputPlaceholder");
197
+ if (!((t = c.selectedChannel) != null && t.channelId))
198
+ return h("component.ChatInput.InputPlaceholder");
199
+ const e = c.selectedChannel.channelId.toLowerCase();
200
+ return e.includes("whatsapp") || e.includes("waba") ? h("component.ChatInput.WhatsappInputPlaceholder") : e.includes("telegram") ? h("component.ChatInput.TelegramInputPlaceholder") : e.includes("sms") ? h("component.ChatInput.SmsInputPlaceholder") : e.includes("max") ? h("component.ChatInput.MaxInputPlaceholder") : h("component.ChatInput.InputPlaceholder");
153
201
  });
154
- d(
155
- () => oe.value,
202
+ p(
203
+ () => ve.value,
156
204
  () => {
157
- L("typing");
205
+ H("typing");
158
206
  }
159
- ), d(
160
- () => {
161
- var e;
162
- return (e = l().edit) == null ? void 0 : e.messageId;
163
- },
164
- (e, t) => {
165
- e != null && e !== t && (w.value = !0, S(() => {
166
- if (!w.value) return;
167
- const o = n.value;
168
- o && (C(o), w.value = !1, H(o), requestAnimationFrame(() => H(o)));
169
- }));
207
+ );
208
+ function te(e = !1) {
209
+ b(() => {
210
+ if (e && !k.value) return;
211
+ const t = l.value;
212
+ t && (L(t), e && (k.value = !1), q(t), requestAnimationFrame(() => q(t)));
213
+ });
214
+ }
215
+ p(
216
+ () => o().edit,
217
+ (e) => {
218
+ (e == null ? void 0 : e.messageId) != null && (k.value = !0, te(!0));
170
219
  }
171
- ), d(
172
- () => a.focusOnInputArea,
220
+ ), p(
221
+ () => o().reply,
222
+ (e) => {
223
+ (e == null ? void 0 : e.messageId) != null && te();
224
+ }
225
+ ), p(
226
+ () => c.focusOnInputArea,
173
227
  () => {
174
- a.focusOnInputArea && S(() => {
175
- const e = u(n);
228
+ c.focusOnInputArea && b(() => {
229
+ const e = a(l);
176
230
  e == null || e.focus();
177
231
  });
178
232
  },
179
233
  { immediate: !0 }
180
- ), d(
181
- () => l().text,
234
+ ), p(
235
+ () => o().text,
182
236
  () => {
183
- const e = n.value;
184
- e && (C(e), w.value && (w.value = !1, H(e), requestAnimationFrame(() => H(e))));
237
+ const e = l.value;
238
+ e && (L(e), k.value && (k.value = !1, q(e), requestAnimationFrame(() => q(e))));
185
239
  },
186
240
  { immediate: !0, flush: "post" }
187
- ), d(
188
- () => l().id,
241
+ ), p(
242
+ () => o().id,
189
243
  () => {
190
- const e = n.value;
191
- e && (R(e), requestAnimationFrame(() => {
192
- const t = n.value;
193
- t && C(t);
244
+ const e = l.value;
245
+ e && (P(e), requestAnimationFrame(() => {
246
+ const t = l.value;
247
+ t && L(t);
194
248
  }));
195
249
  }
196
- ), d(g, (e) => {
197
- e && S(() => {
198
- const t = n.value;
250
+ ), p(A, (e) => {
251
+ e && b(() => {
252
+ const t = l.value;
199
253
  if (!t) return;
200
- const o = t.scrollTop;
201
- C(t), t.scrollTop = o, c(), requestAnimationFrame(c);
254
+ const n = t.scrollTop;
255
+ L(t), t.scrollTop = n, g(), requestAnimationFrame(g);
202
256
  });
203
257
  });
204
- function R(e) {
205
- const t = l().inputHeight;
206
- e.style.height = (t || z) + "px", (!t || t <= z) && (e.style.overflowY = "hidden");
258
+ function P(e) {
259
+ const t = o().inputHeight;
260
+ e.style.height = (t || Y) + "px", (!t || t <= Y) && (e.style.overflowY = "hidden");
207
261
  }
208
- function fe(e) {
262
+ function Ae(e) {
209
263
  const t = parseFloat(e.style.height);
210
- Number.isFinite(t) && (l().inputHeight = t);
264
+ Number.isFinite(t) && (o().inputHeight = t);
211
265
  }
212
- function C(e) {
213
- const t = l().text || "";
266
+ function L(e) {
267
+ const t = o().text || "";
214
268
  if (e.value !== t || e.clientWidth === 0) {
215
- R(e);
269
+ P(e);
216
270
  return;
217
271
  }
218
- const o = e.scrollTop;
272
+ const n = e.scrollTop;
219
273
  e.style.height = "auto";
220
- const i = getComputedStyle(e), r = parseFloat(i.fontSize) || 16, p = parseFloat(i.lineHeight) || r * 1.4, x = z, A = p * 11, B = e.scrollHeight, xe = t.split(`
221
- `).length > 1, s = document.createElement("div");
222
- s.style.position = "absolute", s.style.visibility = "hidden", s.style.whiteSpace = "nowrap", s.style.font = i.font, s.style.fontSize = i.fontSize, s.style.fontFamily = i.fontFamily, s.style.fontWeight = i.fontWeight, s.style.letterSpacing = i.letterSpacing, s.textContent = t, document.body.appendChild(s);
223
- const _e = s.offsetWidth;
224
- document.body.removeChild(s);
225
- const Se = parseFloat(i.paddingLeft) || 0, Ie = parseFloat(i.paddingRight) || 0, Te = e.clientWidth - Se - Ie, be = _e > Te, G = xe || be;
226
- if (G && B <= x + 1) {
227
- R(e);
274
+ const i = getComputedStyle(e), s = parseFloat(i.fontSize) || 16, d = parseFloat(i.lineHeight) || s * 1.4, f = Y, y = d * 11, G = e.scrollHeight, He = t.split(`
275
+ `).length > 1, r = document.createElement("div");
276
+ r.style.position = "absolute", r.style.visibility = "hidden", r.style.whiteSpace = "nowrap", r.style.font = i.font, r.style.fontSize = i.fontSize, r.style.fontFamily = i.fontFamily, r.style.fontWeight = i.fontWeight, r.style.letterSpacing = i.letterSpacing, r.textContent = t, document.body.appendChild(r);
277
+ const De = r.offsetWidth;
278
+ document.body.removeChild(r);
279
+ const We = parseFloat(i.paddingLeft) || 0, Pe = parseFloat(i.paddingRight) || 0, qe = e.clientWidth - We - Pe, ze = De > qe, ne = He || ze;
280
+ if (ne && G <= f + 1) {
281
+ P(e);
228
282
  return;
229
283
  }
230
- t.trim() && G ? B <= A ? (e.style.height = B + "px", e.style.overflowY = "hidden") : (e.style.height = A + "px", e.style.overflowY = "auto", e.scrollTop = o) : (e.style.height = x + "px", e.style.overflowY = "hidden"), fe(e), c(), requestAnimationFrame(c);
284
+ t.trim() && ne ? G <= y ? (e.style.height = G + "px", e.style.overflowY = "hidden") : (e.style.height = y + "px", e.style.overflowY = "auto", e.scrollTop = n) : (e.style.height = f + "px", e.style.overflowY = "hidden"), Ae(e), g(), requestAnimationFrame(g);
231
285
  }
232
- function H(e) {
233
- if (a.state === "disabled" || l().isRecording) return;
286
+ function q(e) {
287
+ if (c.state === "disabled" || o().isRecording) return;
234
288
  const t = e.value.length;
235
- e.focus(), e.setSelectionRange(t, t), e.scrollTop = e.scrollHeight, c();
289
+ e.focus(), e.setSelectionRange(t, t), e.scrollTop = e.scrollHeight, g();
236
290
  }
237
- d(
238
- () => l().forceSend,
291
+ p(
292
+ () => o().forceSend,
239
293
  () => {
240
- l().forceSend && (q(), Z(!1));
294
+ o().forceSend && ($(), de(!1));
241
295
  }
242
296
  );
243
- const pe = (e) => {
297
+ const we = (e) => {
244
298
  const t = e.target;
245
- L("typing", t.value), f();
299
+ H("typing", t.value), I();
246
300
  };
247
- Ae(() => {
248
- const e = n.value;
249
- e && (R(e), C(e)), document.addEventListener("selectionchange", N);
250
- }), Ee(() => {
251
- Pe(K), document.removeEventListener("selectionchange", N), y && cancelAnimationFrame(y);
301
+ p(
302
+ v,
303
+ (e, t) => {
304
+ b(() => {
305
+ Q(), W();
306
+ const n = R.value;
307
+ n && e.length > ((t == null ? void 0 : t.length) ?? 0) && n.scrollTo({ left: n.scrollWidth, behavior: "smooth" });
308
+ });
309
+ },
310
+ { flush: "post" }
311
+ ), Ke(() => {
312
+ const e = l.value;
313
+ e && (P(e), L(e)), Q(), W(), document.addEventListener("selectionchange", Z);
314
+ }), $e(() => {
315
+ et(X), document.removeEventListener("selectionchange", Z), m == null || m.disconnect(), w && cancelAnimationFrame(w);
252
316
  });
253
- const he = (e) => {
317
+ const Ee = (e) => {
254
318
  if (e.shiftKey) {
255
- if (n.value instanceof HTMLTextAreaElement) {
256
- let t = n.value.selectionStart;
257
- t && (n.value.setRangeText(`
258
- `, t, t, "end"), M(n.value.value));
319
+ if (l.value instanceof HTMLTextAreaElement) {
320
+ let t = l.value.selectionStart;
321
+ t && (l.value.setRangeText(`
322
+ `, t, t, "end"), D(l.value.value));
259
323
  }
260
324
  e.preventDefault();
261
325
  } else if (e.ctrlKey) {
262
- if (n.value instanceof HTMLTextAreaElement) {
263
- let t = n.value.selectionStart;
264
- t && (n.value.setRangeText(`
265
- `, t, t, "end"), M(n.value.value));
326
+ if (l.value instanceof HTMLTextAreaElement) {
327
+ let t = l.value.selectionStart;
328
+ t && (l.value.setRangeText(`
329
+ `, t, t, "end"), D(l.value.value));
266
330
  }
267
331
  e.preventDefault();
268
332
  } else
269
- e.preventDefault(), q();
270
- }, me = (e) => {
271
- if (n.value) {
272
- const t = n.value.value;
273
- n.value.value = e.newText;
274
- const o = e.newText.length - (t.length - (e.end - e.start)), i = e.start + o;
275
- M(e.newText), S(() => {
276
- n.value && (n.value.setSelectionRange(i, i), n.value.focus());
333
+ e.preventDefault(), $();
334
+ }, Me = (e) => {
335
+ if (l.value) {
336
+ const t = l.value.value;
337
+ l.value.value = e.newText;
338
+ const n = e.newText.length - (t.length - (e.end - e.start)), i = e.start + n;
339
+ D(e.newText), b(() => {
340
+ l.value && (l.value.setSelectionRange(i, i), l.value.focus());
277
341
  });
278
342
  }
279
343
  };
280
- function ve() {
281
- te();
344
+ function Re(e) {
345
+ pe(e);
282
346
  }
283
- function ge() {
284
- ee(), M(""), je(b), n.value && n.value.focus();
347
+ function ke() {
348
+ fe(), D(""), it(M), l.value && l.value.focus();
285
349
  }
286
- function ye() {
287
- const e = l();
350
+ function Le() {
351
+ const e = o();
288
352
  return e.edit ? (e.text ?? "").trim() === (e.edit.text ?? "").trim() : !1;
289
353
  }
290
- const q = () => {
291
- var t, o;
292
- const e = E(l());
293
- if (e.value.edit && ye()) {
294
- ge();
354
+ const $ = () => {
355
+ const e = _(o());
356
+ if (e.value.edit && Le() && !v.value.length) {
357
+ ke();
295
358
  return;
296
359
  }
297
- if (e.value.text != "" || e.value.file) {
298
- const i = {
360
+ if (e.value.text != "" || v.value.length) {
361
+ const t = {
299
362
  type: "",
300
363
  text: "",
301
364
  url: "",
302
365
  filename: "",
303
366
  size: "",
304
367
  reply: void 0
305
- };
306
- e.value.file ? (i.type = "message." + e.value.file.type, i.url = e.value.file.url, i.filename = e.value.file.name, i.size = (t = e.value.file.size) == null ? void 0 : t.toString(), i.text = (o = e == null ? void 0 : e.value) == null ? void 0 : o.text.trim()) : (i.type = "message.text", i.text = e.value.text.trim()), e.value.reply && (i.reply = e.value.reply), e.value.edit && (i.edit = e.value.edit), L("send", i), X(), n.value && n.value.focus();
368
+ }, n = v.value;
369
+ if (n.length) {
370
+ const i = e.value.text.trim();
371
+ n.forEach((s, d) => {
372
+ var y;
373
+ const f = {
374
+ type: "message." + s.type,
375
+ url: s.url,
376
+ filename: s.name,
377
+ size: (y = s.size) == null ? void 0 : y.toString(),
378
+ text: d === 0 ? i : ""
379
+ };
380
+ d === 0 && (e.value.reply && (f.reply = e.value.reply), e.value.edit && (f.edit = e.value.edit)), H("send", f);
381
+ });
382
+ } else
383
+ t.type = "message.text", t.text = e.value.text.trim(), e.value.reply && (t.reply = e.value.reply), e.value.edit && (t.edit = e.value.edit), H("send", t);
384
+ ce(), l.value && l.value.focus();
307
385
  }
308
386
  };
309
- return (e, t) => (F(), k("div", Ge, [
310
- h("div", {
311
- id: "chat-input-reply-line-" + u(b),
387
+ return (e, t) => (S(), C("div", rt, [
388
+ u("div", {
389
+ id: "chat-input-reply-line-" + a(M),
312
390
  class: "chat-input__reply-line"
313
- }, null, 8, Oe),
314
- h("div", {
315
- id: "chat-input-file-line-" + u(b),
316
- class: j(["chat-input__file-line", { "chat-input__file-line--visible": !!D.value }])
391
+ }, null, 8, ut),
392
+ u("div", {
393
+ id: "chat-input-file-line-" + a(M),
394
+ class: O(["chat-input__file-line", { "chat-input__file-line--visible": v.value.length > 0 }])
317
395
  }, [
318
- D.value ? (F(), Fe(Ne, {
319
- key: 0,
320
- "file-info": D.value,
321
- onReset: ve
322
- }, null, 8, ["file-info"])) : U("", !0)
323
- ], 10, Ue),
324
- h("div", Ye, [
325
- Y(e.$slots, "inline-buttons", {}, void 0, !0)
396
+ u("span", dt, [
397
+ u("span", null, U(a(h)("component.ChatInput.FilesSelected")), 1),
398
+ u("span", null, U(be.value), 1)
399
+ ]),
400
+ u("div", ft, [
401
+ B.value ? (S(), C("button", {
402
+ key: 0,
403
+ type: "button",
404
+ class: "chat-input__file-scroll chat-input__file-scroll--left",
405
+ "aria-label": a(h)("component.ChatInput.FilesScrollLeft"),
406
+ onClick: t[0] || (t[0] = (n) => J("left"))
407
+ }, [
408
+ z(a(re))
409
+ ], 8, pt)) : V("", !0),
410
+ u("div", {
411
+ ref_key: "refFileChips",
412
+ ref: R,
413
+ class: "chat-input__file-chips",
414
+ onScroll: W
415
+ }, [
416
+ (S(!0), C(Ge, null, Oe(v.value, (n, i) => (S(), Ue(at, {
417
+ key: (n.url || n.name || "") + "-" + i,
418
+ "file-info": ye(n),
419
+ onReset: (s) => Re(i)
420
+ }, null, 8, ["file-info", "onReset"]))), 128))
421
+ ], 544),
422
+ N.value ? (S(), C("button", {
423
+ key: 1,
424
+ type: "button",
425
+ class: "chat-input__file-scroll chat-input__file-scroll--right",
426
+ "aria-label": a(h)("component.ChatInput.FilesScrollRight"),
427
+ onClick: t[1] || (t[1] = (n) => J("right"))
428
+ }, [
429
+ z(a(re))
430
+ ], 8, ht)) : V("", !0)
431
+ ])
432
+ ], 10, ct),
433
+ u("div", mt, [
434
+ le(e.$slots, "inline-buttons", {}, void 0, !0)
326
435
  ]),
327
- T.disabledPlaceholder && (T.state == "disabled" || u(l)().isRecording) ? (F(), k("div", Ve, Me(T.disabledPlaceholder), 1)) : (F(), k("div", $e, [
328
- g.value ? (F(), k("div", {
436
+ E.disabledPlaceholder && (E.state == "disabled" || a(o)().isRecording) ? (S(), C("div", vt, U(E.disabledPlaceholder), 1)) : (S(), C("div", gt, [
437
+ A.value ? (S(), C("div", {
329
438
  key: 0,
330
439
  ref_key: "refMirror",
331
- ref: m,
440
+ ref: F,
332
441
  class: "chat-input__input-mirror",
333
442
  "aria-hidden": "true",
334
- innerHTML: le.value
335
- }, null, 8, Je)) : U("", !0),
336
- Re(h("textarea", {
443
+ innerHTML: _e.value
444
+ }, null, 8, yt)) : V("", !0),
445
+ Ve(u("textarea", {
337
446
  ref_key: "refInput",
338
- ref: n,
339
- "onUpdate:modelValue": t[0] || (t[0] = (o) => u(l)().text = o),
447
+ ref: l,
448
+ "onUpdate:modelValue": t[2] || (t[2] = (n) => a(o)().text = n),
340
449
  rows: "1",
341
- disabled: T.state == "disabled" || u(l)().isRecording,
342
- class: j(["chat-input__input", { "chat-input__input--emoji-images": g.value }]),
343
- placeholder: de.value,
450
+ disabled: E.state == "disabled" || a(o)().isRecording,
451
+ class: O(["chat-input__input", { "chat-input__input--emoji-images": A.value }]),
452
+ placeholder: Te.value,
344
453
  onKeydown: [
345
- ae,
346
- He(he, ["enter"])
454
+ Se,
455
+ Ye(Ee, ["enter"])
347
456
  ],
348
- onInput: pe,
349
- onScroll: c,
350
- onSelect: f,
351
- onMouseup: W,
352
- onKeyup: W,
353
- onMousemove: re,
354
- onBlur: P
355
- }, null, 42, Qe), [
356
- [ke, u(l)().text]
457
+ onInput: we,
458
+ onScroll: g,
459
+ onSelect: I,
460
+ onMouseup: K,
461
+ onKeyup: K,
462
+ onMousemove: Ie,
463
+ onBlur: j
464
+ }, null, 42, _t), [
465
+ [Xe, a(o)().text]
357
466
  ])
358
467
  ])),
359
- O(Ke, {
360
- textarea: n.value,
361
- onFormatApplied: me
468
+ z(st, {
469
+ textarea: l.value,
470
+ onFormatApplied: Me
362
471
  }, null, 8, ["textarea"]),
363
- h("button", {
364
- class: j(["chat-input__button", { "chat-input__button-disabled": ue.value }]),
365
- disabled: u(l)().isRecording,
366
- onClick: q
472
+ u("button", {
473
+ class: O(["chat-input__button", { "chat-input__button-disabled": Ce.value }]),
474
+ disabled: a(o)().isRecording,
475
+ onClick: $
367
476
  }, [
368
- h("span", Ze, [
369
- O(u(ze), { color: ce.value }, null, 8, ["color"])
477
+ u("span", St, [
478
+ z(a(ot), { color: Fe.value }, null, 8, ["color"])
370
479
  ])
371
- ], 10, Xe),
372
- h("div", et, [
373
- Y(e.$slots, "buttons", {}, void 0, !0)
480
+ ], 10, xt),
481
+ u("div", It, [
482
+ le(e.$slots, "buttons", {}, void 0, !0)
374
483
  ])
375
484
  ]));
376
485
  }
377
486
  });
378
487
  export {
379
- _t as default
488
+ Kt as default
380
489
  };