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.
@@ -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=_;
@@ -1 +1 @@
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;
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=$;
@@ -1,78 +1,44 @@
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
- import { I as j, P as q, S as H, B as G } from "../SendIcon-BGGNLlmf.js";
5
- import { o as J } from "../onClickOutside.util-BWGmebYq.js";
6
- import "../dayjs.util-RJe77c19.js";
7
- const K = { class: "chat-file__content" }, Q = /* @__PURE__ */ v({
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(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" }])
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
- r("button", {
18
+ i("button", {
19
19
  class: "chat-file__delete",
20
- onClick: d[0] || (d[0] = (a) => t("deleteFile", l.file))
20
+ onClick: m[0] || (m[0] = (s) => d("deleteFile", e.file))
21
21
  }, [
22
- p(u(O))
22
+ _(u(E))
23
23
  ]),
24
- r("div", K, [
25
- u(C)(l.file.type) === "image" ? (o(), _(u(T), {
24
+ i("div", K, [
25
+ u(F)(e.file.type) === "image" ? (a(), v(u(O), {
26
26
  key: 0,
27
- file: c.value,
27
+ file: r.value,
28
28
  size: "large",
29
29
  fullScreen: ""
30
- }, null, 8, ["file"])) : (o(), _(u(U), {
30
+ }, null, 8, ["file"])) : (a(), v(u(A), {
31
31
  key: 1,
32
- file: c.value,
32
+ file: r.value,
33
33
  outlined: !1
34
34
  }, null, 8, ["file"]))
35
35
  ])
36
36
  ], 2));
37
37
  }
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 = {
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
- }, le = ["onClick"], te = { class: "chat-field-actions__overlay-item__label" }, ae = ["disabled"], ie = /* @__PURE__ */ v({
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(e) {
87
- const n = g(e, "modelValue"), t = y("button"), c = y("overlay"), l = I(!1), d = M({
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: b(j),
55
+ icon: g(j),
90
56
  label: "Добавить изображение"
91
57
  },
92
58
  file: {
93
- icon: b(P),
59
+ icon: g(P),
94
60
  label: "Добавить файл"
95
61
  }
96
- }), a = (s) => {
97
- Y({
98
- accept: s === "image" ? ["image"] : ["pdf", "excel", "word"],
62
+ }), s = (t) => {
63
+ J({
64
+ accept: t === "image" ? ["image"] : ["pdf", "excel", "word"],
99
65
  maxFileSize: "5mb",
100
66
  maxFiles: 1
101
- }).then((i) => {
102
- n.value ? n.value = e.multiple ? [...n.value, ...i] : i : n.value = [...i], l.value = !1;
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 V(() => {
106
- J(c.value, () => {
107
- l.value = !1;
108
- }, { ignore: [t.value] });
109
- }), (s, i) => (o(), m("div", Z, [
110
- p(z, { name: "slide-up" }, {
111
- default: R(() => [
112
- S(r("div", ee, [
113
- (o(!0), m(x, null, $(s.actions, (f) => (o(), m("div", {
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) => a(f)
82
+ onClick: (ue) => s(f)
117
83
  }, [
118
- (o(), _(A(d[f].icon), { class: "chat-field-actions__overlay-item__icon" })),
119
- r("span", te, D(d[f].label), 1)
120
- ], 8, le))), 128))
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
- [L, l.value]
88
+ [z, e.value]
123
89
  ])
124
90
  ]),
125
91
  _: 1
126
92
  }),
127
- r("button", {
93
+ i("button", {
128
94
  ref: "button",
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 }]),
131
- disabled: s.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
- p(u(q))
134
- ], 10, ae)
99
+ _(u(q))
100
+ ], 10, le)
135
101
  ]));
136
102
  }
137
- }), se = /* @__PURE__ */ w(ie, [["__scopeId", "data-v-6b295528"]]), ne = { class: "chat-field" }, oe = {
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
- }, ce = { class: "chat-field__wrapper" }, de = ["placeholder"], ge = /* @__PURE__ */ v({
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(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));
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 (a, s) => (o(), m("div", ne, [
159
- l.value && l.value.length > 0 ? (o(), m("div", oe, [
160
- (o(!0), m(x, null, $(l.value, (i) => (o(), _(W, {
161
- key: i.name,
162
- file: i,
163
- onDeleteFile: d
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
- ])) : F("", !0),
166
- r("div", ce, [
167
- a.viewActions && a.actions.length > 0 ? (o(), _(se, {
131
+ ])) : C("", !0),
132
+ i("div", ie, [
133
+ s.viewActions && s.actions.length > 0 ? (a(), v(ae, {
168
134
  key: 0,
169
- modelValue: l.value,
170
- "onUpdate:modelValue": s[0] || (s[0] = (i) => l.value = i),
171
- actions: a.actions,
172
- disabled: a.disabled
173
- }, null, 8, ["modelValue", "actions", "disabled"])) : F("", !0),
174
- S(r("input", {
175
- "onUpdate:modelValue": s[1] || (s[1] = (i) => c.value = i),
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: a.placeholder
178
- }, null, 8, de), [
179
- [E, c.value]
143
+ placeholder: s.placeholder
144
+ }, null, 8, ne), [
145
+ [N, r.value]
180
146
  ]),
181
- r("button", {
147
+ i("button", {
182
148
  class: "chat-field__button",
183
- onClick: s[2] || (s[2] = (i) => t("sendMessage"))
149
+ onClick: t[2] || (t[2] = (l) => d("sendMessage"))
184
150
  }, [
185
- p(u(H))
151
+ _(u(x))
186
152
  ])
187
153
  ])
188
154
  ]));
189
155
  }
190
- }), re = { class: "bonus-summary" }, ye = /* @__PURE__ */ v({
156
+ }), de = { class: "bonus-summary" }, he = /* @__PURE__ */ p({
191
157
  __name: "BonusSummary",
192
- setup(e) {
193
- return (n, t) => (o(), m("div", re, [
194
- p(u(G), { class: "bonus-summary__icon" }),
195
- t[0] || (t[0] = r("div", { class: "bonus-summary__number" }, "123", -1))
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
- ye as BonusSummary,
201
- ge as ChatField
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
+ };