@mobilon-dev/chotto 0.3.125 → 0.3.127

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.
Files changed (28) hide show
  1. package/dist/chotto.css +1 -1
  2. package/dist/components/2_blocks/CommunicationPanel/CommunicationPanel.vue.js +51 -51
  3. package/dist/components/2_blocks/CommunicationPanel/composables/useCommunicationActions.js +52 -50
  4. package/dist/components/2_blocks/FeedFoundItem/FeedFoundItem.vue.js +2 -2
  5. package/dist/components/2_blocks/FeedFoundItem/FeedFoundItem.vue2.js +41 -31
  6. package/dist/components/2_feed_elements/FeedReplyQuote/FeedReplyQuote.vue.js +2 -2
  7. package/dist/components/2_feed_elements/FeedReplyQuote/FeedReplyQuote.vue2.js +51 -30
  8. package/dist/components/2_feed_elements/ImageMessage/ImageMessage.vue.js +2 -2
  9. package/dist/components/2_feed_elements/ImageMessage/ImageMessage.vue2.js +286 -270
  10. package/dist/components/2_feed_elements/ReplyImageMessage/ReplyImageMessage.vue.js +3 -3
  11. package/dist/components/2_feed_elements/ReplyImageMessage/ReplyImageMessage.vue2.js +40 -34
  12. package/dist/components/3_compounds/ChatInput/ChatInput.vue.js +1 -1
  13. package/dist/components/3_compounds/ChatInput/ChatInput.vue2.js +282 -259
  14. package/dist/components/3_compounds/Feed/composables/useFeedScroll.js +79 -59
  15. package/dist/functions/parseMarkdown.js +7 -6
  16. package/dist/hooks/messages/useImageFeedSrc.js +50 -0
  17. package/dist/index.js +118 -113
  18. package/dist/themes/dark.css +1 -1
  19. package/dist/themes/default.css +1 -1
  20. package/dist/themes/glass.css +1 -1
  21. package/dist/themes/green.css +1 -1
  22. package/dist/themes/mobilon1.css +1 -1
  23. package/dist/types/src/components/2_feed_elements/ImageMessage/stories/ImageMessage.stories.d.ts +2 -0
  24. package/dist/types/src/components/3_compounds/Feed/composables/useFeedScroll.d.ts +3 -0
  25. package/dist/types/src/components/4_layouts/ChatWrapper/styles/types.d.ts +4 -0
  26. package/dist/types/src/hooks/messages/index.d.ts +1 -0
  27. package/dist/types/src/hooks/messages/useImageFeedSrc.d.ts +29 -0
  28. package/package.json +1 -1
