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 N, useEffect as T, useMemo as V } from "react";
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 _ } 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";
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, Q = D(
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: w,
23
- buttonText: z = "Выберите файлы",
22
+ titleUploader: b,
23
+ buttonText: w = "Выберите файлы",
24
24
  showOnlyUploadButton: u = !1,
25
- uploadButtonVariant: b = _.SecondaryAsphalt,
26
- buttonSize: I = "m"
27
- } = i, [l, n] = N(
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
- T(() => {
31
+ V(() => {
31
32
  a && n(a);
32
33
  }, [a]);
33
- const L = (t) => {
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 } = V(() => {
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
- O,
64
+ P,
64
65
  {
65
66
  filesType: x,
66
67
  arrayName: F,
67
68
  maxSize: U,
68
- onChangeValue: L,
69
+ onChangeValue: N,
69
70
  ref: v,
70
71
  maxFiles: m,
71
72
  isDisabled: d,
72
- titleUploader: w,
73
+ titleUploader: b,
73
74
  showOnlyUploadButton: u,
74
- buttonText: z,
75
- uploadButtonVariant: b,
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
- E,
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
- M,
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
- Q as UniversalUploader
103
+ W as UniversalUploader
102
104
  };
@@ -49,6 +49,10 @@ export type TUploader = {
49
49
  * Размер кнопки загрузки файла
50
50
  */
51
51
  buttonSize?: EButtonSize | `${EButtonSize}`;
52
+ /**
53
+ * Класс для кнопки
54
+ */
55
+ buttonClassName?: string;
52
56
  };
53
57
  export type TUploadValue = {
54
58
  value: TFileItem[];
@@ -1,8 +1,8 @@
1
- import { jsxs as a, jsx as n, Fragment as S } from "react/jsx-runtime";
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 C } from "../Button/constants.js";
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
- }, M = [
24
+ }, k = [
25
25
  "jpeg",
26
26
  "jpg",
27
27
  "png",
28
28
  "tiff",
29
29
  "gif",
30
30
  "heic"
31
- ], k = () => {
31
+ ], D = () => {
32
32
  let i = 0;
33
33
  return () => (i = (i + 1) % Number.MAX_SAFE_INTEGER, i);
34
- }, D = k(), H = U(
34
+ }, G = D(), J = U(
35
35
  (i, x) => {
36
36
  const {
37
- filesType: o = M,
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 = C.SecondaryAsphalt,
47
- buttonSize: v = "m"
48
- } = i, d = u(null), l = u(null), f = V(), I = (e) => {
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
- }, N = (e) => {
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 z = I(t), E = o.map((R) => g[R]).includes(z), F = t.size / 1024 ** 2 <= r;
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: D() }));
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
- }, T = () => {
60
+ }, z = () => {
60
61
  var e;
61
62
  (e = d.current) == null || e.click();
62
63
  };
63
- return /* @__PURE__ */ a("div", { className: p["upload-file-wrapper"], ref: x, children: [
64
- /* @__PURE__ */ n(
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: N,
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__ */ a("label", { htmlFor: f, ref: d, children: [
81
- /* @__PURE__ */ n(
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__ */ n(A, { iconName: "UnionIcon16px" }),
87
- onClick: T,
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__ */ a(S, { children: [
93
- c && /* @__PURE__ */ n("b", { children: c }),
94
- /* @__PURE__ */ a("span", { className: p["upload-text"], children: [
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__ */ n("br", {}),
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
- H as Uploader
110
+ J as Uploader
109
111
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.36.14",
4
+ "version": "1.36.15",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {