@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.
@@ -1,123 +1,144 @@
1
- import { ref as R, getCurrentInstance as D, inject as C, computed as F, unref as P, watch as S } from "vue";
2
- const r = R([]);
3
- function T(e) {
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: e,
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(e) {
13
- const i = r.value.find((c) => c.id === e);
12
+ function f(t) {
13
+ const i = o.value.find((c) => c.id === t);
14
14
  if (i) return i;
15
- const s = T(e);
16
- return r.value.push(s), s;
15
+ const s = S(t);
16
+ return o.value.push(s), s;
17
17
  }
18
- function B(e, i) {
18
+ function k(t, i) {
19
19
  if (!(i == null || i === ""))
20
- return r.value.find((s) => s.id === `${e}:${i}`);
20
+ return o.value.find((s) => s.id === `${t}:${i}`);
21
21
  }
22
- function E(e) {
23
- return e.replace(/\s+/g, " ").trim();
22
+ function v(t) {
23
+ return t.replace(/\s+/g, " ").trim();
24
24
  }
25
- function a(e) {
26
- var c, u, o;
27
- if (!e) return;
28
- if (e.edit) {
29
- e.listPreviewText = void 0, e.listPreviewFile = void 0;
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 = E(e.text || "");
33
- e.listPreviewText = i || void 0;
34
- const s = ((c = e.file) == null ? void 0 : c.name) || ((o = (u = e.file) == null ? void 0 : u.preview) == null ? void 0 : o.fileName) || "";
35
- e.listPreviewFile = e.file ? { name: s, type: e.file.type } : void 0;
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 b(e) {
38
- e && a(r.value.find((i) => i.id === e));
37
+ function E(t) {
38
+ return !!(v(t.text || "") || t.file);
39
39
  }
40
- function L(e, i) {
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-" + e);
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 k = (e) => {
46
- const i = D() ? C("selectedChat", void 0) : void 0, s = F(() => {
47
- const t = i ? P(i) : void 0, n = t == null ? void 0 : t.chatId;
48
- return n == null || n === "" ? e : `${e}:${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
- S(
56
+ a(
51
57
  s,
52
- (t, n) => {
53
- const l = f(t);
54
- if (n !== void 0 && n !== t) {
55
- const w = r.value.find((h) => h.id === n);
56
- a(w), L(e, l);
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 t = s.value, n = r.value.findIndex((l) => l.id === t);
63
- return n !== -1 ? n : (f(t), r.value.findIndex((l) => l.id === t));
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 t = d();
66
- r.value[c()] = {
67
- id: t.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: t.isRecording
94
+ isRecording: e.isRecording
74
95
  };
75
- }, o = (t) => {
76
- const n = d();
77
- r.value[c()] = {
96
+ }, r = (e) => {
97
+ const n = l();
98
+ o.value[c()] = {
78
99
  ...n,
79
100
  forceSend: !1,
80
- ...t,
101
+ ...e,
81
102
  id: n.id
82
103
  };
83
- }, v = (t) => {
84
- o({ text: t });
85
- }, g = (t) => {
86
- o({ file: t });
87
- }, p = () => {
88
- o({ file: void 0 });
89
- }, m = (t) => {
90
- o({ reply: t, edit: void 0 });
91
- }, y = () => {
92
- o({ reply: void 0 });
93
- }, x = (t) => {
94
- o({ edit: t, reply: void 0 });
95
- }, M = () => {
96
- o({ edit: void 0 });
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 d() {
119
+ function l() {
99
120
  return f(s.value);
100
121
  }
101
122
  return {
102
- getMessage: d,
123
+ getMessage: l,
103
124
  resetMessage: u,
104
- setMessageFile: g,
105
- resetMessageFile: p,
106
- setMessageText: v,
107
- setReply: m,
108
- resetReply: y,
109
- setEdit: x,
110
- resetEdit: M,
111
- setForceSendMessage: (t) => {
112
- d().forceSend = t;
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: (t) => {
115
- d().isRecording = t;
135
+ setRecordingMessage: (e) => {
136
+ l().isRecording = e;
116
137
  }
117
138
  };
118
139
  };
119
140
  export {
120
- b as commitChatDraftToList,
121
- B as getChatDraft,
122
- k as useMessageDraft
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mobilon-dev/chotto",
3
- "version": "0.3.93",
3
+ "version": "0.3.95",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",