@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.
Files changed (29) hide show
  1. package/dist/chotto.css +1 -1
  2. package/dist/components/2_chatinput_elements/FilePreview/FilePreview.vue.js +4 -3
  3. package/dist/components/2_chatinput_elements/FilePreview/FilePreview.vue2.js +72 -119
  4. package/dist/components/2_chatinput_elements/FileUploader/FileUploader.vue.js +2 -2
  5. package/dist/components/2_chatinput_elements/FileUploader/FileUploader.vue2.js +109 -88
  6. package/dist/components/3_compounds/ChatInput/ChatInput.vue.js +2 -2
  7. package/dist/components/3_compounds/ChatInput/ChatInput.vue2.js +334 -225
  8. package/dist/components/3_compounds/ChatInput/icons/ArrowIcon.vue.js +40 -0
  9. package/dist/hooks/uploadFile/generatePreview.js +19 -18
  10. package/dist/hooks/useMessageDraft.js +85 -65
  11. package/dist/index.js +159 -157
  12. package/dist/locale/en.js +4 -0
  13. package/dist/locale/ru.js +4 -0
  14. package/dist/themes/dark.css +1 -1
  15. package/dist/themes/default.css +1 -1
  16. package/dist/themes/glass.css +1 -1
  17. package/dist/themes/green.css +1 -1
  18. package/dist/themes/mobilon1.css +1 -1
  19. package/dist/types/components/2_chatinput_elements/FilePreview/stories/FilePreview.stories.d.ts +3 -3
  20. package/dist/types/components/2_chatinput_elements/FilePreview/styles/types.d.ts +135 -127
  21. package/dist/types/components/2_chatinput_elements/FileUploader/FileUploader.vue.d.ts +9 -0
  22. package/dist/types/components/3_compounds/ChatInput/ChatInput.vue.d.ts +14 -3
  23. package/dist/types/components/3_compounds/ChatInput/icons/ArrowIcon.vue.d.ts +2 -0
  24. package/dist/types/components/3_compounds/ChatInput/icons/index.d.ts +1 -0
  25. package/dist/types/components/3_compounds/ChatInput/styles/types.d.ts +74 -0
  26. package/dist/types/hooks/useMessageDraft.d.ts +10 -3
  27. package/dist/types/locale/en.d.ts +4 -0
  28. package/dist/types/locale/ru.d.ts +4 -0
  29. package/package.json +1 -1
