@mobilon-dev/chotto 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 mobilon-dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # chotto
2
+ Vue3 Chat UI - собери свой интерфейс чата
3
+
4
+ # использование
5
+
6
+ ## документация
7
+
8
+ - ссылка
9
+
10
+ ## схема
11
+
12
+ ![](images/scheme.png)
13
+
14
+ ## пример
15
+
16
+ - ссылка
17
+
18
+ ## скриншот
19
+
20
+ ![](images/screenshot1.png)
21
+
22
+
23
+
24
+ # разработка
25
+
26
+
27
+ ## install
28
+
29
+ > npm i
30
+
31
+ ## run storybook
32
+
33
+ > npm run storybook
34
+
35
+ ## build
36
+
37
+ > npm run build
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .chat[data-v-77b8ac34]{cursor:pointer;padding:8px;border-bottom:1px solid #ccc}.file-message a[data-v-9fef0716]{color:#00f;text-decoration:underline}.image-message img[data-v-1c1327d6]{max-width:100%;border-radius:5px}.text-message-left[data-v-4deff5d3]{background-color:#c3e8ba;max-height:50px;min-width:300px;border-radius:10px;padding:10px;margin-bottom:10px;max-width:70%;text-align:left;position:relative;justify-content:flex-start;flex-basis:200px;flex-grow:2;align-self:flex-start}.text-message-right[data-v-4deff5d3]{background-color:#f5f5f5;max-height:50px;min-width:300px;border-radius:10px;padding:10px;margin-bottom:10px;max-width:70%;position:relative;justify-content:flex-end;flex-basis:500px;flex-grow:2;align-self:flex-end}.chat-info[data-v-7ca4835c]{padding:16px}.chat-input[data-v-07719b64]{padding:10px}.chat-input input[data-v-07719b64]{flex:1;width:500px;padding:10px;border:1px solid #ece5dd;border-radius:20px}.chat-input button[data-v-07719b64]{padding:10px;margin-left:10px;border:none;background-color:#25d366;color:#fff;border-radius:20px;cursor:pointer}.chat-input button[data-v-07719b64]:hover{background-color:#128c7e}.chat-list[data-v-dda91c95]{max-height:400px;overflow-y:auto;grid-column:span 1}.message-feed[data-v-b2d2ed34]{flex:1;max-height:400px;height:300px;overflow:auto;display:flex;flex-direction:column;gap:5px}.profile[data-v-e1bf37ef]{padding:16px}
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,192 @@
1
+ import { openBlock as c, createElementBlock as a, createElementVNode as u, toDisplayString as i, normalizeClass as x, createCommentVNode as p, ref as m, withDirectives as I, withKeys as C, vModelText as $, unref as h, Fragment as f, renderList as g, createBlock as v, watch as k, resolveDynamicComponent as b, nextTick as M } from "vue";
2
+ const l = (e, s) => {
3
+ const t = e.__vccOpts || e;
4
+ for (const [n, r] of s)
5
+ t[n] = r;
6
+ return t;
7
+ }, q = {
8
+ __name: "Chat",
9
+ props: {
10
+ chat: {
11
+ type: Object,
12
+ required: !0
13
+ }
14
+ },
15
+ emits: ["select"],
16
+ setup(e, { emit: s }) {
17
+ const t = e, n = s, r = () => {
18
+ n("select", t.chat);
19
+ };
20
+ return (o, d) => (c(), a("div", {
21
+ class: "chat",
22
+ onClick: r
23
+ }, [
24
+ u("p", null, i(e.chat.name) + " " + i(e.chat.countUnread), 1)
25
+ ]));
26
+ }
27
+ }, F = /* @__PURE__ */ l(q, [["__scopeId", "data-v-77b8ac34"]]), O = { class: "file-message" }, T = ["href"], j = {
28
+ __name: "FileMessage",
29
+ props: {
30
+ message: {
31
+ type: Object,
32
+ required: !0
33
+ }
34
+ },
35
+ setup(e) {
36
+ return (s, t) => (c(), a("div", O, [
37
+ u("a", {
38
+ href: e.message.url,
39
+ download: ""
40
+ }, i(e.message.filename), 9, T)
41
+ ]));
42
+ }
43
+ }, w = /* @__PURE__ */ l(j, [["__scopeId", "data-v-9fef0716"]]), B = { class: "image-message" }, D = ["src", "alt"], L = {
44
+ __name: "ImageMessage",
45
+ props: {
46
+ message: {
47
+ type: Object,
48
+ required: !0
49
+ }
50
+ },
51
+ setup(e) {
52
+ return (s, t) => (c(), a("div", B, [
53
+ u("img", {
54
+ src: e.message.url,
55
+ alt: e.message.alt
56
+ }, null, 8, D)
57
+ ]));
58
+ }
59
+ }, S = /* @__PURE__ */ l(L, [["__scopeId", "data-v-1c1327d6"]]), V = {
60
+ __name: "TextMessage",
61
+ props: {
62
+ message: {
63
+ type: Object,
64
+ required: !0
65
+ }
66
+ },
67
+ setup(e) {
68
+ function s(t) {
69
+ return t.direction === "incoming" ? "text-message-left" : "text-message-right";
70
+ }
71
+ return (t, n) => (c(), a("div", {
72
+ class: x(s(e.message))
73
+ }, [
74
+ u("p", null, i(e.message.text), 1)
75
+ ], 2));
76
+ }
77
+ }, A = /* @__PURE__ */ l(V, [["__scopeId", "data-v-4deff5d3"]]), E = { class: "chat-info" }, K = { key: 0 }, N = {
78
+ __name: "ChatInfo",
79
+ props: {
80
+ chat: {
81
+ type: Object,
82
+ required: !0
83
+ }
84
+ },
85
+ setup(e) {
86
+ return (s, t) => (c(), a("div", E, [
87
+ e.chat ? (c(), a("div", K, [
88
+ u("h2", null, i(e.chat.name), 1)
89
+ ])) : p("", !0)
90
+ ]));
91
+ }
92
+ }, X = /* @__PURE__ */ l(N, [["__scopeId", "data-v-7ca4835c"]]), P = { class: "chat-input" }, U = {
93
+ __name: "ChatInput",
94
+ emits: ["send"],
95
+ setup(e, { emit: s }) {
96
+ const t = s, n = m(""), r = m(null), o = () => {
97
+ n.value.trim() && (t("send", n.value), n.value = "", h(r).focus());
98
+ };
99
+ return (d, _) => (c(), a("div", P, [
100
+ I(u("input", {
101
+ "onUpdate:modelValue": _[0] || (_[0] = (y) => n.value = y),
102
+ ref_key: "refInput",
103
+ ref: r,
104
+ onKeydown: C(o, ["enter"]),
105
+ placeholder: "Type a message..."
106
+ }, null, 544), [
107
+ [$, n.value]
108
+ ]),
109
+ u("button", { onClick: o }, "Send")
110
+ ]));
111
+ }
112
+ }, Y = /* @__PURE__ */ l(U, [["__scopeId", "data-v-07719b64"]]), z = { class: "chat-list" }, H = {
113
+ __name: "ChatList",
114
+ props: {
115
+ chats: {
116
+ type: Array,
117
+ required: !0
118
+ }
119
+ },
120
+ emits: ["select"],
121
+ setup(e, { emit: s }) {
122
+ const t = s, n = (r) => {
123
+ t("select", r);
124
+ };
125
+ return (r, o) => (c(), a("div", z, [
126
+ (c(!0), a(f, null, g(e.chats, (d) => (c(), v(F, {
127
+ key: d.chatId,
128
+ chat: d,
129
+ onSelect: n
130
+ }, null, 8, ["chat"]))), 128))
131
+ ]));
132
+ }
133
+ }, Z = /* @__PURE__ */ l(H, [["__scopeId", "data-v-dda91c95"]]), G = {
134
+ __name: "MessageFeed",
135
+ props: {
136
+ messages: {
137
+ type: Array,
138
+ required: !0
139
+ }
140
+ },
141
+ setup(e) {
142
+ const s = m(null), t = e, n = (o) => ({
143
+ "message.text": A,
144
+ "message.image": S,
145
+ "message.file": w
146
+ })[o];
147
+ function r() {
148
+ M(function() {
149
+ const o = h(s);
150
+ o.scrollTop = o.scrollHeight;
151
+ });
152
+ }
153
+ return k(() => t.messages, r), (o, d) => (c(), a("div", {
154
+ class: "message-feed",
155
+ ref_key: "refFeed",
156
+ ref: s
157
+ }, [
158
+ (c(!0), a(f, null, g(e.messages, (_) => (c(), v(b(n(_.type)), {
159
+ key: _.id,
160
+ message: _
161
+ }, null, 8, ["message"]))), 128))
162
+ ], 512));
163
+ }
164
+ }, ee = /* @__PURE__ */ l(G, [["__scopeId", "data-v-b2d2ed34"]]), J = { class: "profile" }, Q = { key: 0 }, R = {
165
+ __name: "Profile",
166
+ props: {
167
+ user: {
168
+ type: Object,
169
+ required: !0
170
+ }
171
+ },
172
+ setup(e) {
173
+ return (s, t) => (c(), a("div", J, [
174
+ e.user ? (c(), a("div", Q, [
175
+ u("h2", null, i(e.user.name), 1),
176
+ u("p", null, i(e.user.email), 1),
177
+ u("p", null, i(e.user.phone), 1)
178
+ ])) : p("", !0)
179
+ ]));
180
+ }
181
+ }, te = /* @__PURE__ */ l(R, [["__scopeId", "data-v-e1bf37ef"]]);
182
+ export {
183
+ F as Chat,
184
+ X as ChatInfo,
185
+ Y as ChatInput,
186
+ Z as ChatList,
187
+ w as FileMessage,
188
+ S as ImageMessage,
189
+ ee as MessageFeed,
190
+ te as Profile,
191
+ A as TextMessage
192
+ };
@@ -0,0 +1 @@
1
+ (function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c.vuessages={},c.Vue))})(this,function(c,e){"use strict";const l=(t,n)=>{const s=t.__vccOpts||t;for(const[a,o]of n)s[a]=o;return s},d=l({__name:"Chat",props:{chat:{type:Object,required:!0}},emits:["select"],setup(t,{emit:n}){const s=t,a=n,o=()=>{a("select",s.chat)};return(r,i)=>(e.openBlock(),e.createElementBlock("div",{class:"chat",onClick:o},[e.createElementVNode("p",null,e.toDisplayString(t.chat.name)+" "+e.toDisplayString(t.chat.countUnread),1)]))}},[["__scopeId","data-v-77b8ac34"]]),h={class:"file-message"},g=["href"],_=l({__name:"FileMessage",props:{message:{type:Object,required:!0}},setup(t){return(n,s)=>(e.openBlock(),e.createElementBlock("div",h,[e.createElementVNode("a",{href:t.message.url,download:""},e.toDisplayString(t.message.filename),9,g)]))}},[["__scopeId","data-v-9fef0716"]]),u={class:"image-message"},k=["src","alt"],p=l({__name:"ImageMessage",props:{message:{type:Object,required:!0}},setup(t){return(n,s)=>(e.openBlock(),e.createElementBlock("div",u,[e.createElementVNode("img",{src:t.message.url,alt:t.message.alt},null,8,k)]))}},[["__scopeId","data-v-1c1327d6"]]),f=l({__name:"TextMessage",props:{message:{type:Object,required:!0}},setup(t){function n(s){return s.direction==="incoming"?"text-message-left":"text-message-right"}return(s,a)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(n(t.message))},[e.createElementVNode("p",null,e.toDisplayString(t.message.text),1)],2))}},[["__scopeId","data-v-4deff5d3"]]),y={class:"chat-info"},B={key:0},$=l({__name:"ChatInfo",props:{chat:{type:Object,required:!0}},setup(t){return(n,s)=>(e.openBlock(),e.createElementBlock("div",y,[t.chat?(e.openBlock(),e.createElementBlock("div",B,[e.createElementVNode("h2",null,e.toDisplayString(t.chat.name),1)])):e.createCommentVNode("",!0)]))}},[["__scopeId","data-v-7ca4835c"]]),E={class:"chat-input"},C=l({__name:"ChatInput",emits:["send"],setup(t,{emit:n}){const s=n,a=e.ref(""),o=e.ref(null),r=()=>{a.value.trim()&&(s("send",a.value),a.value="",e.unref(o).focus())};return(i,m)=>(e.openBlock(),e.createElementBlock("div",E,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":m[0]||(m[0]=S=>a.value=S),ref_key:"refInput",ref:o,onKeydown:e.withKeys(r,["enter"]),placeholder:"Type a message..."},null,544),[[e.vModelText,a.value]]),e.createElementVNode("button",{onClick:r},"Send")]))}},[["__scopeId","data-v-07719b64"]]),I={class:"chat-list"},M=l({__name:"ChatList",props:{chats:{type:Array,required:!0}},emits:["select"],setup(t,{emit:n}){const s=n,a=o=>{s("select",o)};return(o,r)=>(e.openBlock(),e.createElementBlock("div",I,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.chats,i=>(e.openBlock(),e.createBlock(d,{key:i.chatId,chat:i,onSelect:a},null,8,["chat"]))),128))]))}},[["__scopeId","data-v-dda91c95"]]),V=l({__name:"MessageFeed",props:{messages:{type:Array,required:!0}},setup(t){const n=e.ref(null),s=t,a=r=>({"message.text":f,"message.image":p,"message.file":_})[r];function o(){e.nextTick(function(){const r=e.unref(n);r.scrollTop=r.scrollHeight})}return e.watch(()=>s.messages,o),(r,i)=>(e.openBlock(),e.createElementBlock("div",{class:"message-feed",ref_key:"refFeed",ref:n},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.messages,m=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a(m.type)),{key:m.id,message:m},null,8,["message"]))),128))],512))}},[["__scopeId","data-v-b2d2ed34"]]),b={class:"profile"},x={key:0},N=l({__name:"Profile",props:{user:{type:Object,required:!0}},setup(t){return(n,s)=>(e.openBlock(),e.createElementBlock("div",b,[t.user?(e.openBlock(),e.createElementBlock("div",x,[e.createElementVNode("h2",null,e.toDisplayString(t.user.name),1),e.createElementVNode("p",null,e.toDisplayString(t.user.email),1),e.createElementVNode("p",null,e.toDisplayString(t.user.phone),1)])):e.createCommentVNode("",!0)]))}},[["__scopeId","data-v-e1bf37ef"]]);c.Chat=d,c.ChatInfo=$,c.ChatInput=C,c.ChatList=M,c.FileMessage=_,c.ImageMessage=p,c.MessageFeed=V,c.Profile=N,c.TextMessage=f,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@mobilon-dev/chotto",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/vuessages.umd.js",
6
+ "module": "./dist/vuessages.es.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/vuessages.es.js",
10
+ "require": "./dist/vuessages.umd.js"
11
+ },
12
+ "./style.css": "./dist/vuessages.css"
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "types": "./dist/types/index.d.ts",
18
+ "scripts": {
19
+ "dev": "vite",
20
+ "build": "vite build && vue-tsc --emitDeclarationOnly",
21
+ "preview": "vite preview",
22
+ "storybook": "storybook dev -p 6006",
23
+ "build-storybook": "storybook build -o docs"
24
+ },
25
+ "dependencies": {
26
+ "date-fns": "^4.1.0",
27
+ "pinia": "^2.2.2",
28
+ "vue": "^3.5.6",
29
+ "vue3-emoji-picker": "^1.1.8"
30
+ },
31
+ "devDependencies": {
32
+ "@chromatic-com/storybook": "^1.9.0",
33
+ "@storybook/addon-essentials": "^8.3.1",
34
+ "@storybook/addon-interactions": "^8.3.1",
35
+ "@storybook/addon-links": "^8.3.1",
36
+ "@storybook/addon-onboarding": "^8.3.1",
37
+ "@storybook/blocks": "^8.3.1",
38
+ "@storybook/test": "^8.3.1",
39
+ "@storybook/vue3": "^8.3.1",
40
+ "@storybook/vue3-vite": "^8.3.1",
41
+ "@types/node": "^22.5.5",
42
+ "@vitejs/plugin-vue": "^5.1.4",
43
+ "storybook": "^8.3.1",
44
+ "typescript": "^5.6.2",
45
+ "vite": "^5.4.6",
46
+ "vite-plugin-static-copy": "^1.0.6",
47
+ "vue-tsc": "^2.1.6"
48
+ }
49
+ }