@mobilon-dev/chotto 0.3.116 → 0.3.118

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