mimir-ui-kit 1.63.0 → 1.64.1

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,24 +1,25 @@
1
- import { jsxs as b, jsx as c } from "react/jsx-runtime";
2
- import { c as j } from "../../index-DIxK0V-G.js";
3
- import { useState as z } from "react";
4
- import { useDatePickerPosition as I } from "./hooks.js";
5
- import { c as n } from "../../styles.module-DeBRSK_x.js";
6
- import { formating as F } from "../../utils/index.js";
7
- import { Button as P } from "../Button/Button.js";
8
- const p = 15, C = 7, X = ({
9
- date: v,
1
+ import { jsxs as P, jsx as c } from "react/jsx-runtime";
2
+ import { c as v } from "../../index-DIxK0V-G.js";
3
+ import { useState as I } from "react";
4
+ import { useDatePickerPosition as C } from "./hooks.js";
5
+ import { c as r } from "../../styles.module-DjQdoVeY.js";
6
+ import { formating as E } from "../../utils/index.js";
7
+ import { Button as F } from "../Button/Button.js";
8
+ const p = 15, L = 7, Z = ({
9
+ date: S,
10
10
  selectedDate: u,
11
- onChangeValue: E,
11
+ onChangeValue: _,
12
12
  before: Y,
13
13
  onChangeType: d,
14
14
  onChangeYear: N,
15
- disableFuture: S = !1,
16
- disablePast: _ = !1,
15
+ disableFuture: y = !1,
16
+ disablePast: G = !1,
17
17
  disabledDate: o,
18
18
  validRange: k,
19
- position: y
19
+ position: M,
20
+ isFixed: h
20
21
  }) => {
21
- const G = I(y), i = new Date(v), l = u ? new Date(u) : i, M = {
22
+ const Q = C(M, h), i = new Date(S), l = u ? new Date(u) : i, B = {
22
23
  y: l.getFullYear(),
23
24
  d: l.getDate(),
24
25
  m: l.getMonth() + 1
@@ -26,93 +27,100 @@ const p = 15, C = 7, X = ({
26
27
  y: i.getFullYear(),
27
28
  d: i.getDate(),
28
29
  m: i.getMonth() + 1
29
- }, [D, h] = z(e.y), Q = D - C, B = Array.from(Array(p).keys()).map(
30
- (t) => t + Q
31
- ), H = () => {
32
- h(D + p);
33
- }, R = () => {
34
- h(D - p);
35
- }, g = (t) => {
30
+ }, [D, g] = I(e.y), H = D - L, R = Array.from(Array(p).keys()).map(
31
+ (t) => t + H
32
+ ), $ = () => {
33
+ g(D + p);
34
+ }, j = () => {
35
+ g(D - p);
36
+ }, x = (t) => {
36
37
  const s = (/* @__PURE__ */ new Date()).getFullYear();
37
38
  if (k) {
38
39
  const [a, w] = k;
39
- let r;
40
+ let n;
40
41
  if (e.m && e.d)
41
- r = new Date(t, e.m - 1, e.d);
42
+ n = new Date(t, e.m - 1, e.d);
42
43
  else {
43
- const A = /* @__PURE__ */ new Date();
44
- r = new Date(t, A.getMonth(), A.getDate());
44
+ const b = /* @__PURE__ */ new Date();
45
+ n = new Date(t, b.getMonth(), b.getDate());
45
46
  }
46
- r.setHours(0, 0, 0, 0);
47
+ n.setHours(0, 0, 0, 0);
47
48
  const m = new Date(a), f = new Date(w);
48
- if (m.setHours(0, 0, 0, 0), f.setHours(23, 59, 59, 999), r < m || r > f)
49
+ if (m.setHours(0, 0, 0, 0), f.setHours(23, 59, 59, 999), n < m || n > f)
49
50
  return !0;
50
51
  }
51
- if (Y && Y.getFullYear() > t || S && t > s || _ && t < s)
52
+ if (Y && Y.getFullYear() > t || y && t > s || G && t < s)
52
53
  return !0;
53
54
  if (o) {
54
55
  const a = new Date(t, e.m - 1, e.d);
55
56
  if (!o(a)) return !1;
56
- const w = new Date(t, 2, 15), r = new Date(t, 5, 15), m = new Date(t, 8, 15), f = new Date(t, 11, 15);
57
- return o(w) && o(r) && o(m) && o(f);
57
+ const w = new Date(t, 2, 15), n = new Date(t, 5, 15), m = new Date(t, 8, 15), f = new Date(t, 11, 15);
58
+ return o(w) && o(n) && o(m) && o(f);
58
59
  }
59
60
  return !1;
60
- }, $ = (t) => {
61
- g(t) || (N ? N(t) : E(
61
+ }, z = (t) => {
62
+ x(t) || (N ? N(t) : _(
62
63
  /* @__PURE__ */ new Date(
63
- `${t}-${F.Number(2, e.m)}-${F.Number(2, e.d)}`
64
+ `${t}-${E.Number(2, e.m)}-${E.Number(2, e.d)}`
64
65
  )
65
66
  ));
66
67
  };
67
- return /* @__PURE__ */ b("div", { className: n["calendar-block"], ref: G, children: [
68
- /* @__PURE__ */ b("div", { className: n.h, children: [
69
- /* @__PURE__ */ c(
70
- P,
71
- {
72
- isIconButton: !0,
73
- iconName: "DropdownArrowLeft16px",
74
- onClick: R,
75
- variant: "secondary-gray",
76
- size: "l"
77
- }
78
- ),
79
- /* @__PURE__ */ c(
80
- "button",
81
- {
82
- type: "button",
83
- onClick: () => d == null ? void 0 : d("years"),
84
- className: n.d
85
- }
86
- ),
87
- /* @__PURE__ */ c(
88
- P,
89
- {
90
- isIconButton: !0,
91
- iconName: "DropdownArrowRight16px",
92
- onClick: H,
93
- variant: "secondary-gray",
94
- size: "l"
95
- }
96
- )
97
- ] }),
98
- /* @__PURE__ */ c("div", { className: n.monthGrid, "data-testid": "year-picker", children: B.map((t, x) => {
99
- const s = g(t);
100
- return /* @__PURE__ */ c(
101
- "button",
102
- {
103
- type: "button",
104
- onClick: () => $(t),
105
- disabled: s,
106
- className: j(s ? n.m : n.a, {
107
- [n.current]: u && M.y === t
108
- }),
109
- children: t
110
- },
111
- x
112
- );
113
- }) })
114
- ] });
68
+ return /* @__PURE__ */ P(
69
+ "div",
70
+ {
71
+ className: v(r["calendar-block"], h && r.fixed),
72
+ ref: Q,
73
+ children: [
74
+ /* @__PURE__ */ P("div", { className: r.h, children: [
75
+ /* @__PURE__ */ c(
76
+ F,
77
+ {
78
+ isIconButton: !0,
79
+ iconName: "DropdownArrowLeft16px",
80
+ onClick: j,
81
+ variant: "secondary-gray",
82
+ size: "l"
83
+ }
84
+ ),
85
+ /* @__PURE__ */ c(
86
+ "button",
87
+ {
88
+ type: "button",
89
+ onClick: () => d == null ? void 0 : d("years"),
90
+ className: r.d
91
+ }
92
+ ),
93
+ /* @__PURE__ */ c(
94
+ F,
95
+ {
96
+ isIconButton: !0,
97
+ iconName: "DropdownArrowRight16px",
98
+ onClick: $,
99
+ variant: "secondary-gray",
100
+ size: "l"
101
+ }
102
+ )
103
+ ] }),
104
+ /* @__PURE__ */ c("div", { className: r.monthGrid, "data-testid": "year-picker", children: R.map((t, A) => {
105
+ const s = x(t);
106
+ return /* @__PURE__ */ c(
107
+ "button",
108
+ {
109
+ type: "button",
110
+ onClick: () => z(t),
111
+ disabled: s,
112
+ className: v(s ? r.m : r.a, {
113
+ [r.current]: u && B.y === t
114
+ }),
115
+ children: t
116
+ },
117
+ A
118
+ );
119
+ }) })
120
+ ]
121
+ }
122
+ );
115
123
  };
116
124
  export {
117
- X as YearPickerModal
125
+ Z as YearPickerModal
118
126
  };
@@ -1,3 +1,3 @@
1
1
  import { DependencyList } from 'react';
2
2
 
3
- export declare const useDatePickerPosition: (position?: "center" | "bottom" | "top", deps?: DependencyList) => import('react').RefObject<HTMLDivElement>;
3
+ export declare const useDatePickerPosition: (position?: "center" | "bottom" | "top", isFixed?: boolean, deps?: DependencyList) => import('react').RefObject<HTMLDivElement>;
@@ -1,35 +1,35 @@
1
- import { useRef as d, useEffect as h } from "react";
2
- import { BLOCK_WIDTH as l, MAX_MOBILE_WIDTH as w } from "./constants.js";
3
- const H = (i, a) => {
4
- const f = d(null);
5
- return h(() => {
6
- var c, r, y;
7
- const x = window.innerHeight, p = window.innerWidth, t = f.current;
1
+ import { useRef as w, useEffect as d } from "react";
2
+ import { BLOCK_WIDTH as p, MAX_MOBILE_WIDTH as m } from "./constants.js";
3
+ const W = (n, i, x) => {
4
+ const f = w(null);
5
+ return d(() => {
6
+ var c, r, a;
7
+ const u = window.innerHeight, y = window.innerWidth, t = f.current;
8
8
  if (t && t !== null) {
9
- const u = ((c = t == null ? void 0 : t.parentElement) == null ? void 0 : c.offsetWidth) ?? 0, s = ((r = t == null ? void 0 : t.parentElement) == null ? void 0 : r.offsetHeight) ?? 0, o = (y = t == null ? void 0 : t.parentElement) == null ? void 0 : y.getBoundingClientRect(), e = t.offsetHeight;
10
- if (i) {
11
- if (i === "center") {
12
- t.style.position = "fixed", t.style.top = `calc(50vh - ${e / 2}px)`, t.style.left = `calc(50vw - ${l / 2}px)`, t.style.opacity = "1";
9
+ const h = ((c = t == null ? void 0 : t.parentElement) == null ? void 0 : c.offsetWidth) ?? 0, l = ((r = t == null ? void 0 : t.parentElement) == null ? void 0 : r.offsetHeight) ?? 0, e = (a = t == null ? void 0 : t.parentElement) == null ? void 0 : a.getBoundingClientRect(), s = t.offsetHeight;
10
+ if (n) {
11
+ if (n === "center") {
12
+ t.style.position = "fixed", t.style.top = `calc(50vh - ${s / 2}px)`, t.style.left = `calc(50vw - ${p / 2}px)`, t.style.opacity = "1";
13
13
  return;
14
14
  }
15
- if (i === "bottom") {
16
- t.style.top = s + "px", t.style.opacity = "1";
15
+ if (n === "bottom") {
16
+ t.style.top = l + "px", t.style.opacity = "1";
17
17
  return;
18
18
  }
19
- if (i === "top") {
20
- t.style.top = -e + "px", t.style.opacity = "1";
19
+ if (n === "top") {
20
+ t.style.top = -s + "px", t.style.opacity = "1";
21
21
  return;
22
22
  }
23
23
  } else {
24
- if (p < o.x + l) {
25
- const n = u - l;
26
- o.x - Math.abs(n) < 0 ? t.style.left = (n < 0 ? n / 2 : n) + "px" : t.style.left = n + "px";
24
+ if (y < e.x + p) {
25
+ const o = h - p;
26
+ e.x - Math.abs(o) < 0 ? t.style.left = (o < 0 ? o / 2 : o) + "px" : t.style.left = o + "px";
27
27
  }
28
- x < o.y + e + s ? o.y - e > 0 ? t.style.top = -e + "px" : p > w ? t.style.top = s + "px" : (t.style.position = "fixed", t.style.top = `calc(50vh - ${e / 2}px)`, t.style.left = `calc(50vw - ${l / 2}px)`) : t.style.top = s + "px", t.style.opacity = "1";
28
+ u < e.y + s + l ? e.y - s > 0 ? i ? t.style.top = e.y - s + "px" : t.style.top = -s + "px" : y > m ? i ? t.style.top = e.y + l + "px" : t.style.top = l + "px" : (t.style.position = "fixed", t.style.top = `calc(50vh - ${s / 2}px)`, t.style.left = `calc(50vw - ${p / 2}px)`) : i ? t.style.top = e.y + l + "px" : t.style.top = l + "px", t.style.opacity = "1";
29
29
  }
30
30
  }
31
- }, [a, i]), f;
31
+ }, [x, n, i]), f;
32
32
  };
33
33
  export {
34
- H as useDatePickerPosition
34
+ W as useDatePickerPosition
35
35
  };
@@ -1,56 +1,56 @@
1
- import { jsxs as F, jsx as n, Fragment as k } from "react/jsx-runtime";
1
+ import { jsxs as x, jsx as p, Fragment as k } from "react/jsx-runtime";
2
2
  import { c as q } from "../../index-DIxK0V-G.js";
3
3
  import { forwardRef as G, useState as H, useEffect as J, useMemo as K } from "react";
4
- import { imageTypes as g } from "./constants.js";
5
4
  import "../Button/Button.js";
6
5
  import { EButtonVariantDefault as Q } from "../Button/constants.js";
7
6
  import { ListFiles as W } from "../ListFiles/ListFiles.js";
8
7
  import { EFileItemVariant as X } from "../ListFiles/constants.js";
9
8
  import { ListPhotos as Y } from "../ListPhotos/ListPhotos.js";
10
9
  import { Uploader as Z } from "../Uploader/Uploader.js";
11
- import '../../assets/UploaderPhotos.css';const w = {
10
+ import '../../assets/UploaderPhotos.css';const g = {
12
11
  "upload-file-wrapper": "_upload-file-wrapper_1a115_2"
13
- }, c = (r) => "file" in r && r.file instanceof File ? g.includes(r.file.type) : "type" in r && typeof r.type == "string" ? g.includes(r.type) : !1, le = G(
14
- (r, x) => {
12
+ }, y = (r, d) => "file" in r && r.file instanceof File ? d.includes(r.file.type) : "type" in r && typeof r.type == "string" ? d.includes(r.type) : !1, le = G(
13
+ (r, d) => {
15
14
  const {
16
15
  type: s,
17
- filesType: z,
18
- arrayName: P,
19
- maxSize: U,
20
- onChange: o,
21
- value: p,
22
- maxFiles: d,
23
- titleUploader: b,
24
- buttonText: D = "Выберите файлы",
25
- showOnlyUploadButton: h = !1,
26
- uploadButtonVariant: E = Q.SecondaryAsphalt,
27
- buttonSize: S = "m",
28
- buttonClassName: V,
29
- variantListFiles: L = X.white,
30
- onMaxFilesExceeded: N,
31
- onMaxSizeExceeded: B,
32
- onInvalidFileType: _,
33
- loadImage: j,
34
- isDownloadingImage: A,
35
- dataTestIdReactMap: i
36
- } = r, [a, m] = H(
37
- p || []
38
- ), y = !!d && a.length >= d;
16
+ filesType: a,
17
+ arrayName: z,
18
+ maxSize: P,
19
+ onChange: l,
20
+ value: f,
21
+ maxFiles: m,
22
+ titleUploader: U,
23
+ buttonText: b = "Выберите файлы",
24
+ showOnlyUploadButton: v = !1,
25
+ uploadButtonVariant: D = Q.SecondaryAsphalt,
26
+ buttonSize: E = "m",
27
+ buttonClassName: S,
28
+ variantListFiles: V = X.white,
29
+ onMaxFilesExceeded: L,
30
+ onMaxSizeExceeded: N,
31
+ onInvalidFileType: B,
32
+ loadImage: _,
33
+ isDownloadingImage: j,
34
+ dataTestIdReactMap: t,
35
+ accept: A
36
+ } = r, [n, u] = H(
37
+ f || []
38
+ ), F = !!m && n.length >= m;
39
39
  J(() => {
40
- p && m(p);
41
- }, [p]);
42
- const C = (t) => {
43
- const l = t.value.map((e) => c(e.file) ? new Promise((f) => {
44
- const u = new FileReader();
45
- u.onload = () => {
46
- f({
40
+ f && u(f);
41
+ }, [f]);
42
+ const C = (i) => {
43
+ const o = i.value.map((e) => y(e.file, a) ? new Promise((c) => {
44
+ const h = new FileReader();
45
+ h.onload = () => {
46
+ c({
47
47
  id: e.id,
48
- url: u.result,
48
+ url: h.result,
49
49
  type: e.file.type,
50
50
  name: e.file.name,
51
51
  size: e.file.size
52
52
  });
53
- }, u.readAsDataURL(e.file);
53
+ }, h.readAsDataURL(e.file);
54
54
  }) : Promise.resolve({
55
55
  id: e.id,
56
56
  url: "",
@@ -58,63 +58,64 @@ import '../../assets/UploaderPhotos.css';const w = {
58
58
  name: e.file.name,
59
59
  type: e.file.type
60
60
  }));
61
- Promise.all(l).then((e) => {
62
- m((f) => [...f, ...e]), o == null || o({ type: "add", data: t.value });
61
+ Promise.all(o).then((e) => {
62
+ u((c) => [...c, ...e]), l == null || l({ type: "add", data: i.value });
63
63
  });
64
- }, v = (t) => {
65
- m((l) => l.filter((e) => e.id !== t)), o == null || o({ type: "delete", data: t });
64
+ }, w = (i) => {
65
+ u((o) => o.filter((e) => e.id !== i)), l == null || l({ type: "delete", data: i });
66
66
  }, { photos: I, files: O } = K(() => {
67
- const t = () => a.filter((e) => !c(e)), l = () => a.filter(c);
68
- return s === "all" ? { files: t(), photos: l() } : s === "files" ? { photos: [], files: t() } : s === "photos" ? { files: [], photos: l() } : { files: [], photos: [] };
69
- }, [a, s]);
70
- return /* @__PURE__ */ F(
67
+ const i = () => n.filter((e) => !y(e, a)), o = () => n.filter((e) => y(e, a));
68
+ return s === "all" ? { files: i(), photos: o() } : s === "files" ? { photos: [], files: i() } : s === "photos" ? { files: [], photos: o() } : { files: [], photos: [] };
69
+ }, [n, a, s]);
70
+ return /* @__PURE__ */ x(
71
71
  "div",
72
72
  {
73
73
  "data-testid": "universal-uploader",
74
- "data-testid-react": i == null ? void 0 : i.wrapper,
74
+ "data-testid-react": t == null ? void 0 : t.wrapper,
75
75
  className: q(
76
- w["upload-file-wrapper"],
77
- y && w.disabled
76
+ g["upload-file-wrapper"],
77
+ F && g.disabled
78
78
  ),
79
79
  children: [
80
- /* @__PURE__ */ n(
80
+ /* @__PURE__ */ p(
81
81
  Z,
82
82
  {
83
- dataTestIdReactMap: { wrapper: i == null ? void 0 : i.uploader },
84
- filesType: z,
85
- arrayName: P,
86
- maxSize: U,
83
+ dataTestIdReactMap: { wrapper: t == null ? void 0 : t.uploader },
84
+ filesType: a,
85
+ arrayName: z,
86
+ maxSize: P,
87
87
  onChangeValue: C,
88
- ref: x,
89
- maxFiles: d && d - a.length,
90
- isDisabled: y,
91
- titleUploader: b,
92
- showOnlyUploadButton: h,
93
- buttonText: D,
94
- uploadButtonVariant: E,
95
- buttonSize: S,
96
- buttonClassName: V,
97
- onMaxFilesExceeded: N,
98
- onMaxSizeExceeded: B,
99
- onInvalidFileType: _
88
+ ref: d,
89
+ maxFiles: m && m - n.length,
90
+ isDisabled: F,
91
+ titleUploader: U,
92
+ showOnlyUploadButton: v,
93
+ buttonText: b,
94
+ uploadButtonVariant: D,
95
+ buttonSize: E,
96
+ buttonClassName: S,
97
+ onMaxFilesExceeded: L,
98
+ onMaxSizeExceeded: N,
99
+ onInvalidFileType: B,
100
+ accept: A
100
101
  }
101
102
  ),
102
- !h && /* @__PURE__ */ F(k, { children: [
103
- (s === "files" || s === "all") && /* @__PURE__ */ n("div", { "data-testid-react": i == null ? void 0 : i.listFiles, children: /* @__PURE__ */ n(
103
+ !v && /* @__PURE__ */ x(k, { children: [
104
+ (s === "files" || s === "all") && /* @__PURE__ */ p("div", { "data-testid-react": t == null ? void 0 : t.listFiles, children: /* @__PURE__ */ p(
104
105
  W,
105
106
  {
106
107
  value: O,
107
- onChange: (t) => v(t.deleteId),
108
- variant: L
108
+ onChange: (i) => w(i.deleteId),
109
+ variant: V
109
110
  }
110
111
  ) }),
111
- (s === "photos" || s === "all") && /* @__PURE__ */ n("div", { "data-testid-react": i == null ? void 0 : i.listPhotos, children: /* @__PURE__ */ n(
112
+ (s === "photos" || s === "all") && /* @__PURE__ */ p("div", { "data-testid-react": t == null ? void 0 : t.listPhotos, children: /* @__PURE__ */ p(
112
113
  Y,
113
114
  {
114
115
  value: I,
115
- onChange: (t) => v(t.deleteId),
116
- loadImage: j,
117
- isDownloadingImage: A
116
+ onChange: (i) => w(i.deleteId),
117
+ loadImage: _,
118
+ isDownloadingImage: j
118
119
  }
119
120
  ) })
120
121
  ] })
@@ -1,5 +1,4 @@
1
1
  import { default as React } from 'react';
2
- import { imageTypesArr } from './constants';
3
2
  import { TDataTestIdReactMap } from '../../types';
4
3
  import { EButtonSize } from '../Button';
5
4
  import { TButtonDefaultFormProps } from '../Button/types';
@@ -9,7 +8,7 @@ export type TUploader = {
9
8
  * Массив разрешенных типов файлов для настройки валидации
10
9
  * 'jpeg' | 'jpg' | 'png' | 'tiff' | 'gif' | 'heic' | 'doc' | 'xls' | 'pdf' | 'docx' | 'txt' | 'xlsx'
11
10
  */
12
- filesType: imageTypesArr[];
11
+ filesType: string[];
13
12
  /**
14
13
  * Наименование передаваемого массива файлов
15
14
  */
@@ -70,6 +69,7 @@ export type TUploader = {
70
69
  * Объект, для передачи в компонент и его элементы data-testid-react, для автоматизированного тестирования
71
70
  */
72
71
  dataTestIdReactMap?: TDataTestIdReactMap<'wrapper' | 'input' | 'label' | 'button' | 'buttonIcon' | 'title' | 'description'>;
72
+ accept?: Record<string, string>;
73
73
  };
74
74
  export type TUploadValue = {
75
75
  value: TFileItem[];