mimir-ui-kit 1.36.14 → 1.36.15
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,15 @@
|
|
1
1
|
import { jsxs as y, jsx as p, Fragment as j } from "react/jsx-runtime";
|
2
2
|
import { c as B } from "../../index-DIxK0V-G.js";
|
3
|
-
import { forwardRef as D, useState as
|
3
|
+
import { forwardRef as D, useState as T, useEffect as V, useMemo as _ } from "react";
|
4
4
|
import { imageTypes as h } from "./constants.js";
|
5
5
|
import "../Button/Button.js";
|
6
|
-
import { EButtonVariantDefault as
|
7
|
-
import { ListFiles as
|
8
|
-
import { ListPhotos as
|
9
|
-
import { Uploader as
|
6
|
+
import { EButtonVariantDefault as E } from "../Button/constants.js";
|
7
|
+
import { ListFiles as M } from "../ListFiles/ListFiles.js";
|
8
|
+
import { ListPhotos as O } from "../ListPhotos/ListPhotos.js";
|
9
|
+
import { Uploader as P } from "../Uploader/Uploader.js";
|
10
10
|
import '../../assets/UploaderPhotos.css';const g = {
|
11
11
|
"upload-file-wrapper": "_upload-file-wrapper_1a115_2"
|
12
|
-
}, f = (i) => "file" in i && i.file instanceof File ? h.includes(i.file.type) : "type" in i && typeof i.type == "string" ? h.includes(i.type) : !1,
|
12
|
+
}, f = (i) => "file" in i && i.file instanceof File ? h.includes(i.file.type) : "type" in i && typeof i.type == "string" ? h.includes(i.type) : !1, W = D(
|
13
13
|
(i, v) => {
|
14
14
|
const {
|
15
15
|
type: s,
|
@@ -19,18 +19,19 @@ import '../../assets/UploaderPhotos.css';const g = {
|
|
19
19
|
onChange: o,
|
20
20
|
value: a,
|
21
21
|
maxFiles: m,
|
22
|
-
titleUploader:
|
23
|
-
buttonText:
|
22
|
+
titleUploader: b,
|
23
|
+
buttonText: w = "Выберите файлы",
|
24
24
|
showOnlyUploadButton: u = !1,
|
25
|
-
uploadButtonVariant:
|
26
|
-
buttonSize: I = "m"
|
27
|
-
|
25
|
+
uploadButtonVariant: z = E.SecondaryAsphalt,
|
26
|
+
buttonSize: I = "m",
|
27
|
+
buttonClassName: L
|
28
|
+
} = i, [l, n] = T(
|
28
29
|
a || []
|
29
30
|
), d = l.length >= m;
|
30
|
-
|
31
|
+
V(() => {
|
31
32
|
a && n(a);
|
32
33
|
}, [a]);
|
33
|
-
const
|
34
|
+
const N = (t) => {
|
34
35
|
const r = t.value.map((e) => f(e.file) ? {
|
35
36
|
id: e.id,
|
36
37
|
url: URL.createObjectURL(e.file),
|
@@ -47,7 +48,7 @@ import '../../assets/UploaderPhotos.css';const g = {
|
|
47
48
|
n((e) => [...e, ...r]), o == null || o({ type: "add", data: t.value });
|
48
49
|
}, c = (t) => {
|
49
50
|
n((r) => r.filter((e) => e.id !== t)), o == null || o({ type: "delete", data: t });
|
50
|
-
}, { photos: R, files: S } =
|
51
|
+
}, { photos: R, files: S } = _(() => {
|
51
52
|
const t = () => l.filter((e) => !f(e)), r = () => l.filter(f);
|
52
53
|
return s === "all" ? { files: t(), photos: r() } : s === "files" ? { photos: [], files: t() } : s === "photos" ? { files: [], photos: r() } : { files: [], photos: [] };
|
53
54
|
}, [l, s]);
|
@@ -60,32 +61,33 @@ import '../../assets/UploaderPhotos.css';const g = {
|
|
60
61
|
),
|
61
62
|
children: [
|
62
63
|
/* @__PURE__ */ p(
|
63
|
-
|
64
|
+
P,
|
64
65
|
{
|
65
66
|
filesType: x,
|
66
67
|
arrayName: F,
|
67
68
|
maxSize: U,
|
68
|
-
onChangeValue:
|
69
|
+
onChangeValue: N,
|
69
70
|
ref: v,
|
70
71
|
maxFiles: m,
|
71
72
|
isDisabled: d,
|
72
|
-
titleUploader:
|
73
|
+
titleUploader: b,
|
73
74
|
showOnlyUploadButton: u,
|
74
|
-
buttonText:
|
75
|
-
uploadButtonVariant:
|
76
|
-
buttonSize: I
|
75
|
+
buttonText: w,
|
76
|
+
uploadButtonVariant: z,
|
77
|
+
buttonSize: I,
|
78
|
+
buttonClassName: L
|
77
79
|
}
|
78
80
|
),
|
79
81
|
!u && /* @__PURE__ */ y(j, { children: [
|
80
82
|
(s === "files" || s === "all") && /* @__PURE__ */ p(
|
81
|
-
|
83
|
+
M,
|
82
84
|
{
|
83
85
|
value: S,
|
84
86
|
onChange: (t) => c(t.deleteId)
|
85
87
|
}
|
86
88
|
),
|
87
89
|
(s === "photos" || s === "all") && /* @__PURE__ */ p(
|
88
|
-
|
90
|
+
O,
|
89
91
|
{
|
90
92
|
value: R,
|
91
93
|
onChange: (t) => c(t.deleteId)
|
@@ -98,5 +100,5 @@ import '../../assets/UploaderPhotos.css';const g = {
|
|
98
100
|
}
|
99
101
|
);
|
100
102
|
export {
|
101
|
-
|
103
|
+
W as UniversalUploader
|
102
104
|
};
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { jsxs as
|
1
|
+
import { jsxs as n, jsx as a, Fragment as S } from "react/jsx-runtime";
|
2
2
|
import { forwardRef as U, useRef as u, useId as V } from "react";
|
3
3
|
import { Icon as A } from "../../icons/Icon.js";
|
4
4
|
import { Button as B } from "../Button/Button.js";
|
5
|
-
import { EButtonVariantDefault as
|
5
|
+
import { EButtonVariantDefault as M } from "../Button/constants.js";
|
6
6
|
import '../../assets/Uploader.css';const p = {
|
7
7
|
"upload-file-wrapper": "_upload-file-wrapper_bplvw_2",
|
8
8
|
"upload-text": "_upload-text_bplvw_25",
|
@@ -21,20 +21,20 @@ import '../../assets/Uploader.css';const p = {
|
|
21
21
|
xls: "application/excel",
|
22
22
|
txt: "text/plain",
|
23
23
|
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
24
|
-
},
|
24
|
+
}, k = [
|
25
25
|
"jpeg",
|
26
26
|
"jpg",
|
27
27
|
"png",
|
28
28
|
"tiff",
|
29
29
|
"gif",
|
30
30
|
"heic"
|
31
|
-
],
|
31
|
+
], D = () => {
|
32
32
|
let i = 0;
|
33
33
|
return () => (i = (i + 1) % Number.MAX_SAFE_INTEGER, i);
|
34
|
-
},
|
34
|
+
}, G = D(), J = U(
|
35
35
|
(i, x) => {
|
36
36
|
const {
|
37
|
-
filesType: o =
|
37
|
+
filesType: o = k,
|
38
38
|
onChangeValue: h,
|
39
39
|
arrayName: b,
|
40
40
|
maxSize: r = 15,
|
@@ -43,25 +43,26 @@ import '../../assets/Uploader.css';const p = {
|
|
43
43
|
titleUploader: c = "Или перетащите сюда",
|
44
44
|
buttonText: y = "Выберите файлы",
|
45
45
|
showOnlyUploadButton: _ = !1,
|
46
|
-
uploadButtonVariant: j =
|
47
|
-
buttonSize: v = "m"
|
48
|
-
|
46
|
+
uploadButtonVariant: j = M.SecondaryAsphalt,
|
47
|
+
buttonSize: v = "m",
|
48
|
+
buttonClassName: I
|
49
|
+
} = i, d = u(null), l = u(null), f = V(), N = (e) => {
|
49
50
|
var t;
|
50
51
|
return e.type ? e.type : ((t = e.name.split(".").pop()) == null ? void 0 : t.toLowerCase()) === "heic" ? "image/heic" : "";
|
51
|
-
},
|
52
|
+
}, T = (e) => {
|
52
53
|
if (e.target.files && e.target.files[0]) {
|
53
54
|
const m = Array.from(e.target.files).filter((t) => {
|
54
|
-
const
|
55
|
+
const C = N(t), E = o.map((R) => g[R]).includes(C), F = t.size / 1024 ** 2 <= r;
|
55
56
|
return E && F;
|
56
|
-
}).slice(0, w).map((t) => ({ file: t, id:
|
57
|
+
}).slice(0, w).map((t) => ({ file: t, id: G() }));
|
57
58
|
h({ arrayName: b, value: m }), l.current && (l.current.value = "");
|
58
59
|
}
|
59
|
-
},
|
60
|
+
}, z = () => {
|
60
61
|
var e;
|
61
62
|
(e = d.current) == null || e.click();
|
62
63
|
};
|
63
|
-
return /* @__PURE__ */
|
64
|
-
/* @__PURE__ */
|
64
|
+
return /* @__PURE__ */ n("div", { className: p["upload-file-wrapper"], ref: x, children: [
|
65
|
+
/* @__PURE__ */ a(
|
65
66
|
"input",
|
66
67
|
{
|
67
68
|
ref: l,
|
@@ -70,32 +71,33 @@ import '../../assets/Uploader.css';const p = {
|
|
70
71
|
"aria-label": "Upload",
|
71
72
|
name: "image[]",
|
72
73
|
multiple: !0,
|
73
|
-
onChange:
|
74
|
+
onChange: T,
|
74
75
|
title: "",
|
75
76
|
id: f,
|
76
77
|
accept: o.map((e) => g[e]).join(),
|
77
78
|
disabled: s
|
78
79
|
}
|
79
80
|
),
|
80
|
-
/* @__PURE__ */
|
81
|
-
/* @__PURE__ */
|
81
|
+
/* @__PURE__ */ n("label", { htmlFor: f, ref: d, children: [
|
82
|
+
/* @__PURE__ */ a(
|
82
83
|
B,
|
83
84
|
{
|
84
85
|
size: v,
|
85
86
|
variant: j,
|
86
|
-
leftIcon: /* @__PURE__ */
|
87
|
-
onClick:
|
87
|
+
leftIcon: /* @__PURE__ */ a(A, { iconName: "UnionIcon16px" }),
|
88
|
+
onClick: z,
|
88
89
|
disabled: s,
|
90
|
+
className: I,
|
89
91
|
children: y
|
90
92
|
}
|
91
93
|
),
|
92
|
-
!_ && /* @__PURE__ */
|
93
|
-
c && /* @__PURE__ */
|
94
|
-
/* @__PURE__ */
|
94
|
+
!_ && /* @__PURE__ */ n(S, { children: [
|
95
|
+
c && /* @__PURE__ */ a("b", { children: c }),
|
96
|
+
/* @__PURE__ */ n("span", { className: p["upload-text"], children: [
|
95
97
|
"Максимальный размер одного файла – ",
|
96
98
|
r,
|
97
99
|
" Мб",
|
98
|
-
/* @__PURE__ */
|
100
|
+
/* @__PURE__ */ a("br", {}),
|
99
101
|
"Загрузить можно файлы следующих форматов: ",
|
100
102
|
o.join(", ")
|
101
103
|
] })
|
@@ -105,5 +107,5 @@ import '../../assets/Uploader.css';const p = {
|
|
105
107
|
}
|
106
108
|
);
|
107
109
|
export {
|
108
|
-
|
110
|
+
J as Uploader
|
109
111
|
};
|