mimir-ui-kit 1.15.0 → 1.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. package/dist/assets/Image.css +1 -0
  2. package/dist/assets/ListPhotos.css +1 -1
  3. package/dist/assets/SelectSearch.css +1 -1
  4. package/dist/assets/UploaderPhotos.css +1 -1
  5. package/dist/assets/index.css +1 -1
  6. package/dist/components/Image/Image.d.ts +12 -0
  7. package/dist/components/Image/Image.js +42 -15
  8. package/dist/components/ListPhotos/ListPhotos.js +1 -1
  9. package/dist/components/SelectSearch/SelectSearch.d.ts +0 -7
  10. package/dist/components/SelectSearch/SelectSearch.js +3801 -639
  11. package/dist/components/SelectSearch/index.d.ts +1 -1
  12. package/dist/components/SelectSearch/types.d.ts +16 -11
  13. package/dist/components/Slider/Slider.d.ts +2 -0
  14. package/dist/components/Slider/Slider.js +4 -2
  15. package/dist/components/Uploader/Uploader.d.ts +10 -1
  16. package/dist/components/Uploader/Uploader.js +62 -56
  17. package/dist/components/UploaderPhotos/UploaderPhotos.d.ts +10 -1
  18. package/dist/components/UploaderPhotos/UploaderPhotos.js +50 -34
  19. package/dist/components/index.d.ts +1 -3
  20. package/dist/components/index.js +0 -2
  21. package/dist/hooks/index.d.ts +1 -1
  22. package/dist/hooks/index.js +2 -1
  23. package/dist/hooks/useMediaQuery/constants.d.ts +10 -0
  24. package/dist/hooks/useMediaQuery/constants.js +13 -1
  25. package/dist/hooks/useMediaQuery/index.d.ts +1 -1
  26. package/dist/hooks/useMediaQuery/index.js +2 -1
  27. package/dist/index.js +2 -3
  28. package/package.json +1 -1
  29. package/dist/SelectSearchOption-snHM9uZX.js +0 -3796
  30. package/dist/assets/SelectSearchOption.css +0 -1
  31. package/dist/components/SelectSearchOption/SelectSearchOption.d.ts +0 -10
  32. package/dist/components/SelectSearchOption/SelectSearchOption.js +0 -8
  33. package/dist/components/SelectSearchOption/index.d.ts +0 -2
  34. package/dist/components/SelectSearchOption/index.js +0 -4
@@ -1,3 +1,3 @@
1
1
  export { SelectSearch } from './SelectSearch';
2
- export type { TSelectSearchProps } from './types';
2
+ export type { TSelectSearchProps, TSelectOption } from './types';
3
3
  export { ESelectSearchSize } from './constants';
@@ -1,15 +1,21 @@
1
+ import { ReactNode } from 'react';
1
2
  import { ESelectSearchSize } from './constants';
2
- import { VirtualizedFixedSizeListProps } from './SelectSearch';
3
3
 
