prlg-ui 1.7.43 → 1.7.45
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/Image-CHlS9buq.js +213 -0
- package/dist/Image-DIcd8Rr2.cjs +1 -0
- package/dist/blocks/index.cjs.js +1 -1
- package/dist/blocks/index.es.js +84 -118
- package/dist/index.d.ts +3 -0
- package/dist/parseFileSize.util-BTDZr2sf.cjs +1 -0
- package/dist/parseFileSize.util-BoDbFdVW.js +44 -0
- package/dist/prlg-ui.cjs.js +1 -1
- package/dist/prlg-ui.css +1 -1
- package/dist/prlg-ui.es.js +1470 -1468
- package/dist/uploadFile.util-CorOn5lO.js +760 -0
- package/dist/uploadFile.util-Du5cumgy.cjs +1 -0
- package/dist/utils/index.cjs.js +1 -1
- package/dist/utils/index.es.js +3 -2
- package/dist/utils/uploadFile.util.ts +94 -0
- package/dist/utils.d.ts +27 -0
- package/package.json +1 -1
- package/dist/Image-B46QCYLx.cjs +0 -1
- package/dist/Image-ddX0F8QG.js +0 -225
- package/dist/dayjs.util-Dg65EiGQ.cjs +0 -1
- package/dist/dayjs.util-RJe77c19.js +0 -725
- package/dist/onClickOutside.util-BWGmebYq.js +0 -30
- package/dist/onClickOutside.util-CvjEyTtT.cjs +0 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { defineComponent as w, useId as I, ref as h, computed as k, onMounted as b, createElementBlock as o, openBlock as s, normalizeClass as C, createCommentVNode as n, createBlock as F, createVNode as $, unref as _, resolveDynamicComponent as j, toDisplayString as p, Teleport as E, Transition as V, withCtx as W, createElementVNode as c, useTemplateRef as N, Fragment as O } from "vue";
|
|
2
|
+
import { F as x, E as D, W as L, P, C as B, _ as z, a as R } from "./FileIcon-DkEbi-bi.js";
|
|
3
|
+
import { f as S } from "./parseFileSize.util-BoDbFdVW.js";
|
|
4
|
+
function q(l) {
|
|
5
|
+
return l.startsWith("image/") ? "image" : l === "application/pdf" ? "pdf" : l === "application/msword" || l === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ? "word" : l === "application/vnd.ms-excel" || l === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ? "excel" : "other";
|
|
6
|
+
}
|
|
7
|
+
const A = {
|
|
8
|
+
key: 1,
|
|
9
|
+
class: "file__title"
|
|
10
|
+
}, G = {
|
|
11
|
+
key: 2,
|
|
12
|
+
class: "file__info"
|
|
13
|
+
}, H = {
|
|
14
|
+
key: 0,
|
|
15
|
+
class: "file__type"
|
|
16
|
+
}, J = {
|
|
17
|
+
key: 1,
|
|
18
|
+
class: "file__info-separator"
|
|
19
|
+
}, K = {
|
|
20
|
+
key: 2,
|
|
21
|
+
class: "file__size"
|
|
22
|
+
}, Q = /* @__PURE__ */ w({
|
|
23
|
+
__name: "File",
|
|
24
|
+
props: {
|
|
25
|
+
file: {},
|
|
26
|
+
viewName: { type: Boolean, default: !1 },
|
|
27
|
+
outlined: { type: Boolean, default: !0 },
|
|
28
|
+
removable: { type: Boolean }
|
|
29
|
+
},
|
|
30
|
+
emits: ["remove"],
|
|
31
|
+
setup(l, { emit: d }) {
|
|
32
|
+
const u = d, i = I(), e = h(null);
|
|
33
|
+
async function m(a, r = "image") {
|
|
34
|
+
const f = await (await fetch(a)).blob(), y = f.type.split("/")[1] || "", M = y ? `${r}.${y}` : r;
|
|
35
|
+
return new File([f], M, { type: f.type });
|
|
36
|
+
}
|
|
37
|
+
const g = k(() => e.value && e.value.mime ? q(e.value.mime) : null), t = k(() => {
|
|
38
|
+
switch (g.value) {
|
|
39
|
+
case "pdf":
|
|
40
|
+
return P;
|
|
41
|
+
case "word":
|
|
42
|
+
return L;
|
|
43
|
+
case "excel":
|
|
44
|
+
return D;
|
|
45
|
+
case "other":
|
|
46
|
+
default:
|
|
47
|
+
return x;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return b(async () => {
|
|
51
|
+
if (typeof l.file == "string") {
|
|
52
|
+
const a = await m(l.file);
|
|
53
|
+
e.value = {
|
|
54
|
+
id: i,
|
|
55
|
+
url: l.file,
|
|
56
|
+
name: a.name,
|
|
57
|
+
mime: a.type,
|
|
58
|
+
size: a.size
|
|
59
|
+
};
|
|
60
|
+
} else
|
|
61
|
+
e.value = l.file;
|
|
62
|
+
}), (a, r) => (s(), o("div", {
|
|
63
|
+
class: C(["file", { "file--outlined": a.outlined }])
|
|
64
|
+
}, [
|
|
65
|
+
a.removable && typeof a.file != "string" ? (s(), o("button", {
|
|
66
|
+
key: 0,
|
|
67
|
+
class: "file__remove",
|
|
68
|
+
onClick: r[0] || (r[0] = (v) => u("remove", a.file))
|
|
69
|
+
}, [
|
|
70
|
+
$(_(B))
|
|
71
|
+
])) : n("", !0),
|
|
72
|
+
(s(), F(j(t.value), { class: "file__icon" })),
|
|
73
|
+
e.value && e.value.name && a.viewName ? (s(), o("div", A, p(e.value ? e.value.name.split(".")[0] : "unknown"), 1)) : n("", !0),
|
|
74
|
+
e.value ? (s(), o("div", G, [
|
|
75
|
+
e.value.mime ? (s(), o("div", H, p(g.value), 1)) : n("", !0),
|
|
76
|
+
e.value.mime && e.value.size ? (s(), o("div", J)) : n("", !0),
|
|
77
|
+
e.value.size ? (s(), o("div", K, p(e.value ? _(S)(e.value.size) : "0 Б"), 1)) : n("", !0)
|
|
78
|
+
])) : n("", !0)
|
|
79
|
+
], 2));
|
|
80
|
+
}
|
|
81
|
+
}), me = /* @__PURE__ */ z(Q, [["__scopeId", "data-v-9dee864d"]]), T = {
|
|
82
|
+
key: 0,
|
|
83
|
+
class: "image-full-modal"
|
|
84
|
+
}, U = { class: "image-full-modal__wrapper" }, X = { class: "image-full-modal__header" }, Y = { class: "image-full-modal__main" }, Z = ["src", "alt"], ee = /* @__PURE__ */ w({
|
|
85
|
+
__name: "ImageFullModal",
|
|
86
|
+
props: {
|
|
87
|
+
src: {},
|
|
88
|
+
alt: {}
|
|
89
|
+
},
|
|
90
|
+
setup(l, { expose: d }) {
|
|
91
|
+
const u = h(!1);
|
|
92
|
+
return d({
|
|
93
|
+
open: () => {
|
|
94
|
+
u.value = !0;
|
|
95
|
+
},
|
|
96
|
+
close: () => {
|
|
97
|
+
u.value = !1;
|
|
98
|
+
}
|
|
99
|
+
}), (i, e) => (s(), F(E, { to: "body" }, [
|
|
100
|
+
$(V, { name: "fade" }, {
|
|
101
|
+
default: W(() => [
|
|
102
|
+
u.value ? (s(), o("div", T, [
|
|
103
|
+
c("div", {
|
|
104
|
+
class: "image-full-modal__overlay",
|
|
105
|
+
onClick: e[0] || (e[0] = (m) => u.value = !1)
|
|
106
|
+
}),
|
|
107
|
+
c("div", U, [
|
|
108
|
+
c("div", X, [
|
|
109
|
+
c("button", {
|
|
110
|
+
class: "image-full-modal__close",
|
|
111
|
+
onClick: e[1] || (e[1] = (m) => u.value = !1)
|
|
112
|
+
}, [
|
|
113
|
+
$(_(B))
|
|
114
|
+
])
|
|
115
|
+
]),
|
|
116
|
+
c("div", Y, [
|
|
117
|
+
c("img", {
|
|
118
|
+
src: i.src,
|
|
119
|
+
alt: i.alt
|
|
120
|
+
}, null, 8, Z)
|
|
121
|
+
]),
|
|
122
|
+
e[2] || (e[2] = c("div", { class: "image-full-modal__footer" }, null, -1))
|
|
123
|
+
])
|
|
124
|
+
])) : n("", !0)
|
|
125
|
+
]),
|
|
126
|
+
_: 1
|
|
127
|
+
})
|
|
128
|
+
]));
|
|
129
|
+
}
|
|
130
|
+
}), le = /* @__PURE__ */ z(ee, [["__scopeId", "data-v-edc1a47e"]]), ae = ["src", "alt"], te = {
|
|
131
|
+
key: 1,
|
|
132
|
+
class: "image__info"
|
|
133
|
+
}, ie = {
|
|
134
|
+
key: 0,
|
|
135
|
+
class: "image__type"
|
|
136
|
+
}, se = {
|
|
137
|
+
key: 1,
|
|
138
|
+
class: "image__info-separator"
|
|
139
|
+
}, oe = {
|
|
140
|
+
key: 2,
|
|
141
|
+
class: "image__size"
|
|
142
|
+
}, ne = /* @__PURE__ */ w({
|
|
143
|
+
__name: "Image",
|
|
144
|
+
props: {
|
|
145
|
+
file: {},
|
|
146
|
+
alt: {},
|
|
147
|
+
size: { default: "medium" },
|
|
148
|
+
fullScreen: { type: Boolean }
|
|
149
|
+
},
|
|
150
|
+
setup(l) {
|
|
151
|
+
const d = I(), u = N("imageFullModal"), i = h(null);
|
|
152
|
+
async function e(t, a = "image") {
|
|
153
|
+
const v = await (await fetch(t)).blob(), f = v.type.split("/")[1] || "", y = f ? `${a}.${f}` : a;
|
|
154
|
+
return new File([v], y, { type: v.type });
|
|
155
|
+
}
|
|
156
|
+
const m = k(() => typeof l.file == "string" ? l.file : l.file.url);
|
|
157
|
+
function g(t) {
|
|
158
|
+
if (t.startsWith("image/"))
|
|
159
|
+
return t.replace("image/", "").toLowerCase();
|
|
160
|
+
const a = t.match(/\.(jpeg|jpg|png|gif|webp|bmp|svg|tiff|ico)(\?.*)?$/i);
|
|
161
|
+
if (a) {
|
|
162
|
+
let r = a[1].toLowerCase();
|
|
163
|
+
return r === "jpg" && (r = "jpeg"), r;
|
|
164
|
+
}
|
|
165
|
+
return "unknown";
|
|
166
|
+
}
|
|
167
|
+
return b(async () => {
|
|
168
|
+
if (typeof l.file == "string") {
|
|
169
|
+
const t = await e(l.file);
|
|
170
|
+
i.value = {
|
|
171
|
+
id: d,
|
|
172
|
+
url: l.file,
|
|
173
|
+
name: t.name,
|
|
174
|
+
mime: t.type,
|
|
175
|
+
size: t.size
|
|
176
|
+
};
|
|
177
|
+
} else
|
|
178
|
+
i.value = l.file;
|
|
179
|
+
}), (t, a) => (s(), o(O, null, [
|
|
180
|
+
c("div", {
|
|
181
|
+
class: C(["image", `image--${t.size}`, { "image--full-screen": t.fullScreen }])
|
|
182
|
+
}, [
|
|
183
|
+
t.fullScreen ? (s(), o("div", {
|
|
184
|
+
key: 0,
|
|
185
|
+
class: "image__overlay",
|
|
186
|
+
onClick: a[0] || (a[0] = (r) => u.value?.open())
|
|
187
|
+
}, [
|
|
188
|
+
$(_(R))
|
|
189
|
+
])) : n("", !0),
|
|
190
|
+
c("img", {
|
|
191
|
+
src: m.value,
|
|
192
|
+
alt: t.alt
|
|
193
|
+
}, null, 8, ae),
|
|
194
|
+
i.value && (i.value.mime || i.value.size) && t.size === "large" ? (s(), o("div", te, [
|
|
195
|
+
i.value.mime ? (s(), o("div", ie, p(g(i.value.mime)), 1)) : n("", !0),
|
|
196
|
+
i.value.mime && i.value.size ? (s(), o("div", se)) : n("", !0),
|
|
197
|
+
i.value.size ? (s(), o("div", oe, p(i.value ? _(S)(i.value.size) : "0 Б"), 1)) : n("", !0)
|
|
198
|
+
])) : n("", !0)
|
|
199
|
+
], 2),
|
|
200
|
+
t.fullScreen ? (s(), F(le, {
|
|
201
|
+
key: 0,
|
|
202
|
+
ref: "imageFullModal",
|
|
203
|
+
src: m.value,
|
|
204
|
+
alt: t.alt
|
|
205
|
+
}, null, 8, ["src", "alt"])) : n("", !0)
|
|
206
|
+
], 64));
|
|
207
|
+
}
|
|
208
|
+
}), fe = /* @__PURE__ */ z(ne, [["__scopeId", "data-v-5d09d408"]]);
|
|
209
|
+
export {
|
|
210
|
+
me as F,
|
|
211
|
+
fe as I,
|
|
212
|
+
q as g
|
|
213
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("vue"),s=require("./FileIcon-sxADkCIe.cjs"),v=require("./parseFileSize.util-BTDZr2sf.cjs");function _(l){return l.startsWith("image/")?"image":l==="application/pdf"?"pdf":l==="application/msword"||l==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?"word":l==="application/vnd.ms-excel"||l==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"?"excel":"other"}const k={key:1,class:"file__title"},y={key:2,class:"file__info"},B={key:0,class:"file__type"},C={key:1,class:"file__info-separator"},V={key:2,class:"file__size"},N=e.defineComponent({__name:"File",props:{file:{},viewName:{type:Boolean,default:!1},outlined:{type:Boolean,default:!0},removable:{type:Boolean}},emits:["remove"],setup(l,{emit:u}){const c=u,n=e.useId(),t=e.ref(null);async function r(o,i="image"){const m=await(await fetch(o)).blob(),p=m.type.split("/")[1]||"",g=p?`${i}.${p}`:i;return new File([m],g,{type:m.type})}const f=e.computed(()=>t.value&&t.value.mime?_(t.value.mime):null),a=e.computed(()=>{switch(f.value){case"pdf":return s.PdfIcon;case"word":return s.WordIcon;case"excel":return s.ExcelIcon;case"other":default:return s.FileIcon}});return e.onMounted(async()=>{if(typeof l.file=="string"){const o=await r(l.file);t.value={id:n,url:l.file,name:o.name,mime:o.type,size:o.size}}else t.value=l.file}),(o,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["file",{"file--outlined":o.outlined}])},[o.removable&&typeof o.file!="string"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"file__remove",onClick:i[0]||(i[0]=d=>c("remove",o.file))},[e.createVNode(e.unref(s.CloseIcon))])):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{class:"file__icon"})),t.value&&t.value.name&&o.viewName?(e.openBlock(),e.createElementBlock("div",k,e.toDisplayString(t.value?t.value.name.split(".")[0]:"unknown"),1)):e.createCommentVNode("",!0),t.value?(e.openBlock(),e.createElementBlock("div",y,[t.value.mime?(e.openBlock(),e.createElementBlock("div",B,e.toDisplayString(f.value),1)):e.createCommentVNode("",!0),t.value.mime&&t.value.size?(e.openBlock(),e.createElementBlock("div",C)):e.createCommentVNode("",!0),t.value.size?(e.openBlock(),e.createElementBlock("div",V,e.toDisplayString(t.value?e.unref(v.formatFileSize)(t.value.size):"0 Б"),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],2))}}),E=s._export_sfc(N,[["__scopeId","data-v-9dee864d"]]),F={key:0,class:"image-full-modal"},$={class:"image-full-modal__wrapper"},w={class:"image-full-modal__header"},h={class:"image-full-modal__main"},z=["src","alt"],I=e.defineComponent({__name:"ImageFullModal",props:{src:{},alt:{}},setup(l,{expose:u}){const c=e.ref(!1);return u({open:()=>{c.value=!0},close:()=>{c.value=!1}}),(n,t)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[c.value?(e.openBlock(),e.createElementBlock("div",F,[e.createElementVNode("div",{class:"image-full-modal__overlay",onClick:t[0]||(t[0]=r=>c.value=!1)}),e.createElementVNode("div",$,[e.createElementVNode("div",w,[e.createElementVNode("button",{class:"image-full-modal__close",onClick:t[1]||(t[1]=r=>c.value=!1)},[e.createVNode(e.unref(s.CloseIcon))])]),e.createElementVNode("div",h,[e.createElementVNode("img",{src:n.src,alt:n.alt},null,8,z)]),t[2]||(t[2]=e.createElementVNode("div",{class:"image-full-modal__footer"},null,-1))])])):e.createCommentVNode("",!0)]),_:1})]))}}),b=s._export_sfc(I,[["__scopeId","data-v-edc1a47e"]]),S=["src","alt"],M={key:1,class:"image__info"},j={key:0,class:"image__type"},D={key:1,class:"image__info-separator"},q={key:2,class:"image__size"},x=e.defineComponent({__name:"Image",props:{file:{},alt:{},size:{default:"medium"},fullScreen:{type:Boolean}},setup(l){const u=e.useId(),c=e.useTemplateRef("imageFullModal"),n=e.ref(null);async function t(a,o="image"){const d=await(await fetch(a)).blob(),m=d.type.split("/")[1]||"",p=m?`${o}.${m}`:o;return new File([d],p,{type:d.type})}const r=e.computed(()=>typeof l.file=="string"?l.file:l.file.url);function f(a){if(a.startsWith("image/"))return a.replace("image/","").toLowerCase();const o=a.match(/\.(jpeg|jpg|png|gif|webp|bmp|svg|tiff|ico)(\?.*)?$/i);if(o){let i=o[1].toLowerCase();return i==="jpg"&&(i="jpeg"),i}return"unknown"}return e.onMounted(async()=>{if(typeof l.file=="string"){const a=await t(l.file);n.value={id:u,url:l.file,name:a.name,mime:a.type,size:a.size}}else n.value=l.file}),(a,o)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["image",`image--${a.size}`,{"image--full-screen":a.fullScreen}])},[a.fullScreen?(e.openBlock(),e.createElementBlock("div",{key:0,class:"image__overlay",onClick:o[0]||(o[0]=i=>c.value?.open())},[e.createVNode(e.unref(s.EyeIcon))])):e.createCommentVNode("",!0),e.createElementVNode("img",{src:r.value,alt:a.alt},null,8,S),n.value&&(n.value.mime||n.value.size)&&a.size==="large"?(e.openBlock(),e.createElementBlock("div",M,[n.value.mime?(e.openBlock(),e.createElementBlock("div",j,e.toDisplayString(f(n.value.mime)),1)):e.createCommentVNode("",!0),n.value.mime&&n.value.size?(e.openBlock(),e.createElementBlock("div",D)):e.createCommentVNode("",!0),n.value.size?(e.openBlock(),e.createElementBlock("div",q,e.toDisplayString(n.value?e.unref(v.formatFileSize)(n.value.size):"0 Б"),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],2),a.fullScreen?(e.openBlock(),e.createBlock(b,{key:0,ref:"imageFullModal",src:r.value,alt:a.alt},null,8,["src","alt"])):e.createCommentVNode("",!0)],64))}}),O=s._export_sfc(x,[["__scopeId","data-v-5d09d408"]]);exports.File=E;exports.Image=O;exports.getFileTypeByMime=_;
|
package/dist/blocks/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),u=require("../Image-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),u=require("../Image-DIcd8Rr2.cjs"),f=require("../FileIcon-sxADkCIe.cjs"),m=require("../SendIcon-_UxV_dOO.cjs"),p=require("../parseFileSize.util-BTDZr2sf.cjs"),_=require("../uploadFile.util-Du5cumgy.cjs"),v={class:"chat-file__content"},h=e.defineComponent({__name:"ChatFile",props:{file:{}},emits:["deleteFile"],setup(s,{emit:n}){const i=n,c=e.computed(()=>URL.createObjectURL(s.file));return(l,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["chat-file",{"chat-file--image":e.unref(u.getFileTypeByMime)(l.file.type)==="image"}])},[e.createElementVNode("button",{class:"chat-file__delete",onClick:d[0]||(d[0]=a=>i("deleteFile",l.file))},[e.createVNode(e.unref(f.CloseIcon))]),e.createElementVNode("div",v,[e.unref(u.getFileTypeByMime)(l.file.type)==="image"?(e.openBlock(),e.createBlock(e.unref(u.Image),{key:0,file:c.value,size:"large",fullScreen:""},null,8,["file"])):(e.openBlock(),e.createBlock(e.unref(u.File),{key:1,file:c.value,outlined:!1},null,8,["file"]))])],2))}}),k=f._export_sfc(h,[["__scopeId","data-v-25ab2b0f"]]),B={class:"chat-field-actions"},g={ref:"overlay",class:"chat-field-actions__overlay"},y=["onClick"],b={class:"chat-field-actions__overlay-item__label"},C=["disabled"],V=e.defineComponent({__name:"ChatFieldActions",props:e.mergeModels({actions:{},disabled:{type:Boolean,default:!1},multiple:{type:Boolean,default:!0}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(s){const n=e.useModel(s,"modelValue"),i=e.useTemplateRef("button"),c=e.useTemplateRef("overlay"),l=e.ref(!1),d=e.reactive({image:{icon:e.shallowRef(m.ImageIcon),label:"Добавить изображение"},file:{icon:e.shallowRef(f.FileIcon),label:"Добавить файл"}}),a=o=>{_.openFileDialog({accept:o==="image"?["image"]:["pdf","excel","word"],maxFileSize:"5mb",maxFiles:1}).then(t=>{n.value?n.value=s.multiple?[...n.value,...t]:t:n.value=[...t],l.value=!1})};return e.onMounted(()=>{p.onClickOutside(c.value,()=>{l.value=!1},{ignore:[i.value]})}),(o,t)=>(e.openBlock(),e.createElementBlock("div",B,[e.createVNode(e.Transition,{name:"slide-up"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",g,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.actions,r=>(e.openBlock(),e.createElementBlock("div",{class:"chat-field-actions__overlay-item",key:r,onClick:R=>a(r)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d[r].icon),{class:"chat-field-actions__overlay-item__icon"})),e.createElementVNode("span",b,e.toDisplayString(d[r].label),1)],8,y))),128))],512),[[e.vShow,l.value]])]),_:1}),e.createElementVNode("button",{ref:"button",onClick:t[0]||(t[0]=r=>l.value=!l.value),class:e.normalizeClass(["chat-field-actions__button",{"chat-field-actions__button--active":l.value}]),disabled:o.disabled},[e.createVNode(e.unref(m.PlusRoundedIcon))],10,C)]))}}),F=f._export_sfc(V,[["__scopeId","data-v-e64085d6"]]),E={class:"chat-field"},M={key:0,class:"chat-field__files"},N={class:"chat-field__wrapper"},I=["placeholder"],$=e.defineComponent({__name:"ChatField",props:e.mergeModels({viewActions:{type:Boolean,default:!1},actions:{default:()=>["file","image"]},placeholder:{default:"Введите сообщение"},disabled:{type:Boolean,default:!1}},{message:{required:!0},messageModifiers:{},files:{},filesModifiers:{}}),emits:e.mergeModels(["sendMessage"],["update:message","update:files"]),setup(s,{emit:n}){const i=n,c=e.useModel(s,"message"),l=e.useModel(s,"files"),d=a=>{l.value&&(l.value=l.value.filter(o=>o.name!==a.name))};return(a,o)=>(e.openBlock(),e.createElementBlock("div",E,[l.value&&l.value.length>0?(e.openBlock(),e.createElementBlock("div",M,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,t=>(e.openBlock(),e.createBlock(k,{key:t.name,file:t,onDeleteFile:d},null,8,["file"]))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",N,[a.viewActions&&a.actions.length>0?(e.openBlock(),e.createBlock(F,{key:0,modelValue:l.value,"onUpdate:modelValue":o[0]||(o[0]=t=>l.value=t),actions:a.actions,disabled:a.disabled},null,8,["modelValue","actions","disabled"])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":o[1]||(o[1]=t=>c.value=t),class:"chat-field__input",placeholder:a.placeholder},null,8,I),[[e.vModelText,c.value]]),e.createElementVNode("button",{class:"chat-field__button",onClick:o[2]||(o[2]=t=>i("sendMessage"))},[e.createVNode(e.unref(m.SendIcon))])])]))}}),S={class:"bonus-summary"},w=e.defineComponent({__name:"BonusSummary",setup(s){return(n,i)=>(e.openBlock(),e.createElementBlock("div",S,[e.createVNode(e.unref(m.BonusIcon),{class:"bonus-summary__icon"}),i[0]||(i[0]=e.createElementVNode("div",{class:"bonus-summary__number"},"123",-1))]))}});exports.BonusSummary=w;exports.ChatField=$;
|
package/dist/blocks/index.es.js
CHANGED
|
@@ -1,78 +1,44 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { g as
|
|
3
|
-
import { C as
|
|
4
|
-
import { I as j, P as q, S as
|
|
5
|
-
import { o as
|
|
6
|
-
import "../
|
|
7
|
-
const K = { class: "chat-file__content" }, Q = /* @__PURE__ */
|
|
1
|
+
import { defineComponent as p, computed as V, createElementBlock as c, openBlock as a, normalizeClass as k, unref as u, createElementVNode as i, createVNode as _, createBlock as v, mergeModels as h, useModel as b, useTemplateRef as y, ref as w, reactive as S, shallowRef as g, onMounted as R, Transition as D, withCtx as L, withDirectives as $, Fragment as B, renderList as I, resolveDynamicComponent as T, toDisplayString as U, vShow as z, createCommentVNode as C, vModelText as N } from "vue";
|
|
2
|
+
import { g as F, I as O, F as A } from "../Image-CHlS9buq.js";
|
|
3
|
+
import { C as E, _ as M, F as P } from "../FileIcon-DkEbi-bi.js";
|
|
4
|
+
import { I as j, P as q, S as x, B as H } from "../SendIcon-BGGNLlmf.js";
|
|
5
|
+
import { o as G } from "../parseFileSize.util-BoDbFdVW.js";
|
|
6
|
+
import { o as J } from "../uploadFile.util-CorOn5lO.js";
|
|
7
|
+
const K = { class: "chat-file__content" }, Q = /* @__PURE__ */ p({
|
|
8
8
|
__name: "ChatFile",
|
|
9
9
|
props: {
|
|
10
10
|
file: {}
|
|
11
11
|
},
|
|
12
12
|
emits: ["deleteFile"],
|
|
13
|
-
setup(
|
|
14
|
-
const
|
|
15
|
-
return (
|
|
16
|
-
class: k(["chat-file", { "chat-file--image": u(
|
|
13
|
+
setup(n, { emit: o }) {
|
|
14
|
+
const d = o, r = V(() => URL.createObjectURL(n.file));
|
|
15
|
+
return (e, m) => (a(), c("div", {
|
|
16
|
+
class: k(["chat-file", { "chat-file--image": u(F)(e.file.type) === "image" }])
|
|
17
17
|
}, [
|
|
18
|
-
|
|
18
|
+
i("button", {
|
|
19
19
|
class: "chat-file__delete",
|
|
20
|
-
onClick:
|
|
20
|
+
onClick: m[0] || (m[0] = (s) => d("deleteFile", e.file))
|
|
21
21
|
}, [
|
|
22
|
-
|
|
22
|
+
_(u(E))
|
|
23
23
|
]),
|
|
24
|
-
|
|
25
|
-
u(
|
|
24
|
+
i("div", K, [
|
|
25
|
+
u(F)(e.file.type) === "image" ? (a(), v(u(O), {
|
|
26
26
|
key: 0,
|
|
27
|
-
file:
|
|
27
|
+
file: r.value,
|
|
28
28
|
size: "large",
|
|
29
29
|
fullScreen: ""
|
|
30
|
-
}, null, 8, ["file"])) : (
|
|
30
|
+
}, null, 8, ["file"])) : (a(), v(u(A), {
|
|
31
31
|
key: 1,
|
|
32
|
-
file:
|
|
32
|
+
file: r.value,
|
|
33
33
|
outlined: !1
|
|
34
34
|
}, null, 8, ["file"]))
|
|
35
35
|
])
|
|
36
36
|
], 2));
|
|
37
37
|
}
|
|
38
|
-
}), W = /* @__PURE__ */
|
|
39
|
-
function X(e) {
|
|
40
|
-
if (!e) return;
|
|
41
|
-
const n = Array.isArray(e) ? e : [e], t = {
|
|
42
|
-
image: ["image/*"],
|
|
43
|
-
pdf: ["application/pdf"],
|
|
44
|
-
excel: [
|
|
45
|
-
"application/vnd.ms-excel",
|
|
46
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
47
|
-
],
|
|
48
|
-
word: [
|
|
49
|
-
"application/msword",
|
|
50
|
-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
51
|
-
],
|
|
52
|
-
all: ["*/*"]
|
|
53
|
-
};
|
|
54
|
-
return n.flatMap((c) => t[c] || []).join(",");
|
|
55
|
-
}
|
|
56
|
-
function Y(e = {}) {
|
|
57
|
-
return new Promise((n) => {
|
|
58
|
-
const t = document.createElement("input");
|
|
59
|
-
t.type = "file", t.style.display = "none", e.maxFiles && e.maxFiles > 1 && (t.multiple = !0);
|
|
60
|
-
const c = X(e.accept);
|
|
61
|
-
c && (t.accept = c), t.addEventListener("change", (l) => {
|
|
62
|
-
const d = l.target;
|
|
63
|
-
let a = [];
|
|
64
|
-
if (d.files && d.files.length > 0 && (a = Array.from(d.files), e.maxFiles && a.length > e.maxFiles && (a = a.slice(0, e.maxFiles)), e.maxFileSize)) {
|
|
65
|
-
const s = N(e.maxFileSize);
|
|
66
|
-
a = a.filter((i) => i.size <= s);
|
|
67
|
-
}
|
|
68
|
-
n(a), document.body.removeChild(t);
|
|
69
|
-
}), document.body.appendChild(t), t.click();
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
const Z = { class: "chat-field-actions" }, ee = {
|
|
38
|
+
}), W = /* @__PURE__ */ M(Q, [["__scopeId", "data-v-25ab2b0f"]]), X = { class: "chat-field-actions" }, Y = {
|
|
73
39
|
ref: "overlay",
|
|
74
40
|
class: "chat-field-actions__overlay"
|
|
75
|
-
},
|
|
41
|
+
}, Z = ["onClick"], ee = { class: "chat-field-actions__overlay-item__label" }, le = ["disabled"], te = /* @__PURE__ */ p({
|
|
76
42
|
__name: "ChatFieldActions",
|
|
77
43
|
props: /* @__PURE__ */ h({
|
|
78
44
|
actions: {},
|
|
@@ -83,61 +49,61 @@ const Z = { class: "chat-field-actions" }, ee = {
|
|
|
83
49
|
modelModifiers: {}
|
|
84
50
|
}),
|
|
85
51
|
emits: ["update:modelValue"],
|
|
86
|
-
setup(
|
|
87
|
-
const
|
|
52
|
+
setup(n) {
|
|
53
|
+
const o = b(n, "modelValue"), d = y("button"), r = y("overlay"), e = w(!1), m = S({
|
|
88
54
|
image: {
|
|
89
|
-
icon:
|
|
55
|
+
icon: g(j),
|
|
90
56
|
label: "Добавить изображение"
|
|
91
57
|
},
|
|
92
58
|
file: {
|
|
93
|
-
icon:
|
|
59
|
+
icon: g(P),
|
|
94
60
|
label: "Добавить файл"
|
|
95
61
|
}
|
|
96
|
-
}),
|
|
97
|
-
|
|
98
|
-
accept:
|
|
62
|
+
}), s = (t) => {
|
|
63
|
+
J({
|
|
64
|
+
accept: t === "image" ? ["image"] : ["pdf", "excel", "word"],
|
|
99
65
|
maxFileSize: "5mb",
|
|
100
66
|
maxFiles: 1
|
|
101
|
-
}).then((
|
|
102
|
-
|
|
67
|
+
}).then((l) => {
|
|
68
|
+
o.value ? o.value = n.multiple ? [...o.value, ...l] : l : o.value = [...l], e.value = !1;
|
|
103
69
|
});
|
|
104
70
|
};
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}, { ignore: [
|
|
109
|
-
}), (
|
|
110
|
-
|
|
111
|
-
default:
|
|
112
|
-
|
|
113
|
-
(
|
|
71
|
+
return R(() => {
|
|
72
|
+
G(r.value, () => {
|
|
73
|
+
e.value = !1;
|
|
74
|
+
}, { ignore: [d.value] });
|
|
75
|
+
}), (t, l) => (a(), c("div", X, [
|
|
76
|
+
_(D, { name: "slide-up" }, {
|
|
77
|
+
default: L(() => [
|
|
78
|
+
$(i("div", Y, [
|
|
79
|
+
(a(!0), c(B, null, I(t.actions, (f) => (a(), c("div", {
|
|
114
80
|
class: "chat-field-actions__overlay-item",
|
|
115
81
|
key: f,
|
|
116
|
-
onClick: (ue) =>
|
|
82
|
+
onClick: (ue) => s(f)
|
|
117
83
|
}, [
|
|
118
|
-
(
|
|
119
|
-
|
|
120
|
-
], 8,
|
|
84
|
+
(a(), v(T(m[f].icon), { class: "chat-field-actions__overlay-item__icon" })),
|
|
85
|
+
i("span", ee, U(m[f].label), 1)
|
|
86
|
+
], 8, Z))), 128))
|
|
121
87
|
], 512), [
|
|
122
|
-
[
|
|
88
|
+
[z, e.value]
|
|
123
89
|
])
|
|
124
90
|
]),
|
|
125
91
|
_: 1
|
|
126
92
|
}),
|
|
127
|
-
|
|
93
|
+
i("button", {
|
|
128
94
|
ref: "button",
|
|
129
|
-
onClick:
|
|
130
|
-
class: k(["chat-field-actions__button", { "chat-field-actions__button--active":
|
|
131
|
-
disabled:
|
|
95
|
+
onClick: l[0] || (l[0] = (f) => e.value = !e.value),
|
|
96
|
+
class: k(["chat-field-actions__button", { "chat-field-actions__button--active": e.value }]),
|
|
97
|
+
disabled: t.disabled
|
|
132
98
|
}, [
|
|
133
|
-
|
|
134
|
-
], 10,
|
|
99
|
+
_(u(q))
|
|
100
|
+
], 10, le)
|
|
135
101
|
]));
|
|
136
102
|
}
|
|
137
|
-
}),
|
|
103
|
+
}), ae = /* @__PURE__ */ M(te, [["__scopeId", "data-v-e64085d6"]]), se = { class: "chat-field" }, oe = {
|
|
138
104
|
key: 0,
|
|
139
105
|
class: "chat-field__files"
|
|
140
|
-
},
|
|
106
|
+
}, ie = { class: "chat-field__wrapper" }, ne = ["placeholder"], pe = /* @__PURE__ */ p({
|
|
141
107
|
__name: "ChatField",
|
|
142
108
|
props: /* @__PURE__ */ h({
|
|
143
109
|
viewActions: { type: Boolean, default: !1 },
|
|
@@ -151,52 +117,52 @@ const Z = { class: "chat-field-actions" }, ee = {
|
|
|
151
117
|
filesModifiers: {}
|
|
152
118
|
}),
|
|
153
119
|
emits: /* @__PURE__ */ h(["sendMessage"], ["update:message", "update:files"]),
|
|
154
|
-
setup(
|
|
155
|
-
const
|
|
156
|
-
|
|
120
|
+
setup(n, { emit: o }) {
|
|
121
|
+
const d = o, r = b(n, "message"), e = b(n, "files"), m = (s) => {
|
|
122
|
+
e.value && (e.value = e.value.filter((t) => t.name !== s.name));
|
|
157
123
|
};
|
|
158
|
-
return (
|
|
159
|
-
|
|
160
|
-
(
|
|
161
|
-
key:
|
|
162
|
-
file:
|
|
163
|
-
onDeleteFile:
|
|
124
|
+
return (s, t) => (a(), c("div", se, [
|
|
125
|
+
e.value && e.value.length > 0 ? (a(), c("div", oe, [
|
|
126
|
+
(a(!0), c(B, null, I(e.value, (l) => (a(), v(W, {
|
|
127
|
+
key: l.name,
|
|
128
|
+
file: l,
|
|
129
|
+
onDeleteFile: m
|
|
164
130
|
}, null, 8, ["file"]))), 128))
|
|
165
|
-
])) :
|
|
166
|
-
|
|
167
|
-
|
|
131
|
+
])) : C("", !0),
|
|
132
|
+
i("div", ie, [
|
|
133
|
+
s.viewActions && s.actions.length > 0 ? (a(), v(ae, {
|
|
168
134
|
key: 0,
|
|
169
|
-
modelValue:
|
|
170
|
-
"onUpdate:modelValue":
|
|
171
|
-
actions:
|
|
172
|
-
disabled:
|
|
173
|
-
}, null, 8, ["modelValue", "actions", "disabled"])) :
|
|
174
|
-
|
|
175
|
-
"onUpdate:modelValue":
|
|
135
|
+
modelValue: e.value,
|
|
136
|
+
"onUpdate:modelValue": t[0] || (t[0] = (l) => e.value = l),
|
|
137
|
+
actions: s.actions,
|
|
138
|
+
disabled: s.disabled
|
|
139
|
+
}, null, 8, ["modelValue", "actions", "disabled"])) : C("", !0),
|
|
140
|
+
$(i("input", {
|
|
141
|
+
"onUpdate:modelValue": t[1] || (t[1] = (l) => r.value = l),
|
|
176
142
|
class: "chat-field__input",
|
|
177
|
-
placeholder:
|
|
178
|
-
}, null, 8,
|
|
179
|
-
[
|
|
143
|
+
placeholder: s.placeholder
|
|
144
|
+
}, null, 8, ne), [
|
|
145
|
+
[N, r.value]
|
|
180
146
|
]),
|
|
181
|
-
|
|
147
|
+
i("button", {
|
|
182
148
|
class: "chat-field__button",
|
|
183
|
-
onClick:
|
|
149
|
+
onClick: t[2] || (t[2] = (l) => d("sendMessage"))
|
|
184
150
|
}, [
|
|
185
|
-
|
|
151
|
+
_(u(x))
|
|
186
152
|
])
|
|
187
153
|
])
|
|
188
154
|
]));
|
|
189
155
|
}
|
|
190
|
-
}),
|
|
156
|
+
}), de = { class: "bonus-summary" }, he = /* @__PURE__ */ p({
|
|
191
157
|
__name: "BonusSummary",
|
|
192
|
-
setup(
|
|
193
|
-
return (
|
|
194
|
-
|
|
195
|
-
|
|
158
|
+
setup(n) {
|
|
159
|
+
return (o, d) => (a(), c("div", de, [
|
|
160
|
+
_(u(H), { class: "bonus-summary__icon" }),
|
|
161
|
+
d[0] || (d[0] = i("div", { class: "bonus-summary__number" }, "123", -1))
|
|
196
162
|
]));
|
|
197
163
|
}
|
|
198
164
|
});
|
|
199
165
|
export {
|
|
200
|
-
|
|
201
|
-
|
|
166
|
+
he as BonusSummary,
|
|
167
|
+
pe as ChatField
|
|
202
168
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -228,9 +228,12 @@ declare type __VLS_Props_13 = {
|
|
|
228
228
|
cols?: number;
|
|
229
229
|
maxHeight?: number;
|
|
230
230
|
error?: boolean;
|
|
231
|
+
errorText?: string;
|
|
232
|
+
smallText?: string;
|
|
231
233
|
inputId?: string;
|
|
232
234
|
size?: 'default' | 'small' | 'large';
|
|
233
235
|
maxlength?: number;
|
|
236
|
+
resizable?: boolean;
|
|
234
237
|
};
|
|
235
238
|
|
|
236
239
|
declare type __VLS_Props_14 = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const d=require("vue"),s=new WeakMap;function f(t){const n=d.unref(t);return n?.$el??n}function p(t){return typeof t=="string"?document.querySelector(t):f(t)}function g(t,n,r={}){const e=p(t);if(!e)return()=>{};const u=s.get(e);u&&(u(),s.delete(e));const i=c=>{const a=c.target instanceof Node?c.target:null;if(!a)return;const m=(d.toValue(r.ignore)??[]).map(o=>typeof o=="string"?document.querySelector(o):f(o)).filter(o=>o!=null);e.contains(a)||m.some(o=>o.contains(a))||n(c)};document.addEventListener("mousedown",i,{capture:!0}),document.addEventListener("touchstart",i,{capture:!0});const l=()=>{document.removeEventListener("mousedown",i,{capture:!0}),document.removeEventListener("touchstart",i,{capture:!0}),s.delete(e)};return s.set(e,l),l}const v=t=>{const n=["b","kb","mb","gb","tb"],r=t.match(/[a-zA-Z]+/)?.[0]||"b",e=parseFloat(t.replace(r,"")),u=n.indexOf(r.toLowerCase());return e*Math.pow(1024,u)};function w(t){if(isNaN(t)||t<0)return"0 Б";const n=["Б","КБ","МБ","ГБ","ТБ"];let r=0,e=t;for(;e>=1024&&r<n.length-1;)e=e/1024,r++;return`${e%1===0?e:e.toFixed(1)} ${n[r]}`}exports.formatFileSize=w;exports.onClickOutside=g;exports.parseFileSize=v;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { toValue as m, unref as p } from "vue";
|
|
2
|
+
const i = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function d(t) {
|
|
4
|
+
const n = p(t);
|
|
5
|
+
return n?.$el ?? n;
|
|
6
|
+
}
|
|
7
|
+
function g(t) {
|
|
8
|
+
return typeof t == "string" ? document.querySelector(t) : d(t);
|
|
9
|
+
}
|
|
10
|
+
function E(t, n, r = {}) {
|
|
11
|
+
const e = g(t);
|
|
12
|
+
if (!e) return () => {
|
|
13
|
+
};
|
|
14
|
+
const u = i.get(e);
|
|
15
|
+
u && (u(), i.delete(e));
|
|
16
|
+
const s = (c) => {
|
|
17
|
+
const a = c.target instanceof Node ? c.target : null;
|
|
18
|
+
if (!a) return;
|
|
19
|
+
const f = (m(r.ignore) ?? []).map((o) => typeof o == "string" ? document.querySelector(o) : d(o)).filter((o) => o != null);
|
|
20
|
+
e.contains(a) || f.some((o) => o.contains(a)) || n(c);
|
|
21
|
+
};
|
|
22
|
+
document.addEventListener("mousedown", s, { capture: !0 }), document.addEventListener("touchstart", s, { capture: !0 });
|
|
23
|
+
const l = () => {
|
|
24
|
+
document.removeEventListener("mousedown", s, { capture: !0 }), document.removeEventListener("touchstart", s, { capture: !0 }), i.delete(e);
|
|
25
|
+
};
|
|
26
|
+
return i.set(e, l), l;
|
|
27
|
+
}
|
|
28
|
+
const h = (t) => {
|
|
29
|
+
const n = ["b", "kb", "mb", "gb", "tb"], r = t.match(/[a-zA-Z]+/)?.[0] || "b", e = parseFloat(t.replace(r, "")), u = n.indexOf(r.toLowerCase());
|
|
30
|
+
return e * Math.pow(1024, u);
|
|
31
|
+
};
|
|
32
|
+
function x(t) {
|
|
33
|
+
if (isNaN(t) || t < 0) return "0 Б";
|
|
34
|
+
const n = ["Б", "КБ", "МБ", "ГБ", "ТБ"];
|
|
35
|
+
let r = 0, e = t;
|
|
36
|
+
for (; e >= 1024 && r < n.length - 1; )
|
|
37
|
+
e = e / 1024, r++;
|
|
38
|
+
return `${e % 1 === 0 ? e : e.toFixed(1)} ${n[r]}`;
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
x as f,
|
|
42
|
+
E as o,
|
|
43
|
+
h as p
|
|
44
|
+
};
|