@@ -0,0 +1,40 @@
1
+ import { createElementBlock as l, openBlock as n, createElementVNode as e } from "vue";
2
+ import o from "../../../../_virtual/_plugin-vue_export-helper.js";
3
+ const r = {}, s = {
4
+ id: "svg1",
5
+ width: "22",
6
+ height: "32",
7
+ viewBox: "0 0 22 32",
8
+ fill: "none",
9
+ version: "1.1",
10
+ "xml:space": "preserve",
11
+ xmlns: "http://www.w3.org/2000/svg",
12
+ "xmlns:svg": "http://www.w3.org/2000/svg"
13
+ };
14
+ function f(i, t) {
15
+ return n(), l("svg", s, [...t[0] || (t[0] = [
16
+ e("defs", { id: "defs1" }, null, -1),
17
+ e("path", {
18
+ id: "path1",
19
+ d: "M0 16C0 7.16344 7.16344 0 16 0H22V32H16C7.16344 32 0 24.8366 0 16Z",
20
+ fill: "#D0D0D0"
21
+ }, null, -1),
22
+ e("g", {
23
+ id: "g1",
24
+ style: { fill: "none" },
25
+ transform: "translate(1.99999,6.99915)"
26
+ }, [
27
+ e("path", {
28
+ id: "path1-8",
29
+ "fill-rule": "evenodd",
30
+ "clip-rule": "evenodd",
31
+ d: "M 7.22678,1.85276 C 7.27903,1.80037 7.3411,1.75881 7.40944,1.73045 7.47778,1.7021 7.55104,1.6875 7.62503,1.6875 c 0.07399,0 0.14725,0.0146 0.21559,0.04295 0.06833,0.02836 0.13041,0.06992 0.18266,0.12231 l 6.75002,6.75 c 0.0524,0.05225 0.0939,0.11432 0.1223,0.18266 0.0283,0.06834 0.0429,0.1416 0.0429,0.21559 0,0.07398 -0.0146,0.14724 -0.0429,0.21558 C 14.8672,9.28493 14.8257,9.347 14.7733,9.39926 L 8.02328,16.1493 C 7.91766,16.2549 7.7744,16.3142 7.62503,16.3142 7.47566,16.3142 7.3324,16.2549 7.22678,16.1493 7.12116,16.0436 7.06182,15.9004 7.06182,15.751 c 0,-0.1494 0.05934,-0.2926 0.16496,-0.3982 L 13.5797,9.00101 7.22678,2.64926 C 7.17439,2.597 7.13283,2.53493 7.10448,2.46659 7.07612,2.39826 7.06152,2.32499 7.06152,2.25101 c 0,-0.07399 0.0146,-0.14725 0.04296,-0.21559 0.02835,-0.06834 0.06991,-0.13041 0.1223,-0.18266 z",
32
+ fill: "#ffffff"
33
+ })
34
+ ], -1)
35
+ ])]);
36
+ }
37
+ const p = /* @__PURE__ */ o(r, [["render", f]]);
38
+ export {
39
+ p as default
40
+ };
@@ -1,32 +1,33 @@
1
- import { ref as s } from "vue";
2
- import { getTypeFileByMime as n } from "./getTypeFileByMime.js";
3
- const m = (i) => {
4
- const e = n(i.type), t = s(!1), u = s(!1), a = s(!1), o = s("");
5
- e === "image" ? t.value = !0 : e === "video" ? u.value = !0 : e === "audio" && (a.value = !0), t.value || u.value || a.value ? o.value = URL.createObjectURL(i) : o.value = "";
6
- const f = ["б", "Кб", "Мб", "Гб"];
7
- let l = i.size, r = 0;
8
- for (; l > 1024; )
9
- l = l / 1024, r++;
1
+ import { ref as a } from "vue";
2
+ import { getTypeFileByMime as f } from "./getTypeFileByMime.js";
3
+ const c = (t) => {
4
+ const e = f(t.type), s = a(!1), o = a(!1), r = a(!1), u = a("");
5
+ e === "image" ? s.value = !0 : e === "video" ? o.value = !0 : e === "audio" && (r.value = !0), s.value || o.value || r.value ? u.value = URL.createObjectURL(t) : u.value = "";
6
+ const n = ["Б", "КБ", "МБ", "ГБ"];
7
+ let i = t.size, l = 0;
8
+ for (; i >= 1024 && l < n.length - 1; )
9
+ i = i / 1024, l++;
10
+ const d = l === 0 || Math.abs(i - Math.round(i)) < 0.05 ? String(Math.round(i)) : i.toFixed(1);
10
11
  return {
11
- isImage: t.value,
12
- isVideo: u.value,
13
- isAudio: a.value,
14
- previewUrl: o.value,
15
- fileSize: l.toFixed(2) + f[r]
12
+ isImage: s.value,
13
+ isVideo: o.value,
14
+ isAudio: r.value,
15
+ previewUrl: u.value,
16
+ fileSize: `${d} ${n[l]}`
16
17
  };
17
18
  };
18
- function c(i, e) {
19
+ function g(t, e) {
19
20
  if (e)
20
21
  return {
21
22
  previewUrl: e.previewUrl,
22
23
  isImage: e.isImage,
23
24
  isVideo: e.isVideo,
24
25
  isAudio: e.isAudio,
25
- fileName: i,
26
+ fileName: t,
26
27
  fileSize: e.fileSize
27
28
  };
28
29
  }
29
30
  export {
30
- c as buildFilePreview,
31
- m as generatePreview
31
+ g as buildFilePreview,
32
+ c as generatePreview
32
33
  };
@@ -1,6 +1,15 @@
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) {
1
+ import { ref as S, getCurrentInstance as E, inject as $, computed as A, unref as N, watch as m } from "vue";
2
+ const a = 5;
3
+ function d(t) {
4
+ var i;
5
+ return t ? (i = t.files) != null && i.length ? t.files : t.file ? [t.file] : [] : [];
6
+ }
7
+ function f(t, i = a) {
8
+ const o = Number.isFinite(i) && i > 0 ? Math.floor(i) : a, s = t.slice(0, o);
9
+ return s.length ? { files: s, file: s[0] } : { file: void 0, files: void 0 };
10
+ }
11
+ const l = S([]);
12
+ function _(t) {
4
13
  return {
5
14
  id: t,
6
15
  text: "",
@@ -9,136 +18,147 @@ function S(t) {
9
18
  isRecording: !1
10
19
  };
11
20
  }
12
- function f(t) {
13
- const i = o.value.find((c) => c.id === t);
21
+ function p(t) {
22
+ const i = l.value.find((s) => s.id === t);
14
23
  if (i) return i;
15
- const s = S(t);
16
- return o.value.push(s), s;
24
+ const o = _(t);
25
+ return l.value.push(o), o;
17
26
  }
18
27
  function k(t, i) {
19
28
  if (!(i == null || i === ""))
20
- return o.value.find((s) => s.id === `${t}:${i}`);
29
+ return l.value.find((o) => o.id === `${t}:${i}`);
21
30
  }
22
- function v(t) {
31
+ function h(t) {
23
32
  return t.replace(/\s+/g, " ").trim();
24
33
  }
25
- function g(t) {
26
- var c, u, r;
34
+ function x(t) {
35
+ var r;
27
36
  if (!t) return;
28
37
  if (t.edit) {
29
38
  t.listPreviewText = void 0, t.listPreviewFile = void 0;
30
39
  return;
31
40
  }
32
- const i = v(t.text || "");
41
+ const i = h(t.text || "");
33
42
  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;
43
+ const s = d(t)[0], v = (s == null ? void 0 : s.name) || ((r = s == null ? void 0 : s.preview) == null ? void 0 : r.fileName) || "";
44
+ t.listPreviewFile = s ? { name: v, type: s.type } : void 0;
36
45
  }
37
- function E(t) {
38
- return !!(v(t.text || "") || t.file);
46
+ function B(t) {
47
+ return !!(h(t.text || "") || d(t).length);
39
48
  }
40
- function $(t) {
49
+ function b(t) {
41
50
  t.listPreviewText = void 0, t.listPreviewFile = void 0;
42
51
  }
43
52
  function q(t) {
44
- t && g(o.value.find((i) => i.id === t));
53
+ t && x(l.value.find((i) => i.id === t));
45
54
  }
46
- function B(t, i) {
55
+ function j(t, i) {
47
56
  if (typeof document > "u") return;
48
- const s = document.getElementById("chat-input-reply-line-" + t);
49
- s && (s.style.display = i.reply || i.edit ? "inherit" : "none");
57
+ const o = document.getElementById("chat-input-reply-line-" + t);
58
+ o && (o.style.display = i.reply || i.edit ? "inherit" : "none");
50
59
  }
51
60
  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;
61
+ const i = E() ? $("selectedChat", void 0) : void 0, o = A(() => {
62
+ const e = i ? N(i) : void 0, n = e == null ? void 0 : e.chatId;
54
63
  return n == null || n === "" ? t : `${t}:${n}`;
55
64
  });
56
- a(
57
- s,
65
+ m(
66
+ o,
58
67
  (e, n) => {
59
- const d = f(e);
68
+ const u = p(e);
60
69
  if (n !== void 0 && n !== e) {
61
- const h = o.value.find((D) => D.id === n);
62
- g(h), B(t, d);
70
+ const g = l.value.find((L) => L.id === n);
71
+ x(g), j(t, u);
63
72
  }
64
73
  },
65
74
  { immediate: !0 }
66
- ), a(
75
+ ), m(
67
76
  () => {
68
- const e = l();
69
- return [e.text, e.file];
77
+ var n;
78
+ const e = c();
79
+ return [e.text, e.file, (n = e.files) == null ? void 0 : n.length];
70
80
  },
71
81
  () => {
72
- const e = l();
82
+ const e = c();
73
83
  if (!e.edit) {
74
- if (!E(e)) {
75
- $(e);
84
+ if (!B(e)) {
85
+ b(e);
76
86
  return;
77
87
  }
78
- e.file || (e.listPreviewFile = void 0), v(e.text || "") || (e.listPreviewText = void 0);
88
+ d(e).length || (e.listPreviewFile = void 0), h(e.text || "") || (e.listPreviewText = void 0);
79
89
  }
80
90
  }
81
91
  );
82
- const c = () => {
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));
85
- }, u = () => {
86
- const e = l();
87
- o.value[c()] = {
92
+ const s = () => {
93
+ const e = o.value, n = l.value.findIndex((u) => u.id === e);
94
+ return n !== -1 ? n : (p(e), l.value.findIndex((u) => u.id === e));
95
+ }, v = () => {
96
+ const e = c();
97
+ l.value[s()] = {
88
98
  id: e.id,
89
99
  text: "",
90
100
  file: void 0,
101
+ files: void 0,
91
102
  reply: void 0,
92
103
  edit: void 0,
93
104
  forceSend: !1,
94
105
  isRecording: e.isRecording
95
106
  };
96
107
  }, r = (e) => {
97
- const n = l();
98
- o.value[c()] = {
108
+ const n = c();
109
+ l.value[s()] = {
99
110
  ...n,
100
111
  forceSend: !1,
101
112
  ...e,
102
113
  id: n.id
103
114
  };
104
- }, p = (e) => {
105
- r({ text: e });
106
- }, m = (e) => {
107
- r({ file: e });
108
- }, x = () => {
109
- r({ file: void 0 });
110
115
  }, y = (e) => {
116
+ r({ text: e });
117
+ }, M = (e) => {
118
+ r(f([e]));
119
+ }, w = (e, n = a) => {
120
+ e.length && r(f([...d(c()), ...e], n));
121
+ }, F = (e) => {
122
+ const n = d(c()).filter((u, g) => g !== e);
123
+ r(f(n, n.length || a));
124
+ }, D = () => {
125
+ r(f([]));
126
+ }, P = (e) => {
111
127
  r({ reply: e, edit: void 0 });
112
- }, w = () => {
128
+ }, T = () => {
113
129
  r({ reply: void 0 });
114
- }, M = (e) => {
130
+ }, C = (e) => {
115
131
  r({ edit: e, reply: void 0 });
116
- }, P = () => {
132
+ }, R = () => {
117
133
  r({ edit: void 0 });
118
134
  };
119
- function l() {
120
- return f(s.value);
135
+ function c() {
136
+ return p(o.value);
121
137
  }
122
138
  return {
123
- getMessage: l,
124
- resetMessage: u,
125
- setMessageFile: m,
126
- resetMessageFile: x,
127
- setMessageText: p,
128
- setReply: y,
129
- resetReply: w,
130
- setEdit: M,
131
- resetEdit: P,
139
+ getMessage: c,
140
+ resetMessage: v,
141
+ setMessageFile: M,
142
+ addMessageFiles: w,
143
+ removeMessageFile: F,
144
+ resetMessageFile: D,
145
+ setMessageText: y,
146
+ setReply: P,
147
+ resetReply: T,
148
+ setEdit: C,
149
+ resetEdit: R,
132
150
  setForceSendMessage: (e) => {
133
- l().forceSend = e;
151
+ c().forceSend = e;
134
152
  },
135
153
  setRecordingMessage: (e) => {
136
- l().isRecording = e;
154
+ c().isRecording = e;
137
155
  }
138
156
  };
139
157
  };
140
158
  export {
159
+ a as MAX_ATTACHED_FILES,
141
160
  q as commitChatDraftToList,
142
161
  k as getChatDraft,
162
+ d as getDraftFiles,
143
163
  z as useMessageDraft
144
164
  };