4
+ export type TSelectOption = {
5
+ name: string;
6
+ id: number | string;
7
+ bottom?: ReactNode;
8
+ [index: string]: unknown;
9
+ };
4
10
  export type TSelectSearchProps = {
5
11
  /**
6
12
  * Текущее выбранное значение.
7
13
  */
8
- value?: Record<string, unknown> | null;
14
+ value?: TSelectOption | null;
9
15
  /**
10
16
  * Функция обратного вызова при изменении выбранного значения.
11
17
  */
12
- onChange?: (value: Record<string, unknown>) => void;
18
+ onChange?: (value: TSelectOption) => void;
13
19
  /**
14
20
  * Текст-подсказка для поля ввода.
15
21
  */
@@ -22,19 +28,18 @@ export type TSelectSearchProps = {
22
28
  * Флаг для растягивания компонента на всю ширину контейнера.
23
29
  */
24
30
  full?: boolean;
25
- /**
26
- * Дочерние элементы компонента.
27
- */
28
- children?: React.ReactNode;
29
- /**
30
- * Свойства для виртуализированного списка фиксированного размера.
31
- */
32
- virtualizedFixedSizeList?: VirtualizedFixedSizeListProps;
33
31
  /**
34
32
  * Значение, отображаемое в поле выбора.
35
33
  */
36
34
  displayValue?: string;
35
+ /** Показывать ли иконку стрелки выпадающего списка */
37
36
  showArrow?: boolean;
37
+ /** Функция обратного вызова, срабатывающая при изменении поискового запроса */
38
38
  onSearch?: (value: string) => void;
39
+ /** Фильтровать ли варианты на основе поискового запроса */
39
40
  filterOnSearch?: boolean;
41
+ /** Значения, передаваемые в SelectSearch */
42
+ items: TSelectOption[];
43
+ /** Класснейм для значения */
44
+ classNameOption?: string;
40
45
  };
@@ -21,6 +21,8 @@ type TProps = {
21
21
  */
22
22
  images?: {
23
23
  image?: string;
24
+ imageDesktop?: string;
25
+ imageMobile?: string;
24
26
  url?: string;
25
27
  id?: number;
26
28
  }[];
@@ -323,7 +323,7 @@ const Slider = ({
323
323
  swiperClassName,
324
324
  slideClassName,
325
325
  imageClassName,
326
- delay = 3e3
326
+ delay = 3e5
327
327
  }) => {
328
328
  const progressBar = useRef(null);
329
329
  const swiperRef = useRef(null);
@@ -401,7 +401,9 @@ const Slider = ({
401
401
  AppImage,
402
402
  {
403
403
  className: classNames(cls.image, imageClassName),
404
- src: img.image
404
+ src: img.image,
405
+ desktopImage: img.imageDesktop,
406
+ mobileImage: img.imageMobile
405
407
  }
406
408
  )
407
409
  },
@@ -1,3 +1,4 @@
1
+ import { default as React } from 'react';
1
2
  import { imageTypesArr } from './constants';
2
3
 
3
4
  export type TUploader = {
@@ -18,6 +19,14 @@ export type TUploader = {
18
19
  * Максимальный размер файлов.
19
20
  */
20
21
  maxSize: number;
22
+ /**
23
+ * Максимальное количество файлов.
24
+ */
25
+ maxFiles: number;
26
+ /**
27
+ * Выключен ли Uploader или нет
28
+ */
29
+ isDisabled?: boolean;
21
30
  };
22
31
  export type TUploadValue = {
23
32
  value: TFileItem[];
@@ -27,4 +36,4 @@ export type TFileItem = {
27
36
  id: number;
28
37
  file: File;
29
38
  };
30
- export declare function Uploader({ filesType, onChangeValue, arrayName, maxSize }: TUploader): import("react/jsx-runtime").JSX.Element;
39
+ export declare const Uploader: React.ForwardRefExoticComponent<TUploader & React.RefAttributes<HTMLDivElement>>;
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useId, useRef } from "react";
2
+ import { forwardRef, useRef, useId } from "react";
3
3
  import { Icon } from "../../icons/Icon.js";
4
4
  import { Button } from "../Button/Button.js";
5
5
  import '../../assets/Uploader.css';const cls = {
@@ -25,67 +25,73 @@ const filesTyps = ["jpeg", "jpg", "png", "tiff", "gif"];
25
25
  const generateId = (min, max) => {
26
26
  return Math.random() * (max - min) + min;
27
27
  };
28
- function Uploader({
29
- filesType = filesTyps,
30
- onChangeValue,
31
- arrayName,
32
- maxSize = 15
33
- }) {
34
- const idImg = useId();
35
- const ref = useRef(null);
36
- const onChange = (e) => {
37
- if (e.target.files && e.target.files[0]) {
38
- const list = [];
39
- Array.from(e.target.files).forEach((el) => {
40
- if (filesType.map((name) => MIME[name]).includes(el.type) && el.size / 1024 ** 2 <= maxSize) {
41
- list.push({ file: el, id: generateId(1, 100) });
42
- }
43
- });
44
- onChangeValue({ arrayName, value: list });
45
- }
46
- };
47
- const onOpen = () => {
48
- var _a;
49
- (_a = ref.current) == null ? void 0 : _a.click();
50
- };
51
- return /* @__PURE__ */ jsxs("div", { className: cls["upload-file__wrapper"], children: [
52
- /* @__PURE__ */ jsx(
53
- "input",
54
- {
55
- type: "file",
56
- className: cls["upload-file-input"],
57
- "aria-label": "Upload",
58
- name: "image[]",
59
- multiple: true,
60
- onChange,
61
- title: "",
62
- id: idImg,
63
- accept: filesType.map((i) => MIME[i]).join()
28
+ const Uploader = forwardRef(
29
+ (props, ref) => {
30
+ const {
31
+ filesType = filesTyps,
32
+ onChangeValue,
33
+ arrayName,
34
+ maxSize = 15,
35
+ isDisabled
36
+ } = props;
37
+ const uploaderRef = useRef(null);
38
+ const idImg = useId();
39
+ const onChange = (e) => {
40
+ if (e.target.files && e.target.files[0]) {
41
+ const list = [];
42
+ Array.from(e.target.files).forEach((el) => {
43
+ if (filesType.map((name) => MIME[name]).includes(el.type) && el.size / 1024 ** 2 <= maxSize) {
44
+ list.push({ file: el, id: generateId(1, 100) });
45
+ }
46
+ });
47
+ onChangeValue({ arrayName, value: list });
64
48
  }
65
- ),
66
- /* @__PURE__ */ jsxs("label", { htmlFor: idImg, ref, children: [
49
+ };
50
+ const onOpen = () => {
51
+ var _a;
52
+ (_a = uploaderRef.current) == null ? void 0 : _a.click();
53
+ };
54
+ return /* @__PURE__ */ jsxs("div", { className: cls["upload-file__wrapper"], ref, children: [
67
55
  /* @__PURE__ */ jsx(
68
- Button,
56
+ "input",
69
57
  {
70
- size: "m",
71
- variant: "secondary-asphalt",
72
- leftIcon: /* @__PURE__ */ jsx(Icon, { iconName: "UnionIcon16px" }),
73
- onClick: onOpen,
74
- children: "Выберите файлы"
58
+ type: "file",
59
+ className: cls["upload-file-input"],
60
+ "aria-label": "Upload",
61
+ name: "image[]",
62
+ multiple: true,
63
+ onChange,
64
+ title: "",
65
+ id: idImg,
66
+ accept: filesType.map((i) => MIME[i]).join(),
67
+ disabled: isDisabled
75
68
  }
76
69
  ),
77
- /* @__PURE__ */ jsx("b", { children: "Или перетащие сюда" }),
78
- /* @__PURE__ */ jsxs("span", { className: cls["upload-text"], children: [
79
- "Максимальный размер одного файла – ",
80
- maxSize,
81
- " Мб",
82
- /* @__PURE__ */ jsx("br", {}),
83
- "Загрузить можно файлы следующих форматов: ",
84
- filesType.join(", ")
70
+ /* @__PURE__ */ jsxs("label", { htmlFor: idImg, ref: uploaderRef, children: [
71
+ /* @__PURE__ */ jsx(
72
+ Button,
73
+ {
74
+ size: "m",
75
+ variant: "secondary-asphalt",
76
+ leftIcon: /* @__PURE__ */ jsx(Icon, { iconName: "UnionIcon16px" }),
77
+ onClick: onOpen,
78
+ disabled: isDisabled,
79
+ children: "Выберите файлы"
80
+ }
81
+ ),
82
+ /* @__PURE__ */ jsx("b", { children: "Или перетащите сюда" }),
83
+ /* @__PURE__ */ jsxs("span", { className: cls["upload-text"], children: [
84
+ "Максимальный размер одного файла – ",
85
+ maxSize,
86
+ " Мб",
87
+ /* @__PURE__ */ jsx("br", {}),
88
+ "Загрузить можно файлы следующих форматов: ",
89
+ filesType.join(", ")
90
+ ] })
85
91
  ] })
86
- ] })
87
- ] });
88
- }
92
+ ] });
93
+ }
94
+ );
89
95
  export {
90
96
  Uploader
91
97
  };
@@ -1,3 +1,4 @@
1
+ import { TPhotosDetail } from '../ListPhotos/ListPhotos';
1
2
  import { imageTypesArr } from '../Uploader/constants';
2
3
  import { TFileItem } from '../Uploader/Uploader';
3
4
 
@@ -21,9 +22,17 @@ export type TUploaderPhotos = {
21
22
  * type:'delete' в data передает id удаленного файла
22
23
  */
23
24
  onChange: (j: TOnChangePhotosUpdate) => void;
25
+ /**
26
+ * Передаваемые файлы.
27
+ */
28
+ value?: TPhotosDetail[];
29
+ /**
30
+ * Максимальное количество файлов.
31
+ */
32
+ maxFiles: number;
24
33
  };
25
34
  export type TOnChangePhotosUpdate = {
26
35
  type: string;
27
36
  data: TFileItem[] | number;
28
37
  };
29
- export declare function UploaderPhotos({ filesType, arrayName, maxSize, onChange }: TUploaderPhotos): import("react/jsx-runtime").JSX.Element;
38
+ export declare const UploaderPhotos: import('react').ForwardRefExoticComponent<TUploaderPhotos & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,46 +1,62 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useState } from "react";
2
+ import { c as classNames } from "../../index-CweZ_OcN.js";
3
+ import { forwardRef, useState, useEffect } from "react";
3
4
  import { ListPhotos } from "../ListPhotos/ListPhotos.js";
4
5
  import { Uploader } from "../Uploader/Uploader.js";
5
6
  import '../../assets/UploaderPhotos.css';const cls = {
6
- "upload-file__wrapper": "_upload-file__wrapper_udscq_2"
7
+ "upload-file__wrapper": "_upload-file__wrapper_17bcu_2"
7
8
  };
8
- function UploaderPhotos({
9
- filesType,
10
- arrayName,
11
- maxSize,
12
- onChange
13
- }) {
14
- const [photos, setPhotos] = useState([]);
15
- const onChangeValue = (e) => {
16
- setPhotos([
17
- ...photos,
18
- ...e.value.map((el) => {
19
- return {
9
+ const UploaderPhotos = forwardRef(
10
+ (props, ref) => {
11
+ const { filesType, arrayName, maxSize, onChange, value, maxFiles } = props;
12
+ const [photos, setPhotos] = useState(value || []);
13
+ const isMaxFilesReached = photos.length >= maxFiles;
14
+ useEffect(() => {
15
+ if (value) {
16
+ setPhotos(value);
17
+ }
18
+ }, [value]);
19
+ const onChangeValue = (e) => {
20
+ const newPhotos = [
21
+ ...photos,
22
+ ...e.value.map((el) => ({
20
23
  url: URL.createObjectURL(el.file),
21
24
  id: el.id
22
- };
23
- })
24
- ]);
25
- onChange == null ? void 0 : onChange({ type: "add", data: e.value });
26
- };
27
- const onDelete = (j) => {
28
- setPhotos(j.list);
29
- if (j.deleteId) onChange == null ? void 0 : onChange({ type: "delete", data: j.deleteId });
30
- };
31
- return /* @__PURE__ */ jsxs("div", { className: cls["upload-file__wrapper"], children: [
32
- /* @__PURE__ */ jsx(
33
- Uploader,
25
+ }))
26
+ ];
27
+ setPhotos(newPhotos);
28
+ onChange == null ? void 0 : onChange({ type: "add", data: e.value });
29
+ };
30
+ const onDelete = (j) => {
31
+ setPhotos(j.list);
32
+ if (j.deleteId) onChange == null ? void 0 : onChange({ type: "delete", data: j.deleteId });
33
+ };
34
+ return /* @__PURE__ */ jsxs(
35
+ "div",
34
36
  {
35
- filesType,
36
- arrayName,
37
- maxSize,
38
- onChangeValue
37
+ className: classNames(
38
+ cls["upload-file__wrapper"],
39
+ isMaxFilesReached && cls.disabled
40
+ ),
41
+ children: [
42
+ /* @__PURE__ */ jsx(
43
+ Uploader,
44
+ {
45
+ filesType,
46
+ arrayName,
47
+ maxSize,
48
+ onChangeValue,
49
+ ref,
50
+ maxFiles,
51
+ isDisabled: isMaxFilesReached
52
+ }
53
+ ),
54
+ /* @__PURE__ */ jsx(ListPhotos, { value: photos, onChange: onDelete })
55
+ ]
39
56
  }
40
- ),
41
- /* @__PURE__ */ jsx(ListPhotos, { value: photos, onChange: onDelete })
42
- ] });
43
- }
57
+ );
58
+ }
59
+ );
44
60
  export {
45
61
  UploaderPhotos
46
62
  };
@@ -20,9 +20,7 @@ export { EDrawerPosition } from './Drawer';
20
20
  export { Steps, EStepsPrimaryColor, EStepsSecondaryColor, EStepsSize, type TCommonStepsProps } from './Steps';
21
21
  export { Vote, EVoteSize, type TCommonVoteProps } from './Vote';
22
22
  export { SelectSearch, ESelectSearchSize } from './SelectSearch';
23
- export type { TSelectSearchProps } from './SelectSearch';
24
- export { SelectSearchOption } from './SelectSearchOption';
25
- export type { SelectSearchOptionProps } from './SelectSearchOption';
23
+ export type { TSelectSearchProps, TSelectOption } from './SelectSearch';
26
24
  export { Switch } from './Switch';
27
25
  export type { TSwitchProps } from './Switch';
28
26
  export { Tag, ETagSize, ETagType } from './Tag';
@@ -21,7 +21,6 @@ import { Vote } from "./Vote/Vote.js";
21
21
  import { EVoteSize } from "./Vote/constants.js";
22
22
  import { SelectSearch } from "./SelectSearch/SelectSearch.js";
23
23
  import { ESelectSearchSize } from "./SelectSearch/constants.js";
24
- import { S } from "../SelectSearchOption-snHM9uZX.js";
25
24
  import { Switch } from "./Switch/Switch.js";
26
25
  import { Tag } from "./Tag/Tag.js";
27
26
  import { ETagSize, ETagType } from "./Tag/constants.js";
@@ -73,7 +72,6 @@ export {
73
72
  Pagination,
74
73
  RadioGroup,
75
74
  SelectSearch,
76
- S as SelectSearchOption,
77
75
  Slider,
78
76
  Steps,
79
77
  Switch,
@@ -1,4 +1,4 @@
1
- export { useMediaQuery, EMediaQuery } from './useMediaQuery';
1
+ export { useMediaQuery, EMediaQuery, EMinMediaQuery } from './useMediaQuery';
2
2
  export { useLockBodyScroll } from './useLockBodyScroll';
3
3
  export { useInterval } from './useInterval';
4
4
  export { useTimer } from './useTimer';
@@ -1,11 +1,12 @@
1
1
  import { useMediaQuery } from "./useMediaQuery/useMediaQuery.js";
2
- import { EMediaQuery } from "./useMediaQuery/constants.js";
2
+ import { EMediaQuery, EMinMediaQuery } from "./useMediaQuery/constants.js";
3
3
  import { useLockBodyScroll } from "./useLockBodyScroll/useLockBodyScroll.js";
4
4
  import { useInterval } from "./useInterval/useInterval.js";
5
5
  import { useTimer } from "./useTimer/index.js";
6
6
  import { useCopyToClipboard } from "./useCopyToClipboard/useCopyToClipboard.js";
7
7
  export {
8
8
  EMediaQuery,
9
+ EMinMediaQuery,
9
10
  useCopyToClipboard,
10
11
  useInterval,
11
12
  useLockBodyScroll,
@@ -8,3 +8,13 @@ export declare enum EMediaQuery {
8
8
  XL = "(max-width: 1440px)",
9
9
  XXL = "(max-width: 1920px)"
10
10
  }
11
+ export declare enum EMinMediaQuery {
12
+ XSS = "(min-width: 375px)",
13
+ XS = "(min-width: 600px)",
14
+ XS1 = "(min-width: 767px)",
15
+ S = "(min-width: 768px)",
16
+ M = "(min-width: 960px)",
17
+ L = "(min-width: 1280px)",
18
+ XL = "(min-width: 1440px)",
19
+ XXL = "(min-width: 1920px)"
20
+ }
@@ -9,6 +9,18 @@ var EMediaQuery = /* @__PURE__ */ ((EMediaQuery2) => {
9
9
  EMediaQuery2["XXL"] = "(max-width: 1920px)";
10
10
  return EMediaQuery2;
11
11
  })(EMediaQuery || {});
12
+ var EMinMediaQuery = /* @__PURE__ */ ((EMinMediaQuery2) => {
13
+ EMinMediaQuery2["XSS"] = "(min-width: 375px)";
14
+ EMinMediaQuery2["XS"] = "(min-width: 600px)";
15
+ EMinMediaQuery2["XS1"] = "(min-width: 767px)";
16
+ EMinMediaQuery2["S"] = "(min-width: 768px)";
17
+ EMinMediaQuery2["M"] = "(min-width: 960px)";
18
+ EMinMediaQuery2["L"] = "(min-width: 1280px)";
19
+ EMinMediaQuery2["XL"] = "(min-width: 1440px)";
20
+ EMinMediaQuery2["XXL"] = "(min-width: 1920px)";
21
+ return EMinMediaQuery2;
22
+ })(EMinMediaQuery || {});
12
23
  export {
13
- EMediaQuery
24
+ EMediaQuery,
25
+ EMinMediaQuery
14
26
  };
@@ -1,2 +1,2 @@
1
1
  export { useMediaQuery } from './useMediaQuery';
2
- export { EMediaQuery } from './constants';
2
+ export { EMediaQuery, EMinMediaQuery } from './constants';
@@ -1,6 +1,7 @@
1
1
  import { useMediaQuery } from "./useMediaQuery.js";
2
- import { EMediaQuery } from "./constants.js";
2
+ import { EMediaQuery, EMinMediaQuery } from "./constants.js";
3
3
  export {
4
4
  EMediaQuery,
5
+ EMinMediaQuery,
5
6
  useMediaQuery
6
7
  };
package/dist/index.js CHANGED
@@ -21,7 +21,6 @@ import { Vote } from "./components/Vote/Vote.js";
21
21
  import { EVoteSize } from "./components/Vote/constants.js";
22
22
  import { SelectSearch } from "./components/SelectSearch/SelectSearch.js";
23
23
  import { ESelectSearchSize } from "./components/SelectSearch/constants.js";
24
- import { S } from "./SelectSearchOption-snHM9uZX.js";
25
24
  import { Switch } from "./components/Switch/Switch.js";
26
25
  import { Tag } from "./components/Tag/Tag.js";
27
26
  import { ETagSize, ETagType } from "./components/Tag/constants.js";
@@ -38,7 +37,7 @@ import { EToastPosition, EToastVariant } from "./components/Toasts/constants.js"
38
37
  import { UploaderPhotos } from "./components/UploaderPhotos/UploaderPhotos.js";
39
38
  import { Uploader } from "./components/Uploader/Uploader.js";
40
39
  import { useMediaQuery } from "./hooks/useMediaQuery/useMediaQuery.js";
41
- import { EMediaQuery } from "./hooks/useMediaQuery/constants.js";
40
+ import { EMediaQuery, EMinMediaQuery } from "./hooks/useMediaQuery/constants.js";
42
41
  import { useLockBodyScroll } from "./hooks/useLockBodyScroll/useLockBodyScroll.js";
43
42
  import { useInterval } from "./hooks/useInterval/useInterval.js";
44
43
  import { useTimer } from "./hooks/useTimer/index.js";
@@ -62,6 +61,7 @@ import './assets/index.css';export {
62
61
  EInputVariant,
63
62
  EMediaQuery,
64
63
  EMergedButtonVariantRound,
64
+ EMinMediaQuery,
65
65
  ESelectSearchSize,
66
66
  EStepsPrimaryColor,
67
67
  EStepsSecondaryColor,
@@ -83,7 +83,6 @@ import './assets/index.css';export {
83
83
  Pagination,
84
84
  RadioGroup,
85
85
  SelectSearch,
86
- S as SelectSearchOption,
87
86
  Slider,
88
87
  Steps,
89
88
  Switch,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.15.0",
4
+ "version": "1.15.2",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {