prlg-ui 1.7.42 → 1.7.43

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.
@@ -3,30 +3,30 @@
3
3
  * Возвращает 'image' для изображений, 'pdf' для PDF-файлов,
4
4
  * 'word' для документов Word, 'excel' для файлов Excel,
5
5
  * иначе 'other'.
6
- *
6
+ *
7
7
  * @param {string} mimeType - MIME-тип файла
8
8
  * @returns {'image' | 'pdf' | 'word' | 'excel' | 'other'}
9
9
  */
10
10
  export function getFileTypeByMime(
11
- mimeType: string
11
+ mimeType: string
12
12
  ): 'image' | 'pdf' | 'word' | 'excel' | 'other' {
13
- if (mimeType.startsWith('image/')) {
14
- return 'image';
15
- }
16
- if (mimeType === 'application/pdf') {
17
- return 'pdf';
18
- }
19
- if (
20
- mimeType === 'application/msword' ||
21
- mimeType === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
22
- ) {
23
- return 'word';
24
- }
25
- if (
26
- mimeType === 'application/vnd.ms-excel' ||
27
- mimeType === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
28
- ) {
29
- return 'excel';
30
- }
31
- return 'other';
13
+ if (mimeType.startsWith('image/')) {
14
+ return 'image';
15
+ }
16
+ if (mimeType === 'application/pdf') {
17
+ return 'pdf';
18
+ }
19
+ if (
20
+ mimeType === 'application/msword' ||
21
+ mimeType === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
22
+ ) {
23
+ return 'word';
24
+ }
25
+ if (
26
+ mimeType === 'application/vnd.ms-excel' ||
27
+ mimeType === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
28
+ ) {
29
+ return 'excel';
30
+ }
31
+ return 'other';
32
32
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prlg-ui",
3
3
  "private": false,
4
- "version": "1.7.42",
4
+ "version": "1.7.43",
5
5
  "type": "module",
6
6
  "main": "dist/prlg-ui.umd.js",
7
7
  "module": "dist/prlg-ui.es.js",
@@ -1,182 +0,0 @@
1
- import { defineComponent as F, ref as $, computed as w, onMounted as I, createElementBlock as d, openBlock as u, normalizeClass as k, createCommentVNode as v, createBlock as b, createElementVNode as n, createVNode as y, unref as g, resolveDynamicComponent as B, toDisplayString as p, Teleport as M, Transition as x, withCtx as j, useTemplateRef as E, Fragment as L } from "vue";
2
- import { F as N, E as V, W as R, P as W, C, _ as h, a as O } from "./FileIcon-DkEbi-bi.js";
3
- const se = (e) => {
4
- const r = ["b", "kb", "mb", "gb", "tb"], l = e.match(/[a-zA-Z]+/)?.[0] || "b", t = parseFloat(e.replace(l, "")), o = r.indexOf(l.toLowerCase());
5
- return t * Math.pow(1024, o);
6
- };
7
- function z(e) {
8
- if (isNaN(e) || e < 0) return "0 Б";
9
- const r = ["Б", "КБ", "МБ", "ГБ", "ТБ"];
10
- let l = 0, t = e;
11
- for (; t >= 1024 && l < r.length - 1; )
12
- t = t / 1024, l++;
13
- return `${t % 1 === 0 ? t : t.toFixed(1)} ${r[l]}`;
14
- }
15
- function D(e) {
16
- return e.startsWith("image/") ? "image" : e === "application/pdf" ? "pdf" : e === "application/msword" || e === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ? "word" : e === "application/vnd.ms-excel" || e === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ? "excel" : "other";
17
- }
18
- const P = {
19
- key: 1,
20
- class: "file__title"
21
- }, U = { class: "file__info" }, A = { class: "file__type" }, Z = { class: "file__size" }, q = /* @__PURE__ */ F({
22
- __name: "File",
23
- props: {
24
- file: {},
25
- viewName: { type: Boolean, default: !1 },
26
- outlined: { type: Boolean, default: !0 },
27
- removable: { type: Boolean }
28
- },
29
- emits: ["remove"],
30
- setup(e, { emit: r }) {
31
- const l = r, t = $(null);
32
- async function o(a, i = "image") {
33
- const f = await (await fetch(a)).blob(), _ = f.type.split("/")[1] || "", S = _ ? `${i}.${_}` : i;
34
- return new File([f], S, { type: f.type });
35
- }
36
- const c = w(() => t.value ? D(t.value.type) : ""), s = w(() => {
37
- switch (c.value) {
38
- case "pdf":
39
- return W;
40
- case "word":
41
- return R;
42
- case "excel":
43
- return V;
44
- case "other":
45
- return N;
46
- default:
47
- return null;
48
- }
49
- });
50
- return I(async () => {
51
- t.value = typeof e.file == "string" ? await o(e.file) : e.file;
52
- }), (a, i) => (u(), d("div", {
53
- class: k(["file", { "file--outlined": a.outlined }])
54
- }, [
55
- a.removable && typeof a.file != "string" ? (u(), d("button", {
56
- key: 0,
57
- class: "file__remove",
58
- onClick: i[0] || (i[0] = (m) => l("remove", a.file))
59
- }, [
60
- y(g(C))
61
- ])) : v("", !0),
62
- (u(), b(B(s.value), { class: "file__icon" })),
63
- a.viewName ? (u(), d("div", P, p(t.value ? t.value.name.split(".")[0] : "unknown"), 1)) : v("", !0),
64
- n("div", U, [
65
- n("div", A, p(c.value), 1),
66
- i[1] || (i[1] = n("div", { class: "file__info-separator" }, null, -1)),
67
- n("div", Z, p(t.value ? g(z)(t.value.size) : "0 Б"), 1)
68
- ])
69
- ], 2));
70
- }
71
- }), ie = /* @__PURE__ */ h(q, [["__scopeId", "data-v-c33ea2a8"]]), G = {
72
- key: 0,
73
- class: "image-full-modal"
74
- }, H = { class: "image-full-modal__wrapper" }, J = { class: "image-full-modal__header" }, K = { class: "image-full-modal__main" }, Q = ["src", "alt"], T = /* @__PURE__ */ F({
75
- __name: "ImageFullModal",
76
- props: {
77
- src: {},
78
- alt: {}
79
- },
80
- setup(e, { expose: r }) {
81
- const l = $(!1);
82
- return r({
83
- open: () => {
84
- l.value = !0;
85
- },
86
- close: () => {
87
- l.value = !1;
88
- }
89
- }), (t, o) => (u(), b(M, { to: "body" }, [
90
- y(x, { name: "fade" }, {
91
- default: j(() => [
92
- l.value ? (u(), d("div", G, [
93
- n("div", {
94
- class: "image-full-modal__overlay",
95
- onClick: o[0] || (o[0] = (c) => l.value = !1)
96
- }),
97
- n("div", H, [
98
- n("div", J, [
99
- n("button", {
100
- class: "image-full-modal__close",
101
- onClick: o[1] || (o[1] = (c) => l.value = !1)
102
- }, [
103
- y(g(C))
104
- ])
105
- ]),
106
- n("div", K, [
107
- n("img", {
108
- src: t.src,
109
- alt: t.alt
110
- }, null, 8, Q)
111
- ]),
112
- o[2] || (o[2] = n("div", { class: "image-full-modal__footer" }, null, -1))
113
- ])
114
- ])) : v("", !0)
115
- ]),
116
- _: 1
117
- })
118
- ]));
119
- }
120
- }), X = /* @__PURE__ */ h(T, [["__scopeId", "data-v-edc1a47e"]]), Y = ["src", "alt"], ee = { class: "image__info" }, te = { class: "image__type" }, le = { class: "image__size" }, ae = /* @__PURE__ */ F({
121
- __name: "Image",
122
- props: {
123
- file: {},
124
- alt: {},
125
- size: { default: "medium" },
126
- fullScreen: { type: Boolean }
127
- },
128
- setup(e) {
129
- const r = E("imageFullModal"), l = $(null);
130
- async function t(s, a = "image") {
131
- const m = await (await fetch(s)).blob(), f = m.type.split("/")[1] || "", _ = f ? `${a}.${f}` : a;
132
- return new File([m], _, { type: m.type });
133
- }
134
- const o = w(() => typeof e.file == "string" ? e.file : URL.createObjectURL(e.file));
135
- function c(s) {
136
- if (s.startsWith("image/"))
137
- return s.replace("image/", "").toLowerCase();
138
- const a = s.match(/\.(jpeg|jpg|png|gif|webp|bmp|svg|tiff|ico)(\?.*)?$/i);
139
- if (a) {
140
- let i = a[1].toLowerCase();
141
- return i === "jpg" && (i = "jpeg"), i;
142
- }
143
- return "unknown";
144
- }
145
- return I(async () => {
146
- l.value = typeof e.file == "string" ? await t(e.file) : e.file;
147
- }), (s, a) => (u(), d(L, null, [
148
- n("div", {
149
- class: k(["image", `image--${s.size}`, { "image--full-screen": s.fullScreen }])
150
- }, [
151
- s.fullScreen ? (u(), d("div", {
152
- key: 0,
153
- class: "image__overlay",
154
- onClick: a[0] || (a[0] = (i) => r.value?.open())
155
- }, [
156
- y(g(O))
157
- ])) : v("", !0),
158
- n("img", {
159
- src: o.value,
160
- alt: s.alt
161
- }, null, 8, Y),
162
- n("div", ee, [
163
- n("div", te, p(l.value ? c(l.value.type) : "unknown"), 1),
164
- a[1] || (a[1] = n("div", { class: "image__info-separator" }, null, -1)),
165
- n("div", le, p(l.value ? g(z)(l.value.size) : "0 Б"), 1)
166
- ])
167
- ], 2),
168
- s.fullScreen ? (u(), b(X, {
169
- key: 0,
170
- ref: "imageFullModal",
171
- src: o.value,
172
- alt: s.alt
173
- }, null, 8, ["src", "alt"])) : v("", !0)
174
- ], 64));
175
- }
176
- }), re = /* @__PURE__ */ h(ae, [["__scopeId", "data-v-00bc3295"]]);
177
- export {
178
- ie as F,
179
- re as I,
180
- D as g,
181
- se as p
182
- };
@@ -1 +0,0 @@
1
- "use strict";const e=require("vue"),c=require("./FileIcon-sxADkCIe.cjs"),_=t=>{const r=["b","kb","mb","gb","tb"],o=t.match(/[a-zA-Z]+/)?.[0]||"b",l=parseFloat(t.replace(o,"")),a=r.indexOf(o.toLowerCase());return l*Math.pow(1024,a)};function p(t){if(isNaN(t)||t<0)return"0 Б";const r=["Б","КБ","МБ","ГБ","ТБ"];let o=0,l=t;for(;l>=1024&&o<r.length-1;)l=l/1024,o++;return`${l%1===0?l:l.toFixed(1)} ${r[o]}`}function v(t){return t.startsWith("image/")?"image":t==="application/pdf"?"pdf":t==="application/msword"||t==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?"word":t==="application/vnd.ms-excel"||t==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"?"excel":"other"}const y={key:1,class:"file__title"},k={class:"file__info"},N={class:"file__type"},V={class:"file__size"},w=e.defineComponent({__name:"File",props:{file:{},viewName:{type:Boolean,default:!1},outlined:{type:Boolean,default:!0},removable:{type:Boolean}},emits:["remove"],setup(t,{emit:r}){const o=r,l=e.ref(null);async function a(n,s="image"){const d=await(await fetch(n)).blob(),f=d.type.split("/")[1]||"",g=f?`${s}.${f}`:s;return new File([d],g,{type:d.type})}const u=e.computed(()=>l.value?v(l.value.type):""),i=e.computed(()=>{switch(u.value){case"pdf":return c.PdfIcon;case"word":return c.WordIcon;case"excel":return c.ExcelIcon;case"other":return c.FileIcon;default:return null}});return e.onMounted(async()=>{l.value=typeof t.file=="string"?await a(t.file):t.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]=m=>o("remove",n.file))},[e.createVNode(e.unref(c.CloseIcon))])):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.value),{class:"file__icon"})),n.viewName?(e.openBlock(),e.createElementBlock("div",y,e.toDisplayString(l.value?l.value.name.split(".")[0]:"unknown"),1)):e.createCommentVNode("",!0),e.createElementVNode("div",k,[e.createElementVNode("div",N,e.toDisplayString(u.value),1),s[1]||(s[1]=e.createElementVNode("div",{class:"file__info-separator"},null,-1)),e.createElementVNode("div",V,e.toDisplayString(l.value?e.unref(p)(l.value.size):"0 Б"),1)])],2))}}),E=c._export_sfc(w,[["__scopeId","data-v-c33ea2a8"]]),F={key:0,class:"image-full-modal"},B={class:"image-full-modal__wrapper"},$={class:"image-full-modal__header"},b={class:"image-full-modal__main"},C=["src","alt"],h=e.defineComponent({__name:"ImageFullModal",props:{src:{},alt:{}},setup(t,{expose:r}){const o=e.ref(!1);return r({open:()=>{o.value=!0},close:()=>{o.value=!1}}),(l,a)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[o.value?(e.openBlock(),e.createElementBlock("div",F,[e.createElementVNode("div",{class:"image-full-modal__overlay",onClick:a[0]||(a[0]=u=>o.value=!1)}),e.createElementVNode("div",B,[e.createElementVNode("div",$,[e.createElementVNode("button",{class:"image-full-modal__close",onClick:a[1]||(a[1]=u=>o.value=!1)},[e.createVNode(e.unref(c.CloseIcon))])]),e.createElementVNode("div",b,[e.createElementVNode("img",{src:l.src,alt:l.alt},null,8,C)]),a[2]||(a[2]=e.createElementVNode("div",{class:"image-full-modal__footer"},null,-1))])])):e.createCommentVNode("",!0)]),_:1})]))}}),I=c._export_sfc(h,[["__scopeId","data-v-edc1a47e"]]),S=["src","alt"],z={class:"image__info"},M={class:"image__type"},x={class:"image__size"},D=e.defineComponent({__name:"Image",props:{file:{},alt:{},size:{default:"medium"},fullScreen:{type:Boolean}},setup(t){const r=e.useTemplateRef("imageFullModal"),o=e.ref(null);async function l(i,n="image"){const m=await(await fetch(i)).blob(),d=m.type.split("/")[1]||"",f=d?`${n}.${d}`:n;return new File([m],f,{type:m.type})}const a=e.computed(()=>typeof t.file=="string"?t.file:URL.createObjectURL(t.file));function u(i){if(i.startsWith("image/"))return i.replace("image/","").toLowerCase();const n=i.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()=>{o.value=typeof t.file=="string"?await l(t.file):t.file}),(i,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["image",`image--${i.size}`,{"image--full-screen":i.fullScreen}])},[i.fullScreen?(e.openBlock(),e.createElementBlock("div",{key:0,class:"image__overlay",onClick:n[0]||(n[0]=s=>r.value?.open())},[e.createVNode(e.unref(c.EyeIcon))])):e.createCommentVNode("",!0),e.createElementVNode("img",{src:a.value,alt:i.alt},null,8,S),e.createElementVNode("div",z,[e.createElementVNode("div",M,e.toDisplayString(o.value?u(o.value.type):"unknown"),1),n[1]||(n[1]=e.createElementVNode("div",{class:"image__info-separator"},null,-1)),e.createElementVNode("div",x,e.toDisplayString(o.value?e.unref(p)(o.value.size):"0 Б"),1)])],2),i.fullScreen?(e.openBlock(),e.createBlock(I,{key:0,ref:"imageFullModal",src:a.value,alt:i.alt},null,8,["src","alt"])):e.createCommentVNode("",!0)],64))}}),j=c._export_sfc(D,[["__scopeId","data-v-00bc3295"]]);exports.File=E;exports.Image=j;exports.getFileTypeByMime=v;exports.parseFileSize=_;