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