prlg-ui 1.7.42 → 1.7.44
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-B46QCYLx.cjs +1 -0
- package/dist/Image-ddX0F8QG.js +225 -0
- package/dist/blocks/index.cjs.js +1 -1
- package/dist/blocks/index.es.js +55 -56
- package/dist/index.d.ts +21 -5
- package/dist/prlg-ui.cjs.js +1 -1
- package/dist/prlg-ui.css +1 -1
- package/dist/prlg-ui.es.js +1249 -1262
- package/dist/utils/typeFile.util.ts +21 -21
- package/package.json +1 -1
- package/dist/Image-B_PtktNe.js +0 -182
- package/dist/Image-KC6enSsM.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("vue"),r=require("./FileIcon-sxADkCIe.cjs"),k=l=>{const c=["b","kb","mb","gb","tb"],i=l.match(/[a-zA-Z]+/)?.[0]||"b",o=parseFloat(l.replace(i,"")),t=c.indexOf(i.toLowerCase());return o*Math.pow(1024,t)};function v(l){if(isNaN(l)||l<0)return"0 Б";const c=["Б","КБ","МБ","ГБ","ТБ"];let i=0,o=l;for(;o>=1024&&i<c.length-1;)o=o/1024,i++;return`${o%1===0?o:o.toFixed(1)} ${c[i]}`}function g(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 y={key:1,class:"file__title"},B={key:2,class:"file__info"},C={key:0,class:"file__type"},N={key:1,class:"file__info-separator"},V={key:2,class:"file__size"},h=e.defineComponent({__name:"File",props:{file:{},viewName:{type:Boolean,default:!1},outlined:{type:Boolean,default:!0},removable:{type:Boolean}},emits:["remove"],setup(l,{emit:c}){const i=c,o=e.useId(),t=e.ref(null);async function m(n,s="image"){const u=await(await fetch(n)).blob(),p=u.type.split("/")[1]||"",_=p?`${s}.${p}`:s;return new File([u],_,{type:u.type})}const f=e.computed(()=>t.value&&t.value.mime?g(t.value.mime):null),a=e.computed(()=>{switch(f.value){case"pdf":return r.PdfIcon;case"word":return r.WordIcon;case"excel":return r.ExcelIcon;case"other":default:return r.FileIcon}});return e.onMounted(async()=>{if(typeof l.file=="string"){const n=await m(l.file);t.value={id:o,url:l.file,name:n.name,mime:n.type,size:n.size}}else t.value=l.file}),(n,s)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["file",{"file--outlined":n.outlined}])},[n.removable&&typeof n.file!="string"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"file__remove",onClick:s[0]||(s[0]=d=>i("remove",n.file))},[e.createVNode(e.unref(r.CloseIcon))])):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{class:"file__icon"})),t.value&&t.value.name&&n.viewName?(e.openBlock(),e.createElementBlock("div",y,e.toDisplayString(t.value?t.value.name.split(".")[0]:"unknown"),1)):e.createCommentVNode("",!0),t.value?(e.openBlock(),e.createElementBlock("div",B,[t.value.mime?(e.openBlock(),e.createElementBlock("div",C,e.toDisplayString(f.value),1)):e.createCommentVNode("",!0),t.value.mime&&t.value.size?(e.openBlock(),e.createElementBlock("div",N)):e.createCommentVNode("",!0),t.value.size?(e.openBlock(),e.createElementBlock("div",V,e.toDisplayString(t.value?e.unref(v)(t.value.size):"0 Б"),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],2))}}),w=r._export_sfc(h,[["__scopeId","data-v-9dee864d"]]),E={key:0,class:"image-full-modal"},F={class:"image-full-modal__wrapper"},$={class:"image-full-modal__header"},b={class:"image-full-modal__main"},I=["src","alt"],z=e.defineComponent({__name:"ImageFullModal",props:{src:{},alt:{}},setup(l,{expose:c}){const i=e.ref(!1);return c({open:()=>{i.value=!0},close:()=>{i.value=!1}}),(o,t)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[i.value?(e.openBlock(),e.createElementBlock("div",E,[e.createElementVNode("div",{class:"image-full-modal__overlay",onClick:t[0]||(t[0]=m=>i.value=!1)}),e.createElementVNode("div",F,[e.createElementVNode("div",$,[e.createElementVNode("button",{class:"image-full-modal__close",onClick:t[1]||(t[1]=m=>i.value=!1)},[e.createVNode(e.unref(r.CloseIcon))])]),e.createElementVNode("div",b,[e.createElementVNode("img",{src:o.src,alt:o.alt},null,8,I)]),t[2]||(t[2]=e.createElementVNode("div",{class:"image-full-modal__footer"},null,-1))])])):e.createCommentVNode("",!0)]),_:1})]))}}),S=r._export_sfc(z,[["__scopeId","data-v-edc1a47e"]]),M=["src","alt"],x={key:1,class:"image__info"},j={key:0,class:"image__type"},D={key:1,class:"image__info-separator"},O={key:2,class:"image__size"},L=e.defineComponent({__name:"Image",props:{file:{},alt:{},size:{default:"medium"},fullScreen:{type:Boolean}},setup(l){const c=e.useId(),i=e.useTemplateRef("imageFullModal"),o=e.ref(null);async function t(a,n="image"){const d=await(await fetch(a)).blob(),u=d.type.split("/")[1]||"",p=u?`${n}.${u}`:n;return new File([d],p,{type:d.type})}const m=e.computed(()=>typeof l.file=="string"?l.file:l.file.url);function f(a){if(a.startsWith("image/"))return a.replace("image/","").toLowerCase();const n=a.match(/\.(jpeg|jpg|png|gif|webp|bmp|svg|tiff|ico)(\?.*)?$/i);if(n){let s=n[1].toLowerCase();return s==="jpg"&&(s="jpeg"),s}return"unknown"}return e.onMounted(async()=>{if(typeof l.file=="string"){const a=await t(l.file);o.value={id:c,url:l.file,name:a.name,mime:a.type,size:a.size}}else o.value=l.file}),(a,n)=>(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:n[0]||(n[0]=s=>i.value?.open())},[e.createVNode(e.unref(r.EyeIcon))])):e.createCommentVNode("",!0),e.createElementVNode("img",{src:m.value,alt:a.alt},null,8,M),o.value&&a.size==="large"?(e.openBlock(),e.createElementBlock("div",x,[o.value.mime?(e.openBlock(),e.createElementBlock("div",j,e.toDisplayString(f(o.value.mime)),1)):e.createCommentVNode("",!0),o.value.mime&&o.value.size?(e.openBlock(),e.createElementBlock("div",D)):e.createCommentVNode("",!0),o.value.size?(e.openBlock(),e.createElementBlock("div",O,e.toDisplayString(o.value?e.unref(v)(o.value.size):"0 Б"),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],2),a.fullScreen?(e.openBlock(),e.createBlock(S,{key:0,ref:"imageFullModal",src:m.value,alt:a.alt},null,8,["src","alt"])):e.createCommentVNode("",!0)],64))}}),W=r._export_sfc(L,[["__scopeId","data-v-b7bef272"]]);exports.File=w;exports.Image=W;exports.getFileTypeByMime=g;exports.parseFileSize=k;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { defineComponent as $, useId as z, ref as b, computed as w, onMounted as I, createElementBlock as o, openBlock as s, normalizeClass as C, createCommentVNode as r, createBlock as k, createVNode as h, unref as g, resolveDynamicComponent as j, toDisplayString as p, Teleport as x, Transition as E, withCtx as N, createElementVNode as m, useTemplateRef as V, Fragment as O } from "vue";
|
|
2
|
+
import { F as W, E as L, W as D, P, C as S, _ as F, a as R } from "./FileIcon-DkEbi-bi.js";
|
|
3
|
+
const ce = (l) => {
|
|
4
|
+
const c = ["b", "kb", "mb", "gb", "tb"], n = l.match(/[a-zA-Z]+/)?.[0] || "b", t = parseFloat(l.replace(n, "")), e = c.indexOf(n.toLowerCase());
|
|
5
|
+
return t * Math.pow(1024, e);
|
|
6
|
+
};
|
|
7
|
+
function B(l) {
|
|
8
|
+
if (isNaN(l) || l < 0) return "0 Б";
|
|
9
|
+
const c = ["Б", "КБ", "МБ", "ГБ", "ТБ"];
|
|
10
|
+
let n = 0, t = l;
|
|
11
|
+
for (; t >= 1024 && n < c.length - 1; )
|
|
12
|
+
t = t / 1024, n++;
|
|
13
|
+
return `${t % 1 === 0 ? t : t.toFixed(1)} ${c[n]}`;
|
|
14
|
+
}
|
|
15
|
+
function A(l) {
|
|
16
|
+
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";
|
|
17
|
+
}
|
|
18
|
+
const Z = {
|
|
19
|
+
key: 1,
|
|
20
|
+
class: "file__title"
|
|
21
|
+
}, q = {
|
|
22
|
+
key: 2,
|
|
23
|
+
class: "file__info"
|
|
24
|
+
}, G = {
|
|
25
|
+
key: 0,
|
|
26
|
+
class: "file__type"
|
|
27
|
+
}, H = {
|
|
28
|
+
key: 1,
|
|
29
|
+
class: "file__info-separator"
|
|
30
|
+
}, J = {
|
|
31
|
+
key: 2,
|
|
32
|
+
class: "file__size"
|
|
33
|
+
}, K = /* @__PURE__ */ $({
|
|
34
|
+
__name: "File",
|
|
35
|
+
props: {
|
|
36
|
+
file: {},
|
|
37
|
+
viewName: { type: Boolean, default: !1 },
|
|
38
|
+
outlined: { type: Boolean, default: !0 },
|
|
39
|
+
removable: { type: Boolean }
|
|
40
|
+
},
|
|
41
|
+
emits: ["remove"],
|
|
42
|
+
setup(l, { emit: c }) {
|
|
43
|
+
const n = c, t = z(), e = b(null);
|
|
44
|
+
async function f(a, u = "image") {
|
|
45
|
+
const d = await (await fetch(a)).blob(), y = d.type.split("/")[1] || "", M = y ? `${u}.${y}` : u;
|
|
46
|
+
return new File([d], M, { type: d.type });
|
|
47
|
+
}
|
|
48
|
+
const _ = w(() => e.value && e.value.mime ? A(e.value.mime) : null), i = w(() => {
|
|
49
|
+
switch (_.value) {
|
|
50
|
+
case "pdf":
|
|
51
|
+
return P;
|
|
52
|
+
case "word":
|
|
53
|
+
return D;
|
|
54
|
+
case "excel":
|
|
55
|
+
return L;
|
|
56
|
+
case "other":
|
|
57
|
+
default:
|
|
58
|
+
return W;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return I(async () => {
|
|
62
|
+
if (typeof l.file == "string") {
|
|
63
|
+
const a = await f(l.file);
|
|
64
|
+
e.value = {
|
|
65
|
+
id: t,
|
|
66
|
+
url: l.file,
|
|
67
|
+
name: a.name,
|
|
68
|
+
mime: a.type,
|
|
69
|
+
size: a.size
|
|
70
|
+
};
|
|
71
|
+
} else
|
|
72
|
+
e.value = l.file;
|
|
73
|
+
}), (a, u) => (s(), o("div", {
|
|
74
|
+
class: C(["file", { "file--outlined": a.outlined }])
|
|
75
|
+
}, [
|
|
76
|
+
a.removable && typeof a.file != "string" ? (s(), o("button", {
|
|
77
|
+
key: 0,
|
|
78
|
+
class: "file__remove",
|
|
79
|
+
onClick: u[0] || (u[0] = (v) => n("remove", a.file))
|
|
80
|
+
}, [
|
|
81
|
+
h(g(S))
|
|
82
|
+
])) : r("", !0),
|
|
83
|
+
(s(), k(j(i.value), { class: "file__icon" })),
|
|
84
|
+
e.value && e.value.name && a.viewName ? (s(), o("div", Z, p(e.value ? e.value.name.split(".")[0] : "unknown"), 1)) : r("", !0),
|
|
85
|
+
e.value ? (s(), o("div", q, [
|
|
86
|
+
e.value.mime ? (s(), o("div", G, p(_.value), 1)) : r("", !0),
|
|
87
|
+
e.value.mime && e.value.size ? (s(), o("div", H)) : r("", !0),
|
|
88
|
+
e.value.size ? (s(), o("div", J, p(e.value ? g(B)(e.value.size) : "0 Б"), 1)) : r("", !0)
|
|
89
|
+
])) : r("", !0)
|
|
90
|
+
], 2));
|
|
91
|
+
}
|
|
92
|
+
}), me = /* @__PURE__ */ F(K, [["__scopeId", "data-v-9dee864d"]]), Q = {
|
|
93
|
+
key: 0,
|
|
94
|
+
class: "image-full-modal"
|
|
95
|
+
}, T = { class: "image-full-modal__wrapper" }, U = { class: "image-full-modal__header" }, X = { class: "image-full-modal__main" }, Y = ["src", "alt"], ee = /* @__PURE__ */ $({
|
|
96
|
+
__name: "ImageFullModal",
|
|
97
|
+
props: {
|
|
98
|
+
src: {},
|
|
99
|
+
alt: {}
|
|
100
|
+
},
|
|
101
|
+
setup(l, { expose: c }) {
|
|
102
|
+
const n = b(!1);
|
|
103
|
+
return c({
|
|
104
|
+
open: () => {
|
|
105
|
+
n.value = !0;
|
|
106
|
+
},
|
|
107
|
+
close: () => {
|
|
108
|
+
n.value = !1;
|
|
109
|
+
}
|
|
110
|
+
}), (t, e) => (s(), k(x, { to: "body" }, [
|
|
111
|
+
h(E, { name: "fade" }, {
|
|
112
|
+
default: N(() => [
|
|
113
|
+
n.value ? (s(), o("div", Q, [
|
|
114
|
+
m("div", {
|
|
115
|
+
class: "image-full-modal__overlay",
|
|
116
|
+
onClick: e[0] || (e[0] = (f) => n.value = !1)
|
|
117
|
+
}),
|
|
118
|
+
m("div", T, [
|
|
119
|
+
m("div", U, [
|
|
120
|
+
m("button", {
|
|
121
|
+
class: "image-full-modal__close",
|
|
122
|
+
onClick: e[1] || (e[1] = (f) => n.value = !1)
|
|
123
|
+
}, [
|
|
124
|
+
h(g(S))
|
|
125
|
+
])
|
|
126
|
+
]),
|
|
127
|
+
m("div", X, [
|
|
128
|
+
m("img", {
|
|
129
|
+
src: t.src,
|
|
130
|
+
alt: t.alt
|
|
131
|
+
}, null, 8, Y)
|
|
132
|
+
]),
|
|
133
|
+
e[2] || (e[2] = m("div", { class: "image-full-modal__footer" }, null, -1))
|
|
134
|
+
])
|
|
135
|
+
])) : r("", !0)
|
|
136
|
+
]),
|
|
137
|
+
_: 1
|
|
138
|
+
})
|
|
139
|
+
]));
|
|
140
|
+
}
|
|
141
|
+
}), le = /* @__PURE__ */ F(ee, [["__scopeId", "data-v-edc1a47e"]]), te = ["src", "alt"], ae = {
|
|
142
|
+
key: 1,
|
|
143
|
+
class: "image__info"
|
|
144
|
+
}, ie = {
|
|
145
|
+
key: 0,
|
|
146
|
+
class: "image__type"
|
|
147
|
+
}, se = {
|
|
148
|
+
key: 1,
|
|
149
|
+
class: "image__info-separator"
|
|
150
|
+
}, ne = {
|
|
151
|
+
key: 2,
|
|
152
|
+
class: "image__size"
|
|
153
|
+
}, oe = /* @__PURE__ */ $({
|
|
154
|
+
__name: "Image",
|
|
155
|
+
props: {
|
|
156
|
+
file: {},
|
|
157
|
+
alt: {},
|
|
158
|
+
size: { default: "medium" },
|
|
159
|
+
fullScreen: { type: Boolean }
|
|
160
|
+
},
|
|
161
|
+
setup(l) {
|
|
162
|
+
const c = z(), n = V("imageFullModal"), t = b(null);
|
|
163
|
+
async function e(i, a = "image") {
|
|
164
|
+
const v = await (await fetch(i)).blob(), d = v.type.split("/")[1] || "", y = d ? `${a}.${d}` : a;
|
|
165
|
+
return new File([v], y, { type: v.type });
|
|
166
|
+
}
|
|
167
|
+
const f = w(() => typeof l.file == "string" ? l.file : l.file.url);
|
|
168
|
+
function _(i) {
|
|
169
|
+
if (i.startsWith("image/"))
|
|
170
|
+
return i.replace("image/", "").toLowerCase();
|
|
171
|
+
const a = i.match(/\.(jpeg|jpg|png|gif|webp|bmp|svg|tiff|ico)(\?.*)?$/i);
|
|
172
|
+
if (a) {
|
|
173
|
+
let u = a[1].toLowerCase();
|
|
174
|
+
return u === "jpg" && (u = "jpeg"), u;
|
|
175
|
+
}
|
|
176
|
+
return "unknown";
|
|
177
|
+
}
|
|
178
|
+
return I(async () => {
|
|
179
|
+
if (typeof l.file == "string") {
|
|
180
|
+
const i = await e(l.file);
|
|
181
|
+
t.value = {
|
|
182
|
+
id: c,
|
|
183
|
+
url: l.file,
|
|
184
|
+
name: i.name,
|
|
185
|
+
mime: i.type,
|
|
186
|
+
size: i.size
|
|
187
|
+
};
|
|
188
|
+
} else
|
|
189
|
+
t.value = l.file;
|
|
190
|
+
}), (i, a) => (s(), o(O, null, [
|
|
191
|
+
m("div", {
|
|
192
|
+
class: C(["image", `image--${i.size}`, { "image--full-screen": i.fullScreen }])
|
|
193
|
+
}, [
|
|
194
|
+
i.fullScreen ? (s(), o("div", {
|
|
195
|
+
key: 0,
|
|
196
|
+
class: "image__overlay",
|
|
197
|
+
onClick: a[0] || (a[0] = (u) => n.value?.open())
|
|
198
|
+
}, [
|
|
199
|
+
h(g(R))
|
|
200
|
+
])) : r("", !0),
|
|
201
|
+
m("img", {
|
|
202
|
+
src: f.value,
|
|
203
|
+
alt: i.alt
|
|
204
|
+
}, null, 8, te),
|
|
205
|
+
t.value && i.size === "large" ? (s(), o("div", ae, [
|
|
206
|
+
t.value.mime ? (s(), o("div", ie, p(_(t.value.mime)), 1)) : r("", !0),
|
|
207
|
+
t.value.mime && t.value.size ? (s(), o("div", se)) : r("", !0),
|
|
208
|
+
t.value.size ? (s(), o("div", ne, p(t.value ? g(B)(t.value.size) : "0 Б"), 1)) : r("", !0)
|
|
209
|
+
])) : r("", !0)
|
|
210
|
+
], 2),
|
|
211
|
+
i.fullScreen ? (s(), k(le, {
|
|
212
|
+
key: 0,
|
|
213
|
+
ref: "imageFullModal",
|
|
214
|
+
src: f.value,
|
|
215
|
+
alt: i.alt
|
|
216
|
+
}, null, 8, ["src", "alt"])) : r("", !0)
|
|
217
|
+
], 64));
|
|
218
|
+
}
|
|
219
|
+
}), fe = /* @__PURE__ */ F(oe, [["__scopeId", "data-v-b7bef272"]]);
|
|
220
|
+
export {
|
|
221
|
+
me as F,
|
|
222
|
+
fe as I,
|
|
223
|
+
A as g,
|
|
224
|
+
ce as p
|
|
225
|
+
};
|
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-B46QCYLx.cjs"),f=require("../FileIcon-sxADkCIe.cjs"),m=require("../SendIcon-_UxV_dOO.cjs"),p=require("../onClickOutside.util-CvjEyTtT.cjs");require("../dayjs.util-Dg65EiGQ.cjs");const v={class:"chat-file__content"},_=e.defineComponent({__name:"ChatFile",props:{file:{}},emits:["deleteFile"],setup(l,{emit:s}){const o=s,c=e.computed(()=>URL.createObjectURL(l.file));return(t,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["chat-file",{"chat-file--image":e.unref(u.getFileTypeByMime)(t.file.type)==="image"}])},[e.createElementVNode("button",{class:"chat-file__delete",onClick:r[0]||(r[0]=a=>o("deleteFile",t.file))},[e.createVNode(e.unref(f.CloseIcon))]),e.createElementVNode("div",v,[e.unref(u.getFileTypeByMime)(t.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))}}),h=f._export_sfc(_,[["__scopeId","data-v-25ab2b0f"]]);function g(l){if(!l)return;const s=Array.isArray(l)?l:[l],o={image:["image/*"],pdf:["application/pdf"],excel:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],word:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],all:["*/*"]};return s.flatMap(c=>o[c]||[]).join(",")}function y(l={}){return new Promise(s=>{const o=document.createElement("input");o.type="file",o.style.display="none",l.maxFiles&&l.maxFiles>1&&(o.multiple=!0);const c=g(l.accept);c&&(o.accept=c),o.addEventListener("change",t=>{const r=t.target;let a=[];if(r.files&&r.files.length>0&&(a=Array.from(r.files),l.maxFiles&&a.length>l.maxFiles&&(a=a.slice(0,l.maxFiles)),l.maxFileSize)){const i=u.parseFileSize(l.maxFileSize);a=a.filter(n=>n.size<=i)}s(a),document.body.removeChild(o)}),document.body.appendChild(o),o.click()})}const k={class:"chat-field-actions"},B={ref:"overlay",class:"chat-field-actions__overlay"},b=["onClick"],F={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(l){const s=e.useModel(l,"modelValue"),o=e.useTemplateRef("button"),c=e.useTemplateRef("overlay"),t=e.ref(!1),r=e.reactive({image:{icon:e.shallowRef(m.ImageIcon),label:"Добавить изображение"},file:{icon:e.shallowRef(f.FileIcon),label:"Добавить файл"}}),a=i=>{y({accept:i==="image"?["image"]:["pdf","excel","word"],maxFileSize:"5mb",maxFiles:1}).then(n=>{s.value?s.value=l.multiple?[...s.value,...n]:n:s.value=[...n],t.value=!1})};return e.onMounted(()=>{p.onClickOutside(c.value,()=>{t.value=!1},{ignore:[o.value]})}),(i,n)=>(e.openBlock(),e.createElementBlock("div",k,[e.createVNode(e.Transition,{name:"slide-up"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",B,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.actions,d=>(e.openBlock(),e.createElementBlock("div",{class:"chat-field-actions__overlay-item",key:d,onClick:z=>a(d)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r[d].icon),{class:"chat-field-actions__overlay-item__icon"})),e.createElementVNode("span",F,e.toDisplayString(r[d].label),1)],8,b))),128))],512),[[e.vShow,t.value]])]),_:1}),e.createElementVNode("button",{ref:"button",onClick:n[0]||(n[0]=d=>t.value=!t.value),class:e.normalizeClass(["chat-field-actions__button",{"chat-field-actions__button--active":t.value}]),disabled:i.disabled},[e.createVNode(e.unref(m.PlusRoundedIcon))],10,C)]))}}),E=f._export_sfc(V,[["__scopeId","data-v-6b295528"]]),M={class:"chat-field"},N={key:0,class:"chat-field__files"},S={class:"chat-field__wrapper"},w=["placeholder"],x=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(l,{emit:s}){const o=s,c=e.useModel(l,"message"),t=e.useModel(l,"files"),r=a=>{t.value&&(t.value=t.value.filter(i=>i.name!==a.name))};return(a,i)=>(e.openBlock(),e.createElementBlock("div",M,[t.value&&t.value.length>0?(e.openBlock(),e.createElementBlock("div",N,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.value,n=>(e.openBlock(),e.createBlock(h,{key:n.name,file:n,onDeleteFile:r},null,8,["file"]))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",S,[a.viewActions&&a.actions.length>0?(e.openBlock(),e.createBlock(E,{key:0,modelValue:t.value,"onUpdate:modelValue":i[0]||(i[0]=n=>t.value=n),actions:a.actions,disabled:a.disabled},null,8,["modelValue","actions","disabled"])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":i[1]||(i[1]=n=>c.value=n),class:"chat-field__input",placeholder:a.placeholder},null,8,w),[[e.vModelText,c.value]]),e.createElementVNode("button",{class:"chat-field__button",onClick:i[2]||(i[2]=n=>o("sendMessage"))},[e.createVNode(e.unref(m.SendIcon))])])]))}}),I={class:"bonus-summary"},$=e.defineComponent({__name:"BonusSummary",setup(l){return(s,o)=>(e.openBlock(),e.createElementBlock("div",I,[e.createVNode(e.unref(m.BonusIcon),{class:"bonus-summary__icon"}),o[0]||(o[0]=e.createElementVNode("div",{class:"bonus-summary__number"},"123",-1))]))}});exports.BonusSummary=$;exports.ChatField=x;
|
package/dist/blocks/index.es.js
CHANGED
|
@@ -1,45 +1,44 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { g as C, I as T, F as U, p as N } from "../Image-
|
|
3
|
-
import { C as O, _ as
|
|
1
|
+
import { defineComponent as v, computed as B, createElementBlock as m, openBlock as o, normalizeClass as k, unref as u, createElementVNode as r, createVNode as p, createBlock as _, mergeModels as h, useModel as g, useTemplateRef as y, ref as I, reactive as M, shallowRef as b, onMounted as V, Transition as z, withCtx as R, withDirectives as S, Fragment as x, renderList as $, resolveDynamicComponent as A, toDisplayString as D, vShow as L, createCommentVNode as F, vModelText as E } from "vue";
|
|
2
|
+
import { g as C, I as T, F as U, p as N } from "../Image-ddX0F8QG.js";
|
|
3
|
+
import { C as O, _ as w, F as P } from "../FileIcon-DkEbi-bi.js";
|
|
4
4
|
import { I as j, P as q, S as H, B as G } from "../SendIcon-BGGNLlmf.js";
|
|
5
5
|
import { o as J } from "../onClickOutside.util-BWGmebYq.js";
|
|
6
6
|
import "../dayjs.util-RJe77c19.js";
|
|
7
|
-
const K = { class: "chat-file__content" }, Q = /* @__PURE__ */
|
|
7
|
+
const K = { class: "chat-file__content" }, Q = /* @__PURE__ */ v({
|
|
8
8
|
__name: "ChatFile",
|
|
9
9
|
props: {
|
|
10
10
|
file: {}
|
|
11
11
|
},
|
|
12
12
|
emits: ["deleteFile"],
|
|
13
|
-
setup(
|
|
14
|
-
const t = n,
|
|
15
|
-
return (
|
|
16
|
-
class: k(["chat-file", { "chat-file--image": u(C)(
|
|
13
|
+
setup(e, { emit: n }) {
|
|
14
|
+
const t = n, c = B(() => URL.createObjectURL(e.file));
|
|
15
|
+
return (l, d) => (o(), m("div", {
|
|
16
|
+
class: k(["chat-file", { "chat-file--image": u(C)(l.file.type) === "image" }])
|
|
17
17
|
}, [
|
|
18
18
|
r("button", {
|
|
19
19
|
class: "chat-file__delete",
|
|
20
|
-
onClick:
|
|
20
|
+
onClick: d[0] || (d[0] = (a) => t("deleteFile", l.file))
|
|
21
21
|
}, [
|
|
22
22
|
p(u(O))
|
|
23
23
|
]),
|
|
24
24
|
r("div", K, [
|
|
25
|
-
u(C)(
|
|
25
|
+
u(C)(l.file.type) === "image" ? (o(), _(u(T), {
|
|
26
26
|
key: 0,
|
|
27
|
-
file:
|
|
28
|
-
alt: e.file.name,
|
|
27
|
+
file: c.value,
|
|
29
28
|
size: "large",
|
|
30
|
-
|
|
31
|
-
}, null, 8, ["file"
|
|
29
|
+
fullScreen: ""
|
|
30
|
+
}, null, 8, ["file"])) : (o(), _(u(U), {
|
|
32
31
|
key: 1,
|
|
33
|
-
file:
|
|
32
|
+
file: c.value,
|
|
34
33
|
outlined: !1
|
|
35
34
|
}, null, 8, ["file"]))
|
|
36
35
|
])
|
|
37
36
|
], 2));
|
|
38
37
|
}
|
|
39
|
-
}), W = /* @__PURE__ */
|
|
40
|
-
function X(
|
|
41
|
-
if (!
|
|
42
|
-
const n = Array.isArray(
|
|
38
|
+
}), W = /* @__PURE__ */ w(Q, [["__scopeId", "data-v-25ab2b0f"]]);
|
|
39
|
+
function X(e) {
|
|
40
|
+
if (!e) return;
|
|
41
|
+
const n = Array.isArray(e) ? e : [e], t = {
|
|
43
42
|
image: ["image/*"],
|
|
44
43
|
pdf: ["application/pdf"],
|
|
45
44
|
excel: [
|
|
@@ -52,18 +51,18 @@ function X(l) {
|
|
|
52
51
|
],
|
|
53
52
|
all: ["*/*"]
|
|
54
53
|
};
|
|
55
|
-
return n.flatMap((
|
|
54
|
+
return n.flatMap((c) => t[c] || []).join(",");
|
|
56
55
|
}
|
|
57
|
-
function Y(
|
|
56
|
+
function Y(e = {}) {
|
|
58
57
|
return new Promise((n) => {
|
|
59
58
|
const t = document.createElement("input");
|
|
60
|
-
t.type = "file", t.style.display = "none",
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const
|
|
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;
|
|
64
63
|
let a = [];
|
|
65
|
-
if (
|
|
66
|
-
const s = N(
|
|
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);
|
|
67
66
|
a = a.filter((i) => i.size <= s);
|
|
68
67
|
}
|
|
69
68
|
n(a), document.body.removeChild(t);
|
|
@@ -73,7 +72,7 @@ function Y(l = {}) {
|
|
|
73
72
|
const Z = { class: "chat-field-actions" }, ee = {
|
|
74
73
|
ref: "overlay",
|
|
75
74
|
class: "chat-field-actions__overlay"
|
|
76
|
-
}, le = ["onClick"], te = { class: "chat-field-actions__overlay-item__label" }, ae = ["disabled"], ie = /* @__PURE__ */
|
|
75
|
+
}, le = ["onClick"], te = { class: "chat-field-actions__overlay-item__label" }, ae = ["disabled"], ie = /* @__PURE__ */ v({
|
|
77
76
|
__name: "ChatFieldActions",
|
|
78
77
|
props: /* @__PURE__ */ h({
|
|
79
78
|
actions: {},
|
|
@@ -84,8 +83,8 @@ const Z = { class: "chat-field-actions" }, ee = {
|
|
|
84
83
|
modelModifiers: {}
|
|
85
84
|
}),
|
|
86
85
|
emits: ["update:modelValue"],
|
|
87
|
-
setup(
|
|
88
|
-
const n = g(
|
|
86
|
+
setup(e) {
|
|
87
|
+
const n = g(e, "modelValue"), t = y("button"), c = y("overlay"), l = I(!1), d = M({
|
|
89
88
|
image: {
|
|
90
89
|
icon: b(j),
|
|
91
90
|
label: "Добавить изображение"
|
|
@@ -100,45 +99,45 @@ const Z = { class: "chat-field-actions" }, ee = {
|
|
|
100
99
|
maxFileSize: "5mb",
|
|
101
100
|
maxFiles: 1
|
|
102
101
|
}).then((i) => {
|
|
103
|
-
n.value ? n.value =
|
|
102
|
+
n.value ? n.value = e.multiple ? [...n.value, ...i] : i : n.value = [...i], l.value = !1;
|
|
104
103
|
});
|
|
105
104
|
};
|
|
106
105
|
return V(() => {
|
|
107
|
-
J(
|
|
108
|
-
|
|
106
|
+
J(c.value, () => {
|
|
107
|
+
l.value = !1;
|
|
109
108
|
}, { ignore: [t.value] });
|
|
110
109
|
}), (s, i) => (o(), m("div", Z, [
|
|
111
110
|
p(z, { name: "slide-up" }, {
|
|
112
111
|
default: R(() => [
|
|
113
112
|
S(r("div", ee, [
|
|
114
|
-
(o(!0), m(
|
|
113
|
+
(o(!0), m(x, null, $(s.actions, (f) => (o(), m("div", {
|
|
115
114
|
class: "chat-field-actions__overlay-item",
|
|
116
115
|
key: f,
|
|
117
116
|
onClick: (ue) => a(f)
|
|
118
117
|
}, [
|
|
119
|
-
(o(),
|
|
120
|
-
r("span", te, D(
|
|
118
|
+
(o(), _(A(d[f].icon), { class: "chat-field-actions__overlay-item__icon" })),
|
|
119
|
+
r("span", te, D(d[f].label), 1)
|
|
121
120
|
], 8, le))), 128))
|
|
122
121
|
], 512), [
|
|
123
|
-
[L,
|
|
122
|
+
[L, l.value]
|
|
124
123
|
])
|
|
125
124
|
]),
|
|
126
125
|
_: 1
|
|
127
126
|
}),
|
|
128
127
|
r("button", {
|
|
129
128
|
ref: "button",
|
|
130
|
-
onClick: i[0] || (i[0] = (f) =>
|
|
131
|
-
class: k(["chat-field-actions__button", { "chat-field-actions__button--active":
|
|
129
|
+
onClick: i[0] || (i[0] = (f) => l.value = !l.value),
|
|
130
|
+
class: k(["chat-field-actions__button", { "chat-field-actions__button--active": l.value }]),
|
|
132
131
|
disabled: s.disabled
|
|
133
132
|
}, [
|
|
134
133
|
p(u(q))
|
|
135
134
|
], 10, ae)
|
|
136
135
|
]));
|
|
137
136
|
}
|
|
138
|
-
}), se = /* @__PURE__ */
|
|
137
|
+
}), se = /* @__PURE__ */ w(ie, [["__scopeId", "data-v-6b295528"]]), ne = { class: "chat-field" }, oe = {
|
|
139
138
|
key: 0,
|
|
140
139
|
class: "chat-field__files"
|
|
141
|
-
},
|
|
140
|
+
}, ce = { class: "chat-field__wrapper" }, de = ["placeholder"], ge = /* @__PURE__ */ v({
|
|
142
141
|
__name: "ChatField",
|
|
143
142
|
props: /* @__PURE__ */ h({
|
|
144
143
|
viewActions: { type: Boolean, default: !1 },
|
|
@@ -152,32 +151,32 @@ const Z = { class: "chat-field-actions" }, ee = {
|
|
|
152
151
|
filesModifiers: {}
|
|
153
152
|
}),
|
|
154
153
|
emits: /* @__PURE__ */ h(["sendMessage"], ["update:message", "update:files"]),
|
|
155
|
-
setup(
|
|
156
|
-
const t = n,
|
|
157
|
-
|
|
154
|
+
setup(e, { emit: n }) {
|
|
155
|
+
const t = n, c = g(e, "message"), l = g(e, "files"), d = (a) => {
|
|
156
|
+
l.value && (l.value = l.value.filter((s) => s.name !== a.name));
|
|
158
157
|
};
|
|
159
158
|
return (a, s) => (o(), m("div", ne, [
|
|
160
|
-
|
|
161
|
-
(o(!0), m(
|
|
159
|
+
l.value && l.value.length > 0 ? (o(), m("div", oe, [
|
|
160
|
+
(o(!0), m(x, null, $(l.value, (i) => (o(), _(W, {
|
|
162
161
|
key: i.name,
|
|
163
162
|
file: i,
|
|
164
|
-
onDeleteFile:
|
|
163
|
+
onDeleteFile: d
|
|
165
164
|
}, null, 8, ["file"]))), 128))
|
|
166
165
|
])) : F("", !0),
|
|
167
|
-
r("div",
|
|
168
|
-
a.viewActions && a.actions.length > 0 ? (o(),
|
|
166
|
+
r("div", ce, [
|
|
167
|
+
a.viewActions && a.actions.length > 0 ? (o(), _(se, {
|
|
169
168
|
key: 0,
|
|
170
|
-
modelValue:
|
|
171
|
-
"onUpdate:modelValue": s[0] || (s[0] = (i) =>
|
|
169
|
+
modelValue: l.value,
|
|
170
|
+
"onUpdate:modelValue": s[0] || (s[0] = (i) => l.value = i),
|
|
172
171
|
actions: a.actions,
|
|
173
172
|
disabled: a.disabled
|
|
174
173
|
}, null, 8, ["modelValue", "actions", "disabled"])) : F("", !0),
|
|
175
174
|
S(r("input", {
|
|
176
|
-
"onUpdate:modelValue": s[1] || (s[1] = (i) =>
|
|
175
|
+
"onUpdate:modelValue": s[1] || (s[1] = (i) => c.value = i),
|
|
177
176
|
class: "chat-field__input",
|
|
178
177
|
placeholder: a.placeholder
|
|
179
|
-
}, null, 8,
|
|
180
|
-
[E,
|
|
178
|
+
}, null, 8, de), [
|
|
179
|
+
[E, c.value]
|
|
181
180
|
]),
|
|
182
181
|
r("button", {
|
|
183
182
|
class: "chat-field__button",
|
|
@@ -188,9 +187,9 @@ const Z = { class: "chat-field-actions" }, ee = {
|
|
|
188
187
|
])
|
|
189
188
|
]));
|
|
190
189
|
}
|
|
191
|
-
}), re = { class: "bonus-summary" }, ye = /* @__PURE__ */
|
|
190
|
+
}), re = { class: "bonus-summary" }, ye = /* @__PURE__ */ v({
|
|
192
191
|
__name: "BonusSummary",
|
|
193
|
-
setup(
|
|
192
|
+
setup(e) {
|
|
194
193
|
return (n, t) => (o(), m("div", re, [
|
|
195
194
|
p(u(G), { class: "bonus-summary__icon" }),
|
|
196
195
|
t[0] || (t[0] = r("div", { class: "bonus-summary__number" }, "123", -1))
|
package/dist/index.d.ts
CHANGED
|
@@ -234,14 +234,14 @@ declare type __VLS_Props_13 = {
|
|
|
234
234
|
};
|
|
235
235
|
|
|
236
236
|
declare type __VLS_Props_14 = {
|
|
237
|
-
file: string |
|
|
237
|
+
file: string | IFile;
|
|
238
238
|
viewName?: boolean;
|
|
239
239
|
outlined?: boolean;
|
|
240
240
|
removable?: boolean;
|
|
241
241
|
};
|
|
242
242
|
|
|
243
243
|
declare type __VLS_Props_15 = {
|
|
244
|
-
file: string |
|
|
244
|
+
file: string | IFile_2;
|
|
245
245
|
alt?: string;
|
|
246
246
|
size?: 'small' | 'medium' | 'large';
|
|
247
247
|
fullScreen?: boolean;
|
|
@@ -362,7 +362,7 @@ declare type __VLS_Props_8 = {
|
|
|
362
362
|
countInPackage?: number;
|
|
363
363
|
icon?: Component;
|
|
364
364
|
iconPosition?: 'left' | 'right';
|
|
365
|
-
formatter?: (value: number) =>
|
|
365
|
+
formatter?: (value: number) => number;
|
|
366
366
|
};
|
|
367
367
|
|
|
368
368
|
declare type __VLS_Props_9 = Props_2;
|
|
@@ -1010,14 +1010,30 @@ declare interface DropdownProps {
|
|
|
1010
1010
|
}
|
|
1011
1011
|
|
|
1012
1012
|
declare const File_2: DefineComponent<__VLS_Props_14, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
|
|
1013
|
-
remove: (file:
|
|
1013
|
+
remove: (file: IFile) => any;
|
|
1014
1014
|
}, string, PublicProps, Readonly<__VLS_Props_14> & Readonly<{
|
|
1015
|
-
onRemove?: ((file:
|
|
1015
|
+
onRemove?: ((file: IFile) => any) | undefined;
|
|
1016
1016
|
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
1017
1017
|
export { File_2 as File }
|
|
1018
1018
|
|
|
1019
1019
|
export declare const IconField: __VLS_WithTemplateSlots_7<typeof __VLS_component_7, __VLS_TemplateResult_7["slots"]>;
|
|
1020
1020
|
|
|
1021
|
+
declare interface IFile {
|
|
1022
|
+
id: string;
|
|
1023
|
+
url: string;
|
|
1024
|
+
name?: string;
|
|
1025
|
+
mime: string | null;
|
|
1026
|
+
size: number | null;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
declare interface IFile_2 {
|
|
1030
|
+
id: string;
|
|
1031
|
+
url: string;
|
|
1032
|
+
name?: string;
|
|
1033
|
+
mime: string | null;
|
|
1034
|
+
size: number | null;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1021
1037
|
declare const Image_2: DefineComponent<__VLS_Props_15, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_15> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
1022
1038
|
imageFullModal: CreateComponentPublicInstanceWithMixins<Readonly<{
|
|
1023
1039
|
src: string;
|