@@ -1,98 +1,118 @@
1
- import { ref as S, watch as f, nextTick as h, onUnmounted as U } from "vue";
2
- function q({ feedRef: i, objectsRef: l, scrollToBottomRef: B }) {
3
- const a = S(!1), n = S(!1);
4
- let d = !1, u = !1, s = null, e = null;
5
- function c() {
6
- if (!n.value) return;
1
+ import { ref as k, watch as p, nextTick as w, onUnmounted as D } from "vue";
2
+ const N = 100;
3
+ function X({ feedRef: i, objectsRef: c, scrollToBottomRef: x }) {
4
+ const u = k(!1), o = k(!1);
5
+ let l = !1, v = !1, h = null, n = null, f = 0, d = 0;
6
+ function r() {
7
+ if (!o.value) return;
7
8
  const t = i.value;
8
- t && (d = !0, t.style.scrollBehavior = "auto", t.scrollTop = t.scrollHeight, requestAnimationFrame(() => {
9
- d = !1;
9
+ if (!t) return;
10
+ const e = t.scrollTop, T = Math.max(0, t.scrollHeight - t.clientHeight);
11
+ f = t.scrollHeight, d = t.clientHeight, !(Math.abs(e - T) < 1) && (l = !0, t.style.scrollBehavior = "auto", t.scrollTop = t.scrollHeight, requestAnimationFrame(() => {
12
+ l = !1;
10
13
  }));
11
14
  }
12
- function g() {
15
+ function A() {
13
16
  const t = i.value;
14
17
  if (!t) return;
15
- const o = t.scrollTop;
16
- t.style.scrollBehavior = "auto", t.scrollTop = o;
18
+ const e = t.scrollTop;
19
+ t.style.scrollBehavior = "auto", t.scrollTop = e;
17
20
  }
18
- function m() {
19
- n.value = !0, h(() => {
20
- c(), requestAnimationFrame(() => c());
21
+ function g() {
22
+ o.value = !0, w(() => {
23
+ r(), requestAnimationFrame(() => r());
21
24
  });
22
25
  }
23
- function r() {
24
- n.value && (n.value = !1, g());
25
- }
26
- function p(t) {
27
- e == null || e.disconnect(), e = new ResizeObserver(() => {
28
- c();
29
- }), e.observe(t);
30
- for (const o of t.children)
31
- o instanceof HTMLElement && e.observe(o);
26
+ function s() {
27
+ o.value && (o.value = !1, A());
32
28
  }
33
- function w() {
34
- u = !0;
29
+ function C() {
30
+ const t = i.value;
31
+ if (!t) return;
32
+ const { scrollHeight: e, clientHeight: T, scrollTop: F } = t, a = f, P = d;
33
+ if (f = e, d = T, !a && !P) {
34
+ o.value && r();
35
+ return;
36
+ }
37
+ const y = a - F - P;
38
+ if (o.value || y < N) {
39
+ o.value = !0, r();
40
+ return;
41
+ }
42
+ e !== a && e > a && (l = !0, t.style.scrollBehavior = "auto", t.scrollTop = F + (e - a), requestAnimationFrame(() => {
43
+ l = !1;
44
+ }));
35
45
  }
36
- function v() {
37
- u = !1;
46
+ function H(t) {
47
+ n == null || n.disconnect(), f = t.scrollHeight, d = t.clientHeight, n = new ResizeObserver(() => {
48
+ C();
49
+ }), n.observe(t);
50
+ for (const e of t.children)
51
+ e instanceof HTMLElement && n.observe(e);
38
52
  }
39
53
  function L() {
40
- d || u && r();
54
+ v = !0;
55
+ }
56
+ function m() {
57
+ v = !1;
58
+ }
59
+ function E() {
60
+ l || v && s();
41
61
  }
42
- function k(t) {
43
- t.addEventListener("wheel", r, { passive: !0 }), t.addEventListener("touchstart", r, { passive: !0 }), t.addEventListener("pointerdown", w), t.addEventListener("scroll", L, { passive: !0 }), window.addEventListener("pointerup", v), window.addEventListener("pointercancel", v);
62
+ function M(t) {
63
+ t.addEventListener("wheel", s, { passive: !0 }), t.addEventListener("touchstart", s, { passive: !0 }), t.addEventListener("pointerdown", L), t.addEventListener("scroll", E, { passive: !0 }), window.addEventListener("pointerup", m), window.addEventListener("pointercancel", m);
44
64
  }
45
- function E(t) {
46
- t.removeEventListener("wheel", r), t.removeEventListener("touchstart", r), t.removeEventListener("pointerdown", w), t.removeEventListener("scroll", L), window.removeEventListener("pointerup", v), window.removeEventListener("pointercancel", v), u = !1;
65
+ function B(t) {
66
+ t.removeEventListener("wheel", s), t.removeEventListener("touchstart", s), t.removeEventListener("pointerdown", L), t.removeEventListener("scroll", E), window.removeEventListener("pointerup", m), window.removeEventListener("pointercancel", m), v = !1;
47
67
  }
48
- function F() {
49
- m();
68
+ function U() {
69
+ g();
50
70
  }
51
- function T() {
52
- !a.value && l.value.length > 0 && (m(), a.value = !0);
71
+ function S() {
72
+ !u.value && c.value.length > 0 && (g(), u.value = !0);
53
73
  }
54
- function P() {
55
- n.value = !0, h(() => {
74
+ function q() {
75
+ o.value = !0, w(() => {
56
76
  const t = i.value;
57
77
  t && t.scrollTo({ top: t.scrollHeight, behavior: "smooth" });
58
78
  });
59
79
  }
60
- return f(
80
+ return p(
61
81
  i,
62
- (t, o) => {
63
- o && E(o), s = t ?? null, t && (k(t), p(t), n.value && c());
82
+ (t, e) => {
83
+ e && B(e), h = t ?? null, t && (M(t), H(t), o.value && r());
64
84
  },
65
85
  { immediate: !0 }
66
- ), f(
67
- l,
86
+ ), p(
87
+ c,
68
88
  () => {
69
- h(() => {
70
- i.value && p(i.value);
89
+ w(() => {
90
+ i.value && H(i.value);
71
91
  });
72
92
  }
73
- ), f(
74
- () => B.value,
93
+ ), p(
94
+ () => x.value,
75
95
  (t) => {
76
- t && m();
96
+ t && g();
77
97
  },
78
98
  { immediate: !0 }
79
- ), f(
80
- () => l.value.length,
99
+ ), p(
100
+ () => c.value.length,
81
101
  () => {
82
- !a.value && l.value.length > 0 && T();
102
+ !u.value && c.value.length > 0 && S();
83
103
  },
84
104
  { immediate: !0 }
85
- ), U(() => {
86
- e == null || e.disconnect(), e = null, s && (E(s), s = null);
105
+ ), D(() => {
106
+ n == null || n.disconnect(), n = null, h && (B(h), h = null);
87
107
  }), {
88
- isInitialized: a,
108
+ isInitialized: u,
89
109
  /** true, пока лента прижата вниз (автоскролл при новых сообщениях) */
90
- stickToBottom: n,
91
- performScrollToBottom: F,
92
- initializeScroll: T,
93
- smoothScrollToBottom: P
110
+ stickToBottom: o,
111
+ performScrollToBottom: U,
112
+ initializeScroll: S,
113
+ smoothScrollToBottom: q
94
114
  };
95
115
  }
96
116
  export {
97
- q as useFeedScroll
117
+ X as useFeedScroll
98
118
  };
@@ -1,18 +1,19 @@
1
- import i from "../node_modules/markdown-it/lib/index.js";
2
- const e = new i("default", {
1
+ import l from "../node_modules/markdown-it/lib/index.js";
2
+ const e = new l("default", {
3
3
  html: !0,
4
4
  // Разрешаем HTML-теги (для <u>)
5
- breaks: !0,
6
- // Преобразуем переносы строк в <br>
5
+ // breaks: false — иначе каждый \n → <br>, а в ленте ещё white-space: pre-wrap,
6
+ // и перенос удваивается (пустая строка между каждой строкой при наличии \n\n в тексте).
7
+ breaks: !1,
7
8
  linkify: !1
8
9
  // Отключаем авто-ссылки, так как их обрабатывает linkifyStr
9
10
  });
10
- function o(n) {
11
+ function i(n) {
11
12
  if (!n) return "";
12
13
  const r = n.includes(`
13
14
  `), s = n.includes("> ");
14
15
  return r || s ? e.render(n) : e.renderInline(n);
15
16
  }
16
17
  export {
17
- o as parseMarkdown
18
+ i as parseMarkdown
18
19
  };
@@ -0,0 +1,50 @@
1
+ import { ref as l, watch as f, computed as v } from "vue";
2
+ function i(a, e, n) {
3
+ return !!(e && n && e !== n && a === e);
4
+ }
5
+ function s(a, e, n = !1) {
6
+ return n ? e || a || "" : a || e || "";
7
+ }
8
+ function d(a, e) {
9
+ const n = l(!1);
10
+ f(
11
+ () => [a(), e()],
12
+ () => {
13
+ n.value = !1;
14
+ }
15
+ );
16
+ const u = v(
17
+ () => s(a(), e(), n.value)
18
+ );
19
+ function r() {
20
+ i(u.value, a(), e()) && (n.value = !0);
21
+ }
22
+ return { displaySrc: u, onImageError: r, preferOriginal: n };
23
+ }
24
+ function m(a) {
25
+ const e = l(/* @__PURE__ */ new Set());
26
+ f(
27
+ () => a().map((r) => `${r.imagePreviewUrl ?? ""}\0${r.url ?? ""}`).join(`
28
+ `),
29
+ () => {
30
+ e.value = /* @__PURE__ */ new Set();
31
+ }
32
+ );
33
+ function n(r) {
34
+ const o = r.imagePreviewUrl, t = !!(o && e.value.has(o));
35
+ return s(o, r.url, t);
36
+ }
37
+ function u(r) {
38
+ const o = r.imagePreviewUrl, t = r.url;
39
+ if (!i(n(r), o, t) || !o) return;
40
+ const c = new Set(e.value);
41
+ c.add(o), e.value = c;
42
+ }
43
+ return { getItemSrc: n, onItemError: u, failedPreviews: e };
44
+ }
45
+ export {
46
+ i as canFallbackImagePreviewToUrl,
47
+ s as getImageFeedSrc,
48
+ m as useAlbumImageFeedSrc,
49
+ d as useImageFeedSrc
50
+ };