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