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