@mobilon-dev/chotto 0.3.93 → 0.3.95
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_chatlist_elements/ChatItem/ChatItem.vue.js +2 -2
- package/dist/components/2_chatlist_elements/ChatItem/ChatItem.vue2.js +79 -79
- package/dist/components/3_compounds/Feed/Feed.vue.js +3 -3
- package/dist/components/3_compounds/Feed/Feed.vue2.js +147 -157
- package/dist/components/3_compounds/Feed/composables/useFeedScroll.js +81 -48
- package/dist/hooks/useMessageDraft.js +96 -75
- package/dist/types/components/3_compounds/Feed/composables/useFeedScroll.d.ts +5 -7
- package/package.json +1 -1
|
@@ -1,123 +1,144 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
1
|
+
import { ref as F, getCurrentInstance as R, inject as T, computed as C, unref as L, watch as a } from "vue";
|
|
2
|
+
const o = F([]);
|
|
3
|
+
function S(t) {
|
|
4
4
|
return {
|
|
5
|
-
id:
|
|
5
|
+
id: t,
|
|
6
6
|
text: "",
|
|
7
7
|
file: void 0,
|
|
8
8
|
forceSend: !1,
|
|
9
9
|
isRecording: !1
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
function f(
|
|
13
|
-
const i =
|
|
12
|
+
function f(t) {
|
|
13
|
+
const i = o.value.find((c) => c.id === t);
|
|
14
14
|
if (i) return i;
|
|
15
|
-
const s =
|
|
16
|
-
return
|
|
15
|
+
const s = S(t);
|
|
16
|
+
return o.value.push(s), s;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function k(t, i) {
|
|
19
19
|
if (!(i == null || i === ""))
|
|
20
|
-
return
|
|
20
|
+
return o.value.find((s) => s.id === `${t}:${i}`);
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
22
|
+
function v(t) {
|
|
23
|
+
return t.replace(/\s+/g, " ").trim();
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
var c, u,
|
|
27
|
-
if (!
|
|
28
|
-
if (
|
|
29
|
-
|
|
25
|
+
function g(t) {
|
|
26
|
+
var c, u, r;
|
|
27
|
+
if (!t) return;
|
|
28
|
+
if (t.edit) {
|
|
29
|
+
t.listPreviewText = void 0, t.listPreviewFile = void 0;
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const i =
|
|
33
|
-
|
|
34
|
-
const s = ((c =
|
|
35
|
-
|
|
32
|
+
const i = v(t.text || "");
|
|
33
|
+
t.listPreviewText = i || void 0;
|
|
34
|
+
const s = ((c = t.file) == null ? void 0 : c.name) || ((r = (u = t.file) == null ? void 0 : u.preview) == null ? void 0 : r.fileName) || "";
|
|
35
|
+
t.listPreviewFile = t.file ? { name: s, type: t.file.type } : void 0;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
37
|
+
function E(t) {
|
|
38
|
+
return !!(v(t.text || "") || t.file);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function $(t) {
|
|
41
|
+
t.listPreviewText = void 0, t.listPreviewFile = void 0;
|
|
42
|
+
}
|
|
43
|
+
function q(t) {
|
|
44
|
+
t && g(o.value.find((i) => i.id === t));
|
|
45
|
+
}
|
|
46
|
+
function B(t, i) {
|
|
41
47
|
if (typeof document > "u") return;
|
|
42
|
-
const s = document.getElementById("chat-input-reply-line-" +
|
|
48
|
+
const s = document.getElementById("chat-input-reply-line-" + t);
|
|
43
49
|
s && (s.style.display = i.reply || i.edit ? "inherit" : "none");
|
|
44
50
|
}
|
|
45
|
-
const
|
|
46
|
-
const i =
|
|
47
|
-
const
|
|
48
|
-
return n == null || n === "" ?
|
|
51
|
+
const z = (t) => {
|
|
52
|
+
const i = R() ? T("selectedChat", void 0) : void 0, s = C(() => {
|
|
53
|
+
const e = i ? L(i) : void 0, n = e == null ? void 0 : e.chatId;
|
|
54
|
+
return n == null || n === "" ? t : `${t}:${n}`;
|
|
49
55
|
});
|
|
50
|
-
|
|
56
|
+
a(
|
|
51
57
|
s,
|
|
52
|
-
(
|
|
53
|
-
const
|
|
54
|
-
if (n !== void 0 && n !==
|
|
55
|
-
const
|
|
56
|
-
|
|
58
|
+
(e, n) => {
|
|
59
|
+
const d = f(e);
|
|
60
|
+
if (n !== void 0 && n !== e) {
|
|
61
|
+
const h = o.value.find((D) => D.id === n);
|
|
62
|
+
g(h), B(t, d);
|
|
57
63
|
}
|
|
58
64
|
},
|
|
59
65
|
{ immediate: !0 }
|
|
66
|
+
), a(
|
|
67
|
+
() => {
|
|
68
|
+
const e = l();
|
|
69
|
+
return [e.text, e.file];
|
|
70
|
+
},
|
|
71
|
+
() => {
|
|
72
|
+
const e = l();
|
|
73
|
+
if (!e.edit) {
|
|
74
|
+
if (!E(e)) {
|
|
75
|
+
$(e);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
e.file || (e.listPreviewFile = void 0), v(e.text || "") || (e.listPreviewText = void 0);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
60
81
|
);
|
|
61
82
|
const c = () => {
|
|
62
|
-
const
|
|
63
|
-
return n !== -1 ? n : (f(
|
|
83
|
+
const e = s.value, n = o.value.findIndex((d) => d.id === e);
|
|
84
|
+
return n !== -1 ? n : (f(e), o.value.findIndex((d) => d.id === e));
|
|
64
85
|
}, u = () => {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
id:
|
|
86
|
+
const e = l();
|
|
87
|
+
o.value[c()] = {
|
|
88
|
+
id: e.id,
|
|
68
89
|
text: "",
|
|
69
90
|
file: void 0,
|
|
70
91
|
reply: void 0,
|
|
71
92
|
edit: void 0,
|
|
72
93
|
forceSend: !1,
|
|
73
|
-
isRecording:
|
|
94
|
+
isRecording: e.isRecording
|
|
74
95
|
};
|
|
75
|
-
},
|
|
76
|
-
const n =
|
|
77
|
-
|
|
96
|
+
}, r = (e) => {
|
|
97
|
+
const n = l();
|
|
98
|
+
o.value[c()] = {
|
|
78
99
|
...n,
|
|
79
100
|
forceSend: !1,
|
|
80
|
-
...
|
|
101
|
+
...e,
|
|
81
102
|
id: n.id
|
|
82
103
|
};
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
|
|
104
|
+
}, p = (e) => {
|
|
105
|
+
r({ text: e });
|
|
106
|
+
}, m = (e) => {
|
|
107
|
+
r({ file: e });
|
|
108
|
+
}, x = () => {
|
|
109
|
+
r({ file: void 0 });
|
|
110
|
+
}, y = (e) => {
|
|
111
|
+
r({ reply: e, edit: void 0 });
|
|
112
|
+
}, w = () => {
|
|
113
|
+
r({ reply: void 0 });
|
|
114
|
+
}, M = (e) => {
|
|
115
|
+
r({ edit: e, reply: void 0 });
|
|
116
|
+
}, P = () => {
|
|
117
|
+
r({ edit: void 0 });
|
|
97
118
|
};
|
|
98
|
-
function
|
|
119
|
+
function l() {
|
|
99
120
|
return f(s.value);
|
|
100
121
|
}
|
|
101
122
|
return {
|
|
102
|
-
getMessage:
|
|
123
|
+
getMessage: l,
|
|
103
124
|
resetMessage: u,
|
|
104
|
-
setMessageFile:
|
|
105
|
-
resetMessageFile:
|
|
106
|
-
setMessageText:
|
|
107
|
-
setReply:
|
|
108
|
-
resetReply:
|
|
109
|
-
setEdit:
|
|
110
|
-
resetEdit:
|
|
111
|
-
setForceSendMessage: (
|
|
112
|
-
|
|
125
|
+
setMessageFile: m,
|
|
126
|
+
resetMessageFile: x,
|
|
127
|
+
setMessageText: p,
|
|
128
|
+
setReply: y,
|
|
129
|
+
resetReply: w,
|
|
130
|
+
setEdit: M,
|
|
131
|
+
resetEdit: P,
|
|
132
|
+
setForceSendMessage: (e) => {
|
|
133
|
+
l().forceSend = e;
|
|
113
134
|
},
|
|
114
|
-
setRecordingMessage: (
|
|
115
|
-
|
|
135
|
+
setRecordingMessage: (e) => {
|
|
136
|
+
l().isRecording = e;
|
|
116
137
|
}
|
|
117
138
|
};
|
|
118
139
|
};
|
|
119
140
|
export {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
141
|
+
q as commitChatDraftToList,
|
|
142
|
+
k as getChatDraft,
|
|
143
|
+
z as useMessageDraft
|
|
123
144
|
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
2
|
/**
|
|
3
3
|
* Композабл для управления скроллом ленты сообщений.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Параметры и зависимости композабла.
|
|
4
|
+
*
|
|
5
|
+
* Вместо серии отложенных «подтверждающих» скроллов используется
|
|
6
|
+
* режим stick-to-bottom: при открытии чата лента прижимается вниз
|
|
7
|
+
* и остаётся там, пока растёт контент (картинки, клавиатура и т.п.).
|
|
8
|
+
* Любой пользовательский скролл сразу выключает этот режим.
|
|
10
9
|
*/
|
|
11
10
|
interface UseFeedScrollOptions<T = unknown> {
|
|
12
11
|
/** Ссылка на DOM-элемент контейнера ленты */
|
|
@@ -19,7 +18,6 @@ interface UseFeedScrollOptions<T = unknown> {
|
|
|
19
18
|
export declare function useFeedScroll<T = unknown>({ feedRef, objectsRef, scrollToBottomRef }: UseFeedScrollOptions<T>): {
|
|
20
19
|
isInitialized: Ref<boolean, boolean>;
|
|
21
20
|
performScrollToBottom: () => void;
|
|
22
|
-
ensureScrollToBottom: () => void;
|
|
23
21
|
initializeScroll: () => void;
|
|
24
22
|
smoothScrollToBottom: () => void;
|
|
25
23
|
};
|