@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.
- 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 +334 -225
- package/dist/components/3_compounds/ChatInput/icons/ArrowIcon.vue.js +40 -0
- package/dist/hooks/uploadFile/generatePreview.js +19 -18
- package/dist/hooks/useMessageDraft.js +85 -65
- package/dist/index.js +159 -157
- 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 +14 -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/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,29 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useImmediateDebouncedRef as
|
|
3
|
-
import { useMessageDraft as
|
|
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
|
|
6
|
+
import { useEmojiNative as tt } 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 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
|
-
},
|
|
23
|
+
}, gt = {
|
|
23
24
|
key: 1,
|
|
24
25
|
class: "chat-input__input-wrap"
|
|
25
|
-
},
|
|
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(
|
|
55
|
-
const
|
|
56
|
-
let
|
|
57
|
-
|
|
58
|
-
() =>
|
|
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
|
-
|
|
66
|
+
X = e;
|
|
61
67
|
}
|
|
62
68
|
);
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
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
|
|
76
|
-
function
|
|
77
|
-
|
|
116
|
+
let w = 0;
|
|
117
|
+
function j() {
|
|
118
|
+
T.value = null;
|
|
78
119
|
}
|
|
79
|
-
function
|
|
80
|
-
const t =
|
|
81
|
-
if (!t || !
|
|
82
|
-
const
|
|
83
|
-
(i !== t.selectionStart ||
|
|
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
|
|
86
|
-
|
|
126
|
+
function K() {
|
|
127
|
+
xe("nearest"), I();
|
|
87
128
|
}
|
|
88
|
-
function
|
|
89
|
-
if (!
|
|
90
|
-
const t =
|
|
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
|
|
133
|
+
const n = t.value, i = t.selectionStart !== t.selectionEnd;
|
|
93
134
|
if (e.shiftKey) {
|
|
94
|
-
requestAnimationFrame(() =>
|
|
135
|
+
requestAnimationFrame(() => K());
|
|
95
136
|
return;
|
|
96
137
|
}
|
|
97
138
|
if (i) {
|
|
98
139
|
e.preventDefault();
|
|
99
|
-
const
|
|
100
|
-
t.setSelectionRange(
|
|
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
|
|
105
|
-
t.setSelectionRange(
|
|
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
|
|
108
|
-
if (!
|
|
109
|
-
|
|
148
|
+
function I() {
|
|
149
|
+
if (!A.value) {
|
|
150
|
+
j();
|
|
110
151
|
return;
|
|
111
152
|
}
|
|
112
|
-
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
const e =
|
|
153
|
+
w && cancelAnimationFrame(w), w = requestAnimationFrame(() => {
|
|
154
|
+
var d;
|
|
155
|
+
w = 0;
|
|
156
|
+
const e = l.value;
|
|
116
157
|
if (!e) {
|
|
117
|
-
|
|
158
|
+
j();
|
|
118
159
|
return;
|
|
119
160
|
}
|
|
120
|
-
const t = e.selectionStart,
|
|
121
|
-
if (t ===
|
|
122
|
-
|
|
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 =
|
|
126
|
-
if (i && i.start === t && i.end ===
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
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
|
|
134
|
-
e.buttons &&
|
|
174
|
+
function Ie(e) {
|
|
175
|
+
e.buttons && I();
|
|
135
176
|
}
|
|
136
|
-
function
|
|
137
|
-
document.activeElement ===
|
|
177
|
+
function Z() {
|
|
178
|
+
document.activeElement === l.value && I();
|
|
138
179
|
}
|
|
139
|
-
const
|
|
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 (
|
|
142
|
-
return
|
|
143
|
-
if (!((t =
|
|
189
|
+
if (c.inputButtonColor)
|
|
190
|
+
return c.inputButtonColor;
|
|
191
|
+
if (!((t = c.selectedChannel) != null && t.channelId))
|
|
144
192
|
return "#25D366";
|
|
145
|
-
const e =
|
|
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
|
-
}),
|
|
195
|
+
}), Te = x(() => {
|
|
148
196
|
var t;
|
|
149
|
-
if (!((t =
|
|
150
|
-
return
|
|
151
|
-
const e =
|
|
152
|
-
return e.includes("whatsapp") || e.includes("waba") ?
|
|
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
|
-
|
|
155
|
-
() =>
|
|
202
|
+
p(
|
|
203
|
+
() => ve.value,
|
|
156
204
|
() => {
|
|
157
|
-
|
|
205
|
+
H("typing");
|
|
158
206
|
}
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
),
|
|
172
|
-
() =>
|
|
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
|
-
|
|
175
|
-
const e =
|
|
228
|
+
c.focusOnInputArea && b(() => {
|
|
229
|
+
const e = a(l);
|
|
176
230
|
e == null || e.focus();
|
|
177
231
|
});
|
|
178
232
|
},
|
|
179
233
|
{ immediate: !0 }
|
|
180
|
-
),
|
|
181
|
-
() =>
|
|
234
|
+
), p(
|
|
235
|
+
() => o().text,
|
|
182
236
|
() => {
|
|
183
|
-
const e =
|
|
184
|
-
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
|
-
),
|
|
188
|
-
() =>
|
|
241
|
+
), p(
|
|
242
|
+
() => o().id,
|
|
189
243
|
() => {
|
|
190
|
-
const e =
|
|
191
|
-
e && (
|
|
192
|
-
const t =
|
|
193
|
-
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
|
-
),
|
|
197
|
-
e &&
|
|
198
|
-
const t =
|
|
250
|
+
), p(A, (e) => {
|
|
251
|
+
e && b(() => {
|
|
252
|
+
const t = l.value;
|
|
199
253
|
if (!t) return;
|
|
200
|
-
const
|
|
201
|
-
|
|
254
|
+
const n = t.scrollTop;
|
|
255
|
+
L(t), t.scrollTop = n, g(), requestAnimationFrame(g);
|
|
202
256
|
});
|
|
203
257
|
});
|
|
204
|
-
function
|
|
205
|
-
const t =
|
|
206
|
-
e.style.height = (t ||
|
|
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
|
|
262
|
+
function Ae(e) {
|
|
209
263
|
const t = parseFloat(e.style.height);
|
|
210
|
-
Number.isFinite(t) && (
|
|
264
|
+
Number.isFinite(t) && (o().inputHeight = t);
|
|
211
265
|
}
|
|
212
|
-
function
|
|
213
|
-
const t =
|
|
266
|
+
function L(e) {
|
|
267
|
+
const t = o().text || "";
|
|
214
268
|
if (e.value !== t || e.clientWidth === 0) {
|
|
215
|
-
|
|
269
|
+
P(e);
|
|
216
270
|
return;
|
|
217
271
|
}
|
|
218
|
-
const
|
|
272
|
+
const n = e.scrollTop;
|
|
219
273
|
e.style.height = "auto";
|
|
220
|
-
const i = getComputedStyle(e),
|
|
221
|
-
`).length > 1,
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
document.body.removeChild(
|
|
225
|
-
const
|
|
226
|
-
if (
|
|
227
|
-
|
|
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() &&
|
|
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
|
|
233
|
-
if (
|
|
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,
|
|
289
|
+
e.focus(), e.setSelectionRange(t, t), e.scrollTop = e.scrollHeight, g();
|
|
236
290
|
}
|
|
237
|
-
|
|
238
|
-
() =>
|
|
291
|
+
p(
|
|
292
|
+
() => o().forceSend,
|
|
239
293
|
() => {
|
|
240
|
-
|
|
294
|
+
o().forceSend && ($(), de(!1));
|
|
241
295
|
}
|
|
242
296
|
);
|
|
243
|
-
const
|
|
297
|
+
const we = (e) => {
|
|
244
298
|
const t = e.target;
|
|
245
|
-
|
|
299
|
+
H("typing", t.value), I();
|
|
246
300
|
};
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
|
317
|
+
const Ee = (e) => {
|
|
254
318
|
if (e.shiftKey) {
|
|
255
|
-
if (
|
|
256
|
-
let t =
|
|
257
|
-
t && (
|
|
258
|
-
`, t, t, "end"),
|
|
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 (
|
|
263
|
-
let t =
|
|
264
|
-
t && (
|
|
265
|
-
`, t, t, "end"),
|
|
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(),
|
|
270
|
-
},
|
|
271
|
-
if (
|
|
272
|
-
const t =
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
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
|
|
281
|
-
|
|
344
|
+
function Re(e) {
|
|
345
|
+
pe(e);
|
|
282
346
|
}
|
|
283
|
-
function
|
|
284
|
-
|
|
347
|
+
function ke() {
|
|
348
|
+
fe(), D(""), it(M), l.value && l.value.focus();
|
|
285
349
|
}
|
|
286
|
-
function
|
|
287
|
-
const e =
|
|
350
|
+
function Le() {
|
|
351
|
+
const e = o();
|
|
288
352
|
return e.edit ? (e.text ?? "").trim() === (e.edit.text ?? "").trim() : !1;
|
|
289
353
|
}
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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 != "" ||
|
|
298
|
-
const
|
|
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
|
-
|
|
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) => (
|
|
310
|
-
|
|
311
|
-
id: "chat-input-reply-line-" +
|
|
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,
|
|
314
|
-
|
|
315
|
-
id: "chat-input-file-line-" +
|
|
316
|
-
class:
|
|
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
|
-
|
|
319
|
-
|
|
320
|
-
"
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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
|
-
|
|
328
|
-
|
|
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:
|
|
440
|
+
ref: F,
|
|
332
441
|
class: "chat-input__input-mirror",
|
|
333
442
|
"aria-hidden": "true",
|
|
334
|
-
innerHTML:
|
|
335
|
-
}, null, 8,
|
|
336
|
-
|
|
443
|
+
innerHTML: _e.value
|
|
444
|
+
}, null, 8, yt)) : V("", !0),
|
|
445
|
+
Ve(u("textarea", {
|
|
337
446
|
ref_key: "refInput",
|
|
338
|
-
ref:
|
|
339
|
-
"onUpdate:modelValue": t[
|
|
447
|
+
ref: l,
|
|
448
|
+
"onUpdate:modelValue": t[2] || (t[2] = (n) => a(o)().text = n),
|
|
340
449
|
rows: "1",
|
|
341
|
-
disabled:
|
|
342
|
-
class:
|
|
343
|
-
placeholder:
|
|
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
|
-
|
|
346
|
-
|
|
454
|
+
Se,
|
|
455
|
+
Ye(Ee, ["enter"])
|
|
347
456
|
],
|
|
348
|
-
onInput:
|
|
349
|
-
onScroll:
|
|
350
|
-
onSelect:
|
|
351
|
-
onMouseup:
|
|
352
|
-
onKeyup:
|
|
353
|
-
onMousemove:
|
|
354
|
-
onBlur:
|
|
355
|
-
}, null, 42,
|
|
356
|
-
[
|
|
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
|
-
|
|
360
|
-
textarea:
|
|
361
|
-
onFormatApplied:
|
|
468
|
+
z(st, {
|
|
469
|
+
textarea: l.value,
|
|
470
|
+
onFormatApplied: Me
|
|
362
471
|
}, null, 8, ["textarea"]),
|
|
363
|
-
|
|
364
|
-
class:
|
|
365
|
-
disabled:
|
|
366
|
-
onClick:
|
|
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
|
-
|
|
369
|
-
|
|
477
|
+
u("span", St, [
|
|
478
|
+
z(a(ot), { color: Fe.value }, null, 8, ["color"])
|
|
370
479
|
])
|
|
371
|
-
], 10,
|
|
372
|
-
|
|
373
|
-
|
|
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
|
-
|
|
488
|
+
Kt as default
|
|
380
489
|
